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,12 @@
|
|
|
1
|
+
import {code160to32} from "../util/code160to32";
|
|
2
|
+
|
|
3
|
+
export const getMarkdown = (vditor: IVditor) => {
|
|
4
|
+
if (vditor.currentMode === "sv") {
|
|
5
|
+
return code160to32(`${vditor.sv.element.textContent}\n`.replace(/\n\n$/, "\n"));
|
|
6
|
+
} else if (vditor.currentMode === "wysiwyg") {
|
|
7
|
+
return vditor.lute.VditorDOM2Md(vditor.wysiwyg.element.innerHTML);
|
|
8
|
+
} else if (vditor.currentMode === "ir") {
|
|
9
|
+
return vditor.lute.VditorIRDOM2Md(vditor.ir.element.innerHTML);
|
|
10
|
+
}
|
|
11
|
+
return "";
|
|
12
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {addScript} from "../util/addScript";
|
|
3
|
+
import {graphvizRenderAdapter} from "./adapterRender";
|
|
4
|
+
|
|
5
|
+
declare class Viz {
|
|
6
|
+
public renderSVGElement: (code: string) => Promise<any>;
|
|
7
|
+
|
|
8
|
+
constructor({ }: { worker: Worker });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const graphvizRender = (element: HTMLElement, cdn = Constants.CDN) => {
|
|
12
|
+
const graphvizElements = graphvizRenderAdapter.getElements(element);
|
|
13
|
+
|
|
14
|
+
if (graphvizElements.length === 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
addScript(`${cdn}/dist/js/graphviz/viz.js`, "vditorGraphVizScript").then(() => {
|
|
18
|
+
graphvizElements.forEach((e: HTMLDivElement) => {
|
|
19
|
+
const code = graphvizRenderAdapter.getCode(e);
|
|
20
|
+
if (e.parentElement.classList.contains("vditor-wysiwyg__pre") ||
|
|
21
|
+
e.parentElement.classList.contains("vditor-ir__marker--pre")) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (e.getAttribute("data-processed") === "true" || code.trim() === "") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const blob = new Blob([`importScripts('${(document.getElementById("vditorGraphVizScript") as HTMLScriptElement).src.replace("viz.js", "full.render.js")}');`],
|
|
31
|
+
{ type: "application/javascript" });
|
|
32
|
+
const url = window.URL || window.webkitURL;
|
|
33
|
+
const blobUrl = url.createObjectURL(blob);
|
|
34
|
+
const worker = new Worker(blobUrl);
|
|
35
|
+
new Viz({ worker })
|
|
36
|
+
.renderSVGElement(code).then((result: HTMLElement) => {
|
|
37
|
+
e.innerHTML = result.outerHTML;
|
|
38
|
+
}).catch((error) => {
|
|
39
|
+
e.innerHTML = `graphviz render error: <br>${error}`;
|
|
40
|
+
e.className = "vditor-reset--error";
|
|
41
|
+
});
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error("graphviz error", e);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
e.setAttribute("data-processed", "true");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {addScript} from "../util/addScript";
|
|
3
|
+
import {addStyle} from "../util/addStyle";
|
|
4
|
+
|
|
5
|
+
declare const hljs: {
|
|
6
|
+
highlightElement(element: Element): void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const highlightRender = (hljsOption?: IHljs, element: HTMLElement | Document = document,
|
|
10
|
+
cdn = Constants.CDN) => {
|
|
11
|
+
let style = hljsOption.style;
|
|
12
|
+
if (!Constants.CODE_THEME.includes(style)) {
|
|
13
|
+
style = "github";
|
|
14
|
+
}
|
|
15
|
+
const vditorHljsStyle = document.getElementById("vditorHljsStyle") as HTMLLinkElement;
|
|
16
|
+
const href = `${cdn}/dist/js/highlight.js/styles/${style}.css`;
|
|
17
|
+
if (vditorHljsStyle && vditorHljsStyle.href !== href) {
|
|
18
|
+
vditorHljsStyle.remove();
|
|
19
|
+
}
|
|
20
|
+
addStyle(`${cdn}/dist/js/highlight.js/styles/${style}.css`, "vditorHljsStyle");
|
|
21
|
+
|
|
22
|
+
if (hljsOption.enable === false) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const codes = element.querySelectorAll("pre > code");
|
|
27
|
+
if (codes.length === 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
addScript(`${cdn}/dist/js/highlight.js/highlight.pack.js`, "vditorHljsScript").then(() => {
|
|
32
|
+
element.querySelectorAll("pre > code").forEach((block) => {
|
|
33
|
+
// ir & wysiwyg 区域不渲染
|
|
34
|
+
if (block.parentElement.classList.contains("vditor-ir__marker--pre") ||
|
|
35
|
+
block.parentElement.classList.contains("vditor-wysiwyg__pre")) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (block.classList.contains("language-mermaid") || block.classList.contains("language-flowchart") ||
|
|
40
|
+
block.classList.contains("language-echarts") || block.classList.contains("language-mindmap") ||
|
|
41
|
+
block.classList.contains("language-plantuml") ||
|
|
42
|
+
block.classList.contains("language-abc") || block.classList.contains("language-graphviz") ||
|
|
43
|
+
block.classList.contains("language-math")) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
hljs.highlightElement(block);
|
|
47
|
+
|
|
48
|
+
if (!hljsOption.lineNumber) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
block.classList.add("vditor-linenumber");
|
|
53
|
+
let linenNumberTemp: HTMLDivElement = block.querySelector(".vditor-linenumber__temp");
|
|
54
|
+
if (!linenNumberTemp) {
|
|
55
|
+
linenNumberTemp = document.createElement("div");
|
|
56
|
+
linenNumberTemp.className = "vditor-linenumber__temp";
|
|
57
|
+
block.insertAdjacentElement("beforeend", linenNumberTemp);
|
|
58
|
+
}
|
|
59
|
+
const whiteSpace = getComputedStyle(block).whiteSpace;
|
|
60
|
+
let isSoftWrap = false;
|
|
61
|
+
if (whiteSpace === "pre-wrap" || whiteSpace === "pre-line") {
|
|
62
|
+
isSoftWrap = true;
|
|
63
|
+
}
|
|
64
|
+
let lineNumberHTML = "";
|
|
65
|
+
const lineList = block.textContent.split(/\r\n|\r|\n/g);
|
|
66
|
+
lineList.pop();
|
|
67
|
+
lineList.map((line) => {
|
|
68
|
+
let lineHeight = "";
|
|
69
|
+
if (isSoftWrap) {
|
|
70
|
+
linenNumberTemp.textContent = line || "\n";
|
|
71
|
+
lineHeight = ` style="height:${linenNumberTemp.getBoundingClientRect().height}px"`;
|
|
72
|
+
}
|
|
73
|
+
lineNumberHTML += `<span${lineHeight}></span>`;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
linenNumberTemp.style.display = "none";
|
|
77
|
+
lineNumberHTML = `<span class="vditor-linenumber__rows">${lineNumberHTML}</span>`;
|
|
78
|
+
block.insertAdjacentHTML("beforeend", lineNumberHTML);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
vditorImageIntersectionObserver: IntersectionObserver;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const lazyLoadImageRender = (element: (HTMLElement | Document) = document) => {
|
|
8
|
+
const loadImg = (it: HTMLImageElement) => {
|
|
9
|
+
const testImage = document.createElement("img");
|
|
10
|
+
testImage.src = it.getAttribute("data-src");
|
|
11
|
+
testImage.addEventListener("load", () => {
|
|
12
|
+
if (!it.getAttribute("style") && !it.getAttribute("class") &&
|
|
13
|
+
!it.getAttribute("width") && !it.getAttribute("height")) {
|
|
14
|
+
if (testImage.naturalHeight > testImage.naturalWidth &&
|
|
15
|
+
testImage.naturalWidth / testImage.naturalHeight <
|
|
16
|
+
document.querySelector(".vditor-reset").clientWidth / (window.innerHeight - 40) &&
|
|
17
|
+
testImage.naturalHeight > (window.innerHeight - 40)) {
|
|
18
|
+
it.style.height = (window.innerHeight - 40) + "px";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
it.src = testImage.src;
|
|
23
|
+
});
|
|
24
|
+
it.removeAttribute("data-src");
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (!("IntersectionObserver" in window)) {
|
|
28
|
+
element.querySelectorAll("img").forEach((imgElement: HTMLImageElement) => {
|
|
29
|
+
if (imgElement.getAttribute("data-src")) {
|
|
30
|
+
loadImg(imgElement);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (window.vditorImageIntersectionObserver) {
|
|
37
|
+
window.vditorImageIntersectionObserver.disconnect();
|
|
38
|
+
element.querySelectorAll("img").forEach((imgElement) => {
|
|
39
|
+
window.vditorImageIntersectionObserver.observe(imgElement);
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
window.vditorImageIntersectionObserver = new IntersectionObserver((entries) => {
|
|
43
|
+
entries.forEach((entrie: IntersectionObserverEntry & { target: HTMLImageElement }) => {
|
|
44
|
+
if ((typeof entrie.isIntersecting === "undefined"
|
|
45
|
+
? entrie.intersectionRatio !== 0
|
|
46
|
+
: entrie.isIntersecting)
|
|
47
|
+
&& entrie.target.getAttribute("data-src")) {
|
|
48
|
+
loadImg(entrie.target);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
element.querySelectorAll("img").forEach((imgElement) => {
|
|
53
|
+
window.vditorImageIntersectionObserver.observe(imgElement);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {addScript, addScriptSync} from "../util/addScript";
|
|
3
|
+
import {addStyle} from "../util/addStyle";
|
|
4
|
+
import {code160to32} from "../util/code160to32";
|
|
5
|
+
import {mathRenderAdapter} from "./adapterRender";
|
|
6
|
+
|
|
7
|
+
declare const katex: {
|
|
8
|
+
renderToString(math: string, option: {
|
|
9
|
+
displayMode: boolean;
|
|
10
|
+
output: string;
|
|
11
|
+
}): string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
interface Window {
|
|
16
|
+
MathJax: any;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const mathRender = (element: HTMLElement, options?: { cdn?: string, math?: IMath }) => {
|
|
21
|
+
const mathElements = mathRenderAdapter.getElements(element);
|
|
22
|
+
|
|
23
|
+
if (mathElements.length === 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const defaultOptions = {
|
|
28
|
+
cdn: Constants.CDN,
|
|
29
|
+
math: {
|
|
30
|
+
engine: "KaTeX",
|
|
31
|
+
inlineDigit: false,
|
|
32
|
+
macros: {},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (options && options.math) {
|
|
37
|
+
options.math =
|
|
38
|
+
Object.assign({}, defaultOptions.math, options.math);
|
|
39
|
+
}
|
|
40
|
+
options = Object.assign({}, defaultOptions, options);
|
|
41
|
+
|
|
42
|
+
if (options.math.engine === "KaTeX") {
|
|
43
|
+
addStyle(`${options.cdn}/dist/js/katex/katex.min.css`, "vditorKatexStyle");
|
|
44
|
+
addScript(`${options.cdn}/dist/js/katex/katex.min.js`, "vditorKatexScript").then(() => {
|
|
45
|
+
mathElements.forEach((mathElement) => {
|
|
46
|
+
if (mathElement.parentElement.classList.contains("vditor-wysiwyg__pre") ||
|
|
47
|
+
mathElement.parentElement.classList.contains("vditor-ir__marker--pre")) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (mathElement.getAttribute("data-math")) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const math = code160to32(mathRenderAdapter.getCode(mathElement));
|
|
54
|
+
mathElement.setAttribute("data-math", math);
|
|
55
|
+
try {
|
|
56
|
+
mathElement.innerHTML = katex.renderToString(math, {
|
|
57
|
+
displayMode: mathElement.tagName === "DIV",
|
|
58
|
+
output: "html",
|
|
59
|
+
});
|
|
60
|
+
} catch (e) {
|
|
61
|
+
mathElement.innerHTML = e.message;
|
|
62
|
+
mathElement.className = "language-math vditor-reset--error";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
mathElement.addEventListener("copy", (event: ClipboardEvent) => {
|
|
66
|
+
event.stopPropagation();
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
const vditorMathElement = (event.currentTarget as HTMLElement).closest(".language-math");
|
|
69
|
+
event.clipboardData.setData("text/html", vditorMathElement.innerHTML);
|
|
70
|
+
event.clipboardData.setData("text/plain",
|
|
71
|
+
vditorMathElement.getAttribute("data-math"));
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
} else if (options.math.engine === "MathJax") {
|
|
76
|
+
const chainAsync = (fns: any) => {
|
|
77
|
+
if (fns.length === 0) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
let curr = 0;
|
|
81
|
+
const last = fns[fns.length - 1];
|
|
82
|
+
const next = () => {
|
|
83
|
+
const fn = fns[curr++];
|
|
84
|
+
fn === last ? fn() : fn(next);
|
|
85
|
+
};
|
|
86
|
+
next();
|
|
87
|
+
};
|
|
88
|
+
if (!window.MathJax) {
|
|
89
|
+
window.MathJax = {
|
|
90
|
+
loader: {
|
|
91
|
+
paths: { mathjax: `${options.cdn}/dist/js/mathjax` },
|
|
92
|
+
},
|
|
93
|
+
startup: {
|
|
94
|
+
typeset: false,
|
|
95
|
+
},
|
|
96
|
+
tex: {
|
|
97
|
+
macros: options.math.macros,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// 循环加载会抛异常
|
|
102
|
+
addScriptSync(`${options.cdn}/dist/js/mathjax/tex-svg-full.js`, "protyleMathJaxScript");
|
|
103
|
+
const renderMath = (mathElement: Element, next?: () => void) => {
|
|
104
|
+
const math = code160to32(mathElement.textContent).trim();
|
|
105
|
+
const mathOptions = window.MathJax.getMetricsFor(mathElement);
|
|
106
|
+
mathOptions.display = mathElement.tagName === "DIV";
|
|
107
|
+
window.MathJax.tex2svgPromise(math, mathOptions).then((node: Element) => {
|
|
108
|
+
mathElement.innerHTML = "";
|
|
109
|
+
mathElement.setAttribute("data-math", math);
|
|
110
|
+
mathElement.append(node);
|
|
111
|
+
window.MathJax.startup.document.clear();
|
|
112
|
+
window.MathJax.startup.document.updateDocument();
|
|
113
|
+
const errorTextElement = node.querySelector('[data-mml-node="merror"]');
|
|
114
|
+
if (errorTextElement && errorTextElement.textContent.trim() !== "") {
|
|
115
|
+
mathElement.innerHTML = errorTextElement.textContent.trim();
|
|
116
|
+
mathElement.className = "vditor-reset--error";
|
|
117
|
+
}
|
|
118
|
+
if (next) {
|
|
119
|
+
next();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
window.MathJax.startup.promise.then(() => {
|
|
124
|
+
const chains: any[] = [];
|
|
125
|
+
for (let i = 0; i < mathElements.length; i++) {
|
|
126
|
+
const mathElement = mathElements[i];
|
|
127
|
+
if (!mathElement.parentElement.classList.contains("vditor-wysiwyg__pre") &&
|
|
128
|
+
!mathElement.parentElement.classList.contains("vditor-ir__marker--pre") &&
|
|
129
|
+
!mathElement.getAttribute("data-math") && code160to32(mathElement.textContent).trim()) {
|
|
130
|
+
chains.push((next: () => void) => {
|
|
131
|
+
if (i === mathElements.length - 1) {
|
|
132
|
+
renderMath(mathElement);
|
|
133
|
+
} else {
|
|
134
|
+
renderMath(mathElement, next);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
chainAsync(chains);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const videoRender = (element: HTMLElement, url: string) => {
|
|
2
|
+
element.insertAdjacentHTML("afterend", `<video controls="controls" src="${url}"></video>`);
|
|
3
|
+
element.remove();
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
const audioRender = (element: HTMLElement, url: string) => {
|
|
7
|
+
element.insertAdjacentHTML("afterend", `<audio controls="controls" src="${url}"></audio>`);
|
|
8
|
+
element.remove();
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const iframeRender = (element: HTMLElement, url: string) => {
|
|
12
|
+
const youtubeMatch = url.match(/\/\/(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w|-]{11})(?:(?:[\?&]t=)(\S+))?/);
|
|
13
|
+
const youkuMatch = url.match(/\/\/v\.youku\.com\/v_show\/id_(\w+)=*\.html/);
|
|
14
|
+
const qqMatch = url.match(/\/\/v\.qq\.com\/x\/cover\/.*\/([^\/]+)\.html\??.*/);
|
|
15
|
+
const coubMatch = url.match(/(?:www\.|\/\/)coub\.com\/view\/(\w+)/);
|
|
16
|
+
const facebookMatch = url.match(/(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/);
|
|
17
|
+
const dailymotionMatch = url.match(/.+dailymotion.com\/(video|hub)\/(\w+)\?/);
|
|
18
|
+
const bilibiliMatch = url.match(/(?:www\.|\/\/)bilibili\.com\/video\/(\w+)/);
|
|
19
|
+
const tedMatch = url.match(/(?:www\.|\/\/)ted\.com\/talks\/(\w+)/);
|
|
20
|
+
|
|
21
|
+
if (youtubeMatch && youtubeMatch[1].length === 11) {
|
|
22
|
+
element.insertAdjacentHTML("afterend",
|
|
23
|
+
`<iframe class="iframe__video" src="//www.youtube.com/embed/${youtubeMatch[1] +
|
|
24
|
+
(youtubeMatch[2] ? "?start=" + youtubeMatch[2] : "")}"></iframe>`);
|
|
25
|
+
element.remove();
|
|
26
|
+
} else if (youkuMatch && youkuMatch[1]) {
|
|
27
|
+
element.insertAdjacentHTML("afterend",
|
|
28
|
+
`<iframe class="iframe__video" src="//player.youku.com/embed/${youkuMatch[1]}"></iframe>`);
|
|
29
|
+
element.remove();
|
|
30
|
+
} else if (qqMatch && qqMatch[1]) {
|
|
31
|
+
element.insertAdjacentHTML("afterend",
|
|
32
|
+
`<iframe class="iframe__video" src="https://v.qq.com/txp/iframe/player.html?vid=${qqMatch[1]}"></iframe>`);
|
|
33
|
+
element.remove();
|
|
34
|
+
} else if (coubMatch && coubMatch[1]) {
|
|
35
|
+
element.insertAdjacentHTML("afterend",
|
|
36
|
+
`<iframe class="iframe__video"
|
|
37
|
+
src="//coub.com/embed/${coubMatch[1]}?muted=false&autostart=false&originalSize=true&startWithHD=true"></iframe>`);
|
|
38
|
+
element.remove();
|
|
39
|
+
} else if (facebookMatch && facebookMatch[0]) {
|
|
40
|
+
element.insertAdjacentHTML("afterend",
|
|
41
|
+
`<iframe class="iframe__video"
|
|
42
|
+
src="https://www.facebook.com/plugins/video.php?href=${encodeURIComponent(facebookMatch[0])}"></iframe>`);
|
|
43
|
+
element.remove();
|
|
44
|
+
} else if (dailymotionMatch && dailymotionMatch[2]) {
|
|
45
|
+
element.insertAdjacentHTML("afterend",
|
|
46
|
+
`<iframe class="iframe__video"
|
|
47
|
+
src="https://www.dailymotion.com/embed/video/${dailymotionMatch[2]}"></iframe>`);
|
|
48
|
+
element.remove();
|
|
49
|
+
} else if (bilibiliMatch && bilibiliMatch[1]) {
|
|
50
|
+
element.insertAdjacentHTML("afterend",
|
|
51
|
+
`<iframe class="iframe__video"
|
|
52
|
+
src="//player.bilibili.com/player.html?bvid=${bilibiliMatch[1]}"></iframe>`);
|
|
53
|
+
element.remove();
|
|
54
|
+
} else if (tedMatch && tedMatch[1]) {
|
|
55
|
+
element.insertAdjacentHTML("afterend",
|
|
56
|
+
`<iframe class="iframe__video" src="//embed.ted.com/talks/${tedMatch[1]}"></iframe>`);
|
|
57
|
+
element.remove();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const mediaRender = (element: HTMLElement) => {
|
|
62
|
+
if (!element) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
element.querySelectorAll("a").forEach((aElement) => {
|
|
66
|
+
const url = aElement.getAttribute("href");
|
|
67
|
+
if (!url) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (url.match(/^.+.(mp4|m4v|ogg|ogv|webm)$/)) {
|
|
71
|
+
videoRender(aElement, url);
|
|
72
|
+
} else if (url.match(/^.+.(mp3|wav|flac)$/)) {
|
|
73
|
+
audioRender(aElement, url);
|
|
74
|
+
} else {
|
|
75
|
+
iframeRender(aElement, url);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {addScript} from "../util/addScript";
|
|
3
|
+
import {mermaidRenderAdapter} from "./adapterRender";
|
|
4
|
+
|
|
5
|
+
declare const mermaid: {
|
|
6
|
+
initialize(options: any): void,
|
|
7
|
+
init(options: any, element: Element): void,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const mermaidRender = (element: HTMLElement, cdn = Constants.CDN, theme: string) => {
|
|
11
|
+
const mermaidElements = mermaidRenderAdapter.getElements(element);
|
|
12
|
+
if (mermaidElements.length === 0) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
addScript(`${cdn}/dist/js/mermaid/mermaid.min.js`, "vditorMermaidScript").then(() => {
|
|
16
|
+
const config: any = {
|
|
17
|
+
altFontFamily: "sans-serif",
|
|
18
|
+
flowchart: {
|
|
19
|
+
htmlLabels: true,
|
|
20
|
+
useMaxWidth: true,
|
|
21
|
+
},
|
|
22
|
+
fontFamily: "sans-serif",
|
|
23
|
+
gantt: {
|
|
24
|
+
leftPadding: 75,
|
|
25
|
+
rightPadding: 20,
|
|
26
|
+
},
|
|
27
|
+
securityLevel: "loose",
|
|
28
|
+
sequence: {
|
|
29
|
+
boxMargin: 8,
|
|
30
|
+
diagramMarginX: 8,
|
|
31
|
+
diagramMarginY: 8,
|
|
32
|
+
useMaxWidth: true,
|
|
33
|
+
},
|
|
34
|
+
startOnLoad: false,
|
|
35
|
+
};
|
|
36
|
+
if (theme === "dark") {
|
|
37
|
+
config.theme = "dark";
|
|
38
|
+
config.themeVariables = {
|
|
39
|
+
activationBkgColor: "hsl(180, 1.5873015873%, 28.3529411765%)",
|
|
40
|
+
activationBorderColor: "#81B1DB",
|
|
41
|
+
activeTaskBkgColor: "#81B1DB",
|
|
42
|
+
activeTaskBorderColor: "#ffffff",
|
|
43
|
+
actorBkg: "#1f2020",
|
|
44
|
+
actorBorder: "#81B1DB",
|
|
45
|
+
actorLineColor: "lightgrey",
|
|
46
|
+
actorTextColor: "lightgrey",
|
|
47
|
+
altBackground: "hsl(0, 0%, 40%)",
|
|
48
|
+
altSectionBkgColor: "#333",
|
|
49
|
+
arrowheadColor: "lightgrey",
|
|
50
|
+
background: "#333",
|
|
51
|
+
border1: "#81B1DB",
|
|
52
|
+
border2: "rgba(255, 255, 255, 0.25)",
|
|
53
|
+
classText: "#e0dfdf",
|
|
54
|
+
clusterBkg: "hsl(180, 1.5873015873%, 28.3529411765%)",
|
|
55
|
+
clusterBorder: "rgba(255, 255, 255, 0.25)",
|
|
56
|
+
critBkgColor: "#E83737",
|
|
57
|
+
critBorderColor: "#E83737",
|
|
58
|
+
darkTextColor: "hsl(28.5714285714, 17.3553719008%, 86.2745098039%)",
|
|
59
|
+
defaultLinkColor: "lightgrey",
|
|
60
|
+
doneTaskBkgColor: "lightgrey",
|
|
61
|
+
doneTaskBorderColor: "grey",
|
|
62
|
+
edgeLabelBackground: "hsl(0, 0%, 34.4117647059%)",
|
|
63
|
+
errorBkgColor: "#a44141",
|
|
64
|
+
errorTextColor: "#ddd",
|
|
65
|
+
fillType0: "#1f2020",
|
|
66
|
+
fillType1: "hsl(180, 1.5873015873%, 28.3529411765%)",
|
|
67
|
+
fillType2: "hsl(244, 1.5873015873%, 12.3529411765%)",
|
|
68
|
+
fillType3: "hsl(244, 1.5873015873%, 28.3529411765%)",
|
|
69
|
+
fillType4: "hsl(116, 1.5873015873%, 12.3529411765%)",
|
|
70
|
+
fillType5: "hsl(116, 1.5873015873%, 28.3529411765%)",
|
|
71
|
+
fillType6: "hsl(308, 1.5873015873%, 12.3529411765%)",
|
|
72
|
+
fillType7: "hsl(308, 1.5873015873%, 28.3529411765%)",
|
|
73
|
+
fontFamily: "\"trebuchet ms\", verdana, arial",
|
|
74
|
+
fontSize: "16px",
|
|
75
|
+
gridColor: "lightgrey",
|
|
76
|
+
labelBackground: "#181818",
|
|
77
|
+
labelBoxBkgColor: "#1f2020",
|
|
78
|
+
labelBoxBorderColor: "#81B1DB",
|
|
79
|
+
labelColor: "#ccc",
|
|
80
|
+
labelTextColor: "lightgrey",
|
|
81
|
+
lineColor: "lightgrey",
|
|
82
|
+
loopTextColor: "lightgrey",
|
|
83
|
+
mainBkg: "#1f2020",
|
|
84
|
+
mainContrastColor: "lightgrey",
|
|
85
|
+
nodeBkg: "#1f2020",
|
|
86
|
+
nodeBorder: "#81B1DB",
|
|
87
|
+
noteBkgColor: "#fff5ad",
|
|
88
|
+
noteBorderColor: "rgba(255, 255, 255, 0.25)",
|
|
89
|
+
noteTextColor: "#1f2020",
|
|
90
|
+
primaryBorderColor: "hsl(180, 0%, 2.3529411765%)",
|
|
91
|
+
primaryColor: "#1f2020",
|
|
92
|
+
primaryTextColor: "#e0dfdf",
|
|
93
|
+
secondBkg: "hsl(180, 1.5873015873%, 28.3529411765%)",
|
|
94
|
+
secondaryBorderColor: "hsl(180, 0%, 18.3529411765%)",
|
|
95
|
+
secondaryColor: "hsl(180, 1.5873015873%, 28.3529411765%)",
|
|
96
|
+
secondaryTextColor: "rgb(183.8476190475, 181.5523809523, 181.5523809523)",
|
|
97
|
+
sectionBkgColor: "hsl(52.9411764706, 28.813559322%, 58.431372549%)",
|
|
98
|
+
sectionBkgColor2: "#EAE8D9",
|
|
99
|
+
sequenceNumberColor: "black",
|
|
100
|
+
signalColor: "lightgrey",
|
|
101
|
+
signalTextColor: "lightgrey",
|
|
102
|
+
taskBkgColor: "hsl(180, 1.5873015873%, 35.3529411765%)",
|
|
103
|
+
taskBorderColor: "#ffffff",
|
|
104
|
+
taskTextClickableColor: "#003163",
|
|
105
|
+
taskTextColor: "hsl(28.5714285714, 17.3553719008%, 86.2745098039%)",
|
|
106
|
+
taskTextDarkColor: "hsl(28.5714285714, 17.3553719008%, 86.2745098039%)",
|
|
107
|
+
taskTextLightColor: "lightgrey",
|
|
108
|
+
taskTextOutsideColor: "lightgrey",
|
|
109
|
+
tertiaryBorderColor: "hsl(20, 0%, 2.3529411765%)",
|
|
110
|
+
tertiaryColor: "hsl(20, 1.5873015873%, 12.3529411765%)",
|
|
111
|
+
tertiaryTextColor: "rgb(222.9999999999, 223.6666666666, 223.9999999999)",
|
|
112
|
+
textColor: "#ccc",
|
|
113
|
+
titleColor: "#F9FFFE",
|
|
114
|
+
todayLineColor: "#DB5757",
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
mermaid.initialize(config);
|
|
118
|
+
mermaidElements.forEach((item) => {
|
|
119
|
+
const code = mermaidRenderAdapter.getCode(item);
|
|
120
|
+
if (item.getAttribute("data-processed") === "true" || code.trim() === "") {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
mermaid.init(undefined, item);
|
|
124
|
+
item.setAttribute("data-processed", "true");
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {addScript} from "../util/addScript";
|
|
3
|
+
import {mindmapRenderAdapter} from "./adapterRender";
|
|
4
|
+
|
|
5
|
+
declare const echarts: {
|
|
6
|
+
init(element: HTMLElement, theme?: string): IEChart;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const mindmapRender = (element: (HTMLElement | Document) = document, cdn = Constants.CDN, theme: string) => {
|
|
10
|
+
const mindmapElements = mindmapRenderAdapter.getElements(element);
|
|
11
|
+
if (mindmapElements.length > 0) {
|
|
12
|
+
addScript(`${cdn}/dist/js/echarts/echarts.min.js`, "vditorEchartsScript").then(() => {
|
|
13
|
+
mindmapElements.forEach((e: HTMLDivElement) => {
|
|
14
|
+
if (e.parentElement.classList.contains("vditor-wysiwyg__pre") ||
|
|
15
|
+
e.parentElement.classList.contains("vditor-ir__marker--pre")) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const text = mindmapRenderAdapter.getCode(e);
|
|
19
|
+
if (!text) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
if (e.getAttribute("data-processed") === "true") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
echarts.init(e, theme === "dark" ? "dark" : undefined).setOption({
|
|
27
|
+
series: [
|
|
28
|
+
{
|
|
29
|
+
data: [JSON.parse(decodeURIComponent(text))],
|
|
30
|
+
initialTreeDepth: -1,
|
|
31
|
+
itemStyle: {
|
|
32
|
+
borderWidth: 0,
|
|
33
|
+
color: "#4285f4",
|
|
34
|
+
},
|
|
35
|
+
label: {
|
|
36
|
+
backgroundColor: "#f6f8fa",
|
|
37
|
+
borderColor: "#d1d5da",
|
|
38
|
+
borderRadius: 5,
|
|
39
|
+
borderWidth: 0.5,
|
|
40
|
+
color: "#586069",
|
|
41
|
+
lineHeight: 20,
|
|
42
|
+
offset: [-5, 0],
|
|
43
|
+
padding: [0, 5],
|
|
44
|
+
position: "insideRight",
|
|
45
|
+
},
|
|
46
|
+
lineStyle: {
|
|
47
|
+
color: "#d1d5da",
|
|
48
|
+
width: 1,
|
|
49
|
+
},
|
|
50
|
+
roam: true,
|
|
51
|
+
symbol: (value: number, params: { data?: { children?: object } }) => {
|
|
52
|
+
if (params?.data?.children) {
|
|
53
|
+
return "circle";
|
|
54
|
+
} else {
|
|
55
|
+
return "path://";
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
type: "tree",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
tooltip: {
|
|
62
|
+
trigger: "item",
|
|
63
|
+
triggerOn: "mousemove",
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
e.setAttribute("data-processed", "true");
|
|
67
|
+
} catch (error) {
|
|
68
|
+
e.className = "vditor-reset--error";
|
|
69
|
+
e.innerHTML = `mindmap render error: <br>${error}`;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|