@sveltia/ui 0.23.1 → 0.24.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.
Files changed (34) hide show
  1. package/dist/components/text-editor/code-editor.svelte +121 -0
  2. package/dist/components/text-editor/code-editor.svelte.d.ts +106 -0
  3. package/dist/components/text-editor/core.d.ts +3 -4
  4. package/dist/components/text-editor/core.js +81 -36
  5. package/dist/components/text-editor/lexical-root.svelte +42 -19
  6. package/dist/components/text-editor/lexical-root.svelte.d.ts +1 -9
  7. package/dist/components/text-editor/store.svelte.d.ts +1 -0
  8. package/dist/components/text-editor/store.svelte.js +120 -0
  9. package/dist/components/text-editor/text-editor.svelte +21 -86
  10. package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte +28 -0
  11. package/dist/components/text-editor/toolbar/{editor-toolbar.svelte.d.ts → code-editor-toolbar.svelte.d.ts} +3 -3
  12. package/dist/components/text-editor/toolbar/code-language-switcher.svelte +96 -0
  13. package/dist/components/text-editor/toolbar/code-language-switcher.svelte.d.ts +17 -0
  14. package/dist/components/text-editor/toolbar/format-text-button.svelte +10 -10
  15. package/dist/components/text-editor/toolbar/insert-image-button.svelte +5 -8
  16. package/dist/components/text-editor/toolbar/insert-link-button.svelte +27 -25
  17. package/dist/components/text-editor/toolbar/insert-menu-button.svelte +4 -7
  18. package/dist/components/text-editor/toolbar/{editor-toolbar.svelte → text-editor-toolbar.svelte} +59 -87
  19. package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte.d.ts +37 -0
  20. package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +14 -17
  21. package/dist/components/text-editor/toolbar/toolbar-wrapper.svelte +58 -0
  22. package/dist/components/text-editor/toolbar/toolbar-wrapper.svelte.d.ts +37 -0
  23. package/dist/components/util/app-shell.svelte +2 -2
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +1 -0
  26. package/dist/locales/en.d.ts +3 -0
  27. package/dist/locales/en.js +3 -0
  28. package/dist/locales/ja.d.ts +3 -0
  29. package/dist/locales/ja.js +3 -0
  30. package/dist/services/group.svelte.js +1 -2
  31. package/dist/styles/variables.scss +2 -2
  32. package/dist/typedefs.d.ts +59 -26
  33. package/dist/typedefs.js +26 -13
  34. package/package.json +20 -20
@@ -10,12 +10,13 @@
10
10
  import Icon from '../../icon/icon.svelte';
11
11
  import MenuButton from '../../menu/menu-button.svelte';
12
12
  import Menu from '../../menu/menu.svelte';
13
- import Toolbar from '../../toolbar/toolbar.svelte';
13
+ import CodeLanguageSwitcher from './code-language-switcher.svelte';
14
14
  import FormatTextButton from './format-text-button.svelte';
15
15
  import InsertImageButton from './insert-image-button.svelte';
16
16
  import InsertLinkButton from './insert-link-button.svelte';
17
17
  import InsertMenuButton from './insert-menu-button.svelte';
18
18
  import ToggleBlockMenuItem from './toggle-block-menu-item.svelte';
19
+ import ToolbarWrapper from './toolbar-wrapper.svelte';
19
20
 
20
21
  /**
21
22
  * @typedef {object} Props
@@ -36,23 +37,12 @@
36
37
  /* eslint-enable prefer-const */
37
38
  } = $props();
38
39
 
39
- /**
40
- * Text editor state.
41
- * @type {import('../../../typedefs').TextEditorState}
42
- */
43
- const {
44
- editorId,
45
- selectionBlockType,
46
- modes,
47
- useRichText,
48
- hasConverterError,
49
- enabledButtons,
50
- components,
51
- convertMarkdown,
52
- } = getContext('state');
53
-
54
- const imageComponent = $derived(components.find(({ id }) => id === 'image'));
55
- const otherComponents = $derived(components.filter(({ id }) => id !== 'image'));
40
+ /** @type {import('../../../typedefs').TextEditorStore} */
41
+ const editorStore = getContext('editorStore');
42
+ const imageComponent = $derived(editorStore.config.components.find(({ id }) => id === 'image'));
43
+ const otherComponents = $derived(
44
+ editorStore.config.components.filter(({ id }) => id !== 'image'),
45
+ );
56
46
 
57
47
  /**
58
48
  * Enabled block level buttons.
@@ -61,7 +51,9 @@
61
51
  const blockLevelButtons = $derived(
62
52
  unique([
63
53
  'paragraph', // Always needed
64
- ...enabledButtons.filter((type) => blockButtonTypes.includes(/** @type {any} */ (type))),
54
+ ...editorStore.config.enabledButtons.filter((type) =>
55
+ blockButtonTypes.includes(/** @type {any} */ (type)),
56
+ ),
65
57
  ]),
66
58
  );
67
59
 
@@ -71,29 +63,36 @@
71
63
  */
72
64
  const inlineLevelButtons = $derived(
73
65
  unique([
74
- ...enabledButtons.filter((type) => inlineButtonTypes.includes(/** @type {any} */ (type))),
66
+ ...editorStore.config.enabledButtons.filter((type) =>
67
+ inlineButtonTypes.includes(/** @type {any} */ (type)),
68
+ ),
75
69
  ]),
76
70
  );
77
71
  </script>
78
72
 
79
- <div role="none" class="wrapper">
80
- <Toolbar disabled={disabled || readonly} aria-label={$_('_sui.text_editor.text_editor')}>
81
- <MenuButton
82
- disabled={!$useRichText}
83
- aria-label={$_('_sui.text_editor.show_text_style_options')}
84
- aria-controls="{$editorId}-lexical-root"
85
- >
86
- {#snippet startIcon()}
87
- <Icon name={availableButtons[$selectionBlockType]?.icon ?? 'format_paragraph'} />
88
- {/snippet}
89
- {#snippet popup()}
90
- <Menu aria-label={$_('_sui.text_editor.text_style_options')}>
91
- {#each blockLevelButtons as type (type)}
92
- <ToggleBlockMenuItem {type} />
93
- {/each}
94
- </Menu>
95
- {/snippet}
96
- </MenuButton>
73
+ <ToolbarWrapper disabled={disabled || readonly} aria-label={$_('_sui.text_editor.text_editor')}>
74
+ <MenuButton
75
+ disabled={!editorStore.useRichText}
76
+ aria-label={$_('_sui.text_editor.show_text_style_options')}
77
+ aria-controls="{editorStore.editorId}-lexical-root"
78
+ >
79
+ {#snippet startIcon()}
80
+ <Icon
81
+ name={availableButtons[editorStore.selection.blockType ?? '']?.icon ?? 'format_paragraph'}
82
+ />
83
+ {/snippet}
84
+ {#snippet popup()}
85
+ <Menu aria-label={$_('_sui.text_editor.text_style_options')}>
86
+ {#each blockLevelButtons as type (type)}
87
+ <ToggleBlockMenuItem {type} />
88
+ {/each}
89
+ </Menu>
90
+ {/snippet}
91
+ </MenuButton>
92
+ {#if editorStore.selection.blockType === 'code-block'}
93
+ <Divider orientation="vertical" />
94
+ <CodeLanguageSwitcher disabled={!editorStore.useRichText} />
95
+ {:else}
97
96
  {#if inlineLevelButtons.length}
98
97
  <Divider orientation="vertical" />
99
98
  <ButtonGroup>
@@ -106,7 +105,7 @@
106
105
  {/each}
107
106
  </ButtonGroup>
108
107
  {/if}
109
- {#if components.length}
108
+ {#if editorStore.config.components.length}
110
109
  <Divider orientation="vertical" />
111
110
  {#if imageComponent}
112
111
  <InsertImageButton component={imageComponent} />
@@ -115,52 +114,25 @@
115
114
  <InsertMenuButton components={otherComponents} />
116
115
  {/if}
117
116
  {/if}
118
- <Spacer flex />
119
- {#if modes.length > 1}
120
- <Button
121
- iconic
122
- disabled={$hasConverterError}
123
- pressed={!$useRichText}
124
- aria-label={$_('_sui.text_editor.edit_in_markdown')}
125
- onclick={() => {
126
- $useRichText = !$useRichText;
127
-
128
- if ($useRichText) {
129
- convertMarkdown();
130
- }
131
- }}
132
- >
133
- {#snippet startIcon()}
134
- <Icon name="markdown" />
135
- {/snippet}
136
- </Button>
137
- {/if}
138
- </Toolbar>
139
- </div>
117
+ {/if}
118
+ <Spacer flex />
119
+ {#if editorStore.config.modes.length > 1}
120
+ <Button
121
+ iconic
122
+ disabled={editorStore.hasConverterError}
123
+ pressed={!editorStore.useRichText}
124
+ aria-label={$_('_sui.text_editor.edit_in_markdown')}
125
+ onclick={() => {
126
+ editorStore.useRichText = !editorStore.useRichText;
140
127
 
141
- <style>.wrapper {
142
- display: contents;
143
- }
144
- .wrapper :global([role="toolbar"]) {
145
- position: sticky;
146
- top: 0;
147
- z-index: 1;
148
- display: flex;
149
- gap: 8px;
150
- border-width: 1px 1px 0;
151
- border-style: solid;
152
- border-color: var(--sui-textbox-border-color);
153
- border-radius: var(--sui-textbox-border-radius) var(--sui-textbox-border-radius) 0 0;
154
- padding: 8px;
155
- background-color: var(--sui-tertiary-background-color);
156
- }
157
- .wrapper :global(.sui.menu-button) {
158
- padding: 0 4px;
159
- }
160
- .wrapper :global(.sui.button) {
161
- flex: none;
162
- margin: 0 !important;
163
- }
164
- .wrapper :global(.sui.button-group) {
165
- gap: 4px;
166
- }</style>
128
+ if (editorStore.useRichText) {
129
+ editorStore.convertMarkdown();
130
+ }
131
+ }}
132
+ >
133
+ {#snippet startIcon()}
134
+ <Icon name="markdown" />
135
+ {/snippet}
136
+ </Button>
137
+ {/if}
138
+ </ToolbarWrapper>
@@ -0,0 +1,37 @@
1
+ export default TextEditorToolbar;
2
+ type TextEditorToolbar = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props & Record<string, any>>): void;
5
+ };
6
+ declare const TextEditorToolbar: import("svelte").Component<{
7
+ /**
8
+ * - Whether to hide the widget.
9
+ */
10
+ hidden?: boolean | undefined;
11
+ /**
12
+ * - Whether to disable the widget. An alias of the `aria-disabled`
13
+ * attribute.
14
+ */
15
+ disabled?: boolean | undefined;
16
+ /**
17
+ * - Whether to make the widget read-only. An alias of the
18
+ * `aria-readonly` attribute.
19
+ */
20
+ readonly?: boolean | undefined;
21
+ } & Record<string, any>, {}, "">;
22
+ type Props = {
23
+ /**
24
+ * - Whether to hide the widget.
25
+ */
26
+ hidden?: boolean | undefined;
27
+ /**
28
+ * - Whether to disable the widget. An alias of the `aria-disabled`
29
+ * attribute.
30
+ */
31
+ disabled?: boolean | undefined;
32
+ /**
33
+ * - Whether to make the widget read-only. An alias of the
34
+ * `aria-readonly` attribute.
35
+ */
36
+ readonly?: boolean | undefined;
37
+ };
@@ -31,27 +31,24 @@
31
31
  /* eslint-enable prefer-const */
32
32
  } = $props();
33
33
 
34
- /**
35
- * Text editor state.
36
- * @type {import('../../../typedefs').TextEditorState}
37
- */
38
- const { editor, selectionBlockType } = getContext('state');
39
-
40
- /**
41
- * Whether the current selection matches the button {@link type}.
42
- */
43
- const selectionTypeMatches = $derived($selectionBlockType === type);
34
+ /** @type {import('../../../typedefs').TextEditorStore} */
35
+ const editorStore = getContext('editorStore');
36
+ const selectionTypeMatches = $derived(editorStore.selection.blockType === type);
44
37
 
45
38
  /**
46
39
  * Change the current selection’s type to {@link type}.
47
40
  */
48
41
  const changeBlockType = async () => {
49
- await focusEditor($editor);
42
+ if (!editorStore.editor) {
43
+ return;
44
+ }
45
+
46
+ await focusEditor(editorStore.editor);
50
47
 
51
48
  const [, headingLevel] = type.match(/^heading-(\d)$/) ?? [];
52
49
 
53
50
  if (headingLevel) {
54
- $editor.update(() => {
51
+ editorStore.editor.update(() => {
55
52
  setBlocksType(getSelection(), () =>
56
53
  createHeadingNode(
57
54
  /** @type {import('@lexical/rich-text').HeadingTagType} */ (`h${headingLevel}`),
@@ -61,27 +58,27 @@
61
58
  }
62
59
 
63
60
  if (type === 'paragraph') {
64
- $editor.update(() => {
61
+ editorStore.editor.update(() => {
65
62
  setBlocksType(getSelection(), () => createParagraphNode());
66
63
  });
67
64
  }
68
65
 
69
66
  if (type === 'bulleted-list') {
70
- $editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
67
+ editorStore.editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
71
68
  }
72
69
 
73
70
  if (type === 'numbered-list') {
74
- $editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
71
+ editorStore.editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
75
72
  }
76
73
 
77
74
  if (type === 'blockquote') {
78
- $editor.update(() => {
75
+ editorStore.editor.update(() => {
79
76
  setBlocksType(getSelection(), () => createQuoteNode());
80
77
  });
81
78
  }
82
79
 
83
80
  if (type === 'code-block') {
84
- $editor.update(() => {
81
+ editorStore.editor.update(() => {
85
82
  setBlocksType(getSelection(), () => createCodeNode());
86
83
  });
87
84
  }
@@ -0,0 +1,58 @@
1
+ <script>
2
+ import Toolbar from '../../toolbar/toolbar.svelte';
3
+
4
+ /**
5
+ * @typedef {object} Props
6
+ * @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
7
+ * attribute.
8
+ * @property {boolean} [readonly] - Whether to make the widget read-only. An alias of the
9
+ * `aria-readonly` attribute.
10
+ * @property {import('svelte').Snippet} [children] - Primary slot content.
11
+ */
12
+
13
+ /**
14
+ * @type {Props & Record<string, any>}
15
+ */
16
+ let {
17
+ /* eslint-disable prefer-const */
18
+ code = $bindable(''),
19
+ lang = $bindable(''),
20
+ disabled = false,
21
+ children,
22
+ ...restProps
23
+ /* eslint-enable prefer-const */
24
+ } = $props();
25
+ </script>
26
+
27
+ <div role="none" class="wrapper">
28
+ <Toolbar {...restProps} {disabled}>
29
+ {@render children?.()}
30
+ </Toolbar>
31
+ </div>
32
+
33
+ <style>.wrapper {
34
+ display: contents;
35
+ }
36
+ .wrapper :global([role="toolbar"]) {
37
+ position: sticky;
38
+ top: 0;
39
+ z-index: 1;
40
+ display: flex;
41
+ gap: 8px;
42
+ border-width: 1px 1px 0;
43
+ border-style: solid;
44
+ border-color: var(--sui-textbox-border-color);
45
+ border-radius: var(--sui-textbox-border-radius) var(--sui-textbox-border-radius) 0 0;
46
+ padding: 8px;
47
+ background-color: var(--sui-tertiary-background-color);
48
+ }
49
+ .wrapper :global(.sui.menu-button) {
50
+ padding: 0 4px;
51
+ }
52
+ .wrapper :global(.sui.button) {
53
+ flex: none;
54
+ margin: 0 !important;
55
+ }
56
+ .wrapper :global(.sui.button-group) {
57
+ gap: 4px;
58
+ }</style>
@@ -0,0 +1,37 @@
1
+ export default ToolbarWrapper;
2
+ type ToolbarWrapper = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props & Record<string, any>>): void;
5
+ };
6
+ declare const ToolbarWrapper: import("svelte").Component<{
7
+ /**
8
+ * - Whether to disable the widget. An alias of the `aria-disabled`
9
+ * attribute.
10
+ */
11
+ disabled?: boolean | undefined;
12
+ /**
13
+ * - Whether to make the widget read-only. An alias of the
14
+ * `aria-readonly` attribute.
15
+ */
16
+ readonly?: boolean | undefined;
17
+ /**
18
+ * - Primary slot content.
19
+ */
20
+ children?: import("svelte").Snippet<[]> | undefined;
21
+ } & Record<string, any>, {}, "code" | "lang">;
22
+ type Props = {
23
+ /**
24
+ * - Whether to disable the widget. An alias of the `aria-disabled`
25
+ * attribute.
26
+ */
27
+ disabled?: boolean | undefined;
28
+ /**
29
+ * - Whether to make the widget read-only. An alias of the
30
+ * `aria-readonly` attribute.
31
+ */
32
+ readonly?: boolean | undefined;
33
+ /**
34
+ * - Primary slot content.
35
+ */
36
+ children?: import("svelte").Snippet<[]> | undefined;
37
+ };
@@ -126,7 +126,7 @@
126
126
  --sui-selected-background-color: hsl(var(--sui-background-color-5-hsl) / 75%);
127
127
  --sui-active-background-color: hsl(var(--sui-background-color-5-hsl) / 100%);
128
128
  --sui-content-background-color: hsl(var(--sui-background-color-1-hsl));
129
- --sui-code-background-color: hsl(var(--sui-background-color-4-hsl));
129
+ --sui-code-background-color: hsl(var(--sui-background-color-3-hsl));
130
130
  --sui-primary-background-color: hsl(var(--sui-background-color-2-hsl));
131
131
  --sui-primary-background-color-translucent: hsl(var(--sui-background-color-2-hsl) / 80%);
132
132
  --sui-secondary-background-color: hsl(var(--sui-background-color-3-hsl));
@@ -182,7 +182,7 @@
182
182
  --sui-font-weight-normal: 325;
183
183
  --sui-font-weight-bold: 625;
184
184
  --sui-font-family-monospace: "Noto Sans Mono", monospace;
185
- --sui-font-size-monospace: 0.9em;
185
+ --sui-font-size-monospace: 0.95em;
186
186
  --sui-line-height-default: 1.25;
187
187
  --sui-line-height-compact: 1.5;
188
188
  --sui-line-height-comfortable: 1.75;
package/dist/index.d.ts CHANGED
@@ -58,6 +58,7 @@ export { default as TabList } from "./components/tabs/tab-list.svelte";
58
58
  export { default as TabPanel } from "./components/tabs/tab-panel.svelte";
59
59
  export { default as TabPanels } from "./components/tabs/tab-panels.svelte";
60
60
  export { default as Tab } from "./components/tabs/tab.svelte";
61
+ export { default as CodeEditor } from "./components/text-editor/code-editor.svelte";
61
62
  export { default as TextEditor } from "./components/text-editor/text-editor.svelte";
62
63
  export { default as NumberInput } from "./components/text-field/number-input.svelte";
63
64
  export { default as PasswordInput } from "./components/text-field/password-input.svelte";
package/dist/index.js CHANGED
@@ -83,6 +83,7 @@ export { default as TabList } from './components/tabs/tab-list.svelte';
83
83
  export { default as TabPanel } from './components/tabs/tab-panel.svelte';
84
84
  export { default as TabPanels } from './components/tabs/tab-panels.svelte';
85
85
  export { default as Tab } from './components/tabs/tab.svelte';
86
+ export { default as CodeEditor } from './components/text-editor/code-editor.svelte';
86
87
  export { default as TextEditor } from './components/text-editor/text-editor.svelte';
87
88
  export { default as NumberInput } from './components/text-field/number-input.svelte';
88
89
  export { default as PasswordInput } from './components/text-field/password-input.svelte';
@@ -37,6 +37,7 @@ export namespace strings {
37
37
  namespace text_editor {
38
38
  let text_editor_1: string;
39
39
  export { text_editor_1 as text_editor };
40
+ export let code_editor: string;
40
41
  export let text_style_options: string;
41
42
  export let show_text_style_options: string;
42
43
  export let paragraph: string;
@@ -60,5 +61,7 @@ export namespace strings {
60
61
  export let url: string;
61
62
  export let edit_in_markdown: string;
62
63
  export let converter_error: string;
64
+ export let language: string;
65
+ export let plain_text: string;
63
66
  }
64
67
  }
@@ -36,6 +36,7 @@ export const strings = {
36
36
  },
37
37
  text_editor: {
38
38
  text_editor: 'Text Editor',
39
+ code_editor: 'Code Editor',
39
40
  text_style_options: 'Text Style Options',
40
41
  show_text_style_options: 'Show Text Style Options',
41
42
  paragraph: 'Paragraph',
@@ -60,5 +61,7 @@ export const strings = {
60
61
  edit_in_markdown: 'Edit in Markdown',
61
62
  converter_error:
62
63
  'There was an error while enabling rich text mode. Please use the plain text editor instead.',
64
+ language: 'Language',
65
+ plain_text: 'Plain Text',
63
66
  },
64
67
  };
@@ -37,6 +37,7 @@ export namespace strings {
37
37
  namespace text_editor {
38
38
  let text_editor_1: string;
39
39
  export { text_editor_1 as text_editor };
40
+ export let code_editor: string;
40
41
  export let text_style_options: string;
41
42
  export let show_text_style_options: string;
42
43
  export let paragraph: string;
@@ -60,5 +61,7 @@ export namespace strings {
60
61
  export let url: string;
61
62
  export let edit_in_markdown: string;
62
63
  export let converter_error: string;
64
+ export let language: string;
65
+ export let plain_text: string;
63
66
  }
64
67
  }
@@ -36,6 +36,7 @@ export const strings = {
36
36
  },
37
37
  text_editor: {
38
38
  text_editor: 'テキストエディター',
39
+ code_editor: 'コードエディター',
39
40
  text_style_options: 'テキストスタイルオプション',
40
41
  show_text_style_options: 'テキストスタイルオプションを表示',
41
42
  paragraph: '段落',
@@ -60,5 +61,7 @@ export const strings = {
60
61
  edit_in_markdown: 'マークダウンで編集',
61
62
  converter_error:
62
63
  'リッチテキストモードを有効化中に問題が発生しました。代わりにプレーンテキストエディターを使用してください。',
64
+ language: '言語',
65
+ plain_text: 'プレーンテキスト',
63
66
  },
64
67
  };
@@ -101,8 +101,7 @@ class Group {
101
101
  * Activate the members.
102
102
  */
103
103
  activate() {
104
- const { parent, role, allMembers, selected: defaultSelected } = this;
105
- const multi = this.multi || role === 'menu' || role === 'menubar';
104
+ const { parent, allMembers, selected: defaultSelected } = this;
106
105
 
107
106
  allMembers.forEach((element, index) => {
108
107
  // Select the first one if no member has the `selected` attribute
@@ -102,7 +102,7 @@
102
102
  --sui-selected-background-color: hsl(var(--sui-background-color-5-hsl) / 75%);
103
103
  --sui-active-background-color: hsl(var(--sui-background-color-5-hsl) / 100%);
104
104
  --sui-content-background-color: hsl(var(--sui-background-color-1-hsl));
105
- --sui-code-background-color: hsl(var(--sui-background-color-4-hsl));
105
+ --sui-code-background-color: hsl(var(--sui-background-color-3-hsl));
106
106
  --sui-primary-background-color: hsl(var(--sui-background-color-2-hsl));
107
107
  --sui-primary-background-color-translucent: hsl(var(--sui-background-color-2-hsl) / 80%);
108
108
  --sui-secondary-background-color: hsl(var(--sui-background-color-3-hsl));
@@ -162,7 +162,7 @@
162
162
  --sui-font-weight-normal: 325; // Merriweather Sans is a little bit bold, so we need to adjust the weight
163
163
  --sui-font-weight-bold: 625; // ditto
164
164
  --sui-font-family-monospace: "Noto Sans Mono", monospace;
165
- --sui-font-size-monospace: 0.9em;
165
+ --sui-font-size-monospace: 0.95em;
166
166
  --sui-line-height-default: 1.25;
167
167
  --sui-line-height-compact: 1.5;
168
168
  --sui-line-height-comfortable: 1.75;
@@ -572,51 +572,84 @@ export type TextEditorComponent = {
572
572
  */
573
573
  transformer: import("@lexical/markdown").Transformer;
574
574
  };
575
- export type TextEditorState = {
575
+ export type TextEditorConfig = {
576
576
  /**
577
- * - Lexical
578
- * editor instance.
577
+ * - Enabled modes.
579
578
  */
580
- editor: import("svelte/store").Writable<import("lexical").LexicalEditor>;
579
+ modes: TextEditorMode[];
581
580
  /**
582
- * - Random ID assigned to the editor.
581
+ * - Enabled buttons for
582
+ * the editor.
583
583
  */
584
- editorId: import("svelte/store").Writable<string>;
584
+ enabledButtons: (TextEditorBlockType | TextEditorInlineType)[];
585
585
  /**
586
- * - Block level
587
- * type of the current selection.
586
+ * - Editor components.
588
587
  */
589
- selectionBlockType: import("svelte/store").Writable<TextEditorBlockType>;
588
+ components: TextEditorComponent[];
590
589
  /**
591
- * - Inline
592
- * level types of the current selection.
590
+ * - Whether the editor is used as a code editor.
593
591
  */
594
- selectionInlineTypes: import("svelte/store").Writable<TextEditorInlineType[]>;
592
+ isCodeEditor: boolean;
595
593
  /**
596
- * - Enabled modes.
594
+ * - Default language for the code editor.
597
595
  */
598
- modes: TextEditorMode[];
596
+ defaultLanguage?: string | undefined;
597
+ };
598
+ export type TextEditorSelectionState = {
599
599
  /**
600
- * - Whether to use rich text mode.
601
- * If `false`, the editor shows the plain text editor.
600
+ * - Block level node key.
602
601
  */
603
- useRichText: import("svelte/store").Writable<boolean>;
602
+ blockNodeKey: string | null;
604
603
  /**
605
- * - `true` if there was an
606
- * error while converting Markdown to Lexical nodes.
604
+ * - Block level type of the current selection.
607
605
  */
608
- hasConverterError: import("svelte/store").Writable<boolean>;
606
+ blockType: TextEditorBlockType;
609
607
  /**
610
- * - Enabled buttons for
611
- * the editor.
608
+ * - Inline level types of the current selection.
612
609
  */
613
- enabledButtons: (TextEditorBlockType | TextEditorInlineType)[];
610
+ inlineTypes: TextEditorInlineType[];
611
+ };
612
+ export type TextEditorStore = {
614
613
  /**
615
- * - Editor components.
614
+ * - Lexical editor instance.
616
615
  */
617
- components: TextEditorComponent[];
616
+ editor: import("lexical").LexicalEditor | undefined;
617
+ /**
618
+ * - Whether the Lexical editor is initialized.
619
+ */
620
+ initialized: boolean;
621
+ /**
622
+ * - Random ID assigned to the editor.
623
+ */
624
+ editorId: string;
625
+ /**
626
+ * - Editor configuration.
627
+ */
628
+ config: TextEditorConfig;
629
+ /**
630
+ * - Value entered the Lexical editor.
631
+ */
632
+ inputValue: string;
633
+ /**
634
+ * - Current selection state.
635
+ */
636
+ selection: TextEditorSelectionState;
637
+ /**
638
+ * - Whether to use rich text mode. If `false`, the editor shows the
639
+ * plain text editor.
640
+ */
641
+ useRichText: boolean;
642
+ /**
643
+ * - Whether there was an error while converting Markdown to
644
+ * Lexical nodes.
645
+ */
646
+ hasConverterError: boolean;
647
+ /**
648
+ * - Whether to show a converter error in the UI.
649
+ */
650
+ showConverterError: boolean;
618
651
  /**
619
652
  * - Function to trigger the Lexical converter.
620
653
  */
621
- convertMarkdown: Function;
654
+ convertMarkdown: () => Promise<void>;
622
655
  };