vditor 3.8.7
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/CHANGELOG.md +1072 -0
- package/LICENSE +21 -0
- package/README.md +649 -0
- package/dist/css/content-theme/ant-design.css +210 -0
- package/dist/css/content-theme/dark.css +123 -0
- package/dist/css/content-theme/light.css +101 -0
- package/dist/css/content-theme/wechat.css +94 -0
- package/dist/images/.DS_Store +0 -0
- package/dist/images/emoji/b3log.png +0 -0
- package/dist/images/emoji/chainbook.png +0 -0
- package/dist/images/emoji/doge.png +0 -0
- package/dist/images/emoji/hacpai.png +0 -0
- package/dist/images/emoji/huaji.gif +0 -0
- package/dist/images/emoji/latke.png +0 -0
- package/dist/images/emoji/lute.png +0 -0
- package/dist/images/emoji/octocat.png +0 -0
- package/dist/images/emoji/pipe.png +0 -0
- package/dist/images/emoji/solo.png +0 -0
- package/dist/images/emoji/sym.png +0 -0
- package/dist/images/emoji/trollface.png +0 -0
- package/dist/images/emoji/vditor.png +0 -0
- package/dist/images/emoji/wide.png +0 -0
- package/dist/images/emoji/wulian.png +0 -0
- package/dist/images/img-loading.svg +1 -0
- package/dist/images/logo.png +0 -0
- package/dist/index.css +28 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.min.js +15353 -0
- package/dist/js/.DS_Store +0 -0
- package/dist/js/abcjs/abcjs_basic.min.js +3 -0
- package/dist/js/echarts/echarts.min.js +23 -0
- package/dist/js/flowchart.js/flowchart.min.js +9 -0
- package/dist/js/graphviz/full.render.js +90 -0
- package/dist/js/graphviz/viz.js +333 -0
- package/dist/js/highlight.js/highlight.pack.js +1617 -0
- package/dist/js/highlight.js/styles/abap.css +155 -0
- package/dist/js/highlight.js/styles/algol.css +142 -0
- package/dist/js/highlight.js/styles/algol_nu.css +90 -0
- package/dist/js/highlight.js/styles/ant-design.css +469 -0
- package/dist/js/highlight.js/styles/arduino.css +155 -0
- package/dist/js/highlight.js/styles/autumn.css +136 -0
- package/dist/js/highlight.js/styles/borland.css +146 -0
- package/dist/js/highlight.js/styles/bw.css +149 -0
- package/dist/js/highlight.js/styles/colorful.css +156 -0
- package/dist/js/highlight.js/styles/dracula.css +139 -0
- package/dist/js/highlight.js/styles/emacs.css +166 -0
- package/dist/js/highlight.js/styles/friendly.css +182 -0
- package/dist/js/highlight.js/styles/fruity.css +121 -0
- package/dist/js/highlight.js/styles/github.css +173 -0
- package/dist/js/highlight.js/styles/igor.css +122 -0
- package/dist/js/highlight.js/styles/lovelace.css +145 -0
- package/dist/js/highlight.js/styles/manni.css +138 -0
- package/dist/js/highlight.js/styles/monokai.css +131 -0
- package/dist/js/highlight.js/styles/monokailight.css +179 -0
- package/dist/js/highlight.js/styles/murphy.css +144 -0
- package/dist/js/highlight.js/styles/native.css +163 -0
- package/dist/js/highlight.js/styles/paraiso-dark.css +136 -0
- package/dist/js/highlight.js/styles/paraiso-light.css +135 -0
- package/dist/js/highlight.js/styles/pastie.css +180 -0
- package/dist/js/highlight.js/styles/perldoc.css +140 -0
- package/dist/js/highlight.js/styles/pygments.css +158 -0
- package/dist/js/highlight.js/styles/rainbow_dash.css +163 -0
- package/dist/js/highlight.js/styles/rrt.css +158 -0
- package/dist/js/highlight.js/styles/solarized-dark.css +145 -0
- package/dist/js/highlight.js/styles/solarized-dark256.css +145 -0
- package/dist/js/highlight.js/styles/solarized-light.css +162 -0
- package/dist/js/highlight.js/styles/swapoff.css +144 -0
- package/dist/js/highlight.js/styles/tango.css +183 -0
- package/dist/js/highlight.js/styles/trac.css +166 -0
- package/dist/js/highlight.js/styles/vim.css +143 -0
- package/dist/js/highlight.js/styles/vs.css +112 -0
- package/dist/js/highlight.js/styles/xcode.css +173 -0
- package/dist/js/i18n/en_US.js +85 -0
- package/dist/js/i18n/ja_JP.js +85 -0
- package/dist/js/i18n/ko_KR.js +85 -0
- package/dist/js/i18n/ru_RU.js +85 -0
- package/dist/js/i18n/zh_CN.js +85 -0
- package/dist/js/i18n/zh_TW.js +85 -0
- package/dist/js/icons/ant.js +174 -0
- package/dist/js/icons/material.js +195 -0
- package/dist/js/katex/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/js/katex/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/js/katex/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/js/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/js/katex/katex.min.css +1 -0
- package/dist/js/katex/katex.min.js +2 -0
- package/dist/js/lute/.DS_Store +0 -0
- package/dist/js/lute/lute.min.js +46 -0
- package/dist/js/mathjax/.DS_Store +0 -0
- package/dist/js/mathjax/LICENSE +202 -0
- package/dist/js/mathjax/a11y/assistive-mml.js +1 -0
- package/dist/js/mathjax/a11y/complexity.js +1 -0
- package/dist/js/mathjax/a11y/explorer.js +1 -0
- package/dist/js/mathjax/a11y/semantic-enrich.js +1 -0
- package/dist/js/mathjax/input/asciimath.js +1 -0
- package/dist/js/mathjax/input/mml/entities.js +1 -0
- package/dist/js/mathjax/input/mml.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/action.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/all-packages.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/ams.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/amscd.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/autoload.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/bbox.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/boldsymbol.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/braket.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/bussproofs.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/cancel.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/color.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/colorV2.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/configMacros.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/enclose.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/extpfeil.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/html.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/mhchem.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/newcommand.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/noerrors.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/noundefined.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/physics.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/require.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/tagFormat.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/textmacros.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/unicode.js +1 -0
- package/dist/js/mathjax/input/tex/extensions/verb.js +1 -0
- package/dist/js/mathjax/input/tex-base.js +1 -0
- package/dist/js/mathjax/input/tex-full.js +1 -0
- package/dist/js/mathjax/input/tex.js +1 -0
- package/dist/js/mathjax/sre/mathmaps/de.js +104 -0
- package/dist/js/mathjax/sre/mathmaps/en.js +110 -0
- package/dist/js/mathjax/sre/mathmaps/es.js +104 -0
- package/dist/js/mathjax/sre/mathmaps/fr.js +104 -0
- package/dist/js/mathjax/sre/mathmaps/mathmaps_ie.js +518 -0
- package/dist/js/mathjax/sre/mathmaps/nemeth.js +104 -0
- package/dist/js/mathjax/sre/sre-node.js +11 -0
- package/dist/js/mathjax/sre/sre_browser.js +1633 -0
- package/dist/js/mathjax/tex-svg-full.js +1 -0
- package/dist/js/mermaid/mermaid.min.js +32 -0
- package/dist/js/plantuml/plantuml-encoder.min.js +1 -0
- package/dist/method.d.ts +48 -0
- package/dist/method.min.js +2346 -0
- package/dist/ts/constants.d.ts +43 -0
- package/dist/ts/devtools/index.d.ts +7 -0
- package/dist/ts/export/index.d.ts +5 -0
- package/dist/ts/hint/index.d.ts +14 -0
- package/dist/ts/ir/expandMarker.d.ts +2 -0
- package/dist/ts/ir/highlightToolbarIR.d.ts +2 -0
- package/dist/ts/ir/index.d.ts +13 -0
- package/dist/ts/ir/input.d.ts +2 -0
- package/dist/ts/ir/process.d.ts +9 -0
- package/dist/ts/ir/processKeydown.d.ts +2 -0
- package/dist/ts/markdown/abcRender.d.ts +1 -0
- package/dist/ts/markdown/adapterRender.d.ts +33 -0
- package/dist/ts/markdown/anchorRender.d.ts +1 -0
- package/dist/ts/markdown/chartRender.d.ts +1 -0
- package/dist/ts/markdown/codeRender.d.ts +1 -0
- package/dist/ts/markdown/flowchartRender.d.ts +1 -0
- package/dist/ts/markdown/getHTML.d.ts +2 -0
- package/dist/ts/markdown/getMarkdown.d.ts +2 -0
- package/dist/ts/markdown/graphvizRender.d.ts +1 -0
- package/dist/ts/markdown/highlightRender.d.ts +2 -0
- package/dist/ts/markdown/lazyLoadImageRender.d.ts +6 -0
- package/dist/ts/markdown/mathRender.d.ts +10 -0
- package/dist/ts/markdown/mediaRender.d.ts +1 -0
- package/dist/ts/markdown/mermaidRender.d.ts +1 -0
- package/dist/ts/markdown/mindmapRender.d.ts +1 -0
- package/dist/ts/markdown/outlineRender.d.ts +2 -0
- package/dist/ts/markdown/plantumlRender.d.ts +1 -0
- package/dist/ts/markdown/previewRender.d.ts +3 -0
- package/dist/ts/markdown/setLute.d.ts +2 -0
- package/dist/ts/markdown/speechRender.d.ts +7 -0
- package/dist/ts/outline/index.d.ts +7 -0
- package/dist/ts/preview/image.d.ts +2 -0
- package/dist/ts/preview/index.d.ts +9 -0
- package/dist/ts/resize/index.d.ts +6 -0
- package/dist/ts/sv/index.d.ts +13 -0
- package/dist/ts/sv/inputEvent.d.ts +2 -0
- package/dist/ts/sv/process.d.ts +12 -0
- package/dist/ts/sv/processKeydown.d.ts +2 -0
- package/dist/ts/tip/index.d.ts +6 -0
- package/dist/ts/toolbar/Both.d.ts +5 -0
- package/dist/ts/toolbar/Br.d.ts +4 -0
- package/dist/ts/toolbar/CodeTheme.d.ts +6 -0
- package/dist/ts/toolbar/ContentTheme.d.ts +6 -0
- package/dist/ts/toolbar/Counter.d.ts +6 -0
- package/dist/ts/toolbar/Custom.d.ts +5 -0
- package/dist/ts/toolbar/Devtools.d.ts +5 -0
- package/dist/ts/toolbar/Divider.d.ts +4 -0
- package/dist/ts/toolbar/EditMode.d.ts +8 -0
- package/dist/ts/toolbar/Emoji.d.ts +7 -0
- package/dist/ts/toolbar/Export.d.ts +6 -0
- package/dist/ts/toolbar/Fullscreen.d.ts +6 -0
- package/dist/ts/toolbar/Headings.d.ts +7 -0
- package/dist/ts/toolbar/Help.d.ts +5 -0
- package/dist/ts/toolbar/Indent.d.ts +5 -0
- package/dist/ts/toolbar/Info.d.ts +5 -0
- package/dist/ts/toolbar/InsertAfter.d.ts +5 -0
- package/dist/ts/toolbar/InsertBefore.d.ts +5 -0
- package/dist/ts/toolbar/MenuItem.d.ts +5 -0
- package/dist/ts/toolbar/Outdent.d.ts +5 -0
- package/dist/ts/toolbar/Outline.d.ts +5 -0
- package/dist/ts/toolbar/Preview.d.ts +6 -0
- package/dist/ts/toolbar/Record.d.ts +6 -0
- package/dist/ts/toolbar/Redo.d.ts +5 -0
- package/dist/ts/toolbar/Undo.d.ts +5 -0
- package/dist/ts/toolbar/Upload.d.ts +6 -0
- package/dist/ts/toolbar/index.d.ts +9 -0
- package/dist/ts/toolbar/setToolbar.d.ts +21 -0
- package/dist/ts/ui/initUI.d.ts +9 -0
- package/dist/ts/ui/setCodeTheme.d.ts +1 -0
- package/dist/ts/ui/setContentTheme.d.ts +1 -0
- package/dist/ts/ui/setPreviewMode.d.ts +2 -0
- package/dist/ts/ui/setTheme.d.ts +2 -0
- package/dist/ts/undo/index.d.ts +19 -0
- package/dist/ts/upload/getElement.d.ts +2 -0
- package/dist/ts/upload/index.d.ts +9 -0
- package/dist/ts/upload/setHeaders.d.ts +2 -0
- package/dist/ts/util/Options.d.ts +8 -0
- package/dist/ts/util/RecordMedia.d.ts +18 -0
- package/dist/ts/util/addScript.d.ts +2 -0
- package/dist/ts/util/addStyle.d.ts +1 -0
- package/dist/ts/util/code160to32.d.ts +1 -0
- package/dist/ts/util/compatibility.d.ts +7 -0
- package/dist/ts/util/editorCommonEvent.d.ts +10 -0
- package/dist/ts/util/fixBrowserBehavior.d.ts +40 -0
- package/dist/ts/util/getSelectText.d.ts +1 -0
- package/dist/ts/util/hasClosest.d.ts +9 -0
- package/dist/ts/util/hasClosestByHeadings.d.ts +2 -0
- package/dist/ts/util/highlightToolbar.d.ts +2 -0
- package/dist/ts/util/hotKey.d.ts +1 -0
- package/dist/ts/util/log.d.ts +1 -0
- package/dist/ts/util/merge.d.ts +1 -0
- package/dist/ts/util/processCode.d.ts +3 -0
- package/dist/ts/util/selection.d.ts +15 -0
- package/dist/ts/util/toc.d.ts +6 -0
- package/dist/ts/wysiwyg/afterRenderEvent.d.ts +6 -0
- package/dist/ts/wysiwyg/highlightToolbarWYSIWYG.d.ts +5 -0
- package/dist/ts/wysiwyg/index.d.ts +20 -0
- package/dist/ts/wysiwyg/inlineTag.d.ts +11 -0
- package/dist/ts/wysiwyg/input.d.ts +2 -0
- package/dist/ts/wysiwyg/processKeydown.d.ts +3 -0
- package/dist/ts/wysiwyg/renderDomByMd.d.ts +6 -0
- package/dist/ts/wysiwyg/setHeading.d.ts +3 -0
- package/dist/ts/wysiwyg/showCode.d.ts +2 -0
- package/dist/ts/wysiwyg/toolbarEvent.d.ts +2 -0
- package/dist/types/index.d.ts +772 -0
- package/package.json +69 -0
- package/src/assets/.DS_Store +0 -0
- package/src/assets/scss/_content.scss +284 -0
- package/src/assets/scss/_hint.scss +67 -0
- package/src/assets/scss/_ir.scss +275 -0
- package/src/assets/scss/_panel.scss +110 -0
- package/src/assets/scss/_reset.scss +603 -0
- package/src/assets/scss/_sv.scss +133 -0
- package/src/assets/scss/_toolbar.scss +180 -0
- package/src/assets/scss/_tooltipped.scss +171 -0
- package/src/assets/scss/_wysiwyg.scss +195 -0
- package/src/assets/scss/index.scss +83 -0
- package/src/index.ts +502 -0
- package/src/method.ts +65 -0
- package/src/ts/.DS_Store +0 -0
- package/src/ts/constants.ts +64 -0
- package/src/ts/devtools/index.ts +83 -0
- package/src/ts/export/index.ts +81 -0
- package/src/ts/hint/index.ts +267 -0
- package/src/ts/ir/expandMarker.ts +79 -0
- package/src/ts/ir/highlightToolbarIR.ts +97 -0
- package/src/ts/ir/index.ts +251 -0
- package/src/ts/ir/input.ts +231 -0
- package/src/ts/ir/process.ts +220 -0
- package/src/ts/ir/processKeydown.ts +238 -0
- package/src/ts/markdown/abcRender.ts +27 -0
- package/src/ts/markdown/adapterRender.ts +33 -0
- package/src/ts/markdown/anchorRender.ts +19 -0
- package/src/ts/markdown/chartRender.ts +37 -0
- package/src/ts/markdown/codeRender.ts +50 -0
- package/src/ts/markdown/flowchartRender.ts +25 -0
- package/src/ts/markdown/getHTML.ts +11 -0
- package/src/ts/markdown/getMarkdown.ts +12 -0
- package/src/ts/markdown/graphvizRender.ts +49 -0
- package/src/ts/markdown/highlightRender.ts +82 -0
- package/src/ts/markdown/lazyLoadImageRender.ts +56 -0
- package/src/ts/markdown/mathRender.ts +142 -0
- package/src/ts/markdown/mediaRender.ts +78 -0
- package/src/ts/markdown/mermaidRender.ts +127 -0
- package/src/ts/markdown/mindmapRender.ts +74 -0
- package/src/ts/markdown/outlineRender.ts +106 -0
- package/src/ts/markdown/plantumlRender.ts +32 -0
- package/src/ts/markdown/previewRender.ts +143 -0
- package/src/ts/markdown/setLute.ts +23 -0
- package/src/ts/markdown/speechRender.ts +97 -0
- package/src/ts/outline/index.ts +47 -0
- package/src/ts/preview/image.ts +50 -0
- package/src/ts/preview/index.ts +266 -0
- package/src/ts/resize/index.ts +57 -0
- package/src/ts/sv/index.ts +119 -0
- package/src/ts/sv/inputEvent.ts +207 -0
- package/src/ts/sv/process.ts +210 -0
- package/src/ts/sv/processKeydown.ts +196 -0
- package/src/ts/tip/index.ts +31 -0
- package/src/ts/toolbar/Both.ts +28 -0
- package/src/ts/toolbar/Br.ts +8 -0
- package/src/ts/toolbar/CodeTheme.ts +36 -0
- package/src/ts/toolbar/ContentTheme.ts +35 -0
- package/src/ts/toolbar/Counter.ts +40 -0
- package/src/ts/toolbar/Custom.ts +17 -0
- package/src/ts/toolbar/Devtools.ts +28 -0
- package/src/ts/toolbar/Divider.ts +8 -0
- package/src/ts/toolbar/EditMode.ts +193 -0
- package/src/ts/toolbar/Emoji.ts +75 -0
- package/src/ts/toolbar/Export.ts +41 -0
- package/src/ts/toolbar/Fullscreen.ts +61 -0
- package/src/ts/toolbar/Headings.ts +69 -0
- package/src/ts/toolbar/Help.ts +30 -0
- package/src/ts/toolbar/Indent.ts +25 -0
- package/src/ts/toolbar/Info.ts +43 -0
- package/src/ts/toolbar/InsertAfter.ts +18 -0
- package/src/ts/toolbar/InsertBefore.ts +18 -0
- package/src/ts/toolbar/MenuItem.ts +54 -0
- package/src/ts/toolbar/Outdent.ts +24 -0
- package/src/ts/toolbar/Outline.ts +21 -0
- package/src/ts/toolbar/Preview.ts +55 -0
- package/src/ts/toolbar/Record.ts +60 -0
- package/src/ts/toolbar/Redo.ts +18 -0
- package/src/ts/toolbar/Undo.ts +18 -0
- package/src/ts/toolbar/Upload.ts +41 -0
- package/src/ts/toolbar/index.ts +175 -0
- package/src/ts/toolbar/setToolbar.ts +120 -0
- package/src/ts/ui/initUI.ts +164 -0
- package/src/ts/ui/setCodeTheme.ts +16 -0
- package/src/ts/ui/setContentTheme.ts +15 -0
- package/src/ts/ui/setPreviewMode.ts +31 -0
- package/src/ts/ui/setTheme.ts +7 -0
- package/src/ts/undo/index.ts +255 -0
- package/src/ts/upload/getElement.ts +10 -0
- package/src/ts/upload/index.ts +257 -0
- package/src/ts/upload/setHeaders.ts +10 -0
- package/src/ts/util/Options.ts +429 -0
- package/src/ts/util/RecordMedia.ts +170 -0
- package/src/ts/util/addScript.ts +40 -0
- package/src/ts/util/addStyle.ts +10 -0
- package/src/ts/util/code160to32.ts +4 -0
- package/src/ts/util/compatibility.ts +67 -0
- package/src/ts/util/editorCommonEvent.ts +254 -0
- package/src/ts/util/fixBrowserBehavior.ts +1459 -0
- package/src/ts/util/getSelectText.ts +8 -0
- package/src/ts/util/hasClosest.ts +154 -0
- package/src/ts/util/hasClosestByHeadings.ts +27 -0
- package/src/ts/util/highlightToolbar.ts +10 -0
- package/src/ts/util/hotKey.ts +54 -0
- package/src/ts/util/log.ts +6 -0
- package/src/ts/util/merge.ts +18 -0
- package/src/ts/util/processCode.ts +90 -0
- package/src/ts/util/selection.ts +275 -0
- package/src/ts/util/toc.ts +83 -0
- package/src/ts/wysiwyg/afterRenderEvent.ts +41 -0
- package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +1105 -0
- package/src/ts/wysiwyg/index.ts +547 -0
- package/src/ts/wysiwyg/inlineTag.ts +129 -0
- package/src/ts/wysiwyg/input.ts +210 -0
- package/src/ts/wysiwyg/processKeydown.ts +363 -0
- package/src/ts/wysiwyg/renderDomByMd.ts +18 -0
- package/src/ts/wysiwyg/setHeading.ts +43 -0
- package/src/ts/wysiwyg/showCode.ts +32 -0
- package/src/ts/wysiwyg/toolbarEvent.ts +333 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
$errorColor: #d23f31 !default;
|
|
2
|
+
$blurColor: #4285f4 !default;
|
|
3
|
+
|
|
4
|
+
$font-family-base: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", "EmojiSymbols" !default;
|
|
5
|
+
$font-family-code: mononoki, Consolas, "Liberation Mono", Menlo, Courier, monospace, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", "EmojiSymbols" !default;
|
|
6
|
+
|
|
7
|
+
$transition: all .15s ease-in-out !default;
|
|
8
|
+
|
|
9
|
+
$max-width: 520px !default;
|
|
10
|
+
|
|
11
|
+
.vditor {
|
|
12
|
+
--border-color: #d1d5da;
|
|
13
|
+
--second-color: rgba(88, 96, 105, 0.36);
|
|
14
|
+
|
|
15
|
+
--panel-background-color: #fff;
|
|
16
|
+
--panel-shadow: 0 1px 2px rgba(0, 0, 0, .2);
|
|
17
|
+
|
|
18
|
+
--toolbar-background-color: #f6f8fa;
|
|
19
|
+
--toolbar-icon-color: #586069;
|
|
20
|
+
--toolbar-icon-hover-color: #{$blurColor};
|
|
21
|
+
--toolbar-height: 35px;
|
|
22
|
+
--toolbar-divider-margin-top: 8px;
|
|
23
|
+
|
|
24
|
+
--textarea-background-color: #fafbfc;
|
|
25
|
+
--textarea-text-color: #24292e;
|
|
26
|
+
|
|
27
|
+
--resize-icon-color: var(--toolbar-icon-color);
|
|
28
|
+
--resize-background-color: var(--toolbar-background-color);
|
|
29
|
+
--resize-hover-icon-color: var(--panel-background-color);
|
|
30
|
+
--resize-hover-background-color: var(--toolbar-icon-hover-color);
|
|
31
|
+
|
|
32
|
+
--count-background-color:rgba(27, 31, 35, .05);
|
|
33
|
+
--heading-border-color: #eaecef;
|
|
34
|
+
--blockquote-color: #6a737d;
|
|
35
|
+
|
|
36
|
+
--ir-heading-color: #660e7a;
|
|
37
|
+
--ir-title-color: #808080;
|
|
38
|
+
--ir-bi-color: #0033b3;
|
|
39
|
+
--ir-link-color: #008000;
|
|
40
|
+
--ir-bracket-color: #0000ff;
|
|
41
|
+
--ir-paren-color: #008000;
|
|
42
|
+
|
|
43
|
+
&--dark {
|
|
44
|
+
--border-color: #141414;
|
|
45
|
+
--second-color: rgba(185, 185, 185, .36);
|
|
46
|
+
|
|
47
|
+
--panel-background-color: #24292e;
|
|
48
|
+
--panel-shadow: 0 1px 2px rgba(255, 255, 255, .2);
|
|
49
|
+
|
|
50
|
+
--toolbar-background-color: #1d2125;
|
|
51
|
+
--toolbar-icon-color: #b9b9b9;
|
|
52
|
+
--toolbar-icon-hover-color: #fff;
|
|
53
|
+
|
|
54
|
+
--textarea-background-color: #2f363d;
|
|
55
|
+
--textarea-text-color: #d1d5da;
|
|
56
|
+
|
|
57
|
+
--resize-icon-color: var(--border-color);
|
|
58
|
+
--resize-background-color: var(--second-color);
|
|
59
|
+
--resize-hover-icon-color: var(--toolbar-icon-hover-color);
|
|
60
|
+
--resize-hover-background-color: rgba(185, 185, 185, .86);
|
|
61
|
+
|
|
62
|
+
--count-background-color: #{rgba($blurColor, .36)};
|
|
63
|
+
--heading-border-color: var(--textarea-text-color);
|
|
64
|
+
--blockquote-color: var(--toolbar-icon-color);
|
|
65
|
+
|
|
66
|
+
--ir-heading-color: #9876aa;
|
|
67
|
+
--ir-title-color: #808080;
|
|
68
|
+
--ir-bi-color: #cc7832;
|
|
69
|
+
--ir-link-color: #ffc66d;
|
|
70
|
+
--ir-bracket-color: #287bde;
|
|
71
|
+
--ir-paren-color: #6a8759;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@import "tooltipped";
|
|
76
|
+
@import "panel";
|
|
77
|
+
@import "toolbar";
|
|
78
|
+
@import "content";
|
|
79
|
+
@import "hint";
|
|
80
|
+
@import "reset";
|
|
81
|
+
@import "wysiwyg";
|
|
82
|
+
@import "ir";
|
|
83
|
+
@import "sv";
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import "./assets/scss/index.scss";
|
|
2
|
+
import VditorMethod from "./method";
|
|
3
|
+
import {Constants, VDITOR_VERSION} from "./ts/constants";
|
|
4
|
+
import {DevTools} from "./ts/devtools/index";
|
|
5
|
+
import {Hint} from "./ts/hint/index";
|
|
6
|
+
import {IR} from "./ts/ir/index";
|
|
7
|
+
import {input as irInput} from "./ts/ir/input";
|
|
8
|
+
import {processAfterRender} from "./ts/ir/process";
|
|
9
|
+
import {getHTML} from "./ts/markdown/getHTML";
|
|
10
|
+
import {getMarkdown} from "./ts/markdown/getMarkdown";
|
|
11
|
+
import {setLute} from "./ts/markdown/setLute";
|
|
12
|
+
import {Outline} from "./ts/outline/index";
|
|
13
|
+
import {Preview} from "./ts/preview/index";
|
|
14
|
+
import {Resize} from "./ts/resize/index";
|
|
15
|
+
import {Editor} from "./ts/sv/index";
|
|
16
|
+
import {inputEvent} from "./ts/sv/inputEvent";
|
|
17
|
+
import {processAfterRender as processSVAfterRender} from "./ts/sv/process";
|
|
18
|
+
import {Tip} from "./ts/tip/index";
|
|
19
|
+
import {Toolbar} from "./ts/toolbar/index";
|
|
20
|
+
import {disableToolbar, hidePanel} from "./ts/toolbar/setToolbar";
|
|
21
|
+
import {enableToolbar} from "./ts/toolbar/setToolbar";
|
|
22
|
+
import {initUI} from "./ts/ui/initUI";
|
|
23
|
+
import {setCodeTheme} from "./ts/ui/setCodeTheme";
|
|
24
|
+
import {setContentTheme} from "./ts/ui/setContentTheme";
|
|
25
|
+
import {setPreviewMode} from "./ts/ui/setPreviewMode";
|
|
26
|
+
import {setTheme} from "./ts/ui/setTheme";
|
|
27
|
+
import {Undo} from "./ts/undo/index";
|
|
28
|
+
import {Upload} from "./ts/upload/index";
|
|
29
|
+
import {addScript, addScriptSync} from "./ts/util/addScript";
|
|
30
|
+
import {getSelectText} from "./ts/util/getSelectText";
|
|
31
|
+
import {Options} from "./ts/util/Options";
|
|
32
|
+
import {processCodeRender} from "./ts/util/processCode";
|
|
33
|
+
import {getCursorPosition, getEditorRange} from "./ts/util/selection";
|
|
34
|
+
import {afterRenderEvent} from "./ts/wysiwyg/afterRenderEvent";
|
|
35
|
+
import {WYSIWYG} from "./ts/wysiwyg/index";
|
|
36
|
+
import {input} from "./ts/wysiwyg/input";
|
|
37
|
+
import {renderDomByMd} from "./ts/wysiwyg/renderDomByMd";
|
|
38
|
+
|
|
39
|
+
class Vditor extends VditorMethod {
|
|
40
|
+
public readonly version: string;
|
|
41
|
+
public vditor: IVditor;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param id 要挂载 Vditor 的元素或者元素 ID。
|
|
45
|
+
* @param options Vditor 参数
|
|
46
|
+
*/
|
|
47
|
+
constructor(id: string | HTMLElement, options?: IOptions) {
|
|
48
|
+
super();
|
|
49
|
+
this.version = VDITOR_VERSION;
|
|
50
|
+
|
|
51
|
+
if (typeof id === "string") {
|
|
52
|
+
if (!options) {
|
|
53
|
+
options = {
|
|
54
|
+
cache: {
|
|
55
|
+
id: `vditor${id}`,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
} else if (!options.cache) {
|
|
59
|
+
options.cache = {id: `vditor${id}`};
|
|
60
|
+
} else if (!options.cache.id) {
|
|
61
|
+
options.cache.id = `vditor${id}`;
|
|
62
|
+
}
|
|
63
|
+
id = document.getElementById(id);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const getOptions = new Options(options);
|
|
67
|
+
const mergedOptions = getOptions.merge();
|
|
68
|
+
|
|
69
|
+
// 支持自定义国际化
|
|
70
|
+
if (!mergedOptions.i18n) {
|
|
71
|
+
if (!["en_US", "ja_JP", "ko_KR", "ru_RU", "zh_CN", "zh_TW"].includes(mergedOptions.lang)) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
"options.lang error, see https://ld246.com/article/1549638745630#options",
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
addScript(`${mergedOptions.cdn}/dist/js/i18n/${mergedOptions.lang}.js`, "vditorI18nScript").then(() => {
|
|
77
|
+
this.init(id as HTMLElement, mergedOptions);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
window.VditorI18n = mergedOptions.i18n;
|
|
82
|
+
this.init(id, mergedOptions);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 设置主题 */
|
|
87
|
+
public setTheme(
|
|
88
|
+
theme: "dark" | "classic",
|
|
89
|
+
contentTheme?: string,
|
|
90
|
+
codeTheme?: string,
|
|
91
|
+
contentThemePath?: string,
|
|
92
|
+
) {
|
|
93
|
+
this.vditor.options.theme = theme;
|
|
94
|
+
setTheme(this.vditor);
|
|
95
|
+
if (contentTheme) {
|
|
96
|
+
this.vditor.options.preview.theme.current = contentTheme;
|
|
97
|
+
setContentTheme(contentTheme, contentThemePath || this.vditor.options.preview.theme.path);
|
|
98
|
+
}
|
|
99
|
+
if (codeTheme) {
|
|
100
|
+
this.vditor.options.preview.hljs.style = codeTheme;
|
|
101
|
+
setCodeTheme(codeTheme, this.vditor.options.cdn);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** 获取 Markdown 内容 */
|
|
106
|
+
public getValue() {
|
|
107
|
+
return getMarkdown(this.vditor);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** 获取编辑器当前编辑模式 */
|
|
111
|
+
public getCurrentMode() {
|
|
112
|
+
return this.vditor.currentMode;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** 聚焦到编辑器 */
|
|
116
|
+
public focus() {
|
|
117
|
+
if (this.vditor.currentMode === "sv") {
|
|
118
|
+
this.vditor.sv.element.focus();
|
|
119
|
+
} else if (this.vditor.currentMode === "wysiwyg") {
|
|
120
|
+
this.vditor.wysiwyg.element.focus();
|
|
121
|
+
} else if (this.vditor.currentMode === "ir") {
|
|
122
|
+
this.vditor.ir.element.focus();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** 让编辑器失焦 */
|
|
127
|
+
public blur() {
|
|
128
|
+
if (this.vditor.currentMode === "sv") {
|
|
129
|
+
this.vditor.sv.element.blur();
|
|
130
|
+
} else if (this.vditor.currentMode === "wysiwyg") {
|
|
131
|
+
this.vditor.wysiwyg.element.blur();
|
|
132
|
+
} else if (this.vditor.currentMode === "ir") {
|
|
133
|
+
this.vditor.ir.element.blur();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** 禁用编辑器 */
|
|
138
|
+
public disabled() {
|
|
139
|
+
hidePanel(this.vditor, ["subToolbar", "hint", "popover"]);
|
|
140
|
+
disableToolbar(
|
|
141
|
+
this.vditor.toolbar.elements,
|
|
142
|
+
Constants.EDIT_TOOLBARS.concat(["undo", "redo", "fullscreen", "edit-mode"]),
|
|
143
|
+
);
|
|
144
|
+
this.vditor[this.vditor.currentMode].element.setAttribute(
|
|
145
|
+
"contenteditable",
|
|
146
|
+
"false",
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** 解除编辑器禁用 */
|
|
151
|
+
public enable() {
|
|
152
|
+
enableToolbar(
|
|
153
|
+
this.vditor.toolbar.elements,
|
|
154
|
+
Constants.EDIT_TOOLBARS.concat(["undo", "redo", "fullscreen", "edit-mode"]),
|
|
155
|
+
);
|
|
156
|
+
this.vditor.undo.resetIcon(this.vditor);
|
|
157
|
+
this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable", "true");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** 返回选中的字符串 */
|
|
161
|
+
public getSelection() {
|
|
162
|
+
if (this.vditor.currentMode === "wysiwyg") {
|
|
163
|
+
return getSelectText(this.vditor.wysiwyg.element);
|
|
164
|
+
} else if (this.vditor.currentMode === "sv") {
|
|
165
|
+
return getSelectText(this.vditor.sv.element);
|
|
166
|
+
} else if (this.vditor.currentMode === "ir") {
|
|
167
|
+
return getSelectText(this.vditor.ir.element);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** 设置预览区域内容 */
|
|
172
|
+
public renderPreview(value?: string) {
|
|
173
|
+
this.vditor.preview.render(this.vditor, value);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** 获取焦点位置 */
|
|
177
|
+
public getCursorPosition() {
|
|
178
|
+
return getCursorPosition(this.vditor[this.vditor.currentMode].element);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** 上传是否还在进行中 */
|
|
182
|
+
public isUploading() {
|
|
183
|
+
return this.vditor.upload.isUploading;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** 清除缓存 */
|
|
187
|
+
public clearCache() {
|
|
188
|
+
localStorage.removeItem(this.vditor.options.cache.id);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** 禁用缓存 */
|
|
192
|
+
public disabledCache() {
|
|
193
|
+
this.vditor.options.cache.enable = false;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** 启用缓存 */
|
|
197
|
+
public enableCache() {
|
|
198
|
+
if (!this.vditor.options.cache.id) {
|
|
199
|
+
throw new Error(
|
|
200
|
+
"need options.cache.id, see https://ld246.com/article/1549638745630#options",
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
this.vditor.options.cache.enable = true;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** HTML 转 md */
|
|
207
|
+
public html2md(value: string) {
|
|
208
|
+
return this.vditor.lute.HTML2Md(value);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** markdown 转 JSON 输出 */
|
|
212
|
+
public exportJSON(value: string) {
|
|
213
|
+
return this.vditor.lute.RenderJSON(value);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** 获取 HTML */
|
|
217
|
+
public getHTML() {
|
|
218
|
+
return getHTML(this.vditor);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** 消息提示。time 为 0 将一直显示 */
|
|
222
|
+
public tip(text: string, time?: number) {
|
|
223
|
+
this.vditor.tip.show(text, time);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** 设置预览模式 */
|
|
227
|
+
public setPreviewMode(mode: "both" | "editor") {
|
|
228
|
+
setPreviewMode(mode, this.vditor);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** 删除选中内容 */
|
|
232
|
+
public deleteValue() {
|
|
233
|
+
if (window.getSelection().isCollapsed) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
document.execCommand("delete", false);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** 更新选中内容 */
|
|
240
|
+
public updateValue(value: string) {
|
|
241
|
+
document.execCommand("insertHTML", false, value);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** 在焦点处插入内容,并默认进行 Markdown 渲染 */
|
|
245
|
+
public insertValue(value: string, render = true) {
|
|
246
|
+
const range = getEditorRange(this.vditor);
|
|
247
|
+
range.collapse(true);
|
|
248
|
+
const tmpElement = document.createElement("template");
|
|
249
|
+
tmpElement.innerHTML = value;
|
|
250
|
+
range.insertNode(tmpElement.content.cloneNode(true));
|
|
251
|
+
if (this.vditor.currentMode === "sv") {
|
|
252
|
+
this.vditor.sv.preventInput = true;
|
|
253
|
+
if (render) {
|
|
254
|
+
inputEvent(this.vditor);
|
|
255
|
+
}
|
|
256
|
+
} else if (this.vditor.currentMode === "wysiwyg") {
|
|
257
|
+
this.vditor.wysiwyg.preventInput = true;
|
|
258
|
+
if (render) {
|
|
259
|
+
input(this.vditor, getSelection().getRangeAt(0));
|
|
260
|
+
}
|
|
261
|
+
} else if (this.vditor.currentMode === "ir") {
|
|
262
|
+
this.vditor.ir.preventInput = true;
|
|
263
|
+
if (render) {
|
|
264
|
+
irInput(this.vditor, getSelection().getRangeAt(0), true);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** 设置编辑器内容 */
|
|
270
|
+
public setValue(markdown: string, clearStack = false) {
|
|
271
|
+
if (this.vditor.currentMode === "sv") {
|
|
272
|
+
this.vditor.sv.element.innerHTML = this.vditor.lute.SpinVditorSVDOM(markdown);
|
|
273
|
+
processSVAfterRender(this.vditor, {
|
|
274
|
+
enableAddUndoStack: true,
|
|
275
|
+
enableHint: false,
|
|
276
|
+
enableInput: false,
|
|
277
|
+
});
|
|
278
|
+
} else if (this.vditor.currentMode === "wysiwyg") {
|
|
279
|
+
renderDomByMd(this.vditor, markdown, {
|
|
280
|
+
enableAddUndoStack: true,
|
|
281
|
+
enableHint: false,
|
|
282
|
+
enableInput: false,
|
|
283
|
+
});
|
|
284
|
+
} else {
|
|
285
|
+
this.vditor.ir.element.innerHTML = this.vditor.lute.Md2VditorIRDOM(markdown);
|
|
286
|
+
this.vditor.ir.element
|
|
287
|
+
.querySelectorAll(".vditor-ir__preview[data-render='2']")
|
|
288
|
+
.forEach((item: HTMLElement) => {
|
|
289
|
+
processCodeRender(item, this.vditor);
|
|
290
|
+
});
|
|
291
|
+
processAfterRender(this.vditor, {
|
|
292
|
+
enableAddUndoStack: true,
|
|
293
|
+
enableHint: false,
|
|
294
|
+
enableInput: false,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
this.vditor.outline.render(this.vditor);
|
|
299
|
+
|
|
300
|
+
if (!markdown) {
|
|
301
|
+
hidePanel(this.vditor, ["emoji", "headings", "submenu", "hint"]);
|
|
302
|
+
if (this.vditor.wysiwyg.popover) {
|
|
303
|
+
this.vditor.wysiwyg.popover.style.display = "none";
|
|
304
|
+
}
|
|
305
|
+
this.clearCache();
|
|
306
|
+
}
|
|
307
|
+
if (clearStack) {
|
|
308
|
+
this.clearStack();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** 清空 undo & redo 栈 */
|
|
313
|
+
public clearStack() {
|
|
314
|
+
this.vditor.undo.clearStack(this.vditor);
|
|
315
|
+
this.vditor.undo.addToUndoStack(this.vditor);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** 销毁编辑器 */
|
|
319
|
+
public destroy() {
|
|
320
|
+
this.vditor.element.innerHTML = this.vditor.originalInnerHTML;
|
|
321
|
+
this.vditor.element.classList.remove("vditor");
|
|
322
|
+
this.vditor.element.removeAttribute("style");
|
|
323
|
+
document.getElementById("vditorIconScript").remove();
|
|
324
|
+
this.clearCache();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** 获取评论 ID */
|
|
328
|
+
public getCommentIds() {
|
|
329
|
+
if (this.vditor.currentMode !== "wysiwyg") {
|
|
330
|
+
return [];
|
|
331
|
+
}
|
|
332
|
+
return this.vditor.wysiwyg.getComments(this.vditor, true);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** 高亮评论 */
|
|
336
|
+
public hlCommentIds(ids: string[]) {
|
|
337
|
+
if (this.vditor.currentMode !== "wysiwyg") {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const hlItem = (item: Element) => {
|
|
341
|
+
item.classList.remove("vditor-comment--hover");
|
|
342
|
+
ids.forEach((id) => {
|
|
343
|
+
if (item.getAttribute("data-cmtids").indexOf(id) > -1) {
|
|
344
|
+
item.classList.add("vditor-comment--hover");
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
this.vditor.wysiwyg.element
|
|
349
|
+
.querySelectorAll(".vditor-comment")
|
|
350
|
+
.forEach((item) => {
|
|
351
|
+
hlItem(item);
|
|
352
|
+
});
|
|
353
|
+
if (this.vditor.preview.element.style.display !== "none") {
|
|
354
|
+
this.vditor.preview.element
|
|
355
|
+
.querySelectorAll(".vditor-comment")
|
|
356
|
+
.forEach((item) => {
|
|
357
|
+
hlItem(item);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** 取消评论高亮 */
|
|
363
|
+
public unHlCommentIds(ids: string[]) {
|
|
364
|
+
if (this.vditor.currentMode !== "wysiwyg") {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const unHlItem = (item: Element) => {
|
|
368
|
+
ids.forEach((id) => {
|
|
369
|
+
if (item.getAttribute("data-cmtids").indexOf(id) > -1) {
|
|
370
|
+
item.classList.remove("vditor-comment--hover");
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
this.vditor.wysiwyg.element
|
|
375
|
+
.querySelectorAll(".vditor-comment")
|
|
376
|
+
.forEach((item) => {
|
|
377
|
+
unHlItem(item);
|
|
378
|
+
});
|
|
379
|
+
if (this.vditor.preview.element.style.display !== "none") {
|
|
380
|
+
this.vditor.preview.element
|
|
381
|
+
.querySelectorAll(".vditor-comment")
|
|
382
|
+
.forEach((item) => {
|
|
383
|
+
unHlItem(item);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** 删除评论 */
|
|
389
|
+
public removeCommentIds(removeIds: string[]) {
|
|
390
|
+
if (this.vditor.currentMode !== "wysiwyg") {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const removeItem = (item: Element, removeId: string) => {
|
|
395
|
+
const ids = item.getAttribute("data-cmtids").split(" ");
|
|
396
|
+
ids.find((id, index) => {
|
|
397
|
+
if (id === removeId) {
|
|
398
|
+
ids.splice(index, 1);
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
if (ids.length === 0) {
|
|
403
|
+
item.outerHTML = item.innerHTML;
|
|
404
|
+
getEditorRange(this.vditor).collapse(true);
|
|
405
|
+
} else {
|
|
406
|
+
item.setAttribute("data-cmtids", ids.join(" "));
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
removeIds.forEach((removeId) => {
|
|
410
|
+
this.vditor.wysiwyg.element
|
|
411
|
+
.querySelectorAll(".vditor-comment")
|
|
412
|
+
.forEach((item) => {
|
|
413
|
+
removeItem(item, removeId);
|
|
414
|
+
});
|
|
415
|
+
if (this.vditor.preview.element.style.display !== "none") {
|
|
416
|
+
this.vditor.preview.element
|
|
417
|
+
.querySelectorAll(".vditor-comment")
|
|
418
|
+
.forEach((item) => {
|
|
419
|
+
removeItem(item, removeId);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
afterRenderEvent(this.vditor, {
|
|
424
|
+
enableAddUndoStack: true,
|
|
425
|
+
enableHint: false,
|
|
426
|
+
enableInput: false,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
private init(id: HTMLElement, mergedOptions: IOptions) {
|
|
431
|
+
this.vditor = {
|
|
432
|
+
currentMode: mergedOptions.mode,
|
|
433
|
+
element: id,
|
|
434
|
+
hint: new Hint(mergedOptions.hint.extend),
|
|
435
|
+
lute: undefined,
|
|
436
|
+
options: mergedOptions,
|
|
437
|
+
originalInnerHTML: id.innerHTML,
|
|
438
|
+
outline: new Outline(window.VditorI18n.outline),
|
|
439
|
+
tip: new Tip(),
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
this.vditor.sv = new Editor(this.vditor);
|
|
443
|
+
this.vditor.undo = new Undo();
|
|
444
|
+
this.vditor.wysiwyg = new WYSIWYG(this.vditor);
|
|
445
|
+
this.vditor.ir = new IR(this.vditor);
|
|
446
|
+
this.vditor.toolbar = new Toolbar(this.vditor);
|
|
447
|
+
|
|
448
|
+
if (mergedOptions.resize.enable) {
|
|
449
|
+
this.vditor.resize = new Resize(this.vditor);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (this.vditor.toolbar.elements.devtools) {
|
|
453
|
+
this.vditor.devtools = new DevTools();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (mergedOptions.upload.url || mergedOptions.upload.handler) {
|
|
457
|
+
this.vditor.upload = new Upload();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
addScript(
|
|
461
|
+
mergedOptions._lutePath ||
|
|
462
|
+
`${mergedOptions.cdn}/dist/js/lute/lute.min.js`,
|
|
463
|
+
"vditorLuteScript",
|
|
464
|
+
).then(() => {
|
|
465
|
+
this.vditor.lute = setLute({
|
|
466
|
+
autoSpace: this.vditor.options.preview.markdown.autoSpace,
|
|
467
|
+
codeBlockPreview: this.vditor.options.preview.markdown
|
|
468
|
+
.codeBlockPreview,
|
|
469
|
+
emojiSite: this.vditor.options.hint.emojiPath,
|
|
470
|
+
emojis: this.vditor.options.hint.emoji,
|
|
471
|
+
fixTermTypo: this.vditor.options.preview.markdown.fixTermTypo,
|
|
472
|
+
footnotes: this.vditor.options.preview.markdown.footnotes,
|
|
473
|
+
headingAnchor: false,
|
|
474
|
+
inlineMathDigit: this.vditor.options.preview.math.inlineDigit,
|
|
475
|
+
linkBase: this.vditor.options.preview.markdown.linkBase,
|
|
476
|
+
linkPrefix: this.vditor.options.preview.markdown.linkPrefix,
|
|
477
|
+
listStyle: this.vditor.options.preview.markdown.listStyle,
|
|
478
|
+
mark: this.vditor.options.preview.markdown.mark,
|
|
479
|
+
mathBlockPreview: this.vditor.options.preview.markdown
|
|
480
|
+
.mathBlockPreview,
|
|
481
|
+
paragraphBeginningSpace: this.vditor.options.preview.markdown
|
|
482
|
+
.paragraphBeginningSpace,
|
|
483
|
+
sanitize: this.vditor.options.preview.markdown.sanitize,
|
|
484
|
+
toc: this.vditor.options.preview.markdown.toc,
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
this.vditor.preview = new Preview(this.vditor);
|
|
488
|
+
|
|
489
|
+
initUI(this.vditor);
|
|
490
|
+
|
|
491
|
+
if (mergedOptions.after) {
|
|
492
|
+
mergedOptions.after();
|
|
493
|
+
}
|
|
494
|
+
if (mergedOptions.icon) {
|
|
495
|
+
// 防止初始化 2 个编辑器时加载 2 次
|
|
496
|
+
addScriptSync(`${mergedOptions.cdn}/dist/js/icons/${mergedOptions.icon}.js`, "vditorIconScript");
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export default Vditor;
|
package/src/method.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {abcRender} from "./ts/markdown/abcRender";
|
|
2
|
+
import * as adapterRender from "./ts/markdown/adapterRender";
|
|
3
|
+
import {chartRender} from "./ts/markdown/chartRender";
|
|
4
|
+
import {codeRender} from "./ts/markdown/codeRender";
|
|
5
|
+
import {flowchartRender} from "./ts/markdown/flowchartRender";
|
|
6
|
+
import {graphvizRender} from "./ts/markdown/graphvizRender";
|
|
7
|
+
import {highlightRender} from "./ts/markdown/highlightRender";
|
|
8
|
+
import {lazyLoadImageRender} from "./ts/markdown/lazyLoadImageRender";
|
|
9
|
+
import {mathRender} from "./ts/markdown/mathRender";
|
|
10
|
+
import {mediaRender} from "./ts/markdown/mediaRender";
|
|
11
|
+
import {mermaidRender} from "./ts/markdown/mermaidRender";
|
|
12
|
+
import {mindmapRender} from "./ts/markdown/mindmapRender";
|
|
13
|
+
import {outlineRender} from "./ts/markdown/outlineRender";
|
|
14
|
+
import {plantumlRender} from "./ts/markdown/plantumlRender";
|
|
15
|
+
import {md2html, previewRender} from "./ts/markdown/previewRender";
|
|
16
|
+
import {speechRender} from "./ts/markdown/speechRender";
|
|
17
|
+
import {previewImage} from "./ts/preview/image";
|
|
18
|
+
import {setCodeTheme} from "./ts/ui/setCodeTheme";
|
|
19
|
+
import {setContentTheme} from "./ts/ui/setContentTheme";
|
|
20
|
+
|
|
21
|
+
class Vditor {
|
|
22
|
+
|
|
23
|
+
/** 点击图片放大 */
|
|
24
|
+
public static adapterRender = adapterRender;
|
|
25
|
+
/** 点击图片放大 */
|
|
26
|
+
public static previewImage = previewImage;
|
|
27
|
+
/** 为 element 中的代码块添加复制按钮 */
|
|
28
|
+
public static codeRender = codeRender;
|
|
29
|
+
/** 对 graphviz 进行渲染 */
|
|
30
|
+
public static graphvizRender = graphvizRender;
|
|
31
|
+
/** 为 element 中的代码块进行高亮渲染 */
|
|
32
|
+
public static highlightRender = highlightRender;
|
|
33
|
+
/** 对数学公式进行渲染 */
|
|
34
|
+
public static mathRender = mathRender;
|
|
35
|
+
/** 流程图/时序图/甘特图渲染 */
|
|
36
|
+
public static mermaidRender = mermaidRender;
|
|
37
|
+
/** flowchart.js 渲染 */
|
|
38
|
+
public static flowchartRender = flowchartRender;
|
|
39
|
+
/** 图表渲染 */
|
|
40
|
+
public static chartRender = chartRender;
|
|
41
|
+
/** 五线谱渲染 */
|
|
42
|
+
public static abcRender = abcRender;
|
|
43
|
+
/** 脑图渲染 */
|
|
44
|
+
public static mindmapRender = mindmapRender;
|
|
45
|
+
/** plantuml渲染 */
|
|
46
|
+
public static plantumlRender = plantumlRender;
|
|
47
|
+
/** 大纲渲染 */
|
|
48
|
+
public static outlineRender = outlineRender;
|
|
49
|
+
/** 为[特定链接](https://github.com/Vanessa219/vditor/issues/7)分别渲染为视频、音频、嵌入的 iframe */
|
|
50
|
+
public static mediaRender = mediaRender;
|
|
51
|
+
/** 对选中的文字进行阅读 */
|
|
52
|
+
public static speechRender = speechRender;
|
|
53
|
+
/** 对图片进行懒加载 */
|
|
54
|
+
public static lazyLoadImageRender = lazyLoadImageRender;
|
|
55
|
+
/** Markdown 文本转换为 HTML,该方法需使用[异步编程](https://ld246.com/article/1546828434083?r=Vaness) */
|
|
56
|
+
public static md2html = md2html;
|
|
57
|
+
/** 页面 Markdown 文章渲染 */
|
|
58
|
+
public static preview = previewRender;
|
|
59
|
+
/** 设置代码主题 */
|
|
60
|
+
public static setCodeTheme = setCodeTheme;
|
|
61
|
+
/** 设置内容主题 */
|
|
62
|
+
public static setContentTheme = setContentTheme;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default Vditor;
|
package/src/ts/.DS_Store
ADDED
|
Binary file
|