From 608562a297f077e7547ac4315d11f61e25ef47c3 Mon Sep 17 00:00:00 2001 From: Giamir Buoncristiani Date: Thu, 6 Apr 2023 13:58:45 +0200 Subject: [PATCH] fix(commands): update commonmark to select link instead of text See https://meta.stackoverflow.com/a/423576/5541798 for more context about this change --- src/commonmark/commands.ts | 4 ++-- test/commonmark/commands.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commonmark/commands.ts b/src/commonmark/commands.ts index 48ecd4df..7f481756 100644 --- a/src/commonmark/commands.ts +++ b/src/commonmark/commands.ts @@ -600,8 +600,8 @@ export function insertCommonmarkLinkCommand( if (state.selection.empty) { return insertRawText( "[text](" + dummyLink + ")", - 1, - 5, + 7, // length of "[text](" before the dummyLink + 7 + dummyLink.length, state, dispatch ); diff --git a/test/commonmark/commands.test.ts b/test/commonmark/commands.test.ts index 1f318011..903d57fb 100644 --- a/test/commonmark/commands.test.ts +++ b/test/commonmark/commands.test.ts @@ -772,7 +772,7 @@ some text`; expect(state).transactionSuccess( commands.insertCommonmarkLinkCommand, "[text](http://localhost)", - "text" + "http://localhost" ); });