@mdxeditor/editor 2.13.2 → 2.15.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/index.d.ts CHANGED
@@ -44,7 +44,7 @@ import { FC } from 'react';
44
44
  import { HeadingTagType } from '@lexical/rich-text';
45
45
  import { HistoryState } from '@lexical/history';
46
46
  import { InitialEditorStateType } from '@lexical/react/LexicalComposer.js';
47
- import { Klass } from 'lexical';
47
+ import { KlassConstructor } from 'lexical';
48
48
  import { LexicalCommand } from 'lexical';
49
49
  import { LexicalEditor } from 'lexical';
50
50
  import { LexicalNode } from 'lexical';
@@ -190,7 +190,7 @@ export declare const addImportVisitor$: NodeRef<MdastImportVisitor<Mdast.Nodes>
190
190
  * Registers a lexical node to be used in the editor.
191
191
  * @group Core
192
192
  */
193
- export declare const addLexicalNode$: NodeRef<Klass<LexicalNode> | Klass<LexicalNode>[]>;
193
+ export declare const addLexicalNode$: NodeRef<KlassConstructor<typeof LexicalNode> | KlassConstructor<typeof LexicalNode>[]>;
194
194
 
195
195
  /**
196
196
  * Adds a mdast extension to the markdown parser.
@@ -965,6 +965,8 @@ export declare const disableAutoLink$: NodeRef<boolean>;
965
965
  */
966
966
  export declare const disableImageResize$: NodeRef<boolean>;
967
967
 
968
+ export declare const disableImageSettingsButton$: NodeRef<boolean>;
969
+
968
970
  /**
969
971
  * The state of the image dialog when it is in editing an existing node.
970
972
  * @group Image
@@ -1229,6 +1231,7 @@ export declare const imagePlugin: (params?: {
1229
1231
  imageUploadHandler?: ImageUploadHandler | undefined;
1230
1232
  imageAutocompleteSuggestions?: string[] | undefined;
1231
1233
  disableImageResize?: boolean | undefined;
1234
+ disableImageSettingsButton?: boolean | undefined;
1232
1235
  imagePreviewHandler?: ImagePreviewHandler | undefined;
1233
1236
  ImageDialog?: FC<{}> | (() => JSX.Element) | undefined;
1234
1237
  } | undefined) => RealmPlugin;
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { insertThematicBreak$, thematicBreakPlugin } from "./plugins/thematic-br
9
9
  import { applyListType$, currentListType$, listsPlugin } from "./plugins/lists/index.js";
10
10
  import { insertTable$, tablePlugin } from "./plugins/table/index.js";
11
11
  import { disableAutoLink$, linkPlugin } from "./plugins/link/index.js";
12
- import { INSERT_IMAGE_COMMAND, closeImageDialog$, disableImageResize$, imageAutocompleteSuggestions$, imageDialogState$, imagePlugin, imagePreviewHandler$, imageUploadHandler$, insertImage$, openEditImageDialog$, openNewImageDialog$, saveImage$ } from "./plugins/image/index.js";
12
+ import { INSERT_IMAGE_COMMAND, closeImageDialog$, disableImageResize$, disableImageSettingsButton$, imageAutocompleteSuggestions$, imageDialogState$, imagePlugin, imagePreviewHandler$, imageUploadHandler$, insertImage$, openEditImageDialog$, openNewImageDialog$, saveImage$ } from "./plugins/image/index.js";
13
13
  import { frontmatterDialogOpen$, frontmatterPlugin, hasFrontmatter$, insertFrontmatter$, removeFrontmatter$ } from "./plugins/frontmatter/index.js";
14
14
  import { quotePlugin } from "./plugins/quote/index.js";
15
15
  import { maxLengthPlugin } from "./plugins/maxlength/index.js";
@@ -188,6 +188,7 @@ export {
188
188
  directivesPlugin,
189
189
  disableAutoLink$,
190
190
  disableImageResize$,
191
+ disableImageSettingsButton$,
191
192
  editorInFocus$,
192
193
  editorRootElementRef$,
193
194
  editorWrappers$,
@@ -424,9 +424,11 @@ const insertDecoratorNode$ = Signal((r) => {
424
424
  } else {
425
425
  $insertNodeToNearestRoot(node);
426
426
  }
427
- if ("select" in node && typeof node.select === "function") {
428
- setTimeout(() => node.select());
429
- }
427
+ setTimeout(() => {
428
+ if ("select" in node && typeof node.select === "function") {
429
+ node.select();
430
+ }
431
+ });
430
432
  });
431
433
  setTimeout(() => {
432
434
  theEditor.dispatchCommand(NESTED_EDITOR_UPDATED_COMMAND, void 0);
@@ -10,7 +10,6 @@ import { NestedEditorsContext } from "../core/NestedLexicalEditor.js";
10
10
  import { voidEmitter } from "../../utils/voidEmitter.js";
11
11
  import { useCellValues } from "@mdxeditor/gurx";
12
12
  import { directiveDescriptors$ } from "../core/index.js";
13
- let GENERATION = 0;
14
13
  class DirectiveNode extends DecoratorNode {
15
14
  /**
16
15
  * Constructs a new {@link DirectiveNode} with the specified MDAST directive node as the object to edit.
@@ -28,7 +27,6 @@ class DirectiveNode extends DecoratorNode {
28
27
  this.__focusEmitter.publish();
29
28
  });
30
29
  this.__mdastNode = mdastNode;
31
- this.generation = GENERATION++;
32
30
  }
33
31
  /** @internal */
34
32
  static getType() {
@@ -4,7 +4,7 @@ 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";
7
- import { disableImageResize$, imagePreviewHandler$, openEditImageDialog$ } from "./index.js";
7
+ import { disableImageResize$, disableImageSettingsButton$, imagePreviewHandler$, openEditImageDialog$ } from "./index.js";
8
8
  import styles from "../../styles/ui.module.css.js";
9
9
  import { iconComponentFor$, readOnly$, useTranslation } from "../core/index.js";
10
10
  import { $isImageNode } from "./ImageNode.js";
@@ -48,8 +48,9 @@ function LazyImage({
48
48
  );
49
49
  }
50
50
  function ImageEditor({ src, title, alt, nodeKey, width, height }) {
51
- const [disableImageResize, imagePreviewHandler, iconComponentFor, readOnly] = useCellValues(
51
+ const [disableImageResize, disableImageSettingsButton, imagePreviewHandler, iconComponentFor, readOnly] = useCellValues(
52
52
  disableImageResize$,
53
+ disableImageSettingsButton$,
53
54
  imagePreviewHandler$,
54
55
  iconComponentFor$,
55
56
  readOnly$
@@ -210,7 +211,7 @@ function ImageEditor({ src, title, alt, nodeKey, width, height }) {
210
211
  alt: alt || "",
211
212
  imageRef
212
213
  }
213
- )), draggable && isFocused && !disableImageResize && /* @__PURE__ */ React__default.createElement(ImageResizer, { editor, imageRef, onResizeStart, onResizeEnd }), /* @__PURE__ */ React__default.createElement(
214
+ )), draggable && isFocused && !disableImageResize && /* @__PURE__ */ React__default.createElement(ImageResizer, { editor, imageRef, onResizeStart, onResizeEnd }), !disableImageSettingsButton && /* @__PURE__ */ React__default.createElement(
214
215
  "button",
215
216
  {
216
217
  type: "button",
@@ -128,6 +128,7 @@ const openEditImageDialog$ = Signal((r) => {
128
128
  const closeImageDialog$ = Action((r) => {
129
129
  r.link(r.pipe(closeImageDialog$, mapTo({ type: "inactive" })), imageDialogState$);
130
130
  });
131
+ const disableImageSettingsButton$ = Cell(false);
131
132
  const saveImage$ = Signal();
132
133
  const imagePlugin = realmPlugin({
133
134
  init(realm, params) {
@@ -139,6 +140,7 @@ const imagePlugin = realmPlugin({
139
140
  [imageUploadHandler$]: (params == null ? void 0 : params.imageUploadHandler) || null,
140
141
  [imageAutocompleteSuggestions$]: (params == null ? void 0 : params.imageAutocompleteSuggestions) || [],
141
142
  [disableImageResize$]: Boolean(params == null ? void 0 : params.disableImageResize),
143
+ [disableImageSettingsButton$]: Boolean(params == null ? void 0 : params.disableImageSettingsButton),
142
144
  [imagePreviewHandler$]: (params == null ? void 0 : params.imagePreviewHandler) || null
143
145
  });
144
146
  },
@@ -286,6 +288,7 @@ export {
286
288
  ImageNode,
287
289
  closeImageDialog$,
288
290
  disableImageResize$,
291
+ disableImageSettingsButton$,
289
292
  imageAutocompleteSuggestions$,
290
293
  imageDialogState$,
291
294
  imagePlugin,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "2.13.2",
14
+ "version": "2.15.0",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",
@@ -41,15 +41,15 @@
41
41
  "@codemirror/state": "^6.4.0",
42
42
  "@codemirror/view": "^6.23.0",
43
43
  "@codesandbox/sandpack-react": "^2.10.0",
44
- "@lexical/clipboard": "^0.12.4",
45
- "@lexical/link": "^0.12.4",
46
- "@lexical/list": "^0.12.4",
47
- "@lexical/markdown": "^0.12.4",
48
- "@lexical/plain-text": "^0.12.4",
49
- "@lexical/react": "^0.12.4",
50
- "@lexical/rich-text": "^0.12.4",
51
- "@lexical/selection": "^0.12.4",
52
- "@lexical/utils": "^0.12.4",
44
+ "@lexical/clipboard": "^0.13.1",
45
+ "@lexical/link": "^0.13.1",
46
+ "@lexical/list": "^0.13.1",
47
+ "@lexical/markdown": "^0.13.1",
48
+ "@lexical/plain-text": "^0.13.1",
49
+ "@lexical/react": "^0.13.1",
50
+ "@lexical/rich-text": "^0.13.1",
51
+ "@lexical/selection": "^0.13.1",
52
+ "@lexical/utils": "^0.13.1",
53
53
  "@mdxeditor/gurx": "^1.1.1",
54
54
  "@radix-ui/colors": "^3.0.0",
55
55
  "@radix-ui/react-dialog": "^1.0.5",
@@ -64,7 +64,7 @@
64
64
  "codemirror": "^6.0.1",
65
65
  "downshift": "^7.6.0",
66
66
  "js-yaml": "4.1.0",
67
- "lexical": "^0.12.4",
67
+ "lexical": "^0.13.1",
68
68
  "mdast-util-directive": "^3.0.0",
69
69
  "mdast-util-from-markdown": "^2.0.0",
70
70
  "mdast-util-frontmatter": "^2.0.1",