Skip to content

Commit

Permalink
fix: removing delete jump to link
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvente committed Apr 2, 2024
1 parent a8c88b5 commit edbbd18
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/editors/sharedComponents/InsertLinkModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const InsertLinkModal = ({
const editor = editorRef.current;
const urlPath = blockSelected?.lmsWebUrl || inputUrlValue;
const blockId = blockSelected?.blockId;
const linkRegex = /<a\b[^>]*><\/a>/gi;
if (editor && urlPath) {
const validateUrl = isValidURL(urlPath);

Expand All @@ -78,12 +79,19 @@ const InsertLinkModal = ({
selectedRange.insertNode(newLinkNode);
// Remove empty "a" tags after replacing URLs
const editorContent = editor.getContent();
const modifiedContent = editorContent.replace(/<a\b[^>]*><\/a>/gi, '');
const modifiedContent = editorContent.replace(linkRegex, '');
editor.setContent(modifiedContent);

dispatch(actions.addBlock({ [blockId]: blockSelected }));
}

if(!blockId){
editor.execCommand('unlink');
const editorContent = editor.getContent();
const modifiedContent = editorContent.replace(linkRegex, '');
editor.setContent(modifiedContent);
}

onClose();
};

Expand Down

0 comments on commit edbbd18

Please sign in to comment.