@mdxeditor/editor 1.4.1 → 1.4.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.
@@ -91,10 +91,10 @@ const LinkDialog = () => {
91
91
  "data-visible": linkDialogState.type === "edit",
92
92
  className: styles.linkDialogAnchor,
93
93
  style: {
94
- top: theRect == null ? void 0 : theRect.top,
95
- left: theRect == null ? void 0 : theRect.left,
96
- width: theRect == null ? void 0 : theRect.width,
97
- height: theRect == null ? void 0 : theRect.height
94
+ top: `${(theRect == null ? void 0 : theRect.top) ?? 0}px`,
95
+ left: `${(theRect == null ? void 0 : theRect.left) ?? 0}px`,
96
+ width: `${(theRect == null ? void 0 : theRect.width) ?? 0}px`,
97
+ height: `${(theRect == null ? void 0 : theRect.height) ?? 0}px`
98
98
  }
99
99
  }
100
100
  ), /* @__PURE__ */ React__default.createElement(RadixPopover.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(
@@ -41,30 +41,32 @@ const linkDialogSystem = system(
41
41
  r.o.filter(([, selection]) => $isRangeSelection(selection))
42
42
  ),
43
43
  ([, selection, editor]) => {
44
- editor == null ? void 0 : editor.getEditorState().read(() => {
45
- const node = getLinkNodeInSelection(selection);
46
- const rectangle = getSelectionRectangle(editor);
47
- if (node) {
48
- r.pub(linkDialogState, {
49
- type: "edit",
50
- initialUrl: node.getURL(),
51
- initialTitle: node.getTitle() || "",
52
- url: node.getURL(),
53
- title: node.getTitle() || "",
54
- linkNodeKey: node.getKey(),
55
- rectangle
56
- });
57
- } else {
58
- r.pub(linkDialogState, {
59
- type: "edit",
60
- initialUrl: "",
61
- initialTitle: "",
62
- title: "",
63
- url: "",
64
- linkNodeKey: "",
65
- rectangle
66
- });
67
- }
44
+ editor == null ? void 0 : editor.focus(() => {
45
+ editor == null ? void 0 : editor.getEditorState().read(() => {
46
+ const node = getLinkNodeInSelection(selection);
47
+ const rectangle = getSelectionRectangle(editor);
48
+ if (node) {
49
+ r.pub(linkDialogState, {
50
+ type: "edit",
51
+ initialUrl: node.getURL(),
52
+ initialTitle: node.getTitle() || "",
53
+ url: node.getURL(),
54
+ title: node.getTitle() || "",
55
+ linkNodeKey: node.getKey(),
56
+ rectangle
57
+ });
58
+ } else {
59
+ r.pub(linkDialogState, {
60
+ type: "edit",
61
+ initialUrl: "",
62
+ initialTitle: "",
63
+ title: "",
64
+ url: "",
65
+ linkNodeKey: "",
66
+ rectangle
67
+ });
68
+ }
69
+ });
68
70
  });
69
71
  }
70
72
  );
@@ -94,6 +96,7 @@ const linkDialogSystem = system(
94
96
  if ($isRangeSelection(selection) && (getLinkNodeInSelection(selection) || !selection.isCollapsed())) {
95
97
  r.pub(openLinkEditDialog, true);
96
98
  event.stopPropagation();
99
+ event.preventDefault();
97
100
  return true;
98
101
  } else {
99
102
  return false;
@@ -4,7 +4,16 @@ import LinkIcon from "../../../icons/link.svg.js";
4
4
  import { linkDialogPluginHooks } from "../../link-dialog/index.js";
5
5
  const CreateLink = () => {
6
6
  const openLinkDialog = linkDialogPluginHooks.usePublisher("openLinkEditDialog");
7
- return /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: "Create link", onClick: (_) => openLinkDialog(true) }, /* @__PURE__ */ React__default.createElement(LinkIcon, null));
7
+ return /* @__PURE__ */ React__default.createElement(
8
+ ButtonWithTooltip,
9
+ {
10
+ title: "Create link",
11
+ onClick: (_) => {
12
+ openLinkDialog(true);
13
+ }
14
+ },
15
+ /* @__PURE__ */ React__default.createElement(LinkIcon, null)
16
+ );
8
17
  };
9
18
  export {
10
19
  CreateLink
@@ -37,10 +37,10 @@ function getSelectionRectangle(editor) {
37
37
  rect = domRange.getBoundingClientRect();
38
38
  }
39
39
  return {
40
- top: rect.top,
41
- left: rect.left,
42
- width: rect.width,
43
- height: rect.height
40
+ top: Math.round(rect.top),
41
+ left: Math.round(rect.left),
42
+ width: Math.round(rect.width),
43
+ height: Math.round(rect.height)
44
44
  };
45
45
  } else if (!activeElement || activeElement.className !== "link-input") {
46
46
  return null;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "private": false,
10
10
  "sideEffects": false,
11
11
  "type": "module",
12
- "version": "1.4.1",
12
+ "version": "1.4.2",
13
13
  "description": "React component for rich text markdown editing",
14
14
  "scripts": {
15
15
  "build": "vite build",