|
@@ -11,7 +11,31 @@ import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
|
|
import Plugin from './plugin';
|
|
import Plugin from './plugin';
|
|
|
import MultiCommand from './multicommand';
|
|
import MultiCommand from './multicommand';
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * The indent feature.
|
|
|
|
|
+ *
|
|
|
|
|
+ * This plugin acts as a single entry point plugin for other features that implements indenting of elements like list or paragraphs.
|
|
|
|
|
+ *
|
|
|
|
|
+ * It registers the `'indent'` and `'outdent'` commands and it introduces the `'indent'` and `'outdent'` buttons that allow to
|
|
|
|
|
+ * increase or decrease text indentation of supported elements.
|
|
|
|
|
+ *
|
|
|
|
|
+ * The compatible features are:
|
|
|
|
|
+ * - the {@link module:list/list~List list} or {@link module:list/listediting~ListEditing list editing} feature for list indentation
|
|
|
|
|
+ * - the {@link module:indent-block/indentblock~IndentBlock block indentation} feature for indenting text blocks like paragraphs or headings
|
|
|
|
|
+ *
|
|
|
|
|
+ * **Note**: In order the commands and buttons to work at least one of compatible features is required.
|
|
|
|
|
+ */
|
|
|
export default class Indent extends Plugin {
|
|
export default class Indent extends Plugin {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritDoc
|
|
|
|
|
+ */
|
|
|
|
|
+ static get pluginName() {
|
|
|
|
|
+ return 'Indent';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritDoc
|
|
|
|
|
+ */
|
|
|
init() {
|
|
init() {
|
|
|
const editor = this.editor;
|
|
const editor = this.editor;
|
|
|
const t = editor.t;
|
|
const t = editor.t;
|
|
@@ -19,19 +43,18 @@ export default class Indent extends Plugin {
|
|
|
editor.commands.add( 'indent', new MultiCommand( editor ) );
|
|
editor.commands.add( 'indent', new MultiCommand( editor ) );
|
|
|
editor.commands.add( 'outdent', new MultiCommand( editor ) );
|
|
editor.commands.add( 'outdent', new MultiCommand( editor ) );
|
|
|
|
|
|
|
|
- this._createButton( 'indent', t( '>' ) );
|
|
|
|
|
- this._createButton( 'outdent', t( '<' ) );
|
|
|
|
|
-
|
|
|
|
|
- // TODO: temporary - tests only
|
|
|
|
|
- this._createButton( 'indentList', t( '> List' ) );
|
|
|
|
|
- this._createButton( 'outdentList', t( '< List' ) );
|
|
|
|
|
-
|
|
|
|
|
- // TODO: temporary - tests only
|
|
|
|
|
- this._createButton( 'indentBlock', t( '> Block' ) );
|
|
|
|
|
- this._createButton( 'outdentBlock', t( '< Block' ) );
|
|
|
|
|
|
|
+ this._defineButton( 'indent', t( 'Increase indent' ) );
|
|
|
|
|
+ this._defineButton( 'outdent', t( 'Decrease indent' ) );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- _createButton( commandName, label ) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Defines an UI button.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {String} commandName
|
|
|
|
|
+ * @param {String} label
|
|
|
|
|
+ * @private
|
|
|
|
|
+ */
|
|
|
|
|
+ _defineButton( commandName, label ) {
|
|
|
const editor = this.editor;
|
|
const editor = this.editor;
|
|
|
|
|
|
|
|
editor.ui.componentFactory.add( commandName, locale => {
|
|
editor.ui.componentFactory.add( commandName, locale => {
|
|
@@ -46,7 +69,6 @@ export default class Indent extends Plugin {
|
|
|
|
|
|
|
|
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
|
|
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
|
|
|
|
|
|
|
|
- // Execute command.
|
|
|
|
|
this.listenTo( view, 'execute', () => editor.execute( commandName ) );
|
|
this.listenTo( view, 'execute', () => editor.execute( commandName ) );
|
|
|
|
|
|
|
|
return view;
|
|
return view;
|