mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
Fix issue with select text -> add link not working
This commit is contained in:
parent
36cb343fd2
commit
6d47e650fc
1 changed files with 8 additions and 1 deletions
|
@ -156,7 +156,14 @@ export default class LinkManager extends ContenteditableExtension {
|
|||
const html = '<prompt-link>link text</prompt-link>';
|
||||
editor.insertHTML(html, { selectInsertion: true });
|
||||
} else {
|
||||
editor.wrapSelection('prompt-link');
|
||||
const sel = document.getSelection();
|
||||
const range = sel.getRangeAt(0);
|
||||
const newNode = document.createElement('prompt-link');
|
||||
range.surroundContents(newNode);
|
||||
const newRange = document.createRange();
|
||||
newRange.selectNodeContents(newNode);
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(newRange);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue