@sveltia/ui 0.90.0 → 0.91.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/text-editor/constants.d.ts +40 -6
- package/dist/components/text-editor/constants.js +81 -7
- 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 +1 -1
- 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.js +1 -1
- package/dist/components/text-editor/core.js +4 -12
- 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 +4 -2
- package/dist/components/text-editor/editing/raw-markdown.js +22 -6
- package/dist/components/text-editor/editing/selection.js +6 -2
- package/dist/components/text-editor/lexical-root.svelte +40 -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/text-editor.svelte +7 -4
- package/dist/components/text-editor/text-editor.svelte.d.ts +4 -2
- package/dist/components/text-editor/toolbar/format-text-button.svelte +7 -1
- package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +19 -8
- package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +7 -14
- 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/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/typedefs.d.ts +5 -2
- package/dist/typedefs.js +3 -2
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @import { EditorThemeClasses, LexicalCommand } from 'lexical';
|
|
3
|
+
* @import { ListType } from '@lexical/list';
|
|
3
4
|
* @import { Transformer } from '@lexical/markdown';
|
|
4
5
|
* @import {
|
|
5
6
|
* TextEditorBlockType,
|
|
@@ -35,6 +36,38 @@ export const INLINE_BUTTON_TYPES: TextEditorInlineType[];
|
|
|
35
36
|
* @type {TextEditorBlockType[]}
|
|
36
37
|
*/
|
|
37
38
|
export const BLOCK_BUTTON_TYPES: TextEditorBlockType[];
|
|
39
|
+
/**
|
|
40
|
+
* Buttons only available for HTML, as Markdown has no syntax for them: the underline format and the
|
|
41
|
+
* alignment menu. They’re hidden for Markdown and in the plain text mode, which shows the HTML
|
|
42
|
+
* source, and they’re not enabled by default.
|
|
43
|
+
* @type {('underline' | 'align')[]}
|
|
44
|
+
*/
|
|
45
|
+
export const HTML_ONLY_BUTTON_TYPES: ("underline" | "align")[];
|
|
46
|
+
export function isHtmlOnlyButton(type: string): type is "underline" | "align";
|
|
47
|
+
/**
|
|
48
|
+
* Text formats only available for HTML, like underline. See {@link HTML_ONLY_BUTTON_TYPES}.
|
|
49
|
+
*/
|
|
50
|
+
export const HTML_ONLY_FORMAT_TYPES: TextEditorFormatType[];
|
|
51
|
+
/**
|
|
52
|
+
* Buttons not enabled by default: the HTML-only ones and the task list, a GitHub Flavored Markdown
|
|
53
|
+
* extension that not every Markdown renderer supports.
|
|
54
|
+
* @type {TextEditorNodeType[]}
|
|
55
|
+
*/
|
|
56
|
+
export const OPTIONAL_BUTTON_TYPES: TextEditorNodeType[];
|
|
57
|
+
/**
|
|
58
|
+
* Buttons enabled by default: all the inline and block level buttons but the optional ones.
|
|
59
|
+
* @type {TextEditorNodeType[]}
|
|
60
|
+
*/
|
|
61
|
+
export const DEFAULT_BUTTON_TYPES: TextEditorNodeType[];
|
|
62
|
+
/**
|
|
63
|
+
* List block types, with their Lexical list type and the command to insert the list.
|
|
64
|
+
* @type {{ type: TextEditorBlockType, listType: ListType, command: LexicalCommand<void> }[]}
|
|
65
|
+
*/
|
|
66
|
+
export const LIST_TYPES: {
|
|
67
|
+
type: TextEditorBlockType;
|
|
68
|
+
listType: ListType;
|
|
69
|
+
command: LexicalCommand<void>;
|
|
70
|
+
}[];
|
|
38
71
|
/**
|
|
39
72
|
* Map of Lexical nodes for each block type. The `paragraph` block type is excluded because it is
|
|
40
73
|
* the default block type.
|
|
@@ -42,12 +75,12 @@ export const BLOCK_BUTTON_TYPES: TextEditorBlockType[];
|
|
|
42
75
|
*/
|
|
43
76
|
export const NODE_MAP: Record<Exclude<TextEditorBlockType | "link", "paragraph">, any[]>;
|
|
44
77
|
/**
|
|
45
|
-
* Map of Lexical transformers for each
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* Transformer[]
|
|
78
|
+
* Map of Lexical transformers for each button type. The `paragraph` block type has none because it
|
|
79
|
+
* is the default block type, and neither have the HTML-only buttons. Horizontal rules and tables
|
|
80
|
+
* are always supported in Markdown, so their transformers are added in `core.js`.
|
|
81
|
+
* @type {Partial<Record<TextEditorNodeType, Transformer[]>>}
|
|
49
82
|
*/
|
|
50
|
-
export const TRANSFORMER_MAP: Record<
|
|
83
|
+
export const TRANSFORMER_MAP: Partial<Record<TextEditorNodeType, Transformer[]>>;
|
|
51
84
|
/**
|
|
52
85
|
* List of Markdown tags that should be disabled in the editor when converting Lexical nodes to
|
|
53
86
|
* Markdown (but not when converting Markdown to Lexical nodes because we don’t want to lose any
|
|
@@ -94,5 +127,6 @@ import type { TextEditorFormatType } from '../../typedefs.js';
|
|
|
94
127
|
import type { TextEditorInlineType } from '../../typedefs.js';
|
|
95
128
|
import type { TextEditorBlockType } from '../../typedefs.js';
|
|
96
129
|
import type { TextEditorNodeType } from '../../typedefs.js';
|
|
97
|
-
import type {
|
|
130
|
+
import type { ListType } from '@lexical/list';
|
|
98
131
|
import type { LexicalCommand } from 'lexical';
|
|
132
|
+
import type { Transformer } from '@lexical/markdown';
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { CodeHighlightNode, CodeNode } from '@lexical/code-core';
|
|
2
2
|
import { LinkNode } from '@lexical/link';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
INSERT_CHECK_LIST_COMMAND,
|
|
5
|
+
INSERT_ORDERED_LIST_COMMAND,
|
|
6
|
+
INSERT_UNORDERED_LIST_COMMAND,
|
|
7
|
+
ListItemNode,
|
|
8
|
+
ListNode,
|
|
9
|
+
} from '@lexical/list';
|
|
4
10
|
import {
|
|
5
11
|
BOLD_ITALIC_STAR,
|
|
6
12
|
BOLD_ITALIC_UNDERSCORE,
|
|
@@ -21,9 +27,11 @@ import { createCommand } from 'lexical';
|
|
|
21
27
|
import { CODE } from './conversion/transformers/code.js';
|
|
22
28
|
import { LEADING_INLINE_CODE } from './conversion/transformers/inline-code.js';
|
|
23
29
|
import { LINK } from './conversion/transformers/link.js';
|
|
30
|
+
import { TASK_LIST } from './conversion/transformers/task-list.js';
|
|
24
31
|
|
|
25
32
|
/**
|
|
26
33
|
* @import { EditorThemeClasses, LexicalCommand } from 'lexical';
|
|
34
|
+
* @import { ListType } from '@lexical/list';
|
|
27
35
|
* @import { Transformer } from '@lexical/markdown';
|
|
28
36
|
* @import {
|
|
29
37
|
* TextEditorBlockType,
|
|
@@ -39,16 +47,22 @@ import { LINK } from './conversion/transformers/link.js';
|
|
|
39
47
|
export const EDITOR_THEME = {
|
|
40
48
|
text: {
|
|
41
49
|
/**
|
|
42
|
-
* Enable bold+italic and strikethrough styling.
|
|
50
|
+
* Enable bold+italic, underline and strikethrough styling. Lexical only uses the combined
|
|
51
|
+
* class for text that is both underlined and struck through.
|
|
43
52
|
* @see https://github.com/facebook/lexical/discussions/4381
|
|
44
53
|
*/
|
|
45
54
|
italic: 'italic',
|
|
55
|
+
underline: 'underline',
|
|
46
56
|
strikethrough: 'strikethrough',
|
|
57
|
+
underlineStrikethrough: 'underline strikethrough',
|
|
47
58
|
},
|
|
48
59
|
list: {
|
|
49
60
|
nested: {
|
|
50
61
|
listitem: 'nested',
|
|
51
62
|
},
|
|
63
|
+
// Task list items, drawn with a check box; see `lexical-root.svelte`
|
|
64
|
+
listitemChecked: 'task-list-item checked',
|
|
65
|
+
listitemUnchecked: 'task-list-item',
|
|
52
66
|
},
|
|
53
67
|
code: 'code-block',
|
|
54
68
|
// Lexical wraps a table with an element to scroll it horizontally when the table button is
|
|
@@ -73,6 +87,11 @@ export const AVAILABLE_BUTTONS = {
|
|
|
73
87
|
icon: 'format_italic',
|
|
74
88
|
inline: true,
|
|
75
89
|
},
|
|
90
|
+
underline: {
|
|
91
|
+
labelKey: 'underline',
|
|
92
|
+
icon: 'format_underlined',
|
|
93
|
+
inline: true,
|
|
94
|
+
},
|
|
76
95
|
strikethrough: {
|
|
77
96
|
labelKey: 'strikethrough',
|
|
78
97
|
icon: 'strikethrough_s',
|
|
@@ -133,6 +152,11 @@ export const AVAILABLE_BUTTONS = {
|
|
|
133
152
|
icon: 'format_list_numbered',
|
|
134
153
|
inline: false,
|
|
135
154
|
},
|
|
155
|
+
'task-list': {
|
|
156
|
+
labelKey: 'task_list',
|
|
157
|
+
icon: 'checklist',
|
|
158
|
+
inline: false,
|
|
159
|
+
},
|
|
136
160
|
blockquote: {
|
|
137
161
|
labelKey: 'blockquote',
|
|
138
162
|
icon: 'format_quote',
|
|
@@ -158,7 +182,7 @@ export const AVAILABLE_BUTTONS = {
|
|
|
158
182
|
/**
|
|
159
183
|
* @type {TextEditorFormatType[]}
|
|
160
184
|
*/
|
|
161
|
-
export const TEXT_FORMAT_BUTTON_TYPES = ['bold', 'italic', 'strikethrough', 'code'];
|
|
185
|
+
export const TEXT_FORMAT_BUTTON_TYPES = ['bold', 'italic', 'underline', 'strikethrough', 'code'];
|
|
162
186
|
|
|
163
187
|
/**
|
|
164
188
|
* @type {TextEditorInlineType[]}
|
|
@@ -178,10 +202,57 @@ export const BLOCK_BUTTON_TYPES = [
|
|
|
178
202
|
'heading-6',
|
|
179
203
|
'bulleted-list',
|
|
180
204
|
'numbered-list',
|
|
205
|
+
'task-list',
|
|
181
206
|
'blockquote',
|
|
182
207
|
'code-block',
|
|
183
208
|
];
|
|
184
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Buttons only available for HTML, as Markdown has no syntax for them: the underline format and the
|
|
212
|
+
* alignment menu. They’re hidden for Markdown and in the plain text mode, which shows the HTML
|
|
213
|
+
* source, and they’re not enabled by default.
|
|
214
|
+
* @type {('underline' | 'align')[]}
|
|
215
|
+
*/
|
|
216
|
+
export const HTML_ONLY_BUTTON_TYPES = ['underline', 'align'];
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Check whether the given button is only available for HTML. See {@link HTML_ONLY_BUTTON_TYPES}.
|
|
220
|
+
* @param {string} type Button type.
|
|
221
|
+
* @returns {type is 'underline' | 'align'} Result.
|
|
222
|
+
*/
|
|
223
|
+
export const isHtmlOnlyButton = (type) =>
|
|
224
|
+
/** @type {string[]} */ (HTML_ONLY_BUTTON_TYPES).includes(type);
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Text formats only available for HTML, like underline. See {@link HTML_ONLY_BUTTON_TYPES}.
|
|
228
|
+
*/
|
|
229
|
+
export const HTML_ONLY_FORMAT_TYPES = TEXT_FORMAT_BUTTON_TYPES.filter(isHtmlOnlyButton);
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Buttons not enabled by default: the HTML-only ones and the task list, a GitHub Flavored Markdown
|
|
233
|
+
* extension that not every Markdown renderer supports.
|
|
234
|
+
* @type {TextEditorNodeType[]}
|
|
235
|
+
*/
|
|
236
|
+
export const OPTIONAL_BUTTON_TYPES = [...HTML_ONLY_BUTTON_TYPES, 'task-list'];
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Buttons enabled by default: all the inline and block level buttons but the optional ones.
|
|
240
|
+
* @type {TextEditorNodeType[]}
|
|
241
|
+
*/
|
|
242
|
+
export const DEFAULT_BUTTON_TYPES = [...INLINE_BUTTON_TYPES, ...BLOCK_BUTTON_TYPES].filter(
|
|
243
|
+
(type) => !OPTIONAL_BUTTON_TYPES.includes(type),
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* List block types, with their Lexical list type and the command to insert the list.
|
|
248
|
+
* @type {{ type: TextEditorBlockType, listType: ListType, command: LexicalCommand<void> }[]}
|
|
249
|
+
*/
|
|
250
|
+
export const LIST_TYPES = [
|
|
251
|
+
{ type: 'bulleted-list', listType: 'bullet', command: INSERT_UNORDERED_LIST_COMMAND },
|
|
252
|
+
{ type: 'numbered-list', listType: 'number', command: INSERT_ORDERED_LIST_COMMAND },
|
|
253
|
+
{ type: 'task-list', listType: 'check', command: INSERT_CHECK_LIST_COMMAND },
|
|
254
|
+
];
|
|
255
|
+
|
|
185
256
|
/**
|
|
186
257
|
* Map of Lexical nodes for each block type. The `paragraph` block type is excluded because it is
|
|
187
258
|
* the default block type.
|
|
@@ -196,16 +267,17 @@ export const NODE_MAP = {
|
|
|
196
267
|
'heading-6': [HeadingNode],
|
|
197
268
|
'bulleted-list': [ListNode, ListItemNode],
|
|
198
269
|
'numbered-list': [ListNode, ListItemNode],
|
|
270
|
+
'task-list': [ListNode, ListItemNode],
|
|
199
271
|
blockquote: [QuoteNode],
|
|
200
272
|
'code-block': [CodeNode, CodeHighlightNode],
|
|
201
273
|
link: [LinkNode],
|
|
202
274
|
};
|
|
203
275
|
|
|
204
276
|
/**
|
|
205
|
-
* Map of Lexical transformers for each
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* Transformer[]
|
|
277
|
+
* Map of Lexical transformers for each button type. The `paragraph` block type has none because it
|
|
278
|
+
* is the default block type, and neither have the HTML-only buttons. Horizontal rules and tables
|
|
279
|
+
* are always supported in Markdown, so their transformers are added in `core.js`.
|
|
280
|
+
* @type {Partial<Record<TextEditorNodeType, Transformer[]>>}
|
|
209
281
|
*/
|
|
210
282
|
export const TRANSFORMER_MAP = {
|
|
211
283
|
// ELEMENT_TRANSFORMERS
|
|
@@ -215,6 +287,8 @@ export const TRANSFORMER_MAP = {
|
|
|
215
287
|
'heading-4': [HEADING],
|
|
216
288
|
'heading-5': [HEADING],
|
|
217
289
|
'heading-6': [HEADING],
|
|
290
|
+
// Before the bulleted list, as `- [ ] item` matches both
|
|
291
|
+
'task-list': [TASK_LIST],
|
|
218
292
|
'bulleted-list': [UNORDERED_LIST],
|
|
219
293
|
'numbered-list': [ORDERED_LIST],
|
|
220
294
|
blockquote: [QUOTE],
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { DOMConversionMap, LexicalEditor } from 'lexical';
|
|
3
|
+
* @import { TextEditorComponent } from '../../../../typedefs.js';
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Editor components of each editor, used to tell the elements they import, which come with their
|
|
7
|
+
* content, when HTML is imported.
|
|
8
|
+
* @type {WeakMap<LexicalEditor, TextEditorComponent[]>}
|
|
9
|
+
*/
|
|
10
|
+
export const editorComponents: WeakMap<LexicalEditor, TextEditorComponent[]>;
|
|
11
|
+
export function getComponentConversionMap(node: any): DOMConversionMap;
|
|
12
|
+
export function getElementComponent(editor: LexicalEditor, element: Element): TextEditorComponent | undefined;
|
|
13
|
+
export function isInlineComponentElement(element: Element): boolean;
|
|
14
|
+
import type { LexicalEditor } from 'lexical';
|
|
15
|
+
import type { TextEditorComponent } from '../../../../typedefs.js';
|
|
16
|
+
import type { DOMConversionMap } from 'lexical';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor components in HTML: the elements they import, which come with their content.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { $getEditor as getEditor } from 'lexical';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @import { DOMConversionMap, LexicalEditor } from 'lexical';
|
|
9
|
+
* @import { TextEditorComponent } from '../../../../typedefs.js';
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Editor components of each editor, used to tell the elements they import, which come with their
|
|
14
|
+
* content, when HTML is imported.
|
|
15
|
+
* @type {WeakMap<LexicalEditor, TextEditorComponent[]>}
|
|
16
|
+
*/
|
|
17
|
+
export const editorComponents = new WeakMap();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Conversion maps of the editor component nodes, cached as each `importDOM()` call can create a new
|
|
21
|
+
* map.
|
|
22
|
+
* @type {WeakMap<any, DOMConversionMap>}
|
|
23
|
+
*/
|
|
24
|
+
const componentConversionMaps = new WeakMap();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get the conversion map of the given editor component node.
|
|
28
|
+
* @param {any} node Lexical node class.
|
|
29
|
+
* @returns {DOMConversionMap} Conversion map.
|
|
30
|
+
*/
|
|
31
|
+
export const getComponentConversionMap = (node) => {
|
|
32
|
+
let map = componentConversionMaps.get(node);
|
|
33
|
+
|
|
34
|
+
if (!map) {
|
|
35
|
+
map = node.importDOM?.() ?? {};
|
|
36
|
+
componentConversionMaps.set(node, /** @type {DOMConversionMap} */ (map));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return /** @type {DOMConversionMap} */ (map);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Editor component that imports each element, or `null` if none does, cached as the same element is
|
|
44
|
+
* checked many times during an import, and a conversion can run developer code. An element is only
|
|
45
|
+
* imported to one editor, as each import parses the HTML anew.
|
|
46
|
+
* @type {WeakMap<Element, TextEditorComponent | null>}
|
|
47
|
+
*/
|
|
48
|
+
const elementComponents = new WeakMap();
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get the editor component that imports the given element, if any. The element’s content is then
|
|
52
|
+
* part of the component.
|
|
53
|
+
* @param {LexicalEditor} editor Editor instance.
|
|
54
|
+
* @param {Element} element Element.
|
|
55
|
+
* @returns {TextEditorComponent | undefined} Component.
|
|
56
|
+
*/
|
|
57
|
+
export const getElementComponent = (editor, element) => {
|
|
58
|
+
let component = elementComponents.get(element);
|
|
59
|
+
|
|
60
|
+
if (component === undefined) {
|
|
61
|
+
component =
|
|
62
|
+
editorComponents
|
|
63
|
+
.get(editor)
|
|
64
|
+
?.find(
|
|
65
|
+
({ node }) =>
|
|
66
|
+
!!getComponentConversionMap(node)[element.localName]?.(
|
|
67
|
+
/** @type {HTMLElement} */ (element),
|
|
68
|
+
),
|
|
69
|
+
) ?? null;
|
|
70
|
+
elementComponents.set(element, component);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return component ?? undefined;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check if the given element is imported by an inline editor component, like an image, which is
|
|
78
|
+
* content in the line just like text.
|
|
79
|
+
* @param {Element} element Element.
|
|
80
|
+
* @returns {boolean} Result.
|
|
81
|
+
*/
|
|
82
|
+
export const isInlineComponentElement = (element) => {
|
|
83
|
+
const component = getElementComponent(getEditor(), element);
|
|
84
|
+
|
|
85
|
+
// The `node` is actually a node class
|
|
86
|
+
return !!component && !!(/** @type {any} */ (component.node).prototype.isInline?.());
|
|
87
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map of Lexical node classes and functions to export them to clean HTML. A class only takes effect
|
|
3
|
+
* if the node is registered with the editor. Other nodes, including the ones of editor components,
|
|
4
|
+
* are exported with their own `exportDOM` method.
|
|
5
|
+
* @type {DOMExportOutputMap}
|
|
6
|
+
*/
|
|
7
|
+
export const HTML_EXPORT_MAP: DOMExportOutputMap;
|
|
8
|
+
export function exportHtml(editor: LexicalEditor): string;
|
|
9
|
+
import type { DOMExportOutputMap } from 'lexical';
|
|
10
|
+
import type { LexicalEditor } from 'lexical';
|