@titaui/pc 1.10.4 → 1.10.6-3.beta-2
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/.eslintrc.js +2 -2
- package/.prettierignore +1 -1
- package/lib/components/book-demo/utils.js +4 -0
- package/lib/components/button/default-button/index.css +10 -4
- package/lib/components/button/default-button/index.js +13 -2
- package/lib/components/change-okr-modal/index.js +108 -87
- package/lib/components/checkbox/index.css +1 -0
- package/lib/components/communication/CommunicationRecord.js +22 -16
- package/lib/components/communication/index.css +50 -10
- package/lib/components/communication/index.js +86 -30
- package/lib/components/communication/style.js +8 -6
- package/lib/components/create-okr-modal/fields/o-new-name.js +31 -21
- package/lib/components/create-okr-modal/fields/okr-parent.js +1 -5
- package/lib/components/create-okr-modal/kr-items/krDatas.js +16 -16
- package/lib/components/{dynamic/components/dangerous-html → dangerous-html}/index.js +0 -0
- package/lib/components/dialog/index.css +4 -1
- package/lib/components/dialog/index.js +1 -1
- package/lib/components/dialog-confirm/index.css +1 -1
- package/lib/components/drawer-manager/index.js +6 -1
- package/lib/components/dynamic/components/first-level-tabs/index.css +12 -2
- package/lib/components/dynamic/components/first-level-tabs/index.js +19 -6
- package/lib/components/dynamic/components/obj-status/index.css +3 -19
- package/lib/components/dynamic/components/obj-status/index.js +7 -8
- package/lib/components/dynamic/components/obj-status/utils.js +37 -0
- package/lib/components/dynamic/components/percent/index.css +1 -1
- package/lib/components/dynamic/components/title/index.css +21 -22
- package/lib/components/dynamic/components/title/index.js +20 -8
- package/lib/components/dynamic/constant.js +12 -2
- package/lib/components/dynamic/dynamic-item/components/feed-operate/index.css +71 -0
- package/lib/components/dynamic/dynamic-item/components/feed-operate/index.js +112 -0
- package/lib/components/dynamic/dynamic-item/components/header/index.css +8 -7
- package/lib/components/dynamic/dynamic-item/components/header/index.js +13 -7
- package/lib/components/dynamic/dynamic-item/dynamic-align/img/dynamic-align-kr.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-align/img/dynamic-align-o.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-align/img/dynamic-align.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-align/index.css +44 -27
- package/lib/components/dynamic/dynamic-item/dynamic-align/index.js +43 -31
- package/lib/components/dynamic/dynamic-item/dynamic-announcement/index.css +5 -33
- package/lib/components/dynamic/dynamic-item/dynamic-announcement/index.js +6 -32
- package/lib/components/dynamic/dynamic-item/dynamic-assessment/index.css +58 -18
- package/lib/components/dynamic/dynamic-item/dynamic-assessment/index.js +31 -21
- package/lib/components/dynamic/dynamic-item/dynamic-chart/index.css +4 -0
- package/lib/components/dynamic/dynamic-item/dynamic-chart/index.js +102 -0
- package/lib/components/dynamic/dynamic-item/dynamic-chart/utils.js +61 -0
- package/lib/components/dynamic/dynamic-item/dynamic-create-o/index.css +56 -44
- package/lib/components/dynamic/dynamic-item/dynamic-create-o/index.js +52 -44
- package/lib/components/dynamic/dynamic-item/dynamic-kr/index.css +39 -27
- package/lib/components/dynamic/dynamic-item/dynamic-kr/index.js +25 -29
- package/lib/components/dynamic/dynamic-item/dynamic-learning/img/dynamic-share-course.png +0 -0
- package/lib/components/dynamic/dynamic-item/{dynamic-share-to-dynamic → dynamic-learning}/img/jiantou-right@3x.png +0 -0
- package/lib/components/dynamic/dynamic-item/{dynamic-share-to-dynamic → dynamic-learning}/img/user-photo.png +0 -0
- package/lib/components/dynamic/dynamic-item/{dynamic-share-to-dynamic → dynamic-learning}/index.css +10 -18
- package/lib/components/dynamic/dynamic-item/{dynamic-share-to-dynamic → dynamic-learning}/index.js +15 -30
- package/lib/components/dynamic/dynamic-item/dynamic-milestone/constant.js +9 -2
- package/lib/components/dynamic/dynamic-item/dynamic-milestone/index.css +31 -14
- package/lib/components/dynamic/dynamic-item/dynamic-milestone/index.js +14 -25
- package/lib/components/dynamic/dynamic-item/dynamic-okrs-communication/index.css +25 -40
- package/lib/components/dynamic/dynamic-item/dynamic-okrs-communication/index.js +10 -29
- package/lib/components/dynamic/dynamic-item/dynamic-plan-communication/index.css +25 -40
- package/lib/components/dynamic/dynamic-item/dynamic-plan-communication/index.js +13 -30
- package/lib/components/dynamic/dynamic-item/dynamic-progress/index.css +13 -55
- package/lib/components/dynamic/dynamic-item/dynamic-progress/index.js +33 -80
- package/lib/components/dynamic/dynamic-item/dynamic-progress/utils.js +72 -0
- package/lib/components/dynamic/dynamic-item/dynamic-project/index.css +35 -28
- package/lib/components/dynamic/dynamic-item/dynamic-project/index.js +13 -24
- package/lib/components/dynamic/dynamic-item/dynamic-relative/img/dynamic-rela-kr.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-relative/img/dynamic-rela-o.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-relative/img/dynamic-rela-project.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-relative/img/dynamic-rela-task.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-relative/img/dynamic-rela.svg +23 -0
- package/lib/components/dynamic/dynamic-item/dynamic-relative/index.css +56 -31
- package/lib/components/dynamic/dynamic-item/dynamic-relative/index.js +78 -34
- package/lib/components/dynamic/dynamic-item/{dynamic-replay → dynamic-reply}/index.css +29 -32
- package/lib/components/dynamic/dynamic-item/{dynamic-replay → dynamic-reply}/index.js +12 -18
- package/lib/components/dynamic/dynamic-item/dynamic-report/index.css +20 -22
- package/lib/components/dynamic/dynamic-item/dynamic-report/index.js +42 -29
- package/lib/components/dynamic/dynamic-item/dynamic-reward/img/reward.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-reward/index.css +8 -3
- package/lib/components/dynamic/dynamic-item/dynamic-reward/index.js +23 -66
- package/lib/components/dynamic/dynamic-item/dynamic-reward/utils.js +28 -0
- package/lib/components/dynamic/dynamic-item/dynamic-share/index.css +8 -19
- package/lib/components/dynamic/dynamic-item/dynamic-share/index.js +59 -36
- package/lib/components/dynamic/dynamic-item/dynamic-task/index.css +32 -28
- package/lib/components/dynamic/dynamic-item/dynamic-task/index.js +11 -25
- package/lib/components/dynamic/dynamic-item/index.css +59 -4
- package/lib/components/dynamic/dynamic-item/index.js +148 -17
- package/lib/components/dynamic/dynamic-like-ranking/item.js +1 -1
- package/lib/components/dynamic/dynamic-list/index.js +2 -1
- package/lib/components/dynamic/dynamic-topping/item.js +8 -4
- package/lib/components/dynamic/dynamic.js +1 -1
- package/lib/components/dynamic/img/dynamic-operate.png +0 -0
- package/lib/components/dynamic/img/dynamic-point.svg +13 -0
- package/lib/components/dynamic/img/dynamic-reward-hover.svg +1 -0
- package/lib/components/dynamic/img/dynamic-reward-normal.svg +1 -0
- package/lib/components/dynamic/util.js +41 -81
- package/lib/components/e-status-dropdown/index.css +3 -0
- package/lib/components/e-status-dropdown/index.js +94 -0
- package/lib/components/file-list/components/single-file/index.css +14 -12
- package/lib/components/file-list/components/single-file/index.js +1 -1
- package/lib/components/file-list/index.css +1 -0
- package/lib/components/follower-visitor/index.js +6 -4
- package/lib/components/grid-layout/okr-progress/index.js +20 -30
- package/lib/components/help-card/image/not-try.png +0 -0
- package/lib/components/help-card/image/try.png +0 -0
- package/lib/components/help-card/index.css +31 -2
- package/lib/components/help-card/index.js +54 -17
- package/lib/components/invite-people/img/invite-people.svg +62 -0
- package/lib/components/invite-people/index.css +1 -1
- package/lib/components/mblog/context.js +3 -1
- package/lib/components/mblog/index.css +7 -0
- package/lib/components/mblog/index.js +45 -9
- package/lib/components/mblog/style.js +4 -4
- package/lib/components/menus/export-modules/demo-menus/index.js +2 -2
- package/lib/components/menus/export-modules/demo-menus/menu-highlight.js +25 -1
- package/lib/components/menus/export-modules/demo-menus/menus.js +60 -11
- package/lib/components/menus/export-modules/manage-menus/constant.js +1 -1
- package/lib/components/menus/export-modules/manage-menus/index.css +3 -0
- package/lib/components/menus/images/okr-gongsi.svg +17 -0
- package/lib/components/nav-top/components/menu/index.css +24 -0
- package/lib/components/nav-top/components/menu/index.js +9 -1
- package/lib/components/nav-top/components/user-message/components/reply/index.js +9 -8
- package/lib/components/nav-top/components/user-message/components/reply/reply-item.js +15 -5
- package/lib/components/nav-top/components/user-message/index.css +4 -3
- package/lib/components/nav-top/components/user-message/index.js +33 -6
- package/lib/components/nav-top/request.apis.js +8 -2
- package/lib/components/nav-top/useGlobalValue.js +14 -0
- package/lib/components/okr-detail/components/header/o-score.js +4 -6
- package/lib/components/okr-detail/components/okr-tree/tree-node/e-kr-node/index.css +1 -1
- package/lib/components/okr-detail/components/okr-tree/tree-node/e-kr-node/index.js +27 -13
- package/lib/components/okr-detail/components/okr-tree/tree-node/e-node/e-empty.js +7 -4
- package/lib/components/okr-detail/components/okr-tree/tree-node/e-node/e-project.js +8 -1
- package/lib/components/okr-detail/components/okr-tree/tree-node/e-node/e-task.js +7 -3
- package/lib/components/okr-detail/components/okr-tree/tree-node/e-node/index.css +20 -1
- package/lib/components/okr-detail/e-list/index.js +23 -7
- package/lib/components/okr-detail/e-list/util.js +7 -2
- package/lib/components/okr-detail/index.js +2 -0
- package/lib/components/okr-detail/okr-list/index.js +1 -5
- package/lib/components/okr-flow/export-modal/index.js +3 -3
- package/lib/components/okr-progress-detail/index.js +5 -1
- package/lib/components/okr-progress-modal/helper.js +20 -27
- package/lib/components/okr-share/common-painter/openDataPainter.js +34 -27
- package/lib/components/okrcase-library/okrcases-components/submitOkr-dialog.js +40 -36
- package/lib/components/open-data-painter/index.js +5 -1
- package/lib/components/progress/circle-progress/index.css +1 -0
- package/lib/components/progress/circle-progress/index.js +8 -3
- package/lib/components/rich-editor/basic/schema.js +47 -0
- package/lib/components/rich-editor/consts/events.js +12 -0
- package/lib/components/rich-editor/enums.js +42 -0
- package/lib/components/rich-editor/index.js +58 -0
- package/lib/components/rich-editor/keymap.js +119 -0
- package/lib/components/rich-editor/keymaps/index.js +241 -0
- package/lib/components/rich-editor/models/controller.js +18 -0
- package/lib/components/rich-editor/models/editor.js +47 -0
- package/lib/components/rich-editor/models/plugin.js +20 -0
- package/lib/components/rich-editor/models/schema.js +121 -0
- package/lib/components/rich-editor/plugins/block/block-quote/commond.js +27 -0
- package/lib/components/rich-editor/plugins/block/block-quote/index.js +128 -0
- package/lib/components/rich-editor/plugins/block/heading/commonds.js +31 -0
- package/lib/components/rich-editor/plugins/block/heading/index.js +190 -0
- package/lib/components/rich-editor/plugins/block/index.js +57 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/conversions.js +172 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/indent-list-items-selected.js +163 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/indent-list.js +59 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-forward.js +74 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/index.js +45 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +104 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +92 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +89 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-paragraph-with-list.js +48 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-sibling-list-items.js +61 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/merge-lists.js +34 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/outdent-list-items-selected.js +289 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/wrap-and-join-lists.js +180 -0
- package/lib/components/rich-editor/plugins/block/lists/baseCommand.js +328 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/indent-list.js +60 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/index.js +396 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/join-list-item-forward.js +45 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/listBackspace.js +302 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/outdent-list.js +43 -0
- package/lib/components/rich-editor/plugins/block/lists/index.js +224 -0
- package/lib/components/rich-editor/plugins/block/lists/messages.js +38 -0
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/input-rule.js +152 -0
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/keymap.js +33 -0
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/main.js +94 -0
- package/lib/components/rich-editor/plugins/block/lists/styles.js +15 -0
- package/lib/components/rich-editor/plugins/block/lists/transforms.js +347 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/analytics.js +48 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/find.js +126 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/indentation.js +87 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/node.js +144 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/replace-content.js +31 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/selection.js +201 -0
- package/lib/components/rich-editor/plugins/block/lists/utils.js +52 -0
- package/lib/components/rich-editor/plugins/block/paragraph/index.js +91 -0
- package/lib/components/rich-editor/plugins/core/index.js +90 -0
- package/lib/components/rich-editor/plugins/core/pm-plugins/focus-handler.js +67 -0
- package/lib/components/rich-editor/plugins/core/pm-plugins/keymap.js +29 -0
- package/lib/components/rich-editor/plugins/core/pm-plugins/reactNodeView.js +80 -0
- package/lib/components/rich-editor/plugins/extension/alignment/commond.js +24 -0
- package/lib/components/rich-editor/plugins/extension/alignment/index.js +113 -0
- package/lib/components/rich-editor/plugins/extension/alignment/utils.js +19 -0
- package/lib/components/rich-editor/plugins/extension/index.js +18 -0
- package/lib/components/rich-editor/plugins/extension/placeholder/index.js +126 -0
- package/lib/components/rich-editor/plugins/extension/placeholder/styles.js +19 -0
- package/lib/components/rich-editor/plugins/index.js +44 -0
- package/lib/components/rich-editor/plugins/inline/color/commond.js +128 -0
- package/lib/components/rich-editor/plugins/inline/color/consts.js +43 -0
- package/lib/components/rich-editor/plugins/inline/color/index.css +61 -0
- package/lib/components/rich-editor/plugins/inline/color/index.js +217 -0
- package/lib/components/rich-editor/plugins/inline/color/selector.js +252 -0
- package/lib/components/rich-editor/plugins/inline/color/util.js +25 -0
- package/lib/components/rich-editor/plugins/inline/delete-line/index.js +149 -0
- package/lib/components/rich-editor/plugins/inline/em/index.js +93 -0
- package/lib/components/rich-editor/plugins/inline/index.js +83 -0
- package/lib/components/rich-editor/plugins/inline/link/commands.js +256 -0
- package/lib/components/rich-editor/plugins/inline/link/index.js +149 -0
- package/lib/components/rich-editor/plugins/inline/link/pm-plugins/fake-cursor-for-toolbar.js +77 -0
- package/lib/components/rich-editor/plugins/inline/link/pm-plugins/main.js +293 -0
- package/lib/components/rich-editor/plugins/inline/link/ui/index.css +84 -0
- package/lib/components/rich-editor/plugins/inline/link/ui/linkEditor.js +150 -0
- package/lib/components/rich-editor/plugins/inline/link/ui/linkToolbar.js +101 -0
- package/lib/components/rich-editor/plugins/inline/link/ui/toolbarBtn.js +117 -0
- package/lib/components/rich-editor/plugins/inline/link/utils.js +33 -0
- package/lib/components/rich-editor/plugins/inline/strong/index.js +139 -0
- package/lib/components/rich-editor/plugins/inline/under-line/index.js +147 -0
- package/lib/components/rich-editor/plugins/util.js +284 -0
- package/lib/components/rich-editor/react/reactNodeView.js +383 -0
- package/lib/components/rich-editor/react/uiProvider.js +185 -0
- package/lib/components/rich-editor/schemas/basic.js +309 -0
- package/lib/components/rich-editor/schemas/index.js +19 -0
- package/lib/components/rich-editor/schemas/list.js +342 -0
- package/lib/components/rich-editor/types/commond.js +5 -0
- package/lib/components/rich-editor/types/index.js +18 -0
- package/lib/components/rich-editor/ui/Popup/index.js +247 -0
- package/lib/components/rich-editor/ui/Popup/utils.js +399 -0
- package/lib/components/rich-editor/ui/editor/index.css +178 -0
- package/lib/components/rich-editor/ui/editor/index.js +153 -0
- package/lib/components/rich-editor/ui/normal-toolbar/index.css +34 -0
- package/lib/components/rich-editor/ui/normal-toolbar/index.js +109 -0
- package/lib/components/rich-editor/utils/browser.js +35 -0
- package/lib/components/rich-editor/utils/commands.js +266 -0
- package/lib/components/rich-editor/utils/document.js +211 -0
- package/lib/components/rich-editor/utils/event.js +79 -0
- package/lib/components/rich-editor/utils/helpers.js +16 -0
- package/lib/components/rich-editor/utils/mark.js +168 -0
- package/lib/components/rich-editor/utils/slice.js +85 -0
- package/lib/components/rich-editor/utils/toolbar.js +228 -0
- package/lib/components/search-key-handle/index.js +7 -2
- package/lib/components/superset-charts/components/chart/index.js +54 -0
- package/lib/components/superset-charts/fetch-assets-and-append/append-assets.js +106 -0
- package/lib/components/superset-charts/fetch-assets-and-append/get-assets-with-cache.js +131 -0
- package/lib/components/superset-charts/fetch-assets-and-append/index.js +79 -0
- package/lib/components/superset-charts/index.js +13 -0
- package/lib/components/superset-charts/interface.js +5 -0
- package/lib/components/superset-charts/utils/axios.js +94 -0
- package/lib/components/toast/index.js +5 -17
- package/lib/components/upload/index.js +4 -2
- package/lib/components/upload/util.js +2 -0
- package/lib/components/user-selector/empty/index.css +6 -6
- package/lib/components/user-selector/selected-panel/index.css +3 -3
- package/lib/components/video-modal/components/video-box/index.css +240 -0
- package/lib/components/video-modal/components/video-box/index.js +334 -0
- package/lib/components/video-modal/img/bigFaqi.png +0 -0
- package/lib/components/video-modal/img/close.png +0 -0
- package/lib/components/video-modal/img/full.svg +21 -0
- package/lib/components/video-modal/img/muted.svg +14 -0
- package/lib/components/video-modal/img/not-muted.svg +22 -0
- package/lib/components/video-modal/img/pause.svg +13 -0
- package/lib/components/video-modal/img/play.svg +18 -0
- package/lib/components/video-modal/img/small.svg +22 -0
- package/lib/components/video-modal/index.css +83 -0
- package/lib/components/video-modal/index.js +182 -0
- package/lib/components/video-modal/utils.js +25 -0
- package/lib/components/weekly-report/common-painter/openDataPainter.js +5 -1
- package/lib/hooks/useGlobalState.js +63 -0
- package/lib/index.js +40 -0
- package/lib/pages/aha2021/img/canceled.svg +13 -0
- package/lib/pages/aha2021/img/not-try.png +0 -0
- package/lib/pages/aha2021/img/try.png +0 -0
- package/lib/pages/aha2021/index.css +52 -0
- package/lib/pages/aha2021/index.js +73 -14
- package/lib/pages/new-okr-list/header/index.js +2 -1
- package/lib/pages/new-okr-list/index.js +3 -3
- package/lib/pages/okr-map/export-modules/share-okr-page/header/index.js +0 -5
- package/lib/pages/pay/image/success.png +0 -0
- package/lib/pages/pay/index.css +79 -0
- package/lib/pages/pay/index.js +66 -0
- package/lib/utils/bs-global.js +13 -9
- package/lib/utils/helpers.js +7 -1
- package/lib/utils/open-data.js +2 -1
- package/lib/utils/tools.js +11 -2
- package/package.json +120 -101
- package/lib/components/dynamic/dynamic-item/dynamic-align/img/dynamic-align.svg +0 -22
- package/lib/components/dynamic/dynamic-item/dynamic-align/img/dynamic-relative.svg +0 -22
- package/lib/components/dynamic/dynamic-item/dynamic-milestone/img/dynamic-milestone.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-okrs-communication/img/okrs-icon.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-plan-communication/img/plan-icon.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-project/img/dynamic-project.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-relative/img/dynamic-relative.svg +0 -22
- package/lib/components/dynamic/dynamic-item/dynamic-share-to-dynamic/img/guanlian.png +0 -0
- package/lib/components/dynamic/dynamic-item/dynamic-task/img/task-icon.png +0 -0
- package/lib/components/invite-people/img/invite-people.png +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.editInsertedLink = editInsertedLink;
|
|
7
|
+
exports.hideLinkToolbar = hideLinkToolbar;
|
|
8
|
+
exports.insertLink = insertLink;
|
|
9
|
+
exports.isLinkAtPos = isLinkAtPos;
|
|
10
|
+
exports.isTextAtPos = isTextAtPos;
|
|
11
|
+
exports.removeLink = removeLink;
|
|
12
|
+
exports.setLinkHref = setLinkHref;
|
|
13
|
+
exports.setLinkText = setLinkText;
|
|
14
|
+
exports.updateLink = updateLink;
|
|
15
|
+
|
|
16
|
+
var _utils = require("./utils");
|
|
17
|
+
|
|
18
|
+
var _main = require("./pm-plugins/main");
|
|
19
|
+
|
|
20
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
21
|
+
|
|
22
|
+
var _commands = require("../../../utils/commands");
|
|
23
|
+
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
|
|
28
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
|
+
|
|
30
|
+
// import {
|
|
31
|
+
// addAnalytics,
|
|
32
|
+
// ACTION,
|
|
33
|
+
// ACTION_SUBJECT,
|
|
34
|
+
// INPUT_METHOD,
|
|
35
|
+
// EVENT_TYPE,
|
|
36
|
+
// ACTION_SUBJECT_ID,
|
|
37
|
+
// withAnalytics,
|
|
38
|
+
// } from '../analytics';
|
|
39
|
+
// import { queueCardsFromChangedTr } from '../card/pm-plugins/doc';
|
|
40
|
+
// import { LinkInputType } from './ui/HyperlinkAddToolbar/HyperlinkAddToolbar';
|
|
41
|
+
// import { getLinkCreationAnalyticsEvent } from './analytics';
|
|
42
|
+
function isTextAtPos(pos) {
|
|
43
|
+
return function (state) {
|
|
44
|
+
var node = state.doc.nodeAt(pos);
|
|
45
|
+
return !!node && node.isText;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isLinkAtPos(pos) {
|
|
50
|
+
return function (state) {
|
|
51
|
+
var node = state.doc.nodeAt(pos);
|
|
52
|
+
return !!node && state.schema.marks.link.isInSet(node.marks);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function setLinkHref(href, pos, to, isTabPressed) {
|
|
57
|
+
return (0, _commands.filter)(isTextAtPos(pos), function (state, dispatch) {
|
|
58
|
+
var $pos = state.doc.resolve(pos);
|
|
59
|
+
var node = state.doc.nodeAt(pos);
|
|
60
|
+
var linkMark = state.schema.marks.link;
|
|
61
|
+
var mark = linkMark.isInSet(node.marks);
|
|
62
|
+
var url = (0, _utils.normalizeUrl)(href);
|
|
63
|
+
|
|
64
|
+
if (mark && mark.attrs.href === url) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var rightBound = to && pos !== to ? to : pos - $pos.textOffset + node.nodeSize;
|
|
69
|
+
var tr = state.tr.removeMark(pos, rightBound, linkMark);
|
|
70
|
+
|
|
71
|
+
if (href.trim()) {
|
|
72
|
+
tr.addMark(pos, rightBound, linkMark.create(_objectSpread(_objectSpread({}, mark && mark.attrs || {}), {}, {
|
|
73
|
+
href: url
|
|
74
|
+
})));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!isTabPressed) {
|
|
78
|
+
tr.setMeta(_main.stateKey, {
|
|
79
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (dispatch) {
|
|
84
|
+
dispatch(tr);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return true;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function updateLink(href, text, pos, to) {
|
|
92
|
+
return function (state, dispatch) {
|
|
93
|
+
var $pos = state.doc.resolve(pos);
|
|
94
|
+
var node = state.doc.nodeAt(pos);
|
|
95
|
+
|
|
96
|
+
if (!node) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var url = (0, _utils.normalizeUrl)(href);
|
|
101
|
+
|
|
102
|
+
if (!url) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var mark = state.schema.marks.link.isInSet(node.marks);
|
|
107
|
+
var linkMark = state.schema.marks.link;
|
|
108
|
+
var rightBound = to && pos !== to ? to : pos - $pos.textOffset + node.nodeSize;
|
|
109
|
+
var tr = state.tr;
|
|
110
|
+
tr.insertText(text, pos, rightBound); // Casting to LinkAttributes to prevent wrong attributes been passed (Example ED-7951)
|
|
111
|
+
|
|
112
|
+
var linkAttrs = _objectSpread(_objectSpread({}, mark && mark.attrs || {}), {}, {
|
|
113
|
+
href: url
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
tr.addMark(pos, pos + text.length, linkMark.create(linkAttrs));
|
|
117
|
+
tr.setMeta(_main.stateKey, {
|
|
118
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (dispatch) {
|
|
122
|
+
dispatch(tr);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function setLinkText(text, pos, to) {
|
|
130
|
+
return (0, _commands.filter)(isLinkAtPos(pos), function (state, dispatch) {
|
|
131
|
+
var $pos = state.doc.resolve(pos);
|
|
132
|
+
var node = state.doc.nodeAt(pos);
|
|
133
|
+
var mark = state.schema.marks.link.isInSet(node.marks);
|
|
134
|
+
|
|
135
|
+
if (node && text.length > 0 && text !== node.text) {
|
|
136
|
+
var rightBound = to && pos !== to ? to : pos - $pos.textOffset + node.nodeSize;
|
|
137
|
+
var tr = state.tr;
|
|
138
|
+
tr.insertText(text, pos, rightBound);
|
|
139
|
+
tr.addMark(pos, pos + text.length, mark);
|
|
140
|
+
tr.setMeta(_main.stateKey, {
|
|
141
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (dispatch) {
|
|
145
|
+
dispatch(tr);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return false;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function insertLink(from, to, href, text // source?: INPUT_METHOD.MANUAL | INPUT_METHOD.TYPEAHEAD,
|
|
156
|
+
) {
|
|
157
|
+
return (0, _commands.filter)((0, _main.canLinkBeCreatedInRange)(from, to), function (state, dispatch) {
|
|
158
|
+
var link = state.schema.marks.link;
|
|
159
|
+
|
|
160
|
+
if (href.trim()) {
|
|
161
|
+
var tr = state.tr;
|
|
162
|
+
var normalizedUrl = (0, _utils.normalizeUrl)(href);
|
|
163
|
+
|
|
164
|
+
if (from === to) {
|
|
165
|
+
var textContent = text || href;
|
|
166
|
+
tr.insertText(textContent, from, to);
|
|
167
|
+
tr.addMark(from, from + textContent.length, link.create({
|
|
168
|
+
href: normalizedUrl
|
|
169
|
+
}));
|
|
170
|
+
} else {
|
|
171
|
+
var _textContent = text || href;
|
|
172
|
+
|
|
173
|
+
tr.insertText(_textContent, from, to);
|
|
174
|
+
tr.addMark(from, from + _textContent.length, link.create({
|
|
175
|
+
href: normalizedUrl
|
|
176
|
+
}));
|
|
177
|
+
tr.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(from + _textContent.length)));
|
|
178
|
+
} // queueCardsFromChangedTr(state, tr, source!, false);
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
tr.setMeta(_main.stateKey, {
|
|
182
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
if (dispatch) {
|
|
186
|
+
dispatch(tr);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return false;
|
|
193
|
+
});
|
|
194
|
+
} // export const insertLinkWithAnalytics = (
|
|
195
|
+
// inputMethod: LinkInputType,
|
|
196
|
+
// from: number,
|
|
197
|
+
// to: number,
|
|
198
|
+
// href: string,
|
|
199
|
+
// text?: string,
|
|
200
|
+
// ) =>
|
|
201
|
+
// withAnalytics(getLinkCreationAnalyticsEvent(inputMethod, href))(
|
|
202
|
+
// insertLink(from, to, href, text, inputMethod),
|
|
203
|
+
// );
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
function removeLink(pos) {
|
|
207
|
+
return setLinkHref('', pos);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function editInsertedLink() {
|
|
211
|
+
return function (state, dispatch) {
|
|
212
|
+
if (dispatch) {
|
|
213
|
+
dispatch(state.tr.setMeta(_main.stateKey, {
|
|
214
|
+
type: _main.LinkAction.EDIT_INSERTED_TOOLBAR
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return true;
|
|
219
|
+
};
|
|
220
|
+
} // export function showLinkToolbar(
|
|
221
|
+
// inputMethod:
|
|
222
|
+
// | INPUT_METHOD.TOOLBAR
|
|
223
|
+
// | INPUT_METHOD.QUICK_INSERT
|
|
224
|
+
// | INPUT_METHOD.SHORTCUT
|
|
225
|
+
// | INPUT_METHOD.INSERT_MENU = INPUT_METHOD.TOOLBAR,
|
|
226
|
+
// ): Command {
|
|
227
|
+
// return function(state, dispatch) {
|
|
228
|
+
// if (dispatch) {
|
|
229
|
+
// let tr = state.tr.setMeta(stateKey, {
|
|
230
|
+
// type: LinkAction.SHOW_INSERT_TOOLBAR,
|
|
231
|
+
// });
|
|
232
|
+
// tr = addAnalytics(state, tr, {
|
|
233
|
+
// action: ACTION.INVOKED,
|
|
234
|
+
// actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
235
|
+
// actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
236
|
+
// attributes: { inputMethod },
|
|
237
|
+
// eventType: EVENT_TYPE.UI,
|
|
238
|
+
// });
|
|
239
|
+
// dispatch(tr);
|
|
240
|
+
// }
|
|
241
|
+
// return true;
|
|
242
|
+
// };
|
|
243
|
+
// }
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
function hideLinkToolbar() {
|
|
247
|
+
return function (state, dispatch) {
|
|
248
|
+
if (dispatch) {
|
|
249
|
+
dispatch(state.tr.setMeta(_main.stateKey, {
|
|
250
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return true;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.LinkSchema = exports.LinkPlugin = exports.LinkController = void 0;
|
|
9
|
+
|
|
10
|
+
var _plugin = _interopRequireDefault(require("../../../models/plugin"));
|
|
11
|
+
|
|
12
|
+
var _schema = require("../../../models/schema");
|
|
13
|
+
|
|
14
|
+
var _controller = _interopRequireDefault(require("../../../models/controller"));
|
|
15
|
+
|
|
16
|
+
var _toolbarBtn = _interopRequireDefault(require("./ui/toolbarBtn"));
|
|
17
|
+
|
|
18
|
+
var _main = _interopRequireWildcard(require("./pm-plugins/main"));
|
|
19
|
+
|
|
20
|
+
var _fakeCursorForToolbar = _interopRequireDefault(require("./pm-plugins/fake-cursor-for-toolbar"));
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
|
+
|
|
28
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
|
+
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
|
+
|
|
32
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
+
|
|
34
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
|
+
|
|
36
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
|
+
|
|
38
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
39
|
+
|
|
40
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
41
|
+
|
|
42
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
|
+
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
|
+
|
|
46
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
47
|
+
|
|
48
|
+
var PLUGIN_NAME = 'link';
|
|
49
|
+
|
|
50
|
+
var LinkSchema = /*#__PURE__*/function (_InlineSchema) {
|
|
51
|
+
_inherits(LinkSchema, _InlineSchema);
|
|
52
|
+
|
|
53
|
+
var _super = _createSuper(LinkSchema);
|
|
54
|
+
|
|
55
|
+
function LinkSchema() {
|
|
56
|
+
var _this;
|
|
57
|
+
|
|
58
|
+
_classCallCheck(this, LinkSchema);
|
|
59
|
+
|
|
60
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
61
|
+
args[_key] = arguments[_key];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return _possibleConstructorReturn(_this, (_this = _super.call.apply(_super, [this].concat(args)), _this.name = PLUGIN_NAME, _this.priority = 100, _this.inclusive = false, _this.group = 'link', _this.attrs = {
|
|
65
|
+
href: {
|
|
66
|
+
"default": ''
|
|
67
|
+
}
|
|
68
|
+
}, _this.parseDOM = [{
|
|
69
|
+
tag: 'a[href]',
|
|
70
|
+
priority: 100,
|
|
71
|
+
getAttrs: function getAttrs(dom) {
|
|
72
|
+
if (!dom.textContent && !dom.getAttribute('text')) {
|
|
73
|
+
return false;
|
|
74
|
+
} // solve the problem of copying itself
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
href: dom.getAttribute('href')
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}], _this.toDOM = function (node) {
|
|
82
|
+
return ['a', {
|
|
83
|
+
href: node.attrs.href
|
|
84
|
+
}, 0];
|
|
85
|
+
}, _assertThisInitialized(_this)));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return _createClass(LinkSchema);
|
|
89
|
+
}(_schema.InlineSchema);
|
|
90
|
+
|
|
91
|
+
exports.LinkSchema = LinkSchema;
|
|
92
|
+
|
|
93
|
+
var LinkController = /*#__PURE__*/function (_BaseController) {
|
|
94
|
+
_inherits(LinkController, _BaseController);
|
|
95
|
+
|
|
96
|
+
var _super2 = _createSuper(LinkController);
|
|
97
|
+
|
|
98
|
+
function LinkController() {
|
|
99
|
+
var _this2;
|
|
100
|
+
|
|
101
|
+
_classCallCheck(this, LinkController);
|
|
102
|
+
|
|
103
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
104
|
+
args[_key2] = arguments[_key2];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return _possibleConstructorReturn(_this2, (_this2 = _super2.call.apply(_super2, [this].concat(args)), _this2.toolbar = {
|
|
108
|
+
title: '链接',
|
|
109
|
+
icon: 'tu-icon-text-link',
|
|
110
|
+
handler: function handler(editor) {
|
|
111
|
+
// toggleMark(editor.state.schema.marks[PLUGIN_NAME])(editor.state,editor.view.dispatch)
|
|
112
|
+
editor.view.focus();
|
|
113
|
+
},
|
|
114
|
+
renderMenu: _toolbarBtn["default"],
|
|
115
|
+
active: function active(state) {
|
|
116
|
+
return _main.stateKey.getState(state).activeLinkMark;
|
|
117
|
+
},
|
|
118
|
+
disabled: function disabled(state) {
|
|
119
|
+
return !_main.stateKey.getState(state).canInsertLink;
|
|
120
|
+
}
|
|
121
|
+
}, _this2.pmPlugins = [_main["default"], _fakeCursorForToolbar["default"]], _assertThisInitialized(_this2)));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return _createClass(LinkController);
|
|
125
|
+
}(_controller["default"]);
|
|
126
|
+
|
|
127
|
+
exports.LinkController = LinkController;
|
|
128
|
+
|
|
129
|
+
var LinkPlugin = /*#__PURE__*/function (_BasePlugin) {
|
|
130
|
+
_inherits(LinkPlugin, _BasePlugin);
|
|
131
|
+
|
|
132
|
+
var _super3 = _createSuper(LinkPlugin);
|
|
133
|
+
|
|
134
|
+
function LinkPlugin() {
|
|
135
|
+
var _this3;
|
|
136
|
+
|
|
137
|
+
_classCallCheck(this, LinkPlugin);
|
|
138
|
+
|
|
139
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
140
|
+
args[_key3] = arguments[_key3];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return _possibleConstructorReturn(_this3, (_this3 = _super3.call.apply(_super3, [this].concat(args)), _this3.name = PLUGIN_NAME, _this3.schema = LinkSchema, _this3.controller = LinkController, _assertThisInitialized(_this3)));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return _createClass(LinkPlugin);
|
|
147
|
+
}(_plugin["default"]);
|
|
148
|
+
|
|
149
|
+
exports.LinkPlugin = LinkPlugin;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
+
|
|
10
|
+
var _prosemirrorView = require("prosemirror-view");
|
|
11
|
+
|
|
12
|
+
var _main = require("./main");
|
|
13
|
+
|
|
14
|
+
var createTextCursor = function createTextCursor(pos) {
|
|
15
|
+
var node = document.createElement('div');
|
|
16
|
+
node.className = 'ProseMirror-fake-text-cursor';
|
|
17
|
+
return _prosemirrorView.Decoration.widget(pos, node, {
|
|
18
|
+
key: 'hyperlink-text-cursor'
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var createTextSelection = function createTextSelection(from, to) {
|
|
23
|
+
return _prosemirrorView.Decoration.inline(from, to, {
|
|
24
|
+
"class": 'ProseMirror-fake-text-selection'
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var getInsertLinkToolbarState = function getInsertLinkToolbarState(editorState) {
|
|
29
|
+
var state = _main.stateKey.getState(editorState);
|
|
30
|
+
|
|
31
|
+
if (state && state.activeLinkMark) {
|
|
32
|
+
if (state.activeLinkMark.type === _main.InsertStatus.INSERT_LINK_TOOLBAR) {
|
|
33
|
+
return state.activeLinkMark;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var fakeCursorToolbarPlugin = new _prosemirrorState.Plugin({
|
|
41
|
+
state: {
|
|
42
|
+
init: function init() {
|
|
43
|
+
return _prosemirrorView.DecorationSet.empty;
|
|
44
|
+
},
|
|
45
|
+
apply: function apply(tr, pluginState, oldState, newState) {
|
|
46
|
+
var oldInsertToolbarState = getInsertLinkToolbarState(oldState);
|
|
47
|
+
var insertToolbarState = getInsertLinkToolbarState(newState); // Map DecorationSet if it still refers to the same position in the document
|
|
48
|
+
|
|
49
|
+
if (oldInsertToolbarState && insertToolbarState) {
|
|
50
|
+
var from = insertToolbarState.from,
|
|
51
|
+
to = insertToolbarState.to;
|
|
52
|
+
var oldFrom = tr.mapping.map(oldInsertToolbarState.from);
|
|
53
|
+
var oldTo = tr.mapping.map(oldInsertToolbarState.to);
|
|
54
|
+
|
|
55
|
+
if (oldFrom === from && oldTo === to) {
|
|
56
|
+
return pluginState.map(tr.mapping, tr.doc);
|
|
57
|
+
}
|
|
58
|
+
} // Update DecorationSet if new insert toolbar, or if we have moved to a different position in the doc
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if (insertToolbarState) {
|
|
62
|
+
var _from = insertToolbarState.from,
|
|
63
|
+
_to = insertToolbarState.to;
|
|
64
|
+
return _prosemirrorView.DecorationSet.create(tr.doc, [_from === _to ? createTextCursor(_from) : createTextSelection(_from, _to)]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return _prosemirrorView.DecorationSet.empty;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
props: {
|
|
71
|
+
decorations: function decorations(state) {
|
|
72
|
+
return fakeCursorToolbarPlugin.getState(state);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
var _default = fakeCursorToolbarPlugin;
|
|
77
|
+
exports["default"] = _default;
|