@ckeditor/ckeditor5-widget 41.3.0-alpha.4 → 41.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. package/package.json +7 -8
  2. package/src/utils.js +1 -0
  3. package/src/widget.d.ts +8 -0
  4. package/src/widget.js +85 -1
  5. package/dist/content-index.css +0 -4
  6. package/dist/editor-index.css +0 -144
  7. package/dist/index.css +0 -257
  8. package/dist/index.css.map +0 -1
  9. package/dist/translations/ar.d.ts +0 -8
  10. package/dist/translations/ar.js +0 -5
  11. package/dist/translations/az.d.ts +0 -8
  12. package/dist/translations/az.js +0 -5
  13. package/dist/translations/bg.d.ts +0 -8
  14. package/dist/translations/bg.js +0 -5
  15. package/dist/translations/bn.d.ts +0 -8
  16. package/dist/translations/bn.js +0 -5
  17. package/dist/translations/ca.d.ts +0 -8
  18. package/dist/translations/ca.js +0 -5
  19. package/dist/translations/cs.d.ts +0 -8
  20. package/dist/translations/cs.js +0 -5
  21. package/dist/translations/da.d.ts +0 -8
  22. package/dist/translations/da.js +0 -5
  23. package/dist/translations/de-ch.d.ts +0 -8
  24. package/dist/translations/de-ch.js +0 -5
  25. package/dist/translations/de.d.ts +0 -8
  26. package/dist/translations/de.js +0 -5
  27. package/dist/translations/el.d.ts +0 -8
  28. package/dist/translations/el.js +0 -5
  29. package/dist/translations/en-au.d.ts +0 -8
  30. package/dist/translations/en-au.js +0 -5
  31. package/dist/translations/en.d.ts +0 -8
  32. package/dist/translations/en.js +0 -5
  33. package/dist/translations/es.d.ts +0 -8
  34. package/dist/translations/es.js +0 -5
  35. package/dist/translations/et.d.ts +0 -8
  36. package/dist/translations/et.js +0 -5
  37. package/dist/translations/fa.d.ts +0 -8
  38. package/dist/translations/fa.js +0 -5
  39. package/dist/translations/fi.d.ts +0 -8
  40. package/dist/translations/fi.js +0 -5
  41. package/dist/translations/fr.d.ts +0 -8
  42. package/dist/translations/fr.js +0 -5
  43. package/dist/translations/gl.d.ts +0 -8
  44. package/dist/translations/gl.js +0 -5
  45. package/dist/translations/he.d.ts +0 -8
  46. package/dist/translations/he.js +0 -5
  47. package/dist/translations/hi.d.ts +0 -8
  48. package/dist/translations/hi.js +0 -5
  49. package/dist/translations/hr.d.ts +0 -8
  50. package/dist/translations/hr.js +0 -5
  51. package/dist/translations/hu.d.ts +0 -8
  52. package/dist/translations/hu.js +0 -5
  53. package/dist/translations/id.d.ts +0 -8
  54. package/dist/translations/id.js +0 -5
  55. package/dist/translations/it.d.ts +0 -8
  56. package/dist/translations/it.js +0 -5
  57. package/dist/translations/ja.d.ts +0 -8
  58. package/dist/translations/ja.js +0 -5
  59. package/dist/translations/ko.d.ts +0 -8
  60. package/dist/translations/ko.js +0 -5
  61. package/dist/translations/ku.d.ts +0 -8
  62. package/dist/translations/ku.js +0 -5
  63. package/dist/translations/lt.d.ts +0 -8
  64. package/dist/translations/lt.js +0 -5
  65. package/dist/translations/lv.d.ts +0 -8
  66. package/dist/translations/lv.js +0 -5
  67. package/dist/translations/ms.d.ts +0 -8
  68. package/dist/translations/ms.js +0 -5
  69. package/dist/translations/nl.d.ts +0 -8
  70. package/dist/translations/nl.js +0 -5
  71. package/dist/translations/no.d.ts +0 -8
  72. package/dist/translations/no.js +0 -5
  73. package/dist/translations/pl.d.ts +0 -8
  74. package/dist/translations/pl.js +0 -5
  75. package/dist/translations/pt-br.d.ts +0 -8
  76. package/dist/translations/pt-br.js +0 -5
  77. package/dist/translations/pt.d.ts +0 -8
  78. package/dist/translations/pt.js +0 -5
  79. package/dist/translations/ro.d.ts +0 -8
  80. package/dist/translations/ro.js +0 -5
  81. package/dist/translations/ru.d.ts +0 -8
  82. package/dist/translations/ru.js +0 -5
  83. package/dist/translations/sk.d.ts +0 -8
  84. package/dist/translations/sk.js +0 -5
  85. package/dist/translations/sq.d.ts +0 -8
  86. package/dist/translations/sq.js +0 -5
  87. package/dist/translations/sr-latn.d.ts +0 -8
  88. package/dist/translations/sr-latn.js +0 -5
  89. package/dist/translations/sr.d.ts +0 -8
  90. package/dist/translations/sr.js +0 -5
  91. package/dist/translations/sv.d.ts +0 -8
  92. package/dist/translations/sv.js +0 -5
  93. package/dist/translations/th.d.ts +0 -8
  94. package/dist/translations/th.js +0 -5
  95. package/dist/translations/tk.d.ts +0 -8
  96. package/dist/translations/tk.js +0 -5
  97. package/dist/translations/tr.d.ts +0 -8
  98. package/dist/translations/tr.js +0 -5
  99. package/dist/translations/uk.d.ts +0 -8
  100. package/dist/translations/uk.js +0 -5
  101. package/dist/translations/ur.d.ts +0 -8
  102. package/dist/translations/ur.js +0 -5
  103. package/dist/translations/uz.d.ts +0 -8
  104. package/dist/translations/uz.js +0 -5
  105. package/dist/translations/vi.d.ts +0 -8
  106. package/dist/translations/vi.js +0 -5
  107. package/dist/translations/zh-cn.d.ts +0 -8
  108. package/dist/translations/zh-cn.js +0 -5
  109. package/dist/translations/zh.d.ts +0 -8
  110. package/dist/translations/zh.js +0 -5
  111. package/dist/types/augmentation.d.ts +0 -17
  112. package/dist/types/highlightstack.d.ts +0 -78
  113. package/dist/types/index.d.ts +0 -17
  114. package/dist/types/utils.d.ts +0 -202
  115. package/dist/types/verticalnavigation.d.ts +0 -19
  116. package/dist/types/widget.d.ts +0 -99
  117. package/dist/types/widgetresize/resizer.d.ts +0 -181
  118. package/dist/types/widgetresize/resizerstate.d.ts +0 -129
  119. package/dist/types/widgetresize/sizeview.d.ts +0 -59
  120. package/dist/types/widgetresize.d.ts +0 -129
  121. package/dist/types/widgettoolbarrepository.d.ts +0 -98
  122. package/dist/types/widgettypearound/utils.d.ts +0 -42
  123. package/dist/types/widgettypearound/widgettypearound.d.ts +0 -233
@@ -1,129 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module widget/widgetresize
11
- */
12
- import Resizer from './widgetresize/resizer.js';
13
- import { Plugin, type Editor } from '@ckeditor/ckeditor5-core';
14
- import { type Element, type ViewContainerElement } from '@ckeditor/ckeditor5-engine';
15
- import '../theme/widgetresize.css';
16
- /**
17
- * The widget resize feature plugin.
18
- *
19
- * Use the {@link module:widget/widgetresize~WidgetResize#attachTo} method to create a resizer for the specified widget.
20
- */
21
- export default class WidgetResize extends Plugin {
22
- /**
23
- * The currently selected resizer.
24
- *
25
- * @observable
26
- */
27
- selectedResizer: Resizer | null;
28
- /**
29
- * References an active resizer.
30
- *
31
- * Active resizer means a resizer which handle is actively used by the end user.
32
- *
33
- * @internal
34
- * @observable
35
- */
36
- _activeResizer: Resizer | null;
37
- /**
38
- * A map of resizers created using this plugin instance.
39
- */
40
- private _resizers;
41
- private _observer;
42
- private _redrawSelectedResizerThrottled;
43
- /**
44
- * @inheritDoc
45
- */
46
- static get pluginName(): "WidgetResize";
47
- /**
48
- * @inheritDoc
49
- */
50
- init(): void;
51
- /**
52
- * Redraws the selected resizer if there is any selected resizer and if it is visible.
53
- */
54
- redrawSelectedResizer(): void;
55
- /**
56
- * @inheritDoc
57
- */
58
- destroy(): void;
59
- /**
60
- * Marks resizer as selected.
61
- */
62
- select(resizer: Resizer): void;
63
- /**
64
- * Deselects currently set resizer.
65
- */
66
- deselect(): void;
67
- /**
68
- * @param options Resizer options.
69
- */
70
- attachTo(options: ResizerOptions): Resizer;
71
- /**
72
- * Returns a resizer created for a given view element (widget element).
73
- *
74
- * @param viewElement View element associated with the resizer.
75
- */
76
- getResizerByViewElement(viewElement: ViewContainerElement): Resizer | undefined;
77
- /**
78
- * Returns a resizer that contains a given resize handle.
79
- */
80
- private _getResizerByHandle;
81
- /**
82
- * @param domEventData Native DOM event.
83
- */
84
- private _mouseDownListener;
85
- /**
86
- * @param domEventData Native DOM event.
87
- */
88
- private _mouseMoveListener;
89
- private _mouseUpListener;
90
- }
91
- /**
92
- * Interface describing a resizer. It allows to specify the resizing host, custom logic for calculating aspect ratio, etc.
93
- */
94
- export interface ResizerOptions {
95
- /**
96
- * Editor instance associated with the resizer.
97
- */
98
- editor: Editor;
99
- modelElement: Element;
100
- /**
101
- * A view of an element to be resized. Typically it's the main widget's view instance.
102
- */
103
- viewElement: ViewContainerElement;
104
- unit?: 'px' | '%';
105
- /**
106
- * A callback to be executed once the resizing process is done.
107
- *
108
- * It receives a `Number` (`newValue`) as a parameter.
109
- *
110
- * For example, {@link module:image/imageresize~ImageResize} uses it to execute the resize image command
111
- * which puts the new value into the model.
112
- *
113
- * ```ts
114
- * {
115
- * editor,
116
- * modelElement: data.item,
117
- * viewElement: widget,
118
- *
119
- * onCommit( newValue ) {
120
- * editor.execute( 'resizeImage', { width: newValue } );
121
- * }
122
- * };
123
- * ```
124
- */
125
- onCommit: (newValue: string) => void;
126
- getResizeHost: (widgetWrapper: HTMLElement) => HTMLElement;
127
- getHandleHost: (widgetWrapper: HTMLElement) => HTMLElement;
128
- isCentered?: (resizer: Resizer) => boolean;
129
- }
@@ -1,98 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module widget/widgettoolbarrepository
11
- */
12
- import { Plugin, type ToolbarConfigItem } from '@ckeditor/ckeditor5-core';
13
- import type { ViewDocumentSelection, ViewElement } from '@ckeditor/ckeditor5-engine';
14
- import { ContextualBalloon } from '@ckeditor/ckeditor5-ui';
15
- /**
16
- * Widget toolbar repository plugin. A central point for registering widget toolbars. This plugin handles the whole
17
- * toolbar rendering process and exposes a concise API.
18
- *
19
- * To add a toolbar for your widget use the {@link ~WidgetToolbarRepository#register `WidgetToolbarRepository#register()`} method.
20
- *
21
- * The following example comes from the {@link module:image/imagetoolbar~ImageToolbar} plugin:
22
- *
23
- * ```ts
24
- * class ImageToolbar extends Plugin {
25
- * static get requires() {
26
- * return [ WidgetToolbarRepository ];
27
- * }
28
- *
29
- * afterInit() {
30
- * const editor = this.editor;
31
- * const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
32
- *
33
- * widgetToolbarRepository.register( 'image', {
34
- * items: editor.config.get( 'image.toolbar' ),
35
- * getRelatedElement: getClosestSelectedImageWidget
36
- * } );
37
- * }
38
- * }
39
- * ```
40
- */
41
- export default class WidgetToolbarRepository extends Plugin {
42
- /**
43
- * A map of toolbar definitions.
44
- */
45
- private _toolbarDefinitions;
46
- private _balloon;
47
- /**
48
- * @inheritDoc
49
- */
50
- static get requires(): readonly [typeof ContextualBalloon];
51
- /**
52
- * @inheritDoc
53
- */
54
- static get pluginName(): "WidgetToolbarRepository";
55
- /**
56
- * @inheritDoc
57
- */
58
- init(): void;
59
- destroy(): void;
60
- /**
61
- * Registers toolbar in the WidgetToolbarRepository. It renders it in the `ContextualBalloon` based on the value of the invoked
62
- * `getRelatedElement` function. Toolbar items are gathered from `items` array.
63
- * The balloon's CSS class is by default `ck-toolbar-container` and may be override with the `balloonClassName` option.
64
- *
65
- * Note: This method should be called in the {@link module:core/plugin~PluginInterface#afterInit `Plugin#afterInit()`}
66
- * callback (or later) to make sure that the given toolbar items were already registered by other plugins.
67
- *
68
- * @param toolbarId An id for the toolbar. Used to
69
- * @param options.ariaLabel Label used by assistive technologies to describe this toolbar element.
70
- * @param options.items Array of toolbar items.
71
- * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
72
- * @param options.balloonClassName CSS class for the widget balloon.
73
- */
74
- register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName }: {
75
- ariaLabel?: string;
76
- items: Array<ToolbarConfigItem>;
77
- getRelatedElement: (selection: ViewDocumentSelection) => (ViewElement | null);
78
- balloonClassName?: string;
79
- }): void;
80
- /**
81
- * Iterates over stored toolbars and makes them visible or hidden.
82
- */
83
- private _updateToolbarsVisibility;
84
- /**
85
- * Hides the given toolbar.
86
- */
87
- private _hideToolbar;
88
- /**
89
- * Shows up the toolbar if the toolbar is not visible.
90
- * Otherwise, repositions the toolbar's balloon when toolbar's view is the most top view in balloon stack.
91
- *
92
- * It might happen here that the toolbar's view is under another view. Then do nothing as the other toolbar view
93
- * should be still visible after the {@link module:ui/editorui/editorui~EditorUI#event:update}.
94
- */
95
- private _showToolbar;
96
- private _isToolbarVisible;
97
- private _isToolbarInBalloon;
98
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- import type { DocumentSelection, DomConverter, Element, Schema, Selection, ViewElement } from '@ckeditor/ckeditor5-engine';
10
- /**
11
- * The name of the type around model selection attribute responsible for
12
- * displaying a fake caret next to a selected widget.
13
- */
14
- export declare const TYPE_AROUND_SELECTION_ATTRIBUTE = "widget-type-around";
15
- /**
16
- * Checks if an element is a widget that qualifies to get the widget type around UI.
17
- */
18
- export declare function isTypeAroundWidget(viewElement: ViewElement | undefined, modelElement: Element, schema: Schema): boolean;
19
- /**
20
- * For the passed HTML element, this helper finds the closest widget type around button ancestor.
21
- */
22
- export declare function getClosestTypeAroundDomButton(domElement: HTMLElement): HTMLElement | null;
23
- /**
24
- * For the passed widget type around button element, this helper determines at which position
25
- * the paragraph would be inserted into the content if, for instance, the button was
26
- * clicked by the user.
27
- *
28
- * @returns The position of the button.
29
- */
30
- export declare function getTypeAroundButtonPosition(domElement: HTMLElement): 'before' | 'after';
31
- /**
32
- * For the passed HTML element, this helper returns the closest view widget ancestor.
33
- */
34
- export declare function getClosestWidgetViewElement(domElement: HTMLElement, domConverter: DomConverter): ViewElement;
35
- /**
36
- * For the passed selection instance, it returns the position of the fake caret displayed next to a widget.
37
- *
38
- * **Note**: If the fake caret is not currently displayed, `null` is returned.
39
- *
40
- * @returns The position of the fake caret or `null` when none is present.
41
- */
42
- export declare function getTypeAroundFakeCaretPosition(selection: Selection | DocumentSelection): 'before' | 'after' | null;
@@ -1,233 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module widget/widgettypearound/widgettypearound
11
- */
12
- import { Plugin } from '@ckeditor/ckeditor5-core';
13
- import { Enter } from '@ckeditor/ckeditor5-enter';
14
- import { Delete } from '@ckeditor/ckeditor5-typing';
15
- import '../../theme/widgettypearound.css';
16
- /**
17
- * A plugin that allows users to type around widgets where normally it is impossible to place the caret due
18
- * to limitations of web browsers. These "tight spots" occur, for instance, before (or after) a widget being
19
- * the first (or last) child of its parent or between two block widgets.
20
- *
21
- * This plugin extends the {@link module:widget/widget~Widget `Widget`} plugin and injects the user interface
22
- * with two buttons into each widget instance in the editor. Each of the buttons can be clicked by the
23
- * user if the widget is next to the "tight spot". Once clicked, a paragraph is created with the selection anchored
24
- * in it so that users can type (or insert content, paste, etc.) straight away.
25
- */
26
- export default class WidgetTypeAround extends Plugin {
27
- /**
28
- * A reference to the model widget element that has the fake caret active
29
- * on either side of it. It is later used to remove CSS classes associated with the fake caret
30
- * when the widget no longer needs it.
31
- */
32
- private _currentFakeCaretModelElement;
33
- /**
34
- * @inheritDoc
35
- */
36
- static get pluginName(): "WidgetTypeAround";
37
- /**
38
- * @inheritDoc
39
- */
40
- static get requires(): readonly [typeof Enter, typeof Delete];
41
- /**
42
- * @inheritDoc
43
- */
44
- init(): void;
45
- /**
46
- * @inheritDoc
47
- */
48
- destroy(): void;
49
- /**
50
- * Inserts a new paragraph next to a widget element with the selection anchored in it.
51
- *
52
- * **Note**: This method is heavily user-oriented and will both focus the editing view and scroll
53
- * the viewport to the selection in the inserted paragraph.
54
- *
55
- * @param widgetModelElement The model widget element next to which a paragraph is inserted.
56
- * @param position The position where the paragraph is inserted. Either `'before'` or `'after'` the widget.
57
- */
58
- private _insertParagraph;
59
- /**
60
- * A wrapper for the {@link module:utils/emittermixin~Emitter#listenTo} method that executes the callbacks only
61
- * when the plugin {@link #isEnabled is enabled}.
62
- *
63
- * @param emitter The object that fires the event.
64
- * @param event The name of the event.
65
- * @param callback The function to be called on event.
66
- * @param options Additional options.
67
- * @param options.priority The priority of this event callback. The higher the priority value the sooner
68
- * the callback will be fired. Events having the same priority are called in the order they were added.
69
- */
70
- private _listenToIfEnabled;
71
- /**
72
- * Similar to {@link #_insertParagraph}, this method inserts a paragraph except that it
73
- * does not expect a position. Instead, it performs the insertion next to a selected widget
74
- * according to the `widget-type-around` model selection attribute value (fake caret position).
75
- *
76
- * Because this method requires the `widget-type-around` attribute to be set,
77
- * the insertion can only happen when the widget's fake caret is active (e.g. activated
78
- * using the keyboard).
79
- *
80
- * @returns Returns `true` when the paragraph was inserted (the attribute was present) and `false` otherwise.
81
- */
82
- private _insertParagraphAccordingToFakeCaretPosition;
83
- /**
84
- * Creates a listener in the editing conversion pipeline that injects the widget type around
85
- * UI into every single widget instance created in the editor.
86
- *
87
- * The UI is delivered as a {@link module:engine/view/uielement~UIElement}
88
- * wrapper which renders DOM buttons that users can use to insert paragraphs.
89
- */
90
- private _enableTypeAroundUIInjection;
91
- /**
92
- * Brings support for the fake caret that appears when either:
93
- *
94
- * * the selection moves to a widget from a position next to it using arrow keys,
95
- * * the arrow key is pressed when the widget is already selected.
96
- *
97
- * The fake caret lets the user know that they can start typing or just press
98
- * <kbd>Enter</kbd> to insert a paragraph at the position next to a widget as suggested by the fake caret.
99
- *
100
- * The fake caret disappears when the user changes the selection or the editor
101
- * gets blurred.
102
- *
103
- * The whole idea is as follows:
104
- *
105
- * 1. A user does one of the 2 scenarios described at the beginning.
106
- * 2. The "keydown" listener is executed and the decision is made whether to show or hide the fake caret.
107
- * 3. If it should show up, the `widget-type-around` model selection attribute is set indicating
108
- * on which side of the widget it should appear.
109
- * 4. The selection dispatcher reacts to the selection attribute and sets CSS classes responsible for the
110
- * fake caret on the view widget.
111
- * 5. If the fake caret should disappear, the selection attribute is removed and the dispatcher
112
- * does the CSS class clean-up in the view.
113
- * 6. Additionally, `change:range` and `FocusTracker#isFocused` listeners also remove the selection
114
- * attribute (the former also removes widget CSS classes).
115
- */
116
- private _enableTypeAroundFakeCaretActivationUsingKeyboardArrows;
117
- /**
118
- * A listener executed on each "keydown" in the view document, a part of
119
- * {@link #_enableTypeAroundFakeCaretActivationUsingKeyboardArrows}.
120
- *
121
- * It decides whether the arrow keypress should activate the fake caret or not (also whether it should
122
- * be deactivated).
123
- *
124
- * The fake caret activation is done by setting the `widget-type-around` model selection attribute
125
- * in this listener, and stopping and preventing the event that would normally be handled by the widget
126
- * plugin that is responsible for the regular keyboard navigation near/across all widgets (that
127
- * includes inline widgets, which are ignored by the widget type around plugin).
128
- */
129
- private _handleArrowKeyPress;
130
- /**
131
- * Handles the keyboard navigation on "keydown" when a widget is currently selected and activates or deactivates
132
- * the fake caret for that widget, depending on the current value of the `widget-type-around` model
133
- * selection attribute and the direction of the pressed arrow key.
134
- *
135
- * @param isForward `true` when the pressed arrow key was responsible for the forward model selection movement
136
- * as in {@link module:utils/keyboard~isForwardArrowKeyCode}.
137
- * @returns Returns `true` when the keypress was handled and no other keydown listener of the editor should
138
- * process the event any further. Returns `false` otherwise.
139
- */
140
- private _handleArrowKeyPressOnSelectedWidget;
141
- /**
142
- * Handles the keyboard navigation on "keydown" when **no** widget is selected but the selection is **directly** next
143
- * to one and upon the fake caret should become active for this widget upon arrow keypress
144
- * (AKA entering/selecting the widget).
145
- *
146
- * **Note**: This code mirrors the implementation from the widget plugin but also adds the selection attribute.
147
- * Unfortunately, there is no safe way to let the widget plugin do the selection part first and then just set the
148
- * selection attribute here in the widget type around plugin. This is why this code must duplicate some from the widget plugin.
149
- *
150
- * @param isForward `true` when the pressed arrow key was responsible for the forward model selection movement
151
- * as in {@link module:utils/keyboard~isForwardArrowKeyCode}.
152
- * @returns Returns `true` when the keypress was handled and no other keydown listener of the editor should
153
- * process the event any further. Returns `false` otherwise.
154
- */
155
- private _handleArrowKeyPressWhenSelectionNextToAWidget;
156
- /**
157
- * Handles the keyboard navigation on "keydown" when a widget is currently selected (together with some other content)
158
- * and the widget is the first or last element in the selection. It activates or deactivates the fake caret for that widget.
159
- *
160
- * @param isForward `true` when the pressed arrow key was responsible for the forward model selection movement
161
- * as in {@link module:utils/keyboard~isForwardArrowKeyCode}.
162
- * @returns Returns `true` when the keypress was handled and no other keydown listener of the editor should
163
- * process the event any further. Returns `false` otherwise.
164
- */
165
- private _handleArrowKeyPressWhenNonCollapsedSelection;
166
- /**
167
- * Registers a `mousedown` listener for the view document which intercepts events
168
- * coming from the widget type around UI, which happens when a user clicks one of the buttons
169
- * that insert a paragraph next to a widget.
170
- */
171
- private _enableInsertingParagraphsOnButtonClick;
172
- /**
173
- * Creates the <kbd>Enter</kbd> key listener on the view document that allows the user to insert a paragraph
174
- * near the widget when either:
175
- *
176
- * * The fake caret was first activated using the arrow keys,
177
- * * The entire widget is selected in the model.
178
- *
179
- * In the first case, the new paragraph is inserted according to the `widget-type-around` selection
180
- * attribute (see {@link #_handleArrowKeyPress}).
181
- *
182
- * In the second case, the new paragraph is inserted based on whether a soft (<kbd>Shift</kbd>+<kbd>Enter</kbd>) keystroke
183
- * was pressed or not.
184
- */
185
- private _enableInsertingParagraphsOnEnterKeypress;
186
- /**
187
- * Similar to the {@link #_enableInsertingParagraphsOnEnterKeypress}, it allows the user
188
- * to insert a paragraph next to a widget when the fake caret was activated using arrow
189
- * keys but it responds to typing instead of <kbd>Enter</kbd>.
190
- *
191
- * Listener enabled by this method will insert a new paragraph according to the `widget-type-around`
192
- * model selection attribute as the user simply starts typing, which creates the impression that the fake caret
193
- * behaves like a real one rendered by the browser (AKA your text appears where the caret was).
194
- *
195
- * **Note**: At the moment this listener creates 2 undo steps: one for the `insertParagraph` command
196
- * and another one for actual typing. It is not a disaster but this may need to be fixed
197
- * sooner or later.
198
- */
199
- private _enableInsertingParagraphsOnTypingKeystroke;
200
- /**
201
- * It creates a "delete" event listener on the view document to handle cases when the <kbd>Delete</kbd> or <kbd>Backspace</kbd>
202
- * is pressed and the fake caret is currently active.
203
- *
204
- * The fake caret should create an illusion of a real browser caret so that when it appears before or after
205
- * a widget, pressing <kbd>Delete</kbd> or <kbd>Backspace</kbd> should remove a widget or delete the content
206
- * before or after a widget (depending on the content surrounding the widget).
207
- */
208
- private _enableDeleteIntegration;
209
- /**
210
- * Attaches the {@link module:engine/model/model~Model#event:insertContent} event listener that, for instance, allows the user to paste
211
- * content near a widget when the fake caret is first activated using the arrow keys.
212
- *
213
- * The content is inserted according to the `widget-type-around` selection attribute (see {@link #_handleArrowKeyPress}).
214
- */
215
- private _enableInsertContentIntegration;
216
- /**
217
- * Attaches the {@link module:engine/model/model~Model#event:insertObject} event listener that modifies the
218
- * `options.findOptimalPosition`parameter to position of fake caret in relation to selected element
219
- * to reflect user's intent of desired insertion position.
220
- *
221
- * The object is inserted according to the `widget-type-around` selection attribute (see {@link #_handleArrowKeyPress}).
222
- */
223
- private _enableInsertObjectIntegration;
224
- /**
225
- * Attaches the {@link module:engine/model/model~Model#event:deleteContent} event listener to block the event when the fake
226
- * caret is active.
227
- *
228
- * This is required for cases that trigger {@link module:engine/model/model~Model#deleteContent `model.deleteContent()`}
229
- * before calling {@link module:engine/model/model~Model#insertContent `model.insertContent()`} like, for instance,
230
- * plain text pasting.
231
- */
232
- private _enableDeleteContentIntegration;
233
- }