@sveltia/ui 0.32.1 → 0.32.2
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.
|
@@ -1,56 +1,51 @@
|
|
|
1
1
|
import {
|
|
2
|
+
$createCodeNode,
|
|
3
|
+
$isCodeHighlightNode,
|
|
4
|
+
$isCodeNode,
|
|
2
5
|
CodeHighlightNode,
|
|
3
6
|
CodeNode,
|
|
4
7
|
PrismTokenizer,
|
|
5
|
-
$createCodeNode as createCodeNode,
|
|
6
|
-
$isCodeHighlightNode as isCodeHighlightNode,
|
|
7
|
-
$isCodeNode as isCodeNode,
|
|
8
8
|
registerCodeHighlighting,
|
|
9
9
|
} from '@lexical/code';
|
|
10
10
|
import { registerDragonSupport } from '@lexical/dragon';
|
|
11
11
|
import { HorizontalRuleNode } from '@lexical/extension';
|
|
12
12
|
import { createEmptyHistoryState, registerHistory } from '@lexical/history';
|
|
13
|
+
import { $isLinkNode, $toggleLink, LinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
13
14
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
$
|
|
17
|
-
$
|
|
18
|
-
} from '@lexical/link';
|
|
19
|
-
import {
|
|
15
|
+
$handleListInsertParagraph,
|
|
16
|
+
$insertList,
|
|
17
|
+
$isListItemNode,
|
|
18
|
+
$isListNode,
|
|
20
19
|
INSERT_ORDERED_LIST_COMMAND,
|
|
21
20
|
INSERT_UNORDERED_LIST_COMMAND,
|
|
22
21
|
ListItemNode,
|
|
23
22
|
ListNode,
|
|
24
|
-
$handleListInsertParagraph as handleListInsertParagraph,
|
|
25
|
-
$insertList as insertList,
|
|
26
|
-
$isListItemNode as isListItemNode,
|
|
27
|
-
$isListNode as isListNode,
|
|
28
23
|
} from '@lexical/list';
|
|
29
24
|
import {
|
|
25
|
+
$convertFromMarkdownString,
|
|
26
|
+
$convertToMarkdownString,
|
|
30
27
|
TRANSFORMERS,
|
|
31
|
-
$convertFromMarkdownString as convertFromMarkdownString,
|
|
32
|
-
$convertToMarkdownString as convertToMarkdownString,
|
|
33
28
|
} from '@lexical/markdown';
|
|
34
29
|
import {
|
|
30
|
+
$isHeadingNode,
|
|
31
|
+
$isQuoteNode,
|
|
35
32
|
HeadingNode,
|
|
36
33
|
QuoteNode,
|
|
37
|
-
$isHeadingNode as isHeadingNode,
|
|
38
|
-
$isQuoteNode as isQuoteNode,
|
|
39
34
|
registerRichText,
|
|
40
35
|
} from '@lexical/rich-text';
|
|
41
36
|
import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
42
|
-
import { $getNearestNodeOfType
|
|
37
|
+
import { $getNearestNodeOfType } from '@lexical/utils';
|
|
43
38
|
import { sleep } from '@sveltia/utils/misc';
|
|
44
39
|
import {
|
|
40
|
+
$getRoot,
|
|
41
|
+
$getSelection,
|
|
42
|
+
$isRangeSelection,
|
|
45
43
|
COMMAND_PRIORITY_NORMAL,
|
|
46
44
|
ElementNode,
|
|
47
45
|
INDENT_CONTENT_COMMAND,
|
|
48
46
|
INSERT_PARAGRAPH_COMMAND,
|
|
49
47
|
OUTDENT_CONTENT_COMMAND,
|
|
50
48
|
createEditor,
|
|
51
|
-
$getRoot as getRoot,
|
|
52
|
-
$getSelection as getSelection,
|
|
53
|
-
$isRangeSelection as isRangeSelection,
|
|
54
49
|
} from 'lexical';
|
|
55
50
|
import prismComponents from 'prismjs/components';
|
|
56
51
|
import { BLOCK_BUTTON_TYPES, TEXT_FORMAT_BUTTON_TYPES } from './constants.js';
|
|
@@ -146,9 +141,9 @@ const editorConfig = {
|
|
|
146
141
|
* @returns {TextEditorSelectionState} Current selection state.
|
|
147
142
|
*/
|
|
148
143
|
const getSelectionTypes = () => {
|
|
149
|
-
const selection = getSelection();
|
|
144
|
+
const selection = $getSelection();
|
|
150
145
|
|
|
151
|
-
if (
|
|
146
|
+
if (!$isRangeSelection(selection)) {
|
|
152
147
|
return {
|
|
153
148
|
blockNodeKey: null,
|
|
154
149
|
blockType: 'paragraph',
|
|
@@ -163,15 +158,15 @@ const getSelectionTypes = () => {
|
|
|
163
158
|
const inlineTypes = TEXT_FORMAT_BUTTON_TYPES.filter((type) => selection.hasFormat(type));
|
|
164
159
|
|
|
165
160
|
if (anchor.getType() !== 'root') {
|
|
166
|
-
parent = anchor instanceof ElementNode ? anchor : getNearestNodeOfType(anchor, ElementNode);
|
|
161
|
+
parent = anchor instanceof ElementNode ? anchor : $getNearestNodeOfType(anchor, ElementNode);
|
|
167
162
|
|
|
168
|
-
if (isLinkNode(parent)) {
|
|
163
|
+
if ($isLinkNode(parent)) {
|
|
169
164
|
inlineTypes.push('link');
|
|
170
|
-
parent = getNearestNodeOfType(parent, ElementNode);
|
|
165
|
+
parent = $getNearestNodeOfType(parent, ElementNode);
|
|
171
166
|
}
|
|
172
167
|
|
|
173
|
-
if (isListItemNode(parent)) {
|
|
174
|
-
parent = getNearestNodeOfType(parent, ListNode);
|
|
168
|
+
if ($isListItemNode(parent)) {
|
|
169
|
+
parent = $getNearestNodeOfType(parent, ListNode);
|
|
175
170
|
}
|
|
176
171
|
}
|
|
177
172
|
|
|
@@ -181,19 +176,19 @@ const getSelectionTypes = () => {
|
|
|
181
176
|
return 'paragraph';
|
|
182
177
|
}
|
|
183
178
|
|
|
184
|
-
if (isHeadingNode(parent)) {
|
|
179
|
+
if ($isHeadingNode(parent)) {
|
|
185
180
|
return `heading-${parent.getTag().match(/\d/)?.[0]}`;
|
|
186
181
|
}
|
|
187
182
|
|
|
188
|
-
if (isListNode(parent)) {
|
|
183
|
+
if ($isListNode(parent)) {
|
|
189
184
|
return parent.getListType() === 'bullet' ? 'bulleted-list' : 'numbered-list';
|
|
190
185
|
}
|
|
191
186
|
|
|
192
|
-
if (isQuoteNode(parent)) {
|
|
187
|
+
if ($isQuoteNode(parent)) {
|
|
193
188
|
return 'blockquote';
|
|
194
189
|
}
|
|
195
190
|
|
|
196
|
-
if (isCodeNode(parent) || isCodeHighlightNode(parent)) {
|
|
191
|
+
if ($isCodeNode(parent) || $isCodeHighlightNode(parent)) {
|
|
197
192
|
return 'code-block';
|
|
198
193
|
}
|
|
199
194
|
|
|
@@ -222,7 +217,7 @@ const onEditorUpdate = (editor) => {
|
|
|
222
217
|
editor.getRootElement()?.dispatchEvent(
|
|
223
218
|
new CustomEvent('Update', {
|
|
224
219
|
detail: {
|
|
225
|
-
value: convertToMarkdownString(
|
|
220
|
+
value: $convertToMarkdownString(
|
|
226
221
|
// Use underscores for italic text in Markdown instead of asterisks
|
|
227
222
|
allTransformers.filter((/** @type {any} */ { tag }) => tag !== '*'),
|
|
228
223
|
) // Remove unnecessary backslash for underscore and backslash characters
|
|
@@ -272,7 +267,7 @@ export const initEditor = ({
|
|
|
272
267
|
editor.registerCommand(
|
|
273
268
|
TOGGLE_LINK_COMMAND,
|
|
274
269
|
(payload) => {
|
|
275
|
-
toggleLink(typeof payload === 'string' ? payload : null);
|
|
270
|
+
$toggleLink(typeof payload === 'string' ? payload : null);
|
|
276
271
|
|
|
277
272
|
return true;
|
|
278
273
|
},
|
|
@@ -282,7 +277,7 @@ export const initEditor = ({
|
|
|
282
277
|
editor.registerCommand(
|
|
283
278
|
INSERT_UNORDERED_LIST_COMMAND,
|
|
284
279
|
() => {
|
|
285
|
-
insertList('bullet');
|
|
280
|
+
$insertList('bullet');
|
|
286
281
|
|
|
287
282
|
return true;
|
|
288
283
|
},
|
|
@@ -292,7 +287,7 @@ export const initEditor = ({
|
|
|
292
287
|
editor.registerCommand(
|
|
293
288
|
INSERT_ORDERED_LIST_COMMAND,
|
|
294
289
|
() => {
|
|
295
|
-
insertList('number');
|
|
290
|
+
$insertList('number');
|
|
296
291
|
|
|
297
292
|
return true;
|
|
298
293
|
},
|
|
@@ -302,7 +297,7 @@ export const initEditor = ({
|
|
|
302
297
|
// https://github.com/facebook/lexical/blob/main/packages/lexical-react/src/shared/useList.ts
|
|
303
298
|
editor.registerCommand(
|
|
304
299
|
INSERT_PARAGRAPH_COMMAND,
|
|
305
|
-
() => handleListInsertParagraph(),
|
|
300
|
+
() => $handleListInsertParagraph(),
|
|
306
301
|
COMMAND_PRIORITY_NORMAL,
|
|
307
302
|
);
|
|
308
303
|
|
|
@@ -316,15 +311,15 @@ export const initEditor = ({
|
|
|
316
311
|
editor.update(() => {
|
|
317
312
|
// Prevent CodeNode from being removed
|
|
318
313
|
if (isCodeEditor) {
|
|
319
|
-
const root = getRoot();
|
|
314
|
+
const root = $getRoot();
|
|
320
315
|
const children = root.getChildren();
|
|
321
316
|
|
|
322
|
-
if (children.length === 1 &&
|
|
317
|
+
if (children.length === 1 && !$isCodeNode(children[0])) {
|
|
323
318
|
children[0].remove();
|
|
324
319
|
}
|
|
325
320
|
|
|
326
321
|
if (children.length === 0) {
|
|
327
|
-
const node = createCodeNode();
|
|
322
|
+
const node = $createCodeNode();
|
|
328
323
|
|
|
329
324
|
node.setLanguage(defaultLanguage);
|
|
330
325
|
root.append(node);
|
|
@@ -342,18 +337,18 @@ export const initEditor = ({
|
|
|
342
337
|
root.addEventListener('keydown', (event) => {
|
|
343
338
|
editor.update(() => {
|
|
344
339
|
if (event.key === 'Tab') {
|
|
345
|
-
const selection = getSelection();
|
|
340
|
+
const selection = $getSelection();
|
|
346
341
|
|
|
347
|
-
if (
|
|
342
|
+
if (!$isRangeSelection(selection)) {
|
|
348
343
|
return;
|
|
349
344
|
}
|
|
350
345
|
|
|
351
346
|
const anchor = selection.anchor.getNode();
|
|
352
347
|
|
|
353
348
|
const parent =
|
|
354
|
-
anchor instanceof ElementNode ? anchor : getNearestNodeOfType(anchor, ElementNode);
|
|
349
|
+
anchor instanceof ElementNode ? anchor : $getNearestNodeOfType(anchor, ElementNode);
|
|
355
350
|
|
|
356
|
-
if (isListItemNode(parent) && parent.canIndent()) {
|
|
351
|
+
if ($isListItemNode(parent) && parent.canIndent()) {
|
|
357
352
|
if (!event.shiftKey) {
|
|
358
353
|
event.preventDefault();
|
|
359
354
|
editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined);
|
|
@@ -422,7 +417,7 @@ export const convertMarkdownToLexical = async (editor, value) => {
|
|
|
422
417
|
return new Promise((resolve, reject) => {
|
|
423
418
|
editor.update(() => {
|
|
424
419
|
try {
|
|
425
|
-
convertFromMarkdownString(value, allTransformers);
|
|
420
|
+
$convertFromMarkdownString(value, allTransformers);
|
|
426
421
|
resolve(undefined);
|
|
427
422
|
} catch (ex) {
|
|
428
423
|
reject(new Error('Failed to convert Markdown', { cause: ex }));
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
fixMarkdownFormatting,
|
|
4
|
-
increaseListIndentation,
|
|
5
|
-
splitMultilineFormatting,
|
|
6
|
-
} from './markdown.js';
|
|
2
|
+
import { increaseListIndentation, splitMultilineFormatting } from './markdown.js';
|
|
7
3
|
|
|
8
4
|
describe('splitMultilineFormatting', () => {
|
|
9
5
|
it('should split italic formatting across lines', () => {
|
|
@@ -43,96 +39,6 @@ describe('splitMultilineFormatting', () => {
|
|
|
43
39
|
});
|
|
44
40
|
});
|
|
45
41
|
|
|
46
|
-
describe('fixMarkdownFormatting', () => {
|
|
47
|
-
it('should fix unclosed bold markers with space in between', () => {
|
|
48
|
-
expect(fixMarkdownFormatting('**foo **bar')).toBe('**foo** bar');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should fix unclosed italic markers with space in between', () => {
|
|
52
|
-
expect(fixMarkdownFormatting('_foo _bar')).toBe('_foo_ bar');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should fix multiple bold markers', () => {
|
|
56
|
-
expect(fixMarkdownFormatting('**foo **bar **baz **qux')).toBe('**foo** bar **baz** qux');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should fix multiple italic markers', () => {
|
|
60
|
-
expect(fixMarkdownFormatting('_foo _bar _baz _qux')).toBe('_foo_ bar _baz_ qux');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should fix mixed bold and italic markers', () => {
|
|
64
|
-
expect(fixMarkdownFormatting('**foo **bar _baz _qux')).toBe('**foo** bar _baz_ qux');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should not affect properly closed bold markers', () => {
|
|
68
|
-
expect(fixMarkdownFormatting('**foo** bar')).toBe('**foo** bar');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should not affect properly closed italic markers', () => {
|
|
72
|
-
expect(fixMarkdownFormatting('_foo_ bar')).toBe('_foo_ bar');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should preserve other formatting', () => {
|
|
76
|
-
expect(fixMarkdownFormatting('~~strikethrough~~ **bold** _italic_')).toBe(
|
|
77
|
-
'~~strikethrough~~ **bold** _italic_',
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should handle bold and italic in combination', () => {
|
|
82
|
-
expect(fixMarkdownFormatting('**foo **bar _baz _qux **test **end')).toBe(
|
|
83
|
-
'**foo** bar _baz_ qux **test** end',
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should handle markers at the start of a line', () => {
|
|
88
|
-
expect(fixMarkdownFormatting('**foo **bar\n_baz _qux')).toBe('**foo** bar\n_baz_ qux');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should handle markers at the end of a line', () => {
|
|
92
|
-
expect(fixMarkdownFormatting('line 1 **foo **bar\nline 2 _baz _qux')).toBe(
|
|
93
|
-
'line 1 **foo** bar\nline 2 _baz_ qux',
|
|
94
|
-
);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should work with global flag for multiple occurrences', () => {
|
|
98
|
-
expect(fixMarkdownFormatting('**a **b **c **d _e _f')).toBe('**a** b **c** d _e_ f');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('should not break when markers are not present', () => {
|
|
102
|
-
expect(fixMarkdownFormatting('regular text without formatting')).toBe(
|
|
103
|
-
'regular text without formatting',
|
|
104
|
-
);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('should handle edge case with only formatting markers', () => {
|
|
108
|
-
expect(fixMarkdownFormatting('**foo **')).toBe('**foo** ');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should handle underscores in words (not formatting)', () => {
|
|
112
|
-
expect(fixMarkdownFormatting('snake_case_variable **foo **bar')).toBe(
|
|
113
|
-
'snake_case_variable **foo** bar',
|
|
114
|
-
);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should fix unclosed strikethrough markers with space in between', () => {
|
|
118
|
-
expect(fixMarkdownFormatting('~~foo ~~bar')).toBe('~~foo~~ bar');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should fix multiple strikethrough markers', () => {
|
|
122
|
-
expect(fixMarkdownFormatting('~~foo ~~bar ~~baz ~~qux')).toBe('~~foo~~ bar ~~baz~~ qux');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should fix mixed formatting with strikethrough', () => {
|
|
126
|
-
expect(fixMarkdownFormatting('**bold **text _italic _text ~~strike ~~text')).toBe(
|
|
127
|
-
'**bold** text _italic_ text ~~strike~~ text',
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should not affect properly closed strikethrough markers', () => {
|
|
132
|
-
expect(fixMarkdownFormatting('~~foo~~ bar')).toBe('~~foo~~ bar');
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
42
|
describe('increaseListIndentation', () => {
|
|
137
43
|
it('should double indentation for bullet lists', () => {
|
|
138
44
|
expect(increaseListIndentation(' - item')).toBe(' - item');
|
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
/* eslint-disable jsdoc/require-param-description */
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
+
$convertFromMarkdownString,
|
|
9
|
+
$convertToMarkdownString,
|
|
8
10
|
TRANSFORMERS,
|
|
9
|
-
$convertFromMarkdownString as convertFromMarkdownString,
|
|
10
|
-
$convertToMarkdownString as convertToMarkdownString,
|
|
11
11
|
} from '@lexical/markdown';
|
|
12
12
|
import {
|
|
13
|
+
$createTableCellNode,
|
|
14
|
+
$createTableNode,
|
|
15
|
+
$createTableRowNode,
|
|
16
|
+
$isTableCellNode,
|
|
17
|
+
$isTableNode,
|
|
18
|
+
$isTableRowNode,
|
|
13
19
|
TableCellHeaderStates,
|
|
14
20
|
TableCellNode,
|
|
15
21
|
TableNode,
|
|
16
22
|
TableRowNode,
|
|
17
|
-
$createTableCellNode as createTableCellNode,
|
|
18
|
-
$createTableNode as createTableNode,
|
|
19
|
-
$createTableRowNode as createTableRowNode,
|
|
20
|
-
$isTableCellNode as isTableCellNode,
|
|
21
|
-
$isTableNode as isTableNode,
|
|
22
|
-
$isTableRowNode as isTableRowNode,
|
|
23
23
|
} from '@lexical/table';
|
|
24
|
-
import { $isParagraphNode
|
|
24
|
+
import { $isParagraphNode, $isTextNode } from 'lexical';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* @import { ElementTransformer } from '@lexical/markdown';
|
|
@@ -38,7 +38,7 @@ const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
|
|
|
38
38
|
function getTableColumnsSize(table) {
|
|
39
39
|
const row = table.getFirstChild();
|
|
40
40
|
|
|
41
|
-
return isTableRowNode(row) ? row.getChildrenSize() : 0;
|
|
41
|
+
return $isTableRowNode(row) ? row.getChildrenSize() : 0;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -49,9 +49,9 @@ function getTableColumnsSize(table) {
|
|
|
49
49
|
const createTableCell = (textContent) => {
|
|
50
50
|
textContent = textContent.replace(/\\n/g, '\n');
|
|
51
51
|
|
|
52
|
-
const cell = createTableCellNode(TableCellHeaderStates.NO_STATUS);
|
|
52
|
+
const cell = $createTableCellNode(TableCellHeaderStates.NO_STATUS);
|
|
53
53
|
|
|
54
|
-
convertFromMarkdownString(textContent, TRANSFORMERS, cell);
|
|
54
|
+
$convertFromMarkdownString(textContent, TRANSFORMERS, cell);
|
|
55
55
|
|
|
56
56
|
return cell;
|
|
57
57
|
};
|
|
@@ -77,7 +77,7 @@ const mapToTableCells = (textContent) => {
|
|
|
77
77
|
export const TABLE = {
|
|
78
78
|
dependencies: [TableNode, TableRowNode, TableCellNode],
|
|
79
79
|
export: (node) => {
|
|
80
|
-
if (
|
|
80
|
+
if (!$isTableNode(node)) {
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -88,7 +88,7 @@ export const TABLE = {
|
|
|
88
88
|
/** @type {string[]} */
|
|
89
89
|
const rowOutput = [];
|
|
90
90
|
|
|
91
|
-
if (
|
|
91
|
+
if (!$isTableRowNode(row)) {
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -96,8 +96,8 @@ export const TABLE = {
|
|
|
96
96
|
|
|
97
97
|
row.getChildren().forEach((cell) => {
|
|
98
98
|
// It’s TableCellNode so it’s just to make flow happy
|
|
99
|
-
if (isTableCellNode(cell)) {
|
|
100
|
-
rowOutput.push(convertToMarkdownString(TRANSFORMERS, cell).replace(/\n/g, '\\n').trim());
|
|
99
|
+
if ($isTableCellNode(cell)) {
|
|
100
|
+
rowOutput.push($convertToMarkdownString(TRANSFORMERS, cell).replace(/\n/g, '\\n').trim());
|
|
101
101
|
|
|
102
102
|
if (cell.__headerState === TableCellHeaderStates.ROW) {
|
|
103
103
|
isHeaderRow = true;
|
|
@@ -120,20 +120,20 @@ export const TABLE = {
|
|
|
120
120
|
if (TABLE_ROW_DIVIDER_REG_EXP.test(textContent)) {
|
|
121
121
|
const table = parentNode.getPreviousSibling();
|
|
122
122
|
|
|
123
|
-
if (!table ||
|
|
123
|
+
if (!table || !$isTableNode(table)) {
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
const rows = table.getChildren();
|
|
128
128
|
const lastRow = rows[rows.length - 1];
|
|
129
129
|
|
|
130
|
-
if (!lastRow ||
|
|
130
|
+
if (!lastRow || !$isTableRowNode(lastRow)) {
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// Add header state to row cells
|
|
135
135
|
lastRow.getChildren().forEach((cell) => {
|
|
136
|
-
if (
|
|
136
|
+
if (!$isTableCellNode(cell)) {
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -157,7 +157,7 @@ export const TABLE = {
|
|
|
157
157
|
let maxCells = matchCells.length;
|
|
158
158
|
|
|
159
159
|
while (sibling) {
|
|
160
|
-
if (
|
|
160
|
+
if (!$isParagraphNode(sibling)) {
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -167,7 +167,7 @@ export const TABLE = {
|
|
|
167
167
|
|
|
168
168
|
const firstChild = sibling.getFirstChild();
|
|
169
169
|
|
|
170
|
-
if (
|
|
170
|
+
if (!$isTextNode(firstChild)) {
|
|
171
171
|
break;
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -186,10 +186,10 @@ export const TABLE = {
|
|
|
186
186
|
sibling = previousSibling;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
const table = createTableNode();
|
|
189
|
+
const table = $createTableNode();
|
|
190
190
|
|
|
191
191
|
rows.forEach((cells) => {
|
|
192
|
-
const tableRow = createTableRowNode();
|
|
192
|
+
const tableRow = $createTableRowNode();
|
|
193
193
|
|
|
194
194
|
table.append(tableRow);
|
|
195
195
|
|
|
@@ -200,7 +200,7 @@ export const TABLE = {
|
|
|
200
200
|
|
|
201
201
|
const previousSibling = parentNode.getPreviousSibling();
|
|
202
202
|
|
|
203
|
-
if (isTableNode(previousSibling) && getTableColumnsSize(previousSibling) === maxCells) {
|
|
203
|
+
if ($isTableNode(previousSibling) && getTableColumnsSize(previousSibling) === maxCells) {
|
|
204
204
|
previousSibling.append(...table.getChildren());
|
|
205
205
|
parentNode.remove();
|
|
206
206
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltia/ui",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"url": "github:sveltia/sveltia-ui"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@lexical/code": "^0.
|
|
12
|
-
"@lexical/dragon": "^0.
|
|
13
|
-
"@lexical/extension": "^0.
|
|
14
|
-
"@lexical/history": "^0.
|
|
15
|
-
"@lexical/link": "^0.
|
|
16
|
-
"@lexical/list": "^0.
|
|
17
|
-
"@lexical/markdown": "^0.
|
|
18
|
-
"@lexical/rich-text": "^0.
|
|
19
|
-
"@lexical/selection": "^0.
|
|
20
|
-
"@lexical/table": "^0.
|
|
21
|
-
"@lexical/utils": "^0.
|
|
11
|
+
"@lexical/code": "^0.41.0",
|
|
12
|
+
"@lexical/dragon": "^0.41.0",
|
|
13
|
+
"@lexical/extension": "^0.41.0",
|
|
14
|
+
"@lexical/history": "^0.41.0",
|
|
15
|
+
"@lexical/link": "^0.41.0",
|
|
16
|
+
"@lexical/list": "^0.41.0",
|
|
17
|
+
"@lexical/markdown": "^0.41.0",
|
|
18
|
+
"@lexical/rich-text": "^0.41.0",
|
|
19
|
+
"@lexical/selection": "^0.41.0",
|
|
20
|
+
"@lexical/table": "^0.41.0",
|
|
21
|
+
"@lexical/utils": "^0.41.0",
|
|
22
22
|
"@sveltia/utils": "^0.8.6",
|
|
23
|
-
"lexical": "^0.
|
|
23
|
+
"lexical": "^0.41.0",
|
|
24
24
|
"prismjs": "^1.30.0",
|
|
25
25
|
"svelte-i18n": "^4.0.1"
|
|
26
26
|
},
|
|
@@ -28,29 +28,29 @@
|
|
|
28
28
|
"svelte": "^5.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@sveltejs/adapter-auto": "^7.0.
|
|
32
|
-
"@sveltejs/kit": "^2.
|
|
31
|
+
"@sveltejs/adapter-auto": "^7.0.1",
|
|
32
|
+
"@sveltejs/kit": "^2.53.0",
|
|
33
33
|
"@sveltejs/package": "^2.5.7",
|
|
34
34
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
35
35
|
"@vitest/coverage-v8": "^4.0.18",
|
|
36
|
-
"cspell": "^9.
|
|
36
|
+
"cspell": "^9.7.0",
|
|
37
37
|
"eslint": "^8.57.1",
|
|
38
38
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
39
39
|
"eslint-config-prettier": "^10.1.8",
|
|
40
40
|
"eslint-plugin-import": "^2.32.0",
|
|
41
|
-
"eslint-plugin-jsdoc": "^62.
|
|
41
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
42
42
|
"eslint-plugin-svelte": "^2.46.1",
|
|
43
|
-
"oxlint": "^1.
|
|
43
|
+
"oxlint": "^1.50.0",
|
|
44
44
|
"postcss": "^8.5.6",
|
|
45
45
|
"postcss-html": "^1.8.1",
|
|
46
46
|
"prettier": "^3.8.1",
|
|
47
|
-
"prettier-plugin-svelte": "^3.
|
|
47
|
+
"prettier-plugin-svelte": "^3.5.0",
|
|
48
48
|
"sass": "^1.97.3",
|
|
49
|
-
"stylelint": "^17.
|
|
49
|
+
"stylelint": "^17.3.0",
|
|
50
50
|
"stylelint-config-recommended-scss": "^17.0.0",
|
|
51
51
|
"stylelint-scss": "^7.0.0",
|
|
52
|
-
"svelte": "^5.
|
|
53
|
-
"svelte-check": "^4.3
|
|
52
|
+
"svelte": "^5.53.3",
|
|
53
|
+
"svelte-check": "^4.4.3",
|
|
54
54
|
"svelte-preprocess": "^6.0.3",
|
|
55
55
|
"tslib": "^2.8.1",
|
|
56
56
|
"vite": "^7.3.1",
|