chore: fix link button
This commit is contained in:
@@ -57,13 +57,6 @@ const FloatingLinkEditor = ({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const linkEditorElement = linkEditorRef.current
|
|
||||||
|
|
||||||
if (!linkEditorElement) {
|
|
||||||
setTimeout(updateLinkEditorPosition)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const nativeSelection = window.getSelection()
|
const nativeSelection = window.getSelection()
|
||||||
const rootElement = editor.getRootElement()
|
const rootElement = editor.getRootElement()
|
||||||
|
|
||||||
@@ -71,6 +64,19 @@ const FloatingLinkEditor = ({
|
|||||||
if (rootElement.contains(nativeSelection.anchorNode)) {
|
if (rootElement.contains(nativeSelection.anchorNode)) {
|
||||||
rangeRect.current = getDOMRangeRect(nativeSelection, rootElement)
|
rangeRect.current = getDOMRangeRect(nativeSelection, rootElement)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const linkEditorElement = linkEditorRef.current
|
||||||
|
|
||||||
|
if (!linkEditorElement) {
|
||||||
|
setTimeout(updateLinkEditorPosition)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rootElement) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const linkEditorRect = linkEditorElement.getBoundingClientRect()
|
const linkEditorRect = linkEditorElement.getBoundingClientRect()
|
||||||
const rootElementRect = rootElement.getBoundingClientRect()
|
const rootElementRect = rootElement.getBoundingClientRect()
|
||||||
|
|
||||||
@@ -89,7 +95,6 @@ const FloatingLinkEditor = ({
|
|||||||
})
|
})
|
||||||
linkEditorElement.style.opacity = '1'
|
linkEditorElement.style.opacity = '1'
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [editor, isMobile])
|
}, [editor, isMobile])
|
||||||
|
|
||||||
useElementResize(linkEditorRef.current, updateLinkEditorPosition)
|
useElementResize(linkEditorRef.current, updateLinkEditorPosition)
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ const ToolbarPlugin = () => {
|
|||||||
return activeEditor.dispatchCommand(TOGGLE_LINK_COMMAND, null)
|
return activeEditor.dispatchCommand(TOGGLE_LINK_COMMAND, null)
|
||||||
} else if (typeof payload === 'string') {
|
} else if (typeof payload === 'string') {
|
||||||
const dispatched = activeEditor.dispatchCommand(TOGGLE_LINK_COMMAND, payload)
|
const dispatched = activeEditor.dispatchCommand(TOGGLE_LINK_COMMAND, payload)
|
||||||
|
setIsLink(true)
|
||||||
setLinkUrl(payload)
|
setLinkUrl(payload)
|
||||||
setIsLinkEditMode(true)
|
setIsLinkEditMode(true)
|
||||||
return dispatched
|
return dispatched
|
||||||
|
|||||||
Reference in New Issue
Block a user