@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.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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(
|
|
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;
|