@ckeditor/ckeditor5-indent 40.0.0 → 40.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,42 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * The block indentation behavior that uses offsets to set indentation.
7
- */
8
- export default class IndentUsingOffset {
9
- /**
10
- * Creates an instance of the indentation behavior.
11
- *
12
- * @param config.direction The direction of indentation.
13
- * @param config.offset The offset of the next indentation step.
14
- * @param config.unit Indentation unit.
15
- */
16
- constructor(config) {
17
- this.isForward = config.direction === 'forward';
18
- this.offset = config.offset;
19
- this.unit = config.unit;
20
- }
21
- /**
22
- * @inheritDoc
23
- */
24
- checkEnabled(indentAttributeValue) {
25
- const currentOffset = parseFloat(indentAttributeValue || '0');
26
- // The command is always enabled for forward indentation.
27
- return this.isForward || currentOffset > 0;
28
- }
29
- /**
30
- * @inheritDoc
31
- */
32
- getNextIndent(indentAttributeValue) {
33
- const currentOffset = parseFloat(indentAttributeValue || '0');
34
- const isSameUnit = !indentAttributeValue || indentAttributeValue.endsWith(this.unit);
35
- if (!isSameUnit) {
36
- return this.isForward ? this.offset + this.unit : undefined;
37
- }
38
- const nextOffset = this.isForward ? this.offset : -this.offset;
39
- const offsetToSet = currentOffset + nextOffset;
40
- return offsetToSet > 0 ? offsetToSet + this.unit : undefined;
41
- }
42
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * The block indentation behavior that uses offsets to set indentation.
7
+ */
8
+ export default class IndentUsingOffset {
9
+ /**
10
+ * Creates an instance of the indentation behavior.
11
+ *
12
+ * @param config.direction The direction of indentation.
13
+ * @param config.offset The offset of the next indentation step.
14
+ * @param config.unit Indentation unit.
15
+ */
16
+ constructor(config) {
17
+ this.isForward = config.direction === 'forward';
18
+ this.offset = config.offset;
19
+ this.unit = config.unit;
20
+ }
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ checkEnabled(indentAttributeValue) {
25
+ const currentOffset = parseFloat(indentAttributeValue || '0');
26
+ // The command is always enabled for forward indentation.
27
+ return this.isForward || currentOffset > 0;
28
+ }
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ getNextIndent(indentAttributeValue) {
33
+ const currentOffset = parseFloat(indentAttributeValue || '0');
34
+ const isSameUnit = !indentAttributeValue || indentAttributeValue.endsWith(this.unit);
35
+ if (!isSameUnit) {
36
+ return this.isForward ? this.offset + this.unit : undefined;
37
+ }
38
+ const nextOffset = this.isForward ? this.offset : -this.offset;
39
+ const offsetToSet = currentOffset + nextOffset;
40
+ return offsetToSet > 0 ? offsetToSet + this.unit : undefined;
41
+ }
42
+ }
@@ -1,72 +1,72 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module indent/indentconfig
7
- */
8
- /**
9
- * The configuration of the block indentation feature.
10
- *
11
- * If no {@link module:indent/indentconfig~IndentBlockConfig#classes} are set, the block indentation feature will use
12
- * {@link module:indent/indentconfig~IndentBlockConfig#offset} and {@link module:indent/indentconfig~IndentBlockConfig#unit} to
13
- * create indentation steps.
14
- *
15
- * ```ts
16
- * ClassicEditor
17
- * .create( editorElement, {
18
- * indentBlock: {
19
- * offset: 2,
20
- * unit: 'em'
21
- * }
22
- * } )
23
- * .then( ... )
24
- * .catch( ... );
25
- * ```
26
- *
27
- * Alternatively, the block indentation feature may set one of defined {@link module:indent/indentconfig~IndentBlockConfig#classes} as
28
- * indentation steps:
29
- *
30
- * ```ts
31
- * ClassicEditor
32
- * .create( editorElement, {
33
- * indentBlock: {
34
- * classes: [
35
- * 'indent-a', // The first step - smallest indentation.
36
- * 'indent-b',
37
- * 'indent-c',
38
- * 'indent-d',
39
- * 'indent-e' // The last step - biggest indentation.
40
- * ]
41
- * }
42
- * } )
43
- * .then( ... )
44
- * .catch( ... );
45
- * ```
46
- *
47
- * In the example above only 5 indentation steps will be available.
48
- *
49
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
50
- */
51
- export interface IndentBlockConfig {
52
- /**
53
- * The size of indentation {@link module:indent/indentconfig~IndentBlockConfig#unit units} for each indentation step.
54
- *
55
- * @default 40
56
- */
57
- offset?: number;
58
- /**
59
- * The unit used for indentation {@link module:indent/indentconfig~IndentBlockConfig#offset}.
60
- *
61
- * @default 'px'
62
- */
63
- unit?: string;
64
- /**
65
- * An optional list of classes to use for indenting the editor content. If not set or set to an empty array, no classes will be used.
66
- * The {@link module:indent/indentconfig~IndentBlockConfig#unit `indentBlock.unit`} and
67
- * {@link module:indent/indentconfig~IndentBlockConfig#offset `indentBlock.offset`} properties will be used instead.
68
- *
69
- * @default undefined
70
- */
71
- classes?: Array<string>;
72
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module indent/indentconfig
7
+ */
8
+ /**
9
+ * The configuration of the block indentation feature.
10
+ *
11
+ * If no {@link module:indent/indentconfig~IndentBlockConfig#classes} are set, the block indentation feature will use
12
+ * {@link module:indent/indentconfig~IndentBlockConfig#offset} and {@link module:indent/indentconfig~IndentBlockConfig#unit} to
13
+ * create indentation steps.
14
+ *
15
+ * ```ts
16
+ * ClassicEditor
17
+ * .create( editorElement, {
18
+ * indentBlock: {
19
+ * offset: 2,
20
+ * unit: 'em'
21
+ * }
22
+ * } )
23
+ * .then( ... )
24
+ * .catch( ... );
25
+ * ```
26
+ *
27
+ * Alternatively, the block indentation feature may set one of defined {@link module:indent/indentconfig~IndentBlockConfig#classes} as
28
+ * indentation steps:
29
+ *
30
+ * ```ts
31
+ * ClassicEditor
32
+ * .create( editorElement, {
33
+ * indentBlock: {
34
+ * classes: [
35
+ * 'indent-a', // The first step - smallest indentation.
36
+ * 'indent-b',
37
+ * 'indent-c',
38
+ * 'indent-d',
39
+ * 'indent-e' // The last step - biggest indentation.
40
+ * ]
41
+ * }
42
+ * } )
43
+ * .then( ... )
44
+ * .catch( ... );
45
+ * ```
46
+ *
47
+ * In the example above only 5 indentation steps will be available.
48
+ *
49
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
50
+ */
51
+ export interface IndentBlockConfig {
52
+ /**
53
+ * The size of indentation {@link module:indent/indentconfig~IndentBlockConfig#unit units} for each indentation step.
54
+ *
55
+ * @default 40
56
+ */
57
+ offset?: number;
58
+ /**
59
+ * The unit used for indentation {@link module:indent/indentconfig~IndentBlockConfig#offset}.
60
+ *
61
+ * @default 'px'
62
+ */
63
+ unit?: string;
64
+ /**
65
+ * An optional list of classes to use for indenting the editor content. If not set or set to an empty array, no classes will be used.
66
+ * The {@link module:indent/indentconfig~IndentBlockConfig#unit `indentBlock.unit`} and
67
+ * {@link module:indent/indentconfig~IndentBlockConfig#offset `indentBlock.offset`} properties will be used instead.
68
+ *
69
+ * @default undefined
70
+ */
71
+ classes?: Array<string>;
72
+ }
@@ -1,5 +1,5 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- export {};
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ export {};
@@ -1,26 +1,26 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module indent/indentediting
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- /**
10
- * The indent editing feature.
11
- *
12
- * This plugin registers the `'indent'` and `'outdent'` commands.
13
- *
14
- * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
15
- * {@link module:indent/indent~Indent indent feature} API documentation.
16
- */
17
- export default class IndentEditing extends Plugin {
18
- /**
19
- * @inheritDoc
20
- */
21
- static get pluginName(): "IndentEditing";
22
- /**
23
- * @inheritDoc
24
- */
25
- init(): void;
26
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module indent/indentediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ /**
10
+ * The indent editing feature.
11
+ *
12
+ * This plugin registers the `'indent'` and `'outdent'` commands.
13
+ *
14
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
15
+ * {@link module:indent/indent~Indent indent feature} API documentation.
16
+ */
17
+ export default class IndentEditing extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get pluginName(): "IndentEditing";
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ init(): void;
26
+ }
@@ -1,32 +1,32 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module indent/indentediting
7
- */
8
- import { Plugin, MultiCommand } from 'ckeditor5/src/core';
9
- /**
10
- * The indent editing feature.
11
- *
12
- * This plugin registers the `'indent'` and `'outdent'` commands.
13
- *
14
- * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
15
- * {@link module:indent/indent~Indent indent feature} API documentation.
16
- */
17
- export default class IndentEditing extends Plugin {
18
- /**
19
- * @inheritDoc
20
- */
21
- static get pluginName() {
22
- return 'IndentEditing';
23
- }
24
- /**
25
- * @inheritDoc
26
- */
27
- init() {
28
- const editor = this.editor;
29
- editor.commands.add('indent', new MultiCommand(editor));
30
- editor.commands.add('outdent', new MultiCommand(editor));
31
- }
32
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module indent/indentediting
7
+ */
8
+ import { Plugin, MultiCommand } from 'ckeditor5/src/core';
9
+ /**
10
+ * The indent editing feature.
11
+ *
12
+ * This plugin registers the `'indent'` and `'outdent'` commands.
13
+ *
14
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
15
+ * {@link module:indent/indent~Indent indent feature} API documentation.
16
+ */
17
+ export default class IndentEditing extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get pluginName() {
22
+ return 'IndentEditing';
23
+ }
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ init() {
28
+ const editor = this.editor;
29
+ editor.commands.add('indent', new MultiCommand(editor));
30
+ editor.commands.add('outdent', new MultiCommand(editor));
31
+ }
32
+ }
package/src/indentui.d.ts CHANGED
@@ -1,27 +1,27 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- import { Plugin } from 'ckeditor5/src/core';
6
- /**
7
- * The indent UI feature.
8
- *
9
- * This plugin registers the `'indent'` and `'outdent'` buttons.
10
- *
11
- * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in
12
- * the {@link module:indent/indent~Indent indent feature} API documentation.
13
- */
14
- export default class IndentUI extends Plugin {
15
- /**
16
- * @inheritDoc
17
- */
18
- static get pluginName(): "IndentUI";
19
- /**
20
- * @inheritDoc
21
- */
22
- init(): void;
23
- /**
24
- * Defines a UI button.
25
- */
26
- private _defineButton;
27
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import { Plugin } from 'ckeditor5/src/core';
6
+ /**
7
+ * The indent UI feature.
8
+ *
9
+ * This plugin registers the `'indent'` and `'outdent'` buttons.
10
+ *
11
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in
12
+ * the {@link module:indent/indent~Indent indent feature} API documentation.
13
+ */
14
+ export default class IndentUI extends Plugin {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ static get pluginName(): "IndentUI";
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ init(): void;
23
+ /**
24
+ * Defines a UI button.
25
+ */
26
+ private _defineButton;
27
+ }
package/src/indentui.js CHANGED
@@ -1,60 +1,60 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module indent/indentui
7
- */
8
- import { ButtonView } from 'ckeditor5/src/ui';
9
- import { Plugin } from 'ckeditor5/src/core';
10
- import indentIcon from '../theme/icons/indent.svg';
11
- import outdentIcon from '../theme/icons/outdent.svg';
12
- /**
13
- * The indent UI feature.
14
- *
15
- * This plugin registers the `'indent'` and `'outdent'` buttons.
16
- *
17
- * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in
18
- * the {@link module:indent/indent~Indent indent feature} API documentation.
19
- */
20
- export default class IndentUI extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName() {
25
- return 'IndentUI';
26
- }
27
- /**
28
- * @inheritDoc
29
- */
30
- init() {
31
- const editor = this.editor;
32
- const locale = editor.locale;
33
- const t = editor.t;
34
- const localizedIndentIcon = locale.uiLanguageDirection == 'ltr' ? indentIcon : outdentIcon;
35
- const localizedOutdentIcon = locale.uiLanguageDirection == 'ltr' ? outdentIcon : indentIcon;
36
- this._defineButton('indent', t('Increase indent'), localizedIndentIcon);
37
- this._defineButton('outdent', t('Decrease indent'), localizedOutdentIcon);
38
- }
39
- /**
40
- * Defines a UI button.
41
- */
42
- _defineButton(commandName, label, icon) {
43
- const editor = this.editor;
44
- editor.ui.componentFactory.add(commandName, locale => {
45
- const command = editor.commands.get(commandName);
46
- const view = new ButtonView(locale);
47
- view.set({
48
- label,
49
- icon,
50
- tooltip: true
51
- });
52
- view.bind('isEnabled').to(command, 'isEnabled');
53
- this.listenTo(view, 'execute', () => {
54
- editor.execute(commandName);
55
- editor.editing.view.focus();
56
- });
57
- return view;
58
- });
59
- }
60
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module indent/indentui
7
+ */
8
+ import { ButtonView } from 'ckeditor5/src/ui';
9
+ import { Plugin } from 'ckeditor5/src/core';
10
+ import indentIcon from '../theme/icons/indent.svg';
11
+ import outdentIcon from '../theme/icons/outdent.svg';
12
+ /**
13
+ * The indent UI feature.
14
+ *
15
+ * This plugin registers the `'indent'` and `'outdent'` buttons.
16
+ *
17
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in
18
+ * the {@link module:indent/indent~Indent indent feature} API documentation.
19
+ */
20
+ export default class IndentUI extends Plugin {
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get pluginName() {
25
+ return 'IndentUI';
26
+ }
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ init() {
31
+ const editor = this.editor;
32
+ const locale = editor.locale;
33
+ const t = editor.t;
34
+ const localizedIndentIcon = locale.uiLanguageDirection == 'ltr' ? indentIcon : outdentIcon;
35
+ const localizedOutdentIcon = locale.uiLanguageDirection == 'ltr' ? outdentIcon : indentIcon;
36
+ this._defineButton('indent', t('Increase indent'), localizedIndentIcon);
37
+ this._defineButton('outdent', t('Decrease indent'), localizedOutdentIcon);
38
+ }
39
+ /**
40
+ * Defines a UI button.
41
+ */
42
+ _defineButton(commandName, label, icon) {
43
+ const editor = this.editor;
44
+ editor.ui.componentFactory.add(commandName, locale => {
45
+ const command = editor.commands.get(commandName);
46
+ const view = new ButtonView(locale);
47
+ view.set({
48
+ label,
49
+ icon,
50
+ tooltip: true
51
+ });
52
+ view.bind('isEnabled').to(command, 'isEnabled');
53
+ this.listenTo(view, 'execute', () => {
54
+ editor.execute(commandName);
55
+ editor.editing.view.focus();
56
+ });
57
+ return view;
58
+ });
59
+ }
60
+ }
package/src/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module indent
7
- */
8
- export { default as Indent } from './indent';
9
- export { default as IndentEditing } from './indentediting';
10
- export { default as IndentUI } from './indentui';
11
- export { default as IndentBlock } from './indentblock';
12
- export type { IndentBlockConfig } from './indentconfig';
13
- export type { default as IndentBlockCommand } from './indentblockcommand';
14
- import './augmentation';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module indent
7
+ */
8
+ export { default as Indent } from './indent';
9
+ export { default as IndentEditing } from './indentediting';
10
+ export { default as IndentUI } from './indentui';
11
+ export { default as IndentBlock } from './indentblock';
12
+ export type { IndentBlockConfig } from './indentconfig';
13
+ export type { default as IndentBlockCommand } from './indentblockcommand';
14
+ import './augmentation';
package/src/index.js CHANGED
@@ -1,12 +1,12 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module indent
7
- */
8
- export { default as Indent } from './indent';
9
- export { default as IndentEditing } from './indentediting';
10
- export { default as IndentUI } from './indentui';
11
- export { default as IndentBlock } from './indentblock';
12
- import './augmentation';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module indent
7
+ */
8
+ export { default as Indent } from './indent';
9
+ export { default as IndentEditing } from './indentediting';
10
+ export { default as IndentUI } from './indentui';
11
+ export { default as IndentBlock } from './indentblock';
12
+ import './augmentation';