This commit is contained in:
2026-01-29 23:49:03 +01:00
parent d8fcd65286
commit 5694b726f8
2 changed files with 24 additions and 13 deletions

View File

@@ -1 +1 @@
1.1.57
1.1.58

View File

@@ -918,28 +918,39 @@
linkApply.addEventListener('click', () => {
const url = String(linkInput.value || '').trim();
if (!url) {
exec('unlink');
hideLinkPanel();
linkRemove.click();
return;
}
try {
const linkEl = findLinkAtSelection();
if (linkEl) {
const docRef = content.ownerDocument || document;
const sel = docRef.getSelection();
if (sel && docRef.createRange) {
const range = docRef.createRange();
range.selectNodeContents(linkEl);
sel.removeAllRanges();
sel.addRange(range);
saveSelection();
}
if (linkEl && linkEl.setAttribute) {
linkEl.setAttribute('href', url);
hideLinkPanel();
return;
}
} catch {}
const range = getSelectionRange();
if (!range || range.collapsed) {
hideLinkPanel();
return;
}
restoreSelection();
exec('createLink', url);
hideLinkPanel();
});
linkRemove.addEventListener('click', () => {
try {
const linkEl = findLinkAtSelection();
if (linkEl && linkEl.parentNode) {
while (linkEl.firstChild) {
linkEl.parentNode.insertBefore(linkEl.firstChild, linkEl);
}
linkEl.parentNode.removeChild(linkEl);
hideLinkPanel();
return;
}
} catch {}
restoreSelection();
exec('unlink');
hideLinkPanel();
});