|
|
|
@@ -8,8 +8,14 @@ import LinkPopover from "../../Popovers/LinkPopover/LinkPopover"; |
|
|
|
import PopoverComponent from "../../Popovers/PopoverComponent"; |
|
|
|
|
|
|
|
const toggleMark = (editor, format, link) => { |
|
|
|
Editor.addMark(editor, format, link); |
|
|
|
|
|
|
|
Editor.addMark(editor, format, link.url); |
|
|
|
if ( |
|
|
|
(editor?.selection && |
|
|
|
Editor.string(editor, editor.selection).length === 0) || |
|
|
|
!editor?.selection |
|
|
|
) { |
|
|
|
Editor.insertNode(editor, { text: link.link, a: link.url }); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const LinkButton = (props) => { |
|
|
|
@@ -17,9 +23,9 @@ const LinkButton = (props) => { |
|
|
|
const [isLinkPopoverShowing, setIsLinkPopoverShowing] = useState(false); |
|
|
|
const [linkPopoverAnchor, setLinkPopoverAnchor] = useState(null); |
|
|
|
|
|
|
|
const callbackFunction = (link) => { |
|
|
|
const callbackFunction = (linkObject) => { |
|
|
|
setIsLinkPopoverShowing(false); |
|
|
|
toggleMark(editor, "a", link); |
|
|
|
toggleMark(editor, "a", linkObject); |
|
|
|
}; |
|
|
|
const handleClickLinkButton = (event) => { |
|
|
|
setIsLinkPopoverShowing(true); |