Added code formatting key command support to <KoenigBasicHtmlTextarea>

no issue

- the component was still using the text-replacement component's key commands which didn't include code formatting because code in text-replacement component is re-purposed for replacement string highlights
This commit is contained in:
Kevin Ansfield 2021-11-18 11:28:41 +00:00
parent 8d1c1731eb
commit ca89bc9522
2 changed files with 18 additions and 2 deletions

View File

@ -3,7 +3,7 @@ import Component from '@ember/component';
import Editor from 'mobiledoc-kit/editor/editor';
import cleanBasicHtml from '@tryghost/kg-clean-basic-html';
import defaultAtoms from '../options/atoms';
import registerKeyCommands, {TEXT_REPLACEMENT_KEY_COMMANDS} from '../options/key-commands';
import registerKeyCommands, {BASIC_TEXTAREA_KEY_COMMANDS} from '../options/key-commands';
import validator from 'validator';
import {BLANK_DOC, MOBILEDOC_VERSION} from './koenig-editor';
import {DRAG_DISABLED_DATA_ATTR} from '../lib/dnd/constants';
@ -165,7 +165,7 @@ export default Component.extend({
editor = new Editor(editorOptions);
registerKeyCommands(editor, this, TEXT_REPLACEMENT_KEY_COMMANDS);
registerKeyCommands(editor, this, BASIC_TEXTAREA_KEY_COMMANDS);
registerTextReplacementTextExpansions(editor, this);
// set up editor hooks

View File

@ -434,7 +434,23 @@ export const BASIC_KEY_COMMANDS = DEFAULT_KEY_COMMANDS.filter((command) => {
return basicCommands.includes(command.str);
});
// key commands that are used in koenig-basic-html-textarea
export const BASIC_TEXTAREA_KEY_COMMANDS = DEFAULT_KEY_COMMANDS.filter((command) => {
let basicCommands = [
'BACKSPACE',
'CTRL+K',
'META+K',
'CTRL+ALT+U',
'CTRL+SHIFT+K',
'META+SHIFT+K',
'ENTER',
'SHIFT+ENTER'
];
return basicCommands.includes(command.str);
});
// key commands that are used in koenig-text-replacement-html-input
// (code formatting is not allowed here because it's used to highlight replacement strings)
export const TEXT_REPLACEMENT_KEY_COMMANDS = DEFAULT_KEY_COMMANDS.filter((command) => {
let commands = [
'BACKSPACE',