@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.js
CHANGED
|
@@ -3193,24 +3193,21 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3193
3193
|
const inputRef = React9.useRef(null);
|
|
3194
3194
|
const $updateLinkEditor = React9.useCallback(() => {
|
|
3195
3195
|
const selection = lexical.$getSelection();
|
|
3196
|
+
let hasLink = false;
|
|
3196
3197
|
if (lexical.$isRangeSelection(selection)) {
|
|
3197
3198
|
const node = getSelectedNode2(selection);
|
|
3198
3199
|
const linkParent = utils.$findMatchingParent(node, link.$isLinkNode);
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
setLinkUrl(node.getURL());
|
|
3203
|
-
} else {
|
|
3204
|
-
setLinkUrl("");
|
|
3205
|
-
}
|
|
3200
|
+
hasLink = !!linkParent || link.$isLinkNode(node);
|
|
3201
|
+
const url = linkParent ? linkParent.getURL() : link.$isLinkNode(node) ? node.getURL() : "";
|
|
3202
|
+
setLinkUrl(url);
|
|
3206
3203
|
if (isLinkEditMode) {
|
|
3207
|
-
setEditedLinkUrl(
|
|
3204
|
+
setEditedLinkUrl(url);
|
|
3208
3205
|
}
|
|
3209
3206
|
}
|
|
3210
3207
|
const nativeSelection = lexical.getDOMSelection(editor._window);
|
|
3211
3208
|
const activeElement = document.activeElement;
|
|
3212
3209
|
const rootElement = editor.getRootElement();
|
|
3213
|
-
if (
|
|
3210
|
+
if (hasLink && selection !== null && nativeSelection !== null && rootElement !== null && rootElement.contains(nativeSelection.anchorNode) && editor.isEditable()) {
|
|
3214
3211
|
const domRect = nativeSelection.focusNode?.parentElement?.getBoundingClientRect();
|
|
3215
3212
|
if (domRect) {
|
|
3216
3213
|
setTarget({ getBoundingClientRect: () => domRect });
|
|
@@ -3223,7 +3220,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3223
3220
|
setLinkUrl("");
|
|
3224
3221
|
}
|
|
3225
3222
|
return true;
|
|
3226
|
-
}, [editor, setIsLinkEditMode, isLinkEditMode
|
|
3223
|
+
}, [editor, setIsLinkEditMode, isLinkEditMode]);
|
|
3227
3224
|
React9.useEffect(() => {
|
|
3228
3225
|
const update = () => {
|
|
3229
3226
|
editor.getEditorState().read(() => {
|
|
@@ -3291,6 +3288,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3291
3288
|
if (lastSelection !== null) {
|
|
3292
3289
|
if (linkUrl !== "") {
|
|
3293
3290
|
editor.update(() => {
|
|
3291
|
+
lexical.$setSelection(lastSelection.clone());
|
|
3294
3292
|
editor.dispatchCommand(
|
|
3295
3293
|
link.TOGGLE_LINK_COMMAND,
|
|
3296
3294
|
sanitizeUrl(editedLinkUrl)
|
|
@@ -3379,6 +3377,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3379
3377
|
href: sanitizeUrl(linkUrl),
|
|
3380
3378
|
target: "_blank",
|
|
3381
3379
|
rel: "noopener noreferrer",
|
|
3380
|
+
onMouseDown: preventDefault,
|
|
3382
3381
|
style: {
|
|
3383
3382
|
padding: "0 8px",
|
|
3384
3383
|
overflow: "hidden",
|
|
@@ -6559,6 +6558,7 @@ var InsertLinkPlugin = ({
|
|
|
6559
6558
|
opacity: disabled ? 0.55 : 1,
|
|
6560
6559
|
cursor: disabled ? "not-allowed" : "pointer"
|
|
6561
6560
|
},
|
|
6561
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
6562
6562
|
onClick: insertLink
|
|
6563
6563
|
},
|
|
6564
6564
|
"insert-link"
|