mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
🐛 Koenig - Fixed pasting content into a container card (HTML, markdown, code)
refs https://github.com/TryGhost/Ghost/issues/9623 - pasting inside a container card such as markdown or HTML would paste content into the card and duplicate that content outside of the card, exiting the card's edit mode in the process - use the same "addressable" check that mobiledoc-kit's event manager uses
This commit is contained in:
parent
7438eb05e9
commit
7846192ac3
@ -637,11 +637,20 @@ export default Component.extend({
|
||||
|
||||
handlePaste(event) {
|
||||
let editor = this.editor;
|
||||
let {target: element} = event;
|
||||
|
||||
// don't trigger our paste handling for pastes within cards or outside
|
||||
// of the editor canvas. Avoids double-paste of content when pasting
|
||||
// into cards
|
||||
if (!editor.cursor.isAddressable(element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let range = editor.range;
|
||||
let {html, text} = getContentFromPasteEvent(event);
|
||||
|
||||
// if a URL is pasted and we have a selection, make that selection a link
|
||||
if (range && !range.isCollapsed && range.headSection === range.tailSection && range.headSection.isMarkerable) {
|
||||
let {text} = getContentFromPasteEvent(event);
|
||||
if (text && validator.isURL(text)) {
|
||||
let linkMarkup = editor.builder.createMarkup('a', {href: text});
|
||||
editor.run((postEditor) => {
|
||||
@ -659,7 +668,6 @@ export default Component.extend({
|
||||
// we get better output than mobiledoc's default text parsing and we can
|
||||
// provide an easier MD->Mobiledoc conversion route
|
||||
// NOTE: will not work in IE/Edge which only ever expose `html`
|
||||
let {html, text} = getContentFromPasteEvent(event);
|
||||
if (text && !html && !this._modifierKeys.shift) {
|
||||
// prevent mobiledoc's default paste event handler firing
|
||||
event.preventDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user