u2ui 1.5.4 → 1.5.8
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/js/rte/PLAN.md +42 -43
- package/js/rte/README.md +1 -1
- package/js/rte/playground/hosts.html +35 -0
- package/js/rte/playground/index.html +11 -0
- package/js/rte/run.out +17 -0
- package/js/rte/src/browser/interactive.js +17 -0
- package/js/rte/src/client/README.md +13 -6
- package/js/rte/src/client/editor.js +11 -0
- package/js/rte/src/client/images.js +32 -22
- package/js/rte/src/client/link.js +10 -15
- package/js/rte/src/client/tables.js +3 -0
- package/js/rte/src/command/README.md +4 -1
- package/js/rte/src/command/commands.js +4 -3
- package/js/rte/src/command/delete.js +8 -1
- package/js/rte/src/command/edit.js +8 -2
- package/js/rte/src/config/config.js +7 -0
- package/js/rte/src/core/README.md +25 -3
- package/js/rte/src/core/core.js +97 -6
- package/js/rte/src/input/README.md +18 -0
- package/js/rte/src/input/input-pipeline.js +45 -0
- package/js/rte/src/sanitize/README.md +5 -2
- package/js/rte/src/sanitize/policy.js +5 -1
- package/js/rte/src/ui/README.md +27 -6
- package/js/rte/src/ui/caret.js +17 -0
- package/js/rte/src/ui/chrome.js +1 -1
- package/js/rte/src/ui/handles.js +1 -1
- package/js/rte/src/ui/highlight.js +86 -0
- package/js/rte/src/ui/place.js +24 -2
- package/js/rte/src/ui/toolbar.js +16 -41
- package/package.json +1 -1
package/js/rte/src/ui/toolbar.js
CHANGED
|
@@ -8,7 +8,6 @@ export class Toolbar {
|
|
|
8
8
|
#surfaceController = null;
|
|
9
9
|
#surface = null;
|
|
10
10
|
#commands = null;
|
|
11
|
-
#dismissed = false;
|
|
12
11
|
#connected = true;
|
|
13
12
|
|
|
14
13
|
constructor(core, element, {commands, place = null} = {}) {
|
|
@@ -39,8 +38,6 @@ export class Toolbar {
|
|
|
39
38
|
}, listen);
|
|
40
39
|
element.addEventListener('click', this.#click, listen);
|
|
41
40
|
element.addEventListener('change', this.#change, listen);
|
|
42
|
-
core.root.addEventListener('focusin', this.#focusIn, {...listen, capture: true});
|
|
43
|
-
core.root.addEventListener('focusout', this.#focusOut, {...listen, capture: true});
|
|
44
41
|
if (!element.hasAttribute('role')) element.setAttribute('role', 'toolbar');
|
|
45
42
|
element.hidden = true;
|
|
46
43
|
// Focus landing in a control is still the editor's: without this the core
|
|
@@ -66,12 +63,16 @@ export class Toolbar {
|
|
|
66
63
|
const commands = surface?.connected ? this.#resolve(surface) : null;
|
|
67
64
|
if (commands != null && !registry(commands)) throw new TypeError('Toolbar commands must resolve to a command registry');
|
|
68
65
|
this.#commands = commands || null;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
// One computed style for the settings only this toolbar reads: asking for
|
|
67
|
+
// it three times is three style resolutions on a path every keystroke
|
|
68
|
+
// goes down. The shared ones keep coming from the surface, defaults and
|
|
69
|
+
// validation included.
|
|
70
|
+
const style = commands && getComputedStyle(surface.element);
|
|
71
|
+
const active = !!commands && surface.config.ui === 'roaming' && visibleForSelection(surface, style);
|
|
72
|
+
const names = active ? configured(style) : null;
|
|
72
73
|
// A host may prefer a toolbar that only ever shows what it can do, at
|
|
73
74
|
// the cost of a shape that moves with the caret.
|
|
74
|
-
const hiding = active && unavailable
|
|
75
|
+
const hiding = active && setting(style, 'toolbar-unavailable') === 'hide';
|
|
75
76
|
const detail = surface?.selection ? {range: surface.selection.range()} : undefined;
|
|
76
77
|
let visible = 0;
|
|
77
78
|
for (const item of this.#items()) {
|
|
@@ -138,7 +139,6 @@ export class Toolbar {
|
|
|
138
139
|
this.#surfaceController = null;
|
|
139
140
|
this.#surface = null;
|
|
140
141
|
this.#commands = null;
|
|
141
|
-
this.#dismissed = false;
|
|
142
142
|
display(this.#element, false);
|
|
143
143
|
this.#connected = false;
|
|
144
144
|
}
|
|
@@ -154,7 +154,6 @@ export class Toolbar {
|
|
|
154
154
|
}
|
|
155
155
|
this.#surfaceController?.abort();
|
|
156
156
|
this.#surface = surface || null;
|
|
157
|
-
this.#dismissed = false;
|
|
158
157
|
this.#surfaceController = null;
|
|
159
158
|
if (surface) {
|
|
160
159
|
const Controller = this.#element.ownerDocument.defaultView.AbortController;
|
|
@@ -194,18 +193,6 @@ export class Toolbar {
|
|
|
194
193
|
#disconnect = () => this.#activate(null);
|
|
195
194
|
#refresh = () => this.refresh();
|
|
196
195
|
|
|
197
|
-
#focusIn = event => {
|
|
198
|
-
if (!this.#dismissed || !this.#ownsFocus(event.composedPath()[0])) return;
|
|
199
|
-
this.#dismissed = false;
|
|
200
|
-
this.refresh();
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
#focusOut = event => {
|
|
204
|
-
if (!this.#ownsFocus(event.composedPath()[0]) || this.#ownsFocus(event.relatedTarget)) return;
|
|
205
|
-
this.#dismissed = true;
|
|
206
|
-
display(this.#element, false);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
196
|
// The toolbar is chrome: pointing at it must never move the editor's
|
|
210
197
|
// selection, not even at a control that currently has nothing to run.
|
|
211
198
|
// Fields keep their own pointer behaviour so they can be opened and typed in.
|
|
@@ -233,18 +220,6 @@ export class Toolbar {
|
|
|
233
220
|
}
|
|
234
221
|
this.#run(command, {value: name});
|
|
235
222
|
};
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
#ownsFocus(node) {
|
|
239
|
-
if (!node || !this.#surface) return false;
|
|
240
|
-
// A `focusout` listener outside the toolbar's shadow tree sees its
|
|
241
|
-
// related target retargeted to that tree's host, so focus moving into a
|
|
242
|
-
// control of its own would otherwise read as focus leaving.
|
|
243
|
-
const root = this.#element.getRootNode();
|
|
244
|
-
if (root.host && node === root.host) return true;
|
|
245
|
-
return node === this.#element || this.#element.contains(node)
|
|
246
|
-
|| node === this.#surface.element || this.#surface.element.contains(node);
|
|
247
|
-
}
|
|
248
223
|
}
|
|
249
224
|
|
|
250
225
|
function registry(value) {
|
|
@@ -254,18 +229,18 @@ function registry(value) {
|
|
|
254
229
|
&& typeof value?.run === 'function';
|
|
255
230
|
}
|
|
256
231
|
|
|
257
|
-
function
|
|
258
|
-
|
|
259
|
-
return value ? new Set(value.split(/[\s,]+/).filter(Boolean)) : null;
|
|
232
|
+
function setting(style, name) {
|
|
233
|
+
return style.getPropertyValue(`--u2-rte-${name}`).trim();
|
|
260
234
|
}
|
|
261
235
|
|
|
262
|
-
function
|
|
263
|
-
|
|
236
|
+
function configured(style) {
|
|
237
|
+
const value = setting(style, 'toolbar');
|
|
238
|
+
return value ? new Set(value.split(/[\s,]+/).filter(Boolean)) : null;
|
|
264
239
|
}
|
|
265
240
|
|
|
266
|
-
function visibleForSelection(surface) {
|
|
267
|
-
|
|
268
|
-
|
|
241
|
+
function visibleForSelection(surface, style) {
|
|
242
|
+
return setting(style, 'toolbar-when') !== 'selection'
|
|
243
|
+
|| !!surface.selection && !surface.selection.collapsed;
|
|
269
244
|
}
|
|
270
245
|
|
|
271
246
|
function state(item, value, disabled) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "u2ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "HTML Advanced: More Capabilities, Same Feel, Same Simplicity",
|
|
5
5
|
"keywords": ["web-components","pattern-library","component-library","ui-toolkit","design-system"],
|
|
6
6
|
"author": "Tobias Buschor",
|