This commit is contained in:
2026-01-30 00:24:02 +01:00
parent 2727af68a5
commit d60e2522d9
2 changed files with 27 additions and 18 deletions

View File

@@ -1 +1 @@
1.1.59 1.1.60

View File

@@ -944,6 +944,12 @@
hideLinkPanel(); hideLinkPanel();
return; return;
} }
restoreSelection();
const range = savedRange ? savedRange.cloneRange() : getSelectionRange();
if (!range || range.collapsed) {
hideLinkPanel();
return;
}
try { try {
const linkEl = findLinkAtSelection(); const linkEl = findLinkAtSelection();
if (linkEl && linkEl.setAttribute) { if (linkEl && linkEl.setAttribute) {
@@ -952,11 +958,9 @@
return; return;
} }
} catch {} } catch {}
const range = savedRange ? savedRange.cloneRange() : getSelectionRange(); exec('createLink', url);
if (!range || range.collapsed) { const linkAfter = findLinkAtSelection();
hideLinkPanel(); if (!linkAfter) {
return;
}
try { try {
const docRef = content.ownerDocument || document; const docRef = content.ownerDocument || document;
const anchor = docRef.createElement('a'); const anchor = docRef.createElement('a');
@@ -966,9 +970,7 @@
const fragment = range.extractContents(); const fragment = range.extractContents();
anchor.appendChild(fragment); anchor.appendChild(fragment);
range.insertNode(anchor); range.insertNode(anchor);
} catch { } catch {}
restoreSelection();
exec('createLink', url);
} }
hideLinkPanel(); hideLinkPanel();
}); });
@@ -986,6 +988,13 @@
} catch {} } catch {}
restoreSelection(); restoreSelection();
exec('unlink'); exec('unlink');
const stillLinked = findLinkAtSelection();
if (stillLinked && stillLinked.parentNode) {
while (stillLinked.firstChild) {
stillLinked.parentNode.insertBefore(stillLinked.firstChild, stillLinked);
}
stillLinked.parentNode.removeChild(stillLinked);
}
hideLinkPanel(); hideLinkPanel();
}); });
linkCancel.addEventListener('click', hideLinkPanel); linkCancel.addEventListener('click', hideLinkPanel);