当前位置:网站首页>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 :

边栏推荐
- Vscode编辑器右键没有Open In Default Browser选项
- Crawler career from scratch (V): detailed explanation of re regular expression
- Vscode Arduino installation Library
- Flink学习笔记(十一)Table API 和 SQL
- [graduation season | advanced technology Er] another graduation season, I change my career as soon as I graduate, from animal science to programmer. Programmers have something to say in 10 years
- C language programming specification
- Flink学习笔记(十)Flink容错机制
- Go language - Reflection
- [untitled] use of cmake
- Quickly use markdown to edit articles
猜你喜欢

【Kotlin学习】运算符重载及其他约定——重载算术运算符、比较运算符、集合与区间的约定

Win10 install elk

Trial of the combination of RDS and crawler

Spark 结构化流写入Hudi 实践

Beego learning - Tencent cloud upload pictures

Jenkins learning (III) -- setting scheduled tasks

Go language - Reflection

Crawler career from scratch (IV): climb the bullet curtain of station B through API

软件测试工程师是做什么的 通过技术测试软件程序中是否有漏洞

PolyWorks script development learning notes (III) -treeview advanced operation
随机推荐
CATIA automation object architecture - detailed explanation of application objects (I) document/settingcontrollers
C language programming specification
Crawler career from scratch (IV): climb the bullet curtain of station B through API
一款开源的Markdown转富文本编辑器的实现原理剖析
LeetCode每日一题(1856. Maximum Subarray Min-Product)
LeetCode每日一题(931. Minimum Falling Path Sum)
Long类型的相等判断
Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 2 --blinker_ Hello_ WiFi (lighting technology - Mobile App control routine)
Spark 概述
Liteide is easy to use
Common formulas of probability theory
Hudi quick experience (including detailed operation steps and screenshots)
Jenkins learning (II) -- setting up Chinese
There is no open in default browser option in the right click of the vscade editor
Flink学习笔记(十一)Table API 和 SQL
Word segmentation in full-text indexing
[set theory] order relation (chain | anti chain | chain and anti chain example | chain and anti chain theorem | chain and anti chain inference | good order relation)
Idea uses the MVN command to package and report an error, which is not available
On February 14, 2022, learn the imitation Niuke project - develop the registration function
【Kotlin疑惑】在Kotlin类中重载一个算术运算符,并把该运算符声明为扩展函数会发生什么?