当前位置:   article > 正文

网页MarkDown

网页MarkDown
<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<div th:fragment="writepage">
	<a href="/admin"><span>文章管理</span></a>
	<button id='btn'>发布</button>
	<textarea id="editMD">
	</textarea>
</div>

<div th:fragment="markdownsettings">
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
	<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
	<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">
	<!--markdown图标  https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css-->
	<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
	<script>
		var simplemde = new SimpleMDE({
			element: document.getElementById("editMD"),
			//spellChecker: false,
			autofocus: true,
			autoDownloadFontAwesome: false,
			placeholder: "Type here...",
			autosave: {
				enabled: true,
				uniqueId: "yctop", //必须设置
				delay: 1000, 时间间隔默认 10s
			},
			tabSize: 4,
			status: false,
			lineWrapping: false,
			renderingConfig: {
				codeSyntaxHighlighting: true //代码高亮??
			},
			shortcuts: {
				drawTable: "Alt-T"  //表格快捷键
			},
			toolbar: [{
				name: "bold",
				action: SimpleMDE.toggleBold,
				className: "fa fa-bold",
				title: "加粗",
			},
				{
					name: "italic",
					action: SimpleMDE.toggleItalic,
					className: "fa fa-italic",
					title: "斜体",
				},
				"|", // Separato
				{
					name: "heading",
					action: SimpleMDE.toggleHeadingSmaller,
					className: "fa fa-header",
					title: "标题",
				},
				{
					name: "strikethrough",
					action: SimpleMDE.toggleStrikethrough,
					className: "fa fa-strikethrough",
					title: "删除线",
				},
				{
					name: "unordered-list",
					action: SimpleMDE.toggleUnorderedList,
					className: "fa fa-list-ul",
					title: "无序",
				},
				{
					name: "ordered-list",
					action: SimpleMDE.toggleOrderedList,
					className: "fa fa-list-ol",
					title: "有序",
				},
				{
					name: "quotet",
					action: SimpleMDE.toggleBlockquote,
					className: "fa fa-quote-left",
					title: "引用",
				},
				{
					name: "code",
					action: SimpleMDE.toggleCodeBlock,
					className: "fa fa-code",
					title: "有序",
				},
				{
					name: "preview",
					action: SimpleMDE.togglePreview,
					className: "fa fa-eye no-disable",
					title: "显示效果",
				},
				{
					name: "image",
					action: SimpleMDE.drawImage,
					className: "fa fa-picture-o",
					title: "图片",
				},
				{
					name: "table",
					action: SimpleMDE.drawTable,
					className: "fa fa-table",
					title: "表格",
				},
				{
					name: "horizontal-rule",
					action: SimpleMDE.drawHorizontalRule,
					className: "fa fa-minus",
					title: "水平线",
				},
				{
					name: "link",
					action: SimpleMDE.drawLink,
					className: "fa fa-link",
					title: "链接",
				},
				{
					name: "guide",
					action: "https://simplemde.com/markdown-guide",
					className: "fa fa-question-circle",
					title: "指南",
				},
				{
					name: "fullscreen",
					action: SimpleMDE.toggleFullScreen,
					className: "fa fa-arrows-alt no-disable no-mobile",
					title: "全屏",
				},

			]

		});
		//simplemde.toggleSideBySide()  // 打开时启动全屏 AND 预览

		var val=simplemde.value();
		var html=simplemde.markdown(simplemde.value());
		btn.onclick=function(){  //发布文章  按钮
			/**alert(simplemde.value());
			 alert(val);
			 alert(simplemde.markdown(simplemde.value()));
			 simplemde.value(' 修改了');*/
		}

	</script>
</div>



</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/197189
推荐阅读
相关标签
  

闽ICP备14008679号