Insert markdown-style [text](url) links from the Link toolbar button
Template tests / tests (push) Successful in 1m40s
Template tests / tests (pull_request) Successful in 1m40s

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:
2026-06-13 20:47:16 -05:00
parent 8e2e1f41fb
commit 46d12cc829
+5 -1
View File
@@ -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':