@worktile/theia 3.0.9 → 3.0.12
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 +14420 -14386
- 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-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 +100 -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 +208 -202
- 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 +395 -370
- 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 +58 -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 +14 -14
- 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-all-nodes-by-type.js +5 -0
- 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 +13203 -13168
- 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 +77 -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 -58
- 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 -2
- 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-all-nodes-by-type.d.ts +3 -0
- 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,13 +1,13 @@
|
|
|
1
|
-
import * as TheQueries from '../../../queries';
|
|
2
|
-
import { ElementKinds } from '../../../constants';
|
|
3
|
-
/**
|
|
4
|
-
* Is the selection focus at the start of its parent block.
|
|
5
|
-
*/
|
|
6
|
-
export const isSelectionAtListItemStart = (editor) => {
|
|
7
|
-
const listItemEntry = TheQueries.getAboveByType(editor, [ElementKinds.listItem]);
|
|
8
|
-
if (listItemEntry) {
|
|
9
|
-
return TheQueries.isStart(editor, editor.selection.focus, listItemEntry[1]);
|
|
10
|
-
}
|
|
11
|
-
return false;
|
|
12
|
-
};
|
|
1
|
+
import * as TheQueries from '../../../queries';
|
|
2
|
+
import { ElementKinds } from '../../../constants';
|
|
3
|
+
/**
|
|
4
|
+
* Is the selection focus at the start of its parent block.
|
|
5
|
+
*/
|
|
6
|
+
export const isSelectionAtListItemStart = (editor) => {
|
|
7
|
+
const listItemEntry = TheQueries.getAboveByType(editor, [ElementKinds.listItem]);
|
|
8
|
+
if (listItemEntry) {
|
|
9
|
+
return TheQueries.isSt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MgfSBmcm9tICcuLi8uLi8uLi9jb25zdGFudHMnO1xuXG4vKipcbiAqIElzIHRoZSBzZWxlY3Rpb24gZm9jdXMgYXQgdGhlIHN0YXJ0IG9mIGl0cyBwYXJlbnQgYmxvY2suXG4gKi9cbmV4cG9ydCBjb25zdCBpc1NlbGVjdGlvbkF0TGlzdEl0ZW1TdGFydCA9IChlZGl0b3I6IEVkaXRvcikgPT4ge1xuICAgIGNvbnN0IGxpc3RJdGVtRW50cnkgPSBUaGVRdWVyaWVzLmdldEFib3ZlQnlUeXBlKGVkaXRvciwgW0VsZW1lbnRLaW5kcy5saXN0SXRlbV0pO1xuICAgIGlmIChsaXN0SXRlbUVudHJ5KSB7XG4gICAgICAgIHJldHVybiBUaGVRdWVyaWVzLmlzU3RhcnQoZWRpdG9yLCBlZGl0b3Iuc2VsZWN0aW9uLmZvY3VzLCBsaXN0SXRlbUVudHJ5WzFdKTtcbiAgICB9XG4gICAgcmV0dXJuIGZhbHNlO1xufTtcbiJdfQ==
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Range, Path } from 'slate';
|
|
2
|
-
import { getAboveByType } from '../../../queries/get-above-by-type';
|
|
3
|
-
import { ElementKinds } from '../../../constants/node-types';
|
|
4
|
-
/**
|
|
5
|
-
* Is the selection in same li
|
|
6
|
-
*/
|
|
7
|
-
export const isSelectionInSameListItem = (editor) => {
|
|
8
|
-
const { selection } = editor;
|
|
9
|
-
if (!selection) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
const [start, end] = Range.edges(selection);
|
|
13
|
-
const startListItemEntry = getAboveByType(editor, ElementKinds.listItem, { at: start.path });
|
|
14
|
-
const endListItemEntry = getAboveByType(editor, ElementKinds.listItem, { at: end.path });
|
|
15
|
-
return startListItemEntry && endListItemEntry && Path.equals(startListItemEntry[1], endListItemEntry[1]);
|
|
16
|
-
};
|
|
1
|
+
import { Range, Path } from 'slate';
|
|
2
|
+
import { getAboveByType } from '../../../queries/get-above-by-type';
|
|
3
|
+
import { ElementKinds } from '../../../constants/node-types';
|
|
4
|
+
/**
|
|
5
|
+
* Is the selection in same li
|
|
6
|
+
*/
|
|
7
|
+
export const isSelectionInSameListItem = (editor) => {
|
|
8
|
+
const { selection } = editor;
|
|
9
|
+
if (!selection) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const [start, end] = Range.edges(selection);
|
|
13
|
+
const startListItemEntry = getAboveByType(editor, ElementKinds.listItem, { at: start.path });
|
|
14
|
+
const endListItemEntry = getAboveByType(editor, ElementKinds.listItem, { at: end.path });
|
|
15
|
+
return startListItemEntry && endListItemEntry && Path.equals(startListItemEntry[1], endListItemEntry[1]);
|
|
16
|
+
};
|
|
17
17
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaXMtc2VsZWN0aW9uLWluLXNhbWUtbGlzdC1pdGVtLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvc3JjL3BsdWdpbnMvbGlzdC9xdWVyaWVzL2lzLXNlbGVjdGlvbi1pbi1zYW1lLWxpc3QtaXRlbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQVUsS0FBSyxFQUFFLElBQUksRUFBRSxNQUFNLE9BQU8sQ0FBQztBQUM1QyxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFDcEUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTdEOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0seUJBQXlCLEdBQUcsQ0FDckMsTUFBYyxFQUNoQixFQUFFO0lBQ0EsTUFBTSxFQUFFLFNBQVMsRUFBRSxHQUFHLE1BQU0sQ0FBQztJQUU3QixJQUFJLENBQUMsU0FBUyxFQUFFO1FBQ1osT0FBTyxLQUFLLENBQUM7S0F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HtcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIGNvbnN0IFtzdGFydCwgZW5kXSA9IFJhbmdlLmVkZ2VzKHNlbGVjdGlvbik7XG4gICAgY29uc3Qgc3RhcnRMaXN0SXRlbUVudHJ5ID0gZ2V0QWJvdmVCeVR5cGUoZWRpdG9yLCBFbGVtZW50S2luZHMubGlzdEl0ZW0sIHsgYXQ6IHN0YXJ0LnBhdGggfSk7XG4gICAgY29uc3QgZW5kTGlzdEl0ZW1FbnRyeSA9IGdldEFib3ZlQnlUeXBlKGVkaXRvciwgRWxlbWVudEtpbmRzLmxpc3RJdGVtLCB7IGF0OiBlbmQucGF0aCB9KTtcblxuICAgIHJldHVybiBzdGFydExpc3RJdGVtRW50cnkgJiYgZW5kTGlzdEl0ZW1FbnRyeSAmJiBQYXRoLmVxdWFscyhzdGFydExpc3RJdGVtRW50cnlbMV0sIGVuZExpc3RJdGVtRW50cnlbMV0pO1xufTsiXX0=
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { hasListInListItem } from './has-list-in-list-item';
|
|
2
|
-
import { isNodeTypeList } from './is-node-type-list';
|
|
3
|
-
/**
|
|
4
|
-
* list 中 是否是单个listItem,且listItem没有子列表
|
|
5
|
-
*/
|
|
6
|
-
export const isSingleListItem = (list) => {
|
|
7
|
-
return isNodeTypeList(list) && list.children.length === 1 && !hasListInListItem(list.children[0]);
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
1
|
+
import { hasListInListItem } from './has-list-in-list-item';
|
|
2
|
+
import { isNodeTypeList } from './is-node-type-list';
|
|
3
|
+
/**
|
|
4
|
+
* list 中 是否是单个listItem,且listItem没有子列表
|
|
5
|
+
*/
|
|
6
|
+
export const isSingleListItem = (list) => {
|
|
7
|
+
return isNodeTypeList(list) && list.children.length === 1 && !hasListInListItem(list.children[0]);
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZX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GlzdChsaXN0KSAmJiAobGlzdC5jaGlsZHJlbiBhcyBOb2RlW10pLmxlbmd0aCA9PT0gMSAmJiAhaGFzTGlzdEluTGlzdEl0ZW0obGlzdC5jaGlsZHJlblswXSBhcyBFbGVtZW50KTtcbn07XG4iXX0=
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { Node, Path, Transforms, Editor } from 'slate';
|
|
2
|
-
import * as TheQueries from '../../../queries';
|
|
3
|
-
import { hasListInListItem } from '../queries/has-list-in-list-item';
|
|
4
|
-
import { getListItemEntry } from '../queries/get-list-item-entry';
|
|
5
|
-
export const insertListData = (editor, { fromList, toListItemEntry }) => {
|
|
6
|
-
const { children } = fromList;
|
|
7
|
-
const [toListItem, toListItemPath] = toListItemEntry;
|
|
8
|
-
const nextListItemPath = Path.next(toListItemPath);
|
|
9
|
-
const toListItemIsEmptyParagraph = TheQueries.isEmptyParagraph(editor, editor.selection.anchor);
|
|
10
|
-
const hasSubList = hasListInListItem(toListItem);
|
|
11
|
-
let selectPath = [...toListItemPath];
|
|
12
|
-
const liIndex = selectPath.pop();
|
|
13
|
-
selectPath = [...selectPath, liIndex + children.length];
|
|
14
|
-
Editor.withoutNormalizing(editor, () => {
|
|
15
|
-
if (toListItemIsEmptyParagraph && hasSubList) {
|
|
16
|
-
Transforms.insertNodes(editor, children, { at: nextListItemPath });
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
const insertListItemPath = toListItemIsEmptyParagraph ? toListItemPath : nextListItemPath;
|
|
20
|
-
// 如果粘贴目标listItem为空,则先删除listItem
|
|
21
|
-
if (toListItemIsEmptyParagraph) {
|
|
22
|
-
Transforms.removeNodes(editor, { at: insertListItemPath });
|
|
23
|
-
selectPath = Path.previous(selectPath);
|
|
24
|
-
}
|
|
25
|
-
Transforms.insertNodes(editor, children, { at: insertListItemPath });
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* 粘贴目标lisItem有子列表
|
|
29
|
-
*/
|
|
30
|
-
if (hasSubList) {
|
|
31
|
-
const paragraphPath = toListItemPath.concat([0]);
|
|
32
|
-
const nextSubListPath = Path.next(paragraphPath);
|
|
33
|
-
// 判断粘贴数据是否是多级
|
|
34
|
-
if (hasListInListItem(fromList.children[0])) {
|
|
35
|
-
// 设置粘贴后正确选区
|
|
36
|
-
Transforms.select(editor, Editor.end(editor, nextListItemPath));
|
|
37
|
-
// 获取当前选区所在listItem entry
|
|
38
|
-
const currentListItemEntry = getListItemEntry(editor, {});
|
|
39
|
-
// 获取粘贴目标listItem中的子列表
|
|
40
|
-
const { children: subListChildren } = Node.get(editor, nextSubListPath);
|
|
41
|
-
/**
|
|
42
|
-
* 复制子列表数据
|
|
43
|
-
* 之所以是复制,而不是移动,因为无法单纯一次性移动子列表的所有listItem(不包含subList本身)到目标位置,
|
|
44
|
-
* 需要循环移动才可以
|
|
45
|
-
**/
|
|
46
|
-
Transforms.insertNodes(editor, subListChildren, {
|
|
47
|
-
at: Path.next(currentListItemEntry.listItem[1])
|
|
48
|
-
});
|
|
49
|
-
// 删除已被复制后无用的listItem/listItem subList
|
|
50
|
-
Transforms.delete(editor, {
|
|
51
|
-
at: toListItemIsEmptyParagraph ? toListItemPath : nextSubListPath
|
|
52
|
-
});
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
Transforms.select(editor, Editor.end(editor, selectPath));
|
|
56
|
-
// 粘贴数据不是多级
|
|
57
|
-
const currentListItemEntry = getListItemEntry(editor, {});
|
|
58
|
-
Transforms.moveNodes(editor, {
|
|
59
|
-
at: nextSubListPath,
|
|
60
|
-
to: currentListItemEntry.listItem[1].concat(1)
|
|
61
|
-
});
|
|
62
|
-
if (toListItemIsEmptyParagraph) {
|
|
63
|
-
Transforms.delete(editor, { at: toListItemPath });
|
|
64
|
-
}
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
// 粘贴目标listItem没有子列表, 设置选区
|
|
69
|
-
Transforms.select(editor, Editor.end(editor, selectPath));
|
|
70
|
-
return;
|
|
71
|
-
};
|
|
1
|
+
import { Node, Path, Transforms, Editor } from 'slate';
|
|
2
|
+
import * as TheQueries from '../../../queries';
|
|
3
|
+
import { hasListInListItem } from '../queries/has-list-in-list-item';
|
|
4
|
+
import { getListItemEntry } from '../queries/get-list-item-entry';
|
|
5
|
+
export const insertListData = (editor, { fromList, toListItemEntry }) => {
|
|
6
|
+
const { children } = fromList;
|
|
7
|
+
const [toListItem, toListItemPath] = toListItemEntry;
|
|
8
|
+
const nextListItemPath = Path.next(toListItemPath);
|
|
9
|
+
const toListItemIsEmptyParagraph = TheQueries.isEmptyParagraph(editor, editor.selection.anchor);
|
|
10
|
+
const hasSubList = hasListInListItem(toListItem);
|
|
11
|
+
let selectPath = [...toListItemPath];
|
|
12
|
+
const liIndex = selectPath.pop();
|
|
13
|
+
selectPath = [...selectPath, liIndex + children.length];
|
|
14
|
+
Editor.withoutNormalizing(editor, () => {
|
|
15
|
+
if (toListItemIsEmptyParagraph && hasSubList) {
|
|
16
|
+
Transforms.insertNodes(editor, children, { at: nextListItemPath });
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const insertListItemPath = toListItemIsEmptyParagraph ? toListItemPath : nextListItemPath;
|
|
20
|
+
// 如果粘贴目标listItem为空,则先删除listItem
|
|
21
|
+
if (toListItemIsEmptyParagraph) {
|
|
22
|
+
Transforms.removeNodes(editor, { at: insertListItemPath });
|
|
23
|
+
selectPath = Path.previous(selectPath);
|
|
24
|
+
}
|
|
25
|
+
Transforms.insertNodes(editor, children, { at: insertListItemPath });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 粘贴目标lisItem有子列表
|
|
29
|
+
*/
|
|
30
|
+
if (hasSubList) {
|
|
31
|
+
const paragraphPath = toListItemPath.concat([0]);
|
|
32
|
+
const nextSubListPath = Path.next(paragraphPath);
|
|
33
|
+
// 判断粘贴数据是否是多级
|
|
34
|
+
if (hasListInListItem(fromList.children[0])) {
|
|
35
|
+
// 设置粘贴后正确选区
|
|
36
|
+
Transforms.select(editor, Editor.end(editor, nextListItemPath));
|
|
37
|
+
// 获取当前选区所在listItem entry
|
|
38
|
+
const currentListItemEntry = getListItemEntry(editor, {});
|
|
39
|
+
// 获取粘贴目标listItem中的子列表
|
|
40
|
+
const { children: subListChildren } = Node.get(editor, nextSubListPath);
|
|
41
|
+
/**
|
|
42
|
+
* 复制子列表数据
|
|
43
|
+
* 之所以是复制,而不是移动,因为无法单纯一次性移动子列表的所有listItem(不包含subList本身)到目标位置,
|
|
44
|
+
* 需要循环移动才可以
|
|
45
|
+
**/
|
|
46
|
+
Transforms.insertNodes(editor, subListChildren, {
|
|
47
|
+
at: Path.next(currentListItemEntry.listItem[1])
|
|
48
|
+
});
|
|
49
|
+
// 删除已被复制后无用的listItem/listItem subList
|
|
50
|
+
Transforms.delete(editor, {
|
|
51
|
+
at: toListItemIsEmptyParagraph ? toListItemPath : nextSubListPath
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
Transforms.select(editor, Editor.end(editor, selectPath));
|
|
56
|
+
// 粘贴数据不是多级
|
|
57
|
+
const currentListItemEntry = getListItemEntry(editor, {});
|
|
58
|
+
Transforms.moveNodes(editor, {
|
|
59
|
+
at: nextSubListPath,
|
|
60
|
+
to: currentListItemEntry.listItem[1].concat(1)
|
|
61
|
+
});
|
|
62
|
+
if (toListItemIsEmptyParagraph) {
|
|
63
|
+
Transforms.delete(editor, { at: toListItemPath });
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
// 粘贴目标listItem没有子列表, 设置选区
|
|
69
|
+
Transforms.select(editor, Editor.end(editor, selectPath));
|
|
70
|
+
return;
|
|
71
|
+
};
|
|
72
72
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zZXJ0LWxpc3QtZGF0YS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY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eyBhdDogdG9MaXN0SXRlbVBhdGggfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICB9KTtcblxuICAgIC8vIOeymOi0tOebruagh2xpc3RJdGVt5rKh5pyJ5a2Q5YiX6KGoLCDorr7nva7pgInljLpcbiAgICBUcmFuc2Zvcm1zLnNlbGVjdChlZGl0b3IsIEVkaXRvci5lbmQoZWRpdG9yLCBzZWxlY3RQYXRoKSk7XG4gICAgcmV0dXJuO1xufTtcbiJdfQ==
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { Editor, Path, Range, Transforms, Element } from 'slate';
|
|
2
|
-
import { TheEditor } from '../../../interfaces';
|
|
3
|
-
import { ElementKinds } from '../../../constants';
|
|
4
|
-
import * as TheQueries from '../../../queries';
|
|
5
|
-
/**
|
|
6
|
-
* Insert list item if selection in li>p.
|
|
7
|
-
*/
|
|
8
|
-
export const insertListItem = (editor) => {
|
|
9
|
-
if (editor.selection && !TheQueries.isRangeAtRoot(editor.selection)) {
|
|
10
|
-
const paragraphEntry = TheQueries.getAboveByType(editor, ElementKinds.paragraph);
|
|
11
|
-
if (!paragraphEntry) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const [, paragraphPath] = paragraphEntry;
|
|
15
|
-
const [listItemNode, listItemPath] = Editor.parent(editor, paragraphPath);
|
|
16
|
-
if (Element.isElement(listItemNode) && listItemNode.type !== ElementKinds.listItem) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!Range.isCollapsed(editor.selection)) {
|
|
20
|
-
Transforms.delete(editor);
|
|
21
|
-
}
|
|
22
|
-
const isEnd = TheQueries.isBlockTextEmptyAfterSelection(editor);
|
|
23
|
-
const nextNodePath = Path.next(paragraphPath);
|
|
24
|
-
const nextListItemPath = Path.next(listItemPath);
|
|
25
|
-
const nextEnd = Editor.end(editor, listItemPath);
|
|
26
|
-
/**
|
|
27
|
-
* If not end, split nodes, wrap a list item on the new paragraph and move it to the next list item
|
|
28
|
-
*/
|
|
29
|
-
if (!isEnd) {
|
|
30
|
-
Editor.withoutNormalizing(editor, () => {
|
|
31
|
-
Transforms.splitNodes(editor, { at: editor.selection, always: true });
|
|
32
|
-
Transforms.wrapNodes(editor, {
|
|
33
|
-
type: ElementKinds.listItem,
|
|
34
|
-
children: []
|
|
35
|
-
}, { at: nextNodePath });
|
|
36
|
-
Transforms.moveNodes(editor, {
|
|
37
|
-
at: nextNodePath,
|
|
38
|
-
to: nextListItemPath
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
/**
|
|
44
|
-
* If end, split nodes
|
|
45
|
-
*/
|
|
46
|
-
Editor.withoutNormalizing(editor, () => {
|
|
47
|
-
Transforms.splitNodes(editor, {
|
|
48
|
-
always: true,
|
|
49
|
-
mode: 'highest',
|
|
50
|
-
match: node => {
|
|
51
|
-
const path = node && TheEditor.findPath(editor, node);
|
|
52
|
-
return path && path.length === nextListItemPath.length;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* If there is a list in the list item, move it to the next list item
|
|
59
|
-
*/
|
|
60
|
-
if (TheQueries.getNode(editor, nextNodePath)) {
|
|
61
|
-
Transforms.moveNodes(editor, {
|
|
62
|
-
at: Editor.range(editor, nextNodePath, nextEnd),
|
|
63
|
-
to: nextListItemPath.concat(1),
|
|
64
|
-
match: node => {
|
|
65
|
-
// TODO: types
|
|
66
|
-
return listItemNode.children.includes(node);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
1
|
+
import { Editor, Path, Range, Transforms, Element } from 'slate';
|
|
2
|
+
import { TheEditor } from '../../../interfaces';
|
|
3
|
+
import { ElementKinds } from '../../../constants';
|
|
4
|
+
import * as TheQueries from '../../../queries';
|
|
5
|
+
/**
|
|
6
|
+
* Insert list item if selection in li>p.
|
|
7
|
+
*/
|
|
8
|
+
export const insertListItem = (editor) => {
|
|
9
|
+
if (editor.selection && !TheQueries.isRangeAtRoot(editor.selection)) {
|
|
10
|
+
const paragraphEntry = TheQueries.getAboveByType(editor, ElementKinds.paragraph);
|
|
11
|
+
if (!paragraphEntry) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const [, paragraphPath] = paragraphEntry;
|
|
15
|
+
const [listItemNode, listItemPath] = Editor.parent(editor, paragraphPath);
|
|
16
|
+
if (Element.isElement(listItemNode) && listItemNode.type !== ElementKinds.listItem) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!Range.isCollapsed(editor.selection)) {
|
|
20
|
+
Transforms.delete(editor);
|
|
21
|
+
}
|
|
22
|
+
const isEnd = TheQueries.isBlockTextEmptyAfterSelection(editor);
|
|
23
|
+
const nextNodePath = Path.next(paragraphPath);
|
|
24
|
+
const nextListItemPath = Path.next(listItemPath);
|
|
25
|
+
const nextEnd = Editor.end(editor, listItemPath);
|
|
26
|
+
/**
|
|
27
|
+
* If not end, split nodes, wrap a list item on the new paragraph and move it to the next list item
|
|
28
|
+
*/
|
|
29
|
+
if (!isEnd) {
|
|
30
|
+
Editor.withoutNormalizing(editor, () => {
|
|
31
|
+
Transforms.splitNodes(editor, { at: editor.selection, always: true });
|
|
32
|
+
Transforms.wrapNodes(editor, {
|
|
33
|
+
type: ElementKinds.listItem,
|
|
34
|
+
children: []
|
|
35
|
+
}, { at: nextNodePath });
|
|
36
|
+
Transforms.moveNodes(editor, {
|
|
37
|
+
at: nextNodePath,
|
|
38
|
+
to: nextListItemPath
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
/**
|
|
44
|
+
* If end, split nodes
|
|
45
|
+
*/
|
|
46
|
+
Editor.withoutNormalizing(editor, () => {
|
|
47
|
+
Transforms.splitNodes(editor, {
|
|
48
|
+
always: true,
|
|
49
|
+
mode: 'highest',
|
|
50
|
+
match: node => {
|
|
51
|
+
const path = node && TheEditor.findPath(editor, node);
|
|
52
|
+
return path && path.length === nextListItemPath.length;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* If there is a list in the list item, move it to the next list item
|
|
59
|
+
*/
|
|
60
|
+
if (TheQueries.getNode(editor, nextNodePath)) {
|
|
61
|
+
Transforms.moveNodes(editor, {
|
|
62
|
+
at: Editor.range(editor, nextNodePath, nextEnd),
|
|
63
|
+
to: nextListItemPath.concat(1),
|
|
64
|
+
match: node => {
|
|
65
|
+
// TODO: types
|
|
66
|
+
return listItemNode.children.includes(node);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
73
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zZXJ0LWxpc3QtaXRlbS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3NyYy9wbHVnaW5zL2xpc3QvdHJhbnNmb3Jtcy9pbnNlcnQtbGlzdC1pdGVtLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLEtBQUssRUFBRSxVQUFVLEVBQUUsT0FBTyxFQUFFLE1BQU0sT0FBTyxDQUFDO0FBQ2pFLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNoRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDbEQsT0FBTyxLQUFLLFVBQVUsTUFBTSxrQkFBa0IsQ0FBQztBQUUvQzs7R0FFRztBQUNILE1BQU0sQ0FBQyxNQUFNL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G4gICAgICAgIGNvbnN0IG5leHRFbmQgPSBFZGl0b3IuZW5kKGVkaXRvciwgbGlzdEl0ZW1QYXRoKTtcblxuICAgICAgICAvKipcbiAgICAgICAgICogSWYgbm90IGVuZCwgc3BsaXQgbm9kZXMsIHdyYXAgYSBsaXN0IGl0ZW0gb24gdGhlIG5ldyBwYXJhZ3JhcGggYW5kIG1vdmUgaXQgdG8gdGhlIG5leHQgbGlzdCBpdGVtXG4gICAgICAgICAqL1xuICAgICAgICBpZiAoIWlzRW5kKSB7XG4gICAgICAgICAgICBFZGl0b3Iud2l0aG91dE5vcm1hbGl6aW5nKGVkaXRvciwgKCkgPT4ge1xuICAgICAgICAgICAgICAgIFRyYW5zZm9ybXMuc3BsaXROb2RlcyhlZGl0b3IsIHsgYXQ6IGVkaXRvci5zZWxlY3Rpb24sIGFsd2F5czogdHJ1ZSB9KTtcbiAgICAgICAgICAgICAgICBUcmFuc2Zvcm1zLndyYXBOb2RlcyhcbiAgICAgICAgICAgICAgICAgICAgZWRpdG9yLFxuICAgICAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBFbGVtZW50S2luZHMubGlzdEl0ZW0sXG4gICAgICAgICAgICAgICAgICAgICAgICBjaGlsZHJlbjogW11cbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgeyBhdDogbmV4dE5vZGVQYXRoIH1cbiAgICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgICAgIFRyYW5zZm9ybXMubW92ZU5vZGVzKGVkaXRvciwge1xuICAgICAgICAgICAgICAgICAgICBhdDogbmV4dE5vZGVQYXRoLFxuICAgICAgICAgICAgICAgICAgICB0bzogbmV4dExpc3RJdGVtUGF0aFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvKipcbiAgICAgICAgICAgICAqIElmIGVuZCwgc3BsaXQgbm9kZXNcbiAgICAgICAgICAgICAqL1xuICAgICAgICAgICAgRWRpdG9yLndpdGhvdXROb3JtYWxpemluZyhlZGl0b3IsICgpID0+IHtcbiAgICAgICAgICAgICAgICBUcmFuc2Zvcm1zLnNwbGl0Tm9kZXMoZWRpdG9yLCB7XG4gICAgICAgICAgICAgICAgICAgIGFsd2F5czogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgbW9kZTogJ2hpZ2hlc3QnLFxuICAgICAgICAgICAgICAgICAgICBtYXRjaDogbm9kZSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoID0gbm9kZSAmJiBUaGVFZGl0b3IuZmluZFBhdGgoZWRpdG9yLCBub2RlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXRoICYmIHBhdGgubGVuZ3RoID09PSBuZXh0TGlzdEl0ZW1QYXRoLmxlbmd0aDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogSWYgdGhlcmUgaXMgYSBsaXN0IGluIHRoZSBsaXN0IGl0ZW0sIG1vdmUgaXQgdG8gdGhlIG5leHQgbGlzdCBpdGVtXG4gICAgICAgICAqL1xuICAgICAgICBpZiAoVGhlUXVlcmllcy5nZXROb2RlKGVkaXRvciwgbmV4dE5vZGVQYXRoKSkge1xuICAgICAgICAgICAgVHJhbnNmb3Jtcy5tb3ZlTm9kZXMoZWRpdG9yLCB7XG4gICAgICAgICAgICAgICAgYXQ6IEVkaXRvci5yYW5nZShlZGl0b3IsIG5leHROb2RlUGF0aCwgbmV4dEVuZCksXG4gICAgICAgICAgICAgICAgdG86IG5leHRMaXN0SXRlbVBhdGguY29uY2F0KDEpLFxuICAgICAgICAgICAgICAgIG1hdGNoOiBub2RlID0+IHtcbiAgICAgICAgICAgICAgICAgICAgLy8gVE9ETzogdHlwZXNcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxpc3RJdGVtTm9kZS5jaGlsZHJlbi5pbmNsdWRlcyhub2RlIGFzIGFueSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG59O1xuIl19
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { Editor, Path, Transforms } from 'slate';
|
|
2
|
-
import { getListItemEntry } from '../queries/get-list-item-entry';
|
|
3
|
-
import { hasListInListItem } from '../queries/has-list-in-list-item';
|
|
4
|
-
import { moveListItemSublistItemsToList } from './move-list-item-sublist-items-to-list';
|
|
5
|
-
import { isNodeTypeList } from '../queries/is-node-type-list';
|
|
6
|
-
export const moveListItemDown = (editor, { list, listItem }) => {
|
|
7
|
-
const [listNode] = list;
|
|
8
|
-
const [, listItemPath] = listItem;
|
|
9
|
-
Editor.withoutNormalizing(editor, () => {
|
|
10
|
-
// 以前的兄弟是新父级
|
|
11
|
-
const previousSiblingItem = Editor.node(editor, Path.previous(listItemPath));
|
|
12
|
-
if (previousSiblingItem) {
|
|
13
|
-
const [previousNode, previousPath] = previousSiblingItem;
|
|
14
|
-
const lastChildIndexOfPreviousNode = previousNode.children.length - 1;
|
|
15
|
-
const lastChildOfPreviousNode = previousNode.children[lastChildIndexOfPreviousNode];
|
|
16
|
-
const newPath = previousPath.concat(isNodeTypeList(lastChildOfPreviousNode)
|
|
17
|
-
? [lastChildIndexOfPreviousNode, lastChildOfPreviousNode.children.length]
|
|
18
|
-
: [previousNode.children.length]);
|
|
19
|
-
if (!isNodeTypeList(lastChildOfPreviousNode)) {
|
|
20
|
-
// 创建新子列表
|
|
21
|
-
const type = listNode.type;
|
|
22
|
-
Transforms.wrapNodes(editor, { type, children: [] }, {
|
|
23
|
-
at: listItemPath
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
// 将当前listItem移动到子列表
|
|
27
|
-
Transforms.moveNodes(editor, {
|
|
28
|
-
at: listItemPath,
|
|
29
|
-
to: newPath
|
|
30
|
-
});
|
|
31
|
-
const currentListItemEntry = getListItemEntry(editor, {});
|
|
32
|
-
if (hasListInListItem(currentListItemEntry.listItem[0])) {
|
|
33
|
-
moveListItemSublistItemsToList(editor, {
|
|
34
|
-
fromListItem: currentListItemEntry.listItem,
|
|
35
|
-
toList: currentListItemEntry.list
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
1
|
+
import { Editor, Path, Transforms } from 'slate';
|
|
2
|
+
import { getListItemEntry } from '../queries/get-list-item-entry';
|
|
3
|
+
import { hasListInListItem } from '../queries/has-list-in-list-item';
|
|
4
|
+
import { moveListItemSublistItemsToList } from './move-list-item-sublist-items-to-list';
|
|
5
|
+
import { isNodeTypeList } from '../queries/is-node-type-list';
|
|
6
|
+
export const moveListItemDown = (editor, { list, listItem }) => {
|
|
7
|
+
const [listNode] = list;
|
|
8
|
+
const [, listItemPath] = listItem;
|
|
9
|
+
Editor.withoutNormalizing(editor, () => {
|
|
10
|
+
// 以前的兄弟是新父级
|
|
11
|
+
const previousSiblingItem = Editor.node(editor, Path.previous(listItemPath));
|
|
12
|
+
if (previousSiblingItem) {
|
|
13
|
+
const [previousNode, previousPath] = previousSiblingItem;
|
|
14
|
+
const lastChildIndexOfPreviousNode = previousNode.children.length - 1;
|
|
15
|
+
const lastChildOfPreviousNode = previousNode.children[lastChildIndexOfPreviousNode];
|
|
16
|
+
const newPath = previousPath.concat(isNodeTypeList(lastChildOfPreviousNode)
|
|
17
|
+
? [lastChildIndexOfPreviousNode, lastChildOfPreviousNode.children.length]
|
|
18
|
+
: [previousNode.children.length]);
|
|
19
|
+
if (!isNodeTypeList(lastChildOfPreviousNode)) {
|
|
20
|
+
// 创建新子列表
|
|
21
|
+
const type = listNode.type;
|
|
22
|
+
Transforms.wrapNodes(editor, { type, children: [] }, {
|
|
23
|
+
at: listItemPath
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// 将当前listItem移动到子列表
|
|
27
|
+
Transforms.moveNodes(editor, {
|
|
28
|
+
at: listItemPath,
|
|
29
|
+
to: newPath
|
|
30
|
+
});
|
|
31
|
+
const currentListItemEntry = getListItemEntry(editor, {});
|
|
32
|
+
if (hasListInListItem(currentListItemEntry.listItem[0])) {
|
|
33
|
+
moveListItemSublistItemsToList(editor, {
|
|
34
|
+
fromListItem: currentListItemEntry.listItem,
|
|
35
|
+
toList: currentListItemEntry.list
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW92ZS1saXN0LWl0ZW0tZG93bi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3NyYy9wbHVnaW5zL2xpc3QvdHJhbnNmb3Jtcy9tb3ZlLWxpc3QtaXRlbS1kb3duLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBWSxNQUFNLEVBQWEsSUFBSSxFQUFFLFVBQVUsRUFBaUIsTUFBTSxPQUFPLENBQUM7QUFDckYsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDbEUsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sa0NBQWtDLENBQUM7QUFDckUsT0FBTyxFQUFFLDhCQUE4QixFQUFFLE1BQU0sd0NBQXdDLENBQUM7QUFDeEYsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBTzlELE1BQU0sQ0FBQyxNQUFNLGdCQUFnQixHQUFHLENBQUMsTUFBYyxFQUFFLEVBQUUsSUFBSSxFQUFFLFFBQVEsRUFB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dXNOb2RlID0gcHJldmlvdXNOb2RlLmNoaWxkcmVuW2xhc3RDaGlsZEluZGV4T2ZQcmV2aW91c05vZGVdIGFzIEVsZW1lbnQ7XG5cbiAgICAgICAgICAgIGNvbnN0IG5ld1BhdGggPSBwcmV2aW91c1BhdGguY29uY2F0KFxuICAgICAgICAgICAgICAgIGlzTm9kZVR5cGVMaXN0KGxhc3RDaGlsZE9mUHJldmlvdXNOb2RlKVxuICAgICAgICAgICAgICAgICAgICA/IFtsYXN0Q2hpbGRJbmRleE9mUHJldmlvdXNOb2RlLCBsYXN0Q2hpbGRPZlByZXZpb3VzTm9kZS5jaGlsZHJlbi5sZW5ndGhdXG4gICAgICAgICAgICAgICAgICAgIDogW3ByZXZpb3VzTm9kZS5jaGlsZHJlbi5sZW5ndGhdXG4gICAgICAgICAgICApO1xuXG4gICAgICAgICAgICBpZiAoIWlzTm9kZVR5cGVMaXN0KGxhc3RDaGlsZE9mUHJldmlvdXNOb2RlKSkge1xuICAgICAgICAgICAgICAgIC8vIOWIm+W7uuaWsOWtkOWIl+ihqFxuICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSAobGlzdE5vZGUgYXMgRWxlbWVudCkudHlwZTtcbiAgICAgICAgICAgICAgICBUcmFuc2Zvcm1zLndyYXBOb2RlcyhlZGl0b3IsIHsgdHlwZSwgY2hpbGRyZW46IFtdIH0gYXMgRWxlbWVudCwge1xuICAgICAgICAgICAgICAgICAgICBhdDogbGlzdEl0ZW1QYXRoXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyDlsIblvZPliY1saXN0SXRlbeenu+WKqOWIsOWtkOWIl+ihqFxuICAgICAgICAgICAgVHJhbnNmb3Jtcy5tb3ZlTm9kZXMoZWRpdG9yLCB7XG4gICAgICAgICAgICAgICAgYXQ6IGxpc3RJdGVtUGF0aCxcbiAgICAgICAgICAgICAgICB0bzogbmV3UGF0aFxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRMaXN0SXRlbUVudHJ5ID0gZ2V0TGlzdEl0ZW1FbnRyeShlZGl0b3IsIHt9KTtcbiAgICAgICAgICAgIGlmIChoYXNMaXN0SW5MaXN0SXRlbShjdXJyZW50TGlzdEl0ZW1FbnRyeS5saXN0SXRlbVswXSkpIHtcbiAgICAgICAgICAgICAgICBtb3ZlTGlzdEl0ZW1TdWJsaXN0SXRlbXNUb0xpc3QoZWRpdG9yLCB7XG4gICAgICAgICAgICAgICAgICAgIGZyb21MaXN0SXRlbTogY3VycmVudExpc3RJdGVtRW50cnkubGlzdEl0ZW0sXG4gICAgICAgICAgICAgICAgICAgIHRvTGlzdDogY3VycmVudExpc3RJdGVtRW50cnkubGlzdFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSk7XG59O1xuIl19
|
package/esm2015/plugins/list/transforms/move-list-item-sublist-items-to-list-item-sublist.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { Path, Transforms } from 'slate';
|
|
2
|
-
import { moveChildren } from '../../../transforms/move-children';
|
|
3
|
-
import { getListItemSublist } from '../queries/get-list-item-sublist';
|
|
4
|
-
import * as TheQueries from '../../../queries';
|
|
5
|
-
/**
|
|
6
|
-
* Move fromListItem sublist list items to the end of `toListItem` sublist.
|
|
7
|
-
* If there is no `toListItem` sublist, insert one.
|
|
8
|
-
*/
|
|
9
|
-
export const moveListItemSublistItemsToListItemSublist = (editor, { fromListItem, toListItem, start }, options) => {
|
|
10
|
-
const [, fromListItemPath] = fromListItem;
|
|
11
|
-
const [toListItemNode, toListItemPath] = toListItem;
|
|
12
|
-
const fromListItemSublist = getListItemSublist(fromListItem, options);
|
|
13
|
-
if (!fromListItemSublist)
|
|
14
|
-
return 0;
|
|
15
|
-
const [, fromListItemSublistPath] = fromListItemSublist;
|
|
16
|
-
const toListItemSublist = getListItemSublist(toListItem, options);
|
|
17
|
-
let to;
|
|
18
|
-
if (!toListItemSublist) {
|
|
19
|
-
const fromList = TheQueries.getParent(editor, fromListItemPath);
|
|
20
|
-
if (!fromList)
|
|
21
|
-
return 0;
|
|
22
|
-
const [fromListNode] = fromList;
|
|
23
|
-
const fromListType = fromListNode.type;
|
|
24
|
-
const toListItemSublistPath = toListItemPath.concat([toListItemNode.children.length]);
|
|
25
|
-
Transforms.insertNodes(editor, { type: fromListType, children: [] }, { at: toListItemSublistPath });
|
|
26
|
-
to = toListItemSublistPath.concat([0]);
|
|
27
|
-
}
|
|
28
|
-
else if (start) {
|
|
29
|
-
const [, toListItemSublistPath] = toListItemSublist;
|
|
30
|
-
to = toListItemSublistPath.concat([0]);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
to = Path.next(TheQueries.getLastChildPath(toListItemSublist));
|
|
34
|
-
}
|
|
35
|
-
const moved = moveChildren(editor, {
|
|
36
|
-
at: Path.previous(fromListItemSublistPath),
|
|
37
|
-
to
|
|
38
|
-
});
|
|
39
|
-
// Remove the empty list
|
|
40
|
-
Transforms.delete(editor, { at: fromListItemPath });
|
|
41
|
-
return moved;
|
|
42
|
-
};
|
|
1
|
+
import { Path, Transforms } from 'slate';
|
|
2
|
+
import { moveChildren } from '../../../transforms/move-children';
|
|
3
|
+
import { getListItemSublist } from '../queries/get-list-item-sublist';
|
|
4
|
+
import * as TheQueries from '../../../queries';
|
|
5
|
+
/**
|
|
6
|
+
* Move fromListItem sublist list items to the end of `toListItem` sublist.
|
|
7
|
+
* If there is no `toListItem` sublist, insert one.
|
|
8
|
+
*/
|
|
9
|
+
export const moveListItemSublistItemsToListItemSublist = (editor, { fromListItem, toListItem, start }, options) => {
|
|
10
|
+
const [, fromListItemPath] = fromListItem;
|
|
11
|
+
const [toListItemNode, toListItemPath] = toListItem;
|
|
12
|
+
const fromListItemSublist = getListItemSublist(fromListItem, options);
|
|
13
|
+
if (!fromListItemSublist)
|
|
14
|
+
return 0;
|
|
15
|
+
const [, fromListItemSublistPath] = fromListItemSublist;
|
|
16
|
+
const toListItemSublist = getListItemSublist(toListItem, options);
|
|
17
|
+
let to;
|
|
18
|
+
if (!toListItemSublist) {
|
|
19
|
+
const fromList = TheQueries.getParent(editor, fromListItemPath);
|
|
20
|
+
if (!fromList)
|
|
21
|
+
return 0;
|
|
22
|
+
const [fromListNode] = fromList;
|
|
23
|
+
const fromListType = fromListNode.type;
|
|
24
|
+
const toListItemSublistPath = toListItemPath.concat([toListItemNode.children.length]);
|
|
25
|
+
Transforms.insertNodes(editor, { type: fromListType, children: [] }, { at: toListItemSublistPath });
|
|
26
|
+
to = toListItemSublistPath.concat([0]);
|
|
27
|
+
}
|
|
28
|
+
else if (start) {
|
|
29
|
+
const [, toListItemSublistPath] = toListItemSublist;
|
|
30
|
+
to = toListItemSublistPath.concat([0]);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
to = Path.next(TheQueries.getLastChildPath(toListItemSublist));
|
|
34
|
+
}
|
|
35
|
+
const moved = moveChildren(editor, {
|
|
36
|
+
at: Path.previous(fromListItemSublistPath),
|
|
37
|
+
to
|
|
38
|
+
});
|
|
39
|
+
// Remove the empty list
|
|
40
|
+
Transforms.delete(editor, { at: fromListItemPath });
|
|
41
|
+
return moved;
|
|
42
|
+
};
|
|
43
43
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW92ZS1saXN0LWl0ZW0tc3VibGlzdC1pdGVtcy10by1saXN0LWl0ZW0tc3VibGlzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3NyYy9wbHVnaW5zL2xpc3QvdHJhbnNmb3Jtcy9tb3ZlLWxpc3QtaXRlbS1zdWJsaXN0LWl0ZW1zLXRvLWxpc3QtaXRlbS1zdWJsaXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBK0IsSUFBS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