@ckeditor/ckeditor5-select-all 35.2.1 → 35.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-select-all",
3
- "version": "35.2.1",
3
+ "version": "35.3.0",
4
4
  "description": "Select all feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,19 +12,22 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "^35.2.1",
16
- "@ckeditor/ckeditor5-utils": "^35.2.1",
17
- "@ckeditor/ckeditor5-ui": "^35.2.1"
15
+ "@ckeditor/ckeditor5-core": "^35.3.0",
16
+ "@ckeditor/ckeditor5-utils": "^35.3.0",
17
+ "@ckeditor/ckeditor5-ui": "^35.3.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@ckeditor/ckeditor5-basic-styles": "^35.2.1",
21
- "@ckeditor/ckeditor5-engine": "^35.2.1",
22
- "@ckeditor/ckeditor5-essentials": "^35.2.1",
23
- "@ckeditor/ckeditor5-heading": "^35.2.1",
24
- "@ckeditor/ckeditor5-image": "^35.2.1",
25
- "@ckeditor/ckeditor5-paragraph": "^35.2.1",
26
- "@ckeditor/ckeditor5-table": "^35.2.1",
27
- "@ckeditor/ckeditor5-editor-classic": "^35.2.1"
20
+ "@ckeditor/ckeditor5-basic-styles": "^35.3.0",
21
+ "@ckeditor/ckeditor5-engine": "^35.3.0",
22
+ "@ckeditor/ckeditor5-essentials": "^35.3.0",
23
+ "@ckeditor/ckeditor5-heading": "^35.3.0",
24
+ "@ckeditor/ckeditor5-image": "^35.3.0",
25
+ "@ckeditor/ckeditor5-paragraph": "^35.3.0",
26
+ "@ckeditor/ckeditor5-table": "^35.3.0",
27
+ "@ckeditor/ckeditor5-editor-classic": "^35.3.0",
28
+ "typescript": "^4.8.4",
29
+ "webpack": "^5.58.1",
30
+ "webpack-cli": "^4.9.0"
28
31
  },
29
32
  "engines": {
30
33
  "node": ">=14.0.0",
@@ -41,9 +44,14 @@
41
44
  },
42
45
  "files": [
43
46
  "lang",
44
- "src",
47
+ "src/**/*.js",
48
+ "src/**/*.d.ts",
45
49
  "theme",
46
50
  "ckeditor5-metadata.json",
47
51
  "CHANGELOG.md"
48
- ]
52
+ ],
53
+ "scripts": {
54
+ "build": "tsc -p ./tsconfig.release.json",
55
+ "postversion": "npm run build"
56
+ }
49
57
  }
package/src/index.js CHANGED
@@ -2,11 +2,9 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module select-all
8
7
  */
9
-
10
8
  export { default as SelectAll } from './selectall';
11
9
  export { default as SelectAllEditing } from './selectallediting';
12
10
  export { default as SelectAllUI } from './selectallui';
package/src/selectall.js CHANGED
@@ -2,15 +2,12 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module select-all/selectall
8
7
  */
9
-
10
8
  import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11
9
  import SelectAllEditing from './selectallediting';
12
10
  import SelectAllUI from './selectallui';
13
-
14
11
  /**
15
12
  * The select all feature.
16
13
  *
@@ -22,17 +19,16 @@ import SelectAllUI from './selectallui';
22
19
  * @extends module:core/plugin~Plugin
23
20
  */
24
21
  export default class SelectAll extends Plugin {
25
- /**
26
- * @inheritDoc
27
- */
28
- static get requires() {
29
- return [ SelectAllEditing, SelectAllUI ];
30
- }
31
-
32
- /**
33
- * @inheritDoc
34
- */
35
- static get pluginName() {
36
- return 'SelectAll';
37
- }
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires() {
26
+ return [SelectAllEditing, SelectAllUI];
27
+ }
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get pluginName() {
32
+ return 'SelectAll';
33
+ }
38
34
  }
@@ -2,13 +2,10 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module select-all/selectallcommand
8
7
  */
9
-
10
8
  import Command from '@ckeditor/ckeditor5-core/src/command';
11
-
12
9
  /**
13
10
  * The select all command.
14
11
  *
@@ -26,43 +23,37 @@ import Command from '@ckeditor/ckeditor5-core/src/command';
26
23
  * @extends module:core/command~Command
27
24
  */
28
25
  export default class SelectAllCommand extends Command {
29
- /**
30
- * @inheritDoc
31
- */
32
- constructor( editor ) {
33
- super( editor );
34
-
35
- // It does not affect data so should be enabled in read-only mode.
36
- this.affectsData = false;
37
- }
38
-
39
- /**
40
- * @inheritDoc
41
- */
42
- execute() {
43
- const model = this.editor.model;
44
- const selection = model.document.selection;
45
- let scopeElement = model.schema.getLimitElement( selection );
46
-
47
- // If an entire scope is selected, or the selection's ancestor is not a scope yet,
48
- // browse through ancestors to find the enclosing parent scope.
49
- if ( selection.containsEntireContent( scopeElement ) || !isSelectAllScope( model.schema, scopeElement ) ) {
50
- do {
51
- scopeElement = scopeElement.parent;
52
-
53
- // Do nothing, if the entire `root` is already selected.
54
- if ( !scopeElement ) {
55
- return;
56
- }
57
- } while ( !isSelectAllScope( model.schema, scopeElement ) );
58
- }
59
-
60
- model.change( writer => {
61
- writer.setSelection( scopeElement, 'in' );
62
- } );
63
- }
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ constructor(editor) {
30
+ super(editor);
31
+ // It does not affect data so should be enabled in read-only mode.
32
+ this.affectsData = false;
33
+ }
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ execute() {
38
+ const model = this.editor.model;
39
+ const selection = model.document.selection;
40
+ let scopeElement = model.schema.getLimitElement(selection);
41
+ // If an entire scope is selected, or the selection's ancestor is not a scope yet,
42
+ // browse through ancestors to find the enclosing parent scope.
43
+ if (selection.containsEntireContent(scopeElement) || !isSelectAllScope(model.schema, scopeElement)) {
44
+ do {
45
+ scopeElement = scopeElement.parent;
46
+ // Do nothing, if the entire `root` is already selected.
47
+ if (!scopeElement) {
48
+ return;
49
+ }
50
+ } while (!isSelectAllScope(model.schema, scopeElement));
51
+ }
52
+ model.change(writer => {
53
+ writer.setSelection(scopeElement, 'in');
54
+ });
55
+ }
64
56
  }
65
-
66
57
  // Checks whether the element is a valid select-all scope.
67
58
  // Returns true, if the element is a {@link module:engine/model/schema~Schema#isLimit limit},
68
59
  // and can contain any text or paragraph.
@@ -70,6 +61,6 @@ export default class SelectAllCommand extends Command {
70
61
  // @param {module:engine/model/schema~Schema} schema The schema to check against.
71
62
  // @param {module:engine/model/element~Element} element
72
63
  // @return {Boolean}
73
- function isSelectAllScope( schema, element ) {
74
- return schema.isLimit( element ) && ( schema.checkChild( element, '$text' ) || schema.checkChild( element, 'paragraph' ) );
64
+ function isSelectAllScope(schema, element) {
65
+ return schema.isLimit(element) && (schema.checkChild(element, '$text') || schema.checkChild(element, 'paragraph'));
75
66
  }
@@ -2,17 +2,13 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module select-all/selectallediting
8
7
  */
9
-
10
8
  import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11
9
  import { getCode, parseKeystroke } from '@ckeditor/ckeditor5-utils/src/keyboard';
12
10
  import SelectAllCommand from './selectallcommand';
13
-
14
- const SELECT_ALL_KEYSTROKE = parseKeystroke( 'Ctrl+A' );
15
-
11
+ const SELECT_ALL_KEYSTROKE = parseKeystroke('Ctrl+A');
16
12
  /**
17
13
  * The select all editing feature.
18
14
  *
@@ -22,28 +18,25 @@ const SELECT_ALL_KEYSTROKE = parseKeystroke( 'Ctrl+A' );
22
18
  * @extends module:core/plugin~Plugin
23
19
  */
24
20
  export default class SelectAllEditing extends Plugin {
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName() {
29
- return 'SelectAllEditing';
30
- }
31
-
32
- /**
33
- * @inheritDoc
34
- */
35
- init() {
36
- const editor = this.editor;
37
- const view = editor.editing.view;
38
- const viewDocument = view.document;
39
-
40
- editor.commands.add( 'selectAll', new SelectAllCommand( editor ) );
41
-
42
- this.listenTo( viewDocument, 'keydown', ( eventInfo, domEventData ) => {
43
- if ( getCode( domEventData ) === SELECT_ALL_KEYSTROKE ) {
44
- editor.execute( 'selectAll' );
45
- domEventData.preventDefault();
46
- }
47
- } );
48
- }
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get pluginName() {
25
+ return 'SelectAllEditing';
26
+ }
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ init() {
31
+ const editor = this.editor;
32
+ const view = editor.editing.view;
33
+ const viewDocument = view.document;
34
+ editor.commands.add('selectAll', new SelectAllCommand(editor));
35
+ this.listenTo(viewDocument, 'keydown', (eventInfo, domEventData) => {
36
+ if (getCode(domEventData) === SELECT_ALL_KEYSTROKE) {
37
+ editor.execute('selectAll');
38
+ domEventData.preventDefault();
39
+ }
40
+ });
41
+ }
49
42
  }
@@ -2,16 +2,12 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module select-all/selectallui
8
7
  */
9
-
10
8
  import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11
9
  import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
12
-
13
10
  import selectAllIcon from '../theme/icons/select-all.svg';
14
-
15
11
  /**
16
12
  * The select all UI feature.
17
13
  *
@@ -22,40 +18,34 @@ import selectAllIcon from '../theme/icons/select-all.svg';
22
18
  * @extends module:core/plugin~Plugin
23
19
  */
24
20
  export default class SelectAllUI extends Plugin {
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName() {
29
- return 'SelectAllUI';
30
- }
31
-
32
- /**
33
- * @inheritDoc
34
- */
35
- init() {
36
- const editor = this.editor;
37
-
38
- editor.ui.componentFactory.add( 'selectAll', locale => {
39
- const command = editor.commands.get( 'selectAll' );
40
- const view = new ButtonView( locale );
41
- const t = locale.t;
42
-
43
- view.set( {
44
- label: t( 'Select all' ),
45
- icon: selectAllIcon,
46
- keystroke: 'Ctrl+A',
47
- tooltip: true
48
- } );
49
-
50
- view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
51
-
52
- // Execute the command.
53
- this.listenTo( view, 'execute', () => {
54
- editor.execute( 'selectAll' );
55
- editor.editing.view.focus();
56
- } );
57
-
58
- return view;
59
- } );
60
- }
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get pluginName() {
25
+ return 'SelectAllUI';
26
+ }
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ init() {
31
+ const editor = this.editor;
32
+ editor.ui.componentFactory.add('selectAll', locale => {
33
+ const command = editor.commands.get('selectAll');
34
+ const view = new ButtonView(locale);
35
+ const t = locale.t;
36
+ view.set({
37
+ label: t('Select all'),
38
+ icon: selectAllIcon,
39
+ keystroke: 'Ctrl+A',
40
+ tooltip: true
41
+ });
42
+ view.bind('isEnabled').to(command, 'isEnabled');
43
+ // Execute the command.
44
+ this.listenTo(view, 'execute', () => {
45
+ editor.execute('selectAll');
46
+ editor.editing.view.focus();
47
+ });
48
+ return view;
49
+ });
50
+ }
61
51
  }