@sveltia/ui 0.84.0 → 0.85.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/core.js +15 -4
- 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/toolbar/insert-component.d.ts +2 -1
- package/dist/components/text-editor/toolbar/insert-component.js +14 -2
- package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +24 -21
- package/dist/components/text-editor/transformers/table.d.ts +4 -5
- package/dist/components/text-editor/transformers/table.js +125 -112
- package/dist/typedefs.d.ts +2 -1
- package/dist/typedefs.js +2 -1
- package/package.json +1 -1
|
@@ -118,13 +118,13 @@ import {
|
|
|
118
118
|
$getSelectedTableCellKey,
|
|
119
119
|
$normalizeTableHeaders,
|
|
120
120
|
} from './table.js';
|
|
121
|
-
import {
|
|
121
|
+
import { createTableTransformer } from './transformers/table.js';
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* @import { LexicalEditor, LexicalNode } from 'lexical';
|
|
125
125
|
* @import { LinkAttributes } from '@lexical/link';
|
|
126
126
|
* @import { ListType } from '@lexical/list';
|
|
127
|
-
* @import { Transformer } from '@lexical/markdown';
|
|
127
|
+
* @import { TextMatchTransformer, Transformer } from '@lexical/markdown';
|
|
128
128
|
* @import {
|
|
129
129
|
* TextEditorBlockType,
|
|
130
130
|
* TextEditorComponent,
|
|
@@ -977,9 +977,11 @@ export const initEditor = ({
|
|
|
977
977
|
},
|
|
978
978
|
});
|
|
979
979
|
|
|
980
|
+
const componentTransformers = components.map(({ transformer }) => transformer);
|
|
981
|
+
|
|
980
982
|
/** @type {Transformer[]} */
|
|
981
983
|
const enabledTransformers = [
|
|
982
|
-
...
|
|
984
|
+
...componentTransformers,
|
|
983
985
|
...new Set(
|
|
984
986
|
Object.entries(TRANSFORMER_MAP)
|
|
985
987
|
.filter(([button]) => enabledButtons.includes(/** @type {TextEditorNodeType} */ (button)))
|
|
@@ -988,7 +990,16 @@ export const initEditor = ({
|
|
|
988
990
|
...(isCodeEditor
|
|
989
991
|
? [CODE]
|
|
990
992
|
: // See the comment above for why we always include horizontal rules and tables
|
|
991
|
-
[
|
|
993
|
+
[
|
|
994
|
+
HR,
|
|
995
|
+
// A table cell can only have inline content, so only the components with a text match
|
|
996
|
+
// transformer can be used there
|
|
997
|
+
createTableTransformer(
|
|
998
|
+
/** @type {TextMatchTransformer[]} */ (
|
|
999
|
+
componentTransformers.filter(({ type }) => type === 'text-match')
|
|
1000
|
+
),
|
|
1001
|
+
),
|
|
1002
|
+
]),
|
|
992
1003
|
];
|
|
993
1004
|
|
|
994
1005
|
const editor = buildEditorFromExtensions(editorExtension);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export function isInlineComponent({ transformer }: TextEditorComponent): boolean;
|
|
1
2
|
export function insertEditorComponent(editorStore: TextEditorStore, component: TextEditorComponent): void;
|
|
2
|
-
import type { TextEditorStore } from '../../../typedefs.js';
|
|
3
3
|
import type { TextEditorComponent } from '../../../typedefs.js';
|
|
4
|
+
import type { TextEditorStore } from '../../../typedefs.js';
|
|
@@ -5,6 +5,15 @@ import { insertComponent } from '../raw-markdown.js';
|
|
|
5
5
|
* @import { TextEditorComponent, TextEditorStore } from '../../../typedefs.js';
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Check if the given editor component is inline, which means its Markdown is matched within a line
|
|
10
|
+
* of text by a text match transformer. Only an inline component can be inserted into a Markdown
|
|
11
|
+
* table cell.
|
|
12
|
+
* @param {TextEditorComponent} component Editor component.
|
|
13
|
+
* @returns {boolean} Result.
|
|
14
|
+
*/
|
|
15
|
+
export const isInlineComponent = ({ transformer }) => transformer.type === 'text-match';
|
|
16
|
+
|
|
8
17
|
/**
|
|
9
18
|
* Insert a new instance of the given editor component into the editor: its Markdown in the plain
|
|
10
19
|
* text mode, or its node in the rich text mode.
|
|
@@ -28,7 +37,10 @@ export const insertEditorComponent = (editorStore, component) => {
|
|
|
28
37
|
const { createNode } = component;
|
|
29
38
|
|
|
30
39
|
editorStore.editor?.update(() => {
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
const node = createNode();
|
|
41
|
+
|
|
42
|
+
// Add an additional paragraph after a block for easier editing. An inline node stays within the
|
|
43
|
+
// text, which may be in a table cell where a paragraph can’t be added
|
|
44
|
+
insertNodes(node.isInline() ? [node] : [node, createParagraphNode()]);
|
|
33
45
|
});
|
|
34
46
|
};
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import InsertItemButton from './insert-item-button.svelte';
|
|
18
18
|
import InsertLinkButton from './insert-link-button.svelte';
|
|
19
19
|
import InsertMenuButton from './insert-menu-button.svelte';
|
|
20
|
+
import { isInlineComponent } from './insert-component.js';
|
|
20
21
|
import InsertTableButton from './insert-table-button.svelte';
|
|
21
22
|
import TableActionMenu from './table-action-menu.svelte';
|
|
22
23
|
import ToggleBlockMenuItem from './toggle-block-menu-item.svelte';
|
|
@@ -48,13 +49,6 @@
|
|
|
48
49
|
/** @type {TextEditorStore} */
|
|
49
50
|
const editorStore = getContext('editorStore');
|
|
50
51
|
|
|
51
|
-
const buttons = $derived(
|
|
52
|
-
editorStore.config.components.filter(({ trigger = 'menuitem' }) => trigger === 'button'),
|
|
53
|
-
);
|
|
54
|
-
const menuitems = $derived(
|
|
55
|
-
editorStore.config.components.filter(({ trigger = 'menuitem' }) => trigger === 'menuitem'),
|
|
56
|
-
);
|
|
57
|
-
|
|
58
52
|
/**
|
|
59
53
|
* Enabled block level buttons.
|
|
60
54
|
* @type {TextEditorBlockType[]}
|
|
@@ -93,17 +87,28 @@
|
|
|
93
87
|
);
|
|
94
88
|
/**
|
|
95
89
|
* Whether the caret is in a Markdown table cell, which can only have inline content, so neither
|
|
96
|
-
* a horizontal rule nor
|
|
97
|
-
* standard Markdown syntax only, so an editor component would be lost.
|
|
90
|
+
* a horizontal rule nor a block editor component can be inserted.
|
|
98
91
|
*/
|
|
99
92
|
const inMarkdownTable = $derived(!!tableCellKey && !isHtml);
|
|
93
|
+
/**
|
|
94
|
+
* Editor components that can be inserted at the caret: only the inline ones in a Markdown table
|
|
95
|
+
* cell.
|
|
96
|
+
*/
|
|
97
|
+
const components = $derived(
|
|
98
|
+
inMarkdownTable
|
|
99
|
+
? editorStore.config.components.filter(isInlineComponent)
|
|
100
|
+
: editorStore.config.components,
|
|
101
|
+
);
|
|
102
|
+
const buttons = $derived(components.filter(({ trigger = 'menuitem' }) => trigger === 'button'));
|
|
103
|
+
const menuitems = $derived(
|
|
104
|
+
components.filter(({ trigger = 'menuitem' }) => trigger === 'menuitem'),
|
|
105
|
+
);
|
|
100
106
|
/**
|
|
101
107
|
* Whether any of the buttons to insert a table, a horizontal rule or an editor component is
|
|
102
108
|
* shown.
|
|
103
109
|
*/
|
|
104
110
|
const hasInsertButtons = $derived(
|
|
105
|
-
hasTable ||
|
|
106
|
-
(!inMarkdownTable && (hasHorizontalRule || editorStore.config.components.length > 0)),
|
|
111
|
+
hasTable || (!inMarkdownTable && hasHorizontalRule) || components.length > 0,
|
|
107
112
|
);
|
|
108
113
|
/**
|
|
109
114
|
* Whether the block level styles are available.
|
|
@@ -186,16 +191,14 @@
|
|
|
186
191
|
<!-- Tables can’t be nested -->
|
|
187
192
|
<InsertTableButton disabled={!!tableCellKey} />
|
|
188
193
|
{/if}
|
|
189
|
-
{#if !inMarkdownTable}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
{
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
<InsertMenuButton components={menuitems} />
|
|
198
|
-
{/if}
|
|
194
|
+
{#if hasHorizontalRule && !inMarkdownTable}
|
|
195
|
+
<InsertHorizontalRuleButton />
|
|
196
|
+
{/if}
|
|
197
|
+
{#each buttons as button (button.id)}
|
|
198
|
+
<InsertItemButton component={button} />
|
|
199
|
+
{/each}
|
|
200
|
+
{#if menuitems.length}
|
|
201
|
+
<InsertMenuButton components={menuitems} />
|
|
199
202
|
{/if}
|
|
200
203
|
{/if}
|
|
201
204
|
{/if}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export function getTableColumnsSize(table: TableNode): number;
|
|
2
|
-
export function mapToTableCells(textContent: string): TableCellNode[] | null;
|
|
3
|
-
|
|
4
|
-
* @type {ElementTransformer}
|
|
5
|
-
*/
|
|
6
|
-
export const TABLE: ElementTransformer;
|
|
2
|
+
export function mapToTableCells(textContent: string, transformers: Transformer[]): TableCellNode[] | null;
|
|
3
|
+
export function createTableTransformer(cellTransformers?: TextMatchTransformer[]): ElementTransformer;
|
|
7
4
|
import { TableNode } from '@lexical/table';
|
|
5
|
+
import type { Transformer } from '@lexical/markdown';
|
|
8
6
|
import { TableCellNode } from '@lexical/table';
|
|
7
|
+
import type { TextMatchTransformer } from '@lexical/markdown';
|
|
9
8
|
import type { ElementTransformer } from '@lexical/markdown';
|
|
@@ -26,7 +26,7 @@ import { $isParagraphNode as isParagraphNode, $isTextNode as isTextNode } from '
|
|
|
26
26
|
import { BLOCK_SYNTAX_ESCAPE } from './block-escape.js';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @import { ElementTransformer } from '@lexical/markdown';
|
|
29
|
+
* @import { ElementTransformer, TextMatchTransformer, Transformer } from '@lexical/markdown';
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
const TABLE_ROW_REG_EXP = /^(?:\|)(.+)(?:\|)\s?$/;
|
|
@@ -47,16 +47,17 @@ export const getTableColumnsSize = (table) => {
|
|
|
47
47
|
/**
|
|
48
48
|
* Creates a table cell with the given text content.
|
|
49
49
|
* @param {string} textContent
|
|
50
|
+
* @param {Transformer[]} transformers Transformers to import the cell content with.
|
|
50
51
|
* @returns {TableCellNode}
|
|
51
52
|
*/
|
|
52
|
-
const createTableCell = (textContent) => {
|
|
53
|
+
const createTableCell = (textContent, transformers) => {
|
|
53
54
|
// An escaped pipe is part of the cell, even within inline code, like GitHub Flavored Markdown.
|
|
54
55
|
// The spaces around the content only separate it from the pipes
|
|
55
56
|
textContent = textContent.trim().replace(/\\n/g, '\n').replace(/\\\|/g, '|');
|
|
56
57
|
|
|
57
58
|
const cell = createTableCellNode(TableCellHeaderStates.NO_STATUS);
|
|
58
59
|
|
|
59
|
-
convertFromMarkdownString(textContent,
|
|
60
|
+
convertFromMarkdownString(textContent, transformers, cell);
|
|
60
61
|
|
|
61
62
|
return cell;
|
|
62
63
|
};
|
|
@@ -65,9 +66,10 @@ const createTableCell = (textContent) => {
|
|
|
65
66
|
* Maps the given text content to an array of table cells.
|
|
66
67
|
* @internal
|
|
67
68
|
* @param {string} textContent
|
|
69
|
+
* @param {Transformer[]} transformers Transformers to import the cell content with.
|
|
68
70
|
* @returns {TableCellNode[] | null}
|
|
69
71
|
*/
|
|
70
|
-
export const mapToTableCells = (textContent) => {
|
|
72
|
+
export const mapToTableCells = (textContent, transformers) => {
|
|
71
73
|
const [, match] = textContent.match(TABLE_ROW_REG_EXP) ?? [];
|
|
72
74
|
|
|
73
75
|
if (!match) {
|
|
@@ -76,152 +78,163 @@ export const mapToTableCells = (textContent) => {
|
|
|
76
78
|
|
|
77
79
|
// Split the row at the pipes that are not escaped, which are preceded by an even number of
|
|
78
80
|
// backslashes
|
|
79
|
-
return match.split(/(?<=(?<!\\)(?:\\\\)*)\|/).map((text) => createTableCell(text));
|
|
81
|
+
return match.split(/(?<=(?<!\\)(?:\\\\)*)\|/).map((text) => createTableCell(text, transformers));
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
|
-
*
|
|
85
|
+
* Create a table transformer. A cell can only have inline content, so it’s converted with the
|
|
86
|
+
* standard Markdown transformers and the given text match transformers, like those of the inline
|
|
87
|
+
* editor components, which come first to take priority, as they do for the rest of the document.
|
|
88
|
+
* @param {TextMatchTransformer[]} [cellTransformers] Additional transformers for the cell content.
|
|
89
|
+
* @returns {ElementTransformer}
|
|
84
90
|
*/
|
|
85
|
-
export const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
export const createTableTransformer = (cellTransformers = []) => {
|
|
92
|
+
/** @type {Transformer[]} */
|
|
93
|
+
const transformers = [...cellTransformers, ...TRANSFORMERS];
|
|
94
|
+
/** @type {Transformer[]} */
|
|
95
|
+
const exportTransformers = [...transformers, BLOCK_SYNTAX_ESCAPE];
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
dependencies: [TableNode, TableRowNode, TableCellNode],
|
|
99
|
+
export: (node) => {
|
|
100
|
+
if (!isTableNode(node)) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
94
103
|
|
|
95
|
-
node.getChildren().forEach((row) => {
|
|
96
104
|
/** @type {string[]} */
|
|
97
|
-
const
|
|
105
|
+
const output = [];
|
|
98
106
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
node.getChildren().forEach((row) => {
|
|
108
|
+
/** @type {string[]} */
|
|
109
|
+
const rowOutput = [];
|
|
102
110
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
row.getChildren().forEach((cell) => {
|
|
106
|
-
// It’s TableCellNode so it’s just to make flow happy
|
|
107
|
-
if (isTableCellNode(cell)) {
|
|
108
|
-
rowOutput.push(
|
|
109
|
-
convertToMarkdownString([...TRANSFORMERS, BLOCK_SYNTAX_ESCAPE], cell)
|
|
110
|
-
// Escape a pipe, which would otherwise end the cell, even within inline code
|
|
111
|
-
.replace(/\|/g, '\\|')
|
|
112
|
-
.replace(/\n/g, '\\n')
|
|
113
|
-
.trim(),
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
if (cell.__headerState === TableCellHeaderStates.ROW) {
|
|
117
|
-
isHeaderRow = true;
|
|
118
|
-
}
|
|
111
|
+
if (!isTableRowNode(row)) {
|
|
112
|
+
return;
|
|
119
113
|
}
|
|
120
|
-
});
|
|
121
114
|
|
|
122
|
-
|
|
115
|
+
let isHeaderRow = false;
|
|
116
|
+
|
|
117
|
+
row.getChildren().forEach((cell) => {
|
|
118
|
+
// It’s TableCellNode so it’s just to make flow happy
|
|
119
|
+
if (isTableCellNode(cell)) {
|
|
120
|
+
rowOutput.push(
|
|
121
|
+
convertToMarkdownString(exportTransformers, cell)
|
|
122
|
+
// Escape a pipe, which would otherwise end the cell, even within inline code
|
|
123
|
+
.replace(/\|/g, '\\|')
|
|
124
|
+
.replace(/\n/g, '\\n')
|
|
125
|
+
.trim(),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
if (cell.__headerState === TableCellHeaderStates.ROW) {
|
|
129
|
+
isHeaderRow = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
123
133
|
|
|
124
|
-
|
|
125
|
-
output.push(`| ${rowOutput.map(() => '---').join(' | ')} |`);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
134
|
+
output.push(`| ${rowOutput.join(' | ')} |`);
|
|
128
135
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// Header row
|
|
134
|
-
if (TABLE_ROW_DIVIDER_REG_EXP.test(textContent)) {
|
|
135
|
-
const table = parentNode.getPreviousSibling();
|
|
136
|
+
if (isHeaderRow) {
|
|
137
|
+
output.push(`| ${rowOutput.map(() => '---').join(' | ')} |`);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
136
140
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
141
|
+
return output.join('\n');
|
|
142
|
+
},
|
|
143
|
+
regExp: TABLE_ROW_REG_EXP,
|
|
144
|
+
replace: (parentNode, _children, [textContent]) => {
|
|
145
|
+
// Header row
|
|
146
|
+
if (TABLE_ROW_DIVIDER_REG_EXP.test(textContent)) {
|
|
147
|
+
const table = parentNode.getPreviousSibling();
|
|
140
148
|
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
if (!table || !isTableNode(table)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
143
152
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
153
|
+
const rows = table.getChildren();
|
|
154
|
+
const lastRow = rows[rows.length - 1];
|
|
147
155
|
|
|
148
|
-
|
|
149
|
-
lastRow.getChildren().forEach((cell) => {
|
|
150
|
-
if (!isTableCellNode(cell)) {
|
|
156
|
+
if (!lastRow || !isTableRowNode(lastRow)) {
|
|
151
157
|
return;
|
|
152
158
|
}
|
|
153
159
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
// Add header state to row cells
|
|
161
|
+
lastRow.getChildren().forEach((cell) => {
|
|
162
|
+
if (!isTableCellNode(cell)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
159
165
|
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
cell.setHeaderStyles(TableCellHeaderStates.ROW, TableCellHeaderStates.ROW);
|
|
167
|
+
});
|
|
162
168
|
|
|
163
|
-
|
|
169
|
+
// Remove line
|
|
170
|
+
parentNode.remove();
|
|
164
171
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
168
174
|
|
|
169
|
-
|
|
170
|
-
let sibling = parentNode.getPreviousSibling();
|
|
171
|
-
let maxCells = matchCells.length;
|
|
175
|
+
const matchCells = mapToTableCells(textContent, transformers);
|
|
172
176
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
break;
|
|
177
|
+
if (!matchCells) {
|
|
178
|
+
return;
|
|
176
179
|
}
|
|
177
180
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
const rows = [matchCells];
|
|
182
|
+
let sibling = parentNode.getPreviousSibling();
|
|
183
|
+
let maxCells = matchCells.length;
|
|
181
184
|
|
|
182
|
-
|
|
185
|
+
while (sibling) {
|
|
186
|
+
if (!isParagraphNode(sibling)) {
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
183
189
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
if (sibling.getChildrenSize() !== 1) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
187
193
|
|
|
188
|
-
|
|
194
|
+
const firstChild = sibling.getFirstChild();
|
|
189
195
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
196
|
+
if (!isTextNode(firstChild)) {
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
193
199
|
|
|
194
|
-
|
|
195
|
-
rows.unshift(cells);
|
|
200
|
+
const cells = mapToTableCells(firstChild.getTextContent(), transformers);
|
|
196
201
|
|
|
197
|
-
|
|
202
|
+
if (!cells) {
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
198
205
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
206
|
+
maxCells = Math.max(maxCells, cells.length);
|
|
207
|
+
rows.unshift(cells);
|
|
202
208
|
|
|
203
|
-
|
|
209
|
+
const previousSibling = sibling.getPreviousSibling();
|
|
204
210
|
|
|
205
|
-
|
|
206
|
-
|
|
211
|
+
sibling.remove();
|
|
212
|
+
sibling = previousSibling;
|
|
213
|
+
}
|
|
207
214
|
|
|
208
|
-
table
|
|
215
|
+
const table = createTableNode();
|
|
209
216
|
|
|
210
|
-
|
|
211
|
-
tableRow
|
|
212
|
-
}
|
|
213
|
-
});
|
|
217
|
+
rows.forEach((cells) => {
|
|
218
|
+
const tableRow = createTableRowNode();
|
|
214
219
|
|
|
215
|
-
|
|
220
|
+
table.append(tableRow);
|
|
216
221
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
for (let i = 0; i < maxCells; i += 1) {
|
|
223
|
+
tableRow.append(i < cells.length ? cells[i] : createTableCell('', transformers));
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
const previousSibling = parentNode.getPreviousSibling();
|
|
228
|
+
|
|
229
|
+
if (isTableNode(previousSibling) && getTableColumnsSize(previousSibling) === maxCells) {
|
|
230
|
+
previousSibling.append(...table.getChildren());
|
|
231
|
+
parentNode.remove();
|
|
232
|
+
} else {
|
|
233
|
+
parentNode.replace(table);
|
|
234
|
+
}
|
|
223
235
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
236
|
+
table.selectEnd();
|
|
237
|
+
},
|
|
238
|
+
type: 'element',
|
|
239
|
+
};
|
|
227
240
|
};
|
package/dist/typedefs.d.ts
CHANGED
|
@@ -761,7 +761,8 @@ export type TextEditorComponent = {
|
|
|
761
761
|
*/
|
|
762
762
|
createNode: (props?: Record<string, any>) => LexicalNode;
|
|
763
763
|
/**
|
|
764
|
-
* Node transformer.
|
|
764
|
+
* Node transformer. A component with a text match transformer
|
|
765
|
+
* is inline, so it can also be inserted into, and read from, a Markdown table cell.
|
|
765
766
|
*/
|
|
766
767
|
transformer: Transformer;
|
|
767
768
|
/**
|
package/dist/typedefs.js
CHANGED
|
@@ -326,7 +326,8 @@
|
|
|
326
326
|
* for the same element type, like a link, with a `priority` of 4 or higher.
|
|
327
327
|
* @property {(props?: Record<string, any>) => LexicalNode} createNode Function to create a new node
|
|
328
328
|
* instance.
|
|
329
|
-
* @property {Transformer} transformer Node transformer.
|
|
329
|
+
* @property {Transformer} transformer Node transformer. A component with a text match transformer
|
|
330
|
+
* is inline, so it can also be inserted into, and read from, a Markdown table cell.
|
|
330
331
|
* @property {() => string} [createMarkdown] Function to create the Markdown inserted when the
|
|
331
332
|
* component is chosen in the plain text mode. By default, a new node created with `createNode` is
|
|
332
333
|
* exported with `transformer`, which may result in an empty string, for example if the output
|