@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
|
@@ -1,45 +1,34 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { $getRoot as getRoot, HISTORY_MERGE_TAG } from 'lexical';
|
|
3
3
|
import { getContext, onMount, untrack } from 'svelte';
|
|
4
|
+
import { on } from 'svelte/events';
|
|
4
5
|
import { IMPORT_UPDATE_TAG } from './constants.js';
|
|
5
6
|
import { handleEditorMouseDown, isStaticDecoratorContent } from './editing/caret.js';
|
|
6
7
|
import { initEditor } from './core.js';
|
|
8
|
+
import { mergeUnregisters } from './utils.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
* @import {
|
|
10
|
-
* @import { TextEditorStore } from '../../typedefs.js';
|
|
11
|
+
* @import { ExportDetail } from './conversion/update.js';
|
|
12
|
+
* @import { FormFieldStateProps, TextEditorStore, WidgetStateProps } from '../../typedefs.js';
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* @typedef {object} Props
|
|
15
|
-
* @property {string} [class] The `class` attribute on the wrapper element.
|
|
16
17
|
* @property {'ltr' | 'rtl' | 'auto'} [dir] Direction of the text. With `auto` or no value, each
|
|
17
18
|
* paragraph takes the direction of its own text.
|
|
18
|
-
* @property {boolean} [hidden] Whether to hide the widget.
|
|
19
|
-
* @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
|
|
20
|
-
* attribute.
|
|
21
|
-
* @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
|
|
22
|
-
* `aria-readonly` attribute.
|
|
23
|
-
* @property {boolean} [required] Whether to mark the widget required. An alias of the
|
|
24
|
-
* `aria-required` attribute.
|
|
25
|
-
* @property {boolean} [invalid] Whether to mark the widget invalid. An alias of the
|
|
26
|
-
* `aria-invalid` attribute.
|
|
27
|
-
* @property {Snippet} [children] Primary slot content.
|
|
28
19
|
*/
|
|
29
20
|
|
|
30
21
|
/**
|
|
31
|
-
* @type {Props & Record<string, any>}
|
|
22
|
+
* @type {WidgetStateProps & FormFieldStateProps & Props & Record<string, any>}
|
|
32
23
|
*/
|
|
33
24
|
let {
|
|
34
25
|
/* eslint-disable prefer-const */
|
|
35
|
-
class: className,
|
|
36
26
|
dir = undefined,
|
|
37
27
|
hidden = false,
|
|
38
28
|
disabled = false,
|
|
39
29
|
readonly = false,
|
|
40
30
|
required = false,
|
|
41
31
|
invalid = false,
|
|
42
|
-
children,
|
|
43
32
|
...restProps
|
|
44
33
|
/* eslint-enable prefer-const */
|
|
45
34
|
} = $props();
|
|
@@ -80,10 +69,10 @@
|
|
|
80
69
|
});
|
|
81
70
|
|
|
82
71
|
/**
|
|
83
|
-
* Update
|
|
84
|
-
* @param {
|
|
72
|
+
* Update the input value and the selection state whenever the editor exports its content.
|
|
73
|
+
* @param {ExportDetail} detail Exported value and selection state.
|
|
85
74
|
*/
|
|
86
|
-
const
|
|
75
|
+
const onExport = ({ value: exportedValue, selection }) => {
|
|
87
76
|
const { hasConverterError, useRichText, inputValue } = editorStore;
|
|
88
77
|
|
|
89
78
|
// The content has been converted, if it has changed at all
|
|
@@ -95,18 +84,13 @@
|
|
|
95
84
|
return;
|
|
96
85
|
}
|
|
97
86
|
|
|
98
|
-
const { value: exportedValue, selection } = /** @type {CustomEvent} */ (event).detail;
|
|
99
87
|
// Keep the value as given when the content is the one last imported, which the editor only
|
|
100
88
|
// writes in its own Markdown style, e.g. `_text_` for `*text*`: that’s not a change, whether
|
|
101
89
|
// the content is untouched or the user has undone their changes to it
|
|
102
90
|
const newValue = editorStore.getImportedValue(exportedValue) ?? exportedValue;
|
|
103
91
|
|
|
104
92
|
if (inputValue !== newValue) {
|
|
105
|
-
|
|
106
|
-
// Lexical nodes and selection, then restore the state
|
|
107
|
-
editorStore.useRichText = false;
|
|
108
|
-
editorStore.inputValue = newValue;
|
|
109
|
-
editorStore.useRichText = true;
|
|
93
|
+
editorStore.setExportedValue(newValue);
|
|
110
94
|
}
|
|
111
95
|
|
|
112
96
|
editorStore.selection = selection;
|
|
@@ -230,24 +214,45 @@
|
|
|
230
214
|
}
|
|
231
215
|
};
|
|
232
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Pass what was just typed on as soon as the focus leaves the editor, rather than after the
|
|
219
|
+
* delay, so the value is up to date by the time the user acts on it, like with a button. That
|
|
220
|
+
* includes a nested editor in a component, which passes the change on to this editor through the
|
|
221
|
+
* component.
|
|
222
|
+
* @param {FocusEvent} event `focusout` event.
|
|
223
|
+
*/
|
|
224
|
+
const onRootFocusOut = ({ relatedTarget }) => {
|
|
225
|
+
if (!lexicalRoot?.contains(/** @type {Node | null} */ (relatedTarget))) {
|
|
226
|
+
// The root may be being removed; see above
|
|
227
|
+
untrack(() => {
|
|
228
|
+
editorStore.flushExport();
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
233
|
onMount(() => {
|
|
234
|
-
const { editor, enabledTransformers, dispose } = initEditor(editorStore.config
|
|
234
|
+
const { editor, enabledTransformers, flush, dispose } = initEditor(editorStore.config, {
|
|
235
|
+
onExport,
|
|
236
|
+
});
|
|
235
237
|
|
|
236
238
|
editorStore.editor = editor;
|
|
237
239
|
editorStore.enabledTransformers = enabledTransformers;
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
lexicalRoot
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
240
|
+
editorStore.flushExport = flush;
|
|
241
|
+
|
|
242
|
+
// The root is bound before this runs
|
|
243
|
+
const root = /** @type {HTMLElement} */ (lexicalRoot);
|
|
244
|
+
|
|
245
|
+
const unregister = mergeUnregisters(
|
|
246
|
+
on(root, 'focusout', onRootFocusOut),
|
|
247
|
+
on(root, 'click', onClick),
|
|
248
|
+
on(root, 'mousedown', onMouseDown),
|
|
249
|
+
on(root, 'mousedown', onComponentMouseDown),
|
|
250
|
+
on(document, 'focusin', onFocusIn),
|
|
251
|
+
on(document, 'focusout', onFocusOut),
|
|
252
|
+
// A change made by the user is converted to Markdown a moment later, so report it as pending
|
|
253
|
+
// until then. An import, or an update that only changes how the content looks, e.g. the code
|
|
254
|
+
// highlighting, isn’t a change
|
|
255
|
+
editor.registerUpdateListener(({ dirtyElements, dirtyLeaves, tags }) => {
|
|
251
256
|
if (
|
|
252
257
|
(dirtyElements.size || dirtyLeaves.size) &&
|
|
253
258
|
!tags.has(IMPORT_UPDATE_TAG) &&
|
|
@@ -259,17 +264,14 @@
|
|
|
259
264
|
// An editor component with the focus may have been removed, which doesn’t fire `focusout`
|
|
260
265
|
// in Firefox and Safari
|
|
261
266
|
checkComponentFocus();
|
|
262
|
-
},
|
|
267
|
+
}),
|
|
263
268
|
);
|
|
264
269
|
|
|
265
270
|
return () => {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
lexicalRoot?.removeEventListener('mousedown', onComponentMouseDown);
|
|
271
|
-
document.removeEventListener('focusin', onFocusIn);
|
|
272
|
-
document.removeEventListener('focusout', onFocusOut);
|
|
271
|
+
// Pass on what was just typed, as Firefox and Safari don’t fire `focusout` when the focused
|
|
272
|
+
// root is removed. This does nothing if the change has been passed on already
|
|
273
|
+
flush();
|
|
274
|
+
unregister();
|
|
273
275
|
dispose();
|
|
274
276
|
editor.setRootElement(null);
|
|
275
277
|
editorStore.initialized = false;
|
|
@@ -346,12 +348,52 @@
|
|
|
346
348
|
.lexical-root :global(strong.italic) {
|
|
347
349
|
font-style: italic;
|
|
348
350
|
}
|
|
351
|
+
.lexical-root :global(.underline) {
|
|
352
|
+
text-decoration: underline;
|
|
353
|
+
}
|
|
349
354
|
.lexical-root :global(.strikethrough) {
|
|
350
355
|
text-decoration: line-through;
|
|
351
356
|
}
|
|
357
|
+
.lexical-root :global(.underline.strikethrough) {
|
|
358
|
+
text-decoration: underline line-through;
|
|
359
|
+
}
|
|
352
360
|
.lexical-root :global(li.nested) {
|
|
353
361
|
list-style-type: none;
|
|
354
362
|
}
|
|
363
|
+
.lexical-root :global(li.task-list-item:not(.nested)) {
|
|
364
|
+
position: relative;
|
|
365
|
+
padding-inline-start: 1.5em;
|
|
366
|
+
list-style-type: none;
|
|
367
|
+
}
|
|
368
|
+
.lexical-root :global(li.task-list-item:not(.nested)::before) {
|
|
369
|
+
position: absolute;
|
|
370
|
+
inset-block-start: calc((1lh - 1em) / 2);
|
|
371
|
+
inset-inline-start: 0;
|
|
372
|
+
border: var(--sui-checkbox-border-width, 1.5px) solid var(--sui-checkbox-border-color);
|
|
373
|
+
border-radius: var(--sui-checkbox-border-radius);
|
|
374
|
+
width: 1em;
|
|
375
|
+
height: 1em;
|
|
376
|
+
background-color: var(--sui-checkbox-background-color);
|
|
377
|
+
content: "";
|
|
378
|
+
cursor: pointer;
|
|
379
|
+
}
|
|
380
|
+
.lexical-root :global(li.task-list-item:not(.nested).checked::before) {
|
|
381
|
+
border-color: var(--sui-checkbox-border-color-checked, var(--sui-primary-accent-color));
|
|
382
|
+
background-color: var(--sui-checkbox-background-color-checked, var(--sui-primary-accent-color));
|
|
383
|
+
}
|
|
384
|
+
.lexical-root :global(li.task-list-item:not(.nested).checked::after) {
|
|
385
|
+
position: absolute;
|
|
386
|
+
inset-block-start: calc((1lh - 1em) / 2 + 0.15em);
|
|
387
|
+
inset-inline-start: 0.35em;
|
|
388
|
+
border-width: 0 2px 2px 0;
|
|
389
|
+
border-style: solid;
|
|
390
|
+
border-color: var(--sui-checkbox-foreground-color-checked, var(--sui-primary-accent-color-inverted));
|
|
391
|
+
width: 0.3em;
|
|
392
|
+
height: 0.55em;
|
|
393
|
+
content: "";
|
|
394
|
+
transform: rotate(45deg);
|
|
395
|
+
pointer-events: none;
|
|
396
|
+
}
|
|
355
397
|
.lexical-root :global(.code-block) {
|
|
356
398
|
position: relative;
|
|
357
399
|
display: block;
|
|
@@ -1,84 +1,21 @@
|
|
|
1
1
|
export default LexicalRoot;
|
|
2
2
|
type LexicalRoot = {
|
|
3
3
|
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
-
$set?(props: Partial<Props & Record<string, any>>): void;
|
|
4
|
+
$set?(props: Partial<WidgetStateProps & FormFieldStateProps & Props & Record<string, any>>): void;
|
|
5
5
|
};
|
|
6
|
-
declare const LexicalRoot: import("svelte").Component<{
|
|
7
|
-
/**
|
|
8
|
-
* The `class` attribute on the wrapper element.
|
|
9
|
-
*/
|
|
10
|
-
class?: string | undefined;
|
|
6
|
+
declare const LexicalRoot: import("svelte").Component<WidgetStateProps & FormFieldStateProps & {
|
|
11
7
|
/**
|
|
12
8
|
* Direction of the text. With `auto` or no value, each
|
|
13
9
|
* paragraph takes the direction of its own text.
|
|
14
10
|
*/
|
|
15
11
|
dir?: "ltr" | "rtl" | "auto" | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Whether to hide the widget.
|
|
18
|
-
*/
|
|
19
|
-
hidden?: boolean | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Whether to disable the widget. An alias of the `aria-disabled`
|
|
22
|
-
* attribute.
|
|
23
|
-
*/
|
|
24
|
-
disabled?: boolean | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Whether to make the widget read-only. An alias of the
|
|
27
|
-
* `aria-readonly` attribute.
|
|
28
|
-
*/
|
|
29
|
-
readonly?: boolean | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Whether to mark the widget required. An alias of the
|
|
32
|
-
* `aria-required` attribute.
|
|
33
|
-
*/
|
|
34
|
-
required?: boolean | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Whether to mark the widget invalid. An alias of the
|
|
37
|
-
* `aria-invalid` attribute.
|
|
38
|
-
*/
|
|
39
|
-
invalid?: boolean | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Primary slot content.
|
|
42
|
-
*/
|
|
43
|
-
children?: Snippet<[]> | undefined;
|
|
44
12
|
} & Record<string, any>, {}, "">;
|
|
45
13
|
type Props = {
|
|
46
|
-
/**
|
|
47
|
-
* The `class` attribute on the wrapper element.
|
|
48
|
-
*/
|
|
49
|
-
class?: string | undefined;
|
|
50
14
|
/**
|
|
51
15
|
* Direction of the text. With `auto` or no value, each
|
|
52
16
|
* paragraph takes the direction of its own text.
|
|
53
17
|
*/
|
|
54
18
|
dir?: "ltr" | "rtl" | "auto" | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* Whether to hide the widget.
|
|
57
|
-
*/
|
|
58
|
-
hidden?: boolean | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* Whether to disable the widget. An alias of the `aria-disabled`
|
|
61
|
-
* attribute.
|
|
62
|
-
*/
|
|
63
|
-
disabled?: boolean | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* Whether to make the widget read-only. An alias of the
|
|
66
|
-
* `aria-readonly` attribute.
|
|
67
|
-
*/
|
|
68
|
-
readonly?: boolean | undefined;
|
|
69
|
-
/**
|
|
70
|
-
* Whether to mark the widget required. An alias of the
|
|
71
|
-
* `aria-required` attribute.
|
|
72
|
-
*/
|
|
73
|
-
required?: boolean | undefined;
|
|
74
|
-
/**
|
|
75
|
-
* Whether to mark the widget invalid. An alias of the
|
|
76
|
-
* `aria-invalid` attribute.
|
|
77
|
-
*/
|
|
78
|
-
invalid?: boolean | undefined;
|
|
79
|
-
/**
|
|
80
|
-
* Primary slot content.
|
|
81
|
-
*/
|
|
82
|
-
children?: Snippet<[]> | undefined;
|
|
83
19
|
};
|
|
84
|
-
import type {
|
|
20
|
+
import type { WidgetStateProps } from '../../typedefs.js';
|
|
21
|
+
import type { FormFieldStateProps } from '../../typedefs.js';
|
|
@@ -2,20 +2,20 @@ export function isPlainLanguage(language: string | null | undefined): boolean;
|
|
|
2
2
|
export function isEngineLoaded(): boolean;
|
|
3
3
|
export function isEngineUnavailable(): boolean;
|
|
4
4
|
export function isCodeLanguageLoaded(language: string): boolean;
|
|
5
|
-
export function loadEngine(
|
|
5
|
+
export function loadEngine(onLoaded?: () => void): Promise<void> | undefined;
|
|
6
6
|
export function normalizeCodeLanguage(language: string): string;
|
|
7
|
-
export function loadCodeLanguage(language: string,
|
|
7
|
+
export function loadCodeLanguage(language: string, onLoaded?: () => void): Promise<void> | undefined;
|
|
8
8
|
export function isCodeThemeLoaded(theme: string): boolean;
|
|
9
|
-
export function loadCodeTheme(theme: string,
|
|
10
|
-
export function
|
|
9
|
+
export function loadCodeTheme(theme: string, onLoaded?: () => void): Promise<void> | undefined;
|
|
10
|
+
export function tokenizeCode(code: string, language: string, theme?: string): {
|
|
11
|
+
tokens: any[][];
|
|
12
|
+
diff: boolean;
|
|
13
|
+
};
|
|
14
|
+
export function getTokenStyle(token: any): string;
|
|
11
15
|
export function highlightCodeToHTML(code: string, language: string, { theme }?: {
|
|
12
16
|
theme?: string | undefined;
|
|
13
17
|
}): string | undefined;
|
|
14
18
|
export function highlightCodeToTokens(code: string, language: string, { theme }?: {
|
|
15
19
|
theme?: string | undefined;
|
|
16
20
|
}): HighlightedToken[][] | undefined;
|
|
17
|
-
import type { LexicalEditor } from 'lexical';
|
|
18
|
-
import type { NodeKey } from 'lexical';
|
|
19
|
-
import type { CodeNode } from '@lexical/code-core';
|
|
20
|
-
import type { LexicalNode } from 'lexical';
|
|
21
21
|
import type { HighlightedToken } from '../../../typedefs.js';
|