@sveltia/ui 0.90.0 → 0.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/bottom-navigation/bottom-navigation.svelte +3 -9
- package/dist/components/bottom-navigation/bottom-navigation.svelte.d.ts +4 -39
- package/dist/components/button/button-group.svelte +2 -4
- package/dist/components/button/button-group.svelte.d.ts +3 -19
- package/dist/components/button/select-button-group.svelte +2 -13
- package/dist/components/button/select-button-group.svelte.d.ts +5 -67
- package/dist/components/calendar/calendar.d.ts +9 -0
- package/dist/components/calendar/calendar.js +43 -0
- package/dist/components/calendar/calendar.svelte +26 -27
- package/dist/components/checkbox/checkbox-group.svelte +2 -8
- package/dist/components/checkbox/checkbox-group.svelte.d.ts +4 -39
- package/dist/components/dialog/alert-dialog.svelte.d.ts +2 -3
- package/dist/components/dialog/confirmation-dialog.svelte.d.ts +2 -3
- package/dist/components/dialog/dialog.svelte +6 -7
- package/dist/components/dialog/dialog.svelte.d.ts +2 -3
- package/dist/components/dialog/prompt-dialog.svelte +2 -2
- package/dist/components/dialog/prompt-dialog.svelte.d.ts +2 -3
- package/dist/components/disclosure/disclosure.svelte +14 -16
- package/dist/components/disclosure/disclosure.svelte.d.ts +4 -38
- package/dist/components/drawer/drawer.svelte +22 -39
- package/dist/components/drawer/drawer.svelte.d.ts +3 -24
- package/dist/components/grid/grid-body.svelte +2 -3
- package/dist/components/grid/grid-body.svelte.d.ts +3 -18
- package/dist/components/grid/grid-cell.svelte +2 -8
- package/dist/components/grid/grid-cell.svelte.d.ts +3 -22
- package/dist/components/grid/grid-col-header.svelte +2 -4
- package/dist/components/grid/grid-col-header.svelte.d.ts +3 -19
- package/dist/components/grid/grid-foot.svelte +4 -9
- package/dist/components/grid/grid-foot.svelte.d.ts +3 -22
- package/dist/components/grid/grid-head.svelte +4 -9
- package/dist/components/grid/grid-head.svelte.d.ts +3 -22
- package/dist/components/grid/grid-row-header.svelte +2 -8
- package/dist/components/grid/grid-row-header.svelte.d.ts +3 -22
- package/dist/components/grid/grid-row.svelte +4 -5
- package/dist/components/grid/grid-row.svelte.d.ts +3 -19
- package/dist/components/grid/grid.d.ts +10 -0
- package/dist/components/grid/grid.js +11 -0
- package/dist/components/grid/grid.svelte +6 -7
- package/dist/components/grid/grid.svelte.d.ts +5 -21
- package/dist/components/listbox/listbox.svelte +34 -15
- package/dist/components/listbox/listbox.svelte.d.ts +5 -69
- package/dist/components/listbox/option-group.svelte +2 -8
- package/dist/components/listbox/option-group.svelte.d.ts +4 -39
- package/dist/components/listbox/option.svelte +2 -1
- package/dist/components/menu/menu-item-group.svelte +2 -6
- package/dist/components/menu/menu-item-group.svelte.d.ts +3 -22
- package/dist/components/menu/menu-item.svelte +5 -1
- package/dist/components/menu/menu.svelte +2 -8
- package/dist/components/menu/menu.svelte.d.ts +4 -39
- package/dist/components/radio/radio-group.svelte +2 -17
- package/dist/components/radio/radio-group.svelte.d.ts +5 -67
- package/dist/components/radio/radio.svelte +19 -22
- package/dist/components/radio/radio.svelte.d.ts +10 -40
- package/dist/components/resizable-pane/resizable-handle.svelte +42 -49
- package/dist/components/resizable-pane/resizable-pane-group.svelte +44 -58
- package/dist/components/resizable-pane/resizable-pane-group.svelte.d.ts +3 -19
- package/dist/components/resizable-pane/resizable-pane.svelte +2 -5
- package/dist/components/resizable-pane/resizable-pane.svelte.d.ts +3 -19
- package/dist/components/resizable-pane/sizing.d.ts +24 -0
- package/dist/components/resizable-pane/sizing.js +83 -0
- package/dist/components/select/combobox.svelte +35 -39
- package/dist/components/select/select-tags.svelte +3 -13
- package/dist/components/select/select-tags.svelte.d.ts +5 -67
- package/dist/components/slider/slider.d.ts +5 -4
- package/dist/components/slider/slider.js +28 -23
- package/dist/components/slider/slider.svelte +64 -62
- package/dist/components/slider/slider.svelte.d.ts +4 -37
- package/dist/components/switch/switch.svelte +2 -13
- package/dist/components/switch/switch.svelte.d.ts +5 -67
- package/dist/components/table/table-body.svelte +2 -4
- package/dist/components/table/table-body.svelte.d.ts +3 -19
- package/dist/components/table/table-cell.svelte +2 -8
- package/dist/components/table/table-cell.svelte.d.ts +3 -22
- package/dist/components/table/table-col-header.svelte +2 -8
- package/dist/components/table/table-col-header.svelte.d.ts +3 -22
- package/dist/components/table/table-foot.svelte +2 -8
- package/dist/components/table/table-foot.svelte.d.ts +3 -22
- package/dist/components/table/table-head.svelte +2 -8
- package/dist/components/table/table-head.svelte.d.ts +3 -22
- package/dist/components/table/table-part.svelte +2 -4
- package/dist/components/table/table-part.svelte.d.ts +3 -19
- package/dist/components/table/table-row-header.svelte +2 -8
- package/dist/components/table/table-row-header.svelte.d.ts +3 -22
- package/dist/components/table/table-row.svelte +2 -8
- package/dist/components/table/table-row.svelte.d.ts +3 -22
- package/dist/components/table/table.svelte +2 -4
- package/dist/components/table/table.svelte.d.ts +3 -19
- package/dist/components/tabs/tab-box.svelte +2 -4
- package/dist/components/tabs/tab-box.svelte.d.ts +3 -19
- package/dist/components/tabs/tab-list.svelte +2 -7
- package/dist/components/tabs/tab-list.svelte.d.ts +4 -37
- package/dist/components/tabs/tab-panel.svelte +2 -8
- package/dist/components/tabs/tab-panel.svelte.d.ts +3 -22
- package/dist/components/tabs/tab-panels.svelte +2 -8
- package/dist/components/tabs/tab-panels.svelte.d.ts +3 -22
- package/dist/components/text-editor/code-editor.js +14 -7
- package/dist/components/text-editor/code-editor.svelte +14 -22
- package/dist/components/text-editor/code-editor.svelte.d.ts +5 -103
- package/dist/components/text-editor/config.d.ts +73 -0
- package/dist/components/text-editor/config.js +110 -0
- package/dist/components/text-editor/constants.d.ts +40 -6
- package/dist/components/text-editor/constants.js +81 -7
- package/dist/components/text-editor/conversion/editor-components.js +4 -4
- package/dist/components/text-editor/conversion/html/components.d.ts +16 -0
- package/dist/components/text-editor/conversion/html/components.js +87 -0
- package/dist/components/text-editor/conversion/html/export.d.ts +10 -0
- package/dist/components/text-editor/conversion/html/export.js +360 -0
- package/dist/components/text-editor/conversion/html/import-rules.d.ts +12 -0
- package/dist/components/text-editor/conversion/html/import-rules.js +234 -0
- package/dist/components/text-editor/conversion/html/index.d.ts +10 -0
- package/dist/components/text-editor/conversion/html/index.js +33 -0
- package/dist/components/text-editor/conversion/html/paragraph.d.ts +1 -0
- package/dist/components/text-editor/conversion/html/paragraph.js +123 -0
- package/dist/components/text-editor/conversion/html/task-list.d.ts +13 -0
- package/dist/components/text-editor/conversion/html/task-list.js +82 -0
- package/dist/components/text-editor/conversion/html/unsupported.d.ts +2 -0
- package/dist/components/text-editor/conversion/html/unsupported.js +122 -0
- package/dist/components/text-editor/conversion/html/utils.d.ts +6 -0
- package/dist/components/text-editor/conversion/html/utils.js +34 -0
- package/dist/components/text-editor/conversion/import.js +33 -27
- package/dist/components/text-editor/conversion/markdown/block-conversion.d.ts +4 -0
- package/dist/components/text-editor/conversion/markdown/block-conversion.js +154 -0
- package/dist/components/text-editor/conversion/markdown/block-structure.d.ts +16 -0
- package/dist/components/text-editor/conversion/markdown/block-structure.js +254 -0
- package/dist/components/text-editor/conversion/markdown/code-blocks.d.ts +57 -0
- package/dist/components/text-editor/conversion/markdown/code-blocks.js +279 -0
- package/dist/components/text-editor/conversion/markdown/code-spans.d.ts +19 -0
- package/dist/components/text-editor/conversion/markdown/code-spans.js +71 -0
- package/dist/components/text-editor/conversion/markdown/formatting.d.ts +22 -0
- package/dist/components/text-editor/conversion/markdown/formatting.js +451 -0
- package/dist/components/text-editor/conversion/markdown/index.d.ts +10 -0
- package/dist/components/text-editor/conversion/markdown/index.js +55 -0
- package/dist/components/text-editor/conversion/markdown/placeholders.d.ts +2 -0
- package/dist/components/text-editor/conversion/markdown/placeholders.js +229 -0
- package/dist/components/text-editor/conversion/markdown/syntax.d.ts +99 -0
- package/dist/components/text-editor/conversion/markdown/syntax.js +206 -0
- package/dist/components/text-editor/conversion/placeholder-chars.d.ts +43 -0
- package/dist/components/text-editor/conversion/placeholder-chars.js +51 -0
- package/dist/components/text-editor/conversion/transformers/block-escape.d.ts +1 -0
- package/dist/components/text-editor/conversion/transformers/block-escape.js +53 -26
- package/dist/components/text-editor/conversion/transformers/code.d.ts +3 -14
- package/dist/components/text-editor/conversion/transformers/code.js +78 -16
- package/dist/components/text-editor/conversion/transformers/formatted-code.js +3 -18
- package/dist/components/text-editor/conversion/transformers/inline-code.js +3 -1
- package/dist/components/text-editor/conversion/transformers/link.js +3 -1
- package/dist/components/text-editor/conversion/transformers/raw-syntax.d.ts +0 -19
- package/dist/components/text-editor/conversion/transformers/raw-syntax.js +22 -93
- package/dist/components/text-editor/conversion/transformers/table.js +57 -16
- package/dist/components/text-editor/conversion/transformers/task-list.d.ts +24 -0
- package/dist/components/text-editor/conversion/transformers/task-list.js +53 -0
- package/dist/components/text-editor/conversion/update.d.ts +19 -2
- package/dist/components/text-editor/conversion/update.js +64 -40
- package/dist/components/text-editor/core.d.ts +12 -51
- package/dist/components/text-editor/core.js +47 -77
- package/dist/components/text-editor/editing/commands.js +9 -18
- package/dist/components/text-editor/editing/guards.d.ts +7 -0
- package/dist/components/text-editor/editing/guards.js +123 -0
- package/dist/components/text-editor/editing/raw-markdown.d.ts +7 -2
- package/dist/components/text-editor/editing/raw-markdown.js +68 -8
- package/dist/components/text-editor/editing/selection.js +6 -2
- package/dist/components/text-editor/lexical-root.svelte +89 -47
- package/dist/components/text-editor/lexical-root.svelte.d.ts +4 -67
- package/dist/components/text-editor/shiki/{facade.d.ts → engine.d.ts} +8 -8
- package/dist/components/text-editor/shiki/{facade.js → engine.js} +53 -156
- package/dist/components/text-editor/shiki/highlighter.js +5 -5
- package/dist/components/text-editor/shiki/lexical.d.ts +6 -0
- package/dist/components/text-editor/shiki/lexical.js +165 -0
- package/dist/components/text-editor/shiki/preload.js +1 -1
- package/dist/components/text-editor/shiki/source-highlight.svelte.d.ts +15 -0
- package/dist/components/text-editor/shiki/source-highlight.svelte.js +120 -0
- package/dist/components/text-editor/shiki/version.d.ts +1 -1
- package/dist/components/text-editor/shiki/version.js +1 -1
- package/dist/components/text-editor/store.svelte.js +65 -16
- package/dist/components/text-editor/text-editor.svelte +57 -146
- package/dist/components/text-editor/text-editor.svelte.d.ts +9 -105
- package/dist/components/text-editor/toolbar/actions.d.ts +25 -0
- package/dist/components/text-editor/toolbar/actions.js +107 -0
- package/dist/components/text-editor/toolbar/align-menu-button.svelte +16 -14
- package/dist/components/text-editor/toolbar/format-text-button.svelte +27 -19
- package/dist/components/text-editor/toolbar/insert-horizontal-rule-button.svelte +23 -23
- package/dist/components/text-editor/toolbar/insert-item-button.svelte +1 -1
- package/dist/components/text-editor/toolbar/insert-link-button.svelte +47 -51
- package/dist/components/text-editor/toolbar/insert-menu-button.svelte +1 -1
- package/dist/components/text-editor/toolbar/insert-table-button.svelte +35 -52
- package/dist/components/text-editor/toolbar/table-action-menu.svelte +19 -17
- package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +34 -11
- package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte.d.ts +0 -8
- package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +35 -41
- package/dist/components/text-editor/widgets/emoji-autocomplete.svelte +7 -6
- package/dist/components/text-editor/widgets/floating-link-editor.svelte +19 -32
- package/dist/components/text-editor/widgets/table-cell-menu-button.svelte +28 -32
- package/dist/components/text-field/date-time-input.svelte +7 -8
- package/dist/components/text-field/date-time-input.svelte.d.ts +3 -32
- package/dist/components/text-field/number-input.d.ts +0 -2
- package/dist/components/text-field/number-input.js +25 -25
- package/dist/components/text-field/number-input.svelte +18 -9
- package/dist/components/text-field/number-input.svelte.d.ts +1 -1
- package/dist/components/text-field/text-area.d.ts +2 -0
- package/dist/components/text-field/text-area.js +31 -0
- package/dist/components/text-field/text-area.svelte +12 -25
- package/dist/components/text-field/text-area.svelte.d.ts +5 -67
- package/dist/components/toast/toast.svelte +31 -8
- package/dist/components/toast/toast.svelte.d.ts +6 -6
- package/dist/components/toolbar/toolbar.svelte +2 -7
- package/dist/components/toolbar/toolbar.svelte.d.ts +4 -37
- package/dist/components/tree/tree-item.svelte +2 -6
- package/dist/components/tree/tree-item.svelte.d.ts +3 -22
- package/dist/components/tree/tree.svelte +3 -10
- package/dist/components/tree/tree.svelte.d.ts +4 -39
- package/dist/components/util/group.svelte +2 -7
- package/dist/components/util/group.svelte.d.ts +4 -37
- package/dist/components/util/modal.d.ts +9 -0
- package/dist/components/util/modal.js +30 -0
- package/dist/components/util/modal.svelte +16 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/locales/ar.yaml +2 -0
- package/dist/locales/bg.yaml +2 -0
- package/dist/locales/ca.yaml +2 -0
- package/dist/locales/cs.yaml +2 -0
- package/dist/locales/da.yaml +2 -0
- package/dist/locales/de.yaml +2 -0
- package/dist/locales/el.yaml +2 -0
- package/dist/locales/en-CA.yaml +2 -0
- package/dist/locales/en-GB.yaml +2 -0
- package/dist/locales/en-US.yaml +2 -0
- package/dist/locales/en-ZA.yaml +2 -0
- package/dist/locales/es-CO.yaml +2 -0
- package/dist/locales/es-ES.yaml +2 -0
- package/dist/locales/fa.yaml +2 -0
- package/dist/locales/fi.yaml +2 -0
- package/dist/locales/fr.yaml +2 -0
- package/dist/locales/he.yaml +2 -0
- package/dist/locales/hr.yaml +2 -0
- package/dist/locales/hu.yaml +176 -0
- package/dist/locales/it.yaml +2 -0
- package/dist/locales/ja.yaml +2 -0
- package/dist/locales/ko.yaml +2 -0
- package/dist/locales/nl.yaml +2 -0
- package/dist/locales/pl.yaml +2 -0
- package/dist/locales/pt-BR.yaml +2 -0
- package/dist/locales/pt-PT.yaml +2 -0
- package/dist/locales/ru.yaml +2 -0
- package/dist/locales/sk.yaml +2 -0
- package/dist/locales/sv.yaml +2 -0
- package/dist/locales/tr.yaml +2 -0
- package/dist/locales/uk.yaml +2 -0
- package/dist/locales/vi.yaml +2 -0
- package/dist/locales/zh-CN.yaml +2 -0
- package/dist/locales/zh-TW.yaml +2 -0
- package/dist/services/composite-widget.svelte.d.ts +76 -0
- package/dist/services/composite-widget.svelte.js +157 -0
- package/dist/services/focus.d.ts +2 -0
- package/dist/services/focus.js +68 -0
- package/dist/services/group.svelte.d.ts +17 -69
- package/dist/services/group.svelte.js +128 -391
- package/dist/services/label.d.ts +9 -0
- package/dist/services/label.js +22 -0
- package/dist/services/menu.d.ts +8 -0
- package/dist/services/menu.js +237 -0
- package/dist/services/navigation.d.ts +9 -0
- package/dist/services/navigation.js +13 -0
- package/dist/services/number.d.ts +2 -0
- package/dist/services/number.js +27 -0
- package/dist/services/pointer-drag.d.ts +14 -0
- package/dist/services/pointer-drag.js +89 -0
- package/dist/services/popup.svelte.js +123 -103
- package/dist/services/text.d.ts +3 -0
- package/dist/services/text.js +17 -0
- package/dist/services/tree.svelte.d.ts +29 -43
- package/dist/services/tree.svelte.js +58 -105
- package/dist/services/type-ahead.d.ts +10 -1
- package/dist/services/type-ahead.js +56 -34
- package/dist/typedefs.d.ts +108 -6
- package/dist/typedefs.js +63 -6
- package/package.json +5 -5
- package/dist/components/text-editor/conversion/html.d.ts +0 -30
- package/dist/components/text-editor/conversion/html.js +0 -857
- package/dist/components/text-editor/conversion/markdown.d.ts +0 -56
- package/dist/components/text-editor/conversion/markdown.js +0 -949
- package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte +0 -28
- package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte.d.ts +0 -37
- package/dist/components/text-editor/toolbar/insert-component.d.ts +0 -3
- package/dist/components/text-editor/toolbar/insert-component.js +0 -37
|
@@ -13,15 +13,16 @@
|
|
|
13
13
|
import Icon from '../../icon/icon.svelte';
|
|
14
14
|
import NumberInput from '../../text-field/number-input.svelte';
|
|
15
15
|
import { AVAILABLE_BUTTONS, DEFAULT_TABLE_SIZE, MAX_TABLE_SIZE } from '../constants.js';
|
|
16
|
-
import { focusEditor } from '../editing/caret.js';
|
|
17
16
|
import { editRawText, insertMarkdown } from '../editing/raw-markdown.js';
|
|
18
17
|
import {
|
|
19
18
|
$insertTable as insertTable,
|
|
20
19
|
createTableMarkdown,
|
|
21
20
|
parseTableSize,
|
|
22
21
|
} from '../editing/table.js';
|
|
22
|
+
import { refocusEditor, runEditorAction } from './actions.js';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
+
* @import { LexicalEditor } from 'lexical';
|
|
25
26
|
* @import { TextEditorStore } from '../../../typedefs.js';
|
|
26
27
|
*/
|
|
27
28
|
|
|
@@ -85,42 +86,40 @@
|
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
/**
|
|
88
|
-
* Insert the table into the rich text editor, then move the focus back to it,
|
|
89
|
-
* in the first cell.
|
|
89
|
+
* Insert the table: a table node into the rich text editor, then move the focus back to it, or
|
|
90
|
+
* the table’s Markdown into the `<textarea>`. Either way, the caret ends up in the first cell.
|
|
90
91
|
* @param {TableSize} size Table size.
|
|
92
|
+
* @returns {Promise<void>} Nothing.
|
|
91
93
|
*/
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
const insert = ({ rows: rowSize, columns: columnSize }) =>
|
|
95
|
+
runEditorAction(editorStore, {
|
|
96
|
+
/**
|
|
97
|
+
* Insert the table’s Markdown, with the caret in the first cell.
|
|
98
|
+
* @param {HTMLTextAreaElement} textArea `<textarea>` element.
|
|
99
|
+
* @returns {void | Promise<void>} Nothing.
|
|
100
|
+
*/
|
|
101
|
+
raw: (textArea) => {
|
|
102
|
+
const markdown = createTableMarkdown(rowSize, columnSize);
|
|
103
|
+
|
|
104
|
+
return editRawText(textArea, (state) => {
|
|
105
|
+
const edit = insertMarkdown(state, markdown, { block: true });
|
|
106
|
+
// Right after the leading pipe and space of the first cell
|
|
107
|
+
const caret = edit.start + edit.text.indexOf(markdown) + 2;
|
|
108
|
+
|
|
109
|
+
return { ...edit, selectionStart: caret, selectionEnd: caret };
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Insert a table node.
|
|
114
|
+
* @param {LexicalEditor} editor Editor instance.
|
|
115
|
+
*/
|
|
116
|
+
rich: (editor) => {
|
|
117
|
+
editor.update(() => {
|
|
118
|
+
insertTable(rowSize, columnSize);
|
|
119
|
+
});
|
|
120
|
+
},
|
|
103
121
|
});
|
|
104
122
|
|
|
105
|
-
await focusEditor(editor);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Insert the table’s Markdown into the `<textarea>`, with the caret in the first cell.
|
|
110
|
-
* @param {TableSize} size Table size.
|
|
111
|
-
*/
|
|
112
|
-
const insertPlainText = async ({ rows: rowSize, columns: columnSize }) => {
|
|
113
|
-
const markdown = createTableMarkdown(rowSize, columnSize);
|
|
114
|
-
|
|
115
|
-
await editRawText(editorStore.textArea, (state) => {
|
|
116
|
-
const edit = insertMarkdown(state, markdown, { block: true });
|
|
117
|
-
// Right after the leading pipe and space of the first cell
|
|
118
|
-
const caret = edit.start + edit.text.indexOf(markdown) + 2;
|
|
119
|
-
|
|
120
|
-
return { ...edit, selectionStart: caret, selectionEnd: caret };
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
|
|
124
123
|
/**
|
|
125
124
|
* Handle `close` event fired on the dialog. Insert the table unless the dialog has been canceled.
|
|
126
125
|
* @param {CustomEvent} event `close` event.
|
|
@@ -129,26 +128,10 @@
|
|
|
129
128
|
const canceled = event.detail.returnValue === 'cancel';
|
|
130
129
|
|
|
131
130
|
if (!canceled && rowCount && columnCount) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (editorStore.useRichText) {
|
|
135
|
-
await insertRichText(size);
|
|
136
|
-
} else {
|
|
137
|
-
await insertPlainText(size);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// The dialog leaves the focus alone (see `restoreFocus` below), so bring it back here
|
|
144
|
-
if (editorStore.useRichText) {
|
|
145
|
-
// The button is only enabled while the editor is there
|
|
146
|
-
/* v8 ignore else */
|
|
147
|
-
if (editorStore.editor) {
|
|
148
|
-
await focusEditor(editorStore.editor);
|
|
149
|
-
}
|
|
131
|
+
await insert({ rows: rowCount, columns: columnCount });
|
|
150
132
|
} else {
|
|
151
|
-
|
|
133
|
+
// The dialog leaves the focus alone (see `restoreFocus` below), so bring it back here
|
|
134
|
+
await refocusEditor(editorStore);
|
|
152
135
|
}
|
|
153
136
|
};
|
|
154
137
|
</script>
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
import Divider from '../../divider/divider.svelte';
|
|
10
10
|
import MenuItem from '../../menu/menu-item.svelte';
|
|
11
11
|
import Menu from '../../menu/menu.svelte';
|
|
12
|
-
import { focusEditor } from '../editing/caret.js';
|
|
13
12
|
import { isRightToLeftTable, $runTableAction as runTableAction } from '../editing/table.js';
|
|
13
|
+
import { runEditorAction } from './actions.js';
|
|
14
14
|
import { waitForMenuToClose } from './menu.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
+
* @import { LexicalEditor } from 'lexical';
|
|
17
18
|
* @import { TextEditorStore } from '../../../typedefs.js';
|
|
18
19
|
* @import { TableAction } from '../editing/table.js';
|
|
19
20
|
*/
|
|
@@ -57,26 +58,27 @@
|
|
|
57
58
|
* Run the given operation on the cell, then move the focus back to the editor.
|
|
58
59
|
* @param {TableAction} action Operation.
|
|
59
60
|
* @param {HTMLElement} item Menu item chosen.
|
|
61
|
+
* @returns {Promise<void>} Nothing.
|
|
60
62
|
*/
|
|
61
|
-
const runAction =
|
|
62
|
-
|
|
63
|
+
const runAction = (action, item) =>
|
|
64
|
+
// The menu is only shown for a cell in the rich text editor
|
|
65
|
+
runEditorAction(editorStore, {
|
|
66
|
+
/**
|
|
67
|
+
* Run the operation, and wait for the menu to close.
|
|
68
|
+
* @param {LexicalEditor} editor Editor instance.
|
|
69
|
+
* @returns {Promise<void>} Nothing.
|
|
70
|
+
*/
|
|
71
|
+
rich: async (editor) => {
|
|
72
|
+
const cell = editor.getElementByKey(cellKey);
|
|
73
|
+
const rtl = !!cell && isRightToLeftTable(cell);
|
|
63
74
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
75
|
+
editor.update(() => {
|
|
76
|
+
runTableAction(action, cellKey, { rtl });
|
|
77
|
+
});
|
|
69
78
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
editor.update(() => {
|
|
74
|
-
runTableAction(action, cellKey, { rtl });
|
|
79
|
+
await waitForMenuToClose(item);
|
|
80
|
+
},
|
|
75
81
|
});
|
|
76
|
-
|
|
77
|
-
await waitForMenuToClose(item);
|
|
78
|
-
await focusEditor(editor);
|
|
79
|
-
};
|
|
80
82
|
</script>
|
|
81
83
|
|
|
82
84
|
<Menu ariaLabel={_('_sui.text_editor.table_options')}>
|
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
import Icon from '../../icon/icon.svelte';
|
|
10
10
|
import MenuButton from '../../menu/menu-button.svelte';
|
|
11
11
|
import Menu from '../../menu/menu.svelte';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
AVAILABLE_BUTTONS,
|
|
14
|
+
BLOCK_BUTTON_TYPES,
|
|
15
|
+
INLINE_BUTTON_TYPES,
|
|
16
|
+
isHtmlOnlyButton,
|
|
17
|
+
} from '../constants.js';
|
|
18
|
+
import { getEditorSetup } from '../config.js';
|
|
13
19
|
import { isInlineComponent } from '../conversion/editor-components.js';
|
|
14
20
|
import CodeLanguageSwitcher from './code-language-switcher.svelte';
|
|
15
21
|
import AlignMenuButton from './align-menu-button.svelte';
|
|
@@ -24,12 +30,16 @@
|
|
|
24
30
|
import ToolbarWrapper from './toolbar-wrapper.svelte';
|
|
25
31
|
|
|
26
32
|
/**
|
|
27
|
-
* @import {
|
|
33
|
+
* @import {
|
|
34
|
+
* TextEditorBlockType,
|
|
35
|
+
* TextEditorInlineType,
|
|
36
|
+
* TextEditorStore,
|
|
37
|
+
* } from '../../../typedefs.js';
|
|
38
|
+
* @import { NormalizedEditorConfig } from '../config.js';
|
|
28
39
|
*/
|
|
29
40
|
|
|
30
41
|
/**
|
|
31
42
|
* @typedef {object} Props
|
|
32
|
-
* @property {boolean} [hidden] Whether to hide the widget.
|
|
33
43
|
* @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
|
|
34
44
|
* attribute.
|
|
35
45
|
* @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
|
|
@@ -69,15 +79,20 @@
|
|
|
69
79
|
*/
|
|
70
80
|
const canFormat = $derived(editorStore.useRichText || !isHtml);
|
|
71
81
|
|
|
72
|
-
const hasTable = $derived(editorStore.config.enabledButtons.includes('table'));
|
|
73
82
|
/**
|
|
74
|
-
* Whether the
|
|
75
|
-
* available for HTML, and only in the rich text mode, as
|
|
83
|
+
* Whether the HTML-only buttons, like underline and the alignment menu, are available. Markdown
|
|
84
|
+
* has no syntax for them, so they’re only available for HTML, and only in the rich text mode, as
|
|
85
|
+
* the plain text mode shows the source.
|
|
76
86
|
*/
|
|
87
|
+
const canUseHtmlOnlyButtons = $derived(isHtml && editorStore.useRichText);
|
|
88
|
+
|
|
89
|
+
// The store holds the configuration normalized
|
|
90
|
+
const { hasTable, hasHorizontalRule } = $derived(
|
|
91
|
+
getEditorSetup(/** @type {NormalizedEditorConfig} */ (editorStore.config)),
|
|
92
|
+
);
|
|
77
93
|
const canAlign = $derived(
|
|
78
|
-
|
|
94
|
+
canUseHtmlOnlyButtons && editorStore.config.enabledButtons.includes('align'),
|
|
79
95
|
);
|
|
80
|
-
const hasHorizontalRule = $derived(editorStore.config.enabledButtons.includes('horizontal-rule'));
|
|
81
96
|
/**
|
|
82
97
|
* Key of the table cell the caret is in, if any. The table menu only works with the rich text
|
|
83
98
|
* editor.
|
|
@@ -116,13 +131,16 @@
|
|
|
116
131
|
const canChangeBlock = $derived(canFormat && !inMarkdownTable);
|
|
117
132
|
|
|
118
133
|
/**
|
|
119
|
-
* Enabled inline level buttons
|
|
134
|
+
* Enabled inline level buttons, leaving out the HTML-only ones, like underline, when they’re not
|
|
135
|
+
* available.
|
|
120
136
|
* @type {TextEditorInlineType[]}
|
|
121
137
|
*/
|
|
122
138
|
const inlineLevelButtons = $derived(
|
|
123
139
|
unique(
|
|
124
|
-
editorStore.config.enabledButtons.filter(
|
|
125
|
-
|
|
140
|
+
editorStore.config.enabledButtons.filter(
|
|
141
|
+
(type) =>
|
|
142
|
+
INLINE_BUTTON_TYPES.includes(/** @type {any} */ (type)) &&
|
|
143
|
+
(canUseHtmlOnlyButtons || !isHtmlOnlyButton(type)),
|
|
126
144
|
),
|
|
127
145
|
),
|
|
128
146
|
);
|
|
@@ -214,6 +232,11 @@
|
|
|
214
232
|
pressed={!editorStore.useRichText}
|
|
215
233
|
aria-label={_(`_sui.text_editor.${isHtml ? 'edit_in_html' : 'edit_in_markdown'}`)}
|
|
216
234
|
onclick={() => {
|
|
235
|
+
// The source shows the value, which has to include what was just typed
|
|
236
|
+
if (editorStore.useRichText) {
|
|
237
|
+
editorStore.flushExport();
|
|
238
|
+
}
|
|
239
|
+
|
|
217
240
|
editorStore.useRichText = !editorStore.useRichText;
|
|
218
241
|
|
|
219
242
|
if (editorStore.useRichText) {
|
|
@@ -4,10 +4,6 @@ type TextEditorToolbar = {
|
|
|
4
4
|
$set?(props: Partial<Props & Record<string, any>>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const TextEditorToolbar: import("svelte").Component<{
|
|
7
|
-
/**
|
|
8
|
-
* Whether to hide the widget.
|
|
9
|
-
*/
|
|
10
|
-
hidden?: boolean | undefined;
|
|
11
7
|
/**
|
|
12
8
|
* Whether to disable the widget. An alias of the `aria-disabled`
|
|
13
9
|
* attribute.
|
|
@@ -20,10 +16,6 @@ declare const TextEditorToolbar: import("svelte").Component<{
|
|
|
20
16
|
readonly?: boolean | undefined;
|
|
21
17
|
} & Record<string, any>, {}, "">;
|
|
22
18
|
type Props = {
|
|
23
|
-
/**
|
|
24
|
-
* Whether to hide the widget.
|
|
25
|
-
*/
|
|
26
|
-
hidden?: boolean | undefined;
|
|
27
19
|
/**
|
|
28
20
|
* Whether to disable the widget. An alias of the `aria-disabled`
|
|
29
21
|
* attribute.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { $createCodeNode as createCodeNode } from '@lexical/code-core';
|
|
3
|
-
import { INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND } from '@lexical/list';
|
|
4
3
|
import {
|
|
5
4
|
$createHeadingNode as createHeadingNode,
|
|
6
5
|
$createQuoteNode as createQuoteNode,
|
|
@@ -14,14 +13,14 @@
|
|
|
14
13
|
import { getContext } from 'svelte';
|
|
15
14
|
import Icon from '../../icon/icon.svelte';
|
|
16
15
|
import MenuItemCheckbox from '../../menu/menu-item-checkbox.svelte';
|
|
17
|
-
import { AVAILABLE_BUTTONS } from '../constants.js';
|
|
18
|
-
import { focusEditor } from '../editing/caret.js';
|
|
16
|
+
import { AVAILABLE_BUTTONS, LIST_TYPES } from '../constants.js';
|
|
19
17
|
import { editRawText, setBlockType } from '../editing/raw-markdown.js';
|
|
18
|
+
import { runEditorAction } from './actions.js';
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* @import { TextEditorBlockType, TextEditorStore } from '../../../typedefs.js';
|
|
23
22
|
* @import { HeadingTagType } from '@lexical/rich-text';
|
|
24
|
-
* @import { ElementNode,
|
|
23
|
+
* @import { ElementNode, LexicalEditor } from 'lexical';
|
|
25
24
|
*/
|
|
26
25
|
|
|
27
26
|
/**
|
|
@@ -35,15 +34,6 @@
|
|
|
35
34
|
'code-block': createCodeNode,
|
|
36
35
|
};
|
|
37
36
|
|
|
38
|
-
/**
|
|
39
|
-
* Commands for the list block types, which are toggled by the list plugin instead.
|
|
40
|
-
* @type {Record<string, LexicalCommand<void>>}
|
|
41
|
-
*/
|
|
42
|
-
const LIST_COMMANDS = {
|
|
43
|
-
'bulleted-list': INSERT_UNORDERED_LIST_COMMAND,
|
|
44
|
-
'numbered-list': INSERT_ORDERED_LIST_COMMAND,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
37
|
/**
|
|
48
38
|
* @typedef {object} Props
|
|
49
39
|
* @property {TextEditorBlockType} type Button type.
|
|
@@ -64,39 +54,43 @@
|
|
|
64
54
|
|
|
65
55
|
/**
|
|
66
56
|
* Change the current selection’s type to {@link type}.
|
|
57
|
+
* @returns {Promise<void>} Nothing.
|
|
67
58
|
*/
|
|
68
|
-
const changeBlockType =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
const changeBlockType = () =>
|
|
60
|
+
runEditorAction(editorStore, {
|
|
61
|
+
/**
|
|
62
|
+
* Change the block type in the Markdown.
|
|
63
|
+
* @param {HTMLTextAreaElement} textArea `<textarea>` element.
|
|
64
|
+
* @returns {void | Promise<void>} Nothing.
|
|
65
|
+
*/
|
|
66
|
+
raw: (textArea) => editRawText(textArea, (state) => setBlockType(state, type)),
|
|
67
|
+
/**
|
|
68
|
+
* Change the block type of the selection.
|
|
69
|
+
* @param {LexicalEditor} editor Editor instance.
|
|
70
|
+
*/
|
|
71
|
+
rich: (editor) => {
|
|
72
|
+
const [, headingLevel] = type.match(/^heading-(\d)$/) ?? [];
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
const createNode = headingLevel
|
|
75
|
+
? () => createHeadingNode(/** @type {HeadingTagType} */ (`h${headingLevel}`))
|
|
76
|
+
: NODE_FACTORIES[type];
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
if (createNode) {
|
|
79
|
+
editor.update(() => {
|
|
80
|
+
setBlocksType(getSelection(), createNode);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
// A list is toggled by its command instead
|
|
85
|
+
const list = LIST_TYPES.find((item) => item.type === type);
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
editorStore.editor.update(() => {
|
|
92
|
-
setBlocksType(getSelection(), createNode);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (type in LIST_COMMANDS) {
|
|
97
|
-
editorStore.editor.dispatchCommand(LIST_COMMANDS[type], undefined);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
87
|
+
if (list) {
|
|
88
|
+
editor.dispatchCommand(list.command, undefined);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
// The block type applies to the selection, which the focus restores
|
|
92
|
+
focus: 'before',
|
|
93
|
+
});
|
|
100
94
|
</script>
|
|
101
95
|
|
|
102
96
|
{#key selectionTypeMatches}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import { getContext } from 'svelte';
|
|
23
23
|
import { detectEmojiTrigger, getEmojiInsertText } from '../../emoji/emoji.js';
|
|
24
24
|
import EmojiSuggestions from '../../emoji/emoji-suggestions.svelte';
|
|
25
|
+
import { mergeUnregisters } from '../utils.js';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* @import { EmojiAnchorRect, EmojiEntry, EmojiTrigger, TextEditorStore } from '../../../typedefs.js';
|
|
@@ -135,7 +136,7 @@
|
|
|
135
136
|
* shortcodes. The shortcuts are registered with the highest priority, so they take precedence
|
|
136
137
|
* over the editor’s own handling while the list is open, and return `false` otherwise to leave
|
|
137
138
|
* the editor alone.
|
|
138
|
-
* @returns {
|
|
139
|
+
* @returns {() => void} Cleanup handler.
|
|
139
140
|
*/
|
|
140
141
|
const registerCommands = () => {
|
|
141
142
|
const { editor } = editorStore;
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
// Only called from the effect below, once the editor is there
|
|
144
145
|
/* v8 ignore next */
|
|
145
146
|
if (!editor) {
|
|
146
|
-
return
|
|
147
|
+
return mergeUnregisters();
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
/**
|
|
@@ -162,7 +163,7 @@
|
|
|
162
163
|
return true;
|
|
163
164
|
};
|
|
164
165
|
|
|
165
|
-
return
|
|
166
|
+
return mergeUnregisters(
|
|
166
167
|
editor.registerCommand(
|
|
167
168
|
KEY_ARROW_DOWN_COMMAND,
|
|
168
169
|
whileOpen(() => list?.moveSelection(1)),
|
|
@@ -198,7 +199,7 @@
|
|
|
198
199
|
|
|
199
200
|
list?.update(trigger);
|
|
200
201
|
}),
|
|
201
|
-
|
|
202
|
+
);
|
|
202
203
|
};
|
|
203
204
|
|
|
204
205
|
$effect(() => {
|
|
@@ -208,10 +209,10 @@
|
|
|
208
209
|
return undefined;
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
const
|
|
212
|
+
const unregister = registerCommands();
|
|
212
213
|
|
|
213
214
|
return () => {
|
|
214
|
-
|
|
215
|
+
unregister();
|
|
215
216
|
list?.close();
|
|
216
217
|
};
|
|
217
218
|
});
|
|
@@ -26,17 +26,19 @@
|
|
|
26
26
|
$setSelection as setSelection,
|
|
27
27
|
} from 'lexical';
|
|
28
28
|
import { getContext, onMount, tick, untrack } from 'svelte';
|
|
29
|
+
import { on } from 'svelte/events';
|
|
29
30
|
import Button from '../../button/button.svelte';
|
|
30
31
|
import { getSuggestionListPosition } from '../../emoji/position.js';
|
|
31
32
|
import Icon from '../../icon/icon.svelte';
|
|
32
33
|
import TextInput from '../../text-field/text-input.svelte';
|
|
33
34
|
import { OPEN_LINK_EDITOR_COMMAND } from '../constants.js';
|
|
34
|
-
import { focusEditor } from '../editing/caret.js';
|
|
35
35
|
import {
|
|
36
36
|
$findSelectedLink as findSelectedLink,
|
|
37
37
|
getLinkAnchorRect,
|
|
38
38
|
isSafeLinkURL,
|
|
39
39
|
} from '../editing/link.js';
|
|
40
|
+
import { refocusEditor } from '../toolbar/actions.js';
|
|
41
|
+
import { mergeUnregisters } from '../utils.js';
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
44
|
* @import { LexicalEditor, RangeSelection } from 'lexical';
|
|
@@ -194,17 +196,6 @@
|
|
|
194
196
|
openInNewTab = false;
|
|
195
197
|
};
|
|
196
198
|
|
|
197
|
-
/**
|
|
198
|
-
* Move the focus back to the editor, where the selection is restored, after the popup is done.
|
|
199
|
-
*/
|
|
200
|
-
const refocusEditor = async () => {
|
|
201
|
-
// The editor is there for as long as the popup can be shown
|
|
202
|
-
/* v8 ignore else */
|
|
203
|
-
if (editorStore.editor) {
|
|
204
|
-
await focusEditor(editorStore.editor);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
199
|
/**
|
|
209
200
|
* Start editing the link at the selection, or start linking the selected text. This is the
|
|
210
201
|
* handler for {@link OPEN_LINK_EDITOR_COMMAND}.
|
|
@@ -302,7 +293,8 @@
|
|
|
302
293
|
);
|
|
303
294
|
}
|
|
304
295
|
|
|
305
|
-
|
|
296
|
+
// Move the focus back to the editor, where the selection is restored
|
|
297
|
+
await refocusEditor(editorStore);
|
|
306
298
|
};
|
|
307
299
|
|
|
308
300
|
/**
|
|
@@ -310,7 +302,7 @@
|
|
|
310
302
|
*/
|
|
311
303
|
const cancelEditing = async () => {
|
|
312
304
|
stopEditing();
|
|
313
|
-
await refocusEditor();
|
|
305
|
+
await refocusEditor(editorStore);
|
|
314
306
|
};
|
|
315
307
|
|
|
316
308
|
/**
|
|
@@ -338,7 +330,7 @@
|
|
|
338
330
|
}
|
|
339
331
|
});
|
|
340
332
|
|
|
341
|
-
await refocusEditor();
|
|
333
|
+
await refocusEditor(editorStore);
|
|
342
334
|
};
|
|
343
335
|
|
|
344
336
|
/**
|
|
@@ -432,12 +424,12 @@
|
|
|
432
424
|
}
|
|
433
425
|
});
|
|
434
426
|
|
|
435
|
-
return (
|
|
436
|
-
unregisterCommand
|
|
437
|
-
unregisterEscape
|
|
438
|
-
unregisterUpdateListener
|
|
439
|
-
unregisterEditableListener
|
|
440
|
-
|
|
427
|
+
return mergeUnregisters(
|
|
428
|
+
unregisterCommand,
|
|
429
|
+
unregisterEscape,
|
|
430
|
+
unregisterUpdateListener,
|
|
431
|
+
unregisterEditableListener,
|
|
432
|
+
);
|
|
441
433
|
});
|
|
442
434
|
|
|
443
435
|
// The rich text editor can be swapped for the plain text one at any time, in which case there is
|
|
@@ -516,17 +508,12 @@
|
|
|
516
508
|
}
|
|
517
509
|
};
|
|
518
510
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
window.removeEventListener('scroll', reposition, { capture: true });
|
|
526
|
-
window.removeEventListener('resize', reposition);
|
|
527
|
-
document.removeEventListener('focusin', onFocusIn);
|
|
528
|
-
document.removeEventListener('focusout', onFocusOut);
|
|
529
|
-
};
|
|
511
|
+
return mergeUnregisters(
|
|
512
|
+
on(window, 'scroll', reposition, { capture: true, passive: true }),
|
|
513
|
+
on(window, 'resize', reposition, { passive: true }),
|
|
514
|
+
on(document, 'focusin', onFocusIn),
|
|
515
|
+
on(document, 'focusout', onFocusOut),
|
|
516
|
+
);
|
|
530
517
|
});
|
|
531
518
|
</script>
|
|
532
519
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
<script>
|
|
9
9
|
import { _ } from '@sveltia/i18n';
|
|
10
10
|
import { getContext, onMount } from 'svelte';
|
|
11
|
+
import { on } from 'svelte/events';
|
|
11
12
|
import Icon from '../../icon/icon.svelte';
|
|
12
13
|
import MenuButton from '../../menu/menu-button.svelte';
|
|
13
14
|
import {
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
isRightToLeftTable,
|
|
16
17
|
} from '../editing/table.js';
|
|
17
18
|
import TableActionMenu from '../toolbar/table-action-menu.svelte';
|
|
19
|
+
import { mergeUnregisters } from '../utils.js';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* @import { PopupPosition, TextEditorStore } from '../../../typedefs.js';
|
|
@@ -140,44 +142,38 @@
|
|
|
140
142
|
return undefined;
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
return () => {
|
|
166
|
-
unregisterUpdateListener();
|
|
167
|
-
unregisterRootListener();
|
|
168
|
-
};
|
|
145
|
+
return mergeUnregisters(
|
|
146
|
+
editor.registerUpdateListener(({ editorState }) => {
|
|
147
|
+
cellKey = editorState.read(getSelectedTableCellKey);
|
|
148
|
+
reposition();
|
|
149
|
+
}),
|
|
150
|
+
// Follow the cell when a wide table is scrolled, or the editor is resized
|
|
151
|
+
editor.registerRootListener((root) => {
|
|
152
|
+
if (!root) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const resizeObserver = new ResizeObserver(reposition);
|
|
157
|
+
|
|
158
|
+
resizeObserver.observe(root);
|
|
159
|
+
|
|
160
|
+
return mergeUnregisters(on(root, 'scroll', reposition, { capture: true }), () => {
|
|
161
|
+
resizeObserver.disconnect();
|
|
162
|
+
});
|
|
163
|
+
}),
|
|
164
|
+
);
|
|
169
165
|
});
|
|
170
166
|
|
|
171
167
|
onMount(() => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
168
|
+
const unregister = mergeUnregisters(
|
|
169
|
+
on(window, 'resize', reposition),
|
|
170
|
+
on(document, 'focusin', updateFocus),
|
|
171
|
+
on(document, 'focusout', updateFocus),
|
|
172
|
+
);
|
|
175
173
|
|
|
176
174
|
return () => {
|
|
177
175
|
window.clearTimeout(focusTimer);
|
|
178
|
-
|
|
179
|
-
document.removeEventListener('focusin', updateFocus);
|
|
180
|
-
document.removeEventListener('focusout', updateFocus);
|
|
176
|
+
unregister();
|
|
181
177
|
};
|
|
182
178
|
});
|
|
183
179
|
</script>
|