@mdxeditor/editor 1.6.0 → 1.7.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.
|
@@ -11,6 +11,16 @@ import type { LexicalEditor, RangeSelection, Klass, LexicalNode, TextFormatType,
|
|
|
11
11
|
import type { SystemSpec, Realm, RealmNode, PluginConstructor, TypedRealm, ValueForKey, SystemKeys, ValuesForKeys, SystemDict } from '../../gurx';
|
|
12
12
|
/// <reference types="react" />
|
|
13
13
|
import * as Mdast from 'mdast';
|
|
14
|
+
type InsertTablePayload = {
|
|
15
|
+
/**
|
|
16
|
+
* The nunber of rows of the table.
|
|
17
|
+
*/
|
|
18
|
+
rows?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The nunber of columns of the table.
|
|
21
|
+
*/
|
|
22
|
+
columns?: number;
|
|
23
|
+
};
|
|
14
24
|
/** @internal */
|
|
15
25
|
export declare const tableSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
16
26
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -123,7 +133,7 @@ export declare const tableSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
123
133
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
124
134
|
onBlur: RealmNode<FocusEvent>;
|
|
125
135
|
}]) => {
|
|
126
|
-
insertTable: RealmNode<
|
|
136
|
+
insertTable: RealmNode<InsertTablePayload>;
|
|
127
137
|
}>;
|
|
128
138
|
export declare const
|
|
129
139
|
/** @internal */
|
|
@@ -238,12 +248,12 @@ tablePlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
238
248
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
239
249
|
onBlur: RealmNode<FocusEvent>;
|
|
240
250
|
}]) => {
|
|
241
|
-
insertTable: RealmNode<
|
|
251
|
+
insertTable: RealmNode<InsertTablePayload>;
|
|
242
252
|
}>, object>,
|
|
243
253
|
/** @internal */
|
|
244
254
|
tablePluginHooks: {
|
|
245
255
|
useRealmContext: () => TypedRealm<{
|
|
246
|
-
insertTable: RealmNode<
|
|
256
|
+
insertTable: RealmNode<InsertTablePayload>;
|
|
247
257
|
} & {
|
|
248
258
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
249
259
|
inFocus: RealmNode<boolean>;
|
|
@@ -301,7 +311,7 @@ tablePluginHooks: {
|
|
|
301
311
|
onBlur: RealmNode<FocusEvent>;
|
|
302
312
|
}>;
|
|
303
313
|
useEmitter: <K extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "readOnly" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "onBlur" | "insertTable">(key: K, callback: (value: ValueForKey<{
|
|
304
|
-
insertTable: RealmNode<
|
|
314
|
+
insertTable: RealmNode<InsertTablePayload>;
|
|
305
315
|
} & {
|
|
306
316
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
307
317
|
inFocus: RealmNode<boolean>;
|
|
@@ -359,7 +369,7 @@ tablePluginHooks: {
|
|
|
359
369
|
onBlur: RealmNode<FocusEvent>;
|
|
360
370
|
}, K>) => void) => void;
|
|
361
371
|
useEmitterValues: <K_1 extends SystemKeys<{
|
|
362
|
-
insertTable: RealmNode<
|
|
372
|
+
insertTable: RealmNode<InsertTablePayload>;
|
|
363
373
|
} & {
|
|
364
374
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
365
375
|
inFocus: RealmNode<boolean>;
|
|
@@ -416,7 +426,7 @@ tablePluginHooks: {
|
|
|
416
426
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
417
427
|
onBlur: RealmNode<FocusEvent>;
|
|
418
428
|
}>>(...keys: K_1) => ValuesForKeys<{
|
|
419
|
-
insertTable: RealmNode<
|
|
429
|
+
insertTable: RealmNode<InsertTablePayload>;
|
|
420
430
|
} & {
|
|
421
431
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
422
432
|
inFocus: RealmNode<boolean>;
|
|
@@ -474,7 +484,7 @@ tablePluginHooks: {
|
|
|
474
484
|
onBlur: RealmNode<FocusEvent>;
|
|
475
485
|
}, K_1>;
|
|
476
486
|
usePubKeys: () => (values: SystemDict<{
|
|
477
|
-
insertTable: RealmNode<
|
|
487
|
+
insertTable: RealmNode<InsertTablePayload>;
|
|
478
488
|
} & {
|
|
479
489
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
480
490
|
inFocus: RealmNode<boolean>;
|
|
@@ -532,7 +542,7 @@ tablePluginHooks: {
|
|
|
532
542
|
onBlur: RealmNode<FocusEvent>;
|
|
533
543
|
}>) => void;
|
|
534
544
|
usePublisher: <K_2 extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "readOnly" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "onBlur" | "insertTable">(key: K_2) => (value: ValueForKey<{
|
|
535
|
-
insertTable: RealmNode<
|
|
545
|
+
insertTable: RealmNode<InsertTablePayload>;
|
|
536
546
|
} & {
|
|
537
547
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
538
548
|
inFocus: RealmNode<boolean>;
|
|
@@ -590,3 +600,4 @@ tablePluginHooks: {
|
|
|
590
600
|
onBlur: RealmNode<FocusEvent>;
|
|
591
601
|
}, K_2>) => void;
|
|
592
602
|
};
|
|
603
|
+
export {};
|
|
@@ -6,16 +6,26 @@ import { MdastTableVisitor } from "./MdastTableVisitor.js";
|
|
|
6
6
|
import { $createTableNode, TableNode } from "./TableNode.js";
|
|
7
7
|
import { system } from "../../gurx/realmFactory.js";
|
|
8
8
|
import { realmPlugin } from "../../gurx/react.js";
|
|
9
|
-
function seedTable() {
|
|
10
|
-
|
|
9
|
+
function seedTable(rows = 1, columns = 1) {
|
|
10
|
+
const table = {
|
|
11
11
|
type: "table",
|
|
12
|
-
children: [
|
|
13
|
-
{
|
|
14
|
-
type: "tableRow",
|
|
15
|
-
children: [{ type: "tableCell", children: [] }]
|
|
16
|
-
}
|
|
17
|
-
]
|
|
12
|
+
children: []
|
|
18
13
|
};
|
|
14
|
+
for (let i = 0; i < rows; i++) {
|
|
15
|
+
const tableRow = {
|
|
16
|
+
type: "tableRow",
|
|
17
|
+
children: []
|
|
18
|
+
};
|
|
19
|
+
for (let j = 0; j < columns; j++) {
|
|
20
|
+
const cell = {
|
|
21
|
+
type: "tableCell",
|
|
22
|
+
children: []
|
|
23
|
+
};
|
|
24
|
+
tableRow.children.push(cell);
|
|
25
|
+
}
|
|
26
|
+
table.children.push(tableRow);
|
|
27
|
+
}
|
|
28
|
+
return table;
|
|
19
29
|
}
|
|
20
30
|
const tableSystem = system(
|
|
21
31
|
(r, [{ insertDecoratorNode }]) => {
|
|
@@ -23,8 +33,8 @@ const tableSystem = system(
|
|
|
23
33
|
r.link(
|
|
24
34
|
r.pipe(
|
|
25
35
|
insertTable,
|
|
26
|
-
r.o.
|
|
27
|
-
return $createTableNode(seedTable());
|
|
36
|
+
r.o.map(({ rows, columns }) => {
|
|
37
|
+
return () => $createTableNode(seedTable(rows, columns));
|
|
28
38
|
})
|
|
29
39
|
),
|
|
30
40
|
insertDecoratorNode
|