Skip to content

Commit 758ce51

Browse files
committed
fix: insert admonition commands now properly wrap selected text
1 parent 1c26bd9 commit 758ce51

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ export default class ObsidianAdmonition
523523
editor.getDoc().replaceSelection(
524524
`\`\`\`ad-${admonition.type}
525525
526+
${editor.getDoc().getSelection()}
527+
526528
\`\`\`\n`
527529
);
528530
const cursor = editor.getCursor();
@@ -546,6 +548,8 @@ export default class ObsidianAdmonition
546548
`\`\`\`ad-${admonition.type}
547549
title:
548550
551+
${editor.getDoc().getSelection()}
552+
549553
\`\`\`\n`
550554
);
551555
const cursor = editor.getCursor();
@@ -570,11 +574,10 @@ title:
570574
);
571575
if (admonition.command) {
572576
try {
573-
editor
574-
.getDoc()
575-
.replaceSelection(
576-
`!!! ad-${admonition.type}\n\n--- admonition\n`
577-
);
577+
editor.getDoc().replaceSelection(
578+
`!!! ad-${admonition.type}\n
579+
${editor.getDoc().getSelection()}\n--- admonition\n`
580+
);
578581
const cursor = editor.getCursor();
579582
editor.setCursor(cursor.line - 2);
580583
} catch (e) {

0 commit comments

Comments
 (0)