Insert markdown-style [text](url) links from the Link toolbar button
Previously this wrapped the selection in a real <a> tag via createLink. Now it inserts literal [text](url) markdown syntax, using the selection as the link text or prompting for it if nothing is selected.
This commit is contained in:
@@ -1825,8 +1825,12 @@ class GuideEditor {
|
|||||||
document.execCommand('formatBlock', false, block || 'blockquote');
|
document.execCommand('formatBlock', false, block || 'blockquote');
|
||||||
break;
|
break;
|
||||||
case 'createLink': {
|
case 'createLink': {
|
||||||
|
const selectedText = window.getSelection().toString();
|
||||||
|
const text = selectedText || window.prompt('Link text');
|
||||||
|
if (!text) break;
|
||||||
const url = window.prompt('Link URL');
|
const url = window.prompt('Link URL');
|
||||||
if (url) document.execCommand('createLink', false, url);
|
if (!url) break;
|
||||||
|
document.execCommand('insertText', false, `[${text}](${url})`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'removeFormat':
|
case 'removeFormat':
|
||||||
|
|||||||
Reference in New Issue
Block a user