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();
return;
}
restoreSelection();
const range = savedRange ? savedRange.cloneRange() : getSelectionRange();
if (!range || range.collapsed) {
hideLinkPanel();
return;
}
try {
const linkEl = findLinkAtSelection();
if (linkEl && linkEl.setAttribute) {
@@ -952,23 +958,19 @@
return;
}
} catch {}
const range = savedRange ? savedRange.cloneRange() : getSelectionRange();
if (!range || range.collapsed) {
hideLinkPanel();
return;
}
try {
const docRef = content.ownerDocument || document;
const anchor = docRef.createElement('a');
anchor.setAttribute('href', url);
anchor.setAttribute('target', '_blank');
anchor.setAttribute('rel', 'noopener');
const fragment = range.extractContents();
anchor.appendChild(fragment);
range.insertNode(anchor);
} catch {
restoreSelection();
exec('createLink', url);
exec('createLink', url);
const linkAfter = findLinkAtSelection();
if (!linkAfter) {
try {
const docRef = content.ownerDocument || document;
const anchor = docRef.createElement('a');
anchor.setAttribute('href', url);
anchor.setAttribute('target', '_blank');
anchor.setAttribute('rel', 'noopener');
const fragment = range.extractContents();
anchor.appendChild(fragment);
range.insertNode(anchor);
} catch {}
}
hideLinkPanel();
});
@@ -986,6 +988,13 @@
} catch {}
restoreSelection();
exec('unlink');
const stillLinked = findLinkAtSelection();
if (stillLinked && stillLinked.parentNode) {
while (stillLinked.firstChild) {
stillLinked.parentNode.insertBefore(stillLinked.firstChild, stillLinked);
}
stillLinked.parentNode.removeChild(stillLinked);
}
hideLinkPanel();
});
linkCancel.addEventListener('click', hideLinkPanel);