@sveltia/ui 0.25.7 → 0.25.8

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.
Files changed (179) hide show
  1. package/dist/components/alert/alert.svelte +7 -3
  2. package/dist/components/alert/alert.svelte.d.ts +11 -10
  3. package/dist/components/alert/infobar.svelte +9 -5
  4. package/dist/components/alert/infobar.svelte.d.ts +15 -14
  5. package/dist/components/button/button-group.svelte +6 -2
  6. package/dist/components/button/button-group.svelte.d.ts +7 -6
  7. package/dist/components/button/button.svelte +5 -2
  8. package/dist/components/button/button.svelte.d.ts +2 -1
  9. package/dist/components/button/select-button-group.svelte +12 -8
  10. package/dist/components/button/select-button-group.svelte.d.ts +19 -18
  11. package/dist/components/button/select-button.svelte +6 -3
  12. package/dist/components/button/select-button.svelte.d.ts +4 -3
  13. package/dist/components/button/split-button.svelte +10 -7
  14. package/dist/components/button/split-button.svelte.d.ts +18 -17
  15. package/dist/components/calendar/calendar.svelte +1 -1
  16. package/dist/components/calendar/calendar.svelte.d.ts +2 -2
  17. package/dist/components/checkbox/checkbox-group.svelte +9 -5
  18. package/dist/components/checkbox/checkbox-group.svelte.d.ts +13 -12
  19. package/dist/components/checkbox/checkbox.svelte +13 -9
  20. package/dist/components/checkbox/checkbox.svelte.d.ts +19 -17
  21. package/dist/components/dialog/alert-dialog.svelte +5 -2
  22. package/dist/components/dialog/alert-dialog.svelte.d.ts +3 -1
  23. package/dist/components/dialog/confirmation-dialog.svelte +5 -2
  24. package/dist/components/dialog/confirmation-dialog.svelte.d.ts +3 -1
  25. package/dist/components/dialog/dialog.svelte +5 -2
  26. package/dist/components/dialog/dialog.svelte.d.ts +3 -1
  27. package/dist/components/dialog/prompt-dialog.svelte +16 -7
  28. package/dist/components/dialog/prompt-dialog.svelte.d.ts +17 -13
  29. package/dist/components/disclosure/disclosure.svelte +12 -8
  30. package/dist/components/disclosure/disclosure.svelte.d.ts +21 -20
  31. package/dist/components/divider/divider.svelte +3 -3
  32. package/dist/components/divider/divider.svelte.d.ts +6 -6
  33. package/dist/components/divider/spacer.svelte +2 -2
  34. package/dist/components/divider/spacer.svelte.d.ts +4 -4
  35. package/dist/components/drawer/drawer.svelte +18 -13
  36. package/dist/components/drawer/drawer.svelte.d.ts +39 -37
  37. package/dist/components/grid/grid-body.svelte +7 -3
  38. package/dist/components/grid/grid-body.svelte.d.ts +9 -8
  39. package/dist/components/grid/grid-cell.svelte +6 -2
  40. package/dist/components/grid/grid-cell.svelte.d.ts +7 -6
  41. package/dist/components/grid/grid-col-header.svelte +6 -2
  42. package/dist/components/grid/grid-col-header.svelte.d.ts +7 -6
  43. package/dist/components/grid/grid-foot.svelte +6 -2
  44. package/dist/components/grid/grid-foot.svelte.d.ts +7 -6
  45. package/dist/components/grid/grid-head.svelte +6 -2
  46. package/dist/components/grid/grid-head.svelte.d.ts +7 -6
  47. package/dist/components/grid/grid-row-header.svelte +6 -2
  48. package/dist/components/grid/grid-row-header.svelte.d.ts +7 -6
  49. package/dist/components/grid/grid-row.svelte +9 -5
  50. package/dist/components/grid/grid-row.svelte.d.ts +13 -12
  51. package/dist/components/grid/grid.svelte +10 -6
  52. package/dist/components/grid/grid.svelte.d.ts +15 -14
  53. package/dist/components/icon/icon.svelte +2 -2
  54. package/dist/components/icon/icon.svelte.d.ts +4 -4
  55. package/dist/components/listbox/listbox.svelte +18 -13
  56. package/dist/components/listbox/listbox.svelte.d.ts +27 -26
  57. package/dist/components/listbox/option-group.svelte +9 -5
  58. package/dist/components/listbox/option-group.svelte.d.ts +13 -12
  59. package/dist/components/listbox/option.svelte +12 -8
  60. package/dist/components/listbox/option.svelte.d.ts +17 -15
  61. package/dist/components/menu/menu-button.svelte +7 -4
  62. package/dist/components/menu/menu-button.svelte.d.ts +6 -5
  63. package/dist/components/menu/menu-item-checkbox.svelte +5 -2
  64. package/dist/components/menu/menu-item-checkbox.svelte.d.ts +3 -1
  65. package/dist/components/menu/menu-item-group.svelte +9 -5
  66. package/dist/components/menu/menu-item-group.svelte.d.ts +8 -8
  67. package/dist/components/menu/menu-item-radio.svelte +5 -2
  68. package/dist/components/menu/menu-item-radio.svelte.d.ts +3 -1
  69. package/dist/components/menu/menu-item.svelte +5 -2
  70. package/dist/components/menu/menu-item.svelte.d.ts +3 -1
  71. package/dist/components/menu/menu.svelte +9 -5
  72. package/dist/components/menu/menu.svelte.d.ts +13 -12
  73. package/dist/components/progressbar/progressbar.svelte +5 -5
  74. package/dist/components/progressbar/progressbar.svelte.d.ts +10 -10
  75. package/dist/components/radio/radio-group.svelte +13 -9
  76. package/dist/components/radio/radio-group.svelte.d.ts +21 -20
  77. package/dist/components/radio/radio.svelte +15 -11
  78. package/dist/components/radio/radio.svelte.d.ts +27 -26
  79. package/dist/components/select/combobox.svelte +6 -3
  80. package/dist/components/select/combobox.svelte.d.ts +3 -1
  81. package/dist/components/select/select-tags.svelte +16 -13
  82. package/dist/components/select/select-tags.svelte.d.ts +27 -28
  83. package/dist/components/select/select.svelte +5 -1
  84. package/dist/components/select/select.svelte.d.ts +2 -1
  85. package/dist/components/slider/slider.svelte +27 -25
  86. package/dist/components/slider/slider.svelte.d.ts +35 -34
  87. package/dist/components/switch/switch.svelte +13 -9
  88. package/dist/components/switch/switch.svelte.d.ts +21 -20
  89. package/dist/components/table/table-body.svelte +7 -3
  90. package/dist/components/table/table-body.svelte.d.ts +9 -8
  91. package/dist/components/table/table-cell.svelte +6 -2
  92. package/dist/components/table/table-cell.svelte.d.ts +7 -6
  93. package/dist/components/table/table-col-header.svelte +6 -2
  94. package/dist/components/table/table-col-header.svelte.d.ts +7 -6
  95. package/dist/components/table/table-foot.svelte +6 -2
  96. package/dist/components/table/table-foot.svelte.d.ts +7 -6
  97. package/dist/components/table/table-head.svelte +6 -2
  98. package/dist/components/table/table-head.svelte.d.ts +7 -6
  99. package/dist/components/table/table-row-header.svelte +6 -2
  100. package/dist/components/table/table-row-header.svelte.d.ts +7 -6
  101. package/dist/components/table/table-row.svelte +6 -2
  102. package/dist/components/table/table-row.svelte.d.ts +7 -6
  103. package/dist/components/table/table.svelte +6 -2
  104. package/dist/components/table/table.svelte.d.ts +7 -6
  105. package/dist/components/tabs/tab-box.svelte +7 -3
  106. package/dist/components/tabs/tab-box.svelte.d.ts +9 -8
  107. package/dist/components/tabs/tab-list.svelte +12 -8
  108. package/dist/components/tabs/tab-list.svelte.d.ts +19 -18
  109. package/dist/components/tabs/tab-panel.svelte +6 -2
  110. package/dist/components/tabs/tab-panel.svelte.d.ts +7 -6
  111. package/dist/components/tabs/tab-panels.svelte +6 -2
  112. package/dist/components/tabs/tab-panels.svelte.d.ts +7 -6
  113. package/dist/components/tabs/tab.svelte +6 -3
  114. package/dist/components/tabs/tab.svelte.d.ts +4 -3
  115. package/dist/components/text-editor/code-editor.svelte +15 -11
  116. package/dist/components/text-editor/code-editor.svelte.d.ts +25 -24
  117. package/dist/components/text-editor/core.d.ts +5 -3
  118. package/dist/components/text-editor/core.js +21 -11
  119. package/dist/components/text-editor/index.d.ts +12 -6
  120. package/dist/components/text-editor/index.js +7 -3
  121. package/dist/components/text-editor/lexical-root.svelte +25 -28
  122. package/dist/components/text-editor/lexical-root.svelte.d.ts +17 -16
  123. package/dist/components/text-editor/store.svelte.d.ts +2 -1
  124. package/dist/components/text-editor/store.svelte.js +9 -4
  125. package/dist/components/text-editor/text-editor.svelte +22 -13
  126. package/dist/components/text-editor/text-editor.svelte.d.ts +37 -32
  127. package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte +3 -3
  128. package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte.d.ts +6 -6
  129. package/dist/components/text-editor/toolbar/code-language-switcher.svelte +6 -2
  130. package/dist/components/text-editor/toolbar/code-language-switcher.svelte.d.ts +2 -2
  131. package/dist/components/text-editor/toolbar/format-text-button.svelte +6 -2
  132. package/dist/components/text-editor/toolbar/format-text-button.svelte.d.ts +5 -4
  133. package/dist/components/text-editor/toolbar/insert-image-button.svelte +6 -2
  134. package/dist/components/text-editor/toolbar/insert-image-button.svelte.d.ts +5 -4
  135. package/dist/components/text-editor/toolbar/insert-link-button.svelte +9 -4
  136. package/dist/components/text-editor/toolbar/insert-menu-button.svelte +6 -2
  137. package/dist/components/text-editor/toolbar/insert-menu-button.svelte.d.ts +5 -4
  138. package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +10 -6
  139. package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte.d.ts +6 -6
  140. package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +8 -5
  141. package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte.d.ts +5 -4
  142. package/dist/components/text-editor/toolbar/toolbar-wrapper.svelte +7 -3
  143. package/dist/components/text-editor/toolbar/toolbar-wrapper.svelte.d.ts +9 -8
  144. package/dist/components/text-editor/transformers/table.d.ts +3 -2
  145. package/dist/components/text-editor/transformers/table.js +5 -1
  146. package/dist/components/text-field/number-input.svelte +12 -8
  147. package/dist/components/text-field/number-input.svelte.d.ts +20 -17
  148. package/dist/components/text-field/password-input.svelte +8 -4
  149. package/dist/components/text-field/password-input.svelte.d.ts +10 -7
  150. package/dist/components/text-field/search-bar.svelte +9 -5
  151. package/dist/components/text-field/search-bar.svelte.d.ts +14 -11
  152. package/dist/components/text-field/text-area.svelte +18 -14
  153. package/dist/components/text-field/text-area.svelte.d.ts +29 -27
  154. package/dist/components/text-field/text-input.svelte +7 -3
  155. package/dist/components/text-field/text-input.svelte.d.ts +5 -3
  156. package/dist/components/toast/toast.svelte +10 -5
  157. package/dist/components/toast/toast.svelte.d.ts +16 -14
  158. package/dist/components/toolbar/toolbar.svelte +11 -7
  159. package/dist/components/toolbar/toolbar.svelte.d.ts +17 -16
  160. package/dist/components/util/app-shell.svelte +6 -3
  161. package/dist/components/util/app-shell.svelte.d.ts +7 -8
  162. package/dist/components/util/group.svelte +8 -4
  163. package/dist/components/util/group.svelte.d.ts +11 -10
  164. package/dist/components/util/modal.svelte +7 -3
  165. package/dist/components/util/modal.svelte.d.ts +2 -1
  166. package/dist/components/util/placeholder.svelte +5 -1
  167. package/dist/components/util/placeholder.svelte.d.ts +5 -4
  168. package/dist/components/util/popup.svelte +23 -17
  169. package/dist/components/util/popup.svelte.d.ts +36 -33
  170. package/dist/index.js +3 -3
  171. package/dist/services/events.svelte.d.ts +2 -1
  172. package/dist/services/events.svelte.js +12 -8
  173. package/dist/services/group.svelte.d.ts +2 -1
  174. package/dist/services/group.svelte.js +16 -12
  175. package/dist/services/popup.svelte.d.ts +16 -10
  176. package/dist/services/popup.svelte.js +14 -13
  177. package/dist/typedefs.d.ts +191 -189
  178. package/dist/typedefs.js +168 -164
  179. package/package.json +1 -1
@@ -1,4 +1,6 @@
1
- export function initEditor({ components, isCodeEditor, defaultLanguage }: import("../../typedefs").TextEditorConfig): import("lexical").LexicalEditor;
1
+ export function initEditor({ components, isCodeEditor, defaultLanguage }: TextEditorConfig): LexicalEditor;
2
2
  export function loadCodeHighlighter(lang: string): Promise<void>;
3
- export function convertMarkdownToLexical(editor: import("lexical").LexicalEditor, value: string): Promise<void>;
4
- export function focusEditor(editor: import("lexical").LexicalEditor): Promise<void>;
3
+ export function convertMarkdownToLexical(editor: LexicalEditor, value: string): Promise<void>;
4
+ export function focusEditor(editor: LexicalEditor): Promise<void>;
5
+ import type { TextEditorConfig } from '../../typedefs';
6
+ import type { LexicalEditor } from 'lexical';
@@ -54,11 +54,21 @@ import prismComponents from 'prismjs/components';
54
54
  import { blockButtonTypes, textFormatButtonTypes } from '.';
55
55
  import { TABLE } from './transformers/table';
56
56
 
57
+ /**
58
+ * @import { CreateEditorArgs, LexicalEditor } from 'lexical';
59
+ * @import {
60
+ * TextEditorBlockType,
61
+ * TextEditorConfig,
62
+ * TextEditorInlineType,
63
+ * TextEditorSelectionState,
64
+ * } from '../../typedefs';
65
+ */
66
+
57
67
  const allTransformers = [...TRANSFORMERS, TABLE];
58
68
 
59
69
  /**
60
70
  * Lexical editor configuration.
61
- * @type {import('lexical').CreateEditorArgs}
71
+ * @type {CreateEditorArgs}
62
72
  */
63
73
  const editorConfig = {
64
74
  namespace: 'editor',
@@ -126,7 +136,7 @@ const editorConfig = {
126
136
 
127
137
  /**
128
138
  * Get the current selection’s block node key as well as block and inline level types.
129
- * @returns {import('../../typedefs').TextEditorSelectionState} Current selection state.
139
+ * @returns {TextEditorSelectionState} Current selection state.
130
140
  */
131
141
  const getSelectionTypes = () => {
132
142
  const selection = getSelection();
@@ -142,7 +152,7 @@ const getSelectionTypes = () => {
142
152
  const anchor = selection.anchor.getNode();
143
153
  /** @type {ElementNode | null} */
144
154
  let parent = null;
145
- /** @type {import('../../typedefs').TextEditorInlineType[]} */
155
+ /** @type {TextEditorInlineType[]} */
146
156
  const inlineTypes = textFormatButtonTypes.filter((type) => selection.hasFormat(type));
147
157
 
148
158
  if (anchor.getType() !== 'root') {
@@ -158,7 +168,7 @@ const getSelectionTypes = () => {
158
168
  }
159
169
  }
160
170
 
161
- const blockType = /** @type {import('../../typedefs').TextEditorBlockType} */ (
171
+ const blockType = /** @type {TextEditorBlockType} */ (
162
172
  (() => {
163
173
  if (!parent) {
164
174
  return 'paragraph';
@@ -199,7 +209,7 @@ const getSelectionTypes = () => {
199
209
 
200
210
  /**
201
211
  * Listen to changes made on the editor and trigger the Update event.
202
- * @param {import('lexical').LexicalEditor} editor - Editor instance.
212
+ * @param {LexicalEditor} editor Editor instance.
203
213
  */
204
214
  const onEditorUpdate = (editor) => {
205
215
  editor.getRootElement()?.dispatchEvent(
@@ -217,8 +227,8 @@ const onEditorUpdate = (editor) => {
217
227
 
218
228
  /**
219
229
  * Initialize the Lexical editor.
220
- * @param {import('../../typedefs').TextEditorConfig} config - Editor configuration.
221
- * @returns {import('lexical').LexicalEditor} Editor instance.
230
+ * @param {TextEditorConfig} config Editor configuration.
231
+ * @returns {LexicalEditor} Editor instance.
222
232
  */
223
233
  export const initEditor = ({ components = [], isCodeEditor = false, defaultLanguage = '' }) => {
224
234
  components.forEach(({ node, transformer }) => {
@@ -343,7 +353,7 @@ export const initEditor = ({ components = [], isCodeEditor = false, defaultLangu
343
353
 
344
354
  /**
345
355
  * Load additional Prism syntax highlighter settings for the given programming language.
346
- * @param {string} lang - Language name, like scss.
356
+ * @param {string} lang Language name, like scss.
347
357
  */
348
358
  export const loadCodeHighlighter = async (lang) => {
349
359
  if (lang in window.Prism.languages) {
@@ -372,8 +382,8 @@ export const loadCodeHighlighter = async (lang) => {
372
382
 
373
383
  /**
374
384
  * Convert Markdown to Lexical nodes.
375
- * @param {import('lexical').LexicalEditor} editor - Editor instance.
376
- * @param {string} value - Current Markdown value.
385
+ * @param {LexicalEditor} editor Editor instance.
386
+ * @param {string} value Current Markdown value.
377
387
  * @returns {Promise<void>} Nothing.
378
388
  * @throws {Error} Failed to convert the value to Lexical nodes.
379
389
  */
@@ -399,7 +409,7 @@ export const convertMarkdownToLexical = async (editor, value) => {
399
409
 
400
410
  /**
401
411
  * Move focus to the editor so the user can start editing immediately.
402
- * @param {import('lexical').LexicalEditor} editor - Editor instance.
412
+ * @param {LexicalEditor} editor Editor instance.
403
413
  * @returns {Promise<void>} Nothing.
404
414
  */
405
415
  export const focusEditor = async (editor) => {
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @import { TextEditorBlockType, TextEditorFormatType, TextEditorInlineType } from '../../typedefs';
3
+ */
1
4
  /**
2
5
  * List of available buttons.
3
6
  * @type {{ [key: string]: { labelKey: string, icon: string, inline: boolean } }}
@@ -10,14 +13,17 @@ export const availableButtons: {
10
13
  };
11
14
  };
12
15
  /**
13
- * @type {import('../../typedefs').TextEditorFormatType[]}
16
+ * @type {TextEditorFormatType[]}
14
17
  */
15
- export const textFormatButtonTypes: import("../../typedefs").TextEditorFormatType[];
18
+ export const textFormatButtonTypes: TextEditorFormatType[];
16
19
  /**
17
- * @type {import('../../typedefs').TextEditorInlineType[]}
20
+ * @type {TextEditorInlineType[]}
18
21
  */
19
- export const inlineButtonTypes: import("../../typedefs").TextEditorInlineType[];
22
+ export const inlineButtonTypes: TextEditorInlineType[];
20
23
  /**
21
- * @type {import('../../typedefs').TextEditorBlockType[]}
24
+ * @type {TextEditorBlockType[]}
22
25
  */
23
- export const blockButtonTypes: import("../../typedefs").TextEditorBlockType[];
26
+ export const blockButtonTypes: TextEditorBlockType[];
27
+ import type { TextEditorFormatType } from '../../typedefs';
28
+ import type { TextEditorInlineType } from '../../typedefs';
29
+ import type { TextEditorBlockType } from '../../typedefs';
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @import { TextEditorBlockType, TextEditorFormatType, TextEditorInlineType } from '../../typedefs';
3
+ */
4
+
1
5
  /**
2
6
  * List of available buttons.
3
7
  * @type {{ [key: string]: { labelKey: string, icon: string, inline: boolean } }}
@@ -80,15 +84,15 @@ export const availableButtons = {
80
84
  },
81
85
  };
82
86
  /**
83
- * @type {import('../../typedefs').TextEditorFormatType[]}
87
+ * @type {TextEditorFormatType[]}
84
88
  */
85
89
  export const textFormatButtonTypes = ['bold', 'italic', 'code'];
86
90
  /**
87
- * @type {import('../../typedefs').TextEditorInlineType[]}
91
+ * @type {TextEditorInlineType[]}
88
92
  */
89
93
  export const inlineButtonTypes = [...textFormatButtonTypes, 'link'];
90
94
  /**
91
- * @type {import('../../typedefs').TextEditorBlockType[]}
95
+ * @type {TextEditorBlockType[]}
92
96
  */
93
97
  export const blockButtonTypes = [
94
98
  'paragraph',
@@ -2,19 +2,24 @@
2
2
  import { getContext, onMount } from 'svelte';
3
3
  import { initEditor } from './core';
4
4
 
5
+ /**
6
+ * @import { Snippet } from 'svelte';
7
+ * @import { TextEditorStore } from '../../typedefs';
8
+ */
9
+
5
10
  /**
6
11
  * @typedef {object} Props
7
- * @property {string} [class] - The `class` attribute on the wrapper element.
8
- * @property {boolean} [hidden] - Whether to hide the widget.
9
- * @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
12
+ * @property {string} [class] The `class` attribute on the wrapper element.
13
+ * @property {boolean} [hidden] Whether to hide the widget.
14
+ * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
10
15
  * attribute.
11
- * @property {boolean} [readonly] - Whether to make the widget read-only. An alias of the
16
+ * @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
12
17
  * `aria-readonly` attribute.
13
- * @property {boolean} [required] - Whether to mark the widget required. An alias of the
18
+ * @property {boolean} [required] Whether to mark the widget required. An alias of the
14
19
  * `aria-required` attribute.
15
- * @property {boolean} [invalid] - Whether to mark the widget invalid. An alias of the
20
+ * @property {boolean} [invalid] Whether to mark the widget invalid. An alias of the
16
21
  * `aria-invalid` attribute.
17
- * @property {import('svelte').Snippet} [children] - Primary slot content.
22
+ * @property {Snippet} [children] Primary slot content.
18
23
  */
19
24
 
20
25
  /**
@@ -33,7 +38,7 @@
33
38
  /* eslint-enable prefer-const */
34
39
  } = $props();
35
40
 
36
- /** @type {import('../../typedefs').TextEditorStore} */
41
+ /** @type {TextEditorStore} */
37
42
  const editorStore = getContext('editorStore');
38
43
 
39
44
  /**
@@ -50,39 +55,31 @@
50
55
 
51
56
  /**
52
57
  * Update {@link value} and other state variables whenever the editor content is updated.
53
- * @param {Event} event - `Update` custom event.
58
+ * @param {Event} event `Update` custom event.
54
59
  */
55
60
  const onUpdate = (event) => {
56
- if (editorStore.hasConverterError) {
61
+ const { hasConverterError, useRichText, inputValue } = editorStore;
62
+
63
+ if (hasConverterError || !useRichText) {
57
64
  return;
58
65
  }
59
66
 
60
- const { detail } = /** @type {CustomEvent} */ (event);
61
- const newValue = detail.value;
62
-
63
- if (editorStore.inputValue !== newValue) {
64
- const { useRichText } = editorStore;
65
-
66
- if (useRichText) {
67
- // Temporarily disable rich text to prevent unnecessary Markdown conversion that resets
68
- // Lexical nodes and selection
69
- editorStore.useRichText = false;
70
- }
67
+ const { value: newValue, selection } = /** @type {CustomEvent} */ (event).detail;
71
68
 
69
+ if (inputValue !== newValue) {
70
+ // Temporarily disable rich text to prevent unnecessary Markdown conversion that resets
71
+ // Lexical nodes and selection, then restore the state
72
+ editorStore.useRichText = false;
72
73
  editorStore.inputValue = newValue;
73
-
74
- if (useRichText) {
75
- // Restore the rich text state
76
- editorStore.useRichText = true;
77
- }
74
+ editorStore.useRichText = true;
78
75
  }
79
76
 
80
- editorStore.selection = detail.selection;
77
+ editorStore.selection = selection;
81
78
  };
82
79
 
83
80
  /**
84
81
  * Listen to `click` events on the editor. Ignore a click on a link.
85
- * @param {MouseEvent} event - `click` event.
82
+ * @param {MouseEvent} event `click` event.
86
83
  */
87
84
  const onClick = (event) => {
88
85
  if (/** @type {HTMLElement} */ (event.target)?.matches('a')) {
@@ -5,69 +5,70 @@ type LexicalRoot = {
5
5
  };
6
6
  declare const LexicalRoot: import("svelte").Component<{
7
7
  /**
8
- * - The `class` attribute on the wrapper element.
8
+ * The `class` attribute on the wrapper element.
9
9
  */
10
10
  class?: string | undefined;
11
11
  /**
12
- * - Whether to hide the widget.
12
+ * Whether to hide the widget.
13
13
  */
14
14
  hidden?: boolean | undefined;
15
15
  /**
16
- * - Whether to disable the widget. An alias of the `aria-disabled`
16
+ * Whether to disable the widget. An alias of the `aria-disabled`
17
17
  * attribute.
18
18
  */
19
19
  disabled?: boolean | undefined;
20
20
  /**
21
- * - Whether to make the widget read-only. An alias of the
21
+ * Whether to make the widget read-only. An alias of the
22
22
  * `aria-readonly` attribute.
23
23
  */
24
24
  readonly?: boolean | undefined;
25
25
  /**
26
- * - Whether to mark the widget required. An alias of the
26
+ * Whether to mark the widget required. An alias of the
27
27
  * `aria-required` attribute.
28
28
  */
29
29
  required?: boolean | undefined;
30
30
  /**
31
- * - Whether to mark the widget invalid. An alias of the
31
+ * Whether to mark the widget invalid. An alias of the
32
32
  * `aria-invalid` attribute.
33
33
  */
34
34
  invalid?: boolean | undefined;
35
35
  /**
36
- * - Primary slot content.
36
+ * Primary slot content.
37
37
  */
38
- children?: import("svelte").Snippet<[]> | undefined;
38
+ children?: Snippet<[]> | undefined;
39
39
  } & Record<string, any>, {}, "">;
40
40
  type Props = {
41
41
  /**
42
- * - The `class` attribute on the wrapper element.
42
+ * The `class` attribute on the wrapper element.
43
43
  */
44
44
  class?: string | undefined;
45
45
  /**
46
- * - Whether to hide the widget.
46
+ * Whether to hide the widget.
47
47
  */
48
48
  hidden?: boolean | undefined;
49
49
  /**
50
- * - Whether to disable the widget. An alias of the `aria-disabled`
50
+ * Whether to disable the widget. An alias of the `aria-disabled`
51
51
  * attribute.
52
52
  */
53
53
  disabled?: boolean | undefined;
54
54
  /**
55
- * - Whether to make the widget read-only. An alias of the
55
+ * Whether to make the widget read-only. An alias of the
56
56
  * `aria-readonly` attribute.
57
57
  */
58
58
  readonly?: boolean | undefined;
59
59
  /**
60
- * - Whether to mark the widget required. An alias of the
60
+ * Whether to mark the widget required. An alias of the
61
61
  * `aria-required` attribute.
62
62
  */
63
63
  required?: boolean | undefined;
64
64
  /**
65
- * - Whether to mark the widget invalid. An alias of the
65
+ * Whether to mark the widget invalid. An alias of the
66
66
  * `aria-invalid` attribute.
67
67
  */
68
68
  invalid?: boolean | undefined;
69
69
  /**
70
- * - Primary slot content.
70
+ * Primary slot content.
71
71
  */
72
- children?: import("svelte").Snippet<[]> | undefined;
72
+ children?: Snippet<[]> | undefined;
73
73
  };
74
+ import type { Snippet } from 'svelte';
@@ -1 +1,2 @@
1
- export function createEditorStore(): import("../../typedefs").TextEditorStore;
1
+ export function createEditorStore(): TextEditorStore;
2
+ import type { TextEditorStore } from '../../typedefs';
@@ -1,22 +1,27 @@
1
1
  import { generateElementId } from '@sveltia/utils/element';
2
2
  import { convertMarkdownToLexical } from './core';
3
3
 
4
+ /**
5
+ * @import { TextEditorConfig, TextEditorSelectionState, TextEditorStore } from '../../typedefs';
6
+ * @import { LexicalEditor } from 'lexical';
7
+ */
8
+
4
9
  /**
5
10
  * Create an editor editor store that contains all the states and configuration.
6
- * @returns {import('../../typedefs').TextEditorStore} Store.
11
+ * @returns {TextEditorStore} Store.
7
12
  */
8
13
  export const createEditorStore = () => {
9
14
  /** @type {string} */
10
15
  const editorId = generateElementId('editor');
11
16
  /** @type {boolean} */
12
17
  let initialized = $state(false);
13
- /** @type {import('lexical').LexicalEditor | undefined} */
18
+ /** @type {LexicalEditor | undefined} */
14
19
  let editor = $state();
15
- /** @type {import('../../typedefs').TextEditorConfig} */
20
+ /** @type {TextEditorConfig} */
16
21
  let config = $state({ modes: [], enabledButtons: [], components: [], isCodeEditor: false });
17
22
  /** @type {string} */
18
23
  let inputValue = $state('');
19
- /** @type {import('../../typedefs').TextEditorSelectionState} */
24
+ /** @type {TextEditorSelectionState} */
20
25
  let selection = $state({ blockNodeKey: null, blockType: 'paragraph', inlineTypes: [] });
21
26
  /** @type {boolean} */
22
27
  let useRichText = $state(true);
@@ -13,25 +13,34 @@
13
13
  import { createEditorStore } from './store.svelte';
14
14
  import TextEditorToolbar from './toolbar/text-editor-toolbar.svelte';
15
15
 
16
+ /**
17
+ * @import { Snippet } from 'svelte';
18
+ * @import {
19
+ * TextEditorBlockType,
20
+ * TextEditorComponent,
21
+ * TextEditorInlineType,
22
+ * TextEditorMode,
23
+ * } from '../../typedefs';
24
+ */
25
+
16
26
  /**
17
27
  * @typedef {object} Props
18
- * @property {string} [value] - Input value.
19
- * @property {boolean} [flex] - Make the text input container flexible.
20
- * @property {import('../../typedefs').TextEditorMode[]} [modes] - Enabled modes.
21
- * @property {(import('../../typedefs').TextEditorBlockType |
22
- * import('../../typedefs').TextEditorInlineType)[]} [buttons] - Enabled buttons.
23
- * @property {import('../../typedefs').TextEditorComponent[]} [components] - Editor components.
24
- * @property {string} [class] - The `class` attribute on the wrapper element.
25
- * @property {boolean} [hidden] - Whether to hide the widget.
26
- * @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
28
+ * @property {string} [value] Input value.
29
+ * @property {boolean} [flex] Make the text input container flexible.
30
+ * @property {TextEditorMode[]} [modes] Enabled modes.
31
+ * @property {(TextEditorBlockType | TextEditorInlineType)[]} [buttons] Enabled buttons.
32
+ * @property {TextEditorComponent[]} [components] Editor components.
33
+ * @property {string} [class] The `class` attribute on the wrapper element.
34
+ * @property {boolean} [hidden] Whether to hide the widget.
35
+ * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
27
36
  * attribute.
28
- * @property {boolean} [readonly] - Whether to make the widget read-only. An alias of the
37
+ * @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
29
38
  * `aria-readonly` attribute.
30
- * @property {boolean} [required] - Whether to mark the widget required. An alias of the
39
+ * @property {boolean} [required] Whether to mark the widget required. An alias of the
31
40
  * `aria-required` attribute.
32
- * @property {boolean} [invalid] - Whether to mark the widget invalid. An alias of the
41
+ * @property {boolean} [invalid] Whether to mark the widget invalid. An alias of the
33
42
  * `aria-invalid` attribute.
34
- * @property {import('svelte').Snippet} [children] - Primary slot content.
43
+ * @property {Snippet} [children] Primary slot content.
35
44
  */
36
45
 
37
46
  /**
@@ -6,109 +6,114 @@ type TextEditor = {
6
6
  /** A rich text editor based on Lexical. */
7
7
  declare const TextEditor: import("svelte").Component<{
8
8
  /**
9
- * - Input value.
9
+ * Input value.
10
10
  */
11
11
  value?: string | undefined;
12
12
  /**
13
- * - Make the text input container flexible.
13
+ * Make the text input container flexible.
14
14
  */
15
15
  flex?: boolean | undefined;
16
16
  /**
17
- * - Enabled modes.
17
+ * Enabled modes.
18
18
  */
19
- modes?: import("../../typedefs").TextEditorMode[] | undefined;
19
+ modes?: TextEditorMode[] | undefined;
20
20
  /**
21
- * - Enabled buttons.
21
+ * Enabled buttons.
22
22
  */
23
- buttons?: (import("../../typedefs").TextEditorBlockType | import("../../typedefs").TextEditorInlineType)[] | undefined;
23
+ buttons?: (TextEditorBlockType | TextEditorInlineType)[] | undefined;
24
24
  /**
25
- * - Editor components.
25
+ * Editor components.
26
26
  */
27
- components?: import("../../typedefs").TextEditorComponent[] | undefined;
27
+ components?: TextEditorComponent[] | undefined;
28
28
  /**
29
- * - The `class` attribute on the wrapper element.
29
+ * The `class` attribute on the wrapper element.
30
30
  */
31
31
  class?: string | undefined;
32
32
  /**
33
- * - Whether to hide the widget.
33
+ * Whether to hide the widget.
34
34
  */
35
35
  hidden?: boolean | undefined;
36
36
  /**
37
- * - Whether to disable the widget. An alias of the `aria-disabled`
37
+ * Whether to disable the widget. An alias of the `aria-disabled`
38
38
  * attribute.
39
39
  */
40
40
  disabled?: boolean | undefined;
41
41
  /**
42
- * - Whether to make the widget read-only. An alias of the
42
+ * Whether to make the widget read-only. An alias of the
43
43
  * `aria-readonly` attribute.
44
44
  */
45
45
  readonly?: boolean | undefined;
46
46
  /**
47
- * - Whether to mark the widget required. An alias of the
47
+ * Whether to mark the widget required. An alias of the
48
48
  * `aria-required` attribute.
49
49
  */
50
50
  required?: boolean | undefined;
51
51
  /**
52
- * - Whether to mark the widget invalid. An alias of the
52
+ * Whether to mark the widget invalid. An alias of the
53
53
  * `aria-invalid` attribute.
54
54
  */
55
55
  invalid?: boolean | undefined;
56
56
  /**
57
- * - Primary slot content.
57
+ * Primary slot content.
58
58
  */
59
- children?: import("svelte").Snippet<[]> | undefined;
59
+ children?: Snippet<[]> | undefined;
60
60
  } & Record<string, any>, {}, "value">;
61
61
  type Props = {
62
62
  /**
63
- * - Input value.
63
+ * Input value.
64
64
  */
65
65
  value?: string | undefined;
66
66
  /**
67
- * - Make the text input container flexible.
67
+ * Make the text input container flexible.
68
68
  */
69
69
  flex?: boolean | undefined;
70
70
  /**
71
- * - Enabled modes.
71
+ * Enabled modes.
72
72
  */
73
- modes?: import("../../typedefs").TextEditorMode[] | undefined;
73
+ modes?: TextEditorMode[] | undefined;
74
74
  /**
75
- * - Enabled buttons.
75
+ * Enabled buttons.
76
76
  */
77
- buttons?: (import("../../typedefs").TextEditorBlockType | import("../../typedefs").TextEditorInlineType)[] | undefined;
77
+ buttons?: (TextEditorBlockType | TextEditorInlineType)[] | undefined;
78
78
  /**
79
- * - Editor components.
79
+ * Editor components.
80
80
  */
81
- components?: import("../../typedefs").TextEditorComponent[] | undefined;
81
+ components?: TextEditorComponent[] | undefined;
82
82
  /**
83
- * - The `class` attribute on the wrapper element.
83
+ * The `class` attribute on the wrapper element.
84
84
  */
85
85
  class?: string | undefined;
86
86
  /**
87
- * - Whether to hide the widget.
87
+ * Whether to hide the widget.
88
88
  */
89
89
  hidden?: boolean | undefined;
90
90
  /**
91
- * - Whether to disable the widget. An alias of the `aria-disabled`
91
+ * Whether to disable the widget. An alias of the `aria-disabled`
92
92
  * attribute.
93
93
  */
94
94
  disabled?: boolean | undefined;
95
95
  /**
96
- * - Whether to make the widget read-only. An alias of the
96
+ * Whether to make the widget read-only. An alias of the
97
97
  * `aria-readonly` attribute.
98
98
  */
99
99
  readonly?: boolean | undefined;
100
100
  /**
101
- * - Whether to mark the widget required. An alias of the
101
+ * Whether to mark the widget required. An alias of the
102
102
  * `aria-required` attribute.
103
103
  */
104
104
  required?: boolean | undefined;
105
105
  /**
106
- * - Whether to mark the widget invalid. An alias of the
106
+ * Whether to mark the widget invalid. An alias of the
107
107
  * `aria-invalid` attribute.
108
108
  */
109
109
  invalid?: boolean | undefined;
110
110
  /**
111
- * - Primary slot content.
111
+ * Primary slot content.
112
112
  */
113
- children?: import("svelte").Snippet<[]> | undefined;
113
+ children?: Snippet<[]> | undefined;
114
114
  };
115
+ import type { TextEditorMode } from '../../typedefs';
116
+ import type { TextEditorBlockType } from '../../typedefs';
117
+ import type { TextEditorInlineType } from '../../typedefs';
118
+ import type { TextEditorComponent } from '../../typedefs';
119
+ import type { Snippet } from 'svelte';
@@ -5,10 +5,10 @@
5
5
 
6
6
  /**
7
7
  * @typedef {object} Props
8
- * @property {boolean} [hidden] - Whether to hide the widget.
9
- * @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
8
+ * @property {boolean} [hidden] Whether to hide the widget.
9
+ * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
10
10
  * attribute.
11
- * @property {boolean} [readonly] - Whether to make the widget read-only. An alias of the
11
+ * @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
12
12
  * `aria-readonly` attribute.
13
13
  */
14
14
 
@@ -5,32 +5,32 @@ type CodeEditorToolbar = {
5
5
  };
6
6
  declare const CodeEditorToolbar: import("svelte").Component<{
7
7
  /**
8
- * - Whether to hide the widget.
8
+ * Whether to hide the widget.
9
9
  */
10
10
  hidden?: boolean | undefined;
11
11
  /**
12
- * - Whether to disable the widget. An alias of the `aria-disabled`
12
+ * Whether to disable the widget. An alias of the `aria-disabled`
13
13
  * attribute.
14
14
  */
15
15
  disabled?: boolean | undefined;
16
16
  /**
17
- * - Whether to make the widget read-only. An alias of the
17
+ * Whether to make the widget read-only. An alias of the
18
18
  * `aria-readonly` attribute.
19
19
  */
20
20
  readonly?: boolean | undefined;
21
21
  } & Record<string, any>, {}, "">;
22
22
  type Props = {
23
23
  /**
24
- * - Whether to hide the widget.
24
+ * Whether to hide the widget.
25
25
  */
26
26
  hidden?: boolean | undefined;
27
27
  /**
28
- * - Whether to disable the widget. An alias of the `aria-disabled`
28
+ * Whether to disable the widget. An alias of the `aria-disabled`
29
29
  * attribute.
30
30
  */
31
31
  disabled?: boolean | undefined;
32
32
  /**
33
- * - Whether to make the widget read-only. An alias of the
33
+ * Whether to make the widget read-only. An alias of the
34
34
  * `aria-readonly` attribute.
35
35
  */
36
36
  readonly?: boolean | undefined;
@@ -8,9 +8,13 @@
8
8
  import Select from '../../select/select.svelte';
9
9
  import { focusEditor, loadCodeHighlighter } from '../core';
10
10
 
11
+ /**
12
+ * @import { TextEditorStore } from '../../../typedefs';
13
+ */
14
+
11
15
  /**
12
16
  * @typedef {object} Props
13
- * @property {boolean} [disabled] - Whether to disable the switcher.
17
+ * @property {boolean} [disabled] Whether to disable the switcher.
14
18
  */
15
19
 
16
20
  /** @type {Props} */
@@ -39,7 +43,7 @@
39
43
  .flat(1)
40
44
  .sort((a, b) => a.label.localeCompare(b.label));
41
45
 
42
- /** @type {import('../../../typedefs').TextEditorStore} */
46
+ /** @type {TextEditorStore} */
43
47
  const editorStore = getContext('editorStore');
44
48
 
45
49
  let selectedLanguage = $state('');