@ckeditor/ckeditor5-widget 0.0.0-nightly-20250226.0 → 0.0.0-nightly-next-20250226.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 +13 -15
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/src/highlightstack.js +1 -4
- package/src/utils.d.ts +0 -3
- package/src/utils.js +2 -2
- package/src/widget.js +4 -7
- package/src/widgetresize/resizer.js +22 -4
- package/src/widgetresize/resizerstate.js +36 -0
- package/src/widgetresize.js +7 -8
- package/src/widgettoolbarrepository.d.ts +3 -1
- package/src/widgettoolbarrepository.js +14 -15
- package/src/widgettypearound/widgettypearound.js +8 -11
- package/theme/icons/drag-handle.svg +0 -1
- package/theme/icons/return-arrow.svg +0 -1
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
|
+
* es-toolkit - Copyright (c) 2024 Viva Republica, Inc.
|
22
22
|
|
23
23
|
Trademarks
|
24
24
|
----------
|
package/dist/index.js
CHANGED
@@ -6,9 +6,10 @@ 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';
|
9
10
|
import { IconView, Template, ContextualBalloon, ToolbarView, BalloonPanelView, View } from '@ckeditor/ckeditor5-ui/dist/index.js';
|
10
11
|
import { Enter } from '@ckeditor/ckeditor5-enter/dist/index.js';
|
11
|
-
import { throttle } from '
|
12
|
+
import { throttle } from 'es-toolkit/compat';
|
12
13
|
|
13
14
|
/**
|
14
15
|
* Class used to handle the correct order of highlights on elements.
|
@@ -120,8 +121,6 @@ import { throttle } from 'lodash-es';
|
|
120
121
|
return Array.isArray(classes) ? classes.sort().join(',') : classes;
|
121
122
|
}
|
122
123
|
|
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
|
-
|
125
124
|
/**
|
126
125
|
* CSS class added to each widget element.
|
127
126
|
*/ const WIDGET_CLASS_NAME = 'ck-widget';
|
@@ -438,7 +437,7 @@ var dragHandleIcon = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/
|
|
438
437
|
const domElement = this.toDomElement(domDocument);
|
439
438
|
// Use the IconView from the ui library.
|
440
439
|
const icon = new IconView();
|
441
|
-
icon.set('content',
|
440
|
+
icon.set('content', IconDragHandle);
|
442
441
|
// Render the icon view right away to append its #element to the selectionHandle DOM element.
|
443
442
|
icon.render();
|
444
443
|
domElement.appendChild(icon.element);
|
@@ -536,14 +535,12 @@ var dragHandleIcon = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/
|
|
536
535
|
return selection.getAttribute(TYPE_AROUND_SELECTION_ATTRIBUTE);
|
537
536
|
}
|
538
537
|
|
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
|
-
|
541
538
|
const POSSIBLE_INSERTION_POSITIONS = [
|
542
539
|
'before',
|
543
540
|
'after'
|
544
541
|
];
|
545
542
|
// Do the SVG parsing once and then clone the result <svg> DOM element for each new button.
|
546
|
-
const RETURN_ARROW_ICON_ELEMENT = new DOMParser().parseFromString(
|
543
|
+
const RETURN_ARROW_ICON_ELEMENT = new DOMParser().parseFromString(IconReturnArrow, 'image/svg+xml').firstChild;
|
547
544
|
const PLUGIN_DISABLED_EDITING_ROOT_CLASS = 'ck-widget__type-around_disabled';
|
548
545
|
/**
|
549
546
|
* A plugin that allows users to type around widgets where normally it is impossible to place the caret due
|
@@ -2160,7 +2157,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2160
2157
|
* @param options.items Array of toolbar items.
|
2161
2158
|
* @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
|
2162
2159
|
* @param options.balloonClassName CSS class for the widget balloon.
|
2163
|
-
*/ register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container' }) {
|
2160
|
+
*/ register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container', positions }) {
|
2164
2161
|
// Trying to register a toolbar without any item.
|
2165
2162
|
if (!items.length) {
|
2166
2163
|
/**
|
@@ -2200,6 +2197,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2200
2197
|
getRelatedElement,
|
2201
2198
|
balloonClassName,
|
2202
2199
|
itemsConfig: items,
|
2200
|
+
positions,
|
2203
2201
|
initialized: false
|
2204
2202
|
};
|
2205
2203
|
// Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
|
@@ -2264,7 +2262,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2264
2262
|
* should be still visible after the {@link module:ui/editorui/editorui~EditorUI#event:update}.
|
2265
2263
|
*/ _showToolbar(toolbarDefinition, relatedElement) {
|
2266
2264
|
if (this._isToolbarVisible(toolbarDefinition)) {
|
2267
|
-
repositionContextualBalloon(this.editor, relatedElement);
|
2265
|
+
repositionContextualBalloon(this.editor, relatedElement, toolbarDefinition.positions);
|
2268
2266
|
} else if (!this._isToolbarInBalloon(toolbarDefinition)) {
|
2269
2267
|
if (!toolbarDefinition.initialized) {
|
2270
2268
|
toolbarDefinition.initialized = true;
|
@@ -2272,7 +2270,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2272
2270
|
}
|
2273
2271
|
this._balloon.add({
|
2274
2272
|
view: toolbarDefinition.view,
|
2275
|
-
position: getBalloonPositionData(this.editor, relatedElement),
|
2273
|
+
position: getBalloonPositionData(this.editor, relatedElement, toolbarDefinition.positions),
|
2276
2274
|
balloonClassName: toolbarDefinition.balloonClassName
|
2277
2275
|
});
|
2278
2276
|
// Update toolbar position each time stack with toolbar view is switched to visible.
|
@@ -2283,7 +2281,7 @@ function selectionWillShrink(selection, isForward) {
|
|
2283
2281
|
for (const definition of this._toolbarDefinitions.values()){
|
2284
2282
|
if (this._isToolbarVisible(definition)) {
|
2285
2283
|
const relatedElement = definition.getRelatedElement(this.editor.editing.view.document.selection);
|
2286
|
-
repositionContextualBalloon(this.editor, relatedElement);
|
2284
|
+
repositionContextualBalloon(this.editor, relatedElement, toolbarDefinition.positions);
|
2287
2285
|
}
|
2288
2286
|
}
|
2289
2287
|
});
|
@@ -2296,17 +2294,17 @@ function selectionWillShrink(selection, isForward) {
|
|
2296
2294
|
return this._balloon.hasView(toolbar.view);
|
2297
2295
|
}
|
2298
2296
|
}
|
2299
|
-
function repositionContextualBalloon(editor, relatedElement) {
|
2297
|
+
function repositionContextualBalloon(editor, relatedElement, positions) {
|
2300
2298
|
const balloon = editor.plugins.get('ContextualBalloon');
|
2301
|
-
const position = getBalloonPositionData(editor, relatedElement);
|
2299
|
+
const position = getBalloonPositionData(editor, relatedElement, positions);
|
2302
2300
|
balloon.updatePosition(position);
|
2303
2301
|
}
|
2304
|
-
function getBalloonPositionData(editor, relatedElement) {
|
2302
|
+
function getBalloonPositionData(editor, relatedElement, positions) {
|
2305
2303
|
const editingView = editor.editing.view;
|
2306
2304
|
const defaultPositions = BalloonPanelView.defaultPositions;
|
2307
2305
|
return {
|
2308
2306
|
target: editingView.domConverter.mapViewToDom(relatedElement),
|
2309
|
-
positions: [
|
2307
|
+
positions: positions || [
|
2310
2308
|
defaultPositions.northArrowSouth,
|
2311
2309
|
defaultPositions.northArrowSouthWest,
|
2312
2310
|
defaultPositions.northArrowSouthEast,
|