gesso-core 0.6.15 → 0.6.16
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/CHANGELOG.md +11 -0
- package/dist/{CanvasSurface-LonsUsP3.js → CanvasSurface-Dz-AXwa4.js} +211 -22
- package/dist/CanvasSurface-Dz-AXwa4.js.map +1 -0
- package/dist/{index-BFmthg2S.d.ts → index-5CNL7kuO.d.ts} +219 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/CanvasSurface-LonsUsP3.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# gesso-core
|
|
2
2
|
|
|
3
|
+
## 0.6.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dd5c789: A painted node whose picture changes is repainted without being laid out again, unless the new picture declares a different intrinsic size. Before, every new picture marked layout, which for a painted node sized by its parent (`height: percent(100)`, say) laid the tree out again up to the root on every repaint: a minimap redrawn on each frame of a scroll re-measured thirteen nodes a frame for nothing. Property definitions gain `narrowEffects`, which lets a property mark less than its worst case for a particular change.
|
|
8
|
+
- b681046: A press whose node is taken out of the tree mid-drag goes on to the nearest of that node's ancestors still in it. A drag-select in a virtual list whose row scrolled out of view, and was unmounted, sent the rest of the drag to a node nothing could hear from; the list, and whatever listens above it, now gets it.
|
|
9
|
+
- 8149ae2: What a `textInput` surface draws is left out of the semantics tree: the editing proxy already carries its text as the field's value, so a screen reader heard it twice, and a keystroke in a code editor that redrew hundreds of runs rewrote as many elements of the accessibility mirror on the main thread.
|
|
10
|
+
- 4eed2fd: A node can take text without being a field: `textInput` makes it a surface that keeps and draws its own text, such as a code editor, and receives typed text through `onBeforeInput`, IME composition through the new `onCompositionStart`, `onCompositionUpdate` and `onCompositionEnd`, and the clipboard through `onPaste` and its state's `clipboard`. Keys belonging to an open IME composition (the Enter that commits a candidate, the arrows that choose one) are no longer forwarded as keys, which inserted a line on commit in a field too. A key whose `onKeyDown` called `preventDefault()` now keeps its text out, as in a browser; `UiKeyboardEvent.textFollows` says whether text follows a key at all. `fireEvent` gains `beforeInput`, the composition events, `copy` and `cut`.
|
|
11
|
+
|
|
12
|
+
Key events carry `code`, the physical key (`KeyZ`), so a shortcut can match Option+Z on a Mac, where the key is `Ω`.
|
|
13
|
+
|
|
3
14
|
## 0.6.15
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -187,6 +187,14 @@ let UiEventType = /* @__PURE__ */ function(UiEventType) {
|
|
|
187
187
|
* `preventDefault()` says it was taken.
|
|
188
188
|
*/
|
|
189
189
|
UiEventType["Paste"] = "paste";
|
|
190
|
+
/**
|
|
191
|
+
* An IME composition on a `textInput` surface: opened, its text so
|
|
192
|
+
* far, and committed. A field's composition is the field's own and
|
|
193
|
+
* never reaches here.
|
|
194
|
+
*/
|
|
195
|
+
UiEventType["CompositionStart"] = "compositionstart";
|
|
196
|
+
UiEventType["CompositionUpdate"] = "compositionupdate";
|
|
197
|
+
UiEventType["CompositionEnd"] = "compositionend";
|
|
190
198
|
UiEventType["Click"] = "click";
|
|
191
199
|
/**
|
|
192
200
|
* A second Click on the same node, soon enough after the first and
|
|
@@ -412,10 +420,14 @@ var UiPinchEvent = class extends UiInputEvent {
|
|
|
412
420
|
var UiKeyboardEvent = class extends UiInputEvent {
|
|
413
421
|
key;
|
|
414
422
|
modifiers;
|
|
415
|
-
|
|
423
|
+
textFollows;
|
|
424
|
+
code;
|
|
425
|
+
constructor(type, key, modifiers = noKeyModifiers(), textFollows = false, code = "") {
|
|
416
426
|
super(type);
|
|
417
427
|
this.key = key;
|
|
418
428
|
this.modifiers = modifiers;
|
|
429
|
+
this.textFollows = textFollows;
|
|
430
|
+
this.code = code;
|
|
419
431
|
}
|
|
420
432
|
};
|
|
421
433
|
/**
|
|
@@ -461,6 +473,23 @@ var UiPasteEvent = class extends UiInputEvent {
|
|
|
461
473
|
this.html = html;
|
|
462
474
|
}
|
|
463
475
|
};
|
|
476
|
+
/**
|
|
477
|
+
* An IME composition on a focused `textInput` surface.
|
|
478
|
+
*
|
|
479
|
+
* `text` is the composition so far (the committed text at
|
|
480
|
+
* `CompositionEnd`, empty when it was cancelled) and `caret` the
|
|
481
|
+
* IME's caret within it. The surface draws the composition where its
|
|
482
|
+
* carets are and replaces it with the committed text at the end.
|
|
483
|
+
*/
|
|
484
|
+
var UiCompositionEvent = class extends UiInputEvent {
|
|
485
|
+
text;
|
|
486
|
+
caret;
|
|
487
|
+
constructor(type, text = "", caret = text.length) {
|
|
488
|
+
super(type);
|
|
489
|
+
this.text = text;
|
|
490
|
+
this.caret = caret;
|
|
491
|
+
}
|
|
492
|
+
};
|
|
464
493
|
var UiTextChangeEvent = class extends UiInputEvent {
|
|
465
494
|
value;
|
|
466
495
|
selectionStart;
|
|
@@ -2680,7 +2709,8 @@ function defineProperty(options) {
|
|
|
2680
2709
|
compare: options.compare,
|
|
2681
2710
|
environmentKey: options.environmentKey,
|
|
2682
2711
|
resolveFromEnvironment: options.resolveFromEnvironment,
|
|
2683
|
-
validate: options.validate
|
|
2712
|
+
validate: options.validate,
|
|
2713
|
+
narrowEffects: options.narrowEffects
|
|
2684
2714
|
};
|
|
2685
2715
|
}
|
|
2686
2716
|
/**
|
|
@@ -4229,6 +4259,18 @@ const UiProperties = {
|
|
|
4229
4259
|
affects: 64
|
|
4230
4260
|
}),
|
|
4231
4261
|
/**
|
|
4262
|
+
* Makes the node a text input surface: it keeps and draws its own
|
|
4263
|
+
* text, and takes typed text, IME composition and the clipboard
|
|
4264
|
+
* through the shell's editing proxy while it has focus. The function
|
|
4265
|
+
* says what the proxy mirrors. See `UiTextInput`.
|
|
4266
|
+
*/
|
|
4267
|
+
textInput: defineProperty({
|
|
4268
|
+
name: "textInput",
|
|
4269
|
+
defaultValue: void 0,
|
|
4270
|
+
inherited: false,
|
|
4271
|
+
affects: 64
|
|
4272
|
+
}),
|
|
4273
|
+
/**
|
|
4232
4274
|
* `'none'` takes the node and its whole subtree out of hit testing, to
|
|
4233
4275
|
* block a region. Unlike CSS, a descendant cannot opt back in: its own
|
|
4234
4276
|
* `'auto'` is ignored under a `'none'` ancestor. For a container that
|
|
@@ -4636,9 +4678,10 @@ const UiProperties = {
|
|
|
4636
4678
|
*
|
|
4637
4679
|
* Layout as well as paint, for the reason `text` carries layout: a
|
|
4638
4680
|
* painter may declare an intrinsic size, and a node sized by its
|
|
4639
|
-
* content has to be measured again when that content changes.
|
|
4640
|
-
*
|
|
4641
|
-
*
|
|
4681
|
+
* content has to be measured again when that content changes. Only
|
|
4682
|
+
* then, though: a new picture that declares the same intrinsic size
|
|
4683
|
+
* as the old one (usually none) is a repaint and re-measures nothing,
|
|
4684
|
+
* however the node is sized (`narrowEffects`).
|
|
4642
4685
|
*
|
|
4643
4686
|
* See `rendering/PaintSurface.ts` for the vocabulary.
|
|
4644
4687
|
*/
|
|
@@ -4647,7 +4690,8 @@ const UiProperties = {
|
|
|
4647
4690
|
defaultValue: void 0,
|
|
4648
4691
|
inherited: false,
|
|
4649
4692
|
affects: 6,
|
|
4650
|
-
compare: paintValuesEqual
|
|
4693
|
+
compare: paintValuesEqual,
|
|
4694
|
+
narrowEffects: (previous, next, flags) => previous?.intrinsicWidth === next?.intrinsicWidth && previous?.intrinsicHeight === next?.intrinsicHeight ? flags & -5 : flags
|
|
4651
4695
|
}),
|
|
4652
4696
|
/** A static vector shape: `rendering/PaintSurface.ts`'s `UiPath`. */
|
|
4653
4697
|
path: defineProperty({
|
|
@@ -4703,6 +4747,12 @@ function getPropertyNames() {
|
|
|
4703
4747
|
return Array.from(registry.keys());
|
|
4704
4748
|
}
|
|
4705
4749
|
/**
|
|
4750
|
+
* The properties that narrow their effects for a particular change,
|
|
4751
|
+
* by name: few, so the graph's write path pays one map lookup and finds
|
|
4752
|
+
* nothing for nearly every property. See `narrowEffects`.
|
|
4753
|
+
*/
|
|
4754
|
+
const propertyNarrowers = new Map([...registry.values()].filter((definition) => definition.narrowEffects !== void 0).map((definition) => [definition.name, definition.narrowEffects]));
|
|
4755
|
+
/**
|
|
4706
4756
|
* Returns the dirty flags caused by changing the named property.
|
|
4707
4757
|
*
|
|
4708
4758
|
* Unknown properties are treated as generic property changes so
|
|
@@ -5356,7 +5406,9 @@ var UiGraph = class {
|
|
|
5356
5406
|
const previousValue = node.getProperty(property);
|
|
5357
5407
|
if (Object.is(previousValue, value)) return false;
|
|
5358
5408
|
node.setProperty(property, value);
|
|
5359
|
-
|
|
5409
|
+
const narrow = propertyNarrowers.get(property);
|
|
5410
|
+
const flags = narrow === void 0 ? dirtyFlags : narrow(previousValue, value, dirtyFlags);
|
|
5411
|
+
this.markDirty(node, this.withProvidedFlags(property, flags));
|
|
5360
5412
|
return true;
|
|
5361
5413
|
}
|
|
5362
5414
|
/**
|
|
@@ -8975,6 +9027,13 @@ function comparePositions(a, b) {
|
|
|
8975
9027
|
return 1;
|
|
8976
9028
|
}
|
|
8977
9029
|
//#endregion
|
|
9030
|
+
//#region src/editing/UiTextInput.ts
|
|
9031
|
+
/** The node's text input surface, if it is one. */
|
|
9032
|
+
function textInputOf(node) {
|
|
9033
|
+
const value = node.properties.get("textInput");
|
|
9034
|
+
return typeof value === "function" ? value : void 0;
|
|
9035
|
+
}
|
|
9036
|
+
//#endregion
|
|
8978
9037
|
//#region src/selection/TextSelectionGeometry.ts
|
|
8979
9038
|
const NO_RANGES = [];
|
|
8980
9039
|
/**
|
|
@@ -10157,6 +10216,8 @@ var UiPointerController = class {
|
|
|
10157
10216
|
return this.lastPosition;
|
|
10158
10217
|
}
|
|
10159
10218
|
lastPosition = null;
|
|
10219
|
+
/** The pressed node and its ancestors when the press began, deepest first. */
|
|
10220
|
+
downPath = [];
|
|
10160
10221
|
get hoveredNode() {
|
|
10161
10222
|
return this.hoverNode;
|
|
10162
10223
|
}
|
|
@@ -10164,6 +10225,20 @@ var UiPointerController = class {
|
|
|
10164
10225
|
get pressedNode() {
|
|
10165
10226
|
return this.downTarget;
|
|
10166
10227
|
}
|
|
10228
|
+
/**
|
|
10229
|
+
* Where the press's events go: the node it started on, or, once that
|
|
10230
|
+
* has been taken out of the tree, the nearest of its ancestors at the
|
|
10231
|
+
* time that is still in it. A row of a virtual list that scrolls out
|
|
10232
|
+
* of view in the middle of a drag-select is unmounted, and without
|
|
10233
|
+
* this the rest of the drag went to a node nothing could hear from;
|
|
10234
|
+
* the list it was in, and whoever is listening above it, still are.
|
|
10235
|
+
*/
|
|
10236
|
+
captured() {
|
|
10237
|
+
const path = this.downPath;
|
|
10238
|
+
const root = path[path.length - 1];
|
|
10239
|
+
for (const node of path) if (topOf(node) === root) return node;
|
|
10240
|
+
return this.downTarget;
|
|
10241
|
+
}
|
|
10167
10242
|
/** The scroll container whose thumb is being dragged, or null. */
|
|
10168
10243
|
get draggingScrollbarOf() {
|
|
10169
10244
|
return this.scrollbarDrag?.node ?? null;
|
|
@@ -10212,6 +10287,7 @@ var UiPointerController = class {
|
|
|
10212
10287
|
}
|
|
10213
10288
|
} else this.selection?.pointerDown(null, x, y, modifiers);
|
|
10214
10289
|
this.downTarget = target;
|
|
10290
|
+
this.downPath = pathOf(target);
|
|
10215
10291
|
this.downX = x;
|
|
10216
10292
|
this.downY = y;
|
|
10217
10293
|
this.downDefaultPrevented = event.defaultPrevented;
|
|
@@ -10237,10 +10313,11 @@ var UiPointerController = class {
|
|
|
10237
10313
|
}
|
|
10238
10314
|
if (this.downTarget !== null) {
|
|
10239
10315
|
const event = new UiPointerEvent("pointermove", x, y, buttons, modifiers, pointer);
|
|
10240
|
-
this.
|
|
10241
|
-
this.
|
|
10316
|
+
const captured = this.captured();
|
|
10317
|
+
this.dispatcher.dispatch(event, captured);
|
|
10318
|
+
this.gestures?.pointerMove(event, captured);
|
|
10242
10319
|
if (!event.defaultPrevented) {
|
|
10243
|
-
if (this.editing !== void 0 && this.editing.isEditable(
|
|
10320
|
+
if (this.editing !== void 0 && this.editing.isEditable(captured)) this.editing.pointerMove(captured, x, y);
|
|
10244
10321
|
else if (!this.downDefaultPrevented) this.selection?.pointerMove(x, y);
|
|
10245
10322
|
}
|
|
10246
10323
|
return event;
|
|
@@ -10272,9 +10349,10 @@ var UiPointerController = class {
|
|
|
10272
10349
|
this.activePointer = null;
|
|
10273
10350
|
return null;
|
|
10274
10351
|
}
|
|
10275
|
-
|
|
10276
|
-
|
|
10352
|
+
if (this.downTarget === null) return null;
|
|
10353
|
+
const target = this.captured();
|
|
10277
10354
|
this.downTarget = null;
|
|
10355
|
+
this.downPath = [];
|
|
10278
10356
|
this.activePointer = null;
|
|
10279
10357
|
this.editing?.pointerUp();
|
|
10280
10358
|
this.selection?.pointerUp();
|
|
@@ -10331,10 +10409,14 @@ var UiPointerController = class {
|
|
|
10331
10409
|
this.scrollbarDrag = null;
|
|
10332
10410
|
this.editing?.pointerUp();
|
|
10333
10411
|
this.selection?.pointerUp();
|
|
10334
|
-
|
|
10412
|
+
if (this.downTarget === null) {
|
|
10413
|
+
this.activePointer = null;
|
|
10414
|
+
return;
|
|
10415
|
+
}
|
|
10416
|
+
const target = this.captured();
|
|
10335
10417
|
this.downTarget = null;
|
|
10418
|
+
this.downPath = [];
|
|
10336
10419
|
this.activePointer = null;
|
|
10337
|
-
if (target === null) return;
|
|
10338
10420
|
const event = new UiPointerEvent("pointercancel", this.downX, this.downY, 0, noKeyModifiers(), pointer);
|
|
10339
10421
|
this.dispatcher.dispatch(event, target);
|
|
10340
10422
|
this.gestures?.pointerCancel();
|
|
@@ -10479,6 +10561,18 @@ const MULTI_CLICK_SLOP$1 = 4;
|
|
|
10479
10561
|
function defaultClock$2() {
|
|
10480
10562
|
return typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
10481
10563
|
}
|
|
10564
|
+
/** A node and its ancestors, deepest first. */
|
|
10565
|
+
function pathOf(node) {
|
|
10566
|
+
const path = [];
|
|
10567
|
+
for (let at = node; at !== null; at = at.parent) path.push(at);
|
|
10568
|
+
return path;
|
|
10569
|
+
}
|
|
10570
|
+
/** The top of the tree a node is in now. */
|
|
10571
|
+
function topOf(node) {
|
|
10572
|
+
let at = node;
|
|
10573
|
+
while (at.parent !== null) at = at.parent;
|
|
10574
|
+
return at;
|
|
10575
|
+
}
|
|
10482
10576
|
//#endregion
|
|
10483
10577
|
//#region src/input/UiKeyboardController.ts
|
|
10484
10578
|
/**
|
|
@@ -10539,12 +10633,14 @@ var UiKeyboardController = class {
|
|
|
10539
10633
|
* an editable held the focus — has the key inserted here, whatever the
|
|
10540
10634
|
* text source; absent leaves it to the editing controller's setting.
|
|
10541
10635
|
*/
|
|
10542
|
-
keyDown(key, modifiers = noKeyModifiers(), textFollows) {
|
|
10636
|
+
keyDown(key, modifiers = noKeyModifiers(), textFollows, code = "") {
|
|
10543
10637
|
if (!MODIFIER_KEYS.has(key)) this.focusManager.noteInput("keyboard");
|
|
10544
|
-
const
|
|
10638
|
+
const follows = textFollows ?? this.editing?.textFromKeys === false;
|
|
10639
|
+
const event = new UiKeyboardEvent("keydown", key, modifiers, follows, code);
|
|
10545
10640
|
const focused = this.focusManager.focusedNode;
|
|
10546
10641
|
const target = focused ?? this.root();
|
|
10547
10642
|
this.dispatcher.dispatch(event, target);
|
|
10643
|
+
this.editing?.noteKey?.(follows && event.defaultPrevented);
|
|
10548
10644
|
if (!event.defaultPrevented && focused !== null && this.editing !== void 0 && this.editing.handleKey(focused, key, modifiers, textFollows === false ? true : void 0)) {
|
|
10549
10645
|
event.preventDefault();
|
|
10550
10646
|
return event;
|
|
@@ -10572,8 +10668,9 @@ var UiKeyboardController = class {
|
|
|
10572
10668
|
}
|
|
10573
10669
|
return event;
|
|
10574
10670
|
}
|
|
10575
|
-
keyUp(key, modifiers = noKeyModifiers()) {
|
|
10576
|
-
|
|
10671
|
+
keyUp(key, modifiers = noKeyModifiers(), code = "") {
|
|
10672
|
+
this.editing?.noteKey?.(false);
|
|
10673
|
+
const event = new UiKeyboardEvent("keyup", key, modifiers, false, code);
|
|
10577
10674
|
const target = this.focusManager.focusedNode ?? this.root();
|
|
10578
10675
|
this.dispatcher.dispatch(event, target);
|
|
10579
10676
|
return event;
|
|
@@ -11733,6 +11830,15 @@ var UiEditingController = class {
|
|
|
11733
11830
|
platform;
|
|
11734
11831
|
paint = createPaintState();
|
|
11735
11832
|
focusedEditable = null;
|
|
11833
|
+
/**
|
|
11834
|
+
* The focused `textInput` surface, which keeps its own text: input is
|
|
11835
|
+
* dispatched to it as events rather than applied here. See `UiTextInput`.
|
|
11836
|
+
*/
|
|
11837
|
+
surface = null;
|
|
11838
|
+
/** The surface's open composition's text, or null while none is open. */
|
|
11839
|
+
surfaceComposition = null;
|
|
11840
|
+
/** The last key was cancelled, so the text that follows it is dropped. See `noteKey`. */
|
|
11841
|
+
textCancelled = false;
|
|
11736
11842
|
visible = true;
|
|
11737
11843
|
/** x the current run of vertical moves keeps returning to. */
|
|
11738
11844
|
verticalGoalX = void 0;
|
|
@@ -11779,6 +11885,20 @@ var UiEditingController = class {
|
|
|
11779
11885
|
get focused() {
|
|
11780
11886
|
return this.focusedEditable;
|
|
11781
11887
|
}
|
|
11888
|
+
/** The `textInput` surface that holds focus, or null. */
|
|
11889
|
+
get focusedSurface() {
|
|
11890
|
+
return this.surface;
|
|
11891
|
+
}
|
|
11892
|
+
/**
|
|
11893
|
+
* Each key down says whether a listener cancelled it, and each key up
|
|
11894
|
+
* that it is over. A cancelled key's text, which the shell's proxy
|
|
11895
|
+
* sends after it whatever happened (it cannot wait for the worker's
|
|
11896
|
+
* answer), is dropped when it arrives, as a browser drops the text of
|
|
11897
|
+
* a keydown whose default was prevented.
|
|
11898
|
+
*/
|
|
11899
|
+
noteKey(cancelled) {
|
|
11900
|
+
this.textCancelled = cancelled;
|
|
11901
|
+
}
|
|
11782
11902
|
/** Whether the pointer controller should hand presses on the node to this controller. */
|
|
11783
11903
|
isEditable(node) {
|
|
11784
11904
|
return isEditableNode(node);
|
|
@@ -11932,6 +12052,14 @@ var UiEditingController = class {
|
|
|
11932
12052
|
* twice.
|
|
11933
12053
|
*/
|
|
11934
12054
|
beforeInput(inputType, data) {
|
|
12055
|
+
if (this.textCancelled && inputType.startsWith("insert")) {
|
|
12056
|
+
this.textCancelled = false;
|
|
12057
|
+
return true;
|
|
12058
|
+
}
|
|
12059
|
+
if (this.surface !== null) {
|
|
12060
|
+
this.toSurface(new UiBeforeInputEvent(inputType, data));
|
|
12061
|
+
return true;
|
|
12062
|
+
}
|
|
11935
12063
|
const node = this.focusedEditable;
|
|
11936
12064
|
if (node === null) return false;
|
|
11937
12065
|
const model = editorFor(node);
|
|
@@ -11979,6 +12107,10 @@ var UiEditingController = class {
|
|
|
11979
12107
|
}
|
|
11980
12108
|
/** Inserts text at the selection of the focused editable, as typing would. */
|
|
11981
12109
|
insertText(text) {
|
|
12110
|
+
if (this.surface !== null) {
|
|
12111
|
+
this.toSurface(new UiBeforeInputEvent("insertText", text));
|
|
12112
|
+
return true;
|
|
12113
|
+
}
|
|
11982
12114
|
const node = this.focusedEditable;
|
|
11983
12115
|
if (node === null || isReadOnly(node)) return false;
|
|
11984
12116
|
return this.insert(node, editorFor(node), "insertText", text);
|
|
@@ -12027,6 +12159,11 @@ var UiEditingController = class {
|
|
|
12027
12159
|
return this.applyEdit(node, model, inputType, data, () => model.insertText(data), html);
|
|
12028
12160
|
}
|
|
12029
12161
|
compositionStart() {
|
|
12162
|
+
if (this.surface !== null) {
|
|
12163
|
+
this.surfaceComposition = "";
|
|
12164
|
+
this.toSurface(new UiCompositionEvent("compositionstart"));
|
|
12165
|
+
return;
|
|
12166
|
+
}
|
|
12030
12167
|
if (this.span !== null) this.spanEdit("deleteContent", null);
|
|
12031
12168
|
const node = this.focusedEditable;
|
|
12032
12169
|
if (node === null || isReadOnly(node)) return;
|
|
@@ -12038,6 +12175,12 @@ var UiEditingController = class {
|
|
|
12038
12175
|
}
|
|
12039
12176
|
/** The composition text so far and the caret within it. */
|
|
12040
12177
|
compositionUpdate(text, caret = text.length) {
|
|
12178
|
+
if (this.surface !== null) {
|
|
12179
|
+
if (this.surfaceComposition === null) this.toSurface(new UiCompositionEvent("compositionstart"));
|
|
12180
|
+
this.surfaceComposition = text;
|
|
12181
|
+
this.toSurface(new UiCompositionEvent("compositionupdate", text, caret));
|
|
12182
|
+
return;
|
|
12183
|
+
}
|
|
12041
12184
|
const node = this.focusedEditable;
|
|
12042
12185
|
if (node === null || isReadOnly(node)) return;
|
|
12043
12186
|
const model = editorFor(node);
|
|
@@ -12047,6 +12190,11 @@ var UiEditingController = class {
|
|
|
12047
12190
|
}
|
|
12048
12191
|
/** The IME committed `text` (possibly empty: the composition was cancelled). */
|
|
12049
12192
|
compositionEnd(text) {
|
|
12193
|
+
if (this.surface !== null) {
|
|
12194
|
+
this.surfaceComposition = null;
|
|
12195
|
+
this.toSurface(new UiCompositionEvent("compositionend", text));
|
|
12196
|
+
return;
|
|
12197
|
+
}
|
|
12050
12198
|
const node = this.focusedEditable;
|
|
12051
12199
|
this.compositionOpen = false;
|
|
12052
12200
|
if (node === null || isReadOnly(node)) return;
|
|
@@ -12187,6 +12335,7 @@ var UiEditingController = class {
|
|
|
12187
12335
|
}
|
|
12188
12336
|
/** The focused editable's state for the shell to mirror, or null. */
|
|
12189
12337
|
state() {
|
|
12338
|
+
if (this.surface !== null) return this.surfaceState(this.surface);
|
|
12190
12339
|
const node = this.focusedEditable;
|
|
12191
12340
|
if (node === null || this.host.recordFor(node) === void 0) return null;
|
|
12192
12341
|
const model = editorFor(node);
|
|
@@ -12251,6 +12400,14 @@ var UiEditingController = class {
|
|
|
12251
12400
|
}
|
|
12252
12401
|
handleFocusChange(node) {
|
|
12253
12402
|
if (this.span !== null && !this.spanFocusing && node !== this.span.focus.node) this.clearSpan();
|
|
12403
|
+
const surface = node !== null && !isEditableNode(node) && textInputOf(node) !== void 0 ? node : null;
|
|
12404
|
+
if (surface !== this.surface) {
|
|
12405
|
+
const left = this.surface;
|
|
12406
|
+
const open = this.surfaceComposition;
|
|
12407
|
+
this.surface = surface;
|
|
12408
|
+
this.surfaceComposition = null;
|
|
12409
|
+
if (left !== null && open !== null) this.dispatcher.dispatch(new UiCompositionEvent("compositionend", open), left);
|
|
12410
|
+
}
|
|
12254
12411
|
const previous = this.focusedEditable;
|
|
12255
12412
|
const next = node !== null && isEditableNode(node) ? node : null;
|
|
12256
12413
|
if (previous === next) return;
|
|
@@ -12272,6 +12429,25 @@ var UiEditingController = class {
|
|
|
12272
12429
|
this.host.markDirty(next, 2);
|
|
12273
12430
|
}
|
|
12274
12431
|
}
|
|
12432
|
+
/** Hands an input event to the focused surface. */
|
|
12433
|
+
toSurface(event) {
|
|
12434
|
+
if (this.surface !== null) this.dispatcher.dispatch(event, this.surface);
|
|
12435
|
+
}
|
|
12436
|
+
/** What the shell mirrors for a focused surface: what it says, with its caret placed on the canvas. */
|
|
12437
|
+
surfaceState(node) {
|
|
12438
|
+
const source = textInputOf(node);
|
|
12439
|
+
if (source === void 0 || this.host.recordFor(node) === void 0) return null;
|
|
12440
|
+
const surface = source();
|
|
12441
|
+
return {
|
|
12442
|
+
text: surface.text,
|
|
12443
|
+
selectionStart: surface.selectionStart,
|
|
12444
|
+
selectionEnd: surface.selectionEnd,
|
|
12445
|
+
caret: this.drawnBox(node, surface.caret),
|
|
12446
|
+
multiline: surface.multiline ?? true,
|
|
12447
|
+
composing: this.surfaceComposition !== null,
|
|
12448
|
+
...surface.clipboard === void 0 ? {} : { clipboard: surface.clipboard }
|
|
12449
|
+
};
|
|
12450
|
+
}
|
|
12275
12451
|
/**
|
|
12276
12452
|
* Runs an edit unless a `beforeinput` listener cancels it, then
|
|
12277
12453
|
* reports it. Returns true when the input was consumed either way.
|
|
@@ -12685,11 +12861,13 @@ var UiPlatformAdapter = class {
|
|
|
12685
12861
|
};
|
|
12686
12862
|
this.keyDownHandler = (e) => {
|
|
12687
12863
|
const k = e;
|
|
12688
|
-
if (
|
|
12864
|
+
if (isImeKey(k)) return;
|
|
12865
|
+
if (this.keyboard.keyDown(k.key, modifiersFromEvent(k), void 0, k.code ?? "").defaultPrevented) k.preventDefault();
|
|
12689
12866
|
};
|
|
12690
12867
|
this.keyUpHandler = (e) => {
|
|
12691
12868
|
const k = e;
|
|
12692
|
-
|
|
12869
|
+
if (isImeKey(k)) return;
|
|
12870
|
+
this.keyboard.keyUp(k.key, modifiersFromEvent(k), k.code ?? "");
|
|
12693
12871
|
};
|
|
12694
12872
|
surface.pointerTarget.addEventListener("pointerdown", this.pointerDownHandler);
|
|
12695
12873
|
surface.pointerTarget.addEventListener("pointermove", this.pointerMoveHandler);
|
|
@@ -12769,6 +12947,17 @@ function capturePointer(target, pointerId) {
|
|
|
12769
12947
|
element.setPointerCapture(pointerId);
|
|
12770
12948
|
} catch {}
|
|
12771
12949
|
}
|
|
12950
|
+
/**
|
|
12951
|
+
* Whether a key belongs to an IME rather than to the application: one
|
|
12952
|
+
* pressed while a composition is open (the arrows that move through
|
|
12953
|
+
* candidates, the Enter that commits one, the Backspace that edits the
|
|
12954
|
+
* reading) or the key that opens one, which browsers report with
|
|
12955
|
+
* `keyCode` 229. Its effect arrives as composition events; handled as a
|
|
12956
|
+
* key too, the Enter that commits a candidate would also insert a line.
|
|
12957
|
+
*/
|
|
12958
|
+
function isImeKey(event) {
|
|
12959
|
+
return event.isComposing === true || event.keyCode === 229;
|
|
12960
|
+
}
|
|
12772
12961
|
function modifiersFromEvent(event) {
|
|
12773
12962
|
return {
|
|
12774
12963
|
shift: event.shiftKey,
|
|
@@ -21228,6 +21417,6 @@ function createCanvasSurface(host) {
|
|
|
21228
21417
|
return new CanvasSurface(host);
|
|
21229
21418
|
}
|
|
21230
21419
|
//#endregion
|
|
21231
|
-
export {
|
|
21420
|
+
export { isImeKey as $, UiEventType as $a, defaultShadows as $i, proportionalFontMetrics as $n, gradientPaint as $r, registerFontStack as $t, withOverrideSource as A, colorsEqual as Aa, bandOf as Ai, linkHoverOf as An, propertyIsInherited as Ar, adjacentField as At, FlexDirection as B, clearOverrideProperty as Ba, noThemeExtensions as Bi, isEditableNode as Bn, validateRole as Br, createCanvasTextStyle as Bt, SCROLLBAR_LINGER_MS as C, colorsEqualPalette as Ca, propertyValuesEqual as Ci, isNodeInert as Cn, resolveString as Cr, hasDrawnText as Ct, formatExplanation as D, colorToHex as Da, noInsets as Di, resolveCursor as Dn, inheritedPropertyFlags as Dr, selectionRectsIn as Dt, formatConstraints as E, UiBasicColors as Ea, insetsEqual as Ei, isPressable as En, getPropertyNames as Er, paragraphGeometryFrom as Et, clampSize as F, createEnvironmentKey as Fa, themesEqual as Fi, CARET_WIDTH as Fn, UI_SEMANTIC_STATES as Fr, detectEditingPlatform as Ft, CrossAxisAlignment as G, UiVisualState as Ga, highContrastColors as Gi, resolveColorValue as Gn, paintValuesEqual as Gr, runFontString as Gt, placeGridItems as H, resetOverrideWarnings as Ha, themeExtensionsEqual as Hi, isReadOnly as Hn, UI_SUBGRID_AXES as Hr, fillTextRects as Ht, constraintsEqual as I, findEnvironmentKey as Ia, withContrast as Ii, EDITOR_PROP as In, isUiRole as Ir, isPrintable as It, parseCrossAxisAlignment as J, visualState as Ja, densityFactors as Ji, CharacterCountTextMeasurer as Jn, parseTransform as Jr, textRunBackgrounds as Jt, MainAxisAlignment as K, defaultVisualState as Ka, raiseContrast as Ki, isVideoSurface as Kn, pathValuesEqual as Kr, spanOf as Kt, tightenConstraints as L, UiEnvironment as La, withDensity as Li, caretVisibleAt as Ln, isUiSemanticState as Lr, EditableLayout as Lt, contentOffset as M, parseColor as Ma, unknownContainerSize as Mi, linkRunAtPointIn as Mn, propertyValuesEqualByName as Mr, edgeField as Mt, LayoutRecord as N, rgb8 as Na, darkTheme as Ni, setLinkHover as Nn, UiProperties as Nr, editingGroupOf as Nt, formatNumber as O, colorToRgba as Oa, observeViewportInsets as Oi, clearLinkHover as On, inheritedPropertyNames as Or, wordRangeIn as Ot, Constraints as P, rgba as Pa, lightTheme as Pi, CARET_BLINK_MS as Pn, UI_ROLES as Pr, commandForKey as Pt, capturePointer as Q, UiCompositionEvent as Qa, spacingSteps as Qi, layoutParagraph as Qn, MAX_GRADIENT_STOPS as Qr, fontStackFor as Qt, MAX_MEASURES_PER_CHILD as R, UiNode as Ra, defineThemeExtension as Ri, editorFor as Rn, normalizeStates as Rr, applyCanvasTextStyle as Rt, SCROLLBAR_FADE_MS as S, textStylesEqual as Sa, defineProperty as Si, isNodeHitTestable as Sn, resolvePropertyByName as Sr, UiInputDispatcher as St, describeOverrides as T, lightColors as Ta, UiInsetRegistry as Ti, isNodeTabStop as Tn, findPropertyDefinition as Tr, paragraphGeometry as Tt, sizeGridTracks as U, writeDeclaredProperty as Ua, withThemeExtension as Ui, nextCaretToggle as Un, validateSubgrid as Ur, layoutTextLines as Ut, parseFlexDirection as V, overrideSources as Va, themeExtension as Vi, isMultiline as Vn, validateStates as Vr, drawText as Vt, AlignContent as W, writeOverrideProperty as Wa, contrastRatio as Wi, syncEditorValue as Wn, inputsEqual as Wr, runCanvasStyleInto as Wt, CanvasPlatformSurface as X, MOUSE_POINTER as Xa, scaleSpacing as Xi, spannedRunsFor as Xn, transformIsIdentity as Xr, bumpFontStack as Xt, parseMainAxisAlignment as Y, visualStatesEqual as Ya, defaultSpacing as Yi, ParagraphTextMeasurer as Yn, transform as Yr, textRunDecorations as Yt, UiPlatformAdapter as Z, UiBeforeInputEvent as Za, spacingEqual as Zi, ELLIPSIS as Zn, transformsEqual as Zr, clearFontStacks as Zt, LABEL_PADDING_X as _, resolvedSpansOf as _a, borderRadiusEqual as _i, selectableTextNodes as _n, UiGraph as _r, scrollLeaderOf as _t, PaintPictureCache as a, boxShadowReach as aa, fr as ai, computeObjectFitRect as an, UiPinchEvent as ao, offsetAtX as ar, UiGestureRecognizer as at, snapScroll as b, textContentOf as ba, normalizeBorderRadius as bi, setSelectionRange as bn, resolveNumber as br, scrollbarThumbs as bt, EMPTY_RECORDING as c, isShapeName as ca, isMinMaxTrack as ci, normalizeTextAlign as cn, UiTextChangeEvent as co, EditableTextModel as cr, isScrollContainer as ct, tracePathData as d, isTypographyRole as da, percent as di, TEXT_MATCHES_PROP as dn, noKeyModifiers as do, lineStartAt as dr, UiFocusManager as dt, shadowsEqual as ea, gradientsEqual as ei, DEFAULT_FONT_FAMILY as en, UiFocusEvent as eo, caretRectFor as er, pointerDeviceOf as et, ScaledImageCache as f, typographyEqual as fa, repeat as fi, clearMatchRanges as fn, wheelDeltaYOf as fo, nextGraphemeEnd as fr, UiHitTester as ft, paintsAfterChildren as g, hiddenRangesOf as ga, borderRadiusCorners as gi, clearSelectionRange as gn, wordRangeAt as gr, SCROLLBAR_THICKNESS as gt, hasDecorationPhase as h, flattenTextSpans as ha, borderRadius as hi, TEXT_SELECTION_PROP as hn, UiBinding as ho, previousWordStart as hr, SCROLLBAR_MIN_THUMB as ht, traceRoundedRect as i, boxShadowRadius as ia, auto as ii, colorToCss as in, UiPasteEvent as io, offsetAtPoint as ir, UiTouchScroller as it, accumulatedOffsetTo as j, normalizeColor as ja, containerBands as ji, linkOf as jn, propertyNarrowers as jr, comparePositions as jt, labelNode as k, colorValuesEqual as ka, UiContainerSizeSource as ki, hasTextLinks as kn, propertyEffects as kr, textInputOf as kt, PaintRecorder as l, shapesEqual as la, isPercentLength as li, normalizeVerticalAlign as ln, UiWheelDeltaMode as lo, graphemeBoundaries as lr, UiKeyboardController as lt, decorationRect as m, editableSpansOf as ma, UiBorderRadiuses as mi, setMatchRanges as mn, DirtyFlags as mo, previousGraphemeStart as mr, SCROLLBAR_INSET as mt, createCanvasSurface as n, boxShadow as na, radialGradient as ni, DEFAULT_FONT_WEIGHT as nn, UiInputEvent as no, lineIndexForOffset as nr, touchActionFor as nt, paintPictures as o, boxShadowsEqual as oa, isAutoLength as oi, createPaintState as on, UiPointerEvent as oo, offsetForVerticalMove as or, UiPinchRecognizer as ot, decorationColor as p, defaultTextStyle as pa, resolveLength as pi, matchRangesOf as pn, UiNodeType as po, nextWordEnd as pr, SCROLLBAR_HOVER_ZONE as pt, parseAlignContent as q, hasVisualState as qa, relativeLuminance as qi, videoFrameSize as qn, UiTransforms as qr, textMeasureRequest as qt, Canvas2DRenderer as r, boxShadowArraysEqual as ra, validateGradient as ri, DEFAULT_TEXT_COLOR as rn, UiKeyboardEvent as ro, lineLimit as rr, UiEditingController as rt, PaintTarget as s, defaultShapes as sa, isFrLength as si, isPaintVisible as sn, UiSelectionChangeEvent as so, selectionRects as sr, UiWheelController as st, CanvasSurface as t, BOX_SHADOW_BLUR_REACH as ta, linearGradient as ti, DEFAULT_FONT_SIZE as tn, UiGestureEvent as to, lineIndexAtY as tr, prepareInputSurface as tt, replayPaint as u, defaultTypography as ua, minmax as ui, resolvePaintState as un, UiWheelEvent as uo, lineEndAt as ur, UiPointerController as ut, drawOverlayShapes as v, spanAtOffset as va, borderRadiusIsZero as vi, selectableTextOf as vn, DEFAULT_LINE_HEIGHT_FACTOR as vr, scrollRange as vt, describeLength as w, darkColors as wa, UiEnvironmentKeys as wi, isNodeSelectable as wn, closestPropertyName as wr, offsetAtPointIn as wt, LayoutEngine as x, textSpansEqual as xa, uniformBorderRadius as xi, isNodeFocusable as xn, resolveProperty as xr, scrollbarZoneAt as xt, labelOrigin as y, spannedTextOf as ya, borderRadiusValuesEqual as yi, selectionRangeOf as yn, resolveBoolean as yr, scrollbarThumb as yt, isLayoutProtocol as z, DirtyNodeSet as za, hasThemeExtension as zi, editorOf as zn, statesEqual as zr, buildFontString as zt };
|
|
21232
21421
|
|
|
21233
|
-
//# sourceMappingURL=CanvasSurface-
|
|
21422
|
+
//# sourceMappingURL=CanvasSurface-Dz-AXwa4.js.map
|