当前位置:网站首页>Solve editor MD uploads pictures and cannot get the picture address
Solve editor MD uploads pictures and cannot get the picture address
2022-07-03 09:32:00 【Technology stuff】
Editor.md The picture address cannot be obtained by uploading the picture ,Editor.md Image upload iframe Cross domain situation exists , It is not easy to use after several debugging , Finally, take the alternative , There is no cross domain situation yet .
Support in recent projects markdown Editor , At present, there is no one who doesn't know about technology Markdown Of , Because it's so powerful , You only need to know a few simple operations , You can edit very beautiful articles , Include TeX Scientific formula ( be based on KaTeX)、 flow chart Flowchart and Sequence diagram , No longer let you waste time on format adjustment .
background
Is in PC End use , Directly introducing JQuery and Markdown.md Plug in for use
editor.md catalogue
Here we need to explain editor.md Catalog , The version introduced in this article is v1.5.0, Download on the home page , decompression editor.md-master.zip file , You can see the directory structure as shown in the figure below :

The red box in the figure shows the files and directories we want to reference to the project .
- css You can select... From the directory editormd.min.css Put it in the corresponding item css Directory ;
- js Can choose editormd.min.js Placed in the corresponding item js Directory , It should be noted that at the same time jQuery, Use here jquery.min.js;
- examples Folders are part of the core functions demo, Use the corresponding components or functions in the process of use to open the reference ;
- fonts Need to use fonts , Items can be imported together ;
- images Are some pictures of loading classes ;
- lib yes editor.md Relying on a third party js resources , Such as flow chart js resources ;
- plugins It is mainly the operation function plug-in on the editor , For example, image upload and so on , You can choose to use to load ;
Import to web The contents of the project are as follows :

Files to be imported in the page , Add other plug-ins as needed
<!-- Add... To the page css -->
<link rel="stylesheet" href="./css/style.css" />
<link rel="stylesheet" href="./css/editormd.css" />
<!-- Add... To the page div -->
<div id="editormd">
<textarea style="display:none;">### Hello Editor.md !</textarea>
</div>
<!-- Add... To the page js -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/[email protected]"></script>
<script type="text/javascript" src="js/editormd.min.js"></script>
<script type="text/javascript" src="js/[email protected]"></script>
<script>
var testEditor = editormd("editormd", {
width: "90%",
height: 'calc(100vh - 85px)',
path : './lib/',
// theme : "dark",
// previewTheme : "dark",
// editorTheme : "pastel-on-dark",
// markdown : content?content:' ',
markdown : content,
codeFold : true,
//syncScrolling : false,
saveHTMLToTextarea : true, // preservation HTML To Textarea
searchReplace : true,
//watch : false, // Turn off live preview
htmlDecode : "style,script,iframe|on*", // Turn on HTML Label parsing , For safety reasons , Not on by default
//toolbar : false, // Close the toolbar
//previewCodeHighlight : false, // Close the preview HTML Block of code highlighted , Default on
emoji : true,
taskList : true,
tocm : true, // Using [TOCM]
tex : true, // Unlock the scientific formula TeX Language support , Off by default
flowChart : true, // Enable flow chart support , Off by default
sequenceDiagram : true, // Open the timing / Sequence diagram support , Off by default ,
//dialogLockScreen : false, // Set the pop-up layer dialog box to leave the screen unlocked , The global general , The default is true
//dialogShowMask : false, // Set the pop-up layer dialog box to display the transparent mask layer , The global general , The default is true
//dialogDraggable : false, // The setup pop-up layer dialog box cannot be dragged , The global general , The default is true
//dialogMaskOpacity : 0.4, // Sets the transparency of the transparent mask layer , The global general , The default value is 0.1
//dialogMaskBgColor : "#000", // Sets the background color of the transparent mask layer , The global general , The default is #fff
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL : "https://api.xxxx.com/api/v1/editorMdImgUpload",
onload : function() {
/* After uploading pictures successfully, you can do your own processing */
console.log('onload', this);
//this.fullscreen();
//this.unwatch();
//this.watch().fullscreen();
//this.setMarkdown("#PHP");
//this.width("100%");
//this.height(480);
//this.resize("100%", 640);
}
});
</script>
Copy code id by editormd, hinder js The code needs to use . And this is also used as a prefix in the source code .
adopt form When a form is submitted, the background can pass content-editormd-markdown-doc Get the corresponding markdown Document content . such as Java Pass through request.getParameter(“content-editormd-markdown-doc”) Be careful : Note here , Whatever you need html The content of the format is still markdown Content of format , You only need to write one textarea. There is a big hole here . Many other tutorials say you need two textarea, Then it will lead to the latter textarea The data obtained in the background is an array , Instead of just HTML Content .
Edit configuration in the editor : path The path needs to be specified to the corresponding... In the project lib The path of . If the settings are not correct markdown It can't be rendered .
saveHTMLToTextarea Set to true Express , Turn into html The content in the format is also submitted to the background .
good , Here you can see the page effect . as follows :

边栏推荐
- Jestson Nano自定义根文件系统创建(支持NVIDIA图形库的最小根文件系统)
- Detailed steps of windows installation redis
- Jetson Nano 自定义启动图标kernel Logo cboot logo
- ERROR: certificate common name “*.” doesn’t match requested ho
- [kotlin learning] classes, objects and interfaces - classes with non default construction methods or attributes, data classes and class delegates, object keywords
- 【Kotlin学习】类、对象和接口——带非默认构造方法或属性的类、数据类和类委托、object关键字
- Utilisation de hudi dans idea
- 文件系统中的目录与切换操作
- unbuntu(debian)下TFTP服务器搭建及测试
- Spark cluster installation and deployment
猜你喜欢

Win10安装ELK
![[point cloud processing paper crazy reading frontier version 11] - unsupervised point cloud pre training via occlusion completion](/img/76/b92fe4549cacba15c113993a07abb8.png)
[point cloud processing paper crazy reading frontier version 11] - unsupervised point cloud pre training via occlusion completion

Django operates Excel files through openpyxl to import data into the database in batches.

2022-2-13 learning the imitation Niuke project - home page of the development community

LeetCode每日一题(931. Minimum Falling Path Sum)

Detailed steps of windows installation redis

图像修复方法研究综述----论文笔记

LeetCode每日一题(1162. As Far from Land as Possible)

Flask+supervisor installation realizes background process resident

LeetCode每日一题(2090. K Radius Subarray Averages)
随机推荐
Esp32 at command does not respond
PIP configuring domestic sources
Principles of computer composition - cache, connection mapping, learning experience
Explanation of the answers to the three questions
Redis learning (I)
Alibaba cloud notes for the first time
unbuntu(debian)下TFTP服务器搭建及测试
LeetCode每日一题(745. Prefix and Suffix Search)
LeetCode每日一题(1362. Closest Divisors)
PolyWorks script development learning notes (III) -treeview advanced operation
[solution to the new version of Flink without bat startup file]
Filter comments to filter out uncommented and default values
Beego learning - JWT realizes user login and registration
[point cloud processing paper crazy reading frontier edition 13] - gapnet: graph attention based point neural network for exploring local feature
Failed building wheel for argon2 cffi when installing Jupiter
ERROR: certificate common name “*.” doesn’t match requested ho
Notes on numerical analysis (II): numerical solution of linear equations
2022-2-13 learning xiangniuke project - version control
LeetCode每日一题(516. Longest Palindromic Subsequence)
LeetCode每日一题(2090. K Radius Subarray Averages)