cherry-muse 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +162 -0
- package/README.md +139 -0
- package/dist/addons/cherry-code-block-card-plugin.js +1 -0
- package/dist/addons/cherry-code-block-echarts-plugin.js +1 -0
- package/dist/addons/cherry-code-block-mermaid-plugin.js +1 -0
- package/dist/cherry-markdown.core.common.js +1 -0
- package/dist/cherry-markdown.core.js +1 -0
- package/dist/cherry-markdown.css +4089 -0
- package/dist/cherry-markdown.engine.core.common.js +1 -0
- package/dist/cherry-markdown.engine.core.esm.js +1 -0
- package/dist/cherry-markdown.engine.core.js +1 -0
- package/dist/cherry-markdown.esm.js +1 -0
- package/dist/cherry-markdown.js +70837 -0
- package/dist/cherry-markdown.js.map +1 -0
- package/dist/cherry-markdown.min.css +1 -0
- package/dist/cherry-markdown.min.js +1 -0
- package/dist/stats.html +4838 -0
- package/examples/scripts/pinyin/README.md +53 -0
- package/package.json +167 -0
- package/src/Cherry.config.js +411 -0
- package/src/Cherry.js +788 -0
- package/src/CherryStatic.js +70 -0
- package/src/Editor.js +746 -0
- package/src/Engine.js +334 -0
- package/src/Event.js +74 -0
- package/src/Factory.js +180 -0
- package/src/Logger.js +31 -0
- package/src/Previewer.js +1147 -0
- package/src/Sanitizer.js +4 -0
- package/src/Sanitizer.node.js +7 -0
- package/src/Stats.js +101 -0
- package/src/Theme.js +46 -0
- package/src/UrlCache.js +98 -0
- package/src/addons/cherry-code-block-card-plugin.js +213 -0
- package/src/addons/cherry-code-block-echarts-plugin.js +161 -0
- package/src/addons/cherry-code-block-mermaid-plugin.js +118 -0
- package/src/core/HookCenter.js +303 -0
- package/src/core/HooksConfig.js +106 -0
- package/src/core/ParagraphBase.js +314 -0
- package/src/core/SentenceBase.js +65 -0
- package/src/core/SyntaxBase.js +197 -0
- package/src/core/hooks/AutoLink.js +251 -0
- package/src/core/hooks/BackgroundColor.js +46 -0
- package/src/core/hooks/Badge.js +100 -0
- package/src/core/hooks/Blockquote.js +113 -0
- package/src/core/hooks/Br.js +85 -0
- package/src/core/hooks/CodeBlock.js +876 -0
- package/src/core/hooks/Color.js +78 -0
- package/src/core/hooks/CommentReference.js +96 -0
- package/src/core/hooks/Detail.js +138 -0
- package/src/core/hooks/Emoji.config.js +9388 -0
- package/src/core/hooks/Emoji.js +223 -0
- package/src/core/hooks/Emphasis.js +113 -0
- package/src/core/hooks/Footnote.js +125 -0
- package/src/core/hooks/FrontMatter.js +52 -0
- package/src/core/hooks/FrontMatterVars.js +82 -0
- package/src/core/hooks/Header.js +229 -0
- package/src/core/hooks/HighLight.js +37 -0
- package/src/core/hooks/Hr.js +52 -0
- package/src/core/hooks/HtmlBlock.js +159 -0
- package/src/core/hooks/Iframe.js +80 -0
- package/src/core/hooks/Image.js +276 -0
- package/src/core/hooks/InlineCode.js +45 -0
- package/src/core/hooks/InlineMath.js +142 -0
- package/src/core/hooks/Link.js +169 -0
- package/src/core/hooks/List.js +260 -0
- package/src/core/hooks/Mark.js +55 -0
- package/src/core/hooks/MathBlock.js +97 -0
- package/src/core/hooks/Panel.js +170 -0
- package/src/core/hooks/Paragraph.js +84 -0
- package/src/core/hooks/Ruby.js +34 -0
- package/src/core/hooks/Size.js +84 -0
- package/src/core/hooks/Strikethrough.js +54 -0
- package/src/core/hooks/Sub.js +47 -0
- package/src/core/hooks/SuggestList.js +317 -0
- package/src/core/hooks/Suggester.js +759 -0
- package/src/core/hooks/Sup.js +47 -0
- package/src/core/hooks/Table.js +315 -0
- package/src/core/hooks/Toc.js +290 -0
- package/src/core/hooks/Transfer.js +47 -0
- package/src/core/hooks/Underline.js +37 -0
- package/src/index.core.js +29 -0
- package/src/index.engine.core.js +62 -0
- package/src/index.engine.js +30 -0
- package/src/index.js +28 -0
- package/src/locales/index.js +21 -0
- package/src/locales/zh_CN.js +170 -0
- package/src/sass/cherry.scss +122 -0
- package/src/sass/components/bubble.scss +122 -0
- package/src/sass/components/codemirror.scss +628 -0
- package/src/sass/components/dropdown.scss +37 -0
- package/src/sass/components/editor.scss +78 -0
- package/src/sass/components/preview.scss +71 -0
- package/src/sass/components/prism.scss +142 -0
- package/src/sass/components/stats.scss +32 -0
- package/src/sass/components/toc.scss +184 -0
- package/src/sass/components/toolbar.scss +117 -0
- package/src/sass/core/AutoLink.scss +20 -0
- package/src/sass/core/BackgroundColor.scss +0 -0
- package/src/sass/core/Badge.scss +116 -0
- package/src/sass/core/Blockquote.scss +12 -0
- package/src/sass/core/Br.scss +0 -0
- package/src/sass/core/Card.scss +219 -0
- package/src/sass/core/CodeBlock.scss +205 -0
- package/src/sass/core/Color.scss +37 -0
- package/src/sass/core/CommentReference.scss +0 -0
- package/src/sass/core/Detail.scss +107 -0
- package/src/sass/core/Emoji.scss +127 -0
- package/src/sass/core/Emphasis.scss +9 -0
- package/src/sass/core/Footnote.scss +21 -0
- package/src/sass/core/FrontMatterVars.scss +19 -0
- package/src/sass/core/Header.scss +103 -0
- package/src/sass/core/HighLight.scss +0 -0
- package/src/sass/core/Hr.scss +10 -0
- package/src/sass/core/HtmlBlock.scss +0 -0
- package/src/sass/core/Iframe.scss +36 -0
- package/src/sass/core/Image.scss +59 -0
- package/src/sass/core/InlineCode.scss +10 -0
- package/src/sass/core/InlineMath.scss +11 -0
- package/src/sass/core/Link.scss +16 -0
- package/src/sass/core/List.scss +61 -0
- package/src/sass/core/Mark.scss +15 -0
- package/src/sass/core/MathBlock.scss +0 -0
- package/src/sass/core/Panel.scss +150 -0
- package/src/sass/core/Paragraph.scss +6 -0
- package/src/sass/core/Ruby.scss +0 -0
- package/src/sass/core/Size.scss +8 -0
- package/src/sass/core/Strikethrough.scss +0 -0
- package/src/sass/core/Sub.scss +5 -0
- package/src/sass/core/Suggester.scss +62 -0
- package/src/sass/core/Sup.scss +5 -0
- package/src/sass/core/Table.scss +127 -0
- package/src/sass/core/Toc.scss +28 -0
- package/src/sass/core/Transfer.scss +0 -0
- package/src/sass/core/Underline.scss +0 -0
- package/src/sass/google-fonts.scss +34 -0
- package/src/sass/index.scss +3 -0
- package/src/sass/prism/dark.scss +131 -0
- package/src/sass/prism/light.scss +143 -0
- package/src/sass/variables/colors.scss +96 -0
- package/src/toolbars/Bubble.js +232 -0
- package/src/toolbars/BubbleTable.js +147 -0
- package/src/toolbars/HookCenter.js +185 -0
- package/src/toolbars/MenuBase.js +357 -0
- package/src/toolbars/PreviewerBubble.js +558 -0
- package/src/toolbars/Toc.js +246 -0
- package/src/toolbars/Toolbar.js +401 -0
- package/src/toolbars/hooks/Audio.js +53 -0
- package/src/toolbars/hooks/Badge.js +80 -0
- package/src/toolbars/hooks/BarTable.js +41 -0
- package/src/toolbars/hooks/Bold.js +70 -0
- package/src/toolbars/hooks/Br.js +34 -0
- package/src/toolbars/hooks/Card.js +64 -0
- package/src/toolbars/hooks/CheckList.js +41 -0
- package/src/toolbars/hooks/Code.js +46 -0
- package/src/toolbars/hooks/Color.js +285 -0
- package/src/toolbars/hooks/Copy.js +139 -0
- package/src/toolbars/hooks/Detail.js +70 -0
- package/src/toolbars/hooks/ECharts.js +303 -0
- package/src/toolbars/hooks/Emoji.js +303 -0
- package/src/toolbars/hooks/Export.js +47 -0
- package/src/toolbars/hooks/File.js +54 -0
- package/src/toolbars/hooks/Formula.js +36 -0
- package/src/toolbars/hooks/FullScreen.js +55 -0
- package/src/toolbars/hooks/Graph.js +281 -0
- package/src/toolbars/hooks/H1.js +71 -0
- package/src/toolbars/hooks/H2.js +71 -0
- package/src/toolbars/hooks/H3.js +71 -0
- package/src/toolbars/hooks/Header.js +100 -0
- package/src/toolbars/hooks/Hr.js +35 -0
- package/src/toolbars/hooks/Iframe.js +35 -0
- package/src/toolbars/hooks/Image.js +60 -0
- package/src/toolbars/hooks/Insert.js +36 -0
- package/src/toolbars/hooks/Italic.js +70 -0
- package/src/toolbars/hooks/LineTable.js +41 -0
- package/src/toolbars/hooks/Link.js +46 -0
- package/src/toolbars/hooks/List.js +55 -0
- package/src/toolbars/hooks/Ol.js +41 -0
- package/src/toolbars/hooks/Panel.js +155 -0
- package/src/toolbars/hooks/Quote.js +45 -0
- package/src/toolbars/hooks/Redo.js +33 -0
- package/src/toolbars/hooks/Ruby.js +59 -0
- package/src/toolbars/hooks/Size.js +100 -0
- package/src/toolbars/hooks/Split.js +37 -0
- package/src/toolbars/hooks/Strikethrough.js +65 -0
- package/src/toolbars/hooks/Sub.js +58 -0
- package/src/toolbars/hooks/Sup.js +58 -0
- package/src/toolbars/hooks/SwitchModel.js +78 -0
- package/src/toolbars/hooks/Table.js +56 -0
- package/src/toolbars/hooks/Toc.js +35 -0
- package/src/toolbars/hooks/TogglePreview.js +79 -0
- package/src/toolbars/hooks/Ul.js +41 -0
- package/src/toolbars/hooks/Underline.js +65 -0
- package/src/toolbars/hooks/Undo.js +30 -0
- package/src/toolbars/hooks/Video.js +53 -0
- package/src/utils/LazyLoadImg.js +341 -0
- package/src/utils/autoindent.js +58 -0
- package/src/utils/codeBlockContentHandler.js +351 -0
- package/src/utils/config.js +98 -0
- package/src/utils/copy.js +55 -0
- package/src/utils/dialog.js +196 -0
- package/src/utils/dom.js +162 -0
- package/src/utils/downloadUtil.js +23 -0
- package/src/utils/env.js +22 -0
- package/src/utils/error.js +61 -0
- package/src/utils/event.js +38 -0
- package/src/utils/export.js +115 -0
- package/src/utils/file.js +121 -0
- package/src/utils/formulaUtilsHandler.js +230 -0
- package/src/utils/htmlparser.js +977 -0
- package/src/utils/image.js +99 -0
- package/src/utils/imgSizeHandler.js +279 -0
- package/src/utils/jsonUtils.js +17 -0
- package/src/utils/lineFeed.js +49 -0
- package/src/utils/listContentHandler.js +227 -0
- package/src/utils/lookbehind-replace.js +81 -0
- package/src/utils/mathjax.js +89 -0
- package/src/utils/myersDiff.js +211 -0
- package/src/utils/pasteHelper.js +253 -0
- package/src/utils/recount-pos.js +59 -0
- package/src/utils/regexp.js +295 -0
- package/src/utils/sanitize.js +477 -0
- package/src/utils/selection.js +50 -0
- package/src/utils/svgUtils.js +96 -0
- package/src/utils/tableContentHandler.js +592 -0
- package/tools/README.md +3 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import SyntaxBase from '@/core/SyntaxBase';
|
|
17
|
+
import { isLookbehindSupported } from '@/utils/regexp';
|
|
18
|
+
import { replaceLookbehind } from '@/utils/lookbehind-replace';
|
|
19
|
+
|
|
20
|
+
export default class Size extends SyntaxBase {
|
|
21
|
+
static HOOK_NAME = 'fontSize';
|
|
22
|
+
|
|
23
|
+
// constructor() {
|
|
24
|
+
// super();
|
|
25
|
+
// }
|
|
26
|
+
|
|
27
|
+
toHtml(whole, m1, m2, m3) {
|
|
28
|
+
return `${m1}<span style="font-size:${m2}px;line-height:1em;">${m3}</span>`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
makeHtml(str) {
|
|
32
|
+
if (!this.test(str)) {
|
|
33
|
+
return str;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (isLookbehindSupported()) {
|
|
37
|
+
return str.replace(this.RULE.reg, this.toHtml);
|
|
38
|
+
}
|
|
39
|
+
return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
rule() {
|
|
43
|
+
const ret = {
|
|
44
|
+
begin: isLookbehindSupported() ? '((?<!\\\\))!' : '(^|[^\\\\])!',
|
|
45
|
+
end: '!',
|
|
46
|
+
content: '([0-9]{1,2})[\\s]([\\w\\W]*?)',
|
|
47
|
+
};
|
|
48
|
+
ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
|
|
49
|
+
return ret;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
overlayMode() {
|
|
53
|
+
return {
|
|
54
|
+
name: 'size',
|
|
55
|
+
inSizeContainer: false,
|
|
56
|
+
countTotal: 0,
|
|
57
|
+
token(stream, state) {
|
|
58
|
+
// 尝试匹配规则
|
|
59
|
+
if (stream.match(/!\d+\s.*?!/)) {
|
|
60
|
+
stream.backUp(stream.current().length); // 回退以单独处理
|
|
61
|
+
this.inSizeContainer = true;
|
|
62
|
+
this.countTotal = 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (this.inSizeContainer) {
|
|
66
|
+
if (stream.match('!')) {
|
|
67
|
+
this.countTotal += 1;
|
|
68
|
+
if (this.countTotal === 2) {
|
|
69
|
+
this.inSizeContainer = false;
|
|
70
|
+
this.countTotal = 0;
|
|
71
|
+
}
|
|
72
|
+
return 'size-container'; // 自定义样式类名
|
|
73
|
+
}
|
|
74
|
+
if (stream.match(/\d+/)) {
|
|
75
|
+
return 'size-number'; // 自定义样式类名
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
stream.next(); // 前进到下一个字符
|
|
80
|
+
return null; // 默认返回 null
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import SyntaxBase from '@/core/SyntaxBase';
|
|
17
|
+
/**
|
|
18
|
+
* 删除线语法
|
|
19
|
+
*/
|
|
20
|
+
export default class Strikethrough extends SyntaxBase {
|
|
21
|
+
static HOOK_NAME = 'strikethrough';
|
|
22
|
+
|
|
23
|
+
constructor({ config } = { config: undefined }) {
|
|
24
|
+
super({ config });
|
|
25
|
+
if (!config) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.needWhitespace = !!config.needWhitespace;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 主要逻辑
|
|
33
|
+
* @param {string} str markdown源码
|
|
34
|
+
* @returns {string} html内容
|
|
35
|
+
*/
|
|
36
|
+
makeHtml(str) {
|
|
37
|
+
if (!this.test(str)) {
|
|
38
|
+
return str;
|
|
39
|
+
}
|
|
40
|
+
return str.replace(this.RULE.reg, '$1<del>$2</del>');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
rule({ config } = { config: undefined }) {
|
|
44
|
+
/** @type {import('~types/syntax').BasicHookRegexpRule} */
|
|
45
|
+
let ret = /** @type {any} */ ({});
|
|
46
|
+
if (!!config.needWhitespace) {
|
|
47
|
+
ret = { ...ret, begin: '(^|[\\s])\\~T\\~T', end: '\\~T\\~T(?=\\s|$)', content: '([\\w\\W]+?)' };
|
|
48
|
+
} else {
|
|
49
|
+
ret = { ...ret, begin: '(^|[^\\\\])\\~T\\~T', end: '\\~T\\~T', content: '([\\w\\W]+?)' };
|
|
50
|
+
}
|
|
51
|
+
ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
|
|
52
|
+
return ret;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import SyntaxBase from '@/core/SyntaxBase';
|
|
17
|
+
import { isLookbehindSupported } from '@/utils/regexp';
|
|
18
|
+
import { replaceLookbehind } from '@/utils/lookbehind-replace';
|
|
19
|
+
|
|
20
|
+
export default class Sub extends SyntaxBase {
|
|
21
|
+
static HOOK_NAME = 'sub';
|
|
22
|
+
|
|
23
|
+
// constructor() {
|
|
24
|
+
// super();
|
|
25
|
+
// }
|
|
26
|
+
|
|
27
|
+
toHtml(whole, leadingChar, m1) {
|
|
28
|
+
return `${leadingChar}<sub>${m1}</sub>`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
makeHtml(str) {
|
|
32
|
+
if (isLookbehindSupported()) {
|
|
33
|
+
return str.replace(this.RULE.reg, this.toHtml);
|
|
34
|
+
}
|
|
35
|
+
return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
rule() {
|
|
39
|
+
const ret = {
|
|
40
|
+
begin: isLookbehindSupported() ? '((?<!\\\\))\\^\\^' : '(^|[^\\\\])\\^\\^',
|
|
41
|
+
end: '\\^\\^',
|
|
42
|
+
content: '([\\w\\W]+?)',
|
|
43
|
+
};
|
|
44
|
+
ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
|
|
45
|
+
return ret;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tencent is pleased to support the open source community by making CherryMarkdown available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
|
+
* The below software in this distribution may have been modified by THL A29 Limited ("Tencent Modifications").
|
|
6
|
+
*
|
|
7
|
+
* All Tencent Modifications are Copyright (C) THL A29 Limited.
|
|
8
|
+
*
|
|
9
|
+
* CherryMarkdown is licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
/*
|
|
22
|
+
* 外加配置系统联想词
|
|
23
|
+
*/
|
|
24
|
+
import { fuzzySearchKeysWithValues } from '@/core/hooks/Emoji';
|
|
25
|
+
import { supportLanguages } from '@/core/hooks/CodeBlock';
|
|
26
|
+
import { expandList } from '@/core/hooks/Suggester';
|
|
27
|
+
|
|
28
|
+
const Brackets = [
|
|
29
|
+
{
|
|
30
|
+
key: '[ ]',
|
|
31
|
+
value: `[]`,
|
|
32
|
+
goLeft: 1,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: '{ }',
|
|
36
|
+
value: `{}`,
|
|
37
|
+
goLeft: 1,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: '【 】',
|
|
41
|
+
value: `[]`,
|
|
42
|
+
goLeft: 1,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: '『 』',
|
|
46
|
+
value: `『』`,
|
|
47
|
+
goLeft: 1,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: '「 」',
|
|
51
|
+
value: `「」`,
|
|
52
|
+
goLeft: 1,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {Suggester} suggester
|
|
58
|
+
* @returns
|
|
59
|
+
* */
|
|
60
|
+
export const systemSuggests = [
|
|
61
|
+
{
|
|
62
|
+
keyword: ':',
|
|
63
|
+
data(keywords, callback, $cherry, key) {
|
|
64
|
+
if (!keywords.startsWith('::')) {
|
|
65
|
+
// 面板语法提示
|
|
66
|
+
callback(fuzzySearchKeysWithValues(keywords, $cherry.options.engine.syntax.emoji));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const list = expandList($cherry, [
|
|
70
|
+
{
|
|
71
|
+
toolbar: 'panel',
|
|
72
|
+
keyword: '',
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
75
|
+
const result = [];
|
|
76
|
+
const keyword = keywords.replace('::', '').trim();
|
|
77
|
+
for (let i = 0; i < list.length; i++) {
|
|
78
|
+
const item = list[i];
|
|
79
|
+
const itemKey = item.keyword.replace('panel', '').toLowerCase().trim();
|
|
80
|
+
if (itemKey.startsWith(keyword)) {
|
|
81
|
+
item.goTop = 2;
|
|
82
|
+
result.push(item);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (result.length > 0) {
|
|
86
|
+
callback(result);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
keyword: '`', // 代码块
|
|
92
|
+
data(keywords, callback, $cherry, key) {
|
|
93
|
+
const startKey = '```';
|
|
94
|
+
const keyLength = startKey.length;
|
|
95
|
+
const totalKey = key + keywords;
|
|
96
|
+
if (totalKey.startsWith(startKey)) {
|
|
97
|
+
const languages = [];
|
|
98
|
+
const word = totalKey.substring(keyLength).trim();
|
|
99
|
+
for (let i = 0; i < supportLanguages.length; i++) {
|
|
100
|
+
const language = supportLanguages[i];
|
|
101
|
+
if (language === 'mermaid') continue;
|
|
102
|
+
if (language.startsWith(word)) {
|
|
103
|
+
languages.push({
|
|
104
|
+
key: language,
|
|
105
|
+
value: `\`\`\`${language}
|
|
106
|
+
|
|
107
|
+
\`\`\`
|
|
108
|
+
`,
|
|
109
|
+
goTop: 2,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (languages.length > 0) {
|
|
114
|
+
callback(languages);
|
|
115
|
+
} else {
|
|
116
|
+
for (const string of ['card', 'echarts', 'mermaid']) {
|
|
117
|
+
if (string.startsWith(word)) {
|
|
118
|
+
const list = expandList($cherry, [
|
|
119
|
+
{
|
|
120
|
+
toolbar: string === 'mermaid' ? 'graph' : string,
|
|
121
|
+
keyword: '',
|
|
122
|
+
goTop: 2,
|
|
123
|
+
},
|
|
124
|
+
]);
|
|
125
|
+
callback(list);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
callback([
|
|
131
|
+
{
|
|
132
|
+
icon: 'code',
|
|
133
|
+
key: 'codeBlock',
|
|
134
|
+
keyword: '``',
|
|
135
|
+
value: `\`\`\`
|
|
136
|
+
|
|
137
|
+
\`\`\`
|
|
138
|
+
`,
|
|
139
|
+
goTop: 2,
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
{
|
|
143
|
+
key: 'code',
|
|
144
|
+
icon: 'code',
|
|
145
|
+
keyword: '`',
|
|
146
|
+
value: `\`\``,
|
|
147
|
+
goLeft: 1,
|
|
148
|
+
},
|
|
149
|
+
]);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
keyword: '[【',
|
|
155
|
+
data(keywords, callback, $cherry, key) {
|
|
156
|
+
const result = [];
|
|
157
|
+
let startKey = '[';
|
|
158
|
+
if (keywords.startsWith(startKey)) {
|
|
159
|
+
const list = expandList($cherry, [
|
|
160
|
+
{
|
|
161
|
+
toolbar: 'badge',
|
|
162
|
+
keyword: '',
|
|
163
|
+
},
|
|
164
|
+
]);
|
|
165
|
+
const keyword = keywords.replace(startKey, '').trim();
|
|
166
|
+
for (let i = 0; i < list.length; i++) {
|
|
167
|
+
const item = list[i];
|
|
168
|
+
const itemKey = item.keyword.replace('badge', '').toLowerCase().trim();
|
|
169
|
+
if (itemKey.startsWith(keyword)) {
|
|
170
|
+
switch (itemKey) {
|
|
171
|
+
case 'important':
|
|
172
|
+
item.goLeft = 19;
|
|
173
|
+
break;
|
|
174
|
+
case 'info':
|
|
175
|
+
item.goLeft = 14;
|
|
176
|
+
break;
|
|
177
|
+
case 'warning':
|
|
178
|
+
item.goLeft = 17;
|
|
179
|
+
break;
|
|
180
|
+
case 'danger':
|
|
181
|
+
item.goLeft = 16;
|
|
182
|
+
break;
|
|
183
|
+
case 'tip':
|
|
184
|
+
item.goLeft = 13;
|
|
185
|
+
break;
|
|
186
|
+
case 'top':
|
|
187
|
+
item.goLeft = 11;
|
|
188
|
+
break;
|
|
189
|
+
case 'center':
|
|
190
|
+
item.goLeft = 14;
|
|
191
|
+
break;
|
|
192
|
+
case 'bottom':
|
|
193
|
+
item.goLeft = 14;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
result.push(item);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if ('toc'.startsWith(keyword)) {
|
|
201
|
+
result.push({
|
|
202
|
+
icon: 'toc',
|
|
203
|
+
key: 'toc',
|
|
204
|
+
keyword: 'toc',
|
|
205
|
+
value: `[[TOC]]\n`,
|
|
206
|
+
goLeft: 0,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (result.length > 0) {
|
|
210
|
+
callback(result);
|
|
211
|
+
}
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
startKey = '^';
|
|
215
|
+
if (keywords.startsWith(startKey)) {
|
|
216
|
+
callback([
|
|
217
|
+
{
|
|
218
|
+
icon: 'edit_note',
|
|
219
|
+
key: 'footNoteTitle',
|
|
220
|
+
keyword: '……^',
|
|
221
|
+
value: `[^脚注标题]`,
|
|
222
|
+
goLeft: 5,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
icon: 'text_snippet',
|
|
226
|
+
key: 'footNoteText',
|
|
227
|
+
keyword: '……^',
|
|
228
|
+
value: `[^脚注标题]: 脚注内容`,
|
|
229
|
+
goLeft: 11,
|
|
230
|
+
},
|
|
231
|
+
]);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const list = expandList($cherry, [
|
|
235
|
+
{
|
|
236
|
+
toolbar: 'link',
|
|
237
|
+
keyword: '',
|
|
238
|
+
},
|
|
239
|
+
]);
|
|
240
|
+
callback(list.concat(Brackets));
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
keyword: '+',
|
|
245
|
+
data(keywords, callback, $cherry, key) {
|
|
246
|
+
const result = [];
|
|
247
|
+
const list = [
|
|
248
|
+
{
|
|
249
|
+
icon: 'more_horiz',
|
|
250
|
+
key: 'detailOpen',
|
|
251
|
+
keyword: '+',
|
|
252
|
+
value: `++ 标题\n内容\n+++\n`,
|
|
253
|
+
goTop: 2,
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
icon: 'more_horiz',
|
|
257
|
+
key: 'detailClose',
|
|
258
|
+
keyword: '-',
|
|
259
|
+
value: `++- 标题\n内容\n+++\n`,
|
|
260
|
+
goTop: 2,
|
|
261
|
+
},
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
for (const listElement of list) {
|
|
265
|
+
if (listElement.keyword.startsWith(keywords) || keywords === '') {
|
|
266
|
+
result.push(listElement);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
callback(result);
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
keyword: '!',
|
|
275
|
+
data(keywords, callback, $cherry, key) {
|
|
276
|
+
const result = [];
|
|
277
|
+
const list = [
|
|
278
|
+
{
|
|
279
|
+
icon: 'image',
|
|
280
|
+
key: 'image',
|
|
281
|
+
keyword: '[',
|
|
282
|
+
value: ``,
|
|
283
|
+
goLeft: 14,
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
icon: 'videocam',
|
|
287
|
+
key: 'video',
|
|
288
|
+
keyword: 'video',
|
|
289
|
+
value: `!video[描述](链接){poster=封面链接}`,
|
|
290
|
+
goLeft: 20,
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
icon: 'mic',
|
|
294
|
+
key: 'audio',
|
|
295
|
+
keyword: 'audio',
|
|
296
|
+
value: `!audio[描述](链接)`,
|
|
297
|
+
goLeft: 7,
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
icon: 'attach_file',
|
|
301
|
+
key: 'file',
|
|
302
|
+
keyword: 'file',
|
|
303
|
+
value: `!file[名称|拓展名|密码](链接)`,
|
|
304
|
+
goLeft: 14,
|
|
305
|
+
},
|
|
306
|
+
];
|
|
307
|
+
|
|
308
|
+
for (const listElement of list) {
|
|
309
|
+
if (listElement.keyword.startsWith(keywords) || keywords === '') {
|
|
310
|
+
result.push(listElement);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
callback(result);
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
];
|