소스 검색

Fixed bug 2236

bugfix/2236-fix
Djordje Mitrovic 3 년 전
부모
커밋
4183c11a89

+ 4
- 1
src/components/Popovers/LinkPopover/LinkPopover.js 파일 보기

const handleClickFinishButton = () => { const handleClickFinishButton = () => {
let urlLink = linkValue.trim(); let urlLink = linkValue.trim();
if (urlLink.startsWith("http://") || urlLink.startsWith("https://")) if (urlLink.startsWith("http://") || urlLink.startsWith("https://"))
props?.callbackFunction(urlLink); else props?.callbackFunction(`http://${urlLink}`)
props?.callbackFunction(urlLink); else props?.callbackFunction({
url: `http://${urlLink}`,
link: urlLink
})
}; };


return ( return (

+ 10
- 4
src/components/RichTextComponent/LinkButton/LinkButton.js 파일 보기

import PopoverComponent from "../../Popovers/PopoverComponent"; import PopoverComponent from "../../Popovers/PopoverComponent";


const toggleMark = (editor, format, link) => { 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) => { const LinkButton = (props) => {
const [isLinkPopoverShowing, setIsLinkPopoverShowing] = useState(false); const [isLinkPopoverShowing, setIsLinkPopoverShowing] = useState(false);
const [linkPopoverAnchor, setLinkPopoverAnchor] = useState(null); const [linkPopoverAnchor, setLinkPopoverAnchor] = useState(null);


const callbackFunction = (link) => {
const callbackFunction = (linkObject) => {
setIsLinkPopoverShowing(false); setIsLinkPopoverShowing(false);
toggleMark(editor, "a", link);
toggleMark(editor, "a", linkObject);
}; };
const handleClickLinkButton = (event) => { const handleClickLinkButton = (event) => {
setIsLinkPopoverShowing(true); setIsLinkPopoverShowing(true);

+ 1
- 0
src/components/RichTextComponent/RichTextComponent.js 파일 보기

Editor.removeMark(editor, "a"); Editor.removeMark(editor, "a");
} }
} }
console.log(newValue);
if (props?.onChange) props?.onChange(JSON.stringify(newValue)); if (props?.onChange) props?.onChange(JSON.stringify(newValue));
else setValue(newValue); else setValue(newValue);
}} }}

Loading…
취소
저장