@mdxeditor/editor 3.25.1 → 3.26.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 CHANGED
@@ -2,15 +2,15 @@ import { useCellValue, usePublisher, useCellValues, useRealm } from "@mdxeditor/
2
2
  import React__default from "react";
3
3
  import { RealmWithPlugins } from "./RealmWithPlugins.js";
4
4
  import { corePlugin, rootEditor$, useTranslation, contentEditableRef$, contentEditableClassName$, spellCheck$, composerChildren$, topAreaChildren$, editorWrappers$, placeholder$, editorRootElementRef$, viewMode$, markdownSourceEditorValue$, markdown$, setMarkdown$, insertMarkdown$ } from "./plugins/core/index.js";
5
- import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
6
- import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
7
- import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin.js";
5
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
6
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
8
7
  import classNames from "classnames";
9
8
  import { lexicalTheme } from "./styles/lexicalTheme.js";
10
9
  import styles from "./styles/ui.module.css.js";
11
10
  import { noop } from "./utils/fp.js";
12
11
  import { createLexicalComposerContext, LexicalComposerContext } from "@lexical/react/LexicalComposerContext";
13
12
  import { defaultSvgIcons } from "./defaultSvgIcons.js";
13
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
14
14
  const LexicalProvider = ({ children }) => {
15
15
  const rootEditor = useCellValue(rootEditor$);
16
16
  const composerContextValue = React__default.useMemo(() => {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Config } from 'mdast-util-from-markdown/lib';
2
- import { ContentEditable } from '@lexical/react/LexicalContentEditable.js';
2
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable';
3
3
  import { DecoratorNode } from 'lexical';
4
4
  import { default as default_2 } from 'react';
5
5
  import { Directives } from 'mdast-util-directive';
@@ -18,7 +18,7 @@ import { LexicalCommand } from 'lexical';
18
18
  import { LexicalEditor } from 'lexical';
19
19
  import { LexicalNode } from 'lexical';
20
20
  import { LinkNode } from '@lexical/link';
21
- import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin.js';
21
+ import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
22
22
  import { ListType } from '@lexical/list';
23
23
  import * as Mdast from 'mdast';
24
24
  import { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
@@ -1,10 +1,10 @@
1
1
  import { $addUpdateTag, $getNodeByKey, createEditor, $getRoot, FOCUS_COMMAND, COMMAND_PRIORITY_LOW, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_HIGH, KEY_BACKSPACE_COMMAND, COMMAND_PRIORITY_CRITICAL } from "lexical";
2
2
  import React__default from "react";
3
3
  import { NESTED_EDITOR_UPDATED_COMMAND, rootEditor$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, jsxIsAvailable$, nestedEditorChildren$, lexicalTheme$, editorInFocus$ } from "./index.js";
4
- import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
5
- import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
6
- import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer.js";
7
- import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin.js";
4
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
5
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
6
+ import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
7
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
8
8
  import classNames from "classnames";
9
9
  import { exportLexicalTreeToMdast } from "../../exportMarkdownFromLexical.js";
10
10
  import { importMdastTreeToLexical } from "../../importMarkdownToLexical.js";
@@ -1,4 +1,4 @@
1
- import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin.js";
1
+ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
2
2
  import React__default from "react";
3
3
  import { historyState$ } from "./index.js";
4
4
  import { useCellValue } from "@mdxeditor/gurx";
@@ -1,6 +1,6 @@
1
1
  import React__default from "react";
2
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext.js";
3
- import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection.js";
2
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
+ import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
4
4
  import { mergeRegister } from "@lexical/utils";
5
5
  import classNames from "classnames";
6
6
  import { $isNodeSelection, $getSelection, $getNodeByKey, $setSelection, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, CLICK_COMMAND, DRAGSTART_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND } from "lexical";
@@ -1,4 +1,4 @@
1
- import { createLinkMatcherWithRegExp, AutoLinkPlugin } from "@lexical/react/LexicalAutoLinkPlugin.js";
1
+ import { createLinkMatcherWithRegExp, AutoLinkPlugin } from "@lexical/react/LexicalAutoLinkPlugin";
2
2
  import React__default from "react";
3
3
  const URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
4
4
  const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
@@ -2,7 +2,7 @@ import React__default from "react";
2
2
  import { MdastLinkVisitor } from "./MdastLinkVisitor.js";
3
3
  import { LexicalLinkVisitor } from "./LexicalLinkVisitor.js";
4
4
  import { LinkNode, AutoLinkNode } from "@lexical/link";
5
- import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin.js";
5
+ 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";
@@ -1,11 +1,12 @@
1
1
  import { QUOTE, LINK, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST, CODE, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE } from "@lexical/markdown";
2
- import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin.js";
2
+ import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
3
3
  import { HeadingNode, $isHeadingNode, $createHeadingNode } from "@lexical/rich-text";
4
4
  import React__default from "react";
5
5
  import { realmPlugin } from "../../RealmWithPlugins.js";
6
6
  import { CodeBlockNode, $createCodeBlockNode } from "../codeblock/CodeBlockNode.js";
7
7
  import { activePlugins$, addComposerChild$, addNestedEditorChild$ } from "../core/index.js";
8
8
  import { allowedHeadingLevels$ } from "../headings/index.js";
9
+ import { HorizontalRuleNode, $isHorizontalRuleNode, $createHorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
9
10
  const markdownShortcutPlugin = realmPlugin({
10
11
  init(realm) {
11
12
  const pluginIds = realm.getValue(activePlugins$);
@@ -25,6 +26,18 @@ const createBlockNode = (createNode) => {
25
26
  node.select(0, 0);
26
27
  };
27
28
  };
29
+ const THEMATIC_BREAK = {
30
+ dependencies: [HorizontalRuleNode],
31
+ export: (node) => {
32
+ return $isHorizontalRuleNode(node) ? "***" : null;
33
+ },
34
+ regExp: /^(---|\*\*\*|___)?/,
35
+ replace: (parentNode) => {
36
+ const node = $createHorizontalRuleNode();
37
+ parentNode.replace(node);
38
+ },
39
+ type: "element"
40
+ };
28
41
  function pickTransformersForActivePlugins(pluginIds, allowedHeadingLevels) {
29
42
  const transformers = [
30
43
  BOLD_ITALIC_STAR,
@@ -59,6 +72,9 @@ function pickTransformersForActivePlugins(pluginIds, allowedHeadingLevels) {
59
72
  };
60
73
  transformers.push(HEADING);
61
74
  }
75
+ if (pluginIds.includes("thematicBreak")) {
76
+ transformers.push(THEMATIC_BREAK);
77
+ }
62
78
  if (pluginIds.includes("quote")) {
63
79
  transformers.push(QUOTE);
64
80
  }
@@ -1,14 +1,14 @@
1
- import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
2
- import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
3
- import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer.js";
4
- import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin.js";
1
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
2
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
3
+ import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
4
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
5
5
  import * as RadixPopover from "@radix-ui/react-popover";
6
6
  import { $createParagraphNode, createEditor, $getRoot, KEY_TAB_COMMAND, COMMAND_PRIORITY_CRITICAL, FOCUS_COMMAND, COMMAND_PRIORITY_LOW, KEY_ENTER_COMMAND, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR } from "lexical";
7
7
  import React__default from "react";
8
8
  import { exportLexicalTreeToMdast } from "../../exportMarkdownFromLexical.js";
9
9
  import { importMdastTreeToLexical } from "../../importMarkdownToLexical.js";
10
10
  import { lexicalTheme } from "../../styles/lexicalTheme.js";
11
- import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin.js";
11
+ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
12
12
  import { mergeRegister } from "@lexical/utils";
13
13
  import * as RadixToolbar from "@radix-ui/react-toolbar";
14
14
  import classNames from "classnames";
@@ -2,7 +2,7 @@ import { realmPlugin } from "../../RealmWithPlugins.js";
2
2
  import { INSERT_HORIZONTAL_RULE_COMMAND, HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode.js";
3
3
  import { HorizontalRulePlugin } from "@lexical/react/LexicalHorizontalRulePlugin.js";
4
4
  import { Action, withLatestFrom } from "@mdxeditor/gurx";
5
- import { activeEditor$, addImportVisitor$, addLexicalNode$, addExportVisitor$, addComposerChild$ } from "../core/index.js";
5
+ import { activeEditor$, addActivePlugin$, addImportVisitor$, addLexicalNode$, addExportVisitor$, addComposerChild$ } from "../core/index.js";
6
6
  import { LexicalThematicBreakVisitor } from "./LexicalThematicBreakVisitor.js";
7
7
  import { MdastThematicBreakVisitor } from "./MdastThematicBreakVisitor.js";
8
8
  const insertThematicBreak$ = Action((r) => {
@@ -13,6 +13,7 @@ const insertThematicBreak$ = Action((r) => {
13
13
  const thematicBreakPlugin = realmPlugin({
14
14
  init(realm) {
15
15
  realm.pubIn({
16
+ [addActivePlugin$]: "thematicBreak",
16
17
  [addImportVisitor$]: MdastThematicBreakVisitor,
17
18
  [addLexicalNode$]: HorizontalRuleNode,
18
19
  [addExportVisitor$]: LexicalThematicBreakVisitor,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.25.1",
14
+ "version": "3.26.0",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",
@@ -43,15 +43,15 @@
43
43
  "@codemirror/state": "^6.4.0",
44
44
  "@codemirror/view": "^6.23.0",
45
45
  "@codesandbox/sandpack-react": "^2.19.11",
46
- "@lexical/clipboard": "^0.23.1",
47
- "@lexical/link": "^0.23.1",
48
- "@lexical/list": "^0.23.1",
49
- "@lexical/markdown": "^0.23.1",
50
- "@lexical/plain-text": "^0.23.1",
51
- "@lexical/react": "^0.23.1",
52
- "@lexical/rich-text": "^0.23.1",
53
- "@lexical/selection": "^0.23.1",
54
- "@lexical/utils": "^0.23.1",
46
+ "@lexical/clipboard": "^0.27.1",
47
+ "@lexical/link": "^0.27.1",
48
+ "@lexical/list": "^0.27.1",
49
+ "@lexical/markdown": "^0.27.1",
50
+ "@lexical/plain-text": "^0.27.1",
51
+ "@lexical/react": "^0.27.1",
52
+ "@lexical/rich-text": "^0.27.1",
53
+ "@lexical/selection": "^0.27.1",
54
+ "@lexical/utils": "^0.27.1",
55
55
  "@mdxeditor/gurx": "^1.1.4",
56
56
  "@radix-ui/colors": "^3.0.0",
57
57
  "@radix-ui/react-dialog": "^1.0.5",
@@ -66,7 +66,7 @@
66
66
  "codemirror": "^6.0.1",
67
67
  "downshift": "^7.6.0",
68
68
  "js-yaml": "4.1.0",
69
- "lexical": "^0.23.1",
69
+ "lexical": "^0.27.1",
70
70
  "mdast-util-directive": "^3.0.0",
71
71
  "mdast-util-from-markdown": "^2.0.0",
72
72
  "mdast-util-frontmatter": "^2.0.1",