@seafile/seafile-editor 0.4.8 → 1.0.0
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/.babelrc +5 -0
- package/.eslintignore +19 -0
- package/.eslintrc.json +52 -0
- package/.github/workflows/nodejs.yml +25 -0
- package/.vscode/settings.json +5 -0
- package/config/config.common.js +157 -0
- package/config/config.dev.js +53 -0
- package/config/jest/cssTransform.js +16 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/utils/theme.css.js +103 -0
- package/config.js +61 -0
- package/dev-server.js +145 -0
- package/jest.config.js +16 -0
- package/package.json +81 -131
- package/public/locales/en/seafile-editor.json +145 -148
- package/public/locales/zh-CN/seafile-editor.json +123 -135
- package/public/media/seafile-ui.css +6 -11166
- package/scripts/ejs.js +16 -0
- package/site/_i18n/index.js +35 -0
- package/site/api/index.js +212 -0
- package/site/app.js +21 -0
- package/site/assets/css/app.css +47 -0
- package/site/assets/css/seafile-editor.css +33 -0
- package/site/commons/loading/index.js +14 -0
- package/site/commons/loading/style.css +49 -0
- package/site/commons/switch/index.css +14 -0
- package/site/commons/switch/index.js +37 -0
- package/site/commons/toast/alert.js +106 -0
- package/site/commons/toast/index.js +5 -0
- package/site/commons/toast/toast.js +195 -0
- package/site/commons/toast/toastManager.js +138 -0
- package/site/commons/toast/toaster.js +64 -0
- package/site/index.html +23 -0
- package/site/index.js +21 -0
- package/site/pages/home.js +21 -0
- package/site/pages/plain-markdown-view.js +6 -0
- package/site/pages/rich-seafile-editor.js +72 -0
- package/site/pages/seafile-editor.js +39 -0
- package/site/pages/seafile-viewer.js +45 -0
- package/site/pages/simple-editor.js +44 -0
- package/site/pages/wiki-viewer.js +7 -0
- package/site/setting.js +36 -0
- package/site/setting.local.dist.js +23 -0
- package/src/assets/css/slate-editor.css +57 -0
- package/src/constants/event-types.js +11 -0
- package/src/constants/hot-keys.js +47 -0
- package/src/containers/article-info/index.js +49 -0
- package/src/containers/article-info/style.css +52 -0
- package/src/containers/custom/get-event-transfer.js +28 -0
- package/{dist → src}/containers/custom/set-event-transfer.js +13 -11
- package/src/containers/hotkeys-helper/classify-hotkeys.js +30 -0
- package/src/containers/hotkeys-helper/index.js +43 -0
- package/{dist/assets/css/user-help.css → src/containers/hotkeys-helper/style.css} +37 -29
- package/src/containers/loading/index.js +14 -0
- package/src/containers/loading/style.css +49 -0
- package/src/containers/outline/index.js +75 -0
- package/src/containers/outline/outline-item.js +28 -0
- package/src/containers/outline/style.css +45 -0
- package/src/editors/plain-markdown-editor/code-mirror.css +8 -0
- package/src/editors/plain-markdown-editor/code-mirror.js +73 -0
- package/src/editors/plain-markdown-editor/index.js +136 -0
- package/{dist/assets/editor/plain-editor.css → src/editors/plain-markdown-editor/style.css} +12 -4
- package/src/editors/simple-slate-editor /index.js +71 -0
- package/src/editors/simple-slate-editor /with-props-editor.js +15 -0
- package/src/editors/slate-editor/editor-help/index.js +46 -0
- package/src/editors/slate-editor/editor-help/style.css +15 -0
- package/src/editors/slate-editor/index.js +77 -0
- package/src/editors/slate-editor/with-props-editor.js +15 -0
- package/src/editors/slate-viewer/index.js +35 -0
- package/src/editors/slate-viewer/style.css +40 -0
- package/src/extension/commons/element-popover/index.js +52 -0
- package/src/extension/commons/index.js +10 -0
- package/src/extension/commons/menu/index.js +9 -0
- package/src/extension/commons/menu/menu-drop-down.js +110 -0
- package/src/extension/commons/menu/menu-group.js +20 -0
- package/src/extension/commons/menu/menu-item.js +60 -0
- package/src/extension/commons/menu/menu.css +120 -0
- package/src/extension/commons/tooltip/index.css +21 -0
- package/src/extension/commons/tooltip/index.js +26 -0
- package/src/extension/constants/element-types.js +23 -0
- package/src/extension/constants/index.js +37 -0
- package/src/extension/constants/keyboard.js +29 -0
- package/src/extension/constants/menus-config.js +149 -0
- package/src/extension/core/index.js +3 -0
- package/src/extension/core/queries/index.js +410 -0
- package/src/extension/core/transforms/focus-editor.js +12 -0
- package/src/extension/core/transforms/index.js +4 -0
- package/src/extension/core/transforms/move-children.js +23 -0
- package/src/extension/core/transforms/remove-node-children.js +8 -0
- package/src/extension/core/transforms/replace-node-children.js +14 -0
- package/src/extension/core/utils/index.js +76 -0
- package/src/extension/editor.js +14 -0
- package/src/extension/index.js +15 -0
- package/src/extension/plugins/blockquote/helpers.js +65 -0
- package/src/extension/plugins/blockquote/index.js +13 -0
- package/src/extension/plugins/blockquote/menu/index.js +31 -0
- package/src/extension/plugins/blockquote/plugin.js +64 -0
- package/src/extension/plugins/blockquote/render-elem.js +9 -0
- package/src/extension/plugins/check-list/helper.js +34 -0
- package/src/extension/plugins/check-list/index.js +14 -0
- package/src/extension/plugins/check-list/menu/index.js +44 -0
- package/src/extension/plugins/check-list/plugin.js +46 -0
- package/src/extension/plugins/check-list/render-elem.js +23 -0
- package/src/extension/plugins/clear-format/helpers.js +48 -0
- package/src/extension/plugins/clear-format/menu/index.js +39 -0
- package/src/extension/plugins/code-block/helpers.js +107 -0
- package/src/extension/plugins/code-block/index.js +14 -0
- package/src/extension/plugins/code-block/menu/index.js +40 -0
- package/src/extension/plugins/code-block/plugin.js +210 -0
- package/src/extension/plugins/code-block/render-elem/constant.js +17 -0
- package/src/extension/plugins/code-block/render-elem/index.js +55 -0
- package/src/extension/plugins/code-block/render-elem/language-selector.js +38 -0
- package/src/extension/plugins/code-block/render-elem/style.css +27 -0
- package/src/extension/plugins/formula/formula.css +22 -0
- package/src/extension/plugins/formula/helper.js +68 -0
- package/src/extension/plugins/formula/index.js +14 -0
- package/src/extension/plugins/formula/menu/formula-modal.js +73 -0
- package/src/extension/plugins/formula/menu/index.js +63 -0
- package/src/extension/plugins/formula/plugin.js +18 -0
- package/src/extension/plugins/formula/render-elem.js +40 -0
- package/src/extension/plugins/header/helper.js +47 -0
- package/src/extension/plugins/header/index.js +14 -0
- package/src/extension/plugins/header/menu/index.js +114 -0
- package/src/extension/plugins/header/menu/style.css +115 -0
- package/src/extension/plugins/header/plugin.js +134 -0
- package/src/extension/plugins/header/render-elem.js +31 -0
- package/src/extension/plugins/image/helper.js +50 -0
- package/src/extension/plugins/image/index.js +14 -0
- package/src/extension/plugins/image/menu/image-menu-dialog.js +68 -0
- package/src/extension/plugins/image/menu/image-menu-popover.js +76 -0
- package/src/extension/plugins/image/menu/index.js +61 -0
- package/src/extension/plugins/image/menu/style.css +36 -0
- package/src/extension/plugins/image/plugin.js +23 -0
- package/src/extension/plugins/image/render-element/image-previewer.js +71 -0
- package/src/extension/plugins/image/render-element/index.js +94 -0
- package/src/extension/plugins/image/render-element/style.css +60 -0
- package/src/extension/plugins/index.js +47 -0
- package/src/extension/plugins/link/helper.js +161 -0
- package/src/extension/plugins/link/index.js +14 -0
- package/src/extension/plugins/link/menu/index.js +82 -0
- package/src/extension/plugins/link/menu/link-modal.js +135 -0
- package/src/extension/plugins/link/plugin.js +85 -0
- package/src/extension/plugins/link/render-elem/index.js +69 -0
- package/src/extension/plugins/link/render-elem/link-popover.js +79 -0
- package/src/extension/plugins/link/render-elem/style.css +60 -0
- package/src/extension/plugins/list/constant.js +3 -0
- package/src/extension/plugins/list/helpers.js +53 -0
- package/src/extension/plugins/list/index.js +14 -0
- package/src/extension/plugins/list/menu/index.js +48 -0
- package/src/extension/plugins/list/plugin/index.js +48 -0
- package/src/extension/plugins/list/plugin/insert-break-list.js +25 -0
- package/src/extension/plugins/list/plugin/insert-fragment-list.js +162 -0
- package/src/extension/plugins/list/plugin/normalize-list.js +64 -0
- package/src/extension/plugins/list/plugin/on-tab-handle.js +34 -0
- package/src/extension/plugins/list/queries/index.js +39 -0
- package/src/extension/plugins/list/render-elem/index.js +26 -0
- package/src/extension/plugins/list/render-elem/style.css +6 -0
- package/src/extension/plugins/list/transforms/index.js +23 -0
- package/src/extension/plugins/list/transforms/insert-list-item.js +65 -0
- package/src/extension/plugins/list/transforms/move-list-item-down.js +40 -0
- package/src/extension/plugins/list/transforms/move-list-item-up.js +105 -0
- package/src/extension/plugins/list/transforms/move-list-items-to-list.js +58 -0
- package/src/extension/plugins/list/transforms/move-list-items.js +76 -0
- package/src/extension/plugins/list/transforms/normalize-list-item.js +92 -0
- package/src/extension/plugins/list/transforms/normalize-nested-list.js +31 -0
- package/src/extension/plugins/list/transforms/remove-first-list-item.js +11 -0
- package/src/extension/plugins/list/transforms/transforms-to-list.js +91 -0
- package/src/extension/plugins/list/transforms/unwrap-list.js +44 -0
- package/src/extension/plugins/node-id/constants.js +18 -0
- package/src/extension/plugins/node-id/helpers.js +61 -0
- package/src/extension/plugins/node-id/index.js +7 -0
- package/src/extension/plugins/node-id/with-node-id.js +37 -0
- package/src/extension/plugins/paragraph/helper.js +9 -0
- package/src/extension/plugins/paragraph/index.js +12 -0
- package/src/extension/plugins/paragraph/plugin.js +40 -0
- package/src/extension/plugins/paragraph/render-elem.js +11 -0
- package/src/extension/plugins/table/constant.js +3 -0
- package/src/extension/plugins/table/helper.js +175 -0
- package/src/extension/plugins/table/index.js +15 -0
- package/src/extension/plugins/table/menu/index.js +69 -0
- package/src/extension/plugins/table/menu/style.css +32 -0
- package/src/extension/plugins/table/menu/table-operator.js +101 -0
- package/src/extension/plugins/table/menu/table-size-selector.js +71 -0
- package/src/extension/plugins/table/model.js +69 -0
- package/src/extension/plugins/table/plugin.js +159 -0
- package/src/extension/plugins/table/render-elem/context-menu.js +78 -0
- package/src/extension/plugins/table/render-elem/index.js +157 -0
- package/src/extension/plugins/table/render-elem/style.css +94 -0
- package/src/extension/plugins/table/table-operations.js +162 -0
- package/src/extension/plugins/text-style/helpers.js +38 -0
- package/src/extension/plugins/text-style/index.js +12 -0
- package/src/extension/plugins/text-style/menu/index.js +41 -0
- package/src/extension/plugins/text-style/plugin.js +37 -0
- package/src/extension/plugins/text-style/render-elem.js +45 -0
- package/src/extension/render/render-element.js +82 -0
- package/src/extension/render/render-leaf.js +16 -0
- package/src/extension/toolbar/header-toolbar/index.js +129 -0
- package/src/extension/toolbar/header-toolbar/style.css +41 -0
- package/src/extension/toolbar/index.js +5 -0
- package/src/extension/toolbar/user-help/shortcut-dialog.js +144 -0
- package/src/hooks/use-mathjax.js +44 -0
- package/src/hooks/use-scroll-context.js +14 -0
- package/src/hooks/use-selection-update.js +14 -0
- package/src/index.js +22 -0
- package/src/pages/markdown-editor.js +53 -0
- package/src/pages/markdown-view.js +36 -0
- package/src/pages/rich-markdown-editor.js +95 -0
- package/src/pages/simple-editor.js +52 -0
- package/src/slate-convert/html-to-slate/constants.js +54 -0
- package/src/slate-convert/html-to-slate/helper.js +22 -0
- package/src/slate-convert/html-to-slate/index.js +144 -0
- package/src/slate-convert/html-to-slate/rules/blockquote.js +16 -0
- package/src/slate-convert/html-to-slate/rules/check-list.js +22 -0
- package/src/slate-convert/html-to-slate/rules/code-block.js +91 -0
- package/src/slate-convert/html-to-slate/rules/header.js +18 -0
- package/src/slate-convert/html-to-slate/rules/image.js +18 -0
- package/src/slate-convert/html-to-slate/rules/index.js +23 -0
- package/src/slate-convert/html-to-slate/rules/link.js +24 -0
- package/src/slate-convert/html-to-slate/rules/list.js +52 -0
- package/src/slate-convert/html-to-slate/rules/paragraph.js +16 -0
- package/src/slate-convert/html-to-slate/rules/table.js +37 -0
- package/src/slate-convert/html-to-slate/rules/text.js +63 -0
- package/src/slate-convert/index.js +11 -0
- package/src/slate-convert/md-to-html/index.js +44 -0
- package/src/slate-convert/md-to-html/sanitize-schema.js +41 -0
- package/src/slate-convert/md-to-slate/index.js +42 -0
- package/src/slate-convert/md-to-slate/transform.js +336 -0
- package/src/slate-convert/slate-to-md/index.js +44 -0
- package/src/slate-convert/slate-to-md/transform.js +248 -0
- package/src/utils/common.js +30 -0
- package/src/utils/deserialize-html.js +174 -0
- package/src/utils/dom-utils.js +45 -0
- package/src/utils/event-bus.js +37 -0
- package/src/utils/event-handler.js +36 -0
- package/src/utils/object-utils.js +51 -0
- package/tests/core/constants/index.js +54 -0
- package/tests/core/index.js +11 -0
- package/tests/core/jsx/index.js +9 -0
- package/tests/core/stub-editor/index.js +26 -0
- package/tests/core/utils.js +58 -0
- package/tests/extension/plugins/list/insert-block.test.js +40 -0
- package/tests/extension/plugins/list/insert-fragment-list.test.js +392 -0
- package/tests/extension/plugins/list/toggle-list.test.js +160 -0
- package/tests/extension/plugins/text/text.test.js +29 -0
- package/tests/extension/plugins/text-style/toggle-text-style.test.js +148 -0
- package/tests/slate-convert/html-to-slate/blockquote.test.js +107 -0
- package/tests/slate-convert/html-to-slate/code-block.test.js +32 -0
- package/tests/slate-convert/html-to-slate/header.test.js +56 -0
- package/tests/slate-convert/html-to-slate/link.test.js +77 -0
- package/tests/slate-convert/html-to-slate/list.test.js +190 -0
- package/tests/slate-convert/html-to-slate/paragraph.test.js +40 -0
- package/tests/slate-convert/html-to-slate/text.test.js +131 -0
- package/tests/slate-convert/md-to-html/blockquote.test.js +110 -0
- package/tests/slate-convert/md-to-html/check-list.test.js +19 -0
- package/tests/slate-convert/md-to-html/code-block.test.js +19 -0
- package/tests/slate-convert/md-to-html/header.test.js +20 -0
- package/tests/slate-convert/md-to-html/image.test.js +17 -0
- package/tests/slate-convert/md-to-html/image_reference.test.js +17 -0
- package/tests/slate-convert/md-to-html/link.test.js +15 -0
- package/tests/slate-convert/md-to-html/link_reference.test.js +15 -0
- package/tests/slate-convert/md-to-html/list-ordered.test.js +22 -0
- package/tests/slate-convert/md-to-html/list-unordered.test.js +22 -0
- package/tests/slate-convert/md-to-html/paragraph.test.js +15 -0
- package/tests/slate-convert/md-to-html/table.test.js +29 -0
- package/tests/slate-convert/md-to-html/text_base.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_bold.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_bold_italic.test.js +15 -0
- package/tests/slate-convert/md-to-html/text_code.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_code_bold.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_code_bold_italic.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_code_italic.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_italic.test.js +14 -0
- package/tests/slate-convert/md-to-slate/blockquote.test.js +200 -0
- package/tests/slate-convert/md-to-slate/check-list.test.js +34 -0
- package/tests/slate-convert/md-to-slate/code-block.test.js +32 -0
- package/tests/slate-convert/md-to-slate/header.test.js +49 -0
- package/tests/slate-convert/md-to-slate/image.test.js +31 -0
- package/tests/slate-convert/md-to-slate/link.test.js +30 -0
- package/tests/slate-convert/md-to-slate/list-ordered.test.js +42 -0
- package/tests/slate-convert/md-to-slate/list-unordered.test.js +42 -0
- package/tests/slate-convert/md-to-slate/paragraph.test.js +19 -0
- package/tests/slate-convert/md-to-slate/table.test.js +34 -0
- package/tests/slate-convert/md-to-slate/text_base.test.js +19 -0
- package/tests/slate-convert/md-to-slate/text_bold.test.js +22 -0
- package/tests/slate-convert/md-to-slate/text_bold_italic.test.js +23 -0
- package/tests/slate-convert/md-to-slate/text_code.test.js +22 -0
- package/tests/slate-convert/md-to-slate/text_code_bold.test.js +23 -0
- package/tests/slate-convert/md-to-slate/text_code_bold_italic.test.js +24 -0
- package/tests/slate-convert/md-to-slate/text_code_italic.test.js +23 -0
- package/tests/slate-convert/md-to-slate/text_italic.test.js +22 -0
- package/tests/slate-convert/slate-to-md/blockquote.test.js +416 -0
- package/tests/slate-convert/slate-to-md/check-list.test.js +96 -0
- package/tests/slate-convert/slate-to-md/code-block.test.js +35 -0
- package/tests/slate-convert/slate-to-md/formula.test.js +26 -0
- package/tests/slate-convert/slate-to-md/header.test.js +109 -0
- package/tests/slate-convert/slate-to-md/image.test.js +98 -0
- package/tests/slate-convert/slate-to-md/link.test.js +52 -0
- package/tests/slate-convert/slate-to-md/list-ordered.test.js +87 -0
- package/tests/slate-convert/slate-to-md/list-unordered.test.js +81 -0
- package/tests/slate-convert/slate-to-md/paragraph.test.js +28 -0
- package/tests/slate-convert/slate-to-md/table.test.js +56 -0
- package/tests/slate-convert/slate-to-md/text_base.test.js +28 -0
- package/tests/slate-convert/slate-to-md/text_bold.test.js +36 -0
- package/tests/slate-convert/slate-to-md/text_bold_italic.test.js +42 -0
- package/tests/slate-convert/slate-to-md/text_code.test.js +31 -0
- package/tests/slate-convert/slate-to-md/text_code_bold.test.js +37 -0
- package/tests/slate-convert/slate-to-md/text_code_bold_italic.test.js +43 -0
- package/tests/slate-convert/slate-to-md/text_code_italic.test.js +37 -0
- package/tests/slate-convert/slate-to-md/text_italic.test.js +36 -0
- package/README.md +0 -52
- package/TODO.md +0 -55
- package/dist/assets/css/diff-viewer.css +0 -105
- package/dist/assets/css/formula.css +0 -19
- package/dist/assets/css/history-viewer.css +0 -104
- package/dist/assets/css/image.css +0 -134
- package/dist/assets/css/link.css +0 -7
- package/dist/assets/css/markdown-editor.css +0 -12
- package/dist/assets/css/markdown-viewer.css +0 -69
- package/dist/assets/css/navbar-imgbutton.css +0 -83
- package/dist/assets/css/outline.css +0 -29
- package/dist/assets/css/table.css +0 -57
- package/dist/assets/css/textlink-hovermenu.css +0 -47
- package/dist/assets/css/topbar.css +0 -350
- package/dist/assets/css/tree-view.css +0 -67
- package/dist/assets/editor/seatable-editor.css +0 -77
- package/dist/assets/editor/simple-editor.css +0 -77
- package/dist/components/click-outside.js +0 -46
- package/dist/components/context-menu.js +0 -97
- package/dist/components/dialogs/add-formula-dialog.js +0 -116
- package/dist/components/dialogs/add-image-dialog.js +0 -69
- package/dist/components/dialogs/add-link-dialog.js +0 -133
- package/dist/components/dialogs/shortcut-dialog.js +0 -131
- package/dist/components/error-boundary.js +0 -28
- package/dist/components/load-script/index.js +0 -69
- package/dist/components/loading.js +0 -25
- package/dist/components/menu/index.js +0 -4
- package/dist/components/menu/item.js +0 -49
- package/dist/components/menu/menu.js +0 -38
- package/dist/components/menu/style.css +0 -42
- package/dist/components/modal-portal.js +0 -38
- package/dist/components/outline/index.js +0 -92
- package/dist/components/outline/outline-item.js +0 -58
- package/dist/components/select/_option.js +0 -44
- package/dist/components/select/field-setting.js +0 -106
- package/dist/components/select/index.js +0 -149
- package/dist/components/select/style.css +0 -144
- package/dist/components/svg-icons/check-mark-icon.js +0 -14
- package/dist/components/svg-icons/column-icon.js +0 -17
- package/dist/components/svg-icons/text-icon.js +0 -34
- package/dist/components/text-link-hover-menu/index.js +0 -123
- package/dist/components/toast/alert.js +0 -138
- package/dist/components/toast/index.js +0 -3
- package/dist/components/toast/toast.js +0 -159
- package/dist/components/toast/toastManager.js +0 -139
- package/dist/components/toast/toaster.js +0 -65
- package/dist/components/toolbar/header-list.js +0 -114
- package/dist/components/toolbar/help-group.js +0 -33
- package/dist/components/toolbar/index.js +0 -4
- package/dist/components/toolbar/insert-image.js +0 -106
- package/dist/components/toolbar/insert-table.js +0 -136
- package/dist/components/toolbar/table-group.js +0 -74
- package/dist/components/toolbar/toolbar.js +0 -317
- package/dist/components/toolbar/widgets/button-group.js +0 -24
- package/dist/components/toolbar/widgets/button-item.js +0 -129
- package/dist/components/toolbar/widgets/drop-list.js +0 -88
- package/dist/components/user-help/index.js +0 -179
- package/dist/config.js +0 -15
- package/dist/constants/cell-types.js +0 -29
- package/dist/constants/column.js +0 -4
- package/dist/containers/code-highlight-package.js +0 -14
- package/dist/containers/controller/block-element-controller.js +0 -375
- package/dist/containers/controller/index.js +0 -5
- package/dist/containers/controller/inline-element-controller.js +0 -134
- package/dist/containers/controller/normalize-controller.js +0 -95
- package/dist/containers/controller/shortcut-controller.js +0 -385
- package/dist/containers/controller/void-element-controller.js +0 -9
- package/dist/containers/custom/custom.js +0 -18
- package/dist/containers/custom/get-event-transfer.js +0 -33
- package/dist/containers/custom/getNodesByTypeAtRange.js +0 -57
- package/dist/containers/custom/insertNodes.js +0 -120
- package/dist/containers/custom/is-empty-paragraph.js +0 -9
- package/dist/containers/custom/split-nodes-at-point.js +0 -136
- package/dist/containers/custom/unwrap-node-by-type-at-range.js +0 -70
- package/dist/containers/editor-context.js +0 -85
- package/dist/containers/editor-utils/block-element-utils/blockquote-utils.js +0 -80
- package/dist/containers/editor-utils/block-element-utils/code-utils.js +0 -145
- package/dist/containers/editor-utils/block-element-utils/formula-utils.js +0 -51
- package/dist/containers/editor-utils/block-element-utils/index.js +0 -31
- package/dist/containers/editor-utils/block-element-utils/list-utils.js +0 -395
- package/dist/containers/editor-utils/block-element-utils/table-utils.js +0 -412
- package/dist/containers/editor-utils/clear-format-utils.js +0 -84
- package/dist/containers/editor-utils/common-editor-utils.js +0 -492
- package/dist/containers/editor-utils/inline-element-utils/index.js +0 -95
- package/dist/containers/editor-utils/mark-utils.js +0 -20
- package/dist/containers/editor-utils/range-utils.js +0 -7
- package/dist/containers/editor-utils/selection-utils.js +0 -30
- package/dist/containers/editor-utils/text-utils.js +0 -117
- package/dist/containers/editor-widgets/check-list-item.js +0 -53
- package/dist/containers/editor-widgets/code-block.js +0 -128
- package/dist/containers/editor-widgets/column.js +0 -100
- package/dist/containers/editor-widgets/formula.js +0 -67
- package/dist/containers/editor-widgets/image.js +0 -237
- package/dist/containers/editor-widgets/link.js +0 -9
- package/dist/containers/editor-widgets/table.js +0 -144
- package/dist/containers/element-model/blockquote.js +0 -13
- package/dist/containers/element-model/column.js +0 -19
- package/dist/containers/element-model/image.js +0 -16
- package/dist/containers/element-model/link.js +0 -16
- package/dist/containers/element-model/table.js +0 -57
- package/dist/containers/element-model/text.js +0 -10
- package/dist/containers/render-utils/common-utils.js +0 -80
- package/dist/containers/render-utils/editor-utils.js +0 -133
- package/dist/containers/render-utils/viewer-utils.js +0 -198
- package/dist/containers/viewer-widgets/viewer-formula/index.js +0 -54
- package/dist/containers/viewer-widgets/viewer-image/index.js +0 -70
- package/dist/containers/viewer-widgets/viewer-image/viewer-image.css +0 -3
- package/dist/editors/index.js +0 -78
- package/dist/editors/markdown-editor.js +0 -206
- package/dist/editors/plain-markdown-editor.js +0 -285
- package/dist/editors/seatable-editor.js +0 -210
- package/dist/editors/simple-editor.js +0 -200
- package/dist/index.js +0 -11
- package/dist/setting.local.js +0 -14
- package/dist/utils/deserialize-html.js +0 -260
- package/dist/utils/diff/compare-strings.js +0 -35
- package/dist/utils/diff/diff.js +0 -769
- package/dist/utils/diff/index.js +0 -2
- package/dist/utils/seafile-markdown2html.js +0 -52
- package/dist/utils/slate2markdown/deserialize.js +0 -588
- package/dist/utils/slate2markdown/index.js +0 -3
- package/dist/utils/slate2markdown/serialize.js +0 -366
- package/dist/utils/utils.js +0 -68
- package/dist/viewer/diff-viewer.js +0 -85
- package/dist/viewer/index.js +0 -4
- package/dist/viewer/markdown-viewer.js +0 -121
- package/dist/viewer/seatable-viewer.js +0 -63
- package/dist/viewer/slate-viewer.js +0 -71
- package/public/index.html +0 -45
- package/public/manifest.json +0 -15
- package/public/media/seafile-logo.png +0 -0
- /package/{dist/assets/css/keyboard-shortcuts.css → src/extension/toolbar/user-help/style.css} +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import { Editor, Range } from 'slate';
|
|
4
|
-
|
|
5
|
-
// modified on the basic of the slate function Editor.nodes
|
|
6
|
-
// todo: get the node which nearest to the selection
|
|
7
|
-
var getNodesByTypeAtRange = function getNodesByTypeAtRange(editor, type) {
|
|
8
|
-
var match = {};
|
|
9
|
-
if (Array.isArray(type)) {
|
|
10
|
-
match.match = type;
|
|
11
|
-
} else {
|
|
12
|
-
match.match = {
|
|
13
|
-
type: type
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
var nodes = Editor.nodes(editor, match);
|
|
17
|
-
var _Editor$nodes = Editor.nodes(editor, {
|
|
18
|
-
match: 'block'
|
|
19
|
-
}),
|
|
20
|
-
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
|
|
21
|
-
blockNode = _Editor$nodes2[0];
|
|
22
|
-
var listItemDepth = blockNode[1].length - 1;
|
|
23
|
-
if (Range.isCollapsed(editor.selection)) {
|
|
24
|
-
var node;
|
|
25
|
-
var _iterator = _createForOfIteratorHelper(nodes),
|
|
26
|
-
_step;
|
|
27
|
-
try {
|
|
28
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
29
|
-
var item = _step.value;
|
|
30
|
-
node = item;
|
|
31
|
-
}
|
|
32
|
-
} catch (err) {
|
|
33
|
-
_iterator.e(err);
|
|
34
|
-
} finally {
|
|
35
|
-
_iterator.f();
|
|
36
|
-
}
|
|
37
|
-
return node;
|
|
38
|
-
} else {
|
|
39
|
-
var itemsWithSameAncesstor = [];
|
|
40
|
-
var _iterator2 = _createForOfIteratorHelper(nodes),
|
|
41
|
-
_step2;
|
|
42
|
-
try {
|
|
43
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
44
|
-
var _node = _step2.value;
|
|
45
|
-
if (listItemDepth === _node[1].length) {
|
|
46
|
-
itemsWithSameAncesstor.push(_node);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
} catch (err) {
|
|
50
|
-
_iterator2.e(err);
|
|
51
|
-
} finally {
|
|
52
|
-
_iterator2.f();
|
|
53
|
-
}
|
|
54
|
-
return itemsWithSameAncesstor;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
export default getNodesByTypeAtRange;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import { Editor, Range, Path, Node, Point, Text } from 'slate';
|
|
4
|
-
|
|
5
|
-
// modifyed function from slate
|
|
6
|
-
// The goal of the modification: focus the selection to the end of the last inserted node
|
|
7
|
-
|
|
8
|
-
export var insertNodes = function insertNodes(editor, nodes) {
|
|
9
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10
|
-
Editor.withoutNormalizing(editor, function () {
|
|
11
|
-
// eslint-disable-next-line no-unused-vars
|
|
12
|
-
var selection = editor.selection;
|
|
13
|
-
var _options$hanging = options.hanging,
|
|
14
|
-
hanging = _options$hanging === void 0 ? false : _options$hanging,
|
|
15
|
-
_options$voids = options.voids,
|
|
16
|
-
voids = _options$voids === void 0 ? false : _options$voids;
|
|
17
|
-
var at = options.at,
|
|
18
|
-
match = options.match,
|
|
19
|
-
select = options.select;
|
|
20
|
-
if (Node.isNode(nodes)) {
|
|
21
|
-
nodes = [nodes];
|
|
22
|
-
}
|
|
23
|
-
if (nodes.length === 0) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
var _nodes = nodes,
|
|
27
|
-
_nodes2 = _slicedToArray(_nodes, 1),
|
|
28
|
-
node = _nodes2[0];
|
|
29
|
-
// By default, use the selection as the target location. But if there is
|
|
30
|
-
// no selection, insert at the end of the document since that is such a
|
|
31
|
-
// common use case when inserting from a non-selected state.
|
|
32
|
-
if (!at) {
|
|
33
|
-
if (editor.selection) {
|
|
34
|
-
at = editor.selection;
|
|
35
|
-
} else if (editor.children.length > 0) {
|
|
36
|
-
at = Editor.end(editor, []);
|
|
37
|
-
} else {
|
|
38
|
-
at = [0];
|
|
39
|
-
}
|
|
40
|
-
select = true;
|
|
41
|
-
}
|
|
42
|
-
if (select == null) {
|
|
43
|
-
select = false;
|
|
44
|
-
}
|
|
45
|
-
if (Range.isRange(at)) {
|
|
46
|
-
if (!hanging) {
|
|
47
|
-
at = Editor.unhangRange(editor, at);
|
|
48
|
-
}
|
|
49
|
-
if (Range.isCollapsed(at)) {
|
|
50
|
-
at = at.anchor;
|
|
51
|
-
} else {
|
|
52
|
-
var _Range$edges = Range.edges(at),
|
|
53
|
-
_Range$edges2 = _slicedToArray(_Range$edges, 2),
|
|
54
|
-
end = _Range$edges2[1];
|
|
55
|
-
var pointRef = Editor.pointRef(editor, end);
|
|
56
|
-
Editor.delete(editor, {
|
|
57
|
-
at: at
|
|
58
|
-
});
|
|
59
|
-
at = pointRef.unref();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (Point.isPoint(at)) {
|
|
63
|
-
if (match == null) {
|
|
64
|
-
if (Text.isText(node)) {
|
|
65
|
-
match = 'text';
|
|
66
|
-
} else if (editor.isInline(node)) {
|
|
67
|
-
match = ['inline', 'text'];
|
|
68
|
-
} else {
|
|
69
|
-
match = 'block';
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
var atMatch = Editor.match(editor, at.path, match);
|
|
73
|
-
if (atMatch) {
|
|
74
|
-
var _atMatch = _slicedToArray(atMatch, 2),
|
|
75
|
-
matchPath = _atMatch[1];
|
|
76
|
-
var pathRef = Editor.pathRef(editor, matchPath);
|
|
77
|
-
var isAtEnd = Editor.isEnd(editor, at, matchPath);
|
|
78
|
-
Editor.splitNodes(editor, {
|
|
79
|
-
at: at,
|
|
80
|
-
match: match
|
|
81
|
-
});
|
|
82
|
-
var _path = pathRef.unref();
|
|
83
|
-
at = isAtEnd ? Path.next(_path) : _path;
|
|
84
|
-
} else {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
var parentPath = Path.parent(at);
|
|
89
|
-
var index = at[at.length - 1];
|
|
90
|
-
if (!voids && Editor.match(editor, parentPath, 'void')) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
var path = [];
|
|
94
|
-
var _iterator = _createForOfIteratorHelper(nodes),
|
|
95
|
-
_step;
|
|
96
|
-
try {
|
|
97
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
98
|
-
var _node = _step.value;
|
|
99
|
-
path = parentPath.concat(index);
|
|
100
|
-
index++;
|
|
101
|
-
at = path;
|
|
102
|
-
editor.apply({
|
|
103
|
-
type: 'insert_node',
|
|
104
|
-
path: path,
|
|
105
|
-
node: _node
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
} catch (err) {
|
|
109
|
-
_iterator.e(err);
|
|
110
|
-
} finally {
|
|
111
|
-
_iterator.f();
|
|
112
|
-
}
|
|
113
|
-
if (select) {
|
|
114
|
-
var point = Editor.end(editor, at);
|
|
115
|
-
if (point) {
|
|
116
|
-
Editor.select(editor, point);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Node, Text } from 'slate';
|
|
2
|
-
var isEmptyParagraph = function isEmptyParagraph(node) {
|
|
3
|
-
if (node.type !== 'paragraph') return false;
|
|
4
|
-
if (node.children.length === 1 && Text.isText(node.children[0]) && Node.text(node).length === 0) {
|
|
5
|
-
return true;
|
|
6
|
-
}
|
|
7
|
-
return false;
|
|
8
|
-
};
|
|
9
|
-
export default isEmptyParagraph;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
-
var _excluded = ["text", "children"];
|
|
6
|
-
import { Element, Editor, Range, Path } from 'slate';
|
|
7
|
-
|
|
8
|
-
// modified on the basic of slate function Editor.SplitNodes
|
|
9
|
-
// todo: split the node which nearest to the selection
|
|
10
|
-
var splitNodesAtPoint = function splitNodesAtPoint(editor) {
|
|
11
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12
|
-
Editor.withoutNormalizing(editor, function () {
|
|
13
|
-
var match = options.match,
|
|
14
|
-
_options$at = options.at,
|
|
15
|
-
at = _options$at === void 0 ? editor.selection : _options$at,
|
|
16
|
-
_options$height = options.height,
|
|
17
|
-
height = _options$height === void 0 ? 0 : _options$height,
|
|
18
|
-
_options$always = options.always,
|
|
19
|
-
always = _options$always === void 0 ? false : _options$always,
|
|
20
|
-
_options$voids = options.voids,
|
|
21
|
-
voids = _options$voids === void 0 ? false : _options$voids;
|
|
22
|
-
if (match == null) {
|
|
23
|
-
match = 'block';
|
|
24
|
-
}
|
|
25
|
-
if (Range.isRange(at)) {
|
|
26
|
-
at = deleteRange(editor, at);
|
|
27
|
-
}
|
|
28
|
-
if (!at) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
var beforeRef = Editor.pointRef(editor, at, {
|
|
32
|
-
affinity: 'backward'
|
|
33
|
-
});
|
|
34
|
-
var nodes = Editor.nodes(editor, {
|
|
35
|
-
at: at,
|
|
36
|
-
match: match,
|
|
37
|
-
voids: voids
|
|
38
|
-
});
|
|
39
|
-
var highest = _toConsumableArray(nodes).pop();
|
|
40
|
-
if (!highest) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
var voidMatch = Editor.match(editor, at, 'void');
|
|
44
|
-
var nudge = 0;
|
|
45
|
-
if (!voids && voidMatch) {
|
|
46
|
-
var _voidMatch = _slicedToArray(voidMatch, 2),
|
|
47
|
-
voidNode = _voidMatch[0],
|
|
48
|
-
voidPath = _voidMatch[1];
|
|
49
|
-
if (Element.isElement(voidNode) && editor.isInline(voidNode)) {
|
|
50
|
-
var after = Editor.after(editor, voidPath);
|
|
51
|
-
if (!after) {
|
|
52
|
-
var text = {
|
|
53
|
-
text: ''
|
|
54
|
-
};
|
|
55
|
-
var afterPath = Path.next(voidPath);
|
|
56
|
-
Editor.insertNodes(editor, text, {
|
|
57
|
-
at: afterPath,
|
|
58
|
-
voids: voids
|
|
59
|
-
});
|
|
60
|
-
after = Editor.point(editor, afterPath);
|
|
61
|
-
}
|
|
62
|
-
at = after;
|
|
63
|
-
always = true;
|
|
64
|
-
}
|
|
65
|
-
var siblingHeight = at.path.length - voidPath.length;
|
|
66
|
-
height = siblingHeight + 1;
|
|
67
|
-
always = true;
|
|
68
|
-
}
|
|
69
|
-
var afterRef = Editor.pointRef(editor, at);
|
|
70
|
-
var depth = at.path.length - height;
|
|
71
|
-
var _highest = _slicedToArray(highest, 2),
|
|
72
|
-
highestPath = _highest[1];
|
|
73
|
-
var lowestPath = at.path.slice(0, depth);
|
|
74
|
-
var position = height === 0 ? at.offset : at.path[depth] + nudge;
|
|
75
|
-
var target = null;
|
|
76
|
-
var _iterator = _createForOfIteratorHelper(Editor.levels(editor, {
|
|
77
|
-
at: lowestPath,
|
|
78
|
-
reverse: true,
|
|
79
|
-
voids: voids
|
|
80
|
-
})),
|
|
81
|
-
_step;
|
|
82
|
-
try {
|
|
83
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
84
|
-
var _step$value = _slicedToArray(_step.value, 2),
|
|
85
|
-
node = _step$value[0],
|
|
86
|
-
path = _step$value[1];
|
|
87
|
-
var split = false;
|
|
88
|
-
if (path.length < highestPath.length || path.length === 0 || !voids && Element.isElement(node) && editor.isVoid(node)) {
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
var _point = beforeRef.current;
|
|
92
|
-
var isEnd = Editor.isEnd(editor, _point, path);
|
|
93
|
-
if (always || !beforeRef || !Editor.isEdge(editor, _point, path)) {
|
|
94
|
-
split = true;
|
|
95
|
-
var _text = node.text,
|
|
96
|
-
children = node.children,
|
|
97
|
-
properties = _objectWithoutProperties(node, _excluded);
|
|
98
|
-
editor.apply({
|
|
99
|
-
type: 'split_node',
|
|
100
|
-
path: path,
|
|
101
|
-
position: position,
|
|
102
|
-
target: target,
|
|
103
|
-
properties: properties
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
target = position;
|
|
107
|
-
position = path[path.length - 1] + (split || isEnd ? 1 : 0);
|
|
108
|
-
}
|
|
109
|
-
} catch (err) {
|
|
110
|
-
_iterator.e(err);
|
|
111
|
-
} finally {
|
|
112
|
-
_iterator.f();
|
|
113
|
-
}
|
|
114
|
-
if (options.at == null) {
|
|
115
|
-
var point = afterRef.current || Editor.end(editor, []);
|
|
116
|
-
Editor.select(editor, point);
|
|
117
|
-
}
|
|
118
|
-
beforeRef.unref();
|
|
119
|
-
afterRef.unref();
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
|
-
deleteRange = function deleteRange(editor, range) {
|
|
123
|
-
if (Range.isCollapsed(range)) {
|
|
124
|
-
return range.anchor;
|
|
125
|
-
} else {
|
|
126
|
-
var _Range$edges = Range.edges(range),
|
|
127
|
-
_Range$edges2 = _slicedToArray(_Range$edges, 2),
|
|
128
|
-
end = _Range$edges2[1];
|
|
129
|
-
var pointRef = Editor.pointRef(editor, end);
|
|
130
|
-
Editor.delete(editor, {
|
|
131
|
-
at: range
|
|
132
|
-
});
|
|
133
|
-
return pointRef.unref();
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
export default splitNodesAtPoint;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
-
import { Editor, Range } from 'slate';
|
|
4
|
-
|
|
5
|
-
// modified on the basic of slate function Editor.unwrapNodes
|
|
6
|
-
// todo: split the unwrap by type the node which nearest to the selection
|
|
7
|
-
|
|
8
|
-
var unwrapNodesByTypeAtRange = function unwrapNodesByTypeAtRange(editor) {
|
|
9
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10
|
-
Editor.withoutNormalizing(editor, function () {
|
|
11
|
-
var _options$split = options.split,
|
|
12
|
-
split = _options$split === void 0 ? false : _options$split,
|
|
13
|
-
_options$voids = options.voids,
|
|
14
|
-
voids = _options$voids === void 0 ? false : _options$voids,
|
|
15
|
-
_options$mode = options.mode,
|
|
16
|
-
mode = _options$mode === void 0 ? 'all' : _options$mode,
|
|
17
|
-
_options$at = options.at,
|
|
18
|
-
at = _options$at === void 0 ? editor.selection : _options$at;
|
|
19
|
-
var match = options.match;
|
|
20
|
-
if (!at) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
var matches = Editor.nodes(editor, {
|
|
24
|
-
at: at,
|
|
25
|
-
match: match,
|
|
26
|
-
mode: mode,
|
|
27
|
-
voids: voids
|
|
28
|
-
});
|
|
29
|
-
var node;
|
|
30
|
-
var _iterator = _createForOfIteratorHelper(matches),
|
|
31
|
-
_step;
|
|
32
|
-
try {
|
|
33
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
34
|
-
match = _step.value;
|
|
35
|
-
node = match;
|
|
36
|
-
}
|
|
37
|
-
} catch (err) {
|
|
38
|
-
_iterator.e(err);
|
|
39
|
-
} finally {
|
|
40
|
-
_iterator.f();
|
|
41
|
-
}
|
|
42
|
-
var pathRefs = Array.from([node], function (_ref) {
|
|
43
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
44
|
-
p = _ref2[1];
|
|
45
|
-
return Editor.pathRef(editor, p);
|
|
46
|
-
});
|
|
47
|
-
var _loop = function _loop() {
|
|
48
|
-
var pathRef = _pathRefs[_i];
|
|
49
|
-
var path = pathRef.unref();
|
|
50
|
-
var _Editor$node = Editor.node(editor, path),
|
|
51
|
-
_Editor$node2 = _slicedToArray(_Editor$node, 1),
|
|
52
|
-
node = _Editor$node2[0];
|
|
53
|
-
var range = Editor.range(editor, path);
|
|
54
|
-
if (split && Range.isRange(range)) {
|
|
55
|
-
range = Range.intersection(at, range);
|
|
56
|
-
}
|
|
57
|
-
Editor.liftNodes(editor, {
|
|
58
|
-
at: range,
|
|
59
|
-
match: function match(n) {
|
|
60
|
-
return node.children.includes(n);
|
|
61
|
-
},
|
|
62
|
-
voids: voids
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
for (var _i = 0, _pathRefs = pathRefs; _i < _pathRefs.length; _i++) {
|
|
66
|
-
_loop();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
export default unwrapNodesByTypeAtRange;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import { createEditor } from 'slate';
|
|
4
|
-
import { withHistory } from 'slate-history';
|
|
5
|
-
import { withReact } from '@seafile/slate-react';
|
|
6
|
-
import withInline from './controller/inline-element-controller';
|
|
7
|
-
import withBlock from './controller/block-element-controller';
|
|
8
|
-
import withVoid from './controller/void-element-controller';
|
|
9
|
-
import withMarkdownShortcut from './controller/shortcut-controller';
|
|
10
|
-
import normalizeNode from './controller/normalize-controller';
|
|
11
|
-
import { EditorUtils } from './editor-utils/common-editor-utils';
|
|
12
|
-
import TableUtils from './editor-utils/block-element-utils/table-utils';
|
|
13
|
-
var EditorContext = /*#__PURE__*/function () {
|
|
14
|
-
function EditorContext() {
|
|
15
|
-
_classCallCheck(this, EditorContext);
|
|
16
|
-
this.editor = null;
|
|
17
|
-
this.tableUtils = null;
|
|
18
|
-
this.editorUtils = null;
|
|
19
|
-
}
|
|
20
|
-
_createClass(EditorContext, null, [{
|
|
21
|
-
key: "getEditor",
|
|
22
|
-
value: function getEditor(options) {
|
|
23
|
-
if (this.editor && options) {
|
|
24
|
-
if (options && options.onSave) {
|
|
25
|
-
this.editor.onSave = options.onSave;
|
|
26
|
-
}
|
|
27
|
-
if (options && options.editorApi) {
|
|
28
|
-
this.editor.editorApi = options.editorApi;
|
|
29
|
-
}
|
|
30
|
-
if (options && options.columns) {
|
|
31
|
-
this.editor.columns = options.columns;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (this.editor) return this.editor;
|
|
35
|
-
this.editor = normalizeNode(withMarkdownShortcut(withVoid(withBlock(withInline(withHistory(withReact(createEditor())))))));
|
|
36
|
-
if (options && options.onSave) {
|
|
37
|
-
this.editor.onSave = options.onSave;
|
|
38
|
-
}
|
|
39
|
-
if (options && options.editorApi) {
|
|
40
|
-
this.editor.editorApi = options.editorApi;
|
|
41
|
-
}
|
|
42
|
-
if (options && options.columns) {
|
|
43
|
-
this.editor.columns = options.columns;
|
|
44
|
-
}
|
|
45
|
-
return this.editor;
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "resetEditor",
|
|
49
|
-
value: function resetEditor() {
|
|
50
|
-
this.editor = null;
|
|
51
|
-
this.editorUtils = null;
|
|
52
|
-
this.tableUtils = null;
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "getEditorRef",
|
|
56
|
-
value: function getEditorRef() {
|
|
57
|
-
var editorRef = window.abcdef_editor;
|
|
58
|
-
return editorRef;
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
key: "getToolbarRef",
|
|
62
|
-
value: function getToolbarRef() {
|
|
63
|
-
var toolbarRef = window.abcdef_editorToolbar;
|
|
64
|
-
return toolbarRef;
|
|
65
|
-
}
|
|
66
|
-
}, {
|
|
67
|
-
key: "getEditorUtils",
|
|
68
|
-
value: function getEditorUtils() {
|
|
69
|
-
if (this.editorUtils) return this.editorUtils;
|
|
70
|
-
if (!this.editor) this.getEditor();
|
|
71
|
-
this.editorUtils = new EditorUtils(this.editor);
|
|
72
|
-
return this.editorUtils;
|
|
73
|
-
}
|
|
74
|
-
}, {
|
|
75
|
-
key: "getTableUtils",
|
|
76
|
-
value: function getTableUtils() {
|
|
77
|
-
if (this.tableUtils) return this.tableUtils;
|
|
78
|
-
if (!this.editor) this.getEditor();
|
|
79
|
-
this.tableUtils = new TableUtils(this.editor);
|
|
80
|
-
return this.tableUtils;
|
|
81
|
-
}
|
|
82
|
-
}]);
|
|
83
|
-
return EditorContext;
|
|
84
|
-
}();
|
|
85
|
-
export default EditorContext;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import { Node } from 'slate';
|
|
4
|
-
import { SfEditor } from '../../custom/custom';
|
|
5
|
-
import getEventTransfer from '../../custom/get-event-transfer';
|
|
6
|
-
import generateBlockquote from '../../element-model/blockquote';
|
|
7
|
-
import { htmlDeserializer } from '../../../utils/deserialize-html';
|
|
8
|
-
import { normailizeSelection } from '../selection-utils';
|
|
9
|
-
var BlockquoteUtils = /*#__PURE__*/_createClass(function BlockquoteUtils(editor) {
|
|
10
|
-
var _this = this;
|
|
11
|
-
_classCallCheck(this, BlockquoteUtils);
|
|
12
|
-
this.getCurrentBlockquote = function () {
|
|
13
|
-
var block = SfEditor.match(_this.editor, _this.editor.selection.anchor, 'block');
|
|
14
|
-
var blockPath = block[1];
|
|
15
|
-
var parent = Node.parent(_this.editor, blockPath);
|
|
16
|
-
if (parent && parent.type === 'blockquote') {
|
|
17
|
-
return parent;
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
};
|
|
21
|
-
this.isInBlockquote = function () {
|
|
22
|
-
return Boolean(_this.getCurrentBlockquote());
|
|
23
|
-
};
|
|
24
|
-
this.wrapBlockquote = function () {
|
|
25
|
-
normailizeSelection(_this.editor);
|
|
26
|
-
var selection = _this.editor.selection;
|
|
27
|
-
var currentPath = SfEditor.path(_this.editor, selection);
|
|
28
|
-
var outestElementAtPath = _this.editor.children[currentPath[0]];
|
|
29
|
-
var blockquote = generateBlockquote({
|
|
30
|
-
children: [outestElementAtPath]
|
|
31
|
-
});
|
|
32
|
-
SfEditor.wrapNodes(_this.editor, blockquote);
|
|
33
|
-
};
|
|
34
|
-
this.unwrapBlockquote = function () {
|
|
35
|
-
normailizeSelection(_this.editor);
|
|
36
|
-
SfEditor.unwrapNodes(_this.editor, {
|
|
37
|
-
split: true,
|
|
38
|
-
match: {
|
|
39
|
-
type: 'blockquote'
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
this.pasteContentInBlockquote = function (command) {
|
|
44
|
-
var data = command.data;
|
|
45
|
-
var _getEventTransfer = getEventTransfer(data),
|
|
46
|
-
fragment = _getEventTransfer.fragment,
|
|
47
|
-
text = _getEventTransfer.text,
|
|
48
|
-
type = _getEventTransfer.type,
|
|
49
|
-
html = _getEventTransfer.html;
|
|
50
|
-
if (type === 'text') {
|
|
51
|
-
var textArray = text.split(/\r\n|\n/g);
|
|
52
|
-
textArray.forEach(function (text, index) {
|
|
53
|
-
if (index === 0) {
|
|
54
|
-
SfEditor.insertText(_this.editor, text);
|
|
55
|
-
} else {
|
|
56
|
-
SfEditor.insertNodes(_this.editor, {
|
|
57
|
-
type: 'paragraph',
|
|
58
|
-
children: [{
|
|
59
|
-
text: text
|
|
60
|
-
}]
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (type === 'html') {
|
|
67
|
-
fragment = htmlDeserializer(html);
|
|
68
|
-
}
|
|
69
|
-
var block = SfEditor.match(_this.editor, _this.editor.selection, 'block');
|
|
70
|
-
if (Node.text(block[0]).length === 0) {
|
|
71
|
-
SfEditor.removeNodes(_this.editor, {
|
|
72
|
-
match: 'block'
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
SfEditor.insertNodes(_this.editor, fragment);
|
|
76
|
-
return;
|
|
77
|
-
};
|
|
78
|
-
this.editor = editor;
|
|
79
|
-
});
|
|
80
|
-
export default BlockquoteUtils;
|