From 7b09fedae2f975f719e426b698200aef967245d6 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 2 Aug 2018 15:10:00 +0100 Subject: [PATCH] Koenig - Do not select embed card when auto-converting pasted URL refs https://github.com/TryGhost/Ghost/issues/9724 - selecting the embed card as soon as it's created causes problems with the caption input grabbing focus which interferes with being able to continue typing - if content exists after the paste move the cursor to the beginning of the next section, otherwise create a blank paragraph and move the cursor into that --- .../koenig-editor/addon/components/koenig-editor.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js index a437180647..ddaa6d8799 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-editor.js @@ -807,7 +807,19 @@ export default Component.extend({ editor.run((postEditor) => { let payload = {url: text, linkOnError: true}; let card = postEditor.builder.createCardSection('embed', payload); + let nextSection = range.headSection.next; + postEditor.replaceSection(range.headSection, card); + + // move caret to the next section, creating a blank one + // if none exists + if (nextSection) { + postEditor.setRange(nextSection.headPosition()); + } else { + let newSection = postEditor.builder.createMarkupSection('p'); + postEditor.insertSectionAtEnd(newSection); + postEditor.setRange(newSection.headPosition()); + } }); } else { // ensure the pasted URL is still auto-linked when Shift is pressed