@worktile/theia 3.0.8 → 3.0.9
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/README.md +11 -11
- package/bundles/worktile-theia.umd.js +14357 -14343
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/components/color-select/color-select.component.d.ts +32 -32
- package/components/color-select/color-select.component.scss +107 -107
- package/components/column-resize/column-resize-notifier.d.ts +35 -35
- package/components/column-resize/column-resize.directive.d.ts +26 -26
- package/components/column-resize/column-resize.module.d.ts +14 -14
- package/components/column-resize/event-dispatcher.d.ts +31 -31
- package/components/column-resize/overlay-handle.component.d.ts +33 -33
- package/components/column-resize/resize-ref.d.ts +25 -25
- package/components/column-resize/resizing.store.d.ts +28 -28
- package/components/column-resize/selectors.d.ts +3 -3
- package/components/contextmenu/contextmenu.component.d.ts +22 -22
- package/components/conversion-hint/conversion-hint.component.d.ts +18 -18
- package/components/conversion-hint/conversion-hint.component.scss +11 -11
- package/components/element/element.component.d.ts +7 -7
- package/components/inline-toolbar/inline-toolbar.component.d.ts +26 -26
- package/components/nav-split-line/nav-split-line.component.d.ts +13 -13
- package/components/table-select/table-select.component.d.ts +20 -20
- package/components/table-select/table-select.component.scss +35 -35
- package/components/template/template.component.d.ts +15 -15
- package/components/text/text.component.d.ts +14 -14
- package/components/toolbar/toolbar.component.d.ts +65 -65
- package/components/toolbar-dropdown/toolbar-dropdown.component.d.ts +33 -33
- package/components/toolbar-dropdown/toolbar-dropdown.component.scss +0 -1
- package/components/toolbar-group/toolbar-group.component.d.ts +33 -33
- package/components/toolbar-group/toolbar-group.component.scss +17 -17
- package/components/toolbar-item/toolbar-item.component.d.ts +18 -18
- package/constants/auto-format-rules.d.ts +2 -2
- package/constants/code.d.ts +9 -9
- package/constants/color-select.d.ts +14 -14
- package/constants/default.d.ts +9 -9
- package/constants/error.d.ts +5 -5
- package/constants/index.d.ts +5 -5
- package/constants/node-types.d.ts +99 -99
- package/constants/selector.d.ts +2 -2
- package/constants/toolbar.d.ts +17 -17
- package/core/create-plugin.d.ts +2 -2
- package/core/create-toolbar.d.ts +5 -5
- package/core/index.d.ts +4 -4
- package/core/toolbar-item/base-toolbar-item.d.ts +29 -29
- package/core/utils/combine-plugins.d.ts +2 -2
- package/core/utils/flatten-deep-plugins.d.ts +6 -6
- package/core/utils/get-plugin-options.d.ts +2 -2
- package/core/utils/get-plugin.d.ts +2 -2
- package/core/utils/get-plugins.d.ts +2 -2
- package/core/utils/index.d.ts +10 -10
- package/core/utils/merge-array.d.ts +1 -1
- package/core/utils/merge-deep-plugins.d.ts +2 -2
- package/core/utils/merge-options.d.ts +2 -2
- package/core/utils/nested-structure-by-key.d.ts +2 -2
- package/core/utils/plugins-by-key.d.ts +2 -2
- package/core/with-theia.d.ts +4 -4
- package/custom-types.d.ts +131 -131
- package/editor.component.d.ts +92 -92
- package/editor.module.d.ts +98 -98
- package/esm2015/components/color-select/color-select.component.js +112 -112
- package/esm2015/components/column-resize/column-resize-notifier.js +31 -31
- package/esm2015/components/column-resize/column-resize.directive.js +98 -98
- package/esm2015/components/column-resize/column-resize.module.js +34 -34
- package/esm2015/components/column-resize/event-dispatcher.js +55 -55
- package/esm2015/components/column-resize/overlay-handle.component.js +139 -139
- package/esm2015/components/column-resize/resize-ref.js +25 -25
- package/esm2015/components/column-resize/resizing.store.js +154 -154
- package/esm2015/components/column-resize/selectors.js +4 -4
- package/esm2015/components/contextmenu/contextmenu.component.js +64 -64
- package/esm2015/components/conversion-hint/conversion-hint.component.js +59 -59
- package/esm2015/components/element/element.component.js +23 -23
- package/esm2015/components/inline-toolbar/inline-toolbar.component.js +126 -126
- package/esm2015/components/nav-split-line/nav-split-line.component.js +36 -36
- package/esm2015/components/table-select/table-select.component.js +53 -53
- package/esm2015/components/template/template.component.js +66 -66
- package/esm2015/components/text/text.component.js +57 -57
- package/esm2015/components/toolbar/toolbar.component.js +250 -250
- package/esm2015/components/toolbar-dropdown/toolbar-dropdown.component.js +132 -132
- package/esm2015/components/toolbar-group/toolbar-group.component.js +116 -116
- package/esm2015/components/toolbar-item/toolbar-item.component.js +64 -64
- package/esm2015/constants/auto-format-rules.js +166 -166
- package/esm2015/constants/code.js +88 -88
- package/esm2015/constants/color-select.js +61 -61
- package/esm2015/constants/default.js +9 -9
- package/esm2015/constants/error.js +7 -7
- package/esm2015/constants/index.js +5 -5
- package/esm2015/constants/node-types.js +132 -132
- package/esm2015/constants/selector.js +3 -3
- package/esm2015/constants/toolbar.js +69 -69
- package/esm2015/core/create-plugin.js +4 -4
- package/esm2015/core/create-toolbar.js +56 -56
- package/esm2015/core/index.js +4 -4
- package/esm2015/core/toolbar-item/base-toolbar-item.js +91 -91
- package/esm2015/core/utils/combine-plugins.js +9 -9
- package/esm2015/core/utils/flatten-deep-plugins.js +18 -18
- package/esm2015/core/utils/get-plugin-options.js +2 -2
- package/esm2015/core/utils/get-plugin.js +1 -1
- package/esm2015/core/utils/get-plugins.js +4 -4
- package/esm2015/core/utils/index.js +10 -10
- package/esm2015/core/utils/merge-array.js +17 -17
- package/esm2015/core/utils/merge-deep-plugins.js +13 -13
- package/esm2015/core/utils/merge-options.js +19 -19
- package/esm2015/core/utils/nested-structure-by-key.js +10 -10
- package/esm2015/core/utils/plugins-by-key.js +9 -9
- package/esm2015/core/with-theia.js +22 -22
- package/esm2015/custom-types.js +1 -1
- package/esm2015/editor.component.js +439 -439
- package/esm2015/editor.module.js +201 -201
- package/esm2015/interfaces/auto-format.js +1 -1
- package/esm2015/interfaces/editor.js +22 -22
- package/esm2015/interfaces/element.js +1 -1
- package/esm2015/interfaces/image.js +2 -2
- package/esm2015/interfaces/index.js +8 -8
- package/esm2015/interfaces/plugins/index.js +4 -4
- package/esm2015/interfaces/plugins/no-infer.js +1 -1
- package/esm2015/interfaces/plugins/plugin-key.js +39 -39
- package/esm2015/interfaces/plugins/plugins.js +1 -1
- package/esm2015/interfaces/plugins/with-override.js +1 -1
- package/esm2015/interfaces/reset-block-type-plugin-options.js +2 -2
- package/esm2015/interfaces/toolbar.js +11 -11
- package/esm2015/interfaces/upload.js +2 -2
- package/esm2015/interfaces/utility/index.js +3 -3
- package/esm2015/interfaces/utility/nested-structure-by-key.js +1 -1
- package/esm2015/interfaces/utility/override-by-key.js +1 -1
- package/esm2015/interfaces/utility/types.js +1 -1
- package/esm2015/interfaces/valid-children-types.js +35 -35
- package/esm2015/interfaces/view-base.js +21 -21
- package/esm2015/pipes.js +42 -42
- package/esm2015/plugins/align/align.editor.js +47 -47
- package/esm2015/plugins/align/align.plugin.js +63 -63
- package/esm2015/plugins/autoformat/autoformat.plugin.js +109 -109
- package/esm2015/plugins/autoformat/transforms/auto-format-block.js +14 -14
- package/esm2015/plugins/autoformat/transforms/auto-format-inline.js +77 -77
- package/esm2015/plugins/blockquote/blockquote.component.js +21 -21
- package/esm2015/plugins/blockquote/blockquote.editor.js +20 -20
- package/esm2015/plugins/blockquote/blockquote.plugin.js +70 -70
- package/esm2015/plugins/code/code.component.js +244 -244
- package/esm2015/plugins/code/code.editor.js +47 -47
- package/esm2015/plugins/code/code.plugin.js +41 -41
- package/esm2015/plugins/color/color.editor.js +44 -44
- package/esm2015/plugins/color/color.plugin.js +27 -27
- package/esm2015/plugins/color/toolbar-item.component.js +79 -79
- package/esm2015/plugins/common/auto-insert-data..js +77 -77
- package/esm2015/plugins/common/block-card.plugin.js +286 -286
- package/esm2015/plugins/common/get-fragment.plugin.js +24 -24
- package/esm2015/plugins/common/history.plugin.js +30 -30
- package/esm2015/plugins/common/move-selection.plugin.js +89 -89
- package/esm2015/plugins/common/remove-empty.plugin.js +59 -59
- package/esm2015/plugins/common/remove-void.plugin.js +56 -56
- package/esm2015/plugins/common/reset-type.plugin.js +34 -34
- package/esm2015/plugins/common/transforms.plugin.js +17 -17
- package/esm2015/plugins/deserializers/deserialize-html.plugin.js +38 -38
- package/esm2015/plugins/deserializers/deserialize-md.plugin.js +121 -121
- package/esm2015/plugins/font-size/font-size.editor.js +97 -97
- package/esm2015/plugins/heading/heading.editor.js +53 -53
- package/esm2015/plugins/heading/heading.plugin.js +84 -84
- package/esm2015/plugins/hr/hr.component.js +40 -40
- package/esm2015/plugins/hr/hr.editor.js +7 -7
- package/esm2015/plugins/hr/hr.plugin.js +41 -41
- package/esm2015/plugins/image/image.component.js +369 -369
- package/esm2015/plugins/image/image.editor.js +57 -57
- package/esm2015/plugins/image/image.plugin.js +57 -57
- package/esm2015/plugins/indent/indent.editor.js +72 -72
- package/esm2015/plugins/indent/indent.plugin.js +59 -59
- package/esm2015/plugins/indent/on-keydown-indent.js +53 -53
- package/esm2015/plugins/index.js +70 -70
- package/esm2015/plugins/inline-code/inline-code.component.js +21 -21
- package/esm2015/plugins/inline-code/inline-code.editor.js +48 -48
- package/esm2015/plugins/inline-code/inline-code.plugin.js +65 -65
- package/esm2015/plugins/link/edit/link-edit.component.js +108 -108
- package/esm2015/plugins/link/hover/link-hover.component.js +39 -39
- package/esm2015/plugins/link/link.component.js +162 -162
- package/esm2015/plugins/link/link.editor.js +66 -66
- package/esm2015/plugins/link/link.plugin.js +58 -58
- package/esm2015/plugins/link/link.types.js +12 -12
- package/esm2015/plugins/list/components/bulleted-list.component.js +33 -33
- package/esm2015/plugins/list/components/list-item.component.js +94 -94
- package/esm2015/plugins/list/components/numbered-list.component.js +39 -39
- package/esm2015/plugins/list/list.editor.js +125 -125
- package/esm2015/plugins/list/list.plugin.js +280 -280
- package/esm2015/plugins/list/normalizers/get-list-normalizer.js +39 -39
- package/esm2015/plugins/list/normalizers/normalize-list-item.js +19 -19
- package/esm2015/plugins/list/normalizers/normalize-no.js +42 -42
- package/esm2015/plugins/list/on-key-down-list.js +32 -32
- package/esm2015/plugins/list/queries/get-list-item-entry.js +27 -27
- package/esm2015/plugins/list/queries/get-list-item-sublist.js +12 -12
- package/esm2015/plugins/list/queries/get-list-types.js +5 -5
- package/esm2015/plugins/list/queries/get-start-list-item.js +26 -26
- package/esm2015/plugins/list/queries/has-list-in-list-item.js +27 -27
- package/esm2015/plugins/list/queries/is-in-list.js +5 -5
- package/esm2015/plugins/list/queries/is-list-nested.js +10 -10
- package/esm2015/plugins/list/queries/is-list.js +5 -5
- package/esm2015/plugins/list/queries/is-node-type-list.js +4 -4
- package/esm2015/plugins/list/queries/is-selection-at-list-item-start.js +12 -12
- package/esm2015/plugins/list/queries/is-selection-in-same-list-item.js +16 -16
- package/esm2015/plugins/list/queries/is-single-list-item.js +9 -9
- package/esm2015/plugins/list/transforms/insert-list-data.js +71 -71
- package/esm2015/plugins/list/transforms/insert-list-item.js +72 -72
- package/esm2015/plugins/list/transforms/move-list-item-down.js +41 -41
- package/esm2015/plugins/list/transforms/move-list-item-sublist-items-to-list-item-sublist.js +42 -42
- package/esm2015/plugins/list/transforms/move-list-item-sublist-items-to-list.js +29 -29
- package/esm2015/plugins/list/transforms/move-list-item-up.js +77 -77
- package/esm2015/plugins/list/transforms/unwrap-list.js +9 -9
- package/esm2015/plugins/list/types.js +2 -2
- package/esm2015/plugins/mark/mark.editor.js +28 -28
- package/esm2015/plugins/mark/mark.plugin.js +101 -101
- package/esm2015/plugins/node-id/node-id.plugin.js +68 -68
- package/esm2015/plugins/normalizers/insert-paragraph-nodes.js +28 -28
- package/esm2015/plugins/normalizers/remove-empty-nodes.js +17 -17
- package/esm2015/plugins/normalizers/trailing-node.plugin.js +33 -33
- package/esm2015/plugins/paint-format/paint-format.editor.js +122 -122
- package/esm2015/plugins/public-api.js +15 -15
- package/esm2015/plugins/quick-insert/components/quick-insert.component.js +101 -101
- package/esm2015/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.js +83 -83
- package/esm2015/plugins/quick-insert/quick-insert.editor.js +52 -52
- package/esm2015/plugins/quick-insert/quick-insert.plugin.js +74 -74
- package/esm2015/plugins/soft-break/soft-break.plugin.js +36 -36
- package/esm2015/plugins/soft-break/soft-break.types.js +1 -1
- package/esm2015/plugins/table/components/insert-mark/insert-mark.component.js +102 -102
- package/esm2015/plugins/table/components/row/row.component.js +46 -46
- package/esm2015/plugins/table/components/table.component.js +469 -469
- package/esm2015/plugins/table/components/td/td.component.js +698 -698
- package/esm2015/plugins/table/components/toolbar/table-options.component.js +67 -67
- package/esm2015/plugins/table/components/toolbar/table-toolbar.component.js +161 -161
- package/esm2015/plugins/table/table.editor.js +182 -182
- package/esm2015/plugins/table/table.plugin.js +423 -423
- package/esm2015/plugins/table/table.service.js +102 -102
- package/esm2015/plugins/table/table.store.js +479 -479
- package/esm2015/plugins/table/table.types.js +33 -33
- package/esm2015/plugins/table/toolbar-item.component.js +61 -61
- package/esm2015/plugins/table/transforms/clear-cell.js +11 -11
- package/esm2015/plugins/table/transforms/clear-table-node.js +27 -27
- package/esm2015/plugins/table/transforms/insert-column.js +57 -57
- package/esm2015/plugins/table/transforms/insert-row.js +42 -42
- package/esm2015/plugins/table/transforms/insert-table.js +14 -14
- package/esm2015/plugins/table/transforms/remove-column.js +51 -51
- package/esm2015/plugins/table/transforms/remove-row.js +50 -50
- package/esm2015/plugins/table/transforms/remove-table.js +49 -49
- package/esm2015/plugins/table/utils/add-columns.js +28 -28
- package/esm2015/plugins/table/utils/calc-anchor-position.js +24 -24
- package/esm2015/plugins/table/utils/calc-span.js +72 -72
- package/esm2015/plugins/table/utils/create-cell.js +19 -19
- package/esm2015/plugins/table/utils/create-row.js +12 -12
- package/esm2015/plugins/table/utils/create-table.js +13 -13
- package/esm2015/plugins/table/utils/get-base-height.js +22 -22
- package/esm2015/plugins/table/utils/get-select-cell-node.js +16 -16
- package/esm2015/plugins/table/utils/index.js +8 -8
- package/esm2015/plugins/table/utils/is-range-in-table.js +16 -16
- package/esm2015/plugins/table/utils/is-selection-in-table.js +11 -11
- package/esm2015/plugins/table/utils/is-virtual-key.js +13 -13
- package/esm2015/plugins/table/utils/merge-cell.js +90 -90
- package/esm2015/plugins/table/utils/next-path.js +5 -5
- package/esm2015/plugins/table/utils/normalize-table.js +30 -30
- package/esm2015/plugins/table/utils/remove-columns.js +23 -23
- package/esm2015/plugins/table/utils/set-menu-cell-invisibility.js +15 -15
- package/esm2015/plugins/table/utils/split-cell.js +31 -31
- package/esm2015/plugins/table/utils/table-position.js +242 -242
- package/esm2015/plugins/todo-item/todo-item.component.js +55 -55
- package/esm2015/plugins/todo-item/todo-item.editor.js +31 -31
- package/esm2015/plugins/todo-item/todo-item.plugin.js +78 -78
- package/esm2015/plugins/vertical-align/toolbar-item.component.js +89 -89
- package/esm2015/plugins/vertical-align/vertical-align.editor.js +54 -54
- package/esm2015/public-api.js +23 -23
- package/esm2015/queries/anchor-block-entry.js +13 -13
- package/esm2015/queries/anchor-block.js +6 -6
- package/esm2015/queries/anchor-inline-entry.js +10 -10
- package/esm2015/queries/find-descendant.js +47 -47
- package/esm2015/queries/find-node.js +45 -45
- package/esm2015/queries/find-path.js +28 -28
- package/esm2015/queries/get-above-by-type.js +10 -10
- package/esm2015/queries/get-above.js +9 -9
- package/esm2015/queries/get-anchor-block-entry.js +8 -8
- package/esm2015/queries/get-block-above.js +7 -7
- package/esm2015/queries/get-block-card-above.js +7 -7
- package/esm2015/queries/get-block-card-cursor.js +5 -5
- package/esm2015/queries/get-container-blocks.js +11 -11
- package/esm2015/queries/get-directly-parent.js +11 -11
- package/esm2015/queries/get-insert-elements-path.js +43 -43
- package/esm2015/queries/get-last-child-path.js +9 -9
- package/esm2015/queries/get-last-node.js +17 -17
- package/esm2015/queries/get-next-sibling-nodes.js +17 -17
- package/esm2015/queries/get-node.js +10 -10
- package/esm2015/queries/get-nodes-by-type.js +12 -12
- package/esm2015/queries/get-nodes.js +7 -7
- package/esm2015/queries/get-parent.js +12 -12
- package/esm2015/queries/get-plain-text.js +16 -16
- package/esm2015/queries/get-plugin-by-toolbar.js +12 -12
- package/esm2015/queries/get-point-before.js +62 -62
- package/esm2015/queries/get-point-from-location.js +15 -15
- package/esm2015/queries/get-previous-path.js +9 -9
- package/esm2015/queries/get-rang-from-block-start.js +16 -16
- package/esm2015/queries/get-range-before.js +17 -17
- package/esm2015/queries/get-selection-marks.js +19 -19
- package/esm2015/queries/get-selection-nodes-by-type.js +29 -29
- package/esm2015/queries/get-text.js +9 -9
- package/esm2015/queries/get-toolbar-disabled.js +13 -13
- package/esm2015/queries/index.js +59 -58
- package/esm2015/queries/is-across-blocks.js +7 -7
- package/esm2015/queries/is-ancestor-empty.js +6 -6
- package/esm2015/queries/is-ancestor.js +3 -3
- package/esm2015/queries/is-block-above-empty.js +11 -11
- package/esm2015/queries/is-block-active.js +7 -7
- package/esm2015/queries/is-block-card-cursor.js +4 -4
- package/esm2015/queries/is-block-text-empty-after-selection.js +31 -31
- package/esm2015/queries/is-collapsed.js +7 -7
- package/esm2015/queries/is-contain-nested-type.js +28 -28
- package/esm2015/queries/is-container-type.js +2 -2
- package/esm2015/queries/is-descendant.js +3 -3
- package/esm2015/queries/is-empty-content.js +15 -0
- package/esm2015/queries/is-empty-paragraph-by-path.js +7 -7
- package/esm2015/queries/is-empty-paragraph.js +11 -11
- package/esm2015/queries/is-first-child.js +5 -5
- package/esm2015/queries/is-include-types.js +11 -11
- package/esm2015/queries/is-node-type-in.js +9 -9
- package/esm2015/queries/is-node-type.js +15 -15
- package/esm2015/queries/is-paragraph.js +9 -9
- package/esm2015/queries/is-point-at-root.js +2 -2
- package/esm2015/queries/is-range-across-blocks.js +18 -18
- package/esm2015/queries/is-range-at-root.js +3 -3
- package/esm2015/queries/is-start.js +6 -6
- package/esm2015/queries/some-node.js +9 -9
- package/esm2015/services/color-select.service.js +49 -49
- package/esm2015/services/context.service.js +59 -59
- package/esm2015/services/table-contextmenu.service.js +189 -189
- package/esm2015/services/toolbar.service.js +47 -47
- package/esm2015/shortcuts/index.js +5 -5
- package/esm2015/shortcuts/mark.js +24 -24
- package/esm2015/transforms/apply-deep-to-nodes.js +21 -21
- package/esm2015/transforms/clear-marks.js +23 -23
- package/esm2015/transforms/close-conversion-hint.js +8 -8
- package/esm2015/transforms/delete-element.js +11 -11
- package/esm2015/transforms/handle-continual-delete-backward.js +17 -17
- package/esm2015/transforms/handle-continual-insert-break.js +19 -19
- package/esm2015/transforms/index.js +18 -18
- package/esm2015/transforms/insert-elements.js +34 -34
- package/esm2015/transforms/insert-paragraph.js +6 -6
- package/esm2015/transforms/merge-deep-to-nodes.js +8 -8
- package/esm2015/transforms/move-children.js +21 -21
- package/esm2015/transforms/on-keydown-reset-block-type.js +22 -22
- package/esm2015/transforms/set-end-selection.js +10 -10
- package/esm2015/transforms/set-marks.js +9 -9
- package/esm2015/transforms/set-node.js +5 -5
- package/esm2015/transforms/split-node.js +31 -31
- package/esm2015/transforms/un-hang-range.js +11 -11
- package/esm2015/transforms/un-wrap.js +11 -11
- package/esm2015/transforms/unwrap-nodes-by-type.js +11 -11
- package/esm2015/utils/auto-focus.js +13 -13
- package/esm2015/utils/auto-scroll-view.js +24 -24
- package/esm2015/utils/cast-array.js +7 -7
- package/esm2015/utils/common.js +2 -2
- package/esm2015/utils/create-empty-paragraph.js +14 -14
- package/esm2015/utils/data-transform.js +48 -48
- package/esm2015/utils/dom.js +46 -46
- package/esm2015/utils/editor-uuid.js +8 -8
- package/esm2015/utils/fragment.js +65 -65
- package/esm2015/utils/get-editable-element-height.js +6 -6
- package/esm2015/utils/get-toolbar-class.js +6 -6
- package/esm2015/utils/id-creator.js +11 -11
- package/esm2015/utils/index.js +13 -13
- package/esm2015/utils/is-clean-empty-paragraph.js +36 -36
- package/esm2015/utils/is-inline.js +9 -9
- package/esm2015/utils/lodash.js +3 -3
- package/esm2015/utils/match.js +29 -29
- package/esm2015/utils/merge-element-options.js +19 -19
- package/esm2015/utils/weak-maps.js +3 -3
- package/esm2015/worktile-theia.js +4 -4
- package/fesm2015/worktile-theia.js +13156 -13142
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/auto-format.d.ts +64 -64
- package/interfaces/editor.d.ts +146 -146
- package/interfaces/element.d.ts +9 -9
- package/interfaces/image.d.ts +25 -25
- package/interfaces/index.d.ts +8 -8
- package/interfaces/plugins/index.d.ts +4 -4
- package/interfaces/plugins/no-infer.d.ts +1 -1
- package/interfaces/plugins/plugin-key.d.ts +48 -48
- package/interfaces/plugins/plugins.d.ts +45 -45
- package/interfaces/plugins/with-override.d.ts +7 -7
- package/interfaces/reset-block-type-plugin-options.d.ts +23 -23
- package/interfaces/toolbar.d.ts +64 -64
- package/interfaces/upload.d.ts +11 -11
- package/interfaces/utility/index.d.ts +3 -3
- package/interfaces/utility/nested-structure-by-key.d.ts +3 -3
- package/interfaces/utility/override-by-key.d.ts +3 -3
- package/interfaces/utility/types.d.ts +1 -1
- package/interfaces/valid-children-types.d.ts +9 -9
- package/interfaces/view-base.d.ts +9 -9
- package/package.json +1 -1
- package/pipes.d.ts +16 -16
- package/plugins/align/align.editor.d.ts +7 -7
- package/plugins/align/align.plugin.d.ts +2 -2
- package/plugins/autoformat/autoformat.plugin.d.ts +6 -6
- package/plugins/autoformat/transforms/auto-format-block.d.ts +5 -5
- package/plugins/autoformat/transforms/auto-format-inline.d.ts +9 -9
- package/plugins/blockquote/blockquote.component.d.ts +11 -11
- package/plugins/blockquote/blockquote.editor.d.ts +4 -4
- package/plugins/blockquote/blockquote.plugin.d.ts +2 -2
- package/plugins/code/code.component.d.ts +65 -65
- package/plugins/code/code.editor.d.ts +8 -8
- package/plugins/code/code.plugin.d.ts +2 -2
- package/plugins/color/color.editor.d.ts +8 -8
- package/plugins/color/color.plugin.d.ts +1 -1
- package/plugins/color/toolbar-item.component.d.ts +16 -16
- package/plugins/common/auto-insert-data..d.ts +2 -2
- package/plugins/common/block-card.plugin.d.ts +2 -2
- package/plugins/common/get-fragment.plugin.d.ts +6 -6
- package/plugins/common/history.plugin.d.ts +9 -9
- package/plugins/common/move-selection.plugin.d.ts +2 -2
- package/plugins/common/remove-empty.plugin.d.ts +2 -2
- package/plugins/common/remove-void.plugin.d.ts +2 -2
- package/plugins/common/reset-type.plugin.d.ts +2 -2
- package/plugins/common/transforms.plugin.d.ts +8 -8
- package/plugins/deserializers/deserialize-html.plugin.d.ts +2 -2
- package/plugins/deserializers/deserialize-md.plugin.d.ts +2 -2
- package/plugins/font-size/font-size.editor.d.ts +10 -10
- package/plugins/heading/heading.editor.d.ts +9 -9
- package/plugins/heading/heading.plugin.d.ts +7 -7
- package/plugins/hr/hr.component.d.ts +12 -12
- package/plugins/hr/hr.editor.d.ts +4 -4
- package/plugins/hr/hr.plugin.d.ts +2 -2
- package/plugins/image/image.component.d.ts +74 -74
- package/plugins/image/image.editor.d.ts +12 -12
- package/plugins/image/image.plugin.d.ts +7 -7
- package/plugins/indent/indent.editor.d.ts +10 -10
- package/plugins/indent/indent.plugin.d.ts +8 -8
- package/plugins/indent/on-keydown-indent.d.ts +3 -3
- package/plugins/index.d.ts +1 -1
- package/plugins/inline-code/inline-code.component.d.ts +9 -9
- package/plugins/inline-code/inline-code.editor.d.ts +7 -7
- package/plugins/inline-code/inline-code.plugin.d.ts +2 -2
- package/plugins/link/edit/link-edit.component.d.ts +36 -36
- package/plugins/link/hover/link-hover.component.d.ts +15 -15
- package/plugins/link/link.component.d.ts +39 -39
- package/plugins/link/link.editor.d.ts +7 -7
- package/plugins/link/link.plugin.d.ts +2 -2
- package/plugins/link/link.types.d.ts +9 -9
- package/plugins/list/components/bulleted-list.component.d.ts +15 -15
- package/plugins/list/components/list-item.component.d.ts +20 -20
- package/plugins/list/components/numbered-list.component.d.ts +16 -16
- package/plugins/list/list.editor.d.ts +12 -12
- package/plugins/list/list.plugin.d.ts +3 -3
- package/plugins/list/normalizers/get-list-normalizer.d.ts +6 -6
- package/plugins/list/normalizers/normalize-list-item.d.ts +5 -5
- package/plugins/list/normalizers/normalize-no.d.ts +2 -2
- package/plugins/list/on-key-down-list.d.ts +2 -2
- package/plugins/list/queries/get-list-item-entry.d.ts +10 -10
- package/plugins/list/queries/get-list-item-sublist.d.ts +6 -6
- package/plugins/list/queries/get-list-types.d.ts +2 -2
- package/plugins/list/queries/get-start-list-item.d.ts +8 -8
- package/plugins/list/queries/has-list-in-list-item.d.ts +15 -15
- package/plugins/list/queries/is-in-list.d.ts +2 -2
- package/plugins/list/queries/is-list-nested.d.ts +5 -5
- package/plugins/list/queries/is-list.d.ts +2 -2
- package/plugins/list/queries/is-node-type-list.d.ts +2 -2
- package/plugins/list/queries/is-selection-at-list-item-start.d.ts +5 -5
- package/plugins/list/queries/is-selection-in-same-list-item.d.ts +5 -5
- package/plugins/list/queries/is-single-list-item.d.ts +5 -5
- package/plugins/list/transforms/insert-list-data.d.ts +12 -12
- package/plugins/list/transforms/insert-list-item.d.ts +5 -5
- package/plugins/list/transforms/move-list-item-down.d.ts +6 -6
- package/plugins/list/transforms/move-list-item-sublist-items-to-list-item-sublist.d.ts +20 -20
- package/plugins/list/transforms/move-list-item-sublist-items-to-list.d.ts +19 -19
- package/plugins/list/transforms/move-list-item-up.d.ts +10 -10
- package/plugins/list/transforms/unwrap-list.d.ts +2 -2
- package/plugins/list/types.d.ts +7 -7
- package/plugins/mark/mark.editor.d.ts +8 -8
- package/plugins/mark/mark.plugin.d.ts +3 -3
- package/plugins/node-id/node-id.plugin.d.ts +8 -8
- package/plugins/normalizers/insert-paragraph-nodes.d.ts +7 -7
- package/plugins/normalizers/remove-empty-nodes.d.ts +7 -7
- package/plugins/normalizers/trailing-node.plugin.d.ts +9 -9
- package/plugins/paint-format/paint-format.editor.d.ts +8 -8
- package/plugins/public-api.d.ts +15 -15
- package/plugins/quick-insert/components/quick-insert.component.d.ts +28 -28
- package/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.d.ts +28 -28
- package/plugins/quick-insert/quick-insert.editor.d.ts +7 -7
- package/plugins/quick-insert/quick-insert.plugin.d.ts +10 -10
- package/plugins/soft-break/soft-break.plugin.d.ts +5 -5
- package/plugins/soft-break/soft-break.types.d.ts +8 -8
- package/plugins/table/components/insert-mark/insert-mark.component.d.ts +24 -24
- package/plugins/table/components/row/row.component.d.ts +14 -14
- package/plugins/table/components/table.component.d.ts +79 -79
- package/plugins/table/components/td/td.component.d.ts +95 -95
- package/plugins/table/components/toolbar/table-options.component.d.ts +20 -20
- package/plugins/table/components/toolbar/table-toolbar.component.d.ts +38 -38
- package/plugins/table/table.editor.d.ts +25 -25
- package/plugins/table/table.plugin.d.ts +3 -3
- package/plugins/table/table.service.d.ts +30 -30
- package/plugins/table/table.store.d.ts +71 -71
- package/plugins/table/table.types.d.ts +67 -67
- package/plugins/table/toolbar-item.component.d.ts +17 -17
- package/plugins/table/transforms/clear-cell.d.ts +6 -6
- package/plugins/table/transforms/clear-table-node.d.ts +6 -6
- package/plugins/table/transforms/insert-column.d.ts +12 -12
- package/plugins/table/transforms/insert-row.d.ts +6 -6
- package/plugins/table/transforms/insert-table.d.ts +6 -6
- package/plugins/table/transforms/remove-column.d.ts +3 -3
- package/plugins/table/transforms/remove-row.d.ts +3 -3
- package/plugins/table/transforms/remove-table.d.ts +3 -3
- package/plugins/table/utils/add-columns.d.ts +2 -2
- package/plugins/table/utils/calc-anchor-position.d.ts +6 -6
- package/plugins/table/utils/calc-span.d.ts +11 -11
- package/plugins/table/utils/create-cell.d.ts +16 -16
- package/plugins/table/utils/create-row.d.ts +7 -7
- package/plugins/table/utils/create-table.d.ts +7 -7
- package/plugins/table/utils/get-base-height.d.ts +9 -9
- package/plugins/table/utils/get-select-cell-node.d.ts +7 -7
- package/plugins/table/utils/index.d.ts +7 -7
- package/plugins/table/utils/is-range-in-table.d.ts +6 -6
- package/plugins/table/utils/is-selection-in-table.d.ts +6 -6
- package/plugins/table/utils/is-virtual-key.d.ts +1 -1
- package/plugins/table/utils/merge-cell.d.ts +21 -21
- package/plugins/table/utils/next-path.d.ts +2 -2
- package/plugins/table/utils/normalize-table.d.ts +2 -2
- package/plugins/table/utils/remove-columns.d.ts +2 -2
- package/plugins/table/utils/set-menu-cell-invisibility.d.ts +3 -3
- package/plugins/table/utils/split-cell.d.ts +4 -4
- package/plugins/table/utils/table-position.d.ts +97 -97
- package/plugins/todo-item/todo-item.component.d.ts +21 -21
- package/plugins/todo-item/todo-item.editor.d.ts +5 -5
- package/plugins/todo-item/todo-item.plugin.d.ts +5 -5
- package/plugins/vertical-align/toolbar-item.component.d.ts +25 -25
- package/plugins/vertical-align/vertical-align.editor.d.ts +7 -7
- package/public-api.d.ts +20 -20
- package/queries/anchor-block-entry.d.ts +2 -2
- package/queries/anchor-block.d.ts +2 -2
- package/queries/anchor-inline-entry.d.ts +2 -2
- package/queries/find-descendant.d.ts +10 -10
- package/queries/find-node.d.ts +15 -15
- package/queries/find-path.d.ts +6 -6
- package/queries/get-above-by-type.d.ts +6 -6
- package/queries/get-above.d.ts +6 -6
- package/queries/get-anchor-block-entry.d.ts +2 -2
- package/queries/get-block-above.d.ts +7 -7
- package/queries/get-block-card-above.d.ts +7 -7
- package/queries/get-block-card-cursor.d.ts +2 -2
- package/queries/get-container-blocks.d.ts +2 -2
- package/queries/get-directly-parent.d.ts +2 -2
- package/queries/get-insert-elements-path.d.ts +7 -7
- package/queries/get-last-child-path.d.ts +6 -6
- package/queries/get-last-node.d.ts +2 -2
- package/queries/get-next-sibling-nodes.d.ts +7 -7
- package/queries/get-node.d.ts +2 -2
- package/queries/get-nodes-by-type.d.ts +6 -6
- package/queries/get-nodes.d.ts +4 -4
- package/queries/get-parent.d.ts +7 -7
- package/queries/get-plain-text.d.ts +6 -6
- package/queries/get-plugin-by-toolbar.d.ts +3 -3
- package/queries/get-point-before.d.ts +38 -38
- package/queries/get-point-from-location.d.ts +5 -5
- package/queries/get-previous-path.d.ts +2 -2
- package/queries/get-rang-from-block-start.d.ts +9 -9
- package/queries/get-range-before.d.ts +7 -7
- package/queries/get-selection-marks.d.ts +12 -12
- package/queries/get-selection-nodes-by-type.d.ts +3 -3
- package/queries/get-text.d.ts +6 -6
- package/queries/get-toolbar-disabled.d.ts +4 -4
- package/queries/index.d.ts +58 -57
- package/queries/is-across-blocks.d.ts +2 -2
- package/queries/is-ancestor-empty.d.ts +5 -5
- package/queries/is-ancestor.d.ts +2 -2
- package/queries/is-block-above-empty.d.ts +5 -5
- package/queries/is-block-active.d.ts +3 -3
- package/queries/is-block-card-cursor.d.ts +2 -2
- package/queries/is-block-text-empty-after-selection.d.ts +7 -7
- package/queries/is-collapsed.d.ts +6 -6
- package/queries/is-contain-nested-type.d.ts +2 -2
- package/queries/is-container-type.d.ts +2 -2
- package/queries/is-descendant.d.ts +2 -2
- package/queries/is-empty-content.d.ts +2 -0
- package/queries/is-empty-paragraph-by-path.d.ts +2 -2
- package/queries/is-empty-paragraph.d.ts +2 -2
- package/queries/is-first-child.d.ts +5 -5
- package/queries/is-include-types.d.ts +3 -3
- package/queries/is-node-type-in.d.ts +6 -6
- package/queries/is-node-type.d.ts +6 -6
- package/queries/is-paragraph.d.ts +2 -2
- package/queries/is-point-at-root.d.ts +2 -2
- package/queries/is-range-across-blocks.d.ts +8 -8
- package/queries/is-range-at-root.d.ts +2 -2
- package/queries/is-start.d.ts +5 -5
- package/queries/some-node.d.ts +7 -7
- package/services/color-select.service.d.ts +20 -20
- package/services/context.service.d.ts +49 -49
- package/services/table-contextmenu.service.d.ts +25 -25
- package/services/toolbar.service.d.ts +9 -9
- package/shortcuts/index.d.ts +2 -2
- package/shortcuts/mark.d.ts +2 -2
- package/transforms/apply-deep-to-nodes.d.ts +12 -12
- package/transforms/clear-marks.d.ts +2 -2
- package/transforms/close-conversion-hint.d.ts +2 -2
- package/transforms/delete-element.d.ts +2 -2
- package/transforms/handle-continual-delete-backward.d.ts +3 -3
- package/transforms/handle-continual-insert-break.d.ts +3 -3
- package/transforms/index.d.ts +18 -18
- package/transforms/insert-elements.d.ts +2 -2
- package/transforms/insert-paragraph.d.ts +2 -2
- package/transforms/merge-deep-to-nodes.d.ts +5 -5
- package/transforms/move-children.d.ts +24 -24
- package/transforms/on-keydown-reset-block-type.d.ts +3 -3
- package/transforms/set-end-selection.d.ts +2 -2
- package/transforms/set-marks.d.ts +12 -12
- package/transforms/set-node.d.ts +2 -2
- package/transforms/split-node.d.ts +3 -3
- package/transforms/un-hang-range.d.ts +10 -10
- package/transforms/un-wrap.d.ts +3 -3
- package/transforms/unwrap-nodes-by-type.d.ts +6 -6
- package/utils/auto-focus.d.ts +2 -2
- package/utils/auto-scroll-view.d.ts +6 -6
- package/utils/cast-array.d.ts +1 -1
- package/utils/common.d.ts +2 -2
- package/utils/create-empty-paragraph.d.ts +2 -2
- package/utils/data-transform.d.ts +6 -6
- package/utils/dom.d.ts +10 -10
- package/utils/editor-uuid.d.ts +3 -3
- package/utils/fragment.d.ts +10 -10
- package/utils/get-editable-element-height.d.ts +2 -2
- package/utils/get-toolbar-class.d.ts +2 -2
- package/utils/id-creator.d.ts +1 -1
- package/utils/index.d.ts +13 -13
- package/utils/is-clean-empty-paragraph.d.ts +9 -9
- package/utils/is-inline.d.ts +2 -2
- package/utils/lodash.d.ts +1 -1
- package/utils/match.d.ts +18 -18
- package/utils/merge-element-options.d.ts +2 -2
- package/utils/weak-maps.d.ts +5 -5
- package/worktile-theia.d.ts +5 -5
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
import { Component, HostListener } from '@angular/core';
|
|
2
|
-
import { Element, Node as SlateNode, Transforms } from 'slate';
|
|
3
|
-
import { ElementKinds } from '../../constants';
|
|
4
|
-
import { TheBaseElementComponent } from '../../interfaces';
|
|
5
|
-
import { LinkCloseTypes, LinkTags } from './link.types';
|
|
6
|
-
import { TheLinkHoverComponent } from './hover/link-hover.component';
|
|
7
|
-
import { TheLinkEditComponent } from './edit/link-edit.component';
|
|
8
|
-
import * as i0 from "@angular/core";
|
|
9
|
-
import * as i1 from "ngx-tethys/popover";
|
|
10
|
-
import * as i2 from "@angular/cdk/overlay";
|
|
11
|
-
import * as i3 from "slate-angular";
|
|
12
|
-
export class TheBaseLinkComponent extends TheBaseElementComponent {
|
|
13
|
-
constructor(elementRef, cdr, thyPopover, overlay, viewContainerRef) {
|
|
14
|
-
super(elementRef, cdr);
|
|
15
|
-
this.elementRef = elementRef;
|
|
16
|
-
this.cdr = cdr;
|
|
17
|
-
this.thyPopover = thyPopover;
|
|
18
|
-
this.overlay = overlay;
|
|
19
|
-
this.viewContainerRef = viewContainerRef;
|
|
20
|
-
this.beforeContextChange = (value) => {
|
|
21
|
-
if (this.thyPopoverEditRef && this.thyPopoverEditRef.componentInstance) {
|
|
22
|
-
let { originText } = this.thyPopoverEditRef.componentInstance;
|
|
23
|
-
if (originText && originText !== value.element.children[0].text) {
|
|
24
|
-
this.thyPopoverEditRef.componentInstance.originText = value.element.children[0].text;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
get linkHoverOpened() {
|
|
30
|
-
return this.thyPopoverHoverRef && this.thyPopoverHoverRef.componentInstance;
|
|
31
|
-
}
|
|
32
|
-
get linkEditOpened() {
|
|
33
|
-
return this.thyPopoverEditRef && this.thyPopoverEditRef.componentInstance;
|
|
34
|
-
}
|
|
35
|
-
ngOnInit() {
|
|
36
|
-
super.ngOnInit();
|
|
37
|
-
}
|
|
38
|
-
closeHoverPopover() {
|
|
39
|
-
if (this.linkHoverOpened) {
|
|
40
|
-
this.thyPopoverHoverRef.close();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
mousedownHandle(event) {
|
|
44
|
-
if (!this.readonly && !this.editor.disabled) {
|
|
45
|
-
this.openLinkHover();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
openLinkEdit(tag) {
|
|
49
|
-
if (this.linkHoverOpened) {
|
|
50
|
-
this.thyPopoverHoverRef.afterClosed().subscribe(() => {
|
|
51
|
-
this.internalOpenLinkEdit(tag);
|
|
52
|
-
});
|
|
53
|
-
this.thyPopover.close();
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.internalOpenLinkEdit(tag);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
isLinkEditOpenedByDom(dom) {
|
|
60
|
-
return this.linkEditOpened && this.thyPopoverEditRef.componentInstance.dom === dom;
|
|
61
|
-
}
|
|
62
|
-
closeEditPopover(type) {
|
|
63
|
-
if (this.linkEditOpened) {
|
|
64
|
-
this.thyPopoverEditRef.close(type);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
openLinkHover() {
|
|
68
|
-
const dom = this.nativeElement;
|
|
69
|
-
const url = this.element.url;
|
|
70
|
-
if (this.linkHoverOpened) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.thyPopoverHoverRef = this.thyPopover.open(TheLinkHoverComponent, {
|
|
74
|
-
initialState: {
|
|
75
|
-
link: url,
|
|
76
|
-
dom: dom,
|
|
77
|
-
editHandle: () => {
|
|
78
|
-
this.openLinkEdit(LinkTags.edit);
|
|
79
|
-
},
|
|
80
|
-
deleteHandle: () => {
|
|
81
|
-
Transforms.unwrapNodes(this.editor, { match: n => Element.isElement(n) && n.type === ElementKinds.link });
|
|
82
|
-
this.closeHoverPopover();
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
origin: dom,
|
|
86
|
-
placement: 'bottomLeft',
|
|
87
|
-
offset: 8,
|
|
88
|
-
minWidth: 0,
|
|
89
|
-
hasBackdrop: false,
|
|
90
|
-
outsideClosable: true,
|
|
91
|
-
viewContainerRef: this.viewContainerRef,
|
|
92
|
-
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
|
93
|
-
panelClass: 'the-link-over'
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
internalOpenLinkEdit(tag) {
|
|
97
|
-
const link = this.element.url;
|
|
98
|
-
SlateNode.get(this.editor, this.editor.selection.focus.path);
|
|
99
|
-
this.thyPopoverEditRef = this.thyPopover.open(TheLinkEditComponent, {
|
|
100
|
-
initialState: {
|
|
101
|
-
tag,
|
|
102
|
-
editor: this.editor,
|
|
103
|
-
node: this.element,
|
|
104
|
-
text: SlateNode.string(this.element),
|
|
105
|
-
link,
|
|
106
|
-
originSelection: this.editor.selection
|
|
107
|
-
},
|
|
108
|
-
minWidth: 0,
|
|
109
|
-
origin: this.elementRef.nativeElement,
|
|
110
|
-
backdropClosable: true,
|
|
111
|
-
placement: 'bottomLeft',
|
|
112
|
-
offset: 8,
|
|
113
|
-
hasBackdrop: false,
|
|
114
|
-
originActiveClass: null,
|
|
115
|
-
viewContainerRef: this.viewContainerRef,
|
|
116
|
-
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
|
117
|
-
panelClass: 'the-link-edit'
|
|
118
|
-
});
|
|
119
|
-
this.cdr.markForCheck();
|
|
120
|
-
}
|
|
121
|
-
close(type) {
|
|
122
|
-
this.closeHoverPopover();
|
|
123
|
-
this.closeEditPopover(type);
|
|
124
|
-
}
|
|
125
|
-
ngOnDestroy() {
|
|
126
|
-
super.ngOnDestroy();
|
|
127
|
-
this.close(LinkCloseTypes.destroy);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
TheBaseLinkComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheBaseLinkComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.ThyPopover }, { token: i2.Overlay }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
131
|
-
TheBaseLinkComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheBaseLinkComponent, selector: "[TheBaseLinkComponent]", host: { listeners: { "click": "mousedownHandle($event)" } }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
|
|
132
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheBaseLinkComponent, decorators: [{
|
|
133
|
-
type: Component,
|
|
134
|
-
args: [{
|
|
135
|
-
selector: '[TheBaseLinkComponent]',
|
|
136
|
-
template: ''
|
|
137
|
-
}]
|
|
138
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.ThyPopover }, { type: i2.Overlay }, { type: i0.ViewContainerRef }]; }, propDecorators: { mousedownHandle: [{
|
|
139
|
-
type: HostListener,
|
|
140
|
-
args: ['click', ['$event']]
|
|
141
|
-
}] } });
|
|
142
|
-
export class TheLinkComponent extends TheBaseLinkComponent {
|
|
143
|
-
constructor() {
|
|
144
|
-
super(...arguments);
|
|
145
|
-
// Put this at the start and end of an inline component to work around this Chromium bug:
|
|
146
|
-
// https://bugs.chromium.org/p/chromium/issues/detail?id=1249405
|
|
147
|
-
this.inlineChromiumBugfix = String.fromCodePoint(160);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
TheLinkComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheLinkComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1
|
+
import { Component, HostListener } from '@angular/core';
|
|
2
|
+
import { Element, Node as SlateNode, Transforms } from 'slate';
|
|
3
|
+
import { ElementKinds } from '../../constants';
|
|
4
|
+
import { TheBaseElementComponent } from '../../interfaces';
|
|
5
|
+
import { LinkCloseTypes, LinkTags } from './link.types';
|
|
6
|
+
import { TheLinkHoverComponent } from './hover/link-hover.component';
|
|
7
|
+
import { TheLinkEditComponent } from './edit/link-edit.component';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
import * as i1 from "ngx-tethys/popover";
|
|
10
|
+
import * as i2 from "@angular/cdk/overlay";
|
|
11
|
+
import * as i3 from "slate-angular";
|
|
12
|
+
export class TheBaseLinkComponent extends TheBaseElementComponent {
|
|
13
|
+
constructor(elementRef, cdr, thyPopover, overlay, viewContainerRef) {
|
|
14
|
+
super(elementRef, cdr);
|
|
15
|
+
this.elementRef = elementRef;
|
|
16
|
+
this.cdr = cdr;
|
|
17
|
+
this.thyPopover = thyPopover;
|
|
18
|
+
this.overlay = overlay;
|
|
19
|
+
this.viewContainerRef = viewContainerRef;
|
|
20
|
+
this.beforeContextChange = (value) => {
|
|
21
|
+
if (this.thyPopoverEditRef && this.thyPopoverEditRef.componentInstance) {
|
|
22
|
+
let { originText } = this.thyPopoverEditRef.componentInstance;
|
|
23
|
+
if (originText && originText !== value.element.children[0].text) {
|
|
24
|
+
this.thyPopoverEditRef.componentInstance.originText = value.element.children[0].text;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
get linkHoverOpened() {
|
|
30
|
+
return this.thyPopoverHoverRef && this.thyPopoverHoverRef.componentInstance;
|
|
31
|
+
}
|
|
32
|
+
get linkEditOpened() {
|
|
33
|
+
return this.thyPopoverEditRef && this.thyPopoverEditRef.componentInstance;
|
|
34
|
+
}
|
|
35
|
+
ngOnInit() {
|
|
36
|
+
super.ngOnInit();
|
|
37
|
+
}
|
|
38
|
+
closeHoverPopover() {
|
|
39
|
+
if (this.linkHoverOpened) {
|
|
40
|
+
this.thyPopoverHoverRef.close();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
mousedownHandle(event) {
|
|
44
|
+
if (!this.readonly && !this.editor.disabled) {
|
|
45
|
+
this.openLinkHover();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
openLinkEdit(tag) {
|
|
49
|
+
if (this.linkHoverOpened) {
|
|
50
|
+
this.thyPopoverHoverRef.afterClosed().subscribe(() => {
|
|
51
|
+
this.internalOpenLinkEdit(tag);
|
|
52
|
+
});
|
|
53
|
+
this.thyPopover.close();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.internalOpenLinkEdit(tag);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
isLinkEditOpenedByDom(dom) {
|
|
60
|
+
return this.linkEditOpened && this.thyPopoverEditRef.componentInstance.dom === dom;
|
|
61
|
+
}
|
|
62
|
+
closeEditPopover(type) {
|
|
63
|
+
if (this.linkEditOpened) {
|
|
64
|
+
this.thyPopoverEditRef.close(type);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
openLinkHover() {
|
|
68
|
+
const dom = this.nativeElement;
|
|
69
|
+
const url = this.element.url;
|
|
70
|
+
if (this.linkHoverOpened) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.thyPopoverHoverRef = this.thyPopover.open(TheLinkHoverComponent, {
|
|
74
|
+
initialState: {
|
|
75
|
+
link: url,
|
|
76
|
+
dom: dom,
|
|
77
|
+
editHandle: () => {
|
|
78
|
+
this.openLinkEdit(LinkTags.edit);
|
|
79
|
+
},
|
|
80
|
+
deleteHandle: () => {
|
|
81
|
+
Transforms.unwrapNodes(this.editor, { match: n => Element.isElement(n) && n.type === ElementKinds.link });
|
|
82
|
+
this.closeHoverPopover();
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
origin: dom,
|
|
86
|
+
placement: 'bottomLeft',
|
|
87
|
+
offset: 8,
|
|
88
|
+
minWidth: 0,
|
|
89
|
+
hasBackdrop: false,
|
|
90
|
+
outsideClosable: true,
|
|
91
|
+
viewContainerRef: this.viewContainerRef,
|
|
92
|
+
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
|
93
|
+
panelClass: 'the-link-over'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
internalOpenLinkEdit(tag) {
|
|
97
|
+
const link = this.element.url;
|
|
98
|
+
SlateNode.get(this.editor, this.editor.selection.focus.path);
|
|
99
|
+
this.thyPopoverEditRef = this.thyPopover.open(TheLinkEditComponent, {
|
|
100
|
+
initialState: {
|
|
101
|
+
tag,
|
|
102
|
+
editor: this.editor,
|
|
103
|
+
node: this.element,
|
|
104
|
+
text: SlateNode.string(this.element),
|
|
105
|
+
link,
|
|
106
|
+
originSelection: this.editor.selection
|
|
107
|
+
},
|
|
108
|
+
minWidth: 0,
|
|
109
|
+
origin: this.elementRef.nativeElement,
|
|
110
|
+
backdropClosable: true,
|
|
111
|
+
placement: 'bottomLeft',
|
|
112
|
+
offset: 8,
|
|
113
|
+
hasBackdrop: false,
|
|
114
|
+
originActiveClass: null,
|
|
115
|
+
viewContainerRef: this.viewContainerRef,
|
|
116
|
+
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
|
117
|
+
panelClass: 'the-link-edit'
|
|
118
|
+
});
|
|
119
|
+
this.cdr.markForCheck();
|
|
120
|
+
}
|
|
121
|
+
close(type) {
|
|
122
|
+
this.closeHoverPopover();
|
|
123
|
+
this.closeEditPopover(type);
|
|
124
|
+
}
|
|
125
|
+
ngOnDestroy() {
|
|
126
|
+
super.ngOnDestroy();
|
|
127
|
+
this.close(LinkCloseTypes.destroy);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
TheBaseLinkComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheBaseLinkComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.ThyPopover }, { token: i2.Overlay }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
131
|
+
TheBaseLinkComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheBaseLinkComponent, selector: "[TheBaseLinkComponent]", host: { listeners: { "click": "mousedownHandle($event)" } }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
|
|
132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheBaseLinkComponent, decorators: [{
|
|
133
|
+
type: Component,
|
|
134
|
+
args: [{
|
|
135
|
+
selector: '[TheBaseLinkComponent]',
|
|
136
|
+
template: ''
|
|
137
|
+
}]
|
|
138
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.ThyPopover }, { type: i2.Overlay }, { type: i0.ViewContainerRef }]; }, propDecorators: { mousedownHandle: [{
|
|
139
|
+
type: HostListener,
|
|
140
|
+
args: ['click', ['$event']]
|
|
141
|
+
}] } });
|
|
142
|
+
export class TheLinkComponent extends TheBaseLinkComponent {
|
|
143
|
+
constructor() {
|
|
144
|
+
super(...arguments);
|
|
145
|
+
// Put this at the start and end of an inline component to work around this Chromium bug:
|
|
146
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1249405
|
|
147
|
+
this.inlineChromiumBugfix = String.fromCodePoint(160);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
TheLinkComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheLinkComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
151
151
|
TheLinkComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheLinkComponent, selector: "a[theLink]", host: { attributes: { "target": "_blank" }, properties: { "attr.href": "element.url" } }, usesInheritance: true, ngImport: i0, template: ` <span contenteditable="false" class="the-break-char">{{ inlineChromiumBugfix }}</span>
|
|
152
152
|
<span><slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children></span>
|
|
153
|
-
<span contenteditable="false" class="the-break-char">{{ inlineChromiumBugfix }}</span>`, isInline: true, components: [{ type: i3.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
|
|
154
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheLinkComponent, decorators: [{
|
|
155
|
-
type: Component,
|
|
156
|
-
args: [{
|
|
157
|
-
selector: 'a[theLink]',
|
|
153
|
+
<span contenteditable="false" class="the-break-char">{{ inlineChromiumBugfix }}</span>`, isInline: true, components: [{ type: i3.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
|
|
154
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheLinkComponent, decorators: [{
|
|
155
|
+
type: Component,
|
|
156
|
+
args: [{
|
|
157
|
+
selector: 'a[theLink]',
|
|
158
158
|
template: ` <span contenteditable="false" class="the-break-char">{{ inlineChromiumBugfix }}</span>
|
|
159
159
|
<span><slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children></span>
|
|
160
|
-
<span contenteditable="false" class="the-break-char">{{ inlineChromiumBugfix }}</span>`,
|
|
161
|
-
host: {
|
|
162
|
-
'[attr.href]': 'element.url',
|
|
163
|
-
target: '_blank'
|
|
164
|
-
}
|
|
165
|
-
}]
|
|
166
|
-
}] });
|
|
160
|
+
<span contenteditable="false" class="the-break-char">{{ inlineChromiumBugfix }}</span>`,
|
|
161
|
+
host: {
|
|
162
|
+
'[attr.href]': 'element.url',
|
|
163
|
+
target: '_blank'
|
|
164
|
+
}
|
|
165
|
+
}]
|
|
166
|
+
}] });
|
|
167
167
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGluay5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9zcmMvcGx1Z2lucy9saW5rL2xpbmsuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxTQUFTLEVBQXNFLFlBQVksRUFBVSxNQUFNLGVBQWUsQ0FBQztBQUVwSSxPQUFPLEVBQVUsT0FBTyxFQUFFLElBQUksSUFBSSxTQUFTLEVBQUUsVUFBVSxFQUFRLE1BQU0sT0FBTyxDQUFDO0FBQzdFLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUUvQyxPQUFPLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUMzRCxPQUFPLEVBQUUsY0FBYyxFQUFFLFFBQVEsRUFBRSxNQUFNLGNBQWMsQ0FBQztBQUN4RCxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUNyRSxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQzs7Ozs7QUFPbEUsTUFBTSxPQUFPLG9CQUFxQixTQUFRL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wZW5lZCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMudGh5UG9wb3ZlckhvdmVyUmVmID0gdGhpcy50aHlQb3BvdmVyLm9wZW4oVGhlTGlua0hvdmVyQ29tcG9uZW50LCB7XG4gICAgICAgICAgICBpbml0aWFsU3RhdGU6IHtcbiAgICAgICAgICAgICAgICBsaW5rOiB1cmwsXG4gICAgICAgICAgICAgICAgZG9tOiBkb20sXG4gICAgICAgICAgICAgICAgZWRpdEhhbmRsZTogKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZW5MaW5rRWRpdChMaW5rVGFncy5lZGl0KTtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRlbGV0ZUhhbmRsZTogKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBUcmFuc2Zvcm1zLnVud3JhcE5vZGVzKHRoaXMuZWRpdG9yLCB7IG1hdGNoOiBuID0+IEVsZW1lbnQuaXNFbGVtZW50KG4pICYmIG4udHlwZSA9PT0gRWxlbWVudEtpbmRzLmxpbmsgfSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VIb3ZlclBvcG92ZXIoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgb3JpZ2luOiBkb20sXG4gICAgICAgICAgICBwbGFjZW1lbnQ6ICdib3R0b21MZWZ0JyxcbiAgICAgICAgICAgIG9mZnNldDogOCxcbiAgICAgICAgICAgIG1pbldpZHRoOiAwLFxuICAgICAgICAgICAgaGFzQmFja2Ryb3A6IGZhbHNlLFxuICAgICAgICAgICAgb3V0c2lkZUNsb3NhYmxlOiB0cnVlLFxuICAgICAgICAgICAgdmlld0NvbnRhaW5lclJlZjogdGhpcy52aWV3Q29udGFpbmVyUmVmLFxuICAgICAgICAgICAgc2Nyb2xsU3RyYXRlZ3k6IHRoaXMub3ZlcmxheS5zY3JvbGxTdHJhdGVnaWVzLnJlcG9zaXRpb24oKSxcbiAgICAgICAgICAgIHBhbmVsQ2xhc3M6ICd0aGUtbGluay1vdmVyJ1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBwcml2YXRlIGludGVybmFsT3BlbkxpbmtFZGl0KHRhZzogTGlua1RhZ3MpIHtcbiAgICAgICAgY29uc3QgbGluayA9IHRoaXMuZWxlbWVudC51cmw7XG4gICAgICAgIFNsYXRlTm9kZS5nZXQodGhpcy5lZGl0b3IsIHRoaXMuZWRpdG9yLnNlbGVjdGlvbi5mb2N1cy5wYXRoKTtcbiAgICAgICAgdGhpcy50aHlQb3BvdmVyRWRpdFJlZiA9IHRoaXMudGh5UG9wb3Zlci5vcGVuKFRoZUxpbmtFZGl0Q29tcG9uZW50LCB7XG4gICAgICAgICAgICBpbml0aWFsU3RhdGU6IHtcbiAgICAgICAgICAgICAgICB0YWcsXG4gICAgICAgICAgICAgICAgZWRpdG9yOiB0aGlzLmVkaXRvcixcbiAgICAgICAgICAgICAgICBub2RlOiB0aGlzLmVsZW1lbnQsXG4gICAgICAgICAgICAgICAgdGV4dDogU2xhdGVOb2RlLnN0cmluZyh0aGlzLmVsZW1lbnQpLFxuICAgICAgICAgICAgICAgIGxpbmssXG4gICAgICAgICAgICAgICAgb3JpZ2luU2VsZWN0aW9uOiB0aGlzLmVkaXRvci5zZWxlY3Rpb25cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBtaW5XaWR0aDogMCxcbiAgICAgICAgICAgIG9yaWdpbjogdGhpcy5lbGVtZW50UmVmLm5hdGl2ZUVsZW1lbnQsXG4gICAgICAgICAgICBiYWNrZHJvcENsb3NhYmxlOiB0cnVlLFxuICAgICAgICAgICAgcGxhY2VtZW50OiAnYm90dG9tTGVmdCcsXG4gICAgICAgICAgICBvZmZzZXQ6IDgsXG4gICAgICAgICAgICBoYXNCYWNrZHJvcDogZmFsc2UsXG4gICAgICAgICAgICBvcmlnaW5BY3RpdmVDbGFzczogbnVsbCxcbiA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9zcGFuPmAsXG4gICAgICAgIGhvc3Q6IHtcbiAgICAgICAgICAgICdbYXR0ci5ocmVmXSc6ICdlbGVtZW50LnVybCcsXG4gICAgICAgICAgICB0YXJnZXQ6ICdfYmxhbmsnXG4gICAgICAgIH1cbn0pXG5leHBvcnQgY2xhc3MgVGhlTGlua0NvbXBvbmVudCBleHRlbmRzIFRoZUJhc2VMaW5rQ29tcG9uZW50IHtcbiAgICAvLyBQdXQgdGhpcyBhdCB0aGUgc3RhcnQgYW5kIGVuZCBvZiBhbiBpbmxpbmUgY29tcG9uZW50IHRvIHdvcmsgYXJvdW5kIHRoaXMgQ2hyb21pdW0gYnVnOlxuICAgIC8vIGh0dHBzOi8vYnVncy5jaHJvbWl1bS5vcmcvcC9jaHJvbWl1bS9pc3N1ZXMvZGV0YWlsP2lkPTEyNDk0MDVcbiAgICBpbmxpbmVDaHJvbWl1bUJ1Z2ZpeCA9IFN0cmluZy5mcm9tQ29kZVBvaW50KDE2MCk7XG59Il19
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { Range, Transforms, Editor, Element, Node } from 'slate';
|
|
2
|
-
import { ELEMENT_TO_COMPONENT } from 'slate-angular';
|
|
3
|
-
import { ElementKinds, LINK_DEFAULT_TEXT } from '../../constants';
|
|
4
|
-
import { getAboveByType } from '../../queries/get-above-by-type';
|
|
5
|
-
import { LinkTags } from './link.types';
|
|
6
|
-
export const LinkEditor = {
|
|
7
|
-
insertLink(editor) {
|
|
8
|
-
if (Range.isCollapsed(editor.selection)) {
|
|
9
|
-
Promise.resolve()
|
|
10
|
-
.then(() => {
|
|
11
|
-
LinkEditor.wrapLink(editor, LINK_DEFAULT_TEXT, '');
|
|
12
|
-
})
|
|
13
|
-
.then(() => {
|
|
14
|
-
const [linkNode] = getAboveByType(editor, ElementKinds.link);
|
|
15
|
-
const linkComponent = ELEMENT_TO_COMPONENT.get(linkNode);
|
|
16
|
-
linkComponent.openLinkEdit(LinkTags.insert);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
const isActive = LinkEditor.isLinkActive(editor);
|
|
21
|
-
if (isActive) {
|
|
22
|
-
LinkEditor.unwrapLink(editor);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const fragment = Node.fragment(editor, editor.selection)[0];
|
|
26
|
-
const selectNode = Node.get(fragment, []);
|
|
27
|
-
const selectText = Node.string(selectNode);
|
|
28
|
-
Promise.resolve()
|
|
29
|
-
.then(() => {
|
|
30
|
-
LinkEditor.wrapLink(editor, selectText, '');
|
|
31
|
-
})
|
|
32
|
-
.then(() => {
|
|
33
|
-
const [linkNode] = getAboveByType(editor, ElementKinds.link);
|
|
34
|
-
const linkComponent = ELEMENT_TO_COMPONENT.get(linkNode);
|
|
35
|
-
linkComponent.openLinkEdit(LinkTags.insert);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
isLinkActive(editor) {
|
|
40
|
-
const [link] = Editor.nodes(editor, { match: n => Element.isElement(n) && n.type === ElementKinds.link });
|
|
41
|
-
return !!link;
|
|
42
|
-
},
|
|
43
|
-
wrapLink(editor, text, url) {
|
|
44
|
-
if (LinkEditor.isLinkActive(editor)) {
|
|
45
|
-
LinkEditor.unwrapLink(editor);
|
|
46
|
-
}
|
|
47
|
-
const { selection } = editor;
|
|
48
|
-
const isCollapsed = selection && Range.isCollapsed(selection);
|
|
49
|
-
const link = {
|
|
50
|
-
type: ElementKinds.link,
|
|
51
|
-
url,
|
|
52
|
-
children: isCollapsed ? [{ text }] : []
|
|
53
|
-
};
|
|
54
|
-
if (isCollapsed) {
|
|
55
|
-
Transforms.insertNodes(editor, link);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
Transforms.wrapNodes(editor, link, { split: true });
|
|
59
|
-
Transforms.collapse(editor, { edge: 'end' });
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
unwrapLink(editor) {
|
|
63
|
-
Transforms.unwrapNodes(editor, { match: n => Element.isElement(n) && n.type === ElementKinds.link });
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
1
|
+
import { Range, Transforms, Editor, Element, Node } from 'slate';
|
|
2
|
+
import { ELEMENT_TO_COMPONENT } from 'slate-angular';
|
|
3
|
+
import { ElementKinds, LINK_DEFAULT_TEXT } from '../../constants';
|
|
4
|
+
import { getAboveByType } from '../../queries/get-above-by-type';
|
|
5
|
+
import { LinkTags } from './link.types';
|
|
6
|
+
export const LinkEditor = {
|
|
7
|
+
insertLink(editor) {
|
|
8
|
+
if (Range.isCollapsed(editor.selection)) {
|
|
9
|
+
Promise.resolve()
|
|
10
|
+
.then(() => {
|
|
11
|
+
LinkEditor.wrapLink(editor, LINK_DEFAULT_TEXT, '');
|
|
12
|
+
})
|
|
13
|
+
.then(() => {
|
|
14
|
+
const [linkNode] = getAboveByType(editor, ElementKinds.link);
|
|
15
|
+
const linkComponent = ELEMENT_TO_COMPONENT.get(linkNode);
|
|
16
|
+
linkComponent.openLinkEdit(LinkTags.insert);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const isActive = LinkEditor.isLinkActive(editor);
|
|
21
|
+
if (isActive) {
|
|
22
|
+
LinkEditor.unwrapLink(editor);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const fragment = Node.fragment(editor, editor.selection)[0];
|
|
26
|
+
const selectNode = Node.get(fragment, []);
|
|
27
|
+
const selectText = Node.string(selectNode);
|
|
28
|
+
Promise.resolve()
|
|
29
|
+
.then(() => {
|
|
30
|
+
LinkEditor.wrapLink(editor, selectText, '');
|
|
31
|
+
})
|
|
32
|
+
.then(() => {
|
|
33
|
+
const [linkNode] = getAboveByType(editor, ElementKinds.link);
|
|
34
|
+
const linkComponent = ELEMENT_TO_COMPONENT.get(linkNode);
|
|
35
|
+
linkComponent.openLinkEdit(LinkTags.insert);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
isLinkActive(editor) {
|
|
40
|
+
const [link] = Editor.nodes(editor, { match: n => Element.isElement(n) && n.type === ElementKinds.link });
|
|
41
|
+
return !!link;
|
|
42
|
+
},
|
|
43
|
+
wrapLink(editor, text, url) {
|
|
44
|
+
if (LinkEditor.isLinkActive(editor)) {
|
|
45
|
+
LinkEditor.unwrapLink(editor);
|
|
46
|
+
}
|
|
47
|
+
const { selection } = editor;
|
|
48
|
+
const isCollapsed = selection && Range.isCollapsed(selection);
|
|
49
|
+
const link = {
|
|
50
|
+
type: ElementKinds.link,
|
|
51
|
+
url,
|
|
52
|
+
children: isCollapsed ? [{ text }] : []
|
|
53
|
+
};
|
|
54
|
+
if (isCollapsed) {
|
|
55
|
+
Transforms.insertNodes(editor, link);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
Transforms.wrapNodes(editor, link, { split: true });
|
|
59
|
+
Transforms.collapse(editor, { edge: 'end' });
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
unwrapLink(editor) {
|
|
63
|
+
Transforms.unwrapNodes(editor, { match: n => Element.isElement(n) && n.type === ElementKinds.link });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGluay5lZGl0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9zcmMvcGx1Z2lucy9saW5rL2xpbmsuZWRpdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBRSxPQUFPLEVBQUUsSUFBSSxFQUFFLE1BQU0sT0FBTyxDQUFDO0FBQ2pFLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUVyRCxPQUFPLEVBQUUsWU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PT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IFtsaW5rTm9kZV0gPSBnZXRBYm92ZUJ5VHlwZShlZGl0b3IsIEVsZW1lbnRLaW5kcy5saW5rKTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rQ29tcG9uZW50ID0gRUxFTUVOVF9UT19DT01QT05FTlQuZ2V0KGxpbmtOb2RlKSBhcyBUaGVMaW5rQ29tcG9uZW50O1xyXG4gICAgICAgICAgICAgICAgICAgIGxpbmtDb21wb25lbnQub3BlbkxpbmtFZGl0KExpbmtUYWdzLmluc2VydCk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICBjb25zdCBpc0FjdGl2ZSA9IExpbmtFZGl0b3IuaXNMaW5rQWN0aXZlKGVkaXRvcik7XHJcbiAgICAgICAgICAgIGlmIChpc0FjdGl2ZSkge1xyXG4gICAgICAgICAgICAgICAgTGlua0VkaXRvci51bndyYXBMaW5rKGVkaXRvcik7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGZyYWdtZW50ID0gTm9kZS5mcmFnbWVudChlZGl0b3IsIGVkaXRvci5zZWxlY3Rpb24pWzBdO1xyXG4gICAgICAgICAgICBjb25zdCBzZWxlY3ROb2RlID0gTm9kZS5nZXQoZnJhZ21lbnQsIFtdKTtcclxuICAgICAgICAgICAgY29uc3Qgc2VsZWN0VGV4dCA9IE5vZGUuc3RyaW5nKHNlbGVjdE5vZGUpO1xyXG5cclxuICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKClcclxuICAgICAgICAgICAgICAgIC50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBMaW5rRWRpdG9yLndyYXBMaW5rKGVkaXRvciwgc2VsZWN0VGV4dCwgJycpO1xyXG4gICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgIC50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBbbGlua05vZGVdID0gZ2V0QWJvdmVCeVR5cGUoZWRpdG9yLCBFbGVtZW50S2luZHMubGluayk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGlua0NvbXBvbmVudCA9IEVMRU1FTlRfVE9fQ09NUE9ORU5ULmdldChsaW5rTm9kZSkgYXMgVGhlTGlua0NvbXBvbmVudDtcclxuICAgICAgICAgICAgICAgICAgICBsaW5rQ29tcG9uZW50Lm9wZW5MaW5rRWRpdChMaW5rVGFncy5pbnNlcnQpO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfVxyXG4gICAgfSxcclxuICAgIGlzTGlua0FjdGl2ZShlZGl0b3I6IEVkaXRvcikge1xyXG4gICAgICAgIGNvbnN0IFtsaW5rXSA9IEVkaXRvci5ub2RlcyhlZGl0b3IsIHsgbWF0Y2g6IG4gPT4gRWxlbWVudC5pc0VsZW1lbnQobikgJiYgbi50eXBlID09PSBFbGVtZW50S2luZHMubGluayB9KTtcclxuICAgICAgICByZXR1cm4gISFsaW5rO1xyXG4gICAgfSxcclxuICAgIHdyYXBMaW5rKGVkaXRvcjogRWRpdG9yLCB0ZXh0OiBzdHJpbmcsIHVybDogc3RyaW5nKSB7XHJcbiAgICAgICAgaWYgKExpbmtFZGl0b3IuaXNMaW5rQWN0aXZlKGVkaXRvcikpIHtcclxuICAgICAgICAgICAgTGlua0VkaXRvci51bndyYXBMaW5rKGVkaXRvcik7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGNvbnN0IHsgc2VsZWN0aW9uIH0gPSBlZGl0b3I7XHJcbiAgICAgICAgY29uc3QgaXNDb2xsYXBzZWQgPSBzZWxlY3Rpb24gJiYgUmFuZ2UuaXNDb2xsYXBzZWQoc2VsZWN0aW9uKTtcclxuICAgICAgICBjb25zdCBsaW5rOiBMaW5rRWxlbWVudCA9IHtcclxuICAgICAgICAgICA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