@mdxeditor/editor 4.1.0 → 4.1.1

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.
Files changed (31) hide show
  1. package/dist/index.js +6 -6
  2. package/dist/plugins/codeblock/CodeBlockNode.js +1 -4
  3. package/dist/plugins/codeblock/index.js +1 -1
  4. package/dist/plugins/codemirror/CodeMirrorEditor.js +1 -1
  5. package/dist/plugins/core/GenericHTMLNode.js +2 -5
  6. package/dist/plugins/core/NestedLexicalEditor.js +2 -2
  7. package/dist/plugins/core/index.js +2 -2
  8. package/dist/plugins/diff-source/SourceEditor.js +1 -1
  9. package/dist/plugins/directives/DirectiveNode.js +1 -4
  10. package/dist/plugins/frontmatter/FrontmatterNode.js +1 -4
  11. package/dist/plugins/frontmatter/index.js +1 -1
  12. package/dist/plugins/headings/index.js +2 -1
  13. package/dist/plugins/image/ImageDialog.js +1 -2
  14. package/dist/plugins/image/ImageEditor.js +1 -2
  15. package/dist/plugins/image/ImageNode.js +1 -4
  16. package/dist/plugins/image/index.js +4 -6
  17. package/dist/plugins/jsx/LexicalJsxNode.js +1 -4
  18. package/dist/plugins/jsx/LexicalMdxExpressionNode.js +1 -4
  19. package/dist/plugins/link-dialog/LinkDialog.js +1 -2
  20. package/dist/plugins/link-dialog/index.js +3 -5
  21. package/dist/plugins/lists/index.js +3 -3
  22. package/dist/plugins/markdown-shortcut/index.js +1 -1
  23. package/dist/plugins/search/index.js +24 -47
  24. package/dist/plugins/table/TableEditor.js +1 -1
  25. package/dist/plugins/table/TableNode.js +1 -4
  26. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +1 -1
  27. package/dist/plugins/toolbar/primitives/toolbar.js +1 -1
  28. package/dist/style.css +1511 -1525
  29. package/dist/utils/lexicalHelpers.js +1 -1
  30. package/package.json +2 -2
  31. package/dist/styles/globals.css.js +0 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./styles/globals.css.js";
1
+ /* empty css */
2
2
  export * from "@mdxeditor/gurx";
3
3
  import { MDXEditor } from "./MDXEditor.js";
4
4
  import { defaultSvgIcons } from "./defaultSvgIcons.js";
@@ -62,13 +62,13 @@ import { RealmWithPlugins, realmPlugin } from "./RealmWithPlugins.js";
62
62
  import { DEFAULT_FORMAT, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE } from "./FormatConstants.js";
63
63
  import { lexicalTheme } from "./styles/lexicalTheme.js";
64
64
  import * as lexical from "lexical";
65
- import { htmlTags, isMdastHTMLNode } from "./plugins/core/MdastHTMLNode.js";
66
- import { $createGenericHTMLNode, $isGenericHTMLNode, GenericHTMLNode, TYPE_NAME } from "./plugins/core/GenericHTMLNode.js";
67
- import { $convertTableElement, $createTableNode, $isTableNode, TableNode } from "./plugins/table/TableNode.js";
68
- import { $createImageNode, $isImageNode, ImageNode } from "./plugins/image/ImageNode.js";
69
- import { $createFrontmatterNode, $isFrontmatterNode, FrontmatterNode } from "./plugins/frontmatter/FrontmatterNode.js";
70
65
  import { $convertPreElement, $createCodeBlockNode, $isCodeBlockNode, CodeBlockNode, useCodeBlockEditorContext } from "./plugins/codeblock/CodeBlockNode.js";
66
+ import { $convertTableElement, $createTableNode, $isTableNode, TableNode } from "./plugins/table/TableNode.js";
71
67
  import { $createDirectiveNode, $isDirectiveNode, DirectiveNode } from "./plugins/directives/DirectiveNode.js";
68
+ import { $createFrontmatterNode, $isFrontmatterNode, FrontmatterNode } from "./plugins/frontmatter/FrontmatterNode.js";
69
+ import { $createGenericHTMLNode, $isGenericHTMLNode, GenericHTMLNode, TYPE_NAME } from "./plugins/core/GenericHTMLNode.js";
70
+ import { $createImageNode, $isImageNode, ImageNode } from "./plugins/image/ImageNode.js";
71
+ import { htmlTags, isMdastHTMLNode } from "./plugins/core/MdastHTMLNode.js";
72
72
  export {
73
73
  $convertPreElement,
74
74
  $convertTableElement,
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import { useCellValue } from "@mdxeditor/gurx";
8
5
  import { DecoratorNode } from "lexical";
9
6
  import React__default from "react";
@@ -1,6 +1,6 @@
1
1
  import { CodeBlockVisitor } from "./CodeBlockVisitor.js";
2
2
  import { MdastCodeVisitor } from "./MdastCodeVisitor.js";
3
- import { Appender, defaultCodeBlockLanguage$, insertDecoratorNode$, codeBlockEditorDescriptors$, addExportVisitor$, addLexicalNode$, addImportVisitor$, addActivePlugin$ } from "../core/index.js";
3
+ import { Appender, codeBlockEditorDescriptors$, defaultCodeBlockLanguage$, insertDecoratorNode$, addExportVisitor$, addLexicalNode$, addImportVisitor$, addActivePlugin$ } from "../core/index.js";
4
4
  import { $createCodeBlockNode, CodeBlockNode } from "./CodeBlockNode.js";
5
5
  import { $convertPreElement, $isCodeBlockNode, useCodeBlockEditorContext } from "./CodeBlockNode.js";
6
6
  import { Signal, withLatestFrom, map } from "@mdxeditor/gurx";
@@ -5,7 +5,7 @@ import { useCodeBlockEditorContext } from "../codeblock/CodeBlockNode.js";
5
5
  import { useTranslation, readOnly$, iconComponentFor$ } from "../core/index.js";
6
6
  import { languages } from "@codemirror/language-data";
7
7
  import { EditorState } from "@codemirror/state";
8
- import { lineNumbers, keymap, EditorView } from "@codemirror/view";
8
+ import { EditorView, lineNumbers, keymap } from "@codemirror/view";
9
9
  import { indentWithTab } from "@codemirror/commands";
10
10
  import { basicLight } from "cm6-theme-basic-light";
11
11
  import { basicSetup } from "codemirror";
@@ -1,10 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { ElementNode, $applyNodeReplacement } from "lexical";
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { $applyNodeReplacement, ElementNode } from "lexical";
8
5
  const TYPE_NAME = "generic-html";
9
6
  class GenericHTMLNode extends ElementNode {
10
7
  /**
@@ -1,6 +1,6 @@
1
- import { $addUpdateTag, $getNodeByKey, FOCUS_COMMAND, COMMAND_PRIORITY_LOW, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_HIGH, KEY_BACKSPACE_COMMAND, COMMAND_PRIORITY_CRITICAL, $getRoot } from "lexical";
1
+ import { FOCUS_COMMAND, COMMAND_PRIORITY_LOW, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_HIGH, KEY_BACKSPACE_COMMAND, COMMAND_PRIORITY_CRITICAL, $getNodeByKey, $addUpdateTag, $getRoot } from "lexical";
2
2
  import React__default from "react";
3
- import { NESTED_EDITOR_UPDATED_COMMAND, rootEditor$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, defaultCodeBlockLanguage$, jsxIsAvailable$, nestedEditorChildren$, lexicalTheme$, editorInFocus$, historyState$ } from "./index.js";
3
+ import { rootEditor$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, defaultCodeBlockLanguage$, jsxIsAvailable$, nestedEditorChildren$, lexicalTheme$, editorInFocus$, historyState$, NESTED_EDITOR_UPDATED_COMMAND } from "./index.js";
4
4
  import { ContentEditable } from "@lexical/react/LexicalContentEditable";
5
5
  import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
6
6
  import { LexicalExtensionEditorComposer } from "@lexical/react/LexicalExtensionEditorComposer";
@@ -3,8 +3,8 @@ import { createEmptyHistoryState } from "@lexical/history";
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, map, useCellValue, scan } from "@mdxeditor/gurx";
7
- import { createCommand, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getRoot, $setSelection, $getSelection, $insertNodes, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, DecoratorNode, $createParagraphNode, FOCUS_COMMAND, BLUR_COMMAND, $isRangeSelection, ParagraphNode, TextNode } from "lexical";
6
+ import { Signal, Cell, withLatestFrom, map, filter, useCellValue, scan } from "@mdxeditor/gurx";
7
+ import { createCommand, FORMAT_TEXT_COMMAND, $getSelection, $isRangeSelection, BLUR_COMMAND, COMMAND_PRIORITY_CRITICAL, SELECTION_CHANGE_COMMAND, $getRoot, DecoratorNode, $createParagraphNode, FOCUS_COMMAND, $isRootOrShadowRoot, $insertNodes, $setSelection, ParagraphNode, TextNode } from "lexical";
8
8
  import { gfmStrikethrough } from "micromark-extension-gfm-strikethrough";
9
9
  import { gfmStrikethroughToMarkdown, gfmStrikethroughFromMarkdown } from "mdast-util-gfm-strikethrough";
10
10
  import { highlightMarkToMarkdown, highlightMarkFromMarkdown } from "mdast-util-highlight-mark";
@@ -1,6 +1,6 @@
1
1
  import { markdown } from "@codemirror/lang-markdown";
2
2
  import { EditorState } from "@codemirror/state";
3
- import { lineNumbers, EditorView } from "@codemirror/view";
3
+ import { EditorView, lineNumbers } from "@codemirror/view";
4
4
  import { basicLight } from "cm6-theme-basic-light";
5
5
  import { basicSetup } from "codemirror";
6
6
  import React__default from "react";
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import React__default from "react";
8
5
  import { DecoratorNode } from "lexical";
9
6
  import { NestedEditorsContext } from "../core/NestedLexicalEditor.js";
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import { DecoratorNode } from "lexical";
8
5
  import React__default from "react";
9
6
  import { FrontmatterEditor } from "./FrontmatterEditor.js";
@@ -1,5 +1,5 @@
1
1
  import { realmPlugin } from "../../RealmWithPlugins.js";
2
- import { rootEditor$, createRootEditorSubscription$, addToMarkdownExtension$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addSyntaxExtension$, addMdastExtension$ } from "../core/index.js";
2
+ import { createRootEditorSubscription$, rootEditor$, addToMarkdownExtension$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addSyntaxExtension$, addMdastExtension$ } from "../core/index.js";
3
3
  import { Cell, Action, withLatestFrom } from "@mdxeditor/gurx";
4
4
  import { $getRoot, KEY_DOWN_COMMAND, $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_CRITICAL } from "lexical";
5
5
  import { frontmatterToMarkdown, frontmatterFromMarkdown } from "mdast-util-frontmatter";
@@ -44,13 +44,14 @@ const allowedHeadingLevels$ = Cell(ALL_HEADING_LEVELS, (r) => {
44
44
  });
45
45
  });
46
46
  const headingsPlugin = realmPlugin({
47
- init(realm) {
47
+ init(realm, params) {
48
48
  realm.pubIn({
49
49
  [addActivePlugin$]: "headings",
50
50
  [addImportVisitor$]: MdastHeadingVisitor,
51
51
  [addLexicalNode$]: HeadingNode,
52
52
  [addExportVisitor$]: LexicalHeadingVisitor
53
53
  });
54
+ realm.pub(allowedHeadingLevels$, (params == null ? void 0 : params.allowedHeadingLevels) ?? ALL_HEADING_LEVELS);
54
55
  },
55
56
  update(realm, params) {
56
57
  realm.pub(allowedHeadingLevels$, (params == null ? void 0 : params.allowedHeadingLevels) ?? ALL_HEADING_LEVELS);
@@ -25,8 +25,7 @@ const ImageDialog = () => {
25
25
  const resetFormState = () => {
26
26
  reset({ src: "", title: "", altText: "", width: void 0, height: void 0 });
27
27
  };
28
- if (state.type === "inactive")
29
- return null;
28
+ if (state.type === "inactive") return null;
30
29
  return /* @__PURE__ */ React__default.createElement(
31
30
  Dialog.Root,
32
31
  {
@@ -132,8 +132,7 @@ function ImageEditor({ src, title, alt, nodeKey, width, height, rest }) {
132
132
  React__default.useEffect(() => {
133
133
  if (imagePreviewHandler) {
134
134
  const callPreviewHandler = async () => {
135
- if (!initialImagePath)
136
- setInitialImagePath(src);
135
+ if (!initialImagePath) setInitialImagePath(src);
137
136
  const updatedSrc = await imagePreviewHandler(src);
138
137
  setImageSource(updatedSrc);
139
138
  };
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import React__default from "react";
8
5
  import { DecoratorNode } from "lexical";
9
6
  import { ImageEditor } from "./ImageEditor.js";
@@ -1,13 +1,13 @@
1
1
  import { ImagePlaceholder } from "./ImagePlaceholder.js";
2
2
  import { mergeRegister, $wrapNodeInElement } from "@lexical/utils";
3
- import { Signal, Cell, Action, withLatestFrom, mapTo, map } from "@mdxeditor/gurx";
3
+ import { Cell, Action, mapTo, withLatestFrom, Signal, map } from "@mdxeditor/gurx";
4
4
  import { createCommand, $getNodeByKey, $insertNodes, $isRootOrShadowRoot, $createParagraphNode, COMMAND_PRIORITY_EDITOR, DRAGSTART_COMMAND, COMMAND_PRIORITY_HIGH, DRAGOVER_COMMAND, COMMAND_PRIORITY_LOW, DROP_COMMAND, PASTE_COMMAND, COMMAND_PRIORITY_CRITICAL, $createRangeSelection, $setSelection, $getSelection, $isNodeSelection } from "lexical";
5
5
  import { realmPlugin } from "../../RealmWithPlugins.js";
6
6
  import { CAN_USE_DOM } from "../../utils/detectMac.js";
7
7
  import { activeEditor$, createActiveEditorSubscription$, addComposerChild$, addExportVisitor$, addLexicalNode$, addImportVisitor$ } from "../core/index.js";
8
8
  import { EditImageToolbar } from "./EditImageToolbar.js";
9
9
  import { ImageDialog } from "./ImageDialog.js";
10
- import { $createImageNode, ImageNode, $isImageNode } from "./ImageNode.js";
10
+ import { $createImageNode, $isImageNode, ImageNode } from "./ImageNode.js";
11
11
  import { LexicalImageVisitor } from "./LexicalImageVisitor.js";
12
12
  import { MdastImageVisitor, MdastHtmlImageVisitor, MdastJsxImageVisitor } from "./MdastImageVisitor.js";
13
13
  const internalInsertImage$ = Signal((r) => {
@@ -129,8 +129,7 @@ const imageDialogState$ = Cell(
129
129
  }
130
130
  const cbPayload = Array.from(((_b = event.clipboardData) == null ? void 0 : _b.items) ?? []);
131
131
  const isMixedPayload = cbPayload.some((item) => !item.type.includes("image"));
132
- if (isMixedPayload)
133
- return false;
132
+ if (isMixedPayload) return false;
134
133
  if (!cbPayload.length || cbPayload.length === 0) {
135
134
  return false;
136
135
  }
@@ -173,8 +172,7 @@ const allowSetImageDimensions$ = Cell(false);
173
172
  const saveImage$ = Signal();
174
173
  const editImageToolbarComponent$ = Cell(EditImageToolbar);
175
174
  const parseImageDimension = (value) => {
176
- if (typeof value === "undefined")
177
- return void 0;
175
+ if (typeof value === "undefined") return void 0;
178
176
  const parsed = parseInt(String(value), 10);
179
177
  return Number.isNaN(parsed) ? void 0 : parsed;
180
178
  };
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import { DecoratorNode } from "lexical";
8
5
  import React__default from "react";
9
6
  import { NestedEditorsContext } from "../core/NestedLexicalEditor.js";
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import React__default from "react";
8
5
  import { DecoratorNode, $applyNodeReplacement } from "lexical";
9
6
  import lexicalThemeStyles from "../../styles/lexical-theme.module.css.js";
@@ -128,8 +128,7 @@ const LinkDialog = () => {
128
128
  }, [activeEditor, publishWindowChange]);
129
129
  const [copyUrlTooltipOpen, setCopyUrlTooltipOpen] = React__default.useState(false);
130
130
  const t = useTranslation();
131
- if (linkDialogState.type === "inactive")
132
- return null;
131
+ if (linkDialogState.type === "inactive") return null;
133
132
  const theRect = linkDialogState.rectangle;
134
133
  const urlIsExternal = linkDialogState.type === "preview" && linkDialogState.url.startsWith("http");
135
134
  return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, { open: true }, /* @__PURE__ */ React__default.createElement(
@@ -1,5 +1,5 @@
1
1
  import { $isLinkNode, $createLinkNode, $isAutoLinkNode, TOGGLE_LINK_COMMAND, LinkNode } from "@lexical/link";
2
- import { Signal, Cell, Action, withLatestFrom, map, filter } from "@mdxeditor/gurx";
2
+ import { Action, Cell, withLatestFrom, map, Signal, filter } from "@mdxeditor/gurx";
3
3
  import { KEY_ESCAPE_COMMAND, COMMAND_PRIORITY_LOW, KEY_DOWN_COMMAND, $getSelection, $isRangeSelection, COMMAND_PRIORITY_HIGH, $getNodeByKey, $createTextNode, $insertNodes, $isTextNode, $getNearestNodeFromDOMNode } from "lexical";
4
4
  import { realmPlugin } from "../../RealmWithPlugins.js";
5
5
  import { IS_APPLE } from "../../utils/detectMac.js";
@@ -24,8 +24,7 @@ function getLinkNodeInSelection(selection) {
24
24
  return null;
25
25
  }
26
26
  function getPreviewHref(editor, linkNodeKey, url) {
27
- if (!editor)
28
- return "about:blank";
27
+ if (!editor) return "about:blank";
29
28
  return editor.getEditorState().read(() => {
30
29
  const keyedNode = linkNodeKey === "" ? null : $getNodeByKey(linkNodeKey);
31
30
  const selection = $getSelection();
@@ -186,8 +185,7 @@ const linkDialogState$ = Cell({ type: "inactive" }, (r) => {
186
185
  map(([[selection], activeEditor, _, readOnly]) => {
187
186
  if ($isRangeSelection(selection) && activeEditor && !readOnly) {
188
187
  const node = getLinkNodeInSelection(selection);
189
- if (!selection.isCollapsed())
190
- return { type: "inactive" };
188
+ if (!selection.isCollapsed()) return { type: "inactive" };
191
189
  if (node) {
192
190
  const rect = getSelectionRectangle(activeEditor);
193
191
  if (!rect) {
@@ -1,9 +1,9 @@
1
- import { currentSelection$, activeEditor$, rootEditor$, addNestedEditorChild$, addComposerChild$, addToMarkdownExtension$, addExportVisitor$, addLexicalNode$, addImportVisitor$, addSyntaxExtension$, addMdastExtension$, addActivePlugin$ } from "../core/index.js";
1
+ import { activeEditor$, currentSelection$, rootEditor$, addNestedEditorChild$, addComposerChild$, addToMarkdownExtension$, addExportVisitor$, addLexicalNode$, addImportVisitor$, addSyntaxExtension$, addMdastExtension$, addActivePlugin$ } from "../core/index.js";
2
2
  import { MdastListVisitor } from "./MdastListVisitor.js";
3
3
  import { MdastListItemVisitor } from "./MdastListItemVisitor.js";
4
4
  import { LexicalListVisitor } from "./LexicalListVisitor.js";
5
5
  import { LexicalListItemVisitor } from "./LexicalListItemVisitor.js";
6
- import { $isListNode, ListNode, ListItemNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, REMOVE_LIST_COMMAND, $getListDepth, $isListItemNode } from "@lexical/list";
6
+ import { $isListNode, ListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, REMOVE_LIST_COMMAND, ListItemNode, $getListDepth, $isListItemNode } from "@lexical/list";
7
7
  import { $isRootOrShadowRoot, INDENT_CONTENT_COMMAND, COMMAND_PRIORITY_CRITICAL, $getSelection, $isRangeSelection, $isElementNode } from "lexical";
8
8
  import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin.js";
9
9
  import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin.js";
@@ -11,7 +11,7 @@ import { ListPlugin } from "@lexical/react/LexicalListPlugin.js";
11
11
  import { $findMatchingParent, $getNearestNodeOfType } from "@lexical/utils";
12
12
  import { gfmTaskListItem } from "micromark-extension-gfm-task-list-item";
13
13
  import { gfmTaskListItemToMarkdown, gfmTaskListItemFromMarkdown } from "mdast-util-gfm-task-list-item";
14
- import { Cell, Signal, withLatestFrom } from "@mdxeditor/gurx";
14
+ import { Signal, withLatestFrom, Cell } from "@mdxeditor/gurx";
15
15
  import { realmPlugin } from "../../RealmWithPlugins.js";
16
16
  const ListTypeCommandMap = /* @__PURE__ */ new Map([
17
17
  ["number", INSERT_ORDERED_LIST_COMMAND],
@@ -1,5 +1,5 @@
1
1
  import React__default from "react";
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
+ import { ORDERED_LIST, UNORDERED_LIST, CHECK_LIST, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, QUOTE, LINK, CODE } from "@lexical/markdown";
3
3
  import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
4
4
  import { HeadingNode, $isHeadingNode, $createHeadingNode } from "@lexical/rich-text";
5
5
  import { realmPlugin } from "../../RealmWithPlugins.js";
@@ -1,6 +1,6 @@
1
1
  import { Cell, debounceTime, useRealm, useCellValue, useCell } from "@mdxeditor/gurx";
2
2
  import { createDOMRange } from "@lexical/selection";
3
- import { $createRangeSelection, HISTORY_PUSH_TAG, $getRoot, $getNodeByKey, $isTextNode } from "lexical";
3
+ import { $getRoot, $getNodeByKey, $isTextNode, $createRangeSelection, HISTORY_PUSH_TAG } from "lexical";
4
4
  import { realmPlugin } from "../../RealmWithPlugins.js";
5
5
  import { contentEditableRef$, createActiveEditorSubscription$, activeEditor$, historyState$ } from "../core/index.js";
6
6
  import { editorUsesHistoryState } from "../core/lexicalExtensions.js";
@@ -76,8 +76,7 @@ function createSearchSnapshot(editor) {
76
76
  let sourceOffset = 0;
77
77
  while (sourceOffset < nodeText.length) {
78
78
  const codePoint = nodeText.codePointAt(sourceOffset);
79
- if (codePoint === void 0)
80
- break;
79
+ if (codePoint === void 0) break;
81
80
  const sourceUnit = String.fromCodePoint(codePoint);
82
81
  const normalizedUnit = sourceUnit.normalize("NFKD");
83
82
  const mapsOneToOne = normalizedUnit === sourceUnit;
@@ -97,8 +96,7 @@ function findStateMatches(snapshot, searchQuery) {
97
96
  for (const [startIndex, endIndex] of searchText(snapshot.text, searchQuery)) {
98
97
  const startUnit = snapshot.units[startIndex];
99
98
  const endUnit = snapshot.units[endIndex];
100
- if (!startUnit || !endUnit)
101
- continue;
99
+ if (!startUnit || !endUnit) continue;
102
100
  matches.push({
103
101
  editor: snapshot.editor,
104
102
  start: { key: startUnit.key, offset: startUnit.startOffset },
@@ -136,11 +134,9 @@ function projectSnapshot(snapshot, matches) {
136
134
  for (const match of matches) {
137
135
  const startNode = $getNodeByKey(match.start.key);
138
136
  const endNode = $getNodeByKey(match.end.key);
139
- if (!$isTextNode(startNode) || !$isTextNode(endNode))
140
- continue;
137
+ if (!$isTextNode(startNode) || !$isTextNode(endNode)) continue;
141
138
  const range = createDOMRange(snapshot.editor, startNode, match.start.offset, endNode, match.end.offset);
142
- if (range)
143
- projectedMatches.push({ match, range });
139
+ if (range) projectedMatches.push({ match, range });
144
140
  }
145
141
  });
146
142
  return {
@@ -152,20 +148,16 @@ function supportsHighlights() {
152
148
  return typeof CSS !== "undefined" && typeof CSS.highlights !== "undefined" && typeof Highlight !== "undefined";
153
149
  }
154
150
  const focusHighlightRange = (range) => {
155
- if (!supportsHighlights())
156
- return;
151
+ if (!supportsHighlights()) return;
157
152
  CSS.highlights.delete(MDX_FOCUS_SEARCH_NAME);
158
- if (range)
159
- CSS.highlights.set(MDX_FOCUS_SEARCH_NAME, new Highlight(range));
153
+ if (range) CSS.highlights.set(MDX_FOCUS_SEARCH_NAME, new Highlight(range));
160
154
  };
161
155
  const highlightRanges = (ranges) => {
162
- if (!supportsHighlights())
163
- return;
156
+ if (!supportsHighlights()) return;
164
157
  CSS.highlights.set(MDX_SEARCH_NAME, new Highlight(...ranges));
165
158
  };
166
159
  const resetHighlights = () => {
167
- if (!supportsHighlights())
168
- return;
160
+ if (!supportsHighlights()) return;
169
161
  CSS.highlights.delete(MDX_SEARCH_NAME);
170
162
  CSS.highlights.delete(MDX_FOCUS_SEARCH_NAME);
171
163
  };
@@ -189,8 +181,7 @@ const scrollToRange = (range, contentEditable, options) => {
189
181
  const rangeBottom = bottomRelativeToContainer + contentEditable.scrollTop;
190
182
  const visibleTop = contentEditable.scrollTop;
191
183
  const visibleBottom = visibleTop + contentEditable.clientHeight;
192
- if (rangeTop >= visibleTop && rangeBottom <= visibleBottom)
193
- return;
184
+ if (rangeTop >= visibleTop && rangeBottom <= visibleBottom) return;
194
185
  }
195
186
  const top = topRelativeToContainer + contentEditable.scrollTop - first.height;
196
187
  contentEditable.scrollTo({ top, behavior });
@@ -207,8 +198,7 @@ function clearSearchResults(realm) {
207
198
  resetHighlights();
208
199
  }
209
200
  function refreshSearch(realm, editor, advanceFrom) {
210
- if (realm.getValue(editorSearchActiveEditor$) !== editor)
211
- return;
201
+ if (realm.getValue(editorSearchActiveEditor$) !== editor) return;
212
202
  let snapshot;
213
203
  editor.getEditorState().read(() => {
214
204
  snapshot = createSearchSnapshot(editor);
@@ -244,25 +234,19 @@ function refreshSearch(realm, editor, advanceFrom) {
244
234
  function resolveMatch(match) {
245
235
  const startNode = $getNodeByKey(match.start.key);
246
236
  const endNode = $getNodeByKey(match.end.key);
247
- if (!$isTextNode(startNode) || !$isTextNode(endNode))
248
- return null;
249
- if (match.start.offset < 0 || match.start.offset > startNode.getTextContentSize())
250
- return null;
251
- if (match.end.offset < 0 || match.end.offset > endNode.getTextContentSize())
252
- return null;
237
+ if (!$isTextNode(startNode) || !$isTextNode(endNode)) return null;
238
+ if (match.start.offset < 0 || match.start.offset > startNode.getTextContentSize()) return null;
239
+ if (match.end.offset < 0 || match.end.offset > endNode.getTextContentSize()) return null;
253
240
  return { startNode, endNode };
254
241
  }
255
242
  function replaceStateMatches(editor, matches, replacement, onUpdate) {
256
- if (matches.length === 0 || matches.some((match) => match.editor !== editor))
257
- return;
243
+ if (matches.length === 0 || matches.some((match) => match.editor !== editor)) return;
258
244
  editor.update(
259
245
  () => {
260
- if (matches.some((match) => resolveMatch(match) === null))
261
- return;
246
+ if (matches.some((match) => resolveMatch(match) === null)) return;
262
247
  for (let index = matches.length - 1; index >= 0; index--) {
263
248
  const match = matches[index];
264
- if (!match)
265
- continue;
249
+ if (!match) continue;
266
250
  const resolved = resolveMatch(match);
267
251
  if (!resolved) {
268
252
  throw new Error("Search match became stale during replacement.");
@@ -330,15 +314,13 @@ function useEditorSearch() {
330
314
  realm.pub(editorSearchTermDebounced$, term ?? "");
331
315
  };
332
316
  const next = () => {
333
- if (!ranges.length)
334
- return;
317
+ if (!ranges.length) return;
335
318
  const newCursor = cursor % ranges.length + 1;
336
319
  scrollToRangeOrIndex(newCursor);
337
320
  realm.pub(editorSearchCursor$, newCursor);
338
321
  };
339
322
  const prev = () => {
340
- if (!ranges.length)
341
- return;
323
+ if (!ranges.length) return;
342
324
  const newCursor = cursor <= 1 ? ranges.length : cursor - 1;
343
325
  scrollToRangeOrIndex(newCursor);
344
326
  realm.pub(editorSearchCursor$, newCursor);
@@ -347,8 +329,7 @@ function useEditorSearch() {
347
329
  const editor = realm.getValue(editorSearchActiveEditor$);
348
330
  const matches = realm.getValue(editorSearchStateMatches$);
349
331
  const match = matches[cursor - 1];
350
- if (!editor || !match)
351
- return;
332
+ if (!editor || !match) return;
352
333
  ensureHistoryBaseline(realm, editor);
353
334
  replaceStateMatches(editor, [match], replacement, () => {
354
335
  refreshSearch(realm, editor, { cursor, match });
@@ -358,8 +339,7 @@ function useEditorSearch() {
358
339
  const replaceAll = (replacement, onUpdate) => {
359
340
  const editor = realm.getValue(editorSearchActiveEditor$);
360
341
  const matches = realm.getValue(editorSearchStateMatches$);
361
- if (!editor || matches.length === 0)
362
- return;
342
+ if (!editor || matches.length === 0) return;
363
343
  ensureHistoryBaseline(realm, editor);
364
344
  replaceStateMatches(editor, matches, replacement, () => {
365
345
  refreshSearch(realm, editor);
@@ -397,8 +377,7 @@ const searchPlugin = realmPlugin({
397
377
  });
398
378
  realm.sub(editorSearchTerm$, () => {
399
379
  const editor = realm.getValue(editorSearchActiveEditor$);
400
- if (editor)
401
- refreshSearch(realm, editor);
380
+ if (editor) refreshSearch(realm, editor);
402
381
  });
403
382
  realm.sub(searchOpen$, (searchOpen) => {
404
383
  if (!searchOpen) {
@@ -406,8 +385,7 @@ const searchPlugin = realmPlugin({
406
385
  return;
407
386
  }
408
387
  const editor = realm.getValue(editorSearchActiveEditor$);
409
- if (editor)
410
- refreshSearch(realm, editor);
388
+ if (editor) refreshSearch(realm, editor);
411
389
  });
412
390
  realm.pub(createActiveEditorSubscription$, (editor) => {
413
391
  var _a;
@@ -419,8 +397,7 @@ const searchPlugin = realmPlugin({
419
397
  clearSearchResults(realm);
420
398
  refreshSearch(realm, editor);
421
399
  const unregisterUpdate = editor.registerUpdateListener(({ dirtyElements, dirtyLeaves }) => {
422
- if (dirtyElements.size > 0 || dirtyLeaves.size > 0)
423
- refreshSearch(realm, editor);
400
+ if (dirtyElements.size > 0 || dirtyLeaves.size > 0) refreshSearch(realm, editor);
424
401
  });
425
402
  const unregisterRoot = editor.registerRootListener((rootElement) => {
426
403
  if (!rootElement) {
@@ -191,7 +191,7 @@ const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
191
191
  };
192
192
  const Cell = ({ align, ...props }) => {
193
193
  const { activeCell, setActiveCell } = props;
194
- const isActive = Boolean(activeCell && activeCell[0] === props.colIndex && activeCell[1] === props.rowIndex);
194
+ const isActive = (activeCell == null ? void 0 : activeCell[0]) === props.colIndex && activeCell[1] === props.rowIndex;
195
195
  const className = AlignToTailwindClassMap[align ?? "left"];
196
196
  const CellElement = getCellType(props.rowIndex);
197
197
  return /* @__PURE__ */ React__default.createElement(
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import { DecoratorNode } from "lexical";
8
5
  import React__default from "react";
9
6
  import { noop } from "../../utils/fp.js";
@@ -18,7 +18,7 @@ import { CreateLink } from "./CreateLink.js";
18
18
  import { HighlightToggle } from "./HighlightToggle.js";
19
19
  function whenInAdmonition(editorInFocus) {
20
20
  const node = editorInFocus == null ? void 0 : editorInFocus.rootNode;
21
- if (!node || node.getType() !== "directive") {
21
+ if ((node == null ? void 0 : node.getType()) !== "directive") {
22
22
  return false;
23
23
  }
24
24
  return ["note", "tip", "danger", "info", "caution"].includes(node.getMdastNode().name);
@@ -5,7 +5,7 @@ import React__default from "react";
5
5
  import styles from "../../../styles/ui.module.css.js";
6
6
  import { TooltipWrap } from "./TooltipWrap.js";
7
7
  import { SelectButtonTrigger, SelectContent, SelectItem } from "./select.js";
8
- import { useTranslation, readOnly$, editorInFocus$ } from "../../core/index.js";
8
+ import { readOnly$, editorInFocus$, useTranslation } from "../../core/index.js";
9
9
  import { useCellValue } from "@mdxeditor/gurx";
10
10
  function decorateWithRef(Component, decoratedProps) {
11
11
  return React__default.forwardRef((props, ref) => {