@ckeditor/ckeditor5-widget 46.0.2 → 46.1.0-alpha.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/dist/index.js +35 -10
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/utils.js +15 -3
- package/src/widget.d.ts +4 -0
- package/src/widget.js +22 -7
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-widget",
|
3
|
-
"version": "46.0.
|
3
|
+
"version": "46.1.0-alpha.0",
|
4
4
|
"description": "Widget API for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -12,13 +12,13 @@
|
|
12
12
|
"type": "module",
|
13
13
|
"main": "src/index.js",
|
14
14
|
"dependencies": {
|
15
|
-
"@ckeditor/ckeditor5-core": "46.0.
|
16
|
-
"@ckeditor/ckeditor5-engine": "46.0.
|
17
|
-
"@ckeditor/ckeditor5-enter": "46.0.
|
18
|
-
"@ckeditor/ckeditor5-icons": "46.0.
|
19
|
-
"@ckeditor/ckeditor5-ui": "46.0.
|
20
|
-
"@ckeditor/ckeditor5-utils": "46.0.
|
21
|
-
"@ckeditor/ckeditor5-typing": "46.0.
|
15
|
+
"@ckeditor/ckeditor5-core": "46.1.0-alpha.0",
|
16
|
+
"@ckeditor/ckeditor5-engine": "46.1.0-alpha.0",
|
17
|
+
"@ckeditor/ckeditor5-enter": "46.1.0-alpha.0",
|
18
|
+
"@ckeditor/ckeditor5-icons": "46.1.0-alpha.0",
|
19
|
+
"@ckeditor/ckeditor5-ui": "46.1.0-alpha.0",
|
20
|
+
"@ckeditor/ckeditor5-utils": "46.1.0-alpha.0",
|
21
|
+
"@ckeditor/ckeditor5-typing": "46.1.0-alpha.0",
|
22
22
|
"es-toolkit": "1.39.5"
|
23
23
|
},
|
24
24
|
"author": "CKSource (http://cksource.com/)",
|
package/src/utils.js
CHANGED
@@ -219,15 +219,27 @@ export function toWidgetEditable(editable, writer, options = {}) {
|
|
219
219
|
if (options.withAriaRole !== false) {
|
220
220
|
writer.setAttribute('role', 'textbox', editable);
|
221
221
|
}
|
222
|
-
|
222
|
+
// Setting tabindex=-1 on contenteditable=false makes it focusable. It propagates focus to the editable
|
223
|
+
// element and makes it possible to highlight nested editables as focused. It's not what we want
|
224
|
+
// for read-only editables though.
|
225
|
+
// See more: https://github.com/ckeditor/ckeditor5/issues/18965
|
226
|
+
if (!editable.isReadOnly) {
|
227
|
+
writer.setAttribute('tabindex', '-1', editable);
|
228
|
+
}
|
223
229
|
if (options.label) {
|
224
230
|
writer.setAttribute('aria-label', options.label, editable);
|
225
231
|
}
|
226
232
|
// Set initial contenteditable value.
|
227
233
|
writer.setAttribute('contenteditable', editable.isReadOnly ? 'false' : 'true', editable);
|
228
234
|
// Bind the contenteditable property to element#isReadOnly.
|
229
|
-
editable.on('change:isReadOnly', (evt, property,
|
230
|
-
writer.setAttribute('contenteditable',
|
235
|
+
editable.on('change:isReadOnly', (evt, property, isReadonly) => {
|
236
|
+
writer.setAttribute('contenteditable', isReadonly ? 'false' : 'true', editable);
|
237
|
+
if (isReadonly) {
|
238
|
+
writer.removeAttribute('tabindex', editable);
|
239
|
+
}
|
240
|
+
else {
|
241
|
+
writer.setAttribute('tabindex', '-1', editable);
|
242
|
+
}
|
231
243
|
});
|
232
244
|
editable.on('change:isFocused', (evt, property, is) => {
|
233
245
|
if (is) {
|
package/src/widget.d.ts
CHANGED
@@ -48,6 +48,10 @@ export declare class Widget extends Plugin {
|
|
48
48
|
* Handles {@link module:engine/view/document~ViewDocument#event:mousedown mousedown} events on widget elements.
|
49
49
|
*/
|
50
50
|
private _onMousedown;
|
51
|
+
/**
|
52
|
+
* Handles {@link module:engine/view/document~ViewDocument#event:pointerdown pointerdown} events on widget elements.
|
53
|
+
*/
|
54
|
+
private _onPointerdown;
|
51
55
|
/**
|
52
56
|
* Selects entire block content, e.g. on triple click it selects entire paragraph.
|
53
57
|
*/
|
package/src/widget.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* @module widget/widget
|
7
7
|
*/
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
9
|
-
import { MouseObserver, ModelTreeWalker } from '@ckeditor/ckeditor5-engine';
|
9
|
+
import { PointerObserver, MouseObserver, ModelTreeWalker } from '@ckeditor/ckeditor5-engine';
|
10
10
|
import { Delete } from '@ckeditor/ckeditor5-typing';
|
11
11
|
import { env, keyCodes, getLocalizedArrowKeyCodeDirection, getRangeFromMouseEvent } from '@ckeditor/ckeditor5-utils';
|
12
12
|
import { WidgetTypeAround } from './widgettypearound/widgettypearound.js';
|
@@ -123,7 +123,9 @@ export class Widget extends Plugin {
|
|
123
123
|
}, { priority: 'low' });
|
124
124
|
// If mouse down is pressed on widget - create selection over whole widget.
|
125
125
|
view.addObserver(MouseObserver);
|
126
|
+
view.addObserver(PointerObserver);
|
126
127
|
this.listenTo(viewDocument, 'mousedown', (...args) => this._onMousedown(...args));
|
128
|
+
this.listenTo(viewDocument, 'pointerdown', (...args) => this._onPointerdown(...args));
|
127
129
|
// There are two keydown listeners working on different priorities. This allows other
|
128
130
|
// features such as WidgetTypeAround or TableKeyboard to attach their listeners in between
|
129
131
|
// and customize the behavior even further in different content/selection scenarios.
|
@@ -216,10 +218,7 @@ export class Widget extends Plugin {
|
|
216
218
|
* Handles {@link module:engine/view/document~ViewDocument#event:mousedown mousedown} events on widget elements.
|
217
219
|
*/
|
218
220
|
_onMousedown(eventInfo, domEventData) {
|
219
|
-
const
|
220
|
-
const view = editor.editing.view;
|
221
|
-
const viewDocument = view.document;
|
222
|
-
let element = domEventData.target;
|
221
|
+
const element = domEventData.target;
|
223
222
|
// Some of DOM elements have no view element representation so it may be null.
|
224
223
|
if (!element) {
|
225
224
|
return;
|
@@ -229,6 +228,21 @@ export class Widget extends Plugin {
|
|
229
228
|
if (this._selectBlockContent(element)) {
|
230
229
|
domEventData.preventDefault();
|
231
230
|
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
/**
|
234
|
+
* Handles {@link module:engine/view/document~ViewDocument#event:pointerdown pointerdown} events on widget elements.
|
235
|
+
*/
|
236
|
+
_onPointerdown(eventInfo, domEventData) {
|
237
|
+
if (!domEventData.domEvent.isPrimary) {
|
238
|
+
return;
|
239
|
+
}
|
240
|
+
const editor = this.editor;
|
241
|
+
const view = editor.editing.view;
|
242
|
+
const viewDocument = view.document;
|
243
|
+
let element = domEventData.target;
|
244
|
+
// Some of DOM elements have no view element representation so it may be null.
|
245
|
+
if (!element) {
|
232
246
|
return;
|
233
247
|
}
|
234
248
|
// If target is not a widget element - check if one of the ancestors is.
|
@@ -251,9 +265,10 @@ export class Widget extends Plugin {
|
|
251
265
|
}
|
252
266
|
}
|
253
267
|
}
|
254
|
-
// On Android selection would jump to the first table cell, on other devices
|
268
|
+
// On Android and iOS selection would jump to the first table cell, on other devices
|
255
269
|
// we can't block it (and don't need to) because of drag and drop support.
|
256
|
-
|
270
|
+
// In iOS drag and drop works anyway on a long press.
|
271
|
+
if (env.isAndroid || env.isiOS) {
|
257
272
|
domEventData.preventDefault();
|
258
273
|
}
|
259
274
|
// Focus editor if is not focused already.
|