mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 13:56:11 +01:00
Add '_regroup/ckeditor5-keyboard-marker/' from commit 'c875badc77499941b974c0e5ea7c24728a47e35d'
git-subtree-dir: _regroup/ckeditor5-keyboard-marker git-subtree-mainline:b5fa9f8ea4git-subtree-split:c875badc77
This commit is contained in:
44
_regroup/ckeditor5-keyboard-marker/src/KbdEditing.js
Normal file
44
_regroup/ckeditor5-keyboard-marker/src/KbdEditing.js
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
||||
import AttributeCommand from '@ckeditor/ckeditor5-basic-styles/src/attributecommand';
|
||||
|
||||
const KBD = 'kbd';
|
||||
|
||||
/**
|
||||
* The keyboard shortcut (`kbd`) editing feature.
|
||||
*
|
||||
* It registers the `'kbd'` command, associated keystroke and introduces the
|
||||
* `kbd` attribute in the model which renders to the view as a `<kbd>` element.
|
||||
*
|
||||
* @extends module:core/plugin~Plugin
|
||||
*/
|
||||
export default class KbdEditing extends Plugin {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
static get pluginName() {
|
||||
return 'KbdEditing';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
init() {
|
||||
const editor = this.editor;
|
||||
|
||||
// Allow kbd attribute on text nodes.
|
||||
editor.model.schema.extend( '$text', { allowAttributes: KBD } );
|
||||
editor.model.schema.setAttributeProperties( KBD, {
|
||||
isFormatting: true,
|
||||
copyOnEnter: true
|
||||
} );
|
||||
|
||||
editor.conversion.attributeToElement( {
|
||||
model: KBD,
|
||||
view: KBD
|
||||
} );
|
||||
|
||||
editor.commands.add( KBD, new AttributeCommand( editor, KBD ) );
|
||||
editor.keystrokes.set( 'CTRL+ALT+K', KBD );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user