@cherry-markdown/cherry-markdown-dev 0.9.0-dev.202504110650.834443a → 0.9.0-dev.202504160300.d23d141
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/README.md +2 -2
- package/dist/addons/advance/cherry-table-echarts-plugin.js +1 -1
- package/dist/addons/cherry-code-block-mermaid-plugin.js +1 -1
- package/dist/cherry-markdown.core.common.js +1 -1
- package/dist/cherry-markdown.core.js +1 -1
- package/dist/cherry-markdown.engine.core.common.js +1 -1
- package/dist/cherry-markdown.engine.core.esm.js +1 -1
- package/dist/cherry-markdown.engine.core.js +1 -1
- package/dist/cherry-markdown.esm.js +1 -1
- package/dist/cherry-markdown.js +1 -1
- package/dist/cherry-markdown.min.js +1 -1
- package/dist/fonts/ch-icon.eot +0 -0
- package/dist/fonts/ch-icon.ttf +0 -0
- package/dist/fonts/ch-icon.woff +0 -0
- package/dist/fonts/ch-icon.woff2 +0 -0
- package/package.json +1 -3
- package/src/Cherry.config.js +0 -634
- package/src/Cherry.js +0 -1104
- package/src/CherryStatic.js +0 -70
- package/src/Editor.js +0 -748
- package/src/Engine.js +0 -402
- package/src/Event.js +0 -140
- package/src/Factory.js +0 -180
- package/src/Logger.js +0 -31
- package/src/Previewer.js +0 -1192
- package/src/Sanitizer.js +0 -4
- package/src/Sanitizer.node.js +0 -7
- package/src/UrlCache.js +0 -98
- package/src/addons/advance/cherry-table-echarts-plugin.js +0 -170
- package/src/addons/cherry-code-block-mermaid-plugin.js +0 -158
- package/src/addons/cherry-code-block-plantuml-plugin.js +0 -106
- package/src/core/HookCenter.js +0 -297
- package/src/core/HooksConfig.js +0 -105
- package/src/core/ParagraphBase.js +0 -332
- package/src/core/SentenceBase.js +0 -65
- package/src/core/SyntaxBase.js +0 -194
- package/src/core/hooks/AutoLink.js +0 -232
- package/src/core/hooks/BackgroundColor.js +0 -46
- package/src/core/hooks/Blockquote.js +0 -70
- package/src/core/hooks/Br.js +0 -85
- package/src/core/hooks/CodeBlock.js +0 -456
- package/src/core/hooks/Color.js +0 -46
- package/src/core/hooks/CommentReference.js +0 -96
- package/src/core/hooks/Detail.js +0 -108
- package/src/core/hooks/Emoji.config.js +0 -1825
- package/src/core/hooks/Emoji.js +0 -119
- package/src/core/hooks/Emphasis.js +0 -113
- package/src/core/hooks/Footnote.js +0 -125
- package/src/core/hooks/FrontMatter.js +0 -51
- package/src/core/hooks/Header.js +0 -234
- package/src/core/hooks/HighLight.js +0 -37
- package/src/core/hooks/Hr.js +0 -52
- package/src/core/hooks/HtmlBlock.js +0 -199
- package/src/core/hooks/Image.js +0 -174
- package/src/core/hooks/InlineCode.js +0 -48
- package/src/core/hooks/InlineMath.js +0 -108
- package/src/core/hooks/Link.js +0 -160
- package/src/core/hooks/List.js +0 -264
- package/src/core/hooks/MathBlock.js +0 -104
- package/src/core/hooks/Panel.js +0 -145
- package/src/core/hooks/Paragraph.js +0 -84
- package/src/core/hooks/Ruby.js +0 -34
- package/src/core/hooks/Size.js +0 -51
- package/src/core/hooks/Strikethrough.js +0 -54
- package/src/core/hooks/Sub.js +0 -47
- package/src/core/hooks/SuggestList.js +0 -333
- package/src/core/hooks/Suggester.js +0 -707
- package/src/core/hooks/Sup.js +0 -47
- package/src/core/hooks/Table.js +0 -275
- package/src/core/hooks/Toc.js +0 -292
- package/src/core/hooks/Transfer.js +0 -47
- package/src/core/hooks/Underline.js +0 -37
- package/src/index.core.js +0 -29
- package/src/index.engine.core.js +0 -68
- package/src/index.engine.js +0 -28
- package/src/index.js +0 -32
- package/src/libs/mermaidAPI.8.4.8.js +0 -1
- package/src/libs/mermaidAPI.8.5.2.js +0 -42
- package/src/libs/rawdeflate.js +0 -1663
- package/src/locales/en_US.js +0 -139
- package/src/locales/index.js +0 -25
- package/src/locales/ru_RU.js +0 -139
- package/src/locales/zh_CN.js +0 -142
- package/src/sass/base.scss +0 -26
- package/src/sass/bubble_formula.scss +0 -166
- package/src/sass/ch-icon.scss +0 -118
- package/src/sass/cherry.scss +0 -1116
- package/src/sass/components/bubble.scss +0 -173
- package/src/sass/components/shortcut_key_config.scss +0 -108
- package/src/sass/formula_utils_bubble.scss +0 -82
- package/src/sass/icon_template.scss +0 -24
- package/src/sass/icons/uEA03-list.svg +0 -19
- package/src/sass/icons/uEA04-check.svg +0 -14
- package/src/sass/icons/uEA09-square.svg +0 -10
- package/src/sass/icons/uEA0A-bold.svg +0 -20
- package/src/sass/icons/uEA0B-code.svg +0 -18
- package/src/sass/icons/uEA0C-color.svg +0 -13
- package/src/sass/icons/uEA0D-header.svg +0 -8
- package/src/sass/icons/uEA0E-image.svg +0 -15
- package/src/sass/icons/uEA0F-italic.svg +0 -8
- package/src/sass/icons/uEA10-link.svg +0 -16
- package/src/sass/icons/uEA11-ol.svg +0 -21
- package/src/sass/icons/uEA12-size.svg +0 -11
- package/src/sass/icons/uEA13-strike.svg +0 -16
- package/src/sass/icons/uEA14-table.svg +0 -12
- package/src/sass/icons/uEA15-ul.svg +0 -17
- package/src/sass/icons/uEA16-underline.svg +0 -13
- package/src/sass/icons/uEA17-word.svg +0 -16
- package/src/sass/icons/uEA18-blockquote.svg +0 -11
- package/src/sass/icons/uEA19-font.svg +0 -10
- package/src/sass/icons/uEA1F-insertClass.svg +0 -39
- package/src/sass/icons/uEA20-insertFlow.svg +0 -8
- package/src/sass/icons/uEA21-insertFormula.svg +0 -23
- package/src/sass/icons/uEA22-insertGantt.svg +0 -13
- package/src/sass/icons/uEA23-insertGraph.svg +0 -13
- package/src/sass/icons/uEA24-insertPie.svg +0 -19
- package/src/sass/icons/uEA25-insertSeq.svg +0 -20
- package/src/sass/icons/uEA26-insertState.svg +0 -35
- package/src/sass/icons/uEA27-line.svg +0 -11
- package/src/sass/icons/uEA28-preview.svg +0 -18
- package/src/sass/icons/uEA29-previewClose.svg +0 -24
- package/src/sass/icons/uEA2A-toc.svg +0 -24
- package/src/sass/icons/uEA2D-sub.svg +0 -15
- package/src/sass/icons/uEA2E-sup.svg +0 -15
- package/src/sass/icons/uEA2F-h1.svg +0 -16
- package/src/sass/icons/uEA30-h2.svg +0 -20
- package/src/sass/icons/uEA31-h3.svg +0 -23
- package/src/sass/icons/uEA32-h4.svg +0 -16
- package/src/sass/icons/uEA33-h5.svg +0 -20
- package/src/sass/icons/uEA34-h6.svg +0 -17
- package/src/sass/icons/uEA35-video.svg +0 -20
- package/src/sass/icons/uEA36-insert.svg +0 -25
- package/src/sass/icons/uEA37-little_table.svg +0 -30
- package/src/sass/icons/uEA38-pdf.svg +0 -27
- package/src/sass/icons/uEA39-checklist.svg +0 -22
- package/src/sass/icons/uEA40-close.svg +0 -12
- package/src/sass/icons/uEA41-fullscreen.svg +0 -81
- package/src/sass/icons/uEA42-minscreen.svg +0 -77
- package/src/sass/icons/uEA43-insertChart.svg +0 -23
- package/src/sass/icons/uEA44-question.svg +0 -25
- package/src/sass/icons/uEA45-settings.svg +0 -32
- package/src/sass/icons/uEA46-ok.svg +0 -7
- package/src/sass/icons/uEA47-br.svg +0 -22
- package/src/sass/icons/uEA48-normal.svg +0 -15
- package/src/sass/icons/uEA49-undo.svg +0 -19
- package/src/sass/icons/uEA50-redo.svg +0 -21
- package/src/sass/icons/uEA51-copy.svg +0 -6
- package/src/sass/icons/uEA52-phone.svg +0 -5
- package/src/sass/icons/uEA53-cherry-table-delete.svg +0 -17
- package/src/sass/icons/uEA54-cherry-table-insert-bottom.svg +0 -16
- package/src/sass/icons/uEA55-cherry-table-insert-left.svg +0 -15
- package/src/sass/icons/uEA56-cherry-table-insert-right.svg +0 -16
- package/src/sass/icons/uEA57-cherry-table-insert-top.svg +0 -16
- package/src/sass/icons/uEA58-sort-s.svg +0 -13
- package/src/sass/icons/uEA59-pinyin.svg +0 -1
- package/src/sass/icons/uEA5A-create.svg +0 -24
- package/src/sass/icons/uEA5B-download.svg +0 -34
- package/src/sass/icons/uEA5C-edit.svg +0 -3
- package/src/sass/icons/uEA5D-export.svg +0 -53
- package/src/sass/icons/uEA5E-folder-open.svg +0 -3
- package/src/sass/icons/uEA5F-folder.svg +0 -3
- package/src/sass/icons/uEA60-help.svg +0 -5
- package/src/sass/icons/uEA61-pen-fill.svg +0 -13
- package/src/sass/icons/uEA62-pen.svg +0 -3
- package/src/sass/icons/uEA64-tips.svg +0 -5
- package/src/sass/icons/uEA65-warn.svg +0 -5
- package/src/sass/icons/uEA66-mistake.svg +0 -4
- package/src/sass/icons/uEA67-success.svg +0 -4
- package/src/sass/icons/uEA68-danger.svg +0 -4
- package/src/sass/icons/uEA69-info.svg +0 -5
- package/src/sass/icons/uEA6A-primary.svg +0 -5
- package/src/sass/icons/uEA6B-warning.svg +0 -5
- package/src/sass/icons/uEA6C-justify.svg +0 -19
- package/src/sass/icons/uEA6D-justifyCenter.svg +0 -19
- package/src/sass/icons/uEA6E-justifyLeft.svg +0 -19
- package/src/sass/icons/uEA6F-justifyRight.svg +0 -19
- package/src/sass/icons/uEA70-chevronsLeft.svg +0 -1
- package/src/sass/icons/uEA71-chevronsRight.svg +0 -1
- package/src/sass/icons/uEA72-trendingUp.svg +0 -1
- package/src/sass/icons/uEA74-codeBlock.svg +0 -1
- package/src/sass/icons/uEA75-expand.svg +0 -3
- package/src/sass/icons/uEA76-unExpand.svg +0 -3
- package/src/sass/icons/uEA77-swap-vert.svg +0 -1
- package/src/sass/icons/uEA78-swap.svg +0 -1
- package/src/sass/icons/uEA79-keyboard.svg +0 -1
- package/src/sass/icons/uEA7A-command.svg +0 -1
- package/src/sass/icons/uEA7B-search.svg +0 -1
- package/src/sass/index.scss +0 -3
- package/src/sass/markdown.scss +0 -668
- package/src/sass/markdown_pure.scss +0 -9
- package/src/sass/prettyprint/prettyprint.scss +0 -118
- package/src/sass/previewer.scss +0 -179
- package/src/sass/print.scss +0 -13
- package/src/sass/prism/coy.scss +0 -220
- package/src/sass/prism/dark.scss +0 -132
- package/src/sass/prism/default.scss +0 -143
- package/src/sass/prism/funky.scss +0 -133
- package/src/sass/prism/okaidia.scss +0 -126
- package/src/sass/prism/one-dark.scss +0 -440
- package/src/sass/prism/one-light.scss +0 -428
- package/src/sass/prism/solarized-light.scss +0 -153
- package/src/sass/prism/tomorrow-night.scss +0 -125
- package/src/sass/prism/twilight.scss +0 -202
- package/src/sass/prism/vs-dark.scss +0 -275
- package/src/sass/prism/vs-light.scss +0 -168
- package/src/sass/themes/blue.scss +0 -411
- package/src/sass/themes/dark.scss +0 -517
- package/src/sass/themes/default.scss +0 -255
- package/src/sass/themes/green.scss +0 -395
- package/src/sass/themes/light.scss +0 -368
- package/src/sass/themes/red.scss +0 -397
- package/src/sass/themes/violet.scss +0 -410
- package/src/sass/variable.scss +0 -84
- package/src/toolbars/Bubble.js +0 -234
- package/src/toolbars/BubbleFormula.js +0 -298
- package/src/toolbars/BubbleTable.js +0 -147
- package/src/toolbars/FloatMenu.js +0 -131
- package/src/toolbars/HiddenToolbar.js +0 -36
- package/src/toolbars/HookCenter.js +0 -231
- package/src/toolbars/MenuBase.js +0 -569
- package/src/toolbars/PreviewerBubble.js +0 -608
- package/src/toolbars/ShortcutKeyConfigPanel.js +0 -345
- package/src/toolbars/Sidebar.js +0 -36
- package/src/toolbars/Toc.js +0 -242
- package/src/toolbars/Toolbar.js +0 -449
- package/src/toolbars/ToolbarRight.js +0 -37
- package/src/toolbars/hooks/Audio.js +0 -79
- package/src/toolbars/hooks/BarTable.js +0 -41
- package/src/toolbars/hooks/Bold.js +0 -73
- package/src/toolbars/hooks/Br.js +0 -34
- package/src/toolbars/hooks/ChangeLocale.js +0 -62
- package/src/toolbars/hooks/ChatGpt.js +0 -182
- package/src/toolbars/hooks/CheckList.js +0 -41
- package/src/toolbars/hooks/Code.js +0 -49
- package/src/toolbars/hooks/CodeTheme.js +0 -66
- package/src/toolbars/hooks/Color.js +0 -298
- package/src/toolbars/hooks/Copy.js +0 -141
- package/src/toolbars/hooks/Detail.js +0 -69
- package/src/toolbars/hooks/DrawIo.js +0 -57
- package/src/toolbars/hooks/Export.js +0 -49
- package/src/toolbars/hooks/File.js +0 -79
- package/src/toolbars/hooks/Formula.js +0 -69
- package/src/toolbars/hooks/FullScreen.js +0 -50
- package/src/toolbars/hooks/Graph.js +0 -263
- package/src/toolbars/hooks/H1.js +0 -71
- package/src/toolbars/hooks/H2.js +0 -71
- package/src/toolbars/hooks/H3.js +0 -71
- package/src/toolbars/hooks/Header.js +0 -118
- package/src/toolbars/hooks/Hr.js +0 -35
- package/src/toolbars/hooks/Image.js +0 -91
- package/src/toolbars/hooks/InlineCode.js +0 -53
- package/src/toolbars/hooks/Insert.js +0 -193
- package/src/toolbars/hooks/Italic.js +0 -72
- package/src/toolbars/hooks/Justify.js +0 -49
- package/src/toolbars/hooks/LineTable.js +0 -41
- package/src/toolbars/hooks/Link.js +0 -49
- package/src/toolbars/hooks/List.js +0 -55
- package/src/toolbars/hooks/MobilePreview.js +0 -44
- package/src/toolbars/hooks/Ol.js +0 -41
- package/src/toolbars/hooks/Panel.js +0 -140
- package/src/toolbars/hooks/Pdf.js +0 -78
- package/src/toolbars/hooks/Publish.js +0 -123
- package/src/toolbars/hooks/QuickTable.js +0 -43
- package/src/toolbars/hooks/Quote.js +0 -45
- package/src/toolbars/hooks/Redo.js +0 -33
- package/src/toolbars/hooks/Ruby.js +0 -59
- package/src/toolbars/hooks/Search.js +0 -53
- package/src/toolbars/hooks/Settings.js +0 -220
- package/src/toolbars/hooks/ShortcutKey.js +0 -62
- package/src/toolbars/hooks/Size.js +0 -118
- package/src/toolbars/hooks/Split.js +0 -37
- package/src/toolbars/hooks/Strikethrough.js +0 -71
- package/src/toolbars/hooks/Sub.js +0 -58
- package/src/toolbars/hooks/Sup.js +0 -58
- package/src/toolbars/hooks/SwitchModel.js +0 -56
- package/src/toolbars/hooks/Table.js +0 -56
- package/src/toolbars/hooks/Theme.js +0 -62
- package/src/toolbars/hooks/Toc.js +0 -35
- package/src/toolbars/hooks/TogglePreview.js +0 -91
- package/src/toolbars/hooks/Ul.js +0 -41
- package/src/toolbars/hooks/Underline.js +0 -68
- package/src/toolbars/hooks/Undo.js +0 -30
- package/src/toolbars/hooks/Video.js +0 -79
- package/src/toolbars/hooks/Word.js +0 -78
- package/src/toolbars/hooks/WordCount.js +0 -106
- package/src/utils/autoindent.js +0 -58
- package/src/utils/cm-search-replace.js +0 -794
- package/src/utils/code-preview-language-setting.js +0 -180
- package/src/utils/codeBlockContentHandler.js +0 -400
- package/src/utils/config.js +0 -174
- package/src/utils/copy.js +0 -55
- package/src/utils/dialog.js +0 -214
- package/src/utils/dom.js +0 -163
- package/src/utils/downloadUtil.js +0 -23
- package/src/utils/env.js +0 -22
- package/src/utils/error.js +0 -61
- package/src/utils/event.js +0 -38
- package/src/utils/export.js +0 -166
- package/src/utils/file.js +0 -164
- package/src/utils/formulaUtilsHandler.js +0 -232
- package/src/utils/htmlparser.js +0 -976
- package/src/utils/image.js +0 -99
- package/src/utils/imgSizeHandler.js +0 -279
- package/src/utils/lazyLoadImg.js +0 -327
- package/src/utils/lineFeed.js +0 -49
- package/src/utils/listContentHandler.js +0 -227
- package/src/utils/lookbehind-replace.js +0 -81
- package/src/utils/mathjax.js +0 -89
- package/src/utils/myersDiff.js +0 -211
- package/src/utils/pasteHelper.js +0 -253
- package/src/utils/platformTransform.js +0 -71
- package/src/utils/recount-pos.js +0 -59
- package/src/utils/regexp.js +0 -295
- package/src/utils/sanitize.js +0 -477
- package/src/utils/selection.js +0 -50
- package/src/utils/shortcutKey.js +0 -291
- package/src/utils/svgUtils.js +0 -96
- package/src/utils/tableContentHandler.js +0 -876
- package/test/core/CommonMark.spec.ts +0 -62
- package/test/core/hooks/AutoLink.spec.ts +0 -28
- package/test/core/hooks/List.spec.ts +0 -79
- package/test/core/hooks/__snapshots__/List.spec.ts.snap +0 -11
- package/test/example.md +0 -778
- package/test/node.js +0 -10
- package/test/suites/commonmark.spec.json +0 -5218
- package/test/tsconfig.test.json +0 -6
- package/test/utils/regexp.spec.ts +0 -28
|
@@ -1,58 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
import { getSelection } from '@/utils/selection';
|
|
18
|
-
/**
|
|
19
|
-
* 上标的按钮
|
|
20
|
-
**/
|
|
21
|
-
export default class Sup extends MenuBase {
|
|
22
|
-
constructor($cherry) {
|
|
23
|
-
super($cherry);
|
|
24
|
-
this.setName('sup', 'sup');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
$testIsSup(selection) {
|
|
28
|
-
return /^\s*(\^)[\s\S]+(\1)/.test(selection);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param {string} selection 被用户选中的文本内容
|
|
34
|
-
* @param {string} shortKey 快捷键参数,本函数不处理这个参数
|
|
35
|
-
* @returns {string} 回填到编辑器光标位置/选中文本区域的内容
|
|
36
|
-
*/
|
|
37
|
-
onClick(selection, shortKey = '') {
|
|
38
|
-
let $selection = getSelection(this.editor.editor, selection) || this.locale.sup;
|
|
39
|
-
// 如果选中的内容里有上标的语法,则认为是要去掉上标语法
|
|
40
|
-
if (!this.isSelections && !this.$testIsSup($selection)) {
|
|
41
|
-
this.getMoreSelection('^', '^', () => {
|
|
42
|
-
const newSelection = this.editor.editor.getSelection();
|
|
43
|
-
const isSup = this.$testIsSup(newSelection);
|
|
44
|
-
if (isSup) {
|
|
45
|
-
$selection = newSelection;
|
|
46
|
-
}
|
|
47
|
-
return isSup;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (this.$testIsSup($selection)) {
|
|
51
|
-
return selection.replace(/(^)(\s*)(\^)([^\n]+)(\3)(\s*)($)/gm, '$1$4$7');
|
|
52
|
-
}
|
|
53
|
-
this.registerAfterClickCb(() => {
|
|
54
|
-
this.setLessSelection('^', '^');
|
|
55
|
-
});
|
|
56
|
-
return $selection.replace(/(^)([^\n]+)($)/gm, '$1^$2^$3');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
/**
|
|
18
|
-
* 切换预览/编辑模式的按钮
|
|
19
|
-
* 该按钮不支持切换到双栏编辑模式
|
|
20
|
-
* 只能切换成纯编辑模式和纯预览模式
|
|
21
|
-
**/
|
|
22
|
-
export default class SwitchModel extends MenuBase {
|
|
23
|
-
constructor($cherry) {
|
|
24
|
-
super($cherry);
|
|
25
|
-
this.setName('switchPreview');
|
|
26
|
-
this.instanceId = $cherry.instanceId;
|
|
27
|
-
this.attachEventListeners();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
attachEventListeners() {
|
|
31
|
-
this.$cherry.$event.on('toolbarHide', () => {
|
|
32
|
-
// 当收到工具栏隐藏事件后,修改工具栏的内容为切换到编辑模式的内容
|
|
33
|
-
this.dom.textContent = this.locale.switchEdit;
|
|
34
|
-
});
|
|
35
|
-
this.$cherry.$event.on('toolbarShow', () => {
|
|
36
|
-
// 当收到工具栏显示事件后,修改工具栏的内容为切换到预览模式的内容
|
|
37
|
-
this.dom.textContent = this.locale.switchPreview;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
onClick() {
|
|
42
|
-
if (this.editor.previewer.isPreviewerHidden()) {
|
|
43
|
-
// 从编辑模式切换到预览模式
|
|
44
|
-
this.editor.previewer.previewOnly();
|
|
45
|
-
const toolbar = this.dom.parentElement.parentElement;
|
|
46
|
-
toolbar.classList.add('preview-only');
|
|
47
|
-
this.dom.textContent = this.locale.switchEdit;
|
|
48
|
-
} else {
|
|
49
|
-
// 从预览模式切换到编辑模式
|
|
50
|
-
this.editor.previewer.editOnly(true);
|
|
51
|
-
const toolbar = this.dom.parentElement.parentElement;
|
|
52
|
-
toolbar.classList.remove('preview-only');
|
|
53
|
-
this.dom.textContent = this.locale.switchPreview;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
import BubbleTableMenu from '@/toolbars/BubbleTable';
|
|
18
|
-
/**
|
|
19
|
-
* 插入普通表格
|
|
20
|
-
*/
|
|
21
|
-
export default class Table extends MenuBase {
|
|
22
|
-
constructor($cherry) {
|
|
23
|
-
super($cherry);
|
|
24
|
-
this.setName('table', 'table');
|
|
25
|
-
|
|
26
|
-
this.subBubbleTableMenu = new BubbleTableMenu({ row: 9, col: 9 });
|
|
27
|
-
$cherry.editor.options.wrapperDom.appendChild(this.subBubbleTableMenu.dom);
|
|
28
|
-
this.catchOnce = '';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 响应点击事件
|
|
33
|
-
* @param {string} selection 被用户选中的文本内容
|
|
34
|
-
* @returns {*} 回填到编辑器光标位置/选中文本区域的内容
|
|
35
|
-
*/
|
|
36
|
-
onClick(selection, shortKey = '') {
|
|
37
|
-
// 如果二维面板处于隐藏状态,说明是第一次点击
|
|
38
|
-
if (this.subBubbleTableMenu.dom.style.display === 'none' || !this.hasCacheOnce()) {
|
|
39
|
-
// 插入表格,会出现一个二维面板,用户可以通过点击决定插入表格的行号和列号
|
|
40
|
-
const pos = this.dom.getBoundingClientRect();
|
|
41
|
-
this.subBubbleTableMenu.dom.style.left = `${pos.left + pos.width}px`;
|
|
42
|
-
this.subBubbleTableMenu.dom.style.top = `${pos.top + pos.height}px`;
|
|
43
|
-
this.subBubbleTableMenu.show((row, col) => {
|
|
44
|
-
const headerText = ' Header |'.repeat(col);
|
|
45
|
-
const controlText = ' ------ |'.repeat(col);
|
|
46
|
-
const rowText = `\n|${' Sample |'.repeat(col)}`;
|
|
47
|
-
const final = `${selection}\n\n|${headerText}\n|${controlText}${rowText.repeat(row)}\n\n`;
|
|
48
|
-
this.setCacheOnce(final);
|
|
49
|
-
this.fire(null);
|
|
50
|
-
});
|
|
51
|
-
this.updateMarkdown = false;
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return this.getAndCleanCacheOnce();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
import { changeTheme } from '@/utils/config';
|
|
18
|
-
/**
|
|
19
|
-
* 修改主题
|
|
20
|
-
*/
|
|
21
|
-
export default class Theme extends MenuBase {
|
|
22
|
-
constructor($cherry) {
|
|
23
|
-
super($cherry);
|
|
24
|
-
this.setName('theme', 'insertChart');
|
|
25
|
-
this.subMenuConfig = [];
|
|
26
|
-
const self = this;
|
|
27
|
-
|
|
28
|
-
const themes = $cherry.options.theme || $cherry.options.themeSettings.themeList;
|
|
29
|
-
themes.forEach((one) => {
|
|
30
|
-
self.subMenuConfig.push({
|
|
31
|
-
iconName: one.className,
|
|
32
|
-
name: one.label,
|
|
33
|
-
onclick: self.bindSubClick.bind(self, one.className),
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 绑定子菜单点击事件
|
|
40
|
-
* @param {HTMLDivElement} subMenuDomPanel
|
|
41
|
-
* @returns {number} 当前激活的子菜单索引
|
|
42
|
-
*/
|
|
43
|
-
getActiveSubMenuIndex(subMenuDomPanel) {
|
|
44
|
-
const theme = this.$cherry.wrapperDom.className.match(/theme__([^\s]+)/)?.[1] || '';
|
|
45
|
-
return Array.from(subMenuDomPanel.querySelectorAll('.cherry-dropdown-item')).findIndex((item) =>
|
|
46
|
-
item.querySelector(`.ch-icon-${theme}`),
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 响应点击事件
|
|
52
|
-
* @param {string} selection 被用户选中的文本内容
|
|
53
|
-
* @param {string} shortKey 快捷键参数
|
|
54
|
-
* @returns {string} 回填到编辑器光标位置/选中文本区域的内容
|
|
55
|
-
*/
|
|
56
|
-
onClick(selection, shortKey = '') {
|
|
57
|
-
this.$cherry.$event.emit('changeMainTheme', shortKey);
|
|
58
|
-
changeTheme(this.$cherry, shortKey);
|
|
59
|
-
this.updateMarkdown = false;
|
|
60
|
-
return '';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
/**
|
|
18
|
-
* 插入目录
|
|
19
|
-
*/
|
|
20
|
-
export default class Toc extends MenuBase {
|
|
21
|
-
constructor($cherry) {
|
|
22
|
-
super($cherry);
|
|
23
|
-
this.setName('toc', 'toc');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 响应点击事件
|
|
28
|
-
* @param {string} selection 被用户选中的文本内容
|
|
29
|
-
* @returns {string} 回填到编辑器光标位置/选中文本区域的内容
|
|
30
|
-
*/
|
|
31
|
-
onClick(selection, shortKey = '') {
|
|
32
|
-
// 插入目录
|
|
33
|
-
return `${selection}\n\n[[toc]]\n`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
/**
|
|
18
|
-
* 关闭/展示预览区域的按钮
|
|
19
|
-
*/
|
|
20
|
-
export default class TogglePreview extends MenuBase {
|
|
21
|
-
/** @type {boolean} 当前预览状态 */
|
|
22
|
-
$previewerHidden = false;
|
|
23
|
-
|
|
24
|
-
constructor($cherry) {
|
|
25
|
-
super($cherry);
|
|
26
|
-
this.setName('previewClose', 'previewClose');
|
|
27
|
-
this.instanceId = $cherry.instanceId;
|
|
28
|
-
this.updateMarkdown = false;
|
|
29
|
-
this.attachEventListeners();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 绑定预览事件
|
|
34
|
-
*/
|
|
35
|
-
attachEventListeners() {
|
|
36
|
-
this.$cherry.$event.on('previewerClose', () => {
|
|
37
|
-
this.isHidden = true;
|
|
38
|
-
});
|
|
39
|
-
this.$cherry.$event.on('previewerOpen', () => {
|
|
40
|
-
this.isHidden = false;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get isHidden() {
|
|
45
|
-
return this.$previewerHidden;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
set isHidden(state) {
|
|
49
|
-
// 节流
|
|
50
|
-
if (state === this.$previewerHidden) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const icon = this.dom.querySelector('i');
|
|
54
|
-
// 隐藏预览,按钮状态为打开预览
|
|
55
|
-
if (state) {
|
|
56
|
-
icon.classList.toggle('ch-icon-previewClose', false);
|
|
57
|
-
icon.classList.toggle('ch-icon-preview', true);
|
|
58
|
-
icon.title = this.locale.togglePreview;
|
|
59
|
-
} else {
|
|
60
|
-
icon.classList.toggle('ch-icon-previewClose', true);
|
|
61
|
-
icon.classList.toggle('ch-icon-preview', false);
|
|
62
|
-
icon.title = this.locale.previewClose;
|
|
63
|
-
}
|
|
64
|
-
this.$previewerHidden = state;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 响应点击事件
|
|
69
|
-
*/
|
|
70
|
-
onClick() {
|
|
71
|
-
// 需要浮动预览
|
|
72
|
-
if (this.editor.previewer.isPreviewerNeedFloat()) {
|
|
73
|
-
// 正在浮动预览
|
|
74
|
-
if (this.editor.previewer.isPreviewerFloat()) {
|
|
75
|
-
this.editor.previewer.recoverFloatPreviewer(true);
|
|
76
|
-
this.isHidden = false;
|
|
77
|
-
} else {
|
|
78
|
-
this.editor.previewer.floatPreviewer();
|
|
79
|
-
this.isHidden = true;
|
|
80
|
-
}
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (this.editor.previewer.isPreviewerHidden()) {
|
|
84
|
-
this.editor.previewer.recoverPreviewer(true);
|
|
85
|
-
this.isHidden = false;
|
|
86
|
-
} else {
|
|
87
|
-
this.editor.previewer.editOnly(true);
|
|
88
|
-
this.isHidden = true;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
package/src/toolbars/hooks/Ul.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
import { getSelection } from '@/utils/selection';
|
|
18
|
-
import { getListFromStr } from '@/utils/regexp';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 下标的按钮
|
|
22
|
-
**/
|
|
23
|
-
export default class Ul extends MenuBase {
|
|
24
|
-
constructor($cherry) {
|
|
25
|
-
super($cherry);
|
|
26
|
-
this.setName('ul', 'ul');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {string} selection 被用户选中的文本内容
|
|
32
|
-
* @param {string} shortKey 快捷键参数,本函数不处理这个参数
|
|
33
|
-
* @returns {string} 回填到编辑器光标位置/选中文本区域的内容
|
|
34
|
-
*/
|
|
35
|
-
onClick(selection, shortKey = '') {
|
|
36
|
-
const $selection = getSelection(this.editor.editor, selection, 'line', true) || 'Item 1\n Item 1.1\nItem 2';
|
|
37
|
-
const [before] = $selection.match(/^\n*/);
|
|
38
|
-
const [after] = $selection.match(/\n*$/);
|
|
39
|
-
return `${before}${getListFromStr($selection, 'ul')}${after}`;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
import { CONTROL_KEY, getKeyCode } from '@/utils/shortcutKey';
|
|
18
|
-
/**
|
|
19
|
-
* 下划线按钮
|
|
20
|
-
**/
|
|
21
|
-
export default class Underline extends MenuBase {
|
|
22
|
-
/**
|
|
23
|
-
* @param {import('@/toolbars/MenuBase').MenuBaseConstructorParams} $cherry
|
|
24
|
-
*/
|
|
25
|
-
constructor($cherry) {
|
|
26
|
-
super($cherry);
|
|
27
|
-
this.setName('underline', 'underline');
|
|
28
|
-
this.shortcutKeyMap = {
|
|
29
|
-
[`${CONTROL_KEY}-${getKeyCode('u')}`]: {
|
|
30
|
-
hookName: this.name,
|
|
31
|
-
aliasName: this.$cherry.locale[this.name],
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
$testIsUnderline(selection) {
|
|
37
|
-
return /^\s*(\/)[\s\S]+(\1)/.test(selection);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @param {string} selection 被用户选中的文本内容
|
|
43
|
-
* @param {string} shortKey 快捷键参数,本函数不处理这个参数
|
|
44
|
-
* @returns {string} 回填到编辑器光标位置/选中文本区域的内容
|
|
45
|
-
*/
|
|
46
|
-
onClick(selection, shortKey = '') {
|
|
47
|
-
let $selection = selection ? selection : this.locale.underline;
|
|
48
|
-
// 如果选中的内容里有下划线语法,则认为是要去掉下划线语法
|
|
49
|
-
if (!this.isSelections && !this.$testIsUnderline($selection)) {
|
|
50
|
-
this.getMoreSelection(' /', '/ ', () => {
|
|
51
|
-
const newSelection = this.editor.editor.getSelection();
|
|
52
|
-
const isUnderline = this.$testIsUnderline(newSelection);
|
|
53
|
-
if (isUnderline) {
|
|
54
|
-
$selection = newSelection;
|
|
55
|
-
}
|
|
56
|
-
return isUnderline;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (this.$testIsUnderline($selection)) {
|
|
60
|
-
return $selection.replace(/(^)(\s*)(\/)([^\n]+)(\3)(\s*)($)/gm, '$1$4$7');
|
|
61
|
-
}
|
|
62
|
-
this.registerAfterClickCb(() => {
|
|
63
|
-
this.setLessSelection(' /', '/ ');
|
|
64
|
-
});
|
|
65
|
-
// 如果选中的内容里没有下划线语法,则加上下划线
|
|
66
|
-
return $selection.replace(/(^)([^\n]+)($)/gm, '$1 /$2/ $3');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
/**
|
|
18
|
-
* 撤销回退按钮,点击后触发编辑器的undo操作
|
|
19
|
-
* 依赖codemirror的undo接口
|
|
20
|
-
**/
|
|
21
|
-
export default class Undo extends MenuBase {
|
|
22
|
-
constructor($cherry) {
|
|
23
|
-
super($cherry);
|
|
24
|
-
this.setName('undo', 'undo');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
onClick() {
|
|
28
|
-
this.editor.editor.undo();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
import { handleUpload, handleParams, handleUploadMulti } from '@/utils/file';
|
|
18
|
-
/**
|
|
19
|
-
* 插入视频
|
|
20
|
-
*/
|
|
21
|
-
export default class Video extends MenuBase {
|
|
22
|
-
constructor($cherry) {
|
|
23
|
-
super($cherry);
|
|
24
|
-
this.setName('video', 'video');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 响应点击事件
|
|
29
|
-
* @param {string} selection 被用户选中的文本内容
|
|
30
|
-
* @returns {string} 回填到编辑器光标位置/选中文本区域的内容
|
|
31
|
-
*/
|
|
32
|
-
onClick(selection, shortKey = '') {
|
|
33
|
-
const accept = this.$cherry.options?.fileTypeLimitMap?.video ?? '*';
|
|
34
|
-
const multiple = this.$cherry?.options.multipleFileSelection?.video ?? false;
|
|
35
|
-
if (multiple) {
|
|
36
|
-
if (this.hasCacheOnce()) {
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
const arr = this.getAndCleanCacheOnce();
|
|
39
|
-
let res = '';
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
for (const { url, params } of arr) {
|
|
42
|
-
const begin = '!video[';
|
|
43
|
-
const end = params.poster ? `](${url}){poster=${params.poster}}` : `](${url})`;
|
|
44
|
-
this.registerAfterClickCb(() => {
|
|
45
|
-
this.setLessSelection(begin, end);
|
|
46
|
-
});
|
|
47
|
-
const finalName = params.name ? params.name : name;
|
|
48
|
-
res += `${begin}${finalName}${handleParams(params)}${end}\n`;
|
|
49
|
-
}
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
// 插入图片,调用上传文件逻辑
|
|
53
|
-
handleUploadMulti(this.editor, 'video', accept, (arr) => {
|
|
54
|
-
this.setCacheOnce(arr);
|
|
55
|
-
this.fire(null);
|
|
56
|
-
});
|
|
57
|
-
this.updateMarkdown = false;
|
|
58
|
-
return selection;
|
|
59
|
-
}
|
|
60
|
-
if (this.hasCacheOnce()) {
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
const { name, url, params } = this.getAndCleanCacheOnce();
|
|
63
|
-
const begin = '!video[';
|
|
64
|
-
const end = params.poster ? `](${url}){poster=${params.poster}}` : `](${url})`;
|
|
65
|
-
this.registerAfterClickCb(() => {
|
|
66
|
-
this.setLessSelection(begin, end);
|
|
67
|
-
});
|
|
68
|
-
const finalName = params.name ? params.name : name;
|
|
69
|
-
return `${begin}${finalName}${handleParams(params)}${end}`;
|
|
70
|
-
}
|
|
71
|
-
// 插入图片,调用上传文件逻辑
|
|
72
|
-
handleUpload(this.editor, 'video', accept, (name, url, params) => {
|
|
73
|
-
this.setCacheOnce({ name, url, params });
|
|
74
|
-
this.fire(null);
|
|
75
|
-
});
|
|
76
|
-
this.updateMarkdown = false;
|
|
77
|
-
return selection;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
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 MenuBase from '@/toolbars/MenuBase';
|
|
17
|
-
import { handleUpload, handleUploadMulti } from '@/utils/file';
|
|
18
|
-
/**
|
|
19
|
-
* 插入word
|
|
20
|
-
*/
|
|
21
|
-
export default class Word extends MenuBase {
|
|
22
|
-
constructor($cherry) {
|
|
23
|
-
super($cherry);
|
|
24
|
-
this.setName('word', 'word');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 响应点击事件
|
|
29
|
-
* @param {string} selection 被用户选中的文本内容
|
|
30
|
-
* @returns {string} 回填到编辑器光标位置/选中文本区域的内容
|
|
31
|
-
*/
|
|
32
|
-
onClick(selection, shortKey = '') {
|
|
33
|
-
const accept = this.$cherry.options?.fileTypeLimitMap?.word ?? '*';
|
|
34
|
-
const multiple = this.$cherry?.options.multipleFileSelection?.word ?? false;
|
|
35
|
-
if (multiple) {
|
|
36
|
-
if (this.hasCacheOnce()) {
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
const arr = this.getAndCleanCacheOnce();
|
|
39
|
-
let res = '';
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
for (const { url, params } of arr) {
|
|
42
|
-
const begin = '[';
|
|
43
|
-
const end = `](${url})`;
|
|
44
|
-
this.registerAfterClickCb(() => {
|
|
45
|
-
this.setLessSelection(begin, end);
|
|
46
|
-
});
|
|
47
|
-
const finalName = params.name ? params.name : name;
|
|
48
|
-
res += `${begin}${finalName}${end}\n`;
|
|
49
|
-
}
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
handleUploadMulti(this.editor, 'word', accept, (arr) => {
|
|
53
|
-
this.setCacheOnce(arr);
|
|
54
|
-
this.fire(null);
|
|
55
|
-
});
|
|
56
|
-
this.updateMarkdown = false;
|
|
57
|
-
return selection;
|
|
58
|
-
}
|
|
59
|
-
if (this.hasCacheOnce()) {
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
const { name, url, params } = this.getAndCleanCacheOnce();
|
|
62
|
-
const begin = '[';
|
|
63
|
-
const end = `](${url})`;
|
|
64
|
-
this.registerAfterClickCb(() => {
|
|
65
|
-
this.setLessSelection(begin, end);
|
|
66
|
-
});
|
|
67
|
-
const finalName = params.name ? params.name : name;
|
|
68
|
-
return `${begin}${finalName}${end}`;
|
|
69
|
-
}
|
|
70
|
-
// 插入图片,调用上传文件逻辑
|
|
71
|
-
handleUpload(this.editor, 'word', accept, (name, url, params) => {
|
|
72
|
-
this.setCacheOnce({ name, url, params });
|
|
73
|
-
this.fire(null);
|
|
74
|
-
});
|
|
75
|
-
this.updateMarkdown = false;
|
|
76
|
-
return selection;
|
|
77
|
-
}
|
|
78
|
-
}
|