@mdxeditor/editor 3.21.2 → 3.21.4

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.
@@ -76,6 +76,7 @@ function exportLexicalTreeToMdast({
76
76
  },
77
77
  appendToParent,
78
78
  visitChildren,
79
+ visit,
79
80
  registerReferredComponent
80
81
  }
81
82
  });
package/dist/index.d.ts CHANGED
@@ -1254,7 +1254,7 @@ export declare const headingsPlugin: (params?: {
1254
1254
  * All the HTML tags supported by the generic html node.
1255
1255
  * @group HTML
1256
1256
  */
1257
- export declare const htmlTags: readonly ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr"];
1257
+ export declare const htmlTags: string[];
1258
1258
 
1259
1259
  /**
1260
1260
  * A callback that returns the icon component for the given name.
@@ -1782,6 +1782,10 @@ export declare interface LexicalExportVisitor<LN extends LexicalNode, UN extends
1782
1782
  * @see {@link JsxComponentDescriptor}
1783
1783
  */
1784
1784
  registerReferredComponent(componentName: string): void;
1785
+ /**
1786
+ * visits the specified lexical node
1787
+ */
1788
+ visit(node: LexicalNode, parent: Mdast.Parent): void;
1785
1789
  };
1786
1790
  }): void;
1787
1791
  /**
@@ -1,12 +1,13 @@
1
1
  import { $isLexicalJsxNode } from "./LexicalJsxNode.js";
2
2
  import { isMdastJsxNode } from "./index.js";
3
+ import { htmlTags } from "../core/MdastHTMLNode.js";
3
4
  const LexicalJsxVisitor = {
4
5
  testLexicalNode: $isLexicalJsxNode,
5
6
  visitLexicalNode({ actions, mdastParent, lexicalNode }) {
6
7
  function traverseNestedJsxNodes(node) {
7
8
  if ("children" in node && node.children instanceof Array) {
8
9
  node.children.forEach((child) => {
9
- if (isMdastJsxNode(child)) {
10
+ if (isMdastJsxNode(child) && !htmlTags.includes(child.name.toLowerCase())) {
10
11
  actions.registerReferredComponent(child.name);
11
12
  }
12
13
  traverseNestedJsxNodes(child);
@@ -1,4 +1,5 @@
1
1
  import { $isListItemNode, $isListNode } from "@lexical/list";
2
+ import { $isTextNode } from "lexical";
2
3
  const LexicalListItemVisitor = {
3
4
  testLexicalNode: $isListItemNode,
4
5
  visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
@@ -19,7 +20,21 @@ const LexicalListItemVisitor = {
19
20
  spread: false,
20
21
  children: []
21
22
  });
22
- actions.visitChildren(lexicalNode, listItem);
23
+ let surroundingParagraph = null;
24
+ for (const child of lexicalNode.getChildren()) {
25
+ if ($isTextNode(child)) {
26
+ if (!surroundingParagraph) {
27
+ surroundingParagraph = actions.appendToParent(listItem, {
28
+ type: "paragraph",
29
+ children: []
30
+ });
31
+ }
32
+ actions.visit(child, surroundingParagraph);
33
+ } else {
34
+ surroundingParagraph = null;
35
+ actions.visit(child, listItem);
36
+ }
37
+ }
23
38
  }
24
39
  }
25
40
  };
@@ -1,19 +1,33 @@
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 } from "@mdxeditor/gurx";
5
- import { iconComponentFor$, useTranslation } from "../../core/index.js";
4
+ import { Cell, map, useCellValue, usePublisher } from "@mdxeditor/gurx";
5
+ import { activeEditor$, iconComponentFor$, useTranslation } from "../../core/index.js";
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
+ });
6
18
  const InsertTable = () => {
7
19
  const iconComponentFor = useCellValue(iconComponentFor$);
8
20
  const insertTable = usePublisher(insertTable$);
9
21
  const t = useTranslation();
22
+ const isDisabled = useCellValue(disableInsertTableButton$);
10
23
  return /* @__PURE__ */ React__default.createElement(
11
24
  ButtonWithTooltip,
12
25
  {
13
26
  title: t("toolbar.table", "Insert Table"),
14
27
  onClick: () => {
15
28
  insertTable({ rows: 3, columns: 3 });
16
- }
29
+ },
30
+ ...isDisabled ? { "aria-disabled": true, "data-disabled": true, disabled: true } : {}
17
31
  },
18
32
  iconComponentFor("table")
19
33
  );
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.21.2",
14
+ "version": "3.21.4",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",
@@ -42,7 +42,7 @@
42
42
  "@codemirror/merge": "^6.4.0",
43
43
  "@codemirror/state": "^6.4.0",
44
44
  "@codemirror/view": "^6.23.0",
45
- "@codesandbox/sandpack-react": "^2.10.0",
45
+ "@codesandbox/sandpack-react": "^2.19.11",
46
46
  "@lexical/clipboard": "^0.23.1",
47
47
  "@lexical/link": "^0.23.1",
48
48
  "@lexical/list": "^0.23.1",