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,21 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {getEventName} from "../util/compatibility";
|
|
3
|
+
import {MenuItem} from "./MenuItem";
|
|
4
|
+
|
|
5
|
+
export class Outline extends MenuItem {
|
|
6
|
+
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
|
7
|
+
super(vditor, menuItem);
|
|
8
|
+
if (vditor.options.outline) {
|
|
9
|
+
this.element.firstElementChild.classList.add("vditor-menu--current");
|
|
10
|
+
}
|
|
11
|
+
this.element.children[0].addEventListener(getEventName(), (event) => {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
const btnElement = vditor.toolbar.elements.outline.firstElementChild;
|
|
14
|
+
if (btnElement.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
vditor.options.outline.enable = !this.element.firstElementChild.classList.contains("vditor-menu--current");
|
|
18
|
+
vditor.outline.toggle(vditor, vditor.options.outline.enable);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {setPadding} from "../ui/initUI";
|
|
3
|
+
import {getEventName} from "../util/compatibility";
|
|
4
|
+
import {MenuItem} from "./MenuItem";
|
|
5
|
+
import {disableToolbar, enableToolbar, hidePanel} from "./setToolbar";
|
|
6
|
+
|
|
7
|
+
export class Preview extends MenuItem {
|
|
8
|
+
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
|
9
|
+
super(vditor, menuItem);
|
|
10
|
+
this._bindEvent(vditor);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public _bindEvent(vditor: IVditor) {
|
|
14
|
+
this.element.children[0].addEventListener(getEventName(), (event) => {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
const btnElement = this.element.firstElementChild;
|
|
17
|
+
if (btnElement.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const toolbars = Constants.EDIT_TOOLBARS.concat(["both", "edit-mode", "devtools"]);
|
|
22
|
+
if (btnElement.classList.contains("vditor-menu--current")) {
|
|
23
|
+
btnElement.classList.remove("vditor-menu--current");
|
|
24
|
+
if (vditor.currentMode === "sv") {
|
|
25
|
+
vditor.sv.element.style.display = "block";
|
|
26
|
+
if (vditor.options.preview.mode === "both") {
|
|
27
|
+
vditor.preview.element.style.display = "block";
|
|
28
|
+
} else {
|
|
29
|
+
vditor.preview.element.style.display = "none";
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
vditor[vditor.currentMode].element.parentElement.style.display = "block";
|
|
33
|
+
vditor.preview.element.style.display = "none";
|
|
34
|
+
}
|
|
35
|
+
enableToolbar(vditor.toolbar.elements, toolbars);
|
|
36
|
+
vditor.outline.render(vditor);
|
|
37
|
+
} else {
|
|
38
|
+
disableToolbar(vditor.toolbar.elements, toolbars);
|
|
39
|
+
vditor.preview.element.style.display = "block";
|
|
40
|
+
if (vditor.currentMode === "sv") {
|
|
41
|
+
vditor.sv.element.style.display = "none";
|
|
42
|
+
} else {
|
|
43
|
+
vditor[vditor.currentMode].element.parentElement.style.display = "none";
|
|
44
|
+
}
|
|
45
|
+
vditor.preview.render(vditor);
|
|
46
|
+
btnElement.classList.add("vditor-menu--current");
|
|
47
|
+
hidePanel(vditor, ["subToolbar", "hint", "popover"]);
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
vditor.outline.render(vditor);
|
|
50
|
+
}, vditor.options.preview.delay + 10);
|
|
51
|
+
}
|
|
52
|
+
setPadding(vditor);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {uploadFiles} from "../upload/index";
|
|
3
|
+
import {getEventName} from "../util/compatibility";
|
|
4
|
+
import {RecordMedia} from "../util/RecordMedia";
|
|
5
|
+
import {MenuItem} from "./MenuItem";
|
|
6
|
+
|
|
7
|
+
export class Record extends MenuItem {
|
|
8
|
+
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
|
9
|
+
super(vditor, menuItem);
|
|
10
|
+
this._bindEvent(vditor);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public _bindEvent(vditor: IVditor) {
|
|
14
|
+
let mediaRecorder: RecordMedia;
|
|
15
|
+
this.element.children[0].addEventListener(getEventName(), (event) => {
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
if (this.element.firstElementChild.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const editorElement = vditor[vditor.currentMode].element;
|
|
21
|
+
if (!mediaRecorder) {
|
|
22
|
+
navigator.mediaDevices.getUserMedia({audio: true}).then((mediaStream: MediaStream) => {
|
|
23
|
+
mediaRecorder = new RecordMedia(mediaStream);
|
|
24
|
+
mediaRecorder.recorder.onaudioprocess = (e: AudioProcessingEvent) => {
|
|
25
|
+
// Do nothing if not recording:
|
|
26
|
+
if (!mediaRecorder.isRecording) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Copy the data from the input buffers;
|
|
31
|
+
const left = e.inputBuffer.getChannelData(0);
|
|
32
|
+
const right = e.inputBuffer.getChannelData(1);
|
|
33
|
+
mediaRecorder.cloneChannelData(left, right);
|
|
34
|
+
};
|
|
35
|
+
mediaRecorder.startRecordingNewWavFile();
|
|
36
|
+
vditor.tip.show(window.VditorI18n.recording);
|
|
37
|
+
editorElement.setAttribute("contenteditable", "false");
|
|
38
|
+
this.element.children[0].classList.add("vditor-menu--current");
|
|
39
|
+
}).catch(() => {
|
|
40
|
+
vditor.tip.show(window.VditorI18n["record-tip"]);
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (mediaRecorder.isRecording) {
|
|
46
|
+
mediaRecorder.stopRecording();
|
|
47
|
+
vditor.tip.hide();
|
|
48
|
+
const file: File = new File([mediaRecorder.buildWavFileBlob()],
|
|
49
|
+
`record${(new Date()).getTime()}.wav`, {type: "video/webm"});
|
|
50
|
+
uploadFiles(vditor, [file]);
|
|
51
|
+
this.element.children[0].classList.remove("vditor-menu--current");
|
|
52
|
+
} else {
|
|
53
|
+
vditor.tip.show(window.VditorI18n.recording);
|
|
54
|
+
editorElement.setAttribute("contenteditable", "false");
|
|
55
|
+
mediaRecorder.startRecordingNewWavFile();
|
|
56
|
+
this.element.children[0].classList.add("vditor-menu--current");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {getEventName} from "../util/compatibility";
|
|
3
|
+
import {MenuItem} from "./MenuItem";
|
|
4
|
+
import {disableToolbar} from "./setToolbar";
|
|
5
|
+
|
|
6
|
+
export class Redo extends MenuItem {
|
|
7
|
+
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
|
8
|
+
super(vditor, menuItem);
|
|
9
|
+
disableToolbar({redo: this.element}, ["redo"]);
|
|
10
|
+
this.element.children[0].addEventListener(getEventName(), (event) => {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
if (this.element.firstElementChild.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
vditor.undo.redo(vditor);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {getEventName} from "../util/compatibility";
|
|
3
|
+
import {MenuItem} from "./MenuItem";
|
|
4
|
+
import {disableToolbar} from "./setToolbar";
|
|
5
|
+
|
|
6
|
+
export class Undo extends MenuItem {
|
|
7
|
+
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
|
8
|
+
super(vditor, menuItem);
|
|
9
|
+
disableToolbar({undo: this.element}, ["undo"]);
|
|
10
|
+
this.element.children[0].addEventListener(getEventName(), (event) => {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
if (this.element.firstElementChild.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
vditor.undo.undo(vditor);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {uploadFiles} from "../upload";
|
|
3
|
+
import {getEventName} from "../util/compatibility";
|
|
4
|
+
import {MenuItem} from "./MenuItem";
|
|
5
|
+
|
|
6
|
+
export class Upload extends MenuItem {
|
|
7
|
+
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
|
8
|
+
super(vditor, menuItem);
|
|
9
|
+
let inputHTML = '<input type="file"';
|
|
10
|
+
if (vditor.options.upload.multiple) {
|
|
11
|
+
inputHTML += ' multiple="multiple"';
|
|
12
|
+
}
|
|
13
|
+
if (vditor.options.upload.accept) {
|
|
14
|
+
inputHTML += ` accept="${vditor.options.upload.accept}"`;
|
|
15
|
+
}
|
|
16
|
+
this.element.children[0].innerHTML = `${(menuItem.icon || '<svg><use xlink:href="#vditor-icon-upload"></use></svg>')}${inputHTML}>`;
|
|
17
|
+
this._bindEvent(vditor);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public _bindEvent(vditor: IVditor) {
|
|
21
|
+
this.element.children[0].addEventListener(getEventName(), (event) => {
|
|
22
|
+
if (this.element.firstElementChild.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
this.element.querySelector("input").addEventListener("change",
|
|
29
|
+
(event: InputEvent & { target: HTMLInputElement }) => {
|
|
30
|
+
if (this.element.firstElementChild.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (event.target.files.length === 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
uploadFiles(vditor, event.target.files, event.target);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {getEventName} from "../util/compatibility";
|
|
2
|
+
import {Both} from "./Both";
|
|
3
|
+
import {Br} from "./Br";
|
|
4
|
+
import {CodeTheme} from "./CodeTheme";
|
|
5
|
+
import {ContentTheme} from "./ContentTheme";
|
|
6
|
+
import {Counter} from "./Counter";
|
|
7
|
+
import {Custom} from "./Custom";
|
|
8
|
+
import {Devtools} from "./Devtools";
|
|
9
|
+
import {Divider} from "./Divider";
|
|
10
|
+
import {EditMode} from "./EditMode";
|
|
11
|
+
import {Emoji} from "./Emoji";
|
|
12
|
+
import {Export} from "./Export";
|
|
13
|
+
import {Fullscreen} from "./Fullscreen";
|
|
14
|
+
import {Headings} from "./Headings";
|
|
15
|
+
import {Help} from "./Help";
|
|
16
|
+
import {Indent} from "./Indent";
|
|
17
|
+
import {Info} from "./Info";
|
|
18
|
+
import {InsertAfter} from "./InsertAfter";
|
|
19
|
+
import {InsertBefore} from "./InsertBefore";
|
|
20
|
+
import {MenuItem} from "./MenuItem";
|
|
21
|
+
import {Outdent} from "./Outdent";
|
|
22
|
+
import {Outline} from "./Outline";
|
|
23
|
+
import {Preview} from "./Preview";
|
|
24
|
+
import {Record} from "./Record";
|
|
25
|
+
import {Redo} from "./Redo";
|
|
26
|
+
import {toggleSubMenu} from "./setToolbar";
|
|
27
|
+
import {Undo} from "./Undo";
|
|
28
|
+
import {Upload} from "./Upload";
|
|
29
|
+
|
|
30
|
+
export class Toolbar {
|
|
31
|
+
public elements: { [key: string]: HTMLElement };
|
|
32
|
+
public element: HTMLElement;
|
|
33
|
+
|
|
34
|
+
constructor(vditor: IVditor) {
|
|
35
|
+
const options = vditor.options;
|
|
36
|
+
this.elements = {};
|
|
37
|
+
|
|
38
|
+
this.element = document.createElement("div");
|
|
39
|
+
this.element.className = "vditor-toolbar";
|
|
40
|
+
|
|
41
|
+
options.toolbar.forEach((menuItem: IMenuItem, i: number) => {
|
|
42
|
+
const itemElement = this.genItem(vditor, menuItem, i);
|
|
43
|
+
this.element.appendChild(itemElement);
|
|
44
|
+
if (menuItem.toolbar) {
|
|
45
|
+
const panelElement = document.createElement("div");
|
|
46
|
+
panelElement.className = "vditor-hint vditor-panel--arrow";
|
|
47
|
+
panelElement.addEventListener(getEventName(), (event) => {
|
|
48
|
+
panelElement.style.display = "none";
|
|
49
|
+
});
|
|
50
|
+
menuItem.toolbar.forEach((subMenuItem: IMenuItem, subI: number) => {
|
|
51
|
+
subMenuItem.level = 2;
|
|
52
|
+
panelElement.appendChild(this.genItem(vditor, subMenuItem, i + subI));
|
|
53
|
+
});
|
|
54
|
+
itemElement.appendChild(panelElement);
|
|
55
|
+
toggleSubMenu(vditor, panelElement, itemElement.children[0], 2);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (vditor.options.toolbarConfig.hide) {
|
|
60
|
+
this.element.classList.add("vditor-toolbar--hide");
|
|
61
|
+
}
|
|
62
|
+
if (vditor.options.toolbarConfig.pin) {
|
|
63
|
+
this.element.classList.add("vditor-toolbar--pin");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (vditor.options.counter.enable) {
|
|
67
|
+
vditor.counter = new Counter(vditor);
|
|
68
|
+
this.element.appendChild(vditor.counter.element);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private genItem(vditor: IVditor, menuItem: IMenuItem, index: number) {
|
|
73
|
+
let menuItemObj;
|
|
74
|
+
switch (menuItem.name) {
|
|
75
|
+
case "bold":
|
|
76
|
+
case "italic":
|
|
77
|
+
case "more":
|
|
78
|
+
case "strike":
|
|
79
|
+
case "line":
|
|
80
|
+
case "quote":
|
|
81
|
+
case "list":
|
|
82
|
+
case "ordered-list":
|
|
83
|
+
case "check":
|
|
84
|
+
case "code":
|
|
85
|
+
case "inline-code":
|
|
86
|
+
case "link":
|
|
87
|
+
case "table":
|
|
88
|
+
menuItemObj = new MenuItem(vditor, menuItem);
|
|
89
|
+
break;
|
|
90
|
+
case "emoji":
|
|
91
|
+
menuItemObj = new Emoji(vditor, menuItem);
|
|
92
|
+
break;
|
|
93
|
+
case "headings":
|
|
94
|
+
menuItemObj = new Headings(vditor, menuItem);
|
|
95
|
+
break;
|
|
96
|
+
case "|":
|
|
97
|
+
menuItemObj = new Divider();
|
|
98
|
+
break;
|
|
99
|
+
case "br":
|
|
100
|
+
menuItemObj = new Br();
|
|
101
|
+
break;
|
|
102
|
+
case "undo":
|
|
103
|
+
menuItemObj = new Undo(vditor, menuItem);
|
|
104
|
+
break;
|
|
105
|
+
case "redo":
|
|
106
|
+
menuItemObj = new Redo(vditor, menuItem);
|
|
107
|
+
break;
|
|
108
|
+
case "help":
|
|
109
|
+
menuItemObj = new Help(vditor, menuItem);
|
|
110
|
+
break;
|
|
111
|
+
case "both":
|
|
112
|
+
menuItemObj = new Both(vditor, menuItem);
|
|
113
|
+
break;
|
|
114
|
+
case "preview":
|
|
115
|
+
menuItemObj = new Preview(vditor, menuItem);
|
|
116
|
+
break;
|
|
117
|
+
case "fullscreen":
|
|
118
|
+
menuItemObj = new Fullscreen(vditor, menuItem);
|
|
119
|
+
break;
|
|
120
|
+
case "upload":
|
|
121
|
+
menuItemObj = new Upload(vditor, menuItem);
|
|
122
|
+
break;
|
|
123
|
+
case "record":
|
|
124
|
+
menuItemObj = new Record(vditor, menuItem);
|
|
125
|
+
break;
|
|
126
|
+
case "info":
|
|
127
|
+
menuItemObj = new Info(vditor, menuItem);
|
|
128
|
+
break;
|
|
129
|
+
case "edit-mode":
|
|
130
|
+
menuItemObj = new EditMode(vditor, menuItem);
|
|
131
|
+
break;
|
|
132
|
+
case "devtools":
|
|
133
|
+
menuItemObj = new Devtools(vditor, menuItem);
|
|
134
|
+
break;
|
|
135
|
+
case "outdent":
|
|
136
|
+
menuItemObj = new Outdent(vditor, menuItem);
|
|
137
|
+
break;
|
|
138
|
+
case "indent":
|
|
139
|
+
menuItemObj = new Indent(vditor, menuItem);
|
|
140
|
+
break;
|
|
141
|
+
case "outline":
|
|
142
|
+
menuItemObj = new Outline(vditor, menuItem);
|
|
143
|
+
break;
|
|
144
|
+
case "insert-after":
|
|
145
|
+
menuItemObj = new InsertAfter(vditor, menuItem);
|
|
146
|
+
break;
|
|
147
|
+
case "insert-before":
|
|
148
|
+
menuItemObj = new InsertBefore(vditor, menuItem);
|
|
149
|
+
break;
|
|
150
|
+
case "code-theme":
|
|
151
|
+
menuItemObj = new CodeTheme(vditor, menuItem);
|
|
152
|
+
break;
|
|
153
|
+
case "content-theme":
|
|
154
|
+
menuItemObj = new ContentTheme(vditor, menuItem);
|
|
155
|
+
break;
|
|
156
|
+
case "export":
|
|
157
|
+
menuItemObj = new Export(vditor, menuItem);
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
menuItemObj = new Custom(vditor, menuItem);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!menuItemObj) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
let key = menuItem.name;
|
|
168
|
+
if (key === "br" || key === "|") {
|
|
169
|
+
key = key + index;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this.elements[key] = menuItemObj.element;
|
|
173
|
+
return menuItemObj.element;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {getEventName} from "../util/compatibility";
|
|
3
|
+
|
|
4
|
+
export const removeCurrentToolbar = (toolbar: { [key: string]: HTMLElement }, names: string[]) => {
|
|
5
|
+
names.forEach((name) => {
|
|
6
|
+
if (!toolbar[name]) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const itemElement = toolbar[name].children[0];
|
|
10
|
+
if (itemElement && itemElement.classList.contains("vditor-menu--current")) {
|
|
11
|
+
itemElement.classList.remove("vditor-menu--current");
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const setCurrentToolbar = (toolbar: { [key: string]: HTMLElement }, names: string[]) => {
|
|
17
|
+
names.forEach((name) => {
|
|
18
|
+
if (!toolbar[name]) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const itemElement = toolbar[name].children[0];
|
|
22
|
+
if (itemElement && !itemElement.classList.contains("vditor-menu--current")) {
|
|
23
|
+
itemElement.classList.add("vditor-menu--current");
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const enableToolbar = (toolbar: { [key: string]: HTMLElement }, names: string[]) => {
|
|
29
|
+
names.forEach((name) => {
|
|
30
|
+
if (!toolbar[name]) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const itemElement = toolbar[name].children[0];
|
|
34
|
+
if (itemElement && itemElement.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
35
|
+
itemElement.classList.remove(Constants.CLASS_MENU_DISABLED);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const disableToolbar = (toolbar: { [key: string]: HTMLElement }, names: string[]) => {
|
|
41
|
+
names.forEach((name) => {
|
|
42
|
+
if (!toolbar[name]) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const itemElement = toolbar[name].children[0];
|
|
46
|
+
if (itemElement && !itemElement.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
47
|
+
itemElement.classList.add(Constants.CLASS_MENU_DISABLED);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const hideToolbar = (toolbar: { [key: string]: HTMLElement }, names: string[]) => {
|
|
53
|
+
names.forEach((name) => {
|
|
54
|
+
if (!toolbar[name]) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (toolbar[name]) {
|
|
58
|
+
toolbar[name].style.display = "none";
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const showToolbar = (toolbar: { [key: string]: HTMLElement }, names: string[]) => {
|
|
64
|
+
names.forEach((name) => {
|
|
65
|
+
if (!toolbar[name]) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (toolbar[name]) {
|
|
69
|
+
toolbar[name].style.display = "block";
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// "subToolbar", "hint", "popover"
|
|
75
|
+
export const hidePanel = (vditor: IVditor, panels: string[], exceptElement?: HTMLElement) => {
|
|
76
|
+
if (panels.includes("subToolbar")) {
|
|
77
|
+
vditor.toolbar.element.querySelectorAll(".vditor-hint").forEach((item: HTMLElement) => {
|
|
78
|
+
if (exceptElement && item.isEqualNode(exceptElement)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
item.style.display = "none";
|
|
82
|
+
});
|
|
83
|
+
if (vditor.toolbar.elements.emoji) {
|
|
84
|
+
(vditor.toolbar.elements.emoji.lastElementChild as HTMLElement).style.display = "none";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (panels.includes("hint")) {
|
|
88
|
+
vditor.hint.element.style.display = "none";
|
|
89
|
+
}
|
|
90
|
+
if (vditor.wysiwyg.popover && panels.includes("popover")) {
|
|
91
|
+
vditor.wysiwyg.popover.style.display = "none";
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const toggleSubMenu = (vditor: IVditor, panelElement: HTMLElement, actionBtn: Element, level: number) => {
|
|
96
|
+
actionBtn.addEventListener(getEventName(), (event) => {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
event.stopPropagation();
|
|
99
|
+
if (actionBtn.classList.contains(Constants.CLASS_MENU_DISABLED)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
vditor.toolbar.element.querySelectorAll(".vditor-hint--current").forEach((item) => {
|
|
103
|
+
item.classList.remove("vditor-hint--current");
|
|
104
|
+
});
|
|
105
|
+
if (panelElement.style.display === "block") {
|
|
106
|
+
panelElement.style.display = "none";
|
|
107
|
+
} else {
|
|
108
|
+
hidePanel(vditor, ["subToolbar", "hint", "popover"], actionBtn.parentElement.parentElement);
|
|
109
|
+
if (!actionBtn.classList.contains("vditor-tooltipped")) {
|
|
110
|
+
actionBtn.classList.add("vditor-hint--current");
|
|
111
|
+
}
|
|
112
|
+
panelElement.style.display = "block";
|
|
113
|
+
if (vditor.toolbar.element.getBoundingClientRect().right - actionBtn.getBoundingClientRect().right < 250) {
|
|
114
|
+
panelElement.classList.add("vditor-panel--left");
|
|
115
|
+
} else {
|
|
116
|
+
panelElement.classList.remove("vditor-panel--left");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {setEditMode} from "../toolbar/EditMode";
|
|
3
|
+
import {accessLocalStorage} from "../util/compatibility";
|
|
4
|
+
import {setContentTheme} from "./setContentTheme";
|
|
5
|
+
import {setTheme} from "./setTheme";
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
visualViewport: HTMLElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const initUI = (vditor: IVditor) => {
|
|
14
|
+
vditor.element.innerHTML = "";
|
|
15
|
+
vditor.element.classList.add("vditor");
|
|
16
|
+
setTheme(vditor);
|
|
17
|
+
setContentTheme(vditor.options.preview.theme.current, vditor.options.preview.theme.path);
|
|
18
|
+
if (typeof vditor.options.height === "number") {
|
|
19
|
+
vditor.element.style.height = vditor.options.height + "px";
|
|
20
|
+
}
|
|
21
|
+
if (typeof vditor.options.minHeight === "number") {
|
|
22
|
+
vditor.element.style.minHeight = vditor.options.minHeight + "px";
|
|
23
|
+
}
|
|
24
|
+
if (typeof vditor.options.width === "number") {
|
|
25
|
+
vditor.element.style.width = vditor.options.width + "px";
|
|
26
|
+
} else {
|
|
27
|
+
vditor.element.style.width = vditor.options.width;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
vditor.element.appendChild(vditor.toolbar.element);
|
|
31
|
+
|
|
32
|
+
const contentElement = document.createElement("div");
|
|
33
|
+
contentElement.className = "vditor-content";
|
|
34
|
+
|
|
35
|
+
if (vditor.options.outline.position === "left") {
|
|
36
|
+
contentElement.appendChild(vditor.outline.element);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
contentElement.appendChild(vditor.wysiwyg.element.parentElement);
|
|
40
|
+
|
|
41
|
+
contentElement.appendChild(vditor.sv.element);
|
|
42
|
+
|
|
43
|
+
contentElement.appendChild(vditor.ir.element.parentElement);
|
|
44
|
+
|
|
45
|
+
contentElement.appendChild(vditor.preview.element);
|
|
46
|
+
|
|
47
|
+
if (vditor.toolbar.elements.devtools) {
|
|
48
|
+
contentElement.appendChild(vditor.devtools.element);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (vditor.options.outline.position === "right") {
|
|
52
|
+
vditor.outline.element.classList.add("vditor-outline--right");
|
|
53
|
+
contentElement.appendChild(vditor.outline.element);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (vditor.upload) {
|
|
57
|
+
contentElement.appendChild(vditor.upload.element);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (vditor.options.resize.enable) {
|
|
61
|
+
contentElement.appendChild(vditor.resize.element);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
contentElement.appendChild(vditor.hint.element);
|
|
65
|
+
|
|
66
|
+
contentElement.appendChild(vditor.tip.element);
|
|
67
|
+
|
|
68
|
+
vditor.element.appendChild(contentElement);
|
|
69
|
+
|
|
70
|
+
if (vditor.toolbar.elements.export) {
|
|
71
|
+
// for export pdf
|
|
72
|
+
vditor.element.insertAdjacentHTML("beforeend",
|
|
73
|
+
'<iframe style="width: 100%;height: 0;border: 0"></iframe>');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setEditMode(vditor, vditor.options.mode, afterRender(vditor, contentElement));
|
|
77
|
+
|
|
78
|
+
document.execCommand("DefaultParagraphSeparator", false, "p");
|
|
79
|
+
|
|
80
|
+
if (navigator.userAgent.indexOf("iPhone") > -1 && typeof window.visualViewport !== "undefined") {
|
|
81
|
+
// https://github.com/Vanessa219/vditor/issues/379
|
|
82
|
+
let pendingUpdate = false;
|
|
83
|
+
const viewportHandler = (event: Event) => {
|
|
84
|
+
if (pendingUpdate) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
pendingUpdate = true;
|
|
88
|
+
|
|
89
|
+
requestAnimationFrame(() => {
|
|
90
|
+
pendingUpdate = false;
|
|
91
|
+
const layoutViewport = vditor.toolbar.element;
|
|
92
|
+
layoutViewport.style.transform = "none";
|
|
93
|
+
if (layoutViewport.getBoundingClientRect().top < 0) {
|
|
94
|
+
layoutViewport.style.transform = `translate(0, ${-layoutViewport.getBoundingClientRect().top}px)`;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
window.visualViewport.addEventListener("scroll", viewportHandler);
|
|
99
|
+
window.visualViewport.addEventListener("resize", viewportHandler);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const setPadding = (vditor: IVditor) => {
|
|
104
|
+
const minPadding = window.innerWidth <= Constants.MOBILE_WIDTH ? 10 : 35;
|
|
105
|
+
if (vditor.wysiwyg.element.parentElement.style.display !== "none") {
|
|
106
|
+
const padding = (vditor.wysiwyg.element.parentElement.clientWidth
|
|
107
|
+
- vditor.options.preview.maxWidth) / 2;
|
|
108
|
+
vditor.wysiwyg.element.style.padding = `10px ${Math.max(minPadding, padding)}px`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (vditor.ir.element.parentElement.style.display !== "none") {
|
|
112
|
+
const padding = (vditor.ir.element.parentElement.clientWidth
|
|
113
|
+
- vditor.options.preview.maxWidth) / 2;
|
|
114
|
+
vditor.ir.element.style.padding = `10px ${Math.max(minPadding, padding)}px`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (vditor.preview.element.style.display !== "block" || vditor.currentMode === "sv") {
|
|
118
|
+
vditor.toolbar.element.style.paddingLeft = Math.max(5,
|
|
119
|
+
parseInt(vditor[vditor.currentMode].element.style.paddingLeft || "0", 10) +
|
|
120
|
+
(vditor.options.outline.position === "left" ? vditor.outline.element.offsetWidth : 0)) + "px";
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const setTypewriterPosition = (vditor: IVditor) => {
|
|
125
|
+
if (!vditor.options.typewriterMode) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
let height: number = window.innerHeight;
|
|
129
|
+
if (typeof vditor.options.height === "number") {
|
|
130
|
+
height = vditor.options.height;
|
|
131
|
+
if (typeof vditor.options.minHeight === "number") {
|
|
132
|
+
height = Math.max(height, vditor.options.minHeight);
|
|
133
|
+
}
|
|
134
|
+
height = Math.min(window.innerHeight, height);
|
|
135
|
+
}
|
|
136
|
+
if (vditor.element.classList.contains("vditor--fullscreen")) {
|
|
137
|
+
height = window.innerHeight;
|
|
138
|
+
}
|
|
139
|
+
// 由于 Firefox padding-bottom bug,只能使用 :after
|
|
140
|
+
vditor[vditor.currentMode].element.style.setProperty("--editor-bottom",
|
|
141
|
+
((height - vditor.toolbar.element.offsetHeight) / 2) + "px");
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const afterRender = (vditor: IVditor, contentElement: HTMLElement) => {
|
|
145
|
+
setTypewriterPosition(vditor);
|
|
146
|
+
|
|
147
|
+
window.addEventListener("resize", () => {
|
|
148
|
+
setPadding(vditor);
|
|
149
|
+
setTypewriterPosition(vditor);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// set default value
|
|
153
|
+
let initValue = accessLocalStorage() && localStorage.getItem(vditor.options.cache.id);
|
|
154
|
+
if (!vditor.options.cache.enable || !initValue) {
|
|
155
|
+
if (vditor.options.value) {
|
|
156
|
+
initValue = vditor.options.value;
|
|
157
|
+
} else if (vditor.originalInnerHTML) {
|
|
158
|
+
initValue = vditor.lute.HTML2Md(vditor.originalInnerHTML);
|
|
159
|
+
} else if (!vditor.options.cache.enable) {
|
|
160
|
+
initValue = "";
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return initValue || "";
|
|
164
|
+
};
|