mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Fixed pasting links in koenig basic html input (#16584)
refs https://github.com/TryGhost/Team/issues/2680 When selecting a portion of text in KoenigBasicHtmlInput (caption input for images, newsletter footer text input, new signup notice), and then pasting a link, some funky things happen: - Part of the text disappears - The wrong part of the text is linked The cause of this is that `KoenigBasicHtmlInput` deletes the selected text range when pasting, even when pasting a link. so moving that part below the code that detected a valid link, fixes the issue. This also adds an option to not close an old style modal when pressing the enter key (e.g. pressing enter when entering a link causes the modal to close).
This commit is contained in:
parent
726246b80e
commit
ed1ae60bec
3 changed files with 11 additions and 7 deletions
|
@ -7,6 +7,7 @@ export default Component.extend({
|
|||
classNames: 'modal-content',
|
||||
|
||||
_previousKeymasterScope: null,
|
||||
closeOnEnter: true,
|
||||
|
||||
// Allowed Actions
|
||||
closeModal: () => {},
|
||||
|
@ -38,9 +39,11 @@ export default Component.extend({
|
|||
|
||||
this._previousKeymasterScope = key.getScope();
|
||||
|
||||
key('enter', 'modal', () => {
|
||||
this.send('confirm');
|
||||
});
|
||||
if (this.closeOnEnter) {
|
||||
key('enter', 'modal', () => {
|
||||
this.send('confirm');
|
||||
});
|
||||
}
|
||||
|
||||
key('escape', 'modal', (event) => {
|
||||
if (!event.target.dataset.preventEscapeCloseModal) {
|
||||
|
|
|
@ -28,6 +28,7 @@ export default ModalComponent.extend({
|
|||
changedTiers: null,
|
||||
openSection: null,
|
||||
portalPreviewGuid: 'modal-portal-settings',
|
||||
closeOnEnter: false,
|
||||
|
||||
confirm() {},
|
||||
|
||||
|
|
|
@ -315,10 +315,6 @@ export default class KoenigBasicHtmlInput extends Component {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!range.isCollapsed) {
|
||||
editor.performDelete();
|
||||
}
|
||||
|
||||
if (editor.post.isBlank) {
|
||||
editor._insertEmptyMarkupSectionAtCursor();
|
||||
}
|
||||
|
@ -337,6 +333,10 @@ export default class KoenigBasicHtmlInput extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
if (!range.isCollapsed) {
|
||||
editor.performDelete();
|
||||
}
|
||||
|
||||
const position = editor.range.head;
|
||||
const targetFormat = event.shiftKey ? 'text' : 'html';
|
||||
const pastedPost = parsePostFromPaste(event, editor, {targetFormat});
|
||||
|
|
Loading…
Add table
Reference in a new issue