export const removeLink = () => { return (state, dispatch) => { const { doc, selection, tr } = state; const { $head: { pos }, from, to } = selection; // if the cursor is on the link without any selection if (from === to) { const $pos = doc.resolve(pos); const linkStart = pos - $pos.textOffset; const linkEnd = linkStart + $pos.parent.child($pos.index()).nodeSize; tr.removeMark(linkStart, linkEnd); } else { tr.removeMark(from, to); } if (!tr.docChanged) { return false; } dispatch?.(tr); return true; }; }; export default removeLink; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVtb3ZlTGluay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL25neC1lZGl0b3IvY29tbWFuZHMvcmVtb3ZlTGluay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxNQUFNLENBQUMsTUFBTSxVQUFVLEdBQUcsR0FBWSxFQUFFO0lBQ3RDLE9BQU8sQ0FBQyxLQUFrQixFQUFFLFFBQW9DLEVBQVcsRUFBRTtRQUMzRSxNQUFNLEVBQUUsR0FBRyxFQUFFLFNBQVMsRUFBRSxFQUFFLEVBQUUsR0FBRyxLQUFLLENBQUM7UUFDckMsTUFBTSxFQUFFLEtBQUssRUFBRSxFQUFFLEdBQUcsRUFBRSxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsR0FBRyxTQUFTLENBQUM7UUFFL0MscURBQXFEO1FBQ3JELElBQUksSUFBSSxLQUFLLEVBQUUsRUFBRTtZQUNmLE1BQU0sSUFBSSxHQUFHLEdBQUcsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLENBQUM7WUFDOUIsTUFBTSxTQUFTLEdBQUcsR0FBRyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUM7WUFDeEMsTUFBTSxPQUFPLEdBQUcsU0FBUyxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQyxDQUFDL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