@ckeditor/ckeditor5-widget 0.0.0-nightly-next-20250226.0 → 0.0.0-nightly-20250227.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.
Potentially problematic release.
This version of @ckeditor/ckeditor5-widget might be problematic. Click here for more details.
- package/LICENSE.md +1 -1
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
- package/src/highlightstack.js +4 -1
- package/src/utils.d.ts +3 -0
- package/src/utils.js +2 -2
- package/src/widget.js +7 -4
- package/src/widgetresize/resizer.js +4 -22
- package/src/widgetresize/resizerstate.js +0 -36
- package/src/widgetresize.js +8 -7
- package/src/widgettoolbarrepository.d.ts +1 -3
- package/src/widgettoolbarrepository.js +15 -14
- package/src/widgettypearound/widgettypearound.js +11 -8
- package/theme/icons/drag-handle.svg +1 -0
- package/theme/icons/return-arrow.svg +1 -0
package/LICENSE.md
CHANGED
@@ -18,7 +18,7 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
|
|
18
18
|
|
19
19
|
The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):
|
20
20
|
|
21
|
-
*
|
21
|
+
* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
|
22
22
|
|
23
23
|
Trademarks
|
24
24
|
----------
|
package/dist/index.js
CHANGED
@@ -6,10 +6,9 @@ import { Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
|
|
6
6
|
import { MouseObserver, TreeWalker } from '@ckeditor/ckeditor5-engine/dist/index.js';
|
7
7
|
import { Delete } from '@ckeditor/ckeditor5-typing/dist/index.js';
|
8
8
|
import { EmitterMixin, Rect, CKEditorError, toArray, isForwardArrowKeyCode, env, keyCodes, getLocalizedArrowKeyCodeDirection, getRangeFromMouseEvent, logWarning, ObservableMixin, compareArrays, global, DomEmitterMixin } from '@ckeditor/ckeditor5-utils/dist/index.js';
|
9
|
-
import { IconDragHandle, IconReturnArrow } from '@ckeditor/ckeditor5-icons/dist/index.js';
|
10
9
|
import { IconView, Template, ContextualBalloon, ToolbarView, BalloonPanelView, View } from '@ckeditor/ckeditor5-ui/dist/index.js';
|
11
10
|
import { Enter } from '@ckeditor/ckeditor5-enter/dist/index.js';
|
12
|
-
import { throttle } from 'es
|
11
|
+
import { throttle } from 'lodash-es';
|
13
12
|
|
14
13
|
/**
|
15
14
|
* Class used to handle the correct order of highlights on elements.
|
@@ -121,6 +120,8 @@ import { throttle } from 'es-toolkit/compat';
|
|
121
120
|
return Array.isArray(classes) ? classes.sort().join(',') : classes;
|
122
121
|
}
|
123
122
|
|
123
|
+
var dragHandleIcon = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M4 0v1H1v3H0V.5A.5.5 0 0 1 .5 0H4zm8 0h3.5a.5.5 0 0 1 .5.5V4h-1V1h-3V0zM4 16H.5a.5.5 0 0 1-.5-.5V12h1v3h3v1zm8 0v-1h3v-3h1v3.5a.5.5 0 0 1-.5.5H12z\"/><path fill-opacity=\".256\" d=\"M1 1h14v14H1z\"/><g class=\"ck-icon__selected-indicator\"><path d=\"M7 0h2v1H7V0zM0 7h1v2H0V7zm15 0h1v2h-1V7zm-8 8h2v1H7v-1z\"/><path fill-opacity=\".254\" d=\"M1 1h14v14H1z\"/></g></svg>";
|
124
|
+
|
124
125
|
/**
|
125
126
|
* CSS class added to each widget element.
|
126
127
|
*/ const WIDGET_CLASS_NAME = 'ck-widget';
|
@@ -437,7 +438,7 @@ import { throttle } from 'es-toolkit/compat';
|
|
437
438
|
const domElement = this.toDomElement(domDocument);
|
438
439
|
// Use the IconView from the ui library.
|
439
440
|
const icon = new IconView();
|
440
|
-
icon.set('content',
|
441
|
+
icon.set('content', dragHandleIcon);
|
441
442
|
// Render the icon view right away to append its #element to the selectionHandle DOM element.
|
442
443
|
icon.render();
|
443
444
|
domElement.appendChild(icon.element);
|
@@ -535,12 +536,14 @@ import { throttle } from 'es-toolkit/compat';
|
|
535
536
|
return selection.getAttribute(TYPE_AROUND_SELECTION_ATTRIBUTE);
|
536
537
|
}
|
537
538
|
|
539
|
+
var returnIcon = "<svg viewBox=\"0 0 10 8\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M9.055.263v3.972h-6.77M1 4.216l2-2.038m-2 2 2 2.038\"/></svg>";
|
540
|
+
|
538
541
|
const POSSIBLE_INSERTION_POSITIONS = [
|
539
542
|
'before',
|
540
543
|
'after'
|
541
544
|
];
|
542
545
|
// Do the SVG parsing once and then clone the result <svg> DOM element for each new button.
|
543
|
-
const RETURN_ARROW_ICON_ELEMENT = new DOMParser().parseFromString(
|
546
|
+
const RETURN_ARROW_ICON_ELEMENT = new DOMParser().parseFromString(returnIcon, 'image/svg+xml').firstChild;
|
544
547
|
const PLUGIN_DISABLED_EDITING_ROOT_CLASS = 'ck-widget__type-around_disabled';
|
545
548
|
/**
|
546
549
|
* A plugin that allows users to type around widgets where normally it is impossible to place the caret due
|
@@ -2157,7 +2160,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2157
2160
|
* @param options.items Array of toolbar items.
|
2158
2161
|
* @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
|
2159
2162
|
* @param options.balloonClassName CSS class for the widget balloon.
|
2160
|
-
*/ register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container'
|
2163
|
+
*/ register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container' }) {
|
2161
2164
|
// Trying to register a toolbar without any item.
|
2162
2165
|
if (!items.length) {
|
2163
2166
|
/**
|
@@ -2197,7 +2200,6 @@ function selectionWillShrink(selection, isForward) {
|
|
2197
2200
|
getRelatedElement,
|
2198
2201
|
balloonClassName,
|
2199
2202
|
itemsConfig: items,
|
2200
|
-
positions,
|
2201
2203
|
initialized: false
|
2202
2204
|
};
|
2203
2205
|
// Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
|
@@ -2262,7 +2264,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2262
2264
|
* should be still visible after the {@link module:ui/editorui/editorui~EditorUI#event:update}.
|
2263
2265
|
*/ _showToolbar(toolbarDefinition, relatedElement) {
|
2264
2266
|
if (this._isToolbarVisible(toolbarDefinition)) {
|
2265
|
-
repositionContextualBalloon(this.editor, relatedElement
|
2267
|
+
repositionContextualBalloon(this.editor, relatedElement);
|
2266
2268
|
} else if (!this._isToolbarInBalloon(toolbarDefinition)) {
|
2267
2269
|
if (!toolbarDefinition.initialized) {
|
2268
2270
|
toolbarDefinition.initialized = true;
|
@@ -2270,7 +2272,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2270
2272
|
}
|
2271
2273
|
this._balloon.add({
|
2272
2274
|
view: toolbarDefinition.view,
|
2273
|
-
position: getBalloonPositionData(this.editor, relatedElement
|
2275
|
+
position: getBalloonPositionData(this.editor, relatedElement),
|
2274
2276
|
balloonClassName: toolbarDefinition.balloonClassName
|
2275
2277
|
});
|
2276
2278
|
// Update toolbar position each time stack with toolbar view is switched to visible.
|
@@ -2281,7 +2283,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2281
2283
|
for (const definition of this._toolbarDefinitions.values()){
|
2282
2284
|
if (this._isToolbarVisible(definition)) {
|
2283
2285
|
const relatedElement = definition.getRelatedElement(this.editor.editing.view.document.selection);
|
2284
|
-
repositionContextualBalloon(this.editor, relatedElement
|
2286
|
+
repositionContextualBalloon(this.editor, relatedElement);
|
2285
2287
|
}
|
2286
2288
|
}
|
2287
2289
|
});
|
@@ -2294,17 +2296,17 @@ function selectionWillShrink(selection, isForward) {
|
|
2294
2296
|
return this._balloon.hasView(toolbar.view);
|
2295
2297
|
}
|
2296
2298
|
}
|
2297
|
-
function repositionContextualBalloon(editor, relatedElement
|
2299
|
+
function repositionContextualBalloon(editor, relatedElement) {
|
2298
2300
|
const balloon = editor.plugins.get('ContextualBalloon');
|
2299
|
-
const position = getBalloonPositionData(editor, relatedElement
|
2301
|
+
const position = getBalloonPositionData(editor, relatedElement);
|
2300
2302
|
balloon.updatePosition(position);
|
2301
2303
|
}
|
2302
|
-
function getBalloonPositionData(editor, relatedElement
|
2304
|
+
function getBalloonPositionData(editor, relatedElement) {
|
2303
2305
|
const editingView = editor.editing.view;
|
2304
2306
|
const defaultPositions = BalloonPanelView.defaultPositions;
|
2305
2307
|
return {
|
2306
2308
|
target: editingView.domConverter.mapViewToDom(relatedElement),
|
2307
|
-
positions:
|
2309
|
+
positions: [
|
2308
2310
|
defaultPositions.northArrowSouth,
|
2309
2311
|
defaultPositions.northArrowSouthWest,
|
2310
2312
|
defaultPositions.northArrowSouthEast,
|