@mdxeditor/editor 3.26.0 → 3.27.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/MDXEditor.js +5 -4
- package/dist/index.d.ts +44 -0
- package/dist/index.js +7 -3
- package/dist/plugins/codeblock/CodeBlockNode.js +23 -0
- package/dist/plugins/codeblock/index.js +2 -1
- package/dist/plugins/core/index.js +4 -0
- package/dist/plugins/table/TableNode.js +37 -0
- package/dist/plugins/table/index.js +2 -1
- package/dist/plugins/toolbar/index.js +3 -2
- package/package.json +1 -1
package/dist/MDXEditor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCellValue, usePublisher, useCellValues, useRealm } from "@mdxeditor/gurx";
|
|
2
2
|
import React__default from "react";
|
|
3
3
|
import { RealmWithPlugins } from "./RealmWithPlugins.js";
|
|
4
|
-
import { corePlugin, rootEditor$, useTranslation, contentEditableRef$, contentEditableClassName$, spellCheck$, composerChildren$, topAreaChildren$, editorWrappers$, placeholder$, editorRootElementRef$, viewMode$, markdownSourceEditorValue$, markdown$, setMarkdown$, insertMarkdown$ } from "./plugins/core/index.js";
|
|
4
|
+
import { corePlugin, rootEditor$, useTranslation, contentEditableRef$, contentEditableClassName$, spellCheck$, composerChildren$, topAreaChildren$, editorWrappers$, placeholder$, bottomAreaChildren$, editorRootElementRef$, viewMode$, markdownSourceEditorValue$, markdown$, setMarkdown$, insertMarkdown$ } from "./plugins/core/index.js";
|
|
5
5
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
6
6
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
7
7
|
import classNames from "classnames";
|
|
@@ -24,13 +24,14 @@ const RichTextEditor = () => {
|
|
|
24
24
|
const onRef = (_contentEditableRef) => {
|
|
25
25
|
setContentEditableRef({ current: _contentEditableRef });
|
|
26
26
|
};
|
|
27
|
-
const [contentEditableClassName, spellCheck, composerChildren, topAreaChildren, editorWrappers, placeholder] = useCellValues(
|
|
27
|
+
const [contentEditableClassName, spellCheck, composerChildren, topAreaChildren, editorWrappers, placeholder, bottomAreaChildren] = useCellValues(
|
|
28
28
|
contentEditableClassName$,
|
|
29
29
|
spellCheck$,
|
|
30
30
|
composerChildren$,
|
|
31
31
|
topAreaChildren$,
|
|
32
32
|
editorWrappers$,
|
|
33
|
-
placeholder
|
|
33
|
+
placeholder$,
|
|
34
|
+
bottomAreaChildren$
|
|
34
35
|
);
|
|
35
36
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, topAreaChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })), /* @__PURE__ */ React__default.createElement(RenderRecursiveWrappers, { wrappers: editorWrappers }, /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.rootContentEditableWrapper, "mdxeditor-root-contenteditable") }, /* @__PURE__ */ React__default.createElement(
|
|
36
37
|
RichTextPlugin,
|
|
@@ -46,7 +47,7 @@ const RichTextEditor = () => {
|
|
|
46
47
|
placeholder: /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.contentEditable, styles.placeholder, contentEditableClassName) }, /* @__PURE__ */ React__default.createElement("p", null, placeholder)),
|
|
47
48
|
ErrorBoundary: LexicalErrorBoundary
|
|
48
49
|
}
|
|
49
|
-
))), composerChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })));
|
|
50
|
+
))), composerChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })), bottomAreaChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })));
|
|
50
51
|
};
|
|
51
52
|
const DEFAULT_MARKDOWN_OPTIONS = {
|
|
52
53
|
listItemIndent: "one"
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { DecoratorNode } from 'lexical';
|
|
|
4
4
|
import { default as default_2 } from 'react';
|
|
5
5
|
import { Directives } from 'mdast-util-directive';
|
|
6
6
|
import { DOMConversionMap } from 'lexical';
|
|
7
|
+
import { DOMConversionOutput } from 'lexical';
|
|
7
8
|
import { DOMExportOutput } from 'lexical';
|
|
8
9
|
import { EditorConfig } from 'lexical';
|
|
9
10
|
import { EditorThemeClasses } from 'lexical';
|
|
@@ -45,6 +46,29 @@ import { TextFormatType } from 'lexical';
|
|
|
45
46
|
import { TextNode } from 'lexical';
|
|
46
47
|
import { Options as ToMarkdownOptions } from 'mdast-util-to-markdown';
|
|
47
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Converts a <pre> HTML element into a CodeBlockNode.
|
|
51
|
+
* Extracts the code content, language, and meta information from the element's attributes.
|
|
52
|
+
* The language is determined from the class attribute (e.g., class="language-javascript") or
|
|
53
|
+
* the data-language attribute if available.
|
|
54
|
+
*
|
|
55
|
+
* @param element - The <pre> HTML element to convert.
|
|
56
|
+
* @returns A DOMConversionOutput containing the created CodeBlockNode.
|
|
57
|
+
* @group Code Block
|
|
58
|
+
*/
|
|
59
|
+
export declare function $convertPreElement(element: Element): DOMConversionOutput;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Converts an HTML table element into a {@link TableNode}.
|
|
63
|
+
* This function is used to transform a DOM table element into a format that can be used by Lexical.
|
|
64
|
+
* It extracts the rows and cells from the table, converting them into MDAST-compatible nodes.
|
|
65
|
+
*
|
|
66
|
+
* @param element - The HTML table element to convert.
|
|
67
|
+
* @returns A {@link DOMConversionOutput} containing the converted {@link TableNode}.
|
|
68
|
+
* @group Table
|
|
69
|
+
*/
|
|
70
|
+
export declare function $convertTableElement(element: HTMLElement): DOMConversionOutput;
|
|
71
|
+
|
|
48
72
|
/**
|
|
49
73
|
* Creates a {@link CodeBlockNode}.
|
|
50
74
|
* @param options - The code contents, the language (i.e. js, jsx, etc.), and the additional meta data of the block.
|
|
@@ -139,6 +163,12 @@ export declare const activePlugins$: NodeRef<string[]>;
|
|
|
139
163
|
*/
|
|
140
164
|
export declare const addActivePlugin$: NodeRef<string | string[]>;
|
|
141
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Lets you add React components below the editor.
|
|
168
|
+
* @group Core
|
|
169
|
+
*/
|
|
170
|
+
export declare const addBottomAreaChild$: NodeRef<default_2.ComponentType<{}> | default_2.ComponentType<{}>[]>;
|
|
171
|
+
|
|
142
172
|
/**
|
|
143
173
|
* Lets you add React components to the {@link https://lexical.dev/docs/react/plugins | Lexical Composer} element.
|
|
144
174
|
* @group Core
|
|
@@ -302,6 +332,8 @@ export declare interface BoldItalicUnderlineTogglesProps {
|
|
|
302
332
|
options?: ('Bold' | 'Italic' | 'Underline')[];
|
|
303
333
|
}
|
|
304
334
|
|
|
335
|
+
/* Excluded from this release type: bottomAreaChildren$ */
|
|
336
|
+
|
|
305
337
|
/**
|
|
306
338
|
* A toolbar button primitive.
|
|
307
339
|
* @group Toolbar Primitives
|
|
@@ -501,6 +533,7 @@ export declare class CodeBlockNode extends DecoratorNode<JSX.Element> {
|
|
|
501
533
|
static getType(): string;
|
|
502
534
|
static clone(node: CodeBlockNode): CodeBlockNode;
|
|
503
535
|
static importJSON(serializedNode: SerializedCodeBlockNode): CodeBlockNode;
|
|
536
|
+
static importDOM(): DOMConversionMap;
|
|
504
537
|
constructor(code: string, language: string, meta: string, key?: NodeKey);
|
|
505
538
|
exportJSON(): SerializedCodeBlockNode;
|
|
506
539
|
createDOM(_config: EditorConfig): HTMLDivElement;
|
|
@@ -2708,6 +2741,7 @@ export declare class TableNode extends DecoratorNode<JSX.Element> {
|
|
|
2708
2741
|
/* Excluded from this release type: getType */
|
|
2709
2742
|
/* Excluded from this release type: clone */
|
|
2710
2743
|
/* Excluded from this release type: importJSON */
|
|
2744
|
+
/* Excluded from this release type: importDOM */
|
|
2711
2745
|
/* Excluded from this release type: exportJSON */
|
|
2712
2746
|
/**
|
|
2713
2747
|
* Returns the mdast node that this node is constructed from.
|
|
@@ -2791,8 +2825,18 @@ export declare const toolbarContents$: NodeRef<() => default_2.ReactNode>;
|
|
|
2791
2825
|
* @group Toolbar
|
|
2792
2826
|
*/
|
|
2793
2827
|
export declare const toolbarPlugin: (params?: {
|
|
2828
|
+
/**
|
|
2829
|
+
* Contents of the toolbar
|
|
2830
|
+
*/
|
|
2794
2831
|
toolbarContents: () => default_2.ReactNode;
|
|
2832
|
+
/**
|
|
2833
|
+
* The class name to apply to the toolbar element
|
|
2834
|
+
*/
|
|
2795
2835
|
toolbarClassName?: string | undefined;
|
|
2836
|
+
/**
|
|
2837
|
+
* Controls the position of the toolbar (top by default)
|
|
2838
|
+
*/
|
|
2839
|
+
toolbarPosition?: "top" | "bottom" | undefined;
|
|
2796
2840
|
} | undefined) => RealmPlugin;
|
|
2797
2841
|
|
|
2798
2842
|
/* Excluded from this release type: ToolbarToggleItem */
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { MDXEditor } from "./MDXEditor.js";
|
|
|
4
4
|
import { defaultSvgIcons } from "./defaultSvgIcons.js";
|
|
5
5
|
import { MarkdownParseError, UnrecognizedMarkdownConstructError, importMarkdownToLexical, importMdastTreeToLexical } from "./importMarkdownToLexical.js";
|
|
6
6
|
import { exportLexicalTreeToMdast, exportMarkdownFromLexical } from "./exportMarkdownFromLexical.js";
|
|
7
|
-
import { Appender, NESTED_EDITOR_UPDATED_COMMAND, activeEditor$, activeEditorSubscriptions$, activePlugins$, addActivePlugin$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, contentEditableRef$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, initialMarkdownNormalize$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, lexicalTheme$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, spellCheck$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, translation$, useTranslation, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
|
|
7
|
+
import { Appender, NESTED_EDITOR_UPDATED_COMMAND, activeEditor$, activeEditorSubscriptions$, activePlugins$, addActivePlugin$, addBottomAreaChild$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, bottomAreaChildren$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, contentEditableRef$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, initialMarkdownNormalize$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, lexicalTheme$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, spellCheck$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, translation$, useTranslation, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
|
|
8
8
|
import { ALL_HEADING_LEVELS, allowedHeadingLevels$, headingsPlugin } from "./plugins/headings/index.js";
|
|
9
9
|
import { insertThematicBreak$, thematicBreakPlugin } from "./plugins/thematic-break/index.js";
|
|
10
10
|
import { applyListType$, currentListType$, listsPlugin } from "./plugins/lists/index.js";
|
|
@@ -63,12 +63,14 @@ import { DEFAULT_FORMAT, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHR
|
|
|
63
63
|
import { lexicalTheme } from "./styles/lexicalTheme.js";
|
|
64
64
|
import { htmlTags, isMdastHTMLNode } from "./plugins/core/MdastHTMLNode.js";
|
|
65
65
|
import { $createGenericHTMLNode, $isGenericHTMLNode, GenericHTMLNode, TYPE_NAME } from "./plugins/core/GenericHTMLNode.js";
|
|
66
|
-
import { $createTableNode, $isTableNode, TableNode } from "./plugins/table/TableNode.js";
|
|
66
|
+
import { $convertTableElement, $createTableNode, $isTableNode, TableNode } from "./plugins/table/TableNode.js";
|
|
67
67
|
import { $createImageNode, $isImageNode, ImageNode } from "./plugins/image/ImageNode.js";
|
|
68
68
|
import { $createFrontmatterNode, $isFrontmatterNode, FrontmatterNode } from "./plugins/frontmatter/FrontmatterNode.js";
|
|
69
|
-
import { $createCodeBlockNode, $isCodeBlockNode, CodeBlockNode, useCodeBlockEditorContext } from "./plugins/codeblock/CodeBlockNode.js";
|
|
69
|
+
import { $convertPreElement, $createCodeBlockNode, $isCodeBlockNode, CodeBlockNode, useCodeBlockEditorContext } from "./plugins/codeblock/CodeBlockNode.js";
|
|
70
70
|
import { $createDirectiveNode, $isDirectiveNode, DirectiveNode } from "./plugins/directives/DirectiveNode.js";
|
|
71
71
|
export {
|
|
72
|
+
$convertPreElement,
|
|
73
|
+
$convertTableElement,
|
|
72
74
|
$createCodeBlockNode,
|
|
73
75
|
$createDirectiveNode,
|
|
74
76
|
$createFrontmatterNode,
|
|
@@ -157,6 +159,7 @@ export {
|
|
|
157
159
|
activeEditorSubscriptions$,
|
|
158
160
|
activePlugins$,
|
|
159
161
|
addActivePlugin$,
|
|
162
|
+
addBottomAreaChild$,
|
|
160
163
|
addComposerChild$,
|
|
161
164
|
addEditorWrapper$,
|
|
162
165
|
addExportVisitor$,
|
|
@@ -176,6 +179,7 @@ export {
|
|
|
176
179
|
applyLinkChanges$,
|
|
177
180
|
applyListType$,
|
|
178
181
|
autoFocus$,
|
|
182
|
+
bottomAreaChildren$,
|
|
179
183
|
call,
|
|
180
184
|
cancelLinkEdit$,
|
|
181
185
|
closeImageDialog$,
|
|
@@ -53,6 +53,16 @@ class CodeBlockNode extends DecoratorNode {
|
|
|
53
53
|
meta
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
+
static importDOM() {
|
|
57
|
+
return {
|
|
58
|
+
pre: () => {
|
|
59
|
+
return {
|
|
60
|
+
conversion: $convertPreElement,
|
|
61
|
+
priority: 3
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
56
66
|
exportJSON() {
|
|
57
67
|
return {
|
|
58
68
|
code: this.getCode(),
|
|
@@ -152,7 +162,20 @@ function $createCodeBlockNode(options) {
|
|
|
152
162
|
function $isCodeBlockNode(node) {
|
|
153
163
|
return node instanceof CodeBlockNode;
|
|
154
164
|
}
|
|
165
|
+
function $convertPreElement(element) {
|
|
166
|
+
const preElement = element;
|
|
167
|
+
const code = preElement.textContent ?? "";
|
|
168
|
+
const classAttribute = element.getAttribute("class") ?? "";
|
|
169
|
+
const dataLanguageAttribute = element.getAttribute("data-language") ?? "";
|
|
170
|
+
const languageMatch = classAttribute.match(/language-(\w+)/);
|
|
171
|
+
const language = languageMatch ? languageMatch[1] : dataLanguageAttribute;
|
|
172
|
+
const meta = preElement.getAttribute("data-meta") ?? "";
|
|
173
|
+
return {
|
|
174
|
+
node: $createCodeBlockNode({ code, language, meta })
|
|
175
|
+
};
|
|
176
|
+
}
|
|
155
177
|
export {
|
|
178
|
+
$convertPreElement,
|
|
156
179
|
$createCodeBlockNode,
|
|
157
180
|
$isCodeBlockNode,
|
|
158
181
|
CodeBlockNode,
|
|
@@ -2,7 +2,7 @@ import { CodeBlockVisitor } from "./CodeBlockVisitor.js";
|
|
|
2
2
|
import { MdastCodeVisitor } from "./MdastCodeVisitor.js";
|
|
3
3
|
import { insertDecoratorNode$, Appender, codeBlockEditorDescriptors$, addActivePlugin$, addImportVisitor$, addLexicalNode$, addExportVisitor$ } from "../core/index.js";
|
|
4
4
|
import { $createCodeBlockNode, CodeBlockNode } from "./CodeBlockNode.js";
|
|
5
|
-
import { $isCodeBlockNode, useCodeBlockEditorContext } from "./CodeBlockNode.js";
|
|
5
|
+
import { $convertPreElement, $isCodeBlockNode, useCodeBlockEditorContext } from "./CodeBlockNode.js";
|
|
6
6
|
import { Cell, Signal, withLatestFrom, map } from "@mdxeditor/gurx";
|
|
7
7
|
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
8
8
|
const defaultCodeBlockLanguage$ = Cell("");
|
|
@@ -34,6 +34,7 @@ const codeBlockPlugin = realmPlugin({
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
export {
|
|
37
|
+
$convertPreElement,
|
|
37
38
|
$createCodeBlockNode,
|
|
38
39
|
$isCodeBlockNode,
|
|
39
40
|
CodeBlockNode,
|
|
@@ -391,6 +391,8 @@ const composerChildren$ = Cell([]);
|
|
|
391
391
|
const addComposerChild$ = Appender(composerChildren$);
|
|
392
392
|
const topAreaChildren$ = Cell([]);
|
|
393
393
|
const addTopAreaChild$ = Appender(topAreaChildren$);
|
|
394
|
+
const bottomAreaChildren$ = Cell([]);
|
|
395
|
+
const addBottomAreaChild$ = Appender(bottomAreaChildren$);
|
|
394
396
|
const editorWrappers$ = Cell([]);
|
|
395
397
|
const addEditorWrapper$ = Appender(editorWrappers$);
|
|
396
398
|
const nestedEditorChildren$ = Cell([]);
|
|
@@ -588,6 +590,7 @@ export {
|
|
|
588
590
|
activeEditorSubscriptions$,
|
|
589
591
|
activePlugins$,
|
|
590
592
|
addActivePlugin$,
|
|
593
|
+
addBottomAreaChild$,
|
|
591
594
|
addComposerChild$,
|
|
592
595
|
addEditorWrapper$,
|
|
593
596
|
addExportVisitor$,
|
|
@@ -601,6 +604,7 @@ export {
|
|
|
601
604
|
applyBlockType$,
|
|
602
605
|
applyFormat$,
|
|
603
606
|
autoFocus$,
|
|
607
|
+
bottomAreaChildren$,
|
|
604
608
|
codeBlockEditorDescriptors$,
|
|
605
609
|
composerChildren$,
|
|
606
610
|
contentEditableClassName$,
|
|
@@ -46,6 +46,17 @@ class TableNode extends DecoratorNode {
|
|
|
46
46
|
return $createTableNode(serializedNode.mdastNode);
|
|
47
47
|
}
|
|
48
48
|
/** @internal */
|
|
49
|
+
static importDOM() {
|
|
50
|
+
return {
|
|
51
|
+
table: () => {
|
|
52
|
+
return {
|
|
53
|
+
conversion: $convertTableElement,
|
|
54
|
+
priority: 3
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** @internal */
|
|
49
60
|
exportJSON() {
|
|
50
61
|
return {
|
|
51
62
|
mdastNode: structuredClone(this.__mdastNode),
|
|
@@ -173,7 +184,33 @@ function $isTableNode(node) {
|
|
|
173
184
|
function $createTableNode(mdastNode) {
|
|
174
185
|
return new TableNode(mdastNode);
|
|
175
186
|
}
|
|
187
|
+
function $convertTableElement(element) {
|
|
188
|
+
const rows = element.querySelectorAll("tr");
|
|
189
|
+
const children = Array.from(rows).map((row) => {
|
|
190
|
+
return {
|
|
191
|
+
type: "tableRow",
|
|
192
|
+
children: Array.from(row.querySelectorAll("td, th")).map((cell) => {
|
|
193
|
+
return {
|
|
194
|
+
type: "tableCell",
|
|
195
|
+
children: [
|
|
196
|
+
{
|
|
197
|
+
type: "text",
|
|
198
|
+
value: cell.textContent ?? ""
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
};
|
|
202
|
+
})
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
node: new TableNode({
|
|
207
|
+
type: "table",
|
|
208
|
+
children
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
}
|
|
176
212
|
export {
|
|
213
|
+
$convertTableElement,
|
|
177
214
|
$createTableNode,
|
|
178
215
|
$isTableNode,
|
|
179
216
|
TableNode
|
|
@@ -6,7 +6,7 @@ import { insertDecoratorNode$, addMdastExtension$, addSyntaxExtension$, addImpor
|
|
|
6
6
|
import { LexicalTableVisitor } from "./LexicalTableVisitor.js";
|
|
7
7
|
import { MdastTableVisitor } from "./MdastTableVisitor.js";
|
|
8
8
|
import { $createTableNode, TableNode } from "./TableNode.js";
|
|
9
|
-
import { $isTableNode } from "./TableNode.js";
|
|
9
|
+
import { $convertTableElement, $isTableNode } from "./TableNode.js";
|
|
10
10
|
function seedTable(rows = 1, columns = 1) {
|
|
11
11
|
const table = {
|
|
12
12
|
type: "table",
|
|
@@ -57,6 +57,7 @@ const tablePlugin = realmPlugin({
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
export {
|
|
60
|
+
$convertTableElement,
|
|
60
61
|
$createTableNode,
|
|
61
62
|
$isTableNode,
|
|
62
63
|
TableNode,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
2
2
|
import { Cell, useCellValues } from "@mdxeditor/gurx";
|
|
3
3
|
import React__default from "react";
|
|
4
|
-
import { addTopAreaChild$, readOnly$ } from "../core/index.js";
|
|
4
|
+
import { addBottomAreaChild$, addTopAreaChild$, readOnly$ } from "../core/index.js";
|
|
5
5
|
import { Root } from "./primitives/toolbar.js";
|
|
6
6
|
const toolbarContents$ = Cell(() => null);
|
|
7
7
|
const toolbarClassName$ = Cell("");
|
|
@@ -10,10 +10,11 @@ const DEFAULT_TOOLBAR_CONTENTS = () => {
|
|
|
10
10
|
};
|
|
11
11
|
const toolbarPlugin = realmPlugin({
|
|
12
12
|
init(realm, params) {
|
|
13
|
+
const toolbarPositionSymbol = (params == null ? void 0 : params.toolbarPosition) === "bottom" ? addBottomAreaChild$ : addTopAreaChild$;
|
|
13
14
|
realm.pubIn({
|
|
14
15
|
[toolbarContents$]: (params == null ? void 0 : params.toolbarContents) ?? DEFAULT_TOOLBAR_CONTENTS,
|
|
15
16
|
[toolbarClassName$]: (params == null ? void 0 : params.toolbarClassName) ?? "",
|
|
16
|
-
[
|
|
17
|
+
[toolbarPositionSymbol]: () => {
|
|
17
18
|
const [toolbarContents, readOnly, toolbarClassName] = useCellValues(toolbarContents$, readOnly$, toolbarClassName$);
|
|
18
19
|
return /* @__PURE__ */ React__default.createElement(Root, { className: toolbarClassName, readOnly }, toolbarContents());
|
|
19
20
|
}
|