@mdxeditor/editor 3.52.0 → 3.52.2

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.
@@ -1,4 +1,4 @@
1
- import { $isLinkNode, $createLinkNode, TOGGLE_LINK_COMMAND, LinkNode } from "@lexical/link";
1
+ import { $isLinkNode, $createLinkNode, $isAutoLinkNode, TOGGLE_LINK_COMMAND, LinkNode } from "@lexical/link";
2
2
  import { Signal, Cell, Action, withLatestFrom, map, filter } from "@mdxeditor/gurx";
3
3
  import { KEY_ESCAPE_COMMAND, COMMAND_PRIORITY_LOW, KEY_MODIFIER_COMMAND, $getSelection, $isRangeSelection, COMMAND_PRIORITY_HIGH, $getNodeByKey, $createTextNode, $insertNodes, $isTextNode, $getNearestNodeFromDOMNode } from "lexical";
4
4
  import { realmPlugin } from "../../RealmWithPlugins.js";
@@ -104,9 +104,16 @@ const linkDialogState$ = Cell({ type: "inactive" }, (r) => {
104
104
  $insertNodes([node]);
105
105
  node.select();
106
106
  } else {
107
- linkNode.setURL(url);
108
- linkNode.setTitle(title);
109
- updateLinkText(linkNode.getFirstChild(), text);
107
+ if ($isAutoLinkNode(linkNode)) {
108
+ const newLinkNode = $createLinkNode(url, { title });
109
+ newLinkNode.append($createTextNode(text));
110
+ linkNode.replace(newLinkNode);
111
+ newLinkNode.select();
112
+ } else {
113
+ linkNode.setURL(url);
114
+ linkNode.setTitle(title);
115
+ updateLinkText(linkNode.getFirstChild(), text);
116
+ }
110
117
  }
111
118
  },
112
119
  { discrete: true }
@@ -166,6 +173,8 @@ const linkDialogState$ = Cell({ type: "inactive" }, (r) => {
166
173
  map(([[selection], activeEditor, _, readOnly]) => {
167
174
  if ($isRangeSelection(selection) && activeEditor && !readOnly) {
168
175
  const node = getLinkNodeInSelection(selection);
176
+ if (!selection.isCollapsed())
177
+ return { type: "inactive" };
169
178
  if (node) {
170
179
  const rect = getSelectionRectangle(activeEditor);
171
180
  if (!rect) {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.52.0",
14
+ "version": "3.52.2",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",