ckeditor5-elements-quick-insert 0.0.0-stage → 49.0.0-alpha.2

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -2
  3. package/dist/augmentation.d.ts +18 -0
  4. package/dist/augmentation.d.ts.map +1 -0
  5. package/dist/augmentation.js +2 -0
  6. package/dist/augmentation.js.map +1 -0
  7. package/dist/icons.d.ts +16 -0
  8. package/dist/icons.d.ts.map +1 -0
  9. package/dist/icons.js +21 -0
  10. package/dist/icons.js.map +1 -0
  11. package/dist/index.d.ts +13 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +17 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/quickInsert.d.ts +56 -0
  16. package/dist/quickInsert.d.ts.map +1 -0
  17. package/dist/quickInsert.js +106 -0
  18. package/dist/quickInsert.js.map +1 -0
  19. package/dist/quickInsertCommand.d.ts +38 -0
  20. package/dist/quickInsertCommand.d.ts.map +1 -0
  21. package/dist/quickInsertCommand.js +70 -0
  22. package/dist/quickInsertCommand.js.map +1 -0
  23. package/dist/quickInsertListView.d.ts +29 -0
  24. package/dist/quickInsertListView.d.ts.map +1 -0
  25. package/dist/quickInsertListView.js +44 -0
  26. package/dist/quickInsertListView.js.map +1 -0
  27. package/dist/quickInsertPositionCommand.d.ts +28 -0
  28. package/dist/quickInsertPositionCommand.d.ts.map +1 -0
  29. package/dist/quickInsertPositionCommand.js +54 -0
  30. package/dist/quickInsertPositionCommand.js.map +1 -0
  31. package/dist/quickInsertView.d.ts +20 -0
  32. package/dist/quickInsertView.d.ts.map +1 -0
  33. package/dist/quickInsertView.js +52 -0
  34. package/dist/quickInsertView.js.map +1 -0
  35. package/package.json +49 -3
  36. package/src/augmentation.ts +20 -0
  37. package/src/icons.ts +26 -0
  38. package/src/index.ts +21 -0
  39. package/src/quickInsert.ts +148 -0
  40. package/src/quickInsertCommand.ts +85 -0
  41. package/src/quickInsertListView.ts +71 -0
  42. package/src/quickInsertPositionCommand.ts +72 -0
  43. package/src/quickInsertView.ts +64 -0
  44. package/theme/quickInsert.css +12 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ivan Kildyushov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,30 @@
1
- # Temporary Holding Version
1
+ # ckeditor5-elements-quick-insert
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Quick insert for CKEditor 5 Elements: `QuickInsert` opens a searchable list of the elements allowed at the cursor on
4
+ Alt+Enter (Option+Enter on macOS). The `quickInsertBefore` and `quickInsertAfter` commands open it before or after an
5
+ element, e.g. from the element context menu.
6
+
7
+ ## Installation
8
+
9
+ This package is part of `ckeditor5-elements`. Install the whole package to use it:
10
+
11
+ ```sh
12
+ npm install ckeditor5 ckeditor5-elements
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { QuickInsert } from 'ckeditor5-elements';
19
+ import 'ckeditor5-elements/index.css';
20
+
21
+ // In the editor config:
22
+ plugins: [..., QuickInsert],
23
+ quickInsert: { labels: { paragraph: 'Paragraph', heading1: 'Heading 1' } }
24
+ ```
25
+
26
+ See the [Quick insert guide](https://ivankild.github.io/ckeditor5-elements/guide/quick-insert) of the documentation.
27
+
28
+ ## License
29
+
30
+ MIT
@@ -0,0 +1,18 @@
1
+ import type { QuickInsert, QuickInsertCommand, QuickInsertConfig, QuickInsertPositionCommand } from './index.js';
2
+ declare module 'ckeditor5' {
3
+ interface PluginsMap {
4
+ [QuickInsert.pluginName]: QuickInsert;
5
+ }
6
+ interface CommandsMap {
7
+ quickInsert: QuickInsertCommand;
8
+ quickInsertBefore: QuickInsertPositionCommand;
9
+ quickInsertAfter: QuickInsertPositionCommand;
10
+ }
11
+ interface EditorConfig {
12
+ /**
13
+ * The configuration of the {@link QuickInsert} plugin.
14
+ */
15
+ quickInsert?: QuickInsertConfig;
16
+ }
17
+ }
18
+ //# sourceMappingURL=augmentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"augmentation.d.ts","sourceRoot":"","sources":["../src/augmentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAEjH,OAAO,QAAQ,WAAW,CAAC;IAC1B,UAAU,UAAU;QACnB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;KACtC;IAED,UAAU,WAAW;QACpB,WAAW,EAAE,kBAAkB,CAAC;QAChC,iBAAiB,EAAE,0BAA0B,CAAC;QAC9C,gBAAgB,EAAE,0BAA0B,CAAC;KAC7C;IAED,UAAU,YAAY;QACrB;;WAEG;QACH,WAAW,CAAC,EAAE,iBAAiB,CAAC;KAChC;CACD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=augmentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"augmentation.js","sourceRoot":"","sources":["../src/augmentation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The icons of the quick insert commands, in the style of the CKEditor 5 icons (20×20).
3
+ */
4
+ /**
5
+ * Insert element: CKEditor's own plus icon.
6
+ */
7
+ export declare const insertIcon: string;
8
+ /**
9
+ * Insert before: a plus above a block.
10
+ */
11
+ export declare const insertBeforeIcon: string;
12
+ /**
13
+ * Insert after: a block above a plus.
14
+ */
15
+ export declare const insertAfterIcon: string;
16
+ //# sourceMappingURL=icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,QAAW,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAGsB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,eAAe,QAGmB,CAAC"}
package/dist/icons.js ADDED
@@ -0,0 +1,21 @@
1
+ import { IconPlus } from 'ckeditor5';
2
+ /**
3
+ * The icons of the quick insert commands, in the style of the CKEditor 5 icons (20×20).
4
+ */
5
+ /**
6
+ * Insert element: CKEditor's own plus icon.
7
+ */
8
+ export const insertIcon = IconPlus;
9
+ /**
10
+ * Insert before: a plus above a block.
11
+ */
12
+ export const insertBeforeIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path fill-rule="evenodd" d="' +
13
+ 'M9.25 1.5h1.5v2.75h2.75v1.5h-2.75V8.5h-1.5V5.75H6.5v-1.5h2.75zM3.5 11h13a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-13a1 1 0 0 ' +
14
+ '1-1-1v-5a1 1 0 0 1 1-1zm.5 1.5v4h12v-4z"/></svg>';
15
+ /**
16
+ * Insert after: a block above a plus.
17
+ */
18
+ export const insertAfterIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path fill-rule="evenodd" d="' +
19
+ 'M3.5 2h13a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-13a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zm.5 1.5v4h12v-4zM9.25 11h1.5v2.75h2.75v1.5' +
20
+ 'h-2.75V18h-1.5v-2.75H6.5v-1.5h2.75z"/></svg>';
21
+ //# sourceMappingURL=icons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.js","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC5B,2FAA2F;IAC3F,qHAAqH;IACrH,kDAAkD,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAC3B,2FAA2F;IAC3F,sHAAsH;IACtH,8CAA8C,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Quick insert: search and insert the elements allowed at a position.
3
+ *
4
+ * @module ckeditor5-elements-quick-insert
5
+ */
6
+ export { default as QuickInsert, type QuickInsertConfig } from './quickInsert.js';
7
+ export { default as QuickInsertCommand } from './quickInsertCommand.js';
8
+ export { default as QuickInsertPositionCommand, type QuickInsertPlacement } from './quickInsertPositionCommand.js';
9
+ export { default as QuickInsertView } from './quickInsertView.js';
10
+ export { default as QuickInsertListView, type QuickInsertItem } from './quickInsertListView.js';
11
+ export { insertAfterIcon, insertBeforeIcon, insertIcon } from './icons.js';
12
+ import './augmentation.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGlF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGnH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Quick insert: search and insert the elements allowed at a position.
3
+ *
4
+ * @module ckeditor5-elements-quick-insert
5
+ */
6
+ // Plugins.
7
+ export { default as QuickInsert } from './quickInsert.js';
8
+ // Commands.
9
+ export { default as QuickInsertCommand } from './quickInsertCommand.js';
10
+ export { default as QuickInsertPositionCommand } from './quickInsertPositionCommand.js';
11
+ // Views.
12
+ export { default as QuickInsertView } from './quickInsertView.js';
13
+ export { default as QuickInsertListView } from './quickInsertListView.js';
14
+ // Icons.
15
+ export { insertAfterIcon, insertBeforeIcon, insertIcon } from './icons.js';
16
+ import './augmentation.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,WAAW;AACX,OAAO,EAAE,OAAO,IAAI,WAAW,EAA0B,MAAM,kBAAkB,CAAC;AAElF,YAAY;AACZ,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAA6B,MAAM,iCAAiC,CAAC;AAEnH,SAAS;AACT,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAwB,MAAM,0BAA0B,CAAC;AAEhG,SAAS;AACT,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,mBAAmB,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { Plugin, type Editor, type RectSource } from 'ckeditor5';
2
+ import { ElementMenu, type ElementOrPosition } from 'ckeditor5-elements-core';
3
+ import { type QuickInsertItem } from './quickInsertListView.js';
4
+ /**
5
+ * The configuration of the {@link QuickInsert} plugin.
6
+ */
7
+ export interface QuickInsertConfig {
8
+ /**
9
+ * Labels of the elements, by model name. Elements without a label are listed by their model name.
10
+ */
11
+ labels?: Record<string, string>;
12
+ /**
13
+ * Model names of the elements that are never listed.
14
+ */
15
+ exclude?: string[];
16
+ /**
17
+ * The keystroke that opens the menu at the selection, e.g. `'Ctrl+Space'`. Defaults to `'Alt+Enter'`
18
+ * (Option+Enter on macOS). `false` registers no keystroke.
19
+ */
20
+ keystroke?: string | false;
21
+ }
22
+ /**
23
+ * Opens a menu with a search field and the elements allowed at the selection, on Alt+Enter (Option+Enter on macOS; see
24
+ * {@link QuickInsertConfig.keystroke}). Choosing an element inserts it with the `quickInsert` command.
25
+ *
26
+ * The menu is shown by the `ElementMenu` plugin. The `quickInsertBefore` and `quickInsertAfter` commands (see
27
+ * {@link QuickInsertPositionCommand}) open it for the position before or after an element; list them in the
28
+ * `elementContextMenu` config, e.g. as an "Insert" submenu.
29
+ *
30
+ * The menu closes when the document changes while it is open, so it never inserts at an outdated position.
31
+ */
32
+ export default class QuickInsert extends Plugin {
33
+ static get requires(): readonly [typeof ElementMenu];
34
+ static get pluginName(): 'QuickInsert';
35
+ constructor(editor: Editor);
36
+ init(): void;
37
+ /**
38
+ * Returns the elements that can be inserted at the target (a position, the position before an element, or the
39
+ * selection), with their labels.
40
+ */
41
+ getItems(elementOrPosition?: ElementOrPosition): QuickInsertItem[];
42
+ /**
43
+ * Opens the menu for inserting at the target (a position, the position before an element, or the selection), next
44
+ * to the given DOM target. By default, the menu is next to the element, or the selection.
45
+ *
46
+ * Returns `false` when nothing can be inserted at the target because it cannot be edited, or there is nothing to
47
+ * show the menu next to.
48
+ */
49
+ open(elementOrPosition?: ElementOrPosition, domTarget?: RectSource): boolean;
50
+ /**
51
+ * Returns the DOM element of the element, or the DOM range of the selection.
52
+ */
53
+ private _getDomTarget;
54
+ private _getDomElement;
55
+ }
56
+ //# sourceMappingURL=quickInsert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickInsert.d.ts","sourceRoot":"","sources":["../src/quickInsert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAoD,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AACnH,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG9E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,MAAM;IAC9C,WAAkB,QAAQ,IAAI,SAAS,CAAC,OAAO,WAAW,CAAC,CAE1D;IAED,WAAkB,UAAU,IAAI,aAAa,CAE5C;gBAEW,MAAM,EAAE,MAAM;IAMnB,IAAI,IAAI,IAAI;IAqBnB;;;OAGG;IACI,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,eAAe,EAAE;IAWzE;;;;;;OAMG;IACI,IAAI,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,OAAO;IA2BnF;;OAEG;IACH,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,cAAc;CAOtB"}
@@ -0,0 +1,106 @@
1
+ import { Plugin } from 'ckeditor5';
2
+ import { ElementMenu } from 'ckeditor5-elements-core';
3
+ import QuickInsertCommand from './quickInsertCommand.js';
4
+ import QuickInsertPositionCommand from './quickInsertPositionCommand.js';
5
+ import {} from './quickInsertListView.js';
6
+ import QuickInsertView from './quickInsertView.js';
7
+ /**
8
+ * Opens a menu with a search field and the elements allowed at the selection, on Alt+Enter (Option+Enter on macOS; see
9
+ * {@link QuickInsertConfig.keystroke}). Choosing an element inserts it with the `quickInsert` command.
10
+ *
11
+ * The menu is shown by the `ElementMenu` plugin. The `quickInsertBefore` and `quickInsertAfter` commands (see
12
+ * {@link QuickInsertPositionCommand}) open it for the position before or after an element; list them in the
13
+ * `elementContextMenu` config, e.g. as an "Insert" submenu.
14
+ *
15
+ * The menu closes when the document changes while it is open, so it never inserts at an outdated position.
16
+ */
17
+ export default class QuickInsert extends Plugin {
18
+ static get requires() {
19
+ return [ElementMenu];
20
+ }
21
+ static get pluginName() {
22
+ return 'QuickInsert';
23
+ }
24
+ constructor(editor) {
25
+ super(editor);
26
+ editor.config.define('quickInsert', { labels: {}, exclude: [], keystroke: 'Alt+Enter' });
27
+ }
28
+ init() {
29
+ const editor = this.editor;
30
+ const keystroke = editor.config.get('quickInsert')?.keystroke;
31
+ editor.commands.add('quickInsert', new QuickInsertCommand(editor));
32
+ editor.commands.add('quickInsertBefore', new QuickInsertPositionCommand(editor, 'before'));
33
+ editor.commands.add('quickInsertAfter', new QuickInsertPositionCommand(editor, 'after'));
34
+ if (keystroke) {
35
+ editor.keystrokes.set(keystroke, (data, cancel) => {
36
+ if (this.open()) {
37
+ cancel();
38
+ }
39
+ });
40
+ editor.accessibility.addKeystrokeInfos({
41
+ keystrokes: [{ label: editor.t('Insert an element at the cursor'), keystroke }]
42
+ });
43
+ }
44
+ }
45
+ /**
46
+ * Returns the elements that can be inserted at the target (a position, the position before an element, or the
47
+ * selection), with their labels.
48
+ */
49
+ getItems(elementOrPosition) {
50
+ const config = this.editor.config.get('quickInsert');
51
+ const labels = config?.labels ?? {};
52
+ const command = this.editor.commands.get('quickInsert');
53
+ return (command?.getAllowedElements(elementOrPosition, config?.exclude) ?? []).map(name => ({
54
+ name,
55
+ label: labels[name] ?? name
56
+ }));
57
+ }
58
+ /**
59
+ * Opens the menu for inserting at the target (a position, the position before an element, or the selection), next
60
+ * to the given DOM target. By default, the menu is next to the element, or the selection.
61
+ *
62
+ * Returns `false` when nothing can be inserted at the target because it cannot be edited, or there is nothing to
63
+ * show the menu next to.
64
+ */
65
+ open(elementOrPosition, domTarget) {
66
+ const editor = this.editor;
67
+ const command = editor.commands.get('quickInsert');
68
+ const position = command?.getInsertPosition(elementOrPosition);
69
+ const menuTarget = domTarget ?? this._getDomTarget(elementOrPosition);
70
+ if (!command || !position || !menuTarget || !command.getState(position).isEnabled) {
71
+ return false;
72
+ }
73
+ const view = new QuickInsertView(editor.locale, this.getItems(position));
74
+ view.on('execute', (evt, { value }) => {
75
+ // Focus first: focusing reads the DOM selection, which would override the selection set by the command.
76
+ editor.editing.view.focus();
77
+ command.executeFor(position, value);
78
+ });
79
+ // The search field is labelled "Insert element".
80
+ editor.plugins.get(ElementMenu).show(view, menuTarget, {
81
+ // The position would be outdated after any change, e.g. by another user.
82
+ isObsolete: () => true
83
+ });
84
+ return true;
85
+ }
86
+ /**
87
+ * Returns the DOM element of the element, or the DOM range of the selection.
88
+ */
89
+ _getDomTarget(elementOrPosition) {
90
+ const editing = this.editor.editing;
91
+ if (elementOrPosition && !elementOrPosition.is('position')) {
92
+ return this._getDomElement(elementOrPosition);
93
+ }
94
+ const viewRange = elementOrPosition
95
+ ? editing.view.createRange(editing.mapper.toViewPosition(elementOrPosition))
96
+ : editing.view.document.selection.getFirstRange();
97
+ return viewRange && editing.view.domConverter.viewRangeToDom(viewRange);
98
+ }
99
+ _getDomElement(element) {
100
+ const editing = this.editor.editing;
101
+ const viewElement = editing.mapper.toViewElement(element);
102
+ const domElement = viewElement && editing.view.domConverter.mapViewToDom(viewElement);
103
+ return domElement instanceof HTMLElement ? domElement : null;
104
+ }
105
+ }
106
+ //# sourceMappingURL=quickInsert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickInsert.js","sourceRoot":"","sources":["../src/quickInsert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkF,MAAM,WAAW,CAAC;AACnH,OAAO,EAAE,WAAW,EAA0B,MAAM,yBAAyB,CAAC;AAC9E,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,0BAA0B,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAwB,MAAM,0BAA0B,CAAC;AAChE,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAuBnD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,MAAM;IACvC,MAAM,KAAK,QAAQ;QACzB,OAAO,CAAC,WAAW,CAAU,CAAC;IAC/B,CAAC;IAEM,MAAM,KAAK,UAAU;QAC3B,OAAO,aAAsB,CAAC;IAC/B,CAAC;IAED,YAAY,MAAc;QACzB,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;IAC1F,CAAC;IAEM,IAAI;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,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IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAEpC,IAAI,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,SAAS,GAAG,iBAAiB;YAClC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YAC5E,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC;QAEnD,OAAO,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACzE,CAAC;IAEO,cAAc,CAAC,OAAqB;QAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QACpC,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,UAAU,GAAG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAEtF,OAAO,UAAU,YAAY,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9D,CAAC;CACD"}
@@ -0,0 +1,38 @@
1
+ import { type Editor, type ModelPosition } from 'ckeditor5';
2
+ import { ElementOrPositionCommand, type ElementOrPosition } from 'ckeditor5-elements-core';
3
+ /**
4
+ * Inserts an element by its model name at a position, or opens the quick insert menu for that position.
5
+ *
6
+ * The target comes first, as in every {@link ElementOrPositionCommand}: a position, an element (meaning the position
7
+ * before it), or none (the selection).
8
+ *
9
+ * ```ts
10
+ * editor.execute('quickInsert', position, 'heading1'); // Inserts a heading at the position.
11
+ * editor.execute('quickInsert'); // Opens the quick insert menu at the selection.
12
+ * ```
13
+ *
14
+ * Only elements that the schema allows at exactly that position are inserted (see {@link getAllowedElements}):
15
+ * nothing is split to make room, so e.g. a heading cannot be inserted inside a paragraph.
16
+ *
17
+ * After inserting, objects are selected; other elements get the selection inside them, in a new paragraph when they
18
+ * can hold blocks.
19
+ */
20
+ export default class QuickInsertCommand extends ElementOrPositionCommand {
21
+ constructor(editor: Editor);
22
+ /**
23
+ * Returns the names of the model elements allowed at exactly the position (or the selection), in the order they
24
+ * were registered. Generic items (such as `$text` or `$block`) and the excluded names are skipped.
25
+ */
26
+ getAllowedElements(elementOrPosition?: ElementOrPosition, exclude?: readonly string[]): string[];
27
+ /**
28
+ * Returns the position where elements are inserted for the target: the position, the position before the element,
29
+ * or the selection.
30
+ */
31
+ getInsertPosition(elementOrPosition?: ElementOrPosition): ModelPosition | null;
32
+ /**
33
+ * Inserts the element named `name` at the target, when the schema allows it there. Without a name, opens the quick
34
+ * insert menu for the target (requires the `QuickInsert` plugin).
35
+ */
36
+ execute(elementOrPosition?: ElementOrPosition, name?: string): void;
37
+ }
38
+ //# sourceMappingURL=quickInsertCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickInsertCommand.d.ts","sourceRoot":"","sources":["../src/quickInsertCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAoB,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG7G;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,wBAAwB;gBAC3D,MAAM,EAAE,MAAM;IAO1B;;;OAGG;IACI,kBAAkB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,OAAO,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,EAAE;IAc3G;;;OAGG;IACI,iBAAiB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,aAAa,GAAG,IAAI;IAIrF;;;OAGG;IACa,OAAO,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;CAyBnF"}
@@ -0,0 +1,70 @@
1
+ import {} from 'ckeditor5';
2
+ import { ElementOrPositionCommand, selectNewElement } from 'ckeditor5-elements-core';
3
+ import { insertIcon } from './icons.js';
4
+ /**
5
+ * Inserts an element by its model name at a position, or opens the quick insert menu for that position.
6
+ *
7
+ * The target comes first, as in every {@link ElementOrPositionCommand}: a position, an element (meaning the position
8
+ * before it), or none (the selection).
9
+ *
10
+ * ```ts
11
+ * editor.execute('quickInsert', position, 'heading1'); // Inserts a heading at the position.
12
+ * editor.execute('quickInsert'); // Opens the quick insert menu at the selection.
13
+ * ```
14
+ *
15
+ * Only elements that the schema allows at exactly that position are inserted (see {@link getAllowedElements}):
16
+ * nothing is split to make room, so e.g. a heading cannot be inserted inside a paragraph.
17
+ *
18
+ * After inserting, objects are selected; other elements get the selection inside them, in a new paragraph when they
19
+ * can hold blocks.
20
+ */
21
+ export default class QuickInsertCommand extends ElementOrPositionCommand {
22
+ constructor(editor) {
23
+ super(editor);
24
+ this.title = editor.t('Insert element');
25
+ this.icon = insertIcon;
26
+ }
27
+ /**
28
+ * Returns the names of the model elements allowed at exactly the position (or the selection), in the order they
29
+ * were registered. Generic items (such as `$text` or `$block`) and the excluded names are skipped.
30
+ */
31
+ getAllowedElements(elementOrPosition, exclude = []) {
32
+ const target = this._getPosition(elementOrPosition);
33
+ if (!target) {
34
+ return [];
35
+ }
36
+ const schema = this.editor.model.schema;
37
+ return Object.keys(schema.getDefinitions()).filter(name => !name.startsWith('$') && !exclude.includes(name) && schema.checkChild(target, name));
38
+ }
39
+ /**
40
+ * Returns the position where elements are inserted for the target: the position, the position before the element,
41
+ * or the selection.
42
+ */
43
+ getInsertPosition(elementOrPosition) {
44
+ return this._getPosition(elementOrPosition);
45
+ }
46
+ /**
47
+ * Inserts the element named `name` at the target, when the schema allows it there. Without a name, opens the quick
48
+ * insert menu for the target (requires the `QuickInsert` plugin).
49
+ */
50
+ execute(elementOrPosition, name) {
51
+ if (name === undefined) {
52
+ const plugins = this.editor.plugins;
53
+ if (plugins.has('QuickInsert')) {
54
+ plugins.get('QuickInsert').open(elementOrPosition);
55
+ }
56
+ return;
57
+ }
58
+ const model = this.editor.model;
59
+ const target = this._getPosition(elementOrPosition);
60
+ if (!target || !model.canEditAt(target) || !model.schema.checkChild(target, name)) {
61
+ return;
62
+ }
63
+ model.change(writer => {
64
+ const element = writer.createElement(name);
65
+ writer.insert(element, target);
66
+ selectNewElement(writer, element);
67
+ });
68
+ }
69
+ }
70
+ //# sourceMappingURL=quickInsertCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickInsertCommand.js","sourceRoot":"","sources":["../src/quickInsertCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAA0B,MAAM,yBAAyB,CAAC;AAC7G,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,wBAAwB;IACvE,YAAY,MAAc;QACzB,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,iBAAqC,EAAE,UAA6B,EAAE;QAC/F,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;QAEpD,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAA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AC;YAC/B,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -0,0 +1,29 @@
1
+ import { ListView, type FilteredView, type Locale } from 'ckeditor5';
2
+ /**
3
+ * An element that can be inserted: its model name and the label shown in the list.
4
+ */
5
+ export interface QuickInsertItem {
6
+ name: string;
7
+ label: string;
8
+ }
9
+ /**
10
+ * A list of insertable elements that can be filtered by a search query.
11
+ *
12
+ * Fires `execute` with `{ value: name }` when an item is chosen.
13
+ */
14
+ export default class QuickInsertListView extends ListView implements FilteredView {
15
+ private readonly _entries;
16
+ constructor(locale: Locale, items: readonly QuickInsertItem[]);
17
+ /**
18
+ * Shows only the items whose label or name matches the expression. `null` shows all items.
19
+ */
20
+ filter(regExp: RegExp | null): {
21
+ resultsCount: number;
22
+ totalItemsCount: number;
23
+ };
24
+ /**
25
+ * Returns the first item that is not filtered out.
26
+ */
27
+ getFirstVisibleItem(): QuickInsertItem | null;
28
+ }
29
+ //# sourceMappingURL=quickInsertListView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickInsertListView.d.ts","sourceRoot":"","sources":["../src/quickInsertListView.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,QAAQ,EACR,KAAK,YAAY,EAEjB,KAAK,MAAM,EACX,MAAM,WAAW,CAAC;AAEnB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,QAAS,YAAW,YAAY;IAChF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsE;gBAEnF,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,eAAe,EAAE;IAsB7D;;OAEG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE;IAcvF;;OAEG;IACI,mBAAmB,IAAI,eAAe,GAAG,IAAI;CAGpD"}
@@ -0,0 +1,44 @@
1
+ import { ButtonView, ListItemView, ListView } from 'ckeditor5';
2
+ /**
3
+ * A list of insertable elements that can be filtered by a search query.
4
+ *
5
+ * Fires `execute` with `{ value: name }` when an item is chosen.
6
+ */
7
+ export default class QuickInsertListView extends ListView {
8
+ _entries;
9
+ constructor(locale, items) {
10
+ super(locale);
11
+ this.role = 'listbox';
12
+ this._entries = items.map(item => {
13
+ const view = new ListItemView(locale);
14
+ const button = new ButtonView(locale);
15
+ button.set({ label: item.label, withText: true, role: 'option' });
16
+ button.on('execute', () => {
17
+ this.fire('execute', { value: item.name });
18
+ });
19
+ view.children.add(button);
20
+ return { item, view, button };
21
+ });
22
+ this.items.addMany(this._entries.map(entry => entry.view));
23
+ }
24
+ /**
25
+ * Shows only the items whose label or name matches the expression. `null` shows all items.
26
+ */
27
+ filter(regExp) {
28
+ let resultsCount = 0;
29
+ for (const { item, view } of this._entries) {
30
+ view.isVisible = !regExp || regExp.test(item.label) || regExp.test(item.name);
31
+ if (view.isVisible) {
32
+ resultsCount++;
33
+ }
34
+ }
35
+ return { resultsCount, totalItemsCount: this._entries.length };
36
+ }
37
+ /**
38
+ * Returns the first item that is not filtered out.
39
+ */
40
+ getFirstVisibleItem() {
41
+ return this._entries.find(entry => entry.view.isVisible)?.item ?? null;
42
+ }
43
+ }
44
+ //# sourceMappingURL=quickInsertListView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickInsertListView.js","sourceRoot":"","sources":["../src/quickInsertListView.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,YAAY,EACZ,QAAQ,EAIR,MAAM,WAAW,CAAC;AAUnB;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,QAAQ;IACvC,QAAQ,CAAsE;IAE/F,YAAY,MAAc,EAAE,KA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,SAAS,EAAE,CAAC;gBACpB,YAAY,EAAE,CAAC;YAChB,CAAC;QACF,CAAC;QAED,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChE,CAAC;IAED;;OAEG;IACI,mBAAmB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC;IACxE,CAAC;CACD"}
@@ -0,0 +1,28 @@
1
+ import { type Editor } from 'ckeditor5';
2
+ import { ElementOrPositionCommand, type ElementOrPosition } from 'ckeditor5-elements-core';
3
+ /**
4
+ * Where the quick insert menu inserts, relative to the element.
5
+ */
6
+ export type QuickInsertPlacement = 'before' | 'after';
7
+ /**
8
+ * Opens the quick insert menu for the position before or after an element, next to that element.
9
+ *
10
+ * The element is the given one, the parent of the given position, or the selected element or the parent of the
11
+ * selection (see {@link ElementOrPositionCommand}). Enabled when something can be inserted at that position.
12
+ *
13
+ * Requires the `QuickInsert` plugin, which registers it as `quickInsertBefore` and `quickInsertAfter`.
14
+ */
15
+ export default class QuickInsertPositionCommand extends ElementOrPositionCommand {
16
+ /**
17
+ * Where the quick insert menu inserts, relative to the element.
18
+ */
19
+ readonly placement: QuickInsertPlacement;
20
+ constructor(editor: Editor, placement: QuickInsertPlacement);
21
+ /**
22
+ * Opens the quick insert menu for the position before or after the element, next to the element.
23
+ */
24
+ execute(elementOrPosition?: ElementOrPosition): void;
25
+ protected _isEnabledFor(elementOrPosition?: ElementOrPosition): boolean;
26
+ private _getInsertPosition;
27
+ }
28
+ //# sourceMappingURL=quickInsertPositionCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickInsertPositionCommand.d.ts","sourceRoot":"","sources":["../src/quickInsertPositionCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAsB,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG3F;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,wBAAwB;IAC/E;;OAEG;IACH,SAAgB,SAAS,EAAE,oBAAoB,CAAC;gBAEpC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAQ3D;;OAEG;IACa,OAAO,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI;cAejD,aAAa,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,OAAO;IAYhF,OAAO,CAAC,kBAAkB;CAU1B"}