@mdxeditor/editor 3.52.3 → 3.52.5
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/index.d.ts +21 -1
- package/dist/index.js +4 -1
- package/dist/plugins/core/index.js +18 -1
- package/dist/plugins/image/ImageNode.js +5 -5
- package/dist/plugins/image/MdastImageVisitor.js +2 -2
- package/dist/plugins/link/index.js +2 -1
- package/dist/plugins/lists/index.js +1 -0
- package/dist/plugins/markdown-shortcut/index.js +6 -3
- package/dist/plugins/table/TableEditor.js +4 -4
- package/dist/plugins/toolbar/components/InsertTable.js +3 -15
- package/dist/plugins/toolbar/components/ListsToggle.js +3 -3
- package/dist/plugins/toolbar/primitives/toolbar.js +3 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -229,6 +229,12 @@ export declare const addNestedEditorChild$: NodeRef<default_2.ComponentType<{}>
|
|
|
229
229
|
*/
|
|
230
230
|
export declare const addSyntaxExtension$: NodeRef< Extension | Extension[]>;
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Lets you add React components as children of table cell editors.
|
|
234
|
+
* @group Core
|
|
235
|
+
*/
|
|
236
|
+
export declare const addTableCellEditorChild$: NodeRef<default_2.ComponentType<{}> | default_2.ComponentType<{}>[]>;
|
|
237
|
+
|
|
232
238
|
/**
|
|
233
239
|
* Adds a markdown to string extension to be used when exporting markdown from the Lexical tree.
|
|
234
240
|
* @group Markdown Processing
|
|
@@ -1147,6 +1153,12 @@ export declare interface EditorInFocus {
|
|
|
1147
1153
|
editorRef: unknown;
|
|
1148
1154
|
}
|
|
1149
1155
|
|
|
1156
|
+
/**
|
|
1157
|
+
* Whether the currently active editor is inside a table cell.
|
|
1158
|
+
* @group Core
|
|
1159
|
+
*/
|
|
1160
|
+
export declare const editorInTable$: NodeRef<boolean>;
|
|
1161
|
+
|
|
1150
1162
|
/**
|
|
1151
1163
|
* A reference to a DOM element. used for the various popups, dialogs, and tooltips
|
|
1152
1164
|
* @group Core
|
|
@@ -2883,7 +2895,7 @@ export declare const ShowSandpackInfo: () => JSX_2.Element | null;
|
|
|
2883
2895
|
* A toolbar primitive that allows you to build an UI with multiple exclusive toggle groups, like the list type toggle.
|
|
2884
2896
|
* @group Toolbar Primitives
|
|
2885
2897
|
*/
|
|
2886
|
-
export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChange, className, ggClassName, items }: {
|
|
2898
|
+
export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChange, className, ggClassName, items, disabled }: {
|
|
2887
2899
|
items: {
|
|
2888
2900
|
title: string;
|
|
2889
2901
|
value: T;
|
|
@@ -2893,6 +2905,7 @@ export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChan
|
|
|
2893
2905
|
value: T | "";
|
|
2894
2906
|
ggClassName?: string;
|
|
2895
2907
|
className?: string;
|
|
2908
|
+
disabled?: boolean;
|
|
2896
2909
|
}) => JSX_2.Element;
|
|
2897
2910
|
|
|
2898
2911
|
/* Excluded from this release type: SingleToggleGroup */
|
|
@@ -2930,6 +2943,13 @@ export declare const switchFromPreviewToLinkEdit$: NodeRef<void>;
|
|
|
2930
2943
|
|
|
2931
2944
|
export declare const syntaxExtensions$: NodeRef< Extension[]>;
|
|
2932
2945
|
|
|
2946
|
+
/**
|
|
2947
|
+
* React Components registered to be rendered inside table cell editors. Use this instead of {@link addNestedEditorChild$} for components that should only appear in table cells.
|
|
2948
|
+
* Plugins that should not be active in table cells (e.g. lists) should not register here.
|
|
2949
|
+
* @group Core
|
|
2950
|
+
*/
|
|
2951
|
+
export declare const tableCellEditorChildren$: NodeRef<default_2.ComponentType<{}>[]>;
|
|
2952
|
+
|
|
2933
2953
|
/**
|
|
2934
2954
|
* A Lexical node that represents a markdown table.
|
|
2935
2955
|
* Use {@link "$createTableNode"} to construct one.
|
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$, addBottomAreaChild$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, bottomAreaChildren$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, contentEditableRef$, contentEditableWrapperElement$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrapperElementRef$, 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$, addTableCellEditorChild$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, bottomAreaChildren$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, contentEditableRef$, contentEditableWrapperElement$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorInTable$, editorRootElementRef$, editorWrapperElementRef$, 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$, tableCellEditorChildren$, 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";
|
|
@@ -179,6 +179,7 @@ export {
|
|
|
179
179
|
addMdastExtension$,
|
|
180
180
|
addNestedEditorChild$,
|
|
181
181
|
addSyntaxExtension$,
|
|
182
|
+
addTableCellEditorChild$,
|
|
182
183
|
addToMarkdownExtension$,
|
|
183
184
|
addTopAreaChild$,
|
|
184
185
|
admonitionLabelsMap,
|
|
@@ -230,6 +231,7 @@ export {
|
|
|
230
231
|
disableImageSettingsButton$,
|
|
231
232
|
editImageToolbarComponent$,
|
|
232
233
|
editorInFocus$,
|
|
234
|
+
editorInTable$,
|
|
233
235
|
editorRootElementRef$,
|
|
234
236
|
editorSearchCursor$,
|
|
235
237
|
editorSearchRanges$,
|
|
@@ -333,6 +335,7 @@ export {
|
|
|
333
335
|
spellCheck$,
|
|
334
336
|
switchFromPreviewToLinkEdit$,
|
|
335
337
|
syntaxExtensions$,
|
|
338
|
+
tableCellEditorChildren$,
|
|
336
339
|
tablePlugin,
|
|
337
340
|
tap,
|
|
338
341
|
thematicBreakPlugin,
|
|
@@ -3,7 +3,7 @@ import { createEmptyHistoryState } from "@lexical/react/LexicalHistoryPlugin.js"
|
|
|
3
3
|
import { $isHeadingNode } from "@lexical/rich-text";
|
|
4
4
|
import { $setBlocksType } from "@lexical/selection";
|
|
5
5
|
import { $findMatchingParent, $wrapNodeInElement, $insertNodeToNearestRoot } from "@lexical/utils";
|
|
6
|
-
import { Cell, Signal, withLatestFrom, filter, useCellValue, scan
|
|
6
|
+
import { Cell, Signal, withLatestFrom, filter, map, useCellValue, scan } from "@mdxeditor/gurx";
|
|
7
7
|
import { createCommand, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getRoot, $setSelection, $getSelection, $insertNodes, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, DecoratorNode, $createParagraphNode, FOCUS_COMMAND, BLUR_COMMAND, $isRangeSelection, createEditor, ParagraphNode, TextNode } from "lexical";
|
|
8
8
|
import { gfmStrikethrough } from "micromark-extension-gfm-strikethrough";
|
|
9
9
|
import { gfmStrikethroughToMarkdown, gfmStrikethroughFromMarkdown } from "mdast-util-gfm-strikethrough";
|
|
@@ -402,6 +402,20 @@ const editorWrappers$ = Cell([]);
|
|
|
402
402
|
const addEditorWrapper$ = Appender(editorWrappers$);
|
|
403
403
|
const nestedEditorChildren$ = Cell([]);
|
|
404
404
|
const addNestedEditorChild$ = Appender(nestedEditorChildren$);
|
|
405
|
+
const tableCellEditorChildren$ = Cell([]);
|
|
406
|
+
const addTableCellEditorChild$ = Appender(tableCellEditorChildren$);
|
|
407
|
+
const editorInTable$ = Cell(false, (r) => {
|
|
408
|
+
r.link(
|
|
409
|
+
r.pipe(
|
|
410
|
+
activeEditor$,
|
|
411
|
+
map((editor) => {
|
|
412
|
+
var _a, _b;
|
|
413
|
+
return ["td", "th"].includes(((_b = (_a = editor == null ? void 0 : editor.getRootElement()) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.nodeName.toLowerCase()) ?? "");
|
|
414
|
+
})
|
|
415
|
+
),
|
|
416
|
+
editorInTable$
|
|
417
|
+
);
|
|
418
|
+
});
|
|
405
419
|
const historyState$ = Cell(createEmptyHistoryState());
|
|
406
420
|
const currentBlockType$ = Cell("");
|
|
407
421
|
const applyBlockType$ = Signal();
|
|
@@ -614,6 +628,7 @@ export {
|
|
|
614
628
|
addMdastExtension$,
|
|
615
629
|
addNestedEditorChild$,
|
|
616
630
|
addSyntaxExtension$,
|
|
631
|
+
addTableCellEditorChild$,
|
|
617
632
|
addToMarkdownExtension$,
|
|
618
633
|
addTopAreaChild$,
|
|
619
634
|
applyBlockType$,
|
|
@@ -634,6 +649,7 @@ export {
|
|
|
634
649
|
currentSelection$,
|
|
635
650
|
directiveDescriptors$,
|
|
636
651
|
editorInFocus$,
|
|
652
|
+
editorInTable$,
|
|
637
653
|
editorRootElementRef$,
|
|
638
654
|
editorWrapperElementRef$,
|
|
639
655
|
editorWrappers$,
|
|
@@ -664,6 +680,7 @@ export {
|
|
|
664
680
|
setMarkdown$,
|
|
665
681
|
spellCheck$,
|
|
666
682
|
syntaxExtensions$,
|
|
683
|
+
tableCellEditorChildren$,
|
|
667
684
|
toMarkdownExtensions$,
|
|
668
685
|
toMarkdownOptions$,
|
|
669
686
|
topAreaChildren$,
|
|
@@ -10,7 +10,7 @@ import { ImageEditor } from "./ImageEditor.js";
|
|
|
10
10
|
function convertImageElement(domNode) {
|
|
11
11
|
if (domNode instanceof HTMLImageElement) {
|
|
12
12
|
const { alt: altText, src, title, width, height } = domNode;
|
|
13
|
-
const node = $createImageNode({ altText, src, title, width, height });
|
|
13
|
+
const node = $createImageNode({ altText, src, title, width: width || void 0, height: height || void 0 });
|
|
14
14
|
return { node };
|
|
15
15
|
}
|
|
16
16
|
return null;
|
|
@@ -80,10 +80,10 @@ class ImageNode extends DecoratorNode {
|
|
|
80
80
|
if (this.__title) {
|
|
81
81
|
element.setAttribute("title", this.__title);
|
|
82
82
|
}
|
|
83
|
-
if (this.__width) {
|
|
83
|
+
if (this.__width !== "inherit" && this.__width) {
|
|
84
84
|
element.setAttribute("width", this.__width.toString());
|
|
85
85
|
}
|
|
86
|
-
if (this.__height) {
|
|
86
|
+
if (this.__height !== "inherit" && this.__height) {
|
|
87
87
|
element.setAttribute("height", this.__height.toString());
|
|
88
88
|
}
|
|
89
89
|
return { element };
|
|
@@ -102,8 +102,8 @@ class ImageNode extends DecoratorNode {
|
|
|
102
102
|
return {
|
|
103
103
|
altText: this.getAltText(),
|
|
104
104
|
title: this.getTitle(),
|
|
105
|
-
height: this.__height === "inherit" ? 0 : this.__height,
|
|
106
|
-
width: this.__width === "inherit" ? 0 : this.__width,
|
|
105
|
+
height: this.__height === "inherit" ? void 0 : this.__height,
|
|
106
|
+
width: this.__width === "inherit" ? void 0 : this.__width,
|
|
107
107
|
src: this.getSrc(),
|
|
108
108
|
rest: this.__rest,
|
|
109
109
|
type: "image",
|
|
@@ -6,7 +6,7 @@ import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
|
6
6
|
import { LexicalAutoLinkPlugin } from "./AutoLinkPlugin.js";
|
|
7
7
|
import { Cell } from "@mdxeditor/gurx";
|
|
8
8
|
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
9
|
-
import { addComposerChild$, addNestedEditorChild$, addExportVisitor$, addLexicalNode$, addImportVisitor$, addActivePlugin$ } from "../core/index.js";
|
|
9
|
+
import { addComposerChild$, addTableCellEditorChild$, addNestedEditorChild$, addExportVisitor$, addLexicalNode$, addImportVisitor$, addActivePlugin$ } from "../core/index.js";
|
|
10
10
|
const disableAutoLink$ = Cell(false);
|
|
11
11
|
const linkPlugin = realmPlugin({
|
|
12
12
|
init(realm, params) {
|
|
@@ -20,6 +20,7 @@ const linkPlugin = realmPlugin({
|
|
|
20
20
|
[addExportVisitor$]: LexicalLinkVisitor,
|
|
21
21
|
[disableAutoLink$]: disableAutoLink,
|
|
22
22
|
[addNestedEditorChild$]: EditorChild,
|
|
23
|
+
[addTableCellEditorChild$]: EditorChild,
|
|
23
24
|
[addComposerChild$]: EditorChild
|
|
24
25
|
});
|
|
25
26
|
}
|
|
@@ -62,6 +62,7 @@ const listsPlugin = realmPlugin({
|
|
|
62
62
|
[addToMarkdownExtension$]: gfmTaskListItemToMarkdown(),
|
|
63
63
|
[addComposerChild$]: [TabIndentationPlugin, ListPlugin, CheckListPlugin],
|
|
64
64
|
[addNestedEditorChild$]: [TabIndentationPlugin, ListPlugin, CheckListPlugin]
|
|
65
|
+
// Note: intentionally not registered to addTableCellEditorChild$ — lists are not supported in table cells
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import React__default from "react";
|
|
1
2
|
import { BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, QUOTE, LINK, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST, CODE } from "@lexical/markdown";
|
|
2
3
|
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
3
4
|
import { HeadingNode, $isHeadingNode, $createHeadingNode } from "@lexical/rich-text";
|
|
4
|
-
import React__default from "react";
|
|
5
5
|
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
6
6
|
import { CodeBlockNode, $createCodeBlockNode } from "../codeblock/CodeBlockNode.js";
|
|
7
|
-
import { activePlugins$, addNestedEditorChild$, addComposerChild$ } from "../core/index.js";
|
|
7
|
+
import { activePlugins$, addTableCellEditorChild$, addNestedEditorChild$, addComposerChild$ } from "../core/index.js";
|
|
8
8
|
import { allowedHeadingLevels$ } from "../headings/index.js";
|
|
9
9
|
import { HorizontalRuleNode, $createHorizontalRuleNode, $isHorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
10
10
|
const markdownShortcutPlugin = realmPlugin({
|
|
@@ -12,9 +12,11 @@ const markdownShortcutPlugin = realmPlugin({
|
|
|
12
12
|
const pluginIds = realm.getValue(activePlugins$);
|
|
13
13
|
const allowedHeadingLevels = pluginIds.includes("headings") ? realm.getValue(allowedHeadingLevels$) : [];
|
|
14
14
|
const transformers = pickTransformersForActivePlugins(pluginIds, allowedHeadingLevels);
|
|
15
|
+
const tableCellTransformers = transformers.filter((t) => !LIST_TRANSFORMERS.has(t));
|
|
15
16
|
realm.pubIn({
|
|
16
17
|
[addComposerChild$]: () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers }),
|
|
17
|
-
[addNestedEditorChild$]: () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers })
|
|
18
|
+
[addNestedEditorChild$]: () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers }),
|
|
19
|
+
[addTableCellEditorChild$]: () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers: tableCellTransformers })
|
|
18
20
|
});
|
|
19
21
|
}
|
|
20
22
|
});
|
|
@@ -43,6 +45,7 @@ const THEMATIC_BREAK = {
|
|
|
43
45
|
},
|
|
44
46
|
type: "element"
|
|
45
47
|
};
|
|
48
|
+
const LIST_TRANSFORMERS = /* @__PURE__ */ new Set([ORDERED_LIST, UNORDERED_LIST, CHECK_LIST]);
|
|
46
49
|
function pickTransformersForActivePlugins(pluginIds, allowedHeadingLevels) {
|
|
47
50
|
const transformers = [
|
|
48
51
|
BOLD_ITALIC_STAR,
|
|
@@ -15,7 +15,7 @@ import classNames from "classnames";
|
|
|
15
15
|
import styles from "../../styles/ui.module.css.js";
|
|
16
16
|
import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
|
|
17
17
|
import { uuidv4 } from "../../utils/uuid4.js";
|
|
18
|
-
import { iconComponentFor$, readOnly$, useTranslation, editorRootElementRef$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, jsxIsAvailable$, rootEditor$,
|
|
18
|
+
import { iconComponentFor$, readOnly$, useTranslation, editorRootElementRef$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, jsxIsAvailable$, rootEditor$, tableCellEditorChildren$, NESTED_EDITOR_UPDATED_COMMAND } from "../core/index.js";
|
|
19
19
|
import { useCellValues } from "@mdxeditor/gurx";
|
|
20
20
|
const getCellType = (rowIndex) => {
|
|
21
21
|
if (rowIndex === 0) {
|
|
@@ -217,7 +217,7 @@ const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents
|
|
|
217
217
|
codeBlockEditorDescriptors,
|
|
218
218
|
jsxIsAvailable,
|
|
219
219
|
rootEditor,
|
|
220
|
-
|
|
220
|
+
tableCellEditorChildren
|
|
221
221
|
] = useCellValues(
|
|
222
222
|
importVisitors$,
|
|
223
223
|
exportVisitors$,
|
|
@@ -227,7 +227,7 @@ const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents
|
|
|
227
227
|
codeBlockEditorDescriptors$,
|
|
228
228
|
jsxIsAvailable$,
|
|
229
229
|
rootEditor$,
|
|
230
|
-
|
|
230
|
+
tableCellEditorChildren$
|
|
231
231
|
);
|
|
232
232
|
const [editor] = React__default.useState(() => {
|
|
233
233
|
const editor2 = createEditor({
|
|
@@ -325,7 +325,7 @@ const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents
|
|
|
325
325
|
editor.focus();
|
|
326
326
|
}
|
|
327
327
|
}, [focus, editor]);
|
|
328
|
-
return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(RichTextPlugin, { contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, null), placeholder: /* @__PURE__ */ React__default.createElement("div", null), ErrorBoundary: LexicalErrorBoundary }),
|
|
328
|
+
return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(RichTextPlugin, { contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, null), placeholder: /* @__PURE__ */ React__default.createElement("div", null), ErrorBoundary: LexicalErrorBoundary }), tableCellEditorChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })), /* @__PURE__ */ React__default.createElement(HistoryPlugin, null));
|
|
329
329
|
};
|
|
330
330
|
const ColumnEditor = ({
|
|
331
331
|
parentEditor,
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
import { ButtonWithTooltip } from "../primitives/toolbar.js";
|
|
2
2
|
import React__default from "react";
|
|
3
3
|
import { insertTable$ } from "../../table/index.js";
|
|
4
|
-
import { useCellValue, usePublisher
|
|
5
|
-
import { iconComponentFor$, useTranslation,
|
|
6
|
-
const disableInsertTableButton$ = Cell(false, (r) => {
|
|
7
|
-
r.link(
|
|
8
|
-
r.pipe(
|
|
9
|
-
activeEditor$,
|
|
10
|
-
map((editor) => {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
return ["td", "th"].includes(((_b = (_a = editor == null ? void 0 : editor.getRootElement()) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.nodeName.toLowerCase()) ?? "");
|
|
13
|
-
})
|
|
14
|
-
),
|
|
15
|
-
disableInsertTableButton$
|
|
16
|
-
);
|
|
17
|
-
});
|
|
4
|
+
import { useCellValue, usePublisher } from "@mdxeditor/gurx";
|
|
5
|
+
import { iconComponentFor$, useTranslation, editorInTable$ } from "../../core/index.js";
|
|
18
6
|
const InsertTable = () => {
|
|
19
7
|
const iconComponentFor = useCellValue(iconComponentFor$);
|
|
20
8
|
const insertTable = usePublisher(insertTable$);
|
|
21
9
|
const t = useTranslation();
|
|
22
|
-
const isDisabled = useCellValue(
|
|
10
|
+
const isDisabled = useCellValue(editorInTable$);
|
|
23
11
|
return /* @__PURE__ */ React__default.createElement(
|
|
24
12
|
ButtonWithTooltip,
|
|
25
13
|
{
|
|
@@ -2,14 +2,14 @@ import React__default from "react";
|
|
|
2
2
|
import { currentListType$, applyListType$ } from "../../lists/index.js";
|
|
3
3
|
import { SingleChoiceToggleGroup } from "../primitives/toolbar.js";
|
|
4
4
|
import { useCellValues, usePublisher } from "@mdxeditor/gurx";
|
|
5
|
-
import { iconComponentFor$, useTranslation } from "../../core/index.js";
|
|
5
|
+
import { iconComponentFor$, editorInTable$, useTranslation } from "../../core/index.js";
|
|
6
6
|
const ICON_NAME_MAP = {
|
|
7
7
|
bullet: "format_list_bulleted",
|
|
8
8
|
number: "format_list_numbered",
|
|
9
9
|
check: "format_list_checked"
|
|
10
10
|
};
|
|
11
11
|
const ListsToggle = ({ options = ["bullet", "number", "check"] }) => {
|
|
12
|
-
const [currentListType, iconComponentFor] = useCellValues(currentListType$, iconComponentFor$);
|
|
12
|
+
const [currentListType, iconComponentFor, inTable] = useCellValues(currentListType$, iconComponentFor$, editorInTable$);
|
|
13
13
|
const applyListType = usePublisher(applyListType$);
|
|
14
14
|
const t = useTranslation();
|
|
15
15
|
const LIST_TITLE_MAP = {
|
|
@@ -22,7 +22,7 @@ const ListsToggle = ({ options = ["bullet", "number", "check"] }) => {
|
|
|
22
22
|
title: LIST_TITLE_MAP[type],
|
|
23
23
|
contents: iconComponentFor(ICON_NAME_MAP[type])
|
|
24
24
|
}));
|
|
25
|
-
return /* @__PURE__ */ React__default.createElement(SingleChoiceToggleGroup, { value: currentListType || "", items, onChange: applyListType });
|
|
25
|
+
return /* @__PURE__ */ React__default.createElement(SingleChoiceToggleGroup, { value: currentListType || "", items, onChange: applyListType, disabled: inTable });
|
|
26
26
|
};
|
|
27
27
|
export {
|
|
28
28
|
ListsToggle
|
|
@@ -71,7 +71,8 @@ const SingleChoiceToggleGroup = ({
|
|
|
71
71
|
onChange,
|
|
72
72
|
className,
|
|
73
73
|
ggClassName,
|
|
74
|
-
items
|
|
74
|
+
items,
|
|
75
|
+
disabled
|
|
75
76
|
}) => {
|
|
76
77
|
const t = useTranslation();
|
|
77
78
|
return /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.toolbarGroupOfGroups, ggClassName) }, /* @__PURE__ */ React__default.createElement(
|
|
@@ -82,6 +83,7 @@ const SingleChoiceToggleGroup = ({
|
|
|
82
83
|
className: classNames(styles.toolbarToggleSingleGroup, className),
|
|
83
84
|
onValueChange: onChange,
|
|
84
85
|
value: value || "",
|
|
86
|
+
disabled,
|
|
85
87
|
onFocus: (e) => {
|
|
86
88
|
e.preventDefault();
|
|
87
89
|
}
|