@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,412 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
-
import { Node, Editor } from 'slate';
|
|
6
|
-
import { SfEditor } from '../../custom/custom';
|
|
7
|
-
import { generateTable, generateTableRow, generateTableCell } from '../../element-model/table';
|
|
8
|
-
import getEventTransfer from '../../custom/get-event-transfer';
|
|
9
|
-
import { htmlDeserializer } from '../../../utils/deserialize-html';
|
|
10
|
-
var TableUtils = /*#__PURE__*/_createClass(function TableUtils(_editor) {
|
|
11
|
-
var _this = this;
|
|
12
|
-
_classCallCheck(this, TableUtils);
|
|
13
|
-
this.isInTable = function () {
|
|
14
|
-
var editor = _this.editor;
|
|
15
|
-
var selection = editor.selection;
|
|
16
|
-
if (!selection) return false;
|
|
17
|
-
var block = SfEditor.match(editor, editor.selection.anchor, 'block');
|
|
18
|
-
var parent = Node.parent(editor, block[1]);
|
|
19
|
-
var focusPath = selection.focus.path;
|
|
20
|
-
var anchorPath = selection.anchor.path;
|
|
21
|
-
if (parent && parent.type && parent.type.includes('table')) {
|
|
22
|
-
if (focusPath[0] === anchorPath[0]) return true;
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
};
|
|
26
|
-
this.focusNextTableCell = function () {
|
|
27
|
-
var position = _this.getTablePosition();
|
|
28
|
-
var rowIndex = position.rowIndex,
|
|
29
|
-
cellIndex = position.cellIndex,
|
|
30
|
-
row = position.row,
|
|
31
|
-
table = position.table;
|
|
32
|
-
var nextCellIndex, nextRowIndex;
|
|
33
|
-
if (cellIndex < row.children.length - 1) {
|
|
34
|
-
nextCellIndex = cellIndex + 1;
|
|
35
|
-
nextRowIndex = rowIndex;
|
|
36
|
-
} else {
|
|
37
|
-
if (rowIndex < table.children.length - 1) {
|
|
38
|
-
nextCellIndex = 0;
|
|
39
|
-
nextRowIndex = rowIndex + 1;
|
|
40
|
-
} else {
|
|
41
|
-
_this.insertRow();
|
|
42
|
-
nextCellIndex = 0;
|
|
43
|
-
nextRowIndex = rowIndex + 1;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
_this.selectCellByPosition(nextRowIndex, nextCellIndex);
|
|
47
|
-
};
|
|
48
|
-
this.focusPreviousTableCell = function () {
|
|
49
|
-
var position = _this.getTablePosition();
|
|
50
|
-
var rowIndex = position.rowIndex,
|
|
51
|
-
cellIndex = position.cellIndex,
|
|
52
|
-
row = position.row;
|
|
53
|
-
var nextCellIndex, nextRowIndex;
|
|
54
|
-
if (cellIndex > 0) {
|
|
55
|
-
nextCellIndex = cellIndex - 1;
|
|
56
|
-
nextRowIndex = rowIndex;
|
|
57
|
-
} else {
|
|
58
|
-
if (rowIndex > 0) {
|
|
59
|
-
nextRowIndex = rowIndex - 1;
|
|
60
|
-
nextCellIndex = row.children.length - 1;
|
|
61
|
-
} else {
|
|
62
|
-
nextCellIndex = 0;
|
|
63
|
-
nextRowIndex = 0;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
_this.selectCellByPosition(nextRowIndex, nextCellIndex);
|
|
67
|
-
};
|
|
68
|
-
this.selectCellByPosition = function (rowIndex, cellIndex) {
|
|
69
|
-
var _this$getTablePositio = _this.getTablePosition(),
|
|
70
|
-
tablePath = _this$getTablePositio.tablePath;
|
|
71
|
-
var cellRange = Editor.range(_this.editor, [].concat(_toConsumableArray(tablePath), [rowIndex, cellIndex]));
|
|
72
|
-
Editor.select(_this.editor, cellRange.focus);
|
|
73
|
-
};
|
|
74
|
-
this.insertTable = function (data) {
|
|
75
|
-
var tableElement = generateTable(data);
|
|
76
|
-
SfEditor.insertNodes(_this.editor, tableElement);
|
|
77
|
-
|
|
78
|
-
// get the first cell path of the table and move selection to it;
|
|
79
|
-
var table = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
80
|
-
type: 'table'
|
|
81
|
-
});
|
|
82
|
-
var tablePath = table[1];
|
|
83
|
-
var targetPath = [].concat(_toConsumableArray(tablePath), [0, 0]);
|
|
84
|
-
SfEditor.select(_this.editor, targetPath);
|
|
85
|
-
};
|
|
86
|
-
this.getSelectedTableCells = function () {
|
|
87
|
-
var node = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
88
|
-
type: 'table'
|
|
89
|
-
});
|
|
90
|
-
var tableNode = node[0];
|
|
91
|
-
var selectedCells = document.querySelectorAll('.selected-cell');
|
|
92
|
-
if (selectedCells.length === 0) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
var cellIndexs = [];
|
|
96
|
-
var rowIndexs = [];
|
|
97
|
-
selectedCells.forEach(function (cell, index) {
|
|
98
|
-
var cellIndex = cell.cellIndex;
|
|
99
|
-
var rowDom = cell.parentNode;
|
|
100
|
-
var rowIndex = rowDom.rowIndex;
|
|
101
|
-
cellIndexs.push(cellIndex);
|
|
102
|
-
rowIndexs.push(rowIndex);
|
|
103
|
-
});
|
|
104
|
-
var rowRange = {
|
|
105
|
-
min: Math.min.apply(null, rowIndexs),
|
|
106
|
-
max: Math.max.apply(null, rowIndexs)
|
|
107
|
-
};
|
|
108
|
-
var columnRange = {
|
|
109
|
-
min: Math.min.apply(null, cellIndexs),
|
|
110
|
-
max: Math.max.apply(null, cellIndexs)
|
|
111
|
-
};
|
|
112
|
-
var tableRows = tableNode.children;
|
|
113
|
-
var rowNodes = [];
|
|
114
|
-
tableRows.forEach(function (row, rowIndex) {
|
|
115
|
-
var cellNodes = [];
|
|
116
|
-
if (rowIndex >= rowRange.min && rowIndex <= rowRange.max) {
|
|
117
|
-
row.children.forEach(function (cell, cellIndex) {
|
|
118
|
-
if (cellIndex >= columnRange.min && cellIndex <= columnRange.max) {
|
|
119
|
-
cellNodes.push(Object.assign({}, {}, cell));
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
rowNodes.push(generateTableRow({
|
|
123
|
-
children: cellNodes
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return [generateTable({
|
|
128
|
-
children: rowNodes
|
|
129
|
-
})];
|
|
130
|
-
};
|
|
131
|
-
this.pasteContentInTable = function (command) {
|
|
132
|
-
var data = command.data;
|
|
133
|
-
var _getEventTransfer = getEventTransfer(data),
|
|
134
|
-
fragment = _getEventTransfer.fragment,
|
|
135
|
-
text = _getEventTransfer.text,
|
|
136
|
-
type = _getEventTransfer.type,
|
|
137
|
-
html = _getEventTransfer.html;
|
|
138
|
-
var newtext = text.replace(/\r\n|\n/g, ' ');
|
|
139
|
-
if (!fragment && type === 'text') {
|
|
140
|
-
SfEditor.insertText(_this.editor, newtext);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (type === 'html') {
|
|
144
|
-
fragment = htmlDeserializer(html);
|
|
145
|
-
}
|
|
146
|
-
if (fragment.length === 1) {
|
|
147
|
-
if (fragment[0].type === 'table') {
|
|
148
|
-
var tableNode = fragment[0];
|
|
149
|
-
var _SfEditor$match = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
150
|
-
type: 'table_row'
|
|
151
|
-
}),
|
|
152
|
-
_SfEditor$match2 = _slicedToArray(_SfEditor$match, 2),
|
|
153
|
-
row = _SfEditor$match2[0],
|
|
154
|
-
rowPath = _SfEditor$match2[1];
|
|
155
|
-
var _SfEditor$match3 = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
156
|
-
type: 'table'
|
|
157
|
-
}),
|
|
158
|
-
_SfEditor$match4 = _slicedToArray(_SfEditor$match3, 2),
|
|
159
|
-
table = _SfEditor$match4[0],
|
|
160
|
-
tablePath = _SfEditor$match4[1];
|
|
161
|
-
var cellPath = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
162
|
-
type: 'table_cell'
|
|
163
|
-
})[1];
|
|
164
|
-
var currentRowIndex = rowPath[rowPath.length - 1];
|
|
165
|
-
var currentCellIndex = cellPath[cellPath.length - 1];
|
|
166
|
-
var tableWidth = row.children.length;
|
|
167
|
-
var tableHeight = table.children.length;
|
|
168
|
-
tableNode.children.some(function (row, rowIndex) {
|
|
169
|
-
var rowPath = [].concat(_toConsumableArray(tablePath), [currentRowIndex + rowIndex]);
|
|
170
|
-
if (currentRowIndex + rowIndex > tableHeight - 1) {
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
row.children.some(function (cell, cellIndex) {
|
|
174
|
-
if (currentCellIndex + cellIndex > tableWidth - 1) {
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
var currentCellPath = [].concat(_toConsumableArray(rowPath), [currentCellIndex + cellIndex]);
|
|
178
|
-
SfEditor.removeNodes(_this.editor, {
|
|
179
|
-
at: [].concat(_toConsumableArray(currentCellPath), [0])
|
|
180
|
-
});
|
|
181
|
-
if (cell.children.type !== 'paragraph') {
|
|
182
|
-
var _text = Node.text(cell);
|
|
183
|
-
SfEditor.insertNodes(_this.editor, {
|
|
184
|
-
type: 'paragraph',
|
|
185
|
-
children: [{
|
|
186
|
-
text: _text
|
|
187
|
-
}]
|
|
188
|
-
}, {
|
|
189
|
-
at: [].concat(_toConsumableArray(currentCellPath), [0])
|
|
190
|
-
});
|
|
191
|
-
} else {
|
|
192
|
-
SfEditor.insertNodes(_this.editor, cell.children, {
|
|
193
|
-
at: [].concat(_toConsumableArray(currentCellPath), [0])
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
return false;
|
|
197
|
-
});
|
|
198
|
-
return false;
|
|
199
|
-
});
|
|
200
|
-
} else if (fragment[0].type === 'paragraph') {
|
|
201
|
-
SfEditor.insertFragment(_this.editor, fragment);
|
|
202
|
-
} else {
|
|
203
|
-
SfEditor.insertText(_this.editor, text.replace(/\r\n|\n/g, ' '));
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
fragment.forEach(function (node) {
|
|
207
|
-
if (node.type === 'paragraph') {
|
|
208
|
-
SfEditor.insertFragment(_this.editor, [node]);
|
|
209
|
-
// if the element is node a paragraph, insert the text if the node is not 0
|
|
210
|
-
} else {
|
|
211
|
-
var nodeText = Node.text(node);
|
|
212
|
-
if (nodeText.length > 0) {
|
|
213
|
-
SfEditor.insertText(_this.editor, nodeText.replace(/\r\n|\n/g, ' '));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
this.removeTable = function () {
|
|
220
|
-
var tableNode = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
221
|
-
type: 'table'
|
|
222
|
-
});
|
|
223
|
-
var tablePath = tableNode[1];
|
|
224
|
-
var tableIndex = tablePath[tablePath.length - 1];
|
|
225
|
-
var tableParentPath = tablePath.slice(0, tablePath.length - 1);
|
|
226
|
-
var targetNodeIndex = tableIndex >= 1 ? tableIndex - 1 : 1;
|
|
227
|
-
var targteNodePath = [].concat(_toConsumableArray(tableParentPath), [targetNodeIndex]);
|
|
228
|
-
SfEditor.removeNodes(_this.editor, {
|
|
229
|
-
match: {
|
|
230
|
-
type: 'table'
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
// move selection to previous sibling or next sibling and collapse the selection
|
|
235
|
-
SfEditor.select(_this.editor, targteNodePath);
|
|
236
|
-
SfEditor.collapse(_this.editor, {
|
|
237
|
-
edge: 'end'
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
this.getTablePosition = function () {
|
|
241
|
-
var currentCell = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
242
|
-
type: 'table_cell'
|
|
243
|
-
});
|
|
244
|
-
var currentCellPath = currentCell[1];
|
|
245
|
-
var currentTable = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
246
|
-
type: 'table'
|
|
247
|
-
});
|
|
248
|
-
var tablePath = currentTable[1];
|
|
249
|
-
var rowPath = currentCellPath.slice(0, currentCellPath.length - 1);
|
|
250
|
-
var row = Node.get(_this.editor, rowPath);
|
|
251
|
-
var cell = currentCell[0];
|
|
252
|
-
var table = Node.get(_this.editor, tablePath);
|
|
253
|
-
return {
|
|
254
|
-
rowIndex: currentCellPath[currentCellPath.length - 2],
|
|
255
|
-
cellIndex: currentCellPath[currentCellPath.length - 1],
|
|
256
|
-
cellPath: currentCellPath,
|
|
257
|
-
rowPath: rowPath,
|
|
258
|
-
tablePath: tablePath,
|
|
259
|
-
row: row,
|
|
260
|
-
cell: cell,
|
|
261
|
-
table: table
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
this.insertRow = function () {
|
|
265
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'after';
|
|
266
|
-
var position = _this.getTablePosition();
|
|
267
|
-
var tablePath = position.tablePath;
|
|
268
|
-
var rowIndex = position.rowIndex;
|
|
269
|
-
var targetPath;
|
|
270
|
-
if (type === 'after') {
|
|
271
|
-
targetPath = [].concat(_toConsumableArray(tablePath), [rowIndex + 1]);
|
|
272
|
-
}
|
|
273
|
-
if (type === 'before') {
|
|
274
|
-
targetPath = [].concat(_toConsumableArray(tablePath), [rowIndex]);
|
|
275
|
-
}
|
|
276
|
-
var rowChildren = position.row.children.map(function (cell) {
|
|
277
|
-
return generateTableCell({
|
|
278
|
-
data: {
|
|
279
|
-
align: cell.data.align
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
SfEditor.insertNodes(_this.editor, generateTableRow({
|
|
284
|
-
children: rowChildren
|
|
285
|
-
}), {
|
|
286
|
-
at: targetPath
|
|
287
|
-
});
|
|
288
|
-
var focusPath = [].concat(_toConsumableArray(targetPath), [0]);
|
|
289
|
-
SfEditor.select(_this.editor, focusPath);
|
|
290
|
-
SfEditor.collapse(_this.editor, {
|
|
291
|
-
edge: 'end'
|
|
292
|
-
});
|
|
293
|
-
};
|
|
294
|
-
this.removeRow = function () {
|
|
295
|
-
var position = _this.getTablePosition();
|
|
296
|
-
var rowPath = position.rowPath,
|
|
297
|
-
table = position.table,
|
|
298
|
-
rowIndex = position.rowIndex,
|
|
299
|
-
tablePath = position.tablePath;
|
|
300
|
-
var targetPath;
|
|
301
|
-
if (table.children.length > 1) {
|
|
302
|
-
if (rowIndex === table.children.length - 1) {
|
|
303
|
-
targetPath = [].concat(_toConsumableArray(tablePath), [rowIndex - 1, 0, 0]);
|
|
304
|
-
} else {
|
|
305
|
-
targetPath = [].concat(_toConsumableArray(tablePath), [rowIndex, 0, 0]);
|
|
306
|
-
}
|
|
307
|
-
SfEditor.removeNodes(_this.editor, {
|
|
308
|
-
at: rowPath
|
|
309
|
-
});
|
|
310
|
-
SfEditor.select(_this.editor, targetPath);
|
|
311
|
-
SfEditor.collapse({
|
|
312
|
-
at: 'end'
|
|
313
|
-
});
|
|
314
|
-
} else {
|
|
315
|
-
_this.removeTable();
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
this.insertColumn = function () {
|
|
319
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'after';
|
|
320
|
-
var position = _this.getTablePosition();
|
|
321
|
-
var focusPath;
|
|
322
|
-
var table = position.table,
|
|
323
|
-
tablePath = position.tablePath,
|
|
324
|
-
cellIndex = position.cellIndex;
|
|
325
|
-
if (type === 'after') {
|
|
326
|
-
for (var index = 0; index < table.children.length; index++) {
|
|
327
|
-
var newCellPath = [].concat(_toConsumableArray(tablePath), [index, cellIndex + 1]);
|
|
328
|
-
SfEditor.insertNodes(_this.editor, generateTableCell({
|
|
329
|
-
data: {
|
|
330
|
-
align: 'left'
|
|
331
|
-
}
|
|
332
|
-
}), {
|
|
333
|
-
at: newCellPath
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
focusPath = [].concat(_toConsumableArray(tablePath), [0, cellIndex + 1]);
|
|
337
|
-
} else {
|
|
338
|
-
for (var _index = 0; _index < table.children.length; _index++) {
|
|
339
|
-
var _newCellPath = [].concat(_toConsumableArray(tablePath), [_index, cellIndex]);
|
|
340
|
-
SfEditor.insertNodes(_this.editor, generateTableCell({
|
|
341
|
-
data: {
|
|
342
|
-
align: 'left'
|
|
343
|
-
}
|
|
344
|
-
}), {
|
|
345
|
-
at: _newCellPath
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
focusPath = [].concat(_toConsumableArray(tablePath), [0, cellIndex]);
|
|
349
|
-
}
|
|
350
|
-
SfEditor.select(_this.editor, focusPath);
|
|
351
|
-
SfEditor.collapse(_this.editor, {
|
|
352
|
-
edge: 'end'
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
|
-
this.removeColumn = function () {
|
|
356
|
-
var position = _this.getTablePosition();
|
|
357
|
-
var table = position.table,
|
|
358
|
-
tablePath = position.tablePath,
|
|
359
|
-
cellIndex = position.cellIndex,
|
|
360
|
-
row = position.row;
|
|
361
|
-
if (row.children.length === 1) {
|
|
362
|
-
_this.removeTable();
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
for (var index = 0; index < table.children.length; index++) {
|
|
366
|
-
var cellPath = [].concat(_toConsumableArray(tablePath), [index, cellIndex]);
|
|
367
|
-
SfEditor.removeNodes(_this.editor, {
|
|
368
|
-
at: cellPath
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
return;
|
|
372
|
-
};
|
|
373
|
-
this.setAlign = function (align) {
|
|
374
|
-
var position = _this.getTablePosition();
|
|
375
|
-
var table = position.table,
|
|
376
|
-
tablePath = position.tablePath,
|
|
377
|
-
cellIndex = position.cellIndex;
|
|
378
|
-
for (var index = 0; index < table.children.length; index++) {
|
|
379
|
-
var cellPath = [].concat(_toConsumableArray(tablePath), [index, cellIndex]);
|
|
380
|
-
SfEditor.setNodes(_this.editor, {
|
|
381
|
-
data: {
|
|
382
|
-
align: align
|
|
383
|
-
}
|
|
384
|
-
}, {
|
|
385
|
-
at: cellPath
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
this.exitTable = function () {
|
|
390
|
-
var tableNode = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
391
|
-
type: 'table'
|
|
392
|
-
});
|
|
393
|
-
var tablePath = tableNode[1];
|
|
394
|
-
var tableIndex = tablePath[tablePath.length - 1];
|
|
395
|
-
var tableParentPath = tablePath.slice(0, tablePath.length - 1);
|
|
396
|
-
var newPath = [].concat(_toConsumableArray(tableParentPath), [tableIndex + 1]);
|
|
397
|
-
SfEditor.insertNodes(_this.editor, {
|
|
398
|
-
type: 'paragraph',
|
|
399
|
-
children: [{
|
|
400
|
-
text: ''
|
|
401
|
-
}]
|
|
402
|
-
}, {
|
|
403
|
-
at: newPath
|
|
404
|
-
});
|
|
405
|
-
SfEditor.select(_this.editor, newPath);
|
|
406
|
-
SfEditor.collapse({
|
|
407
|
-
at: 'end'
|
|
408
|
-
});
|
|
409
|
-
};
|
|
410
|
-
this.editor = _editor;
|
|
411
|
-
});
|
|
412
|
-
export default TableUtils;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Editor, Path, Node } from 'slate';
|
|
2
|
-
var removeEmptyParentNode = function removeEmptyParentNode(editor, pathRef) {
|
|
3
|
-
var path = pathRef.current;
|
|
4
|
-
var currentNode = Node.get(editor, path);
|
|
5
|
-
var children = currentNode.children;
|
|
6
|
-
while ((children.length === 0 || children.length === 1 && children[0].text === '') && currentNode.type) {
|
|
7
|
-
Editor.removeNodes(editor, {
|
|
8
|
-
at: path
|
|
9
|
-
});
|
|
10
|
-
path = Path.parent(path);
|
|
11
|
-
currentNode = Node.get(editor, path);
|
|
12
|
-
children = currentNode.children;
|
|
13
|
-
}
|
|
14
|
-
pathRef.unref();
|
|
15
|
-
};
|
|
16
|
-
var clearBlockFormat = function clearBlockFormat(editor) {
|
|
17
|
-
// get selected block node, like the paragraphs in the blockquote;
|
|
18
|
-
var nodes = Editor.nodes(editor, {
|
|
19
|
-
match: 'block',
|
|
20
|
-
voids: false
|
|
21
|
-
});
|
|
22
|
-
var nodesList = [];
|
|
23
|
-
var pathRefs = Array.from(nodes, function (item) {
|
|
24
|
-
nodesList.push(item);
|
|
25
|
-
return Editor.pathRef(editor, item[1]);
|
|
26
|
-
});
|
|
27
|
-
var firstNode = nodesList[0],
|
|
28
|
-
firstNodeRef = pathRefs[0];
|
|
29
|
-
nodesList.shift();
|
|
30
|
-
pathRefs.shift();
|
|
31
|
-
// move first block to outest and set the block to paragraph
|
|
32
|
-
while (firstNodeRef.current.length > 1) {
|
|
33
|
-
Editor.liftNodes(editor, {
|
|
34
|
-
at: firstNodeRef.current
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
if (firstNode[0].type !== 'paragraph') {
|
|
38
|
-
Editor.setNodes(editor, {
|
|
39
|
-
type: 'paragraph',
|
|
40
|
-
at: firstNodeRef.current,
|
|
41
|
-
split: true
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
nodesList.forEach(function (item, index) {
|
|
45
|
-
var toPath = index === 0 ? Path.next(firstNodeRef.current) : Path.next(pathRefs[index - 1].current);
|
|
46
|
-
var currentPath = pathRefs[index].current;
|
|
47
|
-
if (currentPath.length > 1) {
|
|
48
|
-
var parentPath = Path.parent(currentPath);
|
|
49
|
-
var parentRef = Editor.pathRef(editor, parentPath);
|
|
50
|
-
// move current node to outest
|
|
51
|
-
Editor.moveNodes(editor, {
|
|
52
|
-
at: currentPath,
|
|
53
|
-
to: toPath
|
|
54
|
-
});
|
|
55
|
-
// remove empty parent node
|
|
56
|
-
removeEmptyParentNode(editor, parentRef);
|
|
57
|
-
}
|
|
58
|
-
// set current block node to paragraph
|
|
59
|
-
if (item[0].type !== 'paragraph') {
|
|
60
|
-
Editor.setNodes(editor, {
|
|
61
|
-
type: 'paragraph',
|
|
62
|
-
at: currentPath,
|
|
63
|
-
split: true
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
firstNodeRef.unref();
|
|
68
|
-
pathRefs.forEach(function (ref) {
|
|
69
|
-
return ref.unref();
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
var clearMarkerFormat = function clearMarkerFormat(editor) {
|
|
73
|
-
// clear all markers of selected texts;
|
|
74
|
-
var textProperties = {
|
|
75
|
-
BOLD: false,
|
|
76
|
-
ITALIC: false,
|
|
77
|
-
CODE: false
|
|
78
|
-
};
|
|
79
|
-
editor.exec({
|
|
80
|
-
type: 'format_text',
|
|
81
|
-
properties: textProperties
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
export { clearBlockFormat, clearMarkerFormat };
|