@tarviks/lexical-rich-editor 1.3.6 → 1.3.8
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.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3172,24 +3172,21 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3172
3172
|
const inputRef = useRef(null);
|
|
3173
3173
|
const $updateLinkEditor = useCallback(() => {
|
|
3174
3174
|
const selection = $getSelection();
|
|
3175
|
+
let hasLink = false;
|
|
3175
3176
|
if ($isRangeSelection(selection)) {
|
|
3176
3177
|
const node = getSelectedNode2(selection);
|
|
3177
3178
|
const linkParent = $findMatchingParent$1(node, $isLinkNode);
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
setLinkUrl(node.getURL());
|
|
3182
|
-
} else {
|
|
3183
|
-
setLinkUrl("");
|
|
3184
|
-
}
|
|
3179
|
+
hasLink = !!linkParent || $isLinkNode(node);
|
|
3180
|
+
const url = linkParent ? linkParent.getURL() : $isLinkNode(node) ? node.getURL() : "";
|
|
3181
|
+
setLinkUrl(url);
|
|
3185
3182
|
if (isLinkEditMode) {
|
|
3186
|
-
setEditedLinkUrl(
|
|
3183
|
+
setEditedLinkUrl(url);
|
|
3187
3184
|
}
|
|
3188
3185
|
}
|
|
3189
3186
|
const nativeSelection = getDOMSelection(editor._window);
|
|
3190
3187
|
const activeElement = document.activeElement;
|
|
3191
3188
|
const rootElement = editor.getRootElement();
|
|
3192
|
-
if (
|
|
3189
|
+
if (hasLink && selection !== null && nativeSelection !== null && rootElement !== null && rootElement.contains(nativeSelection.anchorNode) && editor.isEditable()) {
|
|
3193
3190
|
const domRect = nativeSelection.focusNode?.parentElement?.getBoundingClientRect();
|
|
3194
3191
|
if (domRect) {
|
|
3195
3192
|
setTarget({ getBoundingClientRect: () => domRect });
|
|
@@ -3202,7 +3199,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3202
3199
|
setLinkUrl("");
|
|
3203
3200
|
}
|
|
3204
3201
|
return true;
|
|
3205
|
-
}, [editor, setIsLinkEditMode, isLinkEditMode
|
|
3202
|
+
}, [editor, setIsLinkEditMode, isLinkEditMode]);
|
|
3206
3203
|
useEffect(() => {
|
|
3207
3204
|
const update = () => {
|
|
3208
3205
|
editor.getEditorState().read(() => {
|
|
@@ -3270,6 +3267,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3270
3267
|
if (lastSelection !== null) {
|
|
3271
3268
|
if (linkUrl !== "") {
|
|
3272
3269
|
editor.update(() => {
|
|
3270
|
+
$setSelection(lastSelection.clone());
|
|
3273
3271
|
editor.dispatchCommand(
|
|
3274
3272
|
TOGGLE_LINK_COMMAND,
|
|
3275
3273
|
sanitizeUrl(editedLinkUrl)
|
|
@@ -3358,6 +3356,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3358
3356
|
href: sanitizeUrl(linkUrl),
|
|
3359
3357
|
target: "_blank",
|
|
3360
3358
|
rel: "noopener noreferrer",
|
|
3359
|
+
onMouseDown: preventDefault,
|
|
3361
3360
|
style: {
|
|
3362
3361
|
padding: "0 8px",
|
|
3363
3362
|
overflow: "hidden",
|
|
@@ -6538,6 +6537,7 @@ var InsertLinkPlugin = ({
|
|
|
6538
6537
|
opacity: disabled ? 0.55 : 1,
|
|
6539
6538
|
cursor: disabled ? "not-allowed" : "pointer"
|
|
6540
6539
|
},
|
|
6540
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
6541
6541
|
onClick: insertLink
|
|
6542
6542
|
},
|
|
6543
6543
|
"insert-link"
|