update cherry-markdown and update editormd code block style (#888)

* fix: first open document, cherryMarkdown not have theme

* fix: modify prismjs style and improve image clarity

* update cherry-markdown

* optimiztion: cherry-markdown

* feat: cherry-markdown add auto-save and update icon

---------

Co-authored-by: zhangsheng.93 <zhangsheng.93@bytedance.com>
pull/914/head
张胜 2023-08-21 02:09:47 -05:00 committed by GitHub
parent 5011aa964f
commit 2e3aebe315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 75026 additions and 67670 deletions

View File

@ -68,6 +68,10 @@ func (c *DocumentController) Index() {
c.Data["Description"] = utils.AutoSummary(doc.Release, 120) c.Data["Description"] = utils.AutoSummary(doc.Release, 120)
c.Data["FoldSetting"] = "first" c.Data["FoldSetting"] = "first"
if bookResult.Editor == EditorCherryMarkdown {
c.Data["MarkdownTheme"] = doc.MarkdownTheme
}
if bookResult.IsDisplayComment { if bookResult.IsDisplayComment {
// 获取评论、分页 // 获取评论、分页
comments, count, _ := models.NewComment().QueryCommentByDocumentId(doc.DocumentId, 1, conf.PageSize, c.Member) comments, count, _ := models.NewComment().QueryCommentByDocumentId(doc.DocumentId, 1, conf.PageSize, c.Member)

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -53,7 +53,7 @@ function addPostMessageListener(graphEditor) {
case 'getData': case 'getData':
editorUIInstance.editor.graph.stopEditing(); editorUIInstance.editor.graph.stopEditing();
var xmlData = mxUtils.getXml(editorUIInstance.editor.getGraphXml()); var xmlData = mxUtils.getXml(editorUIInstance.editor.getGraphXml());
editorUIInstance.exportImage(1, "#ffffff", true, null, true, 50, null, "png", function (base64, filename) { editorUIInstance.exportImage(2, "#ffffff", true, null, true, 50, null, "png", function (base64, filename) {
window.parent.postMessage({ window.parent.postMessage({
mceAction: 'getData:success', mceAction: 'getData:success',
eventName: 'getData:success', eventName: 'getData:success',

Binary file not shown.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 270 KiB

After

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -106,27 +106,28 @@ $(function () {
* cherry * cherry
*/ */
var customMenuB = Cherry.createMenuHook('', { var customMenuB = Cherry.createMenuHook('', {
iconName: '', iconName: 'publish',
onClick: releaseDocument, onClick: releaseDocument,
}); });
var customMenuC = Cherry.createMenuHook("返回", { var customMenuC = Cherry.createMenuHook("返回", {
iconName: '', iconName: 'back',
onClick: backWard, onClick: backWard,
}) })
var customMenuD = Cherry.createMenuHook('', { var customMenuD = Cherry.createMenuHook('', {
iconName: '', id: "markdown-save",
iconName: 'save',
onClick: saveDocument, onClick: saveDocument,
}); });
var customMenuE = Cherry.createMenuHook('', { var customMenuE = Cherry.createMenuHook('', {
iconName: '', iconName: 'sider',
onClick: siderChange, onClick: siderChange,
}); });
var customMenuF = Cherry.createMenuHook('', { var customMenuF = Cherry.createMenuHook('', {
iconName: '', iconName: 'history',
onClick: showHistory, onClick: showHistory,
}); });
@ -191,6 +192,9 @@ $(function () {
toolbars: { toolbars: {
toolbar: [ toolbar: [
'customMenuCName', 'customMenuCName',
'customMenuDName',
'customMenuBName',
'customMenuEName',
'undo', 'undo',
'redo', 'redo',
'bold', 'bold',
@ -219,16 +223,11 @@ $(function () {
'togglePreview', 'togglePreview',
'settings', 'settings',
'switchModel', 'switchModel',
'codeTheme',
'export', 'export',
'customMenuDName',
'customMenuBName',
'customMenuEName',
'customMenuFName', 'customMenuFName',
'theme'
], ],
bubble: ['bold', 'italic', 'underline', 'strikethrough', 'sub', 'sup', 'quote', 'ruby', '|', 'size', 'color'], // array or false bubble: ['bold', 'italic', 'underline', 'strikethrough', 'sub', 'sup', 'quote', 'ruby', '|', 'size', 'color'], // array or false
sidebar: ['mobilePreview', 'copy', 'theme'], sidebar: ['mobilePreview', 'copy', 'codeTheme', 'theme'],
customMenu: { customMenu: {
customMenuAName: customMenuA, customMenuAName: customMenuA,
customMenuBName: customMenuB, customMenuBName: customMenuB,
@ -258,6 +257,9 @@ $(function () {
//var markdownarea = document.getElementById("markdown_area").value //var markdownarea = document.getElementById("markdown_area").value
var config = Object.assign({}, basicConfig);// { value: markdownarea });// { value: value });不显示获取的初始化值 var config = Object.assign({}, basicConfig);// { value: markdownarea });// { value: value });不显示获取的初始化值
window.editor = new Cherry(config); window.editor = new Cherry(config);
window.editor.getCodeMirror().on('change', (e, detail)=>{
resetEditorChanged(true);
});
openLastSelectedNode(); openLastSelectedNode();
uploadImage("manualEditorContainer", function ($state, $res) { uploadImage("manualEditorContainer", function ($state, $res) {
console.log("注册上传图片") console.log("注册上传图片")
@ -274,20 +276,6 @@ $(function () {
}); });
}); });
function insertToMarkdown(body) {
window.isLoad = true;
window.editor.insertValue(body);
window.editor.setCursor({ line: 0, ch: 0 });
resetEditorChanged(true);
}
function insertAndClearToMarkdown(body) {
window.isLoad = true;
window.editor.clear();
window.editor.insertValue(body);
window.editor.setCursor({ line: 0, ch: 0 });
resetEditorChanged(true);
}
/*** /***
* *
* @param $node * @param $node
@ -424,7 +412,12 @@ $(function () {
* *
*/ */
function backWard() { function backWard() {
history.back(); if (document.referrer == "") { // 没有上一级
var homepage = window.location.origin;
window.location.href = homepage; // 返回首页
return;
}
window.location.href = document.referrer;
} }
/** /**

View File

@ -1,10 +1,9 @@
/* PrismJS 1.28.0 /* PrismJS 1.29.0
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+dart+go+java+kotlin+latex+markup-templating+matlab+mongodb+php+python+ruby+rust+sql+swift+systemd+typoscript+yaml&plugins=line-numbers+toolbar+copy-to-clipboard */ https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript */
code[class*=language-], code[class*=language-],
pre[class*=language-] { pre[class*=language-] {
color: #f90505; color: #ccc;
background: 0 0; background: 0 0;
text-shadow: 0 1px #fff;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em; font-size: 1em;
text-align: left; text-align: left;
@ -22,6 +21,12 @@ pre[class*=language-] {
hyphens: none hyphens: none
} }
pre[class*=language-] {
padding: 1em;
margin: .5em 0;
overflow: auto
}
code[class*=language-] ::-moz-selection, code[class*=language-] ::-moz-selection,
code[class*=language-]::-moz-selection, code[class*=language-]::-moz-selection,
pre[class*=language-] ::-moz-selection, pre[class*=language-] ::-moz-selection,
@ -46,15 +51,9 @@ pre[class*=language-]::selection {
} }
} }
pre[class*=language-] {
padding: 1em;
margin: .5em 0;
overflow: auto
}
:not(pre)>code[class*=language-], :not(pre)>code[class*=language-],
pre[class*=language-] { pre[class*=language-] {
background: #f5f2f0 background: #2d2d2d
} }
:not(pre)>code[class*=language-] { :not(pre)>code[class*=language-] {
@ -63,47 +62,79 @@ pre[class*=language-] {
white-space: normal white-space: normal
} }
.token.block-comment,
.token.cdata, .token.cdata,
.token.comment, .token.comment,
.token.doctype, .token.doctype,
.token.prolog { .token.prolog {
color: #708090
}
.token.punctuation {
color: #999 color: #999
} }
.token.namespace { .token.punctuation {
opacity: .7 color: #ccc
}
.token.boolean,
.token.constant,
.token.deleted,
.token.number,
.token.property,
.token.symbol,
.token.tag {
color: #905
} }
.token.attr-name, .token.attr-name,
.token.builtin, .token.deleted,
.token.char, .token.namespace,
.token.inserted, .token.tag {
.token.selector, color: #e2777a
.token.string { }
color: #690
.token.function-name {
color: #6196cc
}
.token.boolean,
.token.function,
.token.number {
color: #f08d49
}
.token.class-name,
.token.constant,
.token.property,
.token.symbol {
color: #f8c555
}
.token.atrule,
.token.builtin,
.token.important,
.token.keyword,
.token.selector {
color: #cc99cd
}
.token.attr-value,
.token.char,
.token.regex,
.token.string,
.token.variable {
color: #7ec699
} }
.language-css .token.string,
.style .token.string,
.token.entity, .token.entity,
.token.operator, .token.operator,
.token.url { .token.url {
color: #9a6e3a; color: #67cdcc
background: hsla(0, 0%, 100%, .5) }
.token.bold,
.token.important {
font-weight: 700
}
.token.italic {
font-style: italic
}
.token.entity {
cursor: help
}
.token.inserted {
color: green
} }
.token.atrule, .token.atrule,
@ -123,19 +154,6 @@ pre[class*=language-] {
color: #e90 color: #e90
} }
.token.bold,
.token.important {
font-weight: 700
}
.token.italic {
font-style: italic
}
.token.entity {
cursor: help
}
pre[class*=language-].line-numbers { pre[class*=language-].line-numbers {
position: relative; position: relative;
padding-left: 3.8em !important; padding-left: 3.8em !important;
@ -241,4 +259,4 @@ div.code-toolbar>.toolbar>.toolbar-item>span:hover {
.cherry div.code-toolbar>.toolbar>.toolbar-item>button:focus, .cherry div.code-toolbar>.toolbar>.toolbar-item>button:focus,
div.code-toolbar>.toolbar>.toolbar-item>button:hover { div.code-toolbar>.toolbar>.toolbar-item>button:hover {
color: #1fa9e0be !important; color: #1fa9e0be !important;
} }