@fulate/ui 1.0.14 → 1.0.19
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/README.md +32 -19
- package/dist/authored-path.d.ts +2 -2
- package/dist/bitmap.d.ts +15 -0
- package/dist/editor/capability.d.ts +2 -1
- package/dist/editor/shape.d.ts +3 -3
- package/dist/editor/transform.d.ts +1 -1
- package/dist/group.d.ts +10 -8
- package/dist/image.d.ts +8 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +315 -256
- package/dist/line/base.d.ts +1 -1
- package/dist/line-tree/index.d.ts +5 -4
- package/dist/line-tree/topology.d.ts +3 -6
- package/dist/line-tree/transform.d.ts +1 -0
- package/dist/polygon.d.ts +2 -1
- package/dist/scrollview.d.ts +2 -2
- package/dist/text/index.d.ts +1 -0
- package/dist/text/layout.d.ts +1 -0
- package/dist/vector-path.d.ts +2 -2
- package/dist/worker-surface-worker.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { clearCache, layoutNextLineRange, layoutWithLines, materializeLineRange, measureLineStats, measureNaturalWidth, prepareWithSegments } from "@chenglou/pretext";
|
|
2
|
-
import { ChangeImpact, CustomEvent, Element, ElementProperties, ElementTransform, SKIN_DEFAULTS, Shape, ShapeProperties, ShapeTransform, createAuthoredLineSubpath, createGeometrySnapshot, createLineSubpath, createPathLocalId, evaluatePathSegmentPoint, getElementConnectionPort, getElementConnectionPortPoint, isReparentTransformIntent, mergeOwnerPropertyChanges, resolveAuthoredGeometryFramePatch, resolveAuthoredSubpath, resolveReferenceBoundsTranslation, resolveReferenceTransform,
|
|
1
|
+
import { clearCache, layout, layoutNextLine, layoutNextLineRange, layoutWithLines, materializeLineRange, measureLineStats, measureNaturalWidth, prepareWithSegments } from "@chenglou/pretext";
|
|
2
|
+
import { ChangeImpact, CustomEvent, Element, ElementProperties, ElementTransform, SKIN_DEFAULTS, Shape, ShapeProperties, ShapeTransform, createAuthoredLineSubpath, createGeometrySnapshot, createLineSubpath, createPathLocalId, evaluatePathSegmentPoint, getAuthoredPathLayoutBounds, getElementConnectionPort, getElementConnectionPortPoint, isReparentTransformIntent, mergeOwnerPropertyChanges, resolveAuthoredGeometryFramePatch, resolveAuthoredSubpath, resolveReferenceBoundsTranslation, resolveReferenceTransform, splitPathSegment } from "@fulate/core";
|
|
3
3
|
import { clamp, has, isFunction, isNil, isNull, isString, isUndefined, last } from "lodash-es";
|
|
4
|
-
import { Bound, Intersection, createCanvasGradient, createPointView, isGradient,
|
|
4
|
+
import { Bound, Intersection, Matrix2D, createCanvasGradient, createPointView, isGradient, isPointWithinDistance, rectEdgePosition, transformPoint } from "@fulate/share";
|
|
5
5
|
import { computePosition as computePosition$1, flip, offset, shift } from "@floating-ui/core";
|
|
6
6
|
import { Easing, Tween } from "@tweenjs/tween.js";
|
|
7
7
|
//#region packages/ui/src/text/layout.ts
|
|
@@ -287,24 +287,47 @@ var PreparedTextLayout = class {
|
|
|
287
287
|
return new TextLayoutSnapshot(this.normalizedText, this.font, this.letterSpacing, options.lineHeight, this.naturalWidth, rawLineCount > 0 ? [this.normalizedText] : [], rawLineCount, truncated, lines, lines.length === 0 ? 0 : this.naturalWidth);
|
|
288
288
|
}
|
|
289
289
|
const prepared = this.getRichPrepared();
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
290
|
+
const wrapWidth = getWrapWidth(options);
|
|
291
|
+
const visibleLineLimit = getVisibleLineLimit(options);
|
|
292
|
+
let rawLineCount;
|
|
293
|
+
let lines;
|
|
294
|
+
if (Number.isFinite(visibleLineLimit)) {
|
|
295
|
+
lines = [];
|
|
296
|
+
let cursor = {
|
|
297
|
+
segmentIndex: 0,
|
|
295
298
|
graphemeIndex: 0
|
|
296
299
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
300
|
+
while (lines.length < visibleLineLimit) {
|
|
301
|
+
const line = layoutNextLine(prepared, cursor, wrapWidth);
|
|
302
|
+
if (!line) break;
|
|
303
|
+
line.ellipsized = false;
|
|
304
|
+
lines.push(line);
|
|
305
|
+
cursor = line.end;
|
|
306
|
+
}
|
|
307
|
+
rawLineCount = cursor.segmentIndex === prepared.segments.length ? lines.length : layout(prepared, wrapWidth, options.lineHeight).lineCount;
|
|
308
|
+
} else {
|
|
309
|
+
const result = layoutWithLines(prepared, wrapWidth, options.lineHeight);
|
|
310
|
+
rawLineCount = result.lineCount;
|
|
311
|
+
lines = result.lines;
|
|
312
|
+
for (const line of lines) line.ellipsized = false;
|
|
304
313
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
314
|
+
if (this.normalizedText.length > 0 && this.normalizedText.endsWith("\n")) {
|
|
315
|
+
rawLineCount += 1;
|
|
316
|
+
if (rawLineCount <= visibleLineLimit) {
|
|
317
|
+
const end = {
|
|
318
|
+
segmentIndex: prepared.segments.length,
|
|
319
|
+
graphemeIndex: 0
|
|
320
|
+
};
|
|
321
|
+
lines.push({
|
|
322
|
+
text: "",
|
|
323
|
+
width: 0,
|
|
324
|
+
start: end,
|
|
325
|
+
end,
|
|
326
|
+
ellipsized: false
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const truncated = rawLineCount > visibleLineLimit;
|
|
308
331
|
if (options.ellipsis && !truncated && lines.length === 1 && lines[0].width > options.width) {
|
|
309
332
|
const line = lines[0];
|
|
310
333
|
const fitted = ellipsizeText(line.text, options.width, this.font, this.letterSpacing, true);
|
|
@@ -328,7 +351,7 @@ var PreparedTextLayout = class {
|
|
|
328
351
|
}
|
|
329
352
|
let maxLineWidth = 0;
|
|
330
353
|
for (const line of lines) maxLineWidth = Math.max(maxLineWidth, line.width);
|
|
331
|
-
return new TextLayoutSnapshot(this.normalizedText, this.font, this.letterSpacing, options.lineHeight, this.naturalWidth, prepared.segments,
|
|
354
|
+
return new TextLayoutSnapshot(this.normalizedText, this.font, this.letterSpacing, options.lineHeight, this.naturalWidth, prepared.segments, rawLineCount, truncated, lines, maxLineWidth);
|
|
332
355
|
}
|
|
333
356
|
getRichPrepared() {
|
|
334
357
|
if (this.prepared) return this.prepared;
|
|
@@ -400,8 +423,11 @@ var TextLayoutSnapshot = class TextLayoutSnapshot {
|
|
|
400
423
|
}
|
|
401
424
|
getLineX(index, width, textAlign) {
|
|
402
425
|
const lineWidth = this.layoutLines[index]?.width ?? 0;
|
|
403
|
-
|
|
404
|
-
|
|
426
|
+
return this.getBlockHorizontalOffset(width, textAlign, lineWidth);
|
|
427
|
+
}
|
|
428
|
+
getBlockHorizontalOffset(width, textAlign, contentWidth = this.maxLineWidth) {
|
|
429
|
+
if (textAlign === "center") return (width - contentWidth) / 2;
|
|
430
|
+
if (textAlign === "right") return width - contentWidth;
|
|
405
431
|
return 0;
|
|
406
432
|
}
|
|
407
433
|
getBlockVerticalOffset(height, verticalAlign, contentHeight = this.textHeight) {
|
|
@@ -412,8 +438,8 @@ var TextLayoutSnapshot = class TextLayoutSnapshot {
|
|
|
412
438
|
getCaretLocalXY(caretIndex, width, height, textAlign, verticalAlign, fontSize) {
|
|
413
439
|
const intraLine = (this.lineHeight - fontSize) / 2;
|
|
414
440
|
if (this.layoutLines.length === 0) return {
|
|
415
|
-
x:
|
|
416
|
-
y: (
|
|
441
|
+
x: this.getBlockHorizontalOffset(width, textAlign, 0),
|
|
442
|
+
y: this.getBlockVerticalOffset(height, verticalAlign, this.lineHeight) + intraLine,
|
|
417
443
|
h: fontSize
|
|
418
444
|
};
|
|
419
445
|
const lineIndex = this.getLineIndex(caretIndex);
|
|
@@ -566,7 +592,6 @@ function syncFromTextarea(self) {
|
|
|
566
592
|
if (!self.textarea) return;
|
|
567
593
|
if (self.editingConsumer) self.editingConsumer.submit(self.textarea.value);
|
|
568
594
|
else self.setOptions({ text: self.textarea.value });
|
|
569
|
-
self.transform.markNeedsLayout();
|
|
570
595
|
ensureCaretVisible(self);
|
|
571
596
|
updateTextareaPosition(self);
|
|
572
597
|
self.dispatchEvent(new CustomEvent("input", {
|
|
@@ -575,7 +600,10 @@ function syncFromTextarea(self) {
|
|
|
575
600
|
}));
|
|
576
601
|
}
|
|
577
602
|
function syncEditingText(self, value) {
|
|
578
|
-
if (self.text !== value)
|
|
603
|
+
if (self.text !== value) {
|
|
604
|
+
self.setOptions({ text: value });
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
579
607
|
const textarea = self.textarea;
|
|
580
608
|
if (textarea && textarea.value !== value) {
|
|
581
609
|
const start = Math.min(textarea.selectionStart ?? value.length, value.length);
|
|
@@ -586,7 +614,6 @@ function syncEditingText(self, value) {
|
|
|
586
614
|
ensureCaretVisible(self);
|
|
587
615
|
updateTextareaPosition(self);
|
|
588
616
|
}
|
|
589
|
-
self.transform.markNeedsLayout();
|
|
590
617
|
}
|
|
591
618
|
function restartBlink(self) {
|
|
592
619
|
stopBlink(self);
|
|
@@ -714,9 +741,11 @@ function enterEditing(self, initialClickLocal, consumer = null) {
|
|
|
714
741
|
ensureCaretVisible(self);
|
|
715
742
|
self.transform.markNeedsLayout();
|
|
716
743
|
}, { signal });
|
|
717
|
-
|
|
744
|
+
const finishSelectionDrag = () => {
|
|
718
745
|
self.selAnchor = -1;
|
|
719
|
-
}
|
|
746
|
+
};
|
|
747
|
+
document.addEventListener("pointerup", finishSelectionDrag, { signal });
|
|
748
|
+
document.addEventListener("pointercancel", finishSelectionDrag, { signal });
|
|
720
749
|
document.addEventListener("pointerdown", (e) => {
|
|
721
750
|
if (!root.container.contains(e.target)) textarea.blur();
|
|
722
751
|
}, { signal });
|
|
@@ -728,20 +757,21 @@ function requestEditingFinish(self) {
|
|
|
728
757
|
else closeEditing(self);
|
|
729
758
|
}
|
|
730
759
|
function closeEditing(self) {
|
|
731
|
-
|
|
760
|
+
const textarea = self.textarea;
|
|
761
|
+
if (!textarea) return;
|
|
762
|
+
const value = textarea.value;
|
|
763
|
+
const consumer = self.editingConsumer;
|
|
764
|
+
self.textarea = null;
|
|
765
|
+
self.editingConsumer = null;
|
|
732
766
|
stopBlink(self);
|
|
733
767
|
self.selAnchor = -1;
|
|
734
768
|
self.scrollX = 0;
|
|
735
|
-
if (self.textarea) {
|
|
736
|
-
if (!self.editingConsumer) self.setOptions({ text: self.textarea.value });
|
|
737
|
-
self.textarea.remove();
|
|
738
|
-
self.textarea = null;
|
|
739
|
-
}
|
|
740
769
|
self.editSubscriptionRemove?.();
|
|
741
770
|
self.editAbort?.abort();
|
|
742
771
|
self.editAbort = null;
|
|
743
|
-
self.editingConsumer = null;
|
|
744
772
|
self.composing = false;
|
|
773
|
+
textarea.remove();
|
|
774
|
+
if (!consumer) self.setOptions({ text: value });
|
|
745
775
|
self.transform.markNeedsLayout();
|
|
746
776
|
self.dispatchEvent(new CustomEvent("change", {
|
|
747
777
|
detail: self.text,
|
|
@@ -963,7 +993,7 @@ function paintTextContent(self, ctx, offsetY = 0) {
|
|
|
963
993
|
const fillStyle = resolveColorFill(ctx, style.color, w, h);
|
|
964
994
|
ctx.fillStyle = self.placeholderColor || fillStyle;
|
|
965
995
|
const phWidth = measureTextWidth(self.placeholder, font, ls);
|
|
966
|
-
const phX =
|
|
996
|
+
const phX = layout.getBlockHorizontalOffset(w, style.textAlign, phWidth);
|
|
967
997
|
const phBlockOffset = layout.getBlockVerticalOffset(h, style.verticalAlign, lineHeightPx);
|
|
968
998
|
const lineMetrics = measureTextLinePlacement(font, style.textBaseline, lineHeightPx);
|
|
969
999
|
drawTextLine(ctx, self.placeholder, phX, lineMetrics.drawY + phBlockOffset, font, ls, true, false);
|
|
@@ -1059,14 +1089,8 @@ var TextBlock = class {
|
|
|
1059
1089
|
/** Return visual bounds for the same snapshot consumed by `paintTextBlock`. */
|
|
1060
1090
|
function getTextBlockVisualBounds(layout, style, width, height) {
|
|
1061
1091
|
if (layout.lines.length === 0) return null;
|
|
1062
|
-
let left =
|
|
1063
|
-
let right =
|
|
1064
|
-
for (let index = 0; index < layout.lines.length; index++) {
|
|
1065
|
-
const line = layout.lines[index];
|
|
1066
|
-
const lineX = layout.getLineX(index, width, style.textAlign);
|
|
1067
|
-
left = Math.min(left, lineX);
|
|
1068
|
-
right = Math.max(right, lineX + line.width);
|
|
1069
|
-
}
|
|
1092
|
+
let left = layout.getBlockHorizontalOffset(width, style.textAlign);
|
|
1093
|
+
let right = left + layout.maxLineWidth;
|
|
1070
1094
|
let top = layout.getBlockVerticalOffset(height, style.verticalAlign);
|
|
1071
1095
|
let bottom = top + layout.textHeight;
|
|
1072
1096
|
const strokeOutset = style.textStrokeColor && style.textStrokeWidth > 0 ? style.textStrokeWidth / 2 : 0;
|
|
@@ -1299,14 +1323,7 @@ var ConnectionPortDecoration = class {
|
|
|
1299
1323
|
const distance = DOT_RADIUS * Math.hypot(matrix.a * ux + matrix.b * uy, matrix.c * ux + matrix.d * uy) + LABEL_GAP * normalLength + halfExtent;
|
|
1300
1324
|
const centerX = worldPosition.x + ux * distance;
|
|
1301
1325
|
const centerY = worldPosition.y + uy * distance;
|
|
1302
|
-
return new
|
|
1303
|
-
scaleX,
|
|
1304
|
-
0,
|
|
1305
|
-
0,
|
|
1306
|
-
scaleY,
|
|
1307
|
-
centerX - worldWidth / 2,
|
|
1308
|
-
centerY - worldHeight / 2
|
|
1309
|
-
]);
|
|
1326
|
+
return new Matrix2D(scaleX, 0, 0, scaleY, centerX - worldWidth / 2, centerY - worldHeight / 2);
|
|
1310
1327
|
}
|
|
1311
1328
|
handleTextMeasurementChanged = () => {
|
|
1312
1329
|
this.host.transform.invalidate(ChangeImpact.VisualBounds);
|
|
@@ -1681,7 +1698,7 @@ var ContentEditingCapabilityToken = defineEditorCapability();
|
|
|
1681
1698
|
//#region packages/ui/src/editor/transform.ts
|
|
1682
1699
|
function readElementTransformBaseline(owner, writeMode, ownedState) {
|
|
1683
1700
|
const parent = owner.parent instanceof Element ? owner.parent : null;
|
|
1684
|
-
const startParentWorldInverseMatrix = parent ?
|
|
1701
|
+
const startParentWorldInverseMatrix = parent ? parent.transform.getChildWorldInverseMatrixView() : new Matrix2D();
|
|
1685
1702
|
const startParentWorldMatrix = parent ? startParentWorldInverseMatrix.inverse() : startParentWorldInverseMatrix;
|
|
1686
1703
|
return {
|
|
1687
1704
|
ownedState,
|
|
@@ -1809,7 +1826,7 @@ var EditorShape = class EditorShape extends Shape {
|
|
|
1809
1826
|
getTransformPolicy() {
|
|
1810
1827
|
return FRAME_TRANSFORM_POLICY;
|
|
1811
1828
|
}
|
|
1812
|
-
captureTransformBaseline() {
|
|
1829
|
+
captureTransformBaseline(_bakeGeometry) {
|
|
1813
1830
|
return captureElementTransformBaseline(this, "frame-authored", void 0);
|
|
1814
1831
|
}
|
|
1815
1832
|
resolveTransformChange(baseline, intent) {
|
|
@@ -2356,7 +2373,7 @@ function removeAuthoredAnchor(subpath, anchorId, minimumAnchorCount = 2) {
|
|
|
2356
2373
|
}
|
|
2357
2374
|
/** Transform coordinates while retaining every subpath, anchor, segment, and record ID. */
|
|
2358
2375
|
function transformAuthoredSubpath(subpath, matrix) {
|
|
2359
|
-
if (
|
|
2376
|
+
if (matrix.isIdentity) return subpath;
|
|
2360
2377
|
return {
|
|
2361
2378
|
...subpath,
|
|
2362
2379
|
anchors: subpath.anchors.map((anchor) => {
|
|
@@ -2525,6 +2542,12 @@ var Polygon = class extends EditorShape {
|
|
|
2525
2542
|
getPointScopeOutline(_scope) {
|
|
2526
2543
|
return null;
|
|
2527
2544
|
}
|
|
2545
|
+
resolvePointContourPatch(contour) {
|
|
2546
|
+
return {
|
|
2547
|
+
...resolveReferenceBoundsPosePatch(this, () => [this.transform.getLayoutReferenceBoundsView(), getAuthoredSubpathBounds(contour)]),
|
|
2548
|
+
contour
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2528
2551
|
resolvePointEdit(request) {
|
|
2529
2552
|
if (request.kind === "delete-scope") return null;
|
|
2530
2553
|
if (request.kind === "move-handle") return null;
|
|
@@ -2534,7 +2557,7 @@ var Polygon = class extends EditorShape {
|
|
|
2534
2557
|
kind: "owner-change",
|
|
2535
2558
|
change: {
|
|
2536
2559
|
owner: this,
|
|
2537
|
-
patch:
|
|
2560
|
+
patch: this.resolvePointContourPatch(inserted.subpath)
|
|
2538
2561
|
},
|
|
2539
2562
|
nextTarget: {
|
|
2540
2563
|
kind: "anchor",
|
|
@@ -2550,7 +2573,7 @@ var Polygon = class extends EditorShape {
|
|
|
2550
2573
|
kind: "owner-change",
|
|
2551
2574
|
change: {
|
|
2552
2575
|
owner: this,
|
|
2553
|
-
patch:
|
|
2576
|
+
patch: this.resolvePointContourPatch(contour)
|
|
2554
2577
|
}
|
|
2555
2578
|
};
|
|
2556
2579
|
}
|
|
@@ -2561,11 +2584,11 @@ var Polygon = class extends EditorShape {
|
|
|
2561
2584
|
kind: "owner-change",
|
|
2562
2585
|
change: {
|
|
2563
2586
|
owner: this,
|
|
2564
|
-
patch:
|
|
2587
|
+
patch: this.resolvePointContourPatch(contour)
|
|
2565
2588
|
}
|
|
2566
2589
|
};
|
|
2567
2590
|
}
|
|
2568
|
-
captureTransformBaseline() {
|
|
2591
|
+
captureTransformBaseline(_bakeGeometry) {
|
|
2569
2592
|
return captureElementTransformBaseline(this, "authored-geometry", this.contour);
|
|
2570
2593
|
}
|
|
2571
2594
|
resolveTransformChange(baseline, intent) {
|
|
@@ -2753,31 +2776,6 @@ function createVectorPathGeometry(commands) {
|
|
|
2753
2776
|
finish();
|
|
2754
2777
|
return { subpaths };
|
|
2755
2778
|
}
|
|
2756
|
-
function resolveVectorPath(path) {
|
|
2757
|
-
return Array.isArray(path) ? createVectorPathGeometry(path) : path;
|
|
2758
|
-
}
|
|
2759
|
-
function createVectorPathSnapshot(elementKey, revision, path) {
|
|
2760
|
-
return createGeometrySnapshot({
|
|
2761
|
-
elementKey,
|
|
2762
|
-
revision,
|
|
2763
|
-
subpaths: path.subpaths.map(resolveAuthoredSubpath)
|
|
2764
|
-
});
|
|
2765
|
-
}
|
|
2766
|
-
function withPathBounds(options) {
|
|
2767
|
-
if (options.path === void 0) return options;
|
|
2768
|
-
const path = resolveVectorPath(options.path);
|
|
2769
|
-
if (path.subpaths.reduce((count, subpath) => count + subpath.anchors.length, 0) < 2) return {
|
|
2770
|
-
...options,
|
|
2771
|
-
path
|
|
2772
|
-
};
|
|
2773
|
-
const { width, height } = createVectorPathSnapshot("", 0, path).layoutReferenceBounds;
|
|
2774
|
-
return {
|
|
2775
|
-
...options,
|
|
2776
|
-
path,
|
|
2777
|
-
width: options.width ?? (width || 1),
|
|
2778
|
-
height: options.height ?? (height || 1)
|
|
2779
|
-
};
|
|
2780
|
-
}
|
|
2781
2779
|
function createEmptyVectorPath() {
|
|
2782
2780
|
return { subpaths: [] };
|
|
2783
2781
|
}
|
|
@@ -2795,7 +2793,11 @@ var VectorPathProperties = class extends ShapeProperties {
|
|
|
2795
2793
|
};
|
|
2796
2794
|
var VectorPathTransform = class extends EditorShapeTransform {
|
|
2797
2795
|
buildGeometrySnapshot(revision) {
|
|
2798
|
-
return
|
|
2796
|
+
return createGeometrySnapshot({
|
|
2797
|
+
elementKey: this.element.key,
|
|
2798
|
+
revision,
|
|
2799
|
+
subpaths: this.element.path.subpaths.map(resolveAuthoredSubpath)
|
|
2800
|
+
});
|
|
2799
2801
|
}
|
|
2800
2802
|
};
|
|
2801
2803
|
var VectorPath = class extends EditorShape {
|
|
@@ -2804,14 +2806,22 @@ var VectorPath = class extends EditorShape {
|
|
|
2804
2806
|
return this.propertyState.path;
|
|
2805
2807
|
}
|
|
2806
2808
|
constructor(options = {}) {
|
|
2807
|
-
const prepared =
|
|
2809
|
+
const prepared = Array.isArray(options.path) ? {
|
|
2810
|
+
...options,
|
|
2811
|
+
path: createVectorPathGeometry(options.path)
|
|
2812
|
+
} : options;
|
|
2808
2813
|
super(prepared, new VectorPathProperties(prepared), VectorPathTransform);
|
|
2814
|
+
if (this.path.subpaths.reduce((count, subpath) => count + subpath.anchors.length, 0) >= 2 && (options.width === void 0 || options.height === void 0)) {
|
|
2815
|
+
const { width, height } = this.transform.getLayoutReferenceBoundsView();
|
|
2816
|
+
this.propertyState.width ??= width || 1;
|
|
2817
|
+
this.propertyState.height ??= height || 1;
|
|
2818
|
+
}
|
|
2809
2819
|
}
|
|
2810
2820
|
resolveOptions(options) {
|
|
2811
|
-
if (!
|
|
2821
|
+
if (!Array.isArray(options.path)) return options;
|
|
2812
2822
|
return {
|
|
2813
2823
|
...options,
|
|
2814
|
-
path:
|
|
2824
|
+
path: createVectorPathGeometry(options.path)
|
|
2815
2825
|
};
|
|
2816
2826
|
}
|
|
2817
2827
|
getEditorCapability(token) {
|
|
@@ -2903,21 +2913,25 @@ var VectorPath = class extends EditorShape {
|
|
|
2903
2913
|
return null;
|
|
2904
2914
|
}
|
|
2905
2915
|
ownerPathChange(previous, next) {
|
|
2916
|
+
const path = { subpaths: this.path.subpaths.map((subpath) => subpath === previous ? next : subpath) };
|
|
2906
2917
|
return {
|
|
2907
2918
|
kind: "owner-change",
|
|
2908
2919
|
change: {
|
|
2909
2920
|
owner: this,
|
|
2910
|
-
patch: {
|
|
2921
|
+
patch: {
|
|
2922
|
+
...resolveReferenceBoundsPosePatch(this, () => [this.transform.getLayoutReferenceBoundsView(), getAuthoredPathLayoutBounds(path.subpaths)]),
|
|
2923
|
+
path
|
|
2924
|
+
}
|
|
2911
2925
|
}
|
|
2912
2926
|
};
|
|
2913
2927
|
}
|
|
2914
|
-
captureTransformBaseline() {
|
|
2928
|
+
captureTransformBaseline(_bakeGeometry) {
|
|
2915
2929
|
return captureElementTransformBaseline(this, "authored-geometry", this.path);
|
|
2916
2930
|
}
|
|
2917
2931
|
resolveTransformChange(baseline, intent) {
|
|
2918
2932
|
const transform = resolveReferenceTransform(baseline.reference, intent);
|
|
2919
|
-
const path =
|
|
2920
|
-
const bounds = path === baseline.ownedState ? null :
|
|
2933
|
+
const path = transform.authoredLocalDelta.isIdentity ? baseline.ownedState : { subpaths: baseline.ownedState.subpaths.map((subpath) => transformAuthoredSubpath(subpath, transform.authoredLocalDelta)) };
|
|
2934
|
+
const bounds = path === baseline.ownedState ? null : getAuthoredPathLayoutBounds(path.subpaths);
|
|
2921
2935
|
const framePatch = bounds && intent.bakeGeometry && !isReparentTransformIntent(intent) ? resolveAuthoredGeometryFramePatch(baseline.reference, transform, bounds) : transform.framePatch;
|
|
2922
2936
|
const restoredFrameSize = intent.bakeGeometry && !isReparentTransformIntent(intent) && path === baseline.ownedState ? {
|
|
2923
2937
|
width: baseline.reference.frame.width,
|
|
@@ -3254,8 +3268,8 @@ var Text = class extends Rectangle {
|
|
|
3254
3268
|
if (this.placeholder) {
|
|
3255
3269
|
const placeholderWidth = measureTextWidth(this.placeholder, this.getFontString(style), style.letterSpacing);
|
|
3256
3270
|
return {
|
|
3257
|
-
left:
|
|
3258
|
-
top:
|
|
3271
|
+
left: layout.getBlockHorizontalOffset(width, style.textAlign, placeholderWidth),
|
|
3272
|
+
top: layout.getBlockVerticalOffset(height, style.verticalAlign, lineHeight),
|
|
3259
3273
|
width: placeholderWidth,
|
|
3260
3274
|
height: lineHeight
|
|
3261
3275
|
};
|
|
@@ -3268,6 +3282,7 @@ var Text = class extends Rectangle {
|
|
|
3268
3282
|
exitEditing() {
|
|
3269
3283
|
exitEditing(this);
|
|
3270
3284
|
}
|
|
3285
|
+
/** 更新文本属性,并同步当前正在使用的 textarea。 */
|
|
3271
3286
|
setEditingText(value) {
|
|
3272
3287
|
syncEditingText(this, value);
|
|
3273
3288
|
}
|
|
@@ -3320,6 +3335,10 @@ var Text = class extends Rectangle {
|
|
|
3320
3335
|
/** Owns one derived bitmap and connects replacements to normal Layer paint. */
|
|
3321
3336
|
var Bitmap = class extends Rectangle {
|
|
3322
3337
|
currentBitmap = null;
|
|
3338
|
+
sentFrameWidth = 0;
|
|
3339
|
+
sentFrameHeight = 0;
|
|
3340
|
+
sentFramePixelRatio = 0;
|
|
3341
|
+
framePending = false;
|
|
3323
3342
|
constructor(options = {}, properties = new RectangleProperties(options), Transform = RectangleTransform) {
|
|
3324
3343
|
super(options, properties, Transform);
|
|
3325
3344
|
}
|
|
@@ -3332,8 +3351,35 @@ var Bitmap = class extends Rectangle {
|
|
|
3332
3351
|
const viewport = this.activeRoot?.viewport;
|
|
3333
3352
|
return viewport ? viewport.scale * viewport.dpr : 1;
|
|
3334
3353
|
}
|
|
3354
|
+
/**
|
|
3355
|
+
* Records the size a new frame renderer is created with; size changes wait
|
|
3356
|
+
* for its first presented frame.
|
|
3357
|
+
*/
|
|
3358
|
+
startFrameSurface(pixelRatio) {
|
|
3359
|
+
this.sentFrameWidth = this.width;
|
|
3360
|
+
this.sentFrameHeight = this.height;
|
|
3361
|
+
this.sentFramePixelRatio = pixelRatio;
|
|
3362
|
+
this.framePending = true;
|
|
3363
|
+
}
|
|
3364
|
+
/**
|
|
3365
|
+
* Returns `true` when the renderer should receive the current size: it
|
|
3366
|
+
* differs from the last sent size and no requested frame is still pending.
|
|
3367
|
+
* The accepted size is recorded and the next presented frame ends the wait.
|
|
3368
|
+
*/
|
|
3369
|
+
claimFrameResize(pixelRatio) {
|
|
3370
|
+
if (this.framePending) return false;
|
|
3371
|
+
const width = this.width;
|
|
3372
|
+
const height = this.height;
|
|
3373
|
+
if (width === this.sentFrameWidth && height === this.sentFrameHeight && pixelRatio === this.sentFramePixelRatio) return false;
|
|
3374
|
+
this.sentFrameWidth = width;
|
|
3375
|
+
this.sentFrameHeight = height;
|
|
3376
|
+
this.sentFramePixelRatio = pixelRatio;
|
|
3377
|
+
this.framePending = true;
|
|
3378
|
+
return true;
|
|
3379
|
+
}
|
|
3335
3380
|
/** Takes ownership of a derived frame and schedules one normal paint commit. */
|
|
3336
3381
|
presentBitmap(bitmap) {
|
|
3382
|
+
this.framePending = false;
|
|
3337
3383
|
this.clearBitmap();
|
|
3338
3384
|
this.currentBitmap = bitmap;
|
|
3339
3385
|
this.transform.markPaintDirty();
|
|
@@ -3380,7 +3426,13 @@ var ImageProperties = class extends RectangleProperties {
|
|
|
3380
3426
|
return impact;
|
|
3381
3427
|
}
|
|
3382
3428
|
};
|
|
3383
|
-
var ImageTransform = class extends RectangleTransform {
|
|
3429
|
+
var ImageTransform = class extends RectangleTransform {
|
|
3430
|
+
resolveFitSize() {
|
|
3431
|
+
const image = this.element;
|
|
3432
|
+
const parent = image.parent;
|
|
3433
|
+
this.commitResolvedSize(isUndefined(image.properties.width) ? image.fitWidth ? parent?.width : image.naturalWidth : void 0, isUndefined(image.properties.height) ? image.fitHeight ? parent?.height : image.naturalHeight : void 0);
|
|
3434
|
+
}
|
|
3435
|
+
};
|
|
3384
3436
|
var AUTO_DOWNSAMPLE_RATIO = 2;
|
|
3385
3437
|
var UPGRADE_RATIO = 1.5;
|
|
3386
3438
|
var Image = class extends Bitmap {
|
|
@@ -3396,13 +3448,25 @@ var Image = class extends Bitmap {
|
|
|
3396
3448
|
w: 0,
|
|
3397
3449
|
h: 0
|
|
3398
3450
|
};
|
|
3399
|
-
|
|
3400
|
-
|
|
3451
|
+
sourceWidth = 0;
|
|
3452
|
+
sourceHeight = 0;
|
|
3453
|
+
externalImage;
|
|
3401
3454
|
isProcessing = false;
|
|
3402
3455
|
processGeneration = 0;
|
|
3403
3456
|
constructor(options = {}, Transform = ImageTransform, properties = new ImageProperties(options)) {
|
|
3404
3457
|
super(options, properties, Transform);
|
|
3405
|
-
if (options.image)
|
|
3458
|
+
if (options.image) {
|
|
3459
|
+
this.externalImage = options.image;
|
|
3460
|
+
this.loadAndProcess();
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
/** Intrinsic width of the current image source, before authored or fit sizing. */
|
|
3464
|
+
get naturalWidth() {
|
|
3465
|
+
return this.sourceWidth;
|
|
3466
|
+
}
|
|
3467
|
+
/** Intrinsic height of the current image source, before authored or fit sizing. */
|
|
3468
|
+
get naturalHeight() {
|
|
3469
|
+
return this.sourceHeight;
|
|
3406
3470
|
}
|
|
3407
3471
|
get resizeMode() {
|
|
3408
3472
|
return this.resize.mode ?? "auto";
|
|
@@ -3417,16 +3481,19 @@ var Image = class extends Bitmap {
|
|
|
3417
3481
|
super.onPropertiesChanged(current, changes);
|
|
3418
3482
|
if (changes.has("src")) {
|
|
3419
3483
|
this.cancelProcessing();
|
|
3484
|
+
this.externalImage = void 0;
|
|
3485
|
+
this.sourceWidth = 0;
|
|
3486
|
+
this.sourceHeight = 0;
|
|
3420
3487
|
this.clearBitmap();
|
|
3421
3488
|
if (this.isActive && current.src) this.loadAndProcess();
|
|
3422
|
-
} else if (changes.has("resize") && this.isActive && current.src) {
|
|
3489
|
+
} else if (changes.has("resize") && this.isActive && (current.src || this.externalImage)) {
|
|
3423
3490
|
this.cancelProcessing();
|
|
3424
3491
|
this.loadAndProcess();
|
|
3425
3492
|
}
|
|
3426
3493
|
}
|
|
3427
3494
|
onActivate(root, layer) {
|
|
3428
3495
|
super.onActivate(root, layer);
|
|
3429
|
-
if (this.src && !this.renderBitmap) this.loadAndProcess();
|
|
3496
|
+
if ((this.src || this.externalImage) && !this.renderBitmap) this.loadAndProcess();
|
|
3430
3497
|
}
|
|
3431
3498
|
onDeactivate(root, layer) {
|
|
3432
3499
|
this.cancelProcessing();
|
|
@@ -3435,15 +3502,16 @@ var Image = class extends Bitmap {
|
|
|
3435
3502
|
paintContent(ctx) {
|
|
3436
3503
|
if (!this.renderBitmap) return;
|
|
3437
3504
|
if (this.resizeMode === "auto") this.checkResolution();
|
|
3438
|
-
this.paintBitmap(ctx, this.width
|
|
3505
|
+
this.paintBitmap(ctx, this.width ?? this.naturalWidth, this.height ?? this.naturalHeight);
|
|
3439
3506
|
}
|
|
3440
3507
|
async paintForExport(ctx) {
|
|
3441
3508
|
if (!this.src) return;
|
|
3442
3509
|
const img = await this.loadHTMLImage(this.src);
|
|
3443
|
-
ctx.drawImage(img, 0, 0, this.width
|
|
3510
|
+
ctx.drawImage(img, 0, 0, this.width ?? img.naturalWidth, this.height ?? img.naturalHeight);
|
|
3444
3511
|
}
|
|
3445
3512
|
onUnmount() {
|
|
3446
3513
|
this.cancelProcessing();
|
|
3514
|
+
this.externalImage = void 0;
|
|
3447
3515
|
super.onUnmount();
|
|
3448
3516
|
}
|
|
3449
3517
|
cancelProcessing() {
|
|
@@ -3458,33 +3526,20 @@ var Image = class extends Bitmap {
|
|
|
3458
3526
|
h: 0
|
|
3459
3527
|
};
|
|
3460
3528
|
}
|
|
3461
|
-
setExternalImage(image) {
|
|
3462
|
-
this.naturalWidth = image instanceof HTMLImageElement ? image.naturalWidth : image.width;
|
|
3463
|
-
this.naturalHeight = image instanceof HTMLImageElement ? image.naturalHeight : image.height;
|
|
3464
|
-
createImageBitmap(image).then((bitmap) => {
|
|
3465
|
-
if (this.isUnmounted) {
|
|
3466
|
-
bitmap.close();
|
|
3467
|
-
return;
|
|
3468
|
-
}
|
|
3469
|
-
this.presentBitmap(bitmap);
|
|
3470
|
-
this.renderSize = {
|
|
3471
|
-
w: this.naturalWidth,
|
|
3472
|
-
h: this.naturalHeight
|
|
3473
|
-
};
|
|
3474
|
-
this.isLoaded = true;
|
|
3475
|
-
this.transform.commitResolvedSize(isUndefined(this.propertyState.width) ? this.naturalWidth : void 0, isUndefined(this.propertyState.height) ? this.naturalHeight : void 0);
|
|
3476
|
-
});
|
|
3477
|
-
}
|
|
3478
3529
|
async loadAndProcess() {
|
|
3479
|
-
if (!this.src || this.isProcessing) return;
|
|
3530
|
+
if (!this.src && !this.externalImage || this.isProcessing) return;
|
|
3480
3531
|
this.isProcessing = true;
|
|
3481
3532
|
const generation = ++this.processGeneration;
|
|
3482
3533
|
try {
|
|
3483
|
-
const img = await this.loadHTMLImage(this.src);
|
|
3534
|
+
const img = this.externalImage ?? await this.loadHTMLImage(this.src);
|
|
3484
3535
|
if (generation !== this.processGeneration || this.isUnmounted) return;
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3536
|
+
const width = img instanceof HTMLCanvasElement ? img.width : img.naturalWidth;
|
|
3537
|
+
const height = img instanceof HTMLCanvasElement ? img.height : img.naturalHeight;
|
|
3538
|
+
if (width !== this.sourceWidth || height !== this.sourceHeight) {
|
|
3539
|
+
this.sourceWidth = width;
|
|
3540
|
+
this.sourceHeight = height;
|
|
3541
|
+
this.transform.markGeometryNeedsLayout();
|
|
3542
|
+
}
|
|
3488
3543
|
await this.processImage(img, generation);
|
|
3489
3544
|
} finally {
|
|
3490
3545
|
if (generation === this.processGeneration) this.isProcessing = false;
|
|
@@ -3499,10 +3554,10 @@ var Image = class extends Bitmap {
|
|
|
3499
3554
|
bitmap.close();
|
|
3500
3555
|
return;
|
|
3501
3556
|
}
|
|
3502
|
-
this.applyBitmap(bitmap,
|
|
3557
|
+
this.applyBitmap(bitmap, this.naturalWidth, this.naturalHeight);
|
|
3503
3558
|
} else {
|
|
3504
|
-
const { w, h } = this.calcAutoSize(
|
|
3505
|
-
if (w >=
|
|
3559
|
+
const { w, h } = this.calcAutoSize(this.naturalWidth, this.naturalHeight);
|
|
3560
|
+
if (w >= this.naturalWidth && h >= this.naturalHeight) bitmap = await createImageBitmap(img);
|
|
3506
3561
|
else bitmap = await createImageBitmap(img, {
|
|
3507
3562
|
resizeWidth: w,
|
|
3508
3563
|
resizeHeight: h,
|
|
@@ -3522,12 +3577,11 @@ var Image = class extends Bitmap {
|
|
|
3522
3577
|
h
|
|
3523
3578
|
};
|
|
3524
3579
|
this.isLoaded = true;
|
|
3525
|
-
this.transform.markNeedsLayout();
|
|
3526
3580
|
}
|
|
3527
3581
|
calcAutoSize(naturalW, naturalH) {
|
|
3528
3582
|
const pixelRatio = this.renderPixelRatio;
|
|
3529
|
-
const targetW = Math.ceil((this.width
|
|
3530
|
-
const targetH = Math.ceil((this.height
|
|
3583
|
+
const targetW = Math.ceil((this.properties.width ?? (this.fitWidth ? this.width : naturalW) ?? naturalW) * pixelRatio);
|
|
3584
|
+
const targetH = Math.ceil((this.properties.height ?? (this.fitHeight ? this.height : naturalH) ?? naturalH) * pixelRatio);
|
|
3531
3585
|
if (!(naturalW > targetW * AUTO_DOWNSAMPLE_RATIO || naturalH > targetH * AUTO_DOWNSAMPLE_RATIO)) return {
|
|
3532
3586
|
w: naturalW,
|
|
3533
3587
|
h: naturalH
|
|
@@ -3543,10 +3597,10 @@ var Image = class extends Bitmap {
|
|
|
3543
3597
|
}
|
|
3544
3598
|
/** @internal 实际绘制前按当前 Viewport 检查分辨率升级。 */
|
|
3545
3599
|
checkResolution() {
|
|
3546
|
-
if (!this.isLoaded || !this.src || this.isProcessing) return;
|
|
3600
|
+
if (!this.isLoaded || !this.src && !this.externalImage || this.isProcessing) return;
|
|
3547
3601
|
const pixelRatio = this.renderPixelRatio;
|
|
3548
|
-
const needW = Math.ceil((this.width
|
|
3549
|
-
const needH = Math.ceil((this.height
|
|
3602
|
+
const needW = Math.ceil((this.width ?? this.naturalWidth) * pixelRatio);
|
|
3603
|
+
const needH = Math.ceil((this.height ?? this.naturalHeight) * pixelRatio);
|
|
3550
3604
|
if (needW > this.renderSize.w * UPGRADE_RATIO || needH > this.renderSize.h * UPGRADE_RATIO) {
|
|
3551
3605
|
const nextSize = this.calcAutoSize(this.naturalWidth, this.naturalHeight);
|
|
3552
3606
|
if (nextSize.w > this.renderSize.w || nextSize.h > this.renderSize.h) this.loadAndProcess();
|
|
@@ -3832,27 +3886,35 @@ function computePosition(reference, floating, options = {}) {
|
|
|
3832
3886
|
}
|
|
3833
3887
|
//#endregion
|
|
3834
3888
|
//#region packages/ui/src/group.ts
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3889
|
+
/**
|
|
3890
|
+
* Group 成员的逻辑范围:frame capability 优先(Text 等排除绘制溢出),否则为成员 content
|
|
3891
|
+
* bounds(Line 取几何,不含描边外扩)。`space` 为 `parent` 时返回成员 parent 的 child 坐标。
|
|
3892
|
+
* 编组命令与 Group 选区框共用这一口径。
|
|
3893
|
+
*/
|
|
3894
|
+
function resolveGroupMemberBounds(element, capability, space) {
|
|
3895
|
+
const frame = capability?.getSelectionFrameBounds?.();
|
|
3896
|
+
if (!frame) {
|
|
3897
|
+
const content = space === "world" ? element.transform.getWorldContentBoundsView() : element.transform.getContentBoundsInParentView();
|
|
3898
|
+
return content ? new Bound(content.minX, content.minY, content.maxX, content.maxY) : null;
|
|
3899
|
+
}
|
|
3900
|
+
const world = element.transform.getWorldMatrixView();
|
|
3901
|
+
const parent = element.parent;
|
|
3902
|
+
const parentInverse = space === "parent" && parent instanceof Element ? parent.transform.getChildWorldInverseMatrixView() : null;
|
|
3903
|
+
const corner = (x, y) => {
|
|
3904
|
+
const point = transformPoint(world, {
|
|
3905
|
+
x,
|
|
3906
|
+
y
|
|
3907
|
+
});
|
|
3908
|
+
return parentInverse ? transformPoint(parentInverse, point) : point;
|
|
3909
|
+
};
|
|
3910
|
+
const right = frame.left + frame.width;
|
|
3911
|
+
const bottom = frame.top + frame.height;
|
|
3912
|
+
return Bound.fromPoints([
|
|
3913
|
+
corner(frame.left, frame.top),
|
|
3914
|
+
corner(right, frame.top),
|
|
3915
|
+
corner(right, bottom),
|
|
3916
|
+
corner(frame.left, bottom)
|
|
3917
|
+
]);
|
|
3856
3918
|
}
|
|
3857
3919
|
var GroupTransform = class extends ElementTransform {
|
|
3858
3920
|
localContentBounds;
|
|
@@ -3887,7 +3949,7 @@ var GroupTransform = class extends ElementTransform {
|
|
|
3887
3949
|
collectContentBoundsInReference(parentMatrix, _referenceWorldInverse) {
|
|
3888
3950
|
if (!this.element.visible) return null;
|
|
3889
3951
|
const bounds = this.getLocalContentBoundsView();
|
|
3890
|
-
return bounds ? this.toBounds(this.writeScalarMatrix(new
|
|
3952
|
+
return bounds ? this.toBounds(this.writeScalarMatrix(new Matrix2D(), parentMatrix), bounds) : null;
|
|
3891
3953
|
}
|
|
3892
3954
|
/** 只合并真实 content members;不贡献 content bounds 的 branch 返回 null。 */
|
|
3893
3955
|
buildLocalContentBounds() {
|
|
@@ -3910,23 +3972,13 @@ var GroupTransform = class extends ElementTransform {
|
|
|
3910
3972
|
bounds.maxY = Math.min(bounds.maxY, clip.top + clip.height);
|
|
3911
3973
|
return bounds.minX < bounds.maxX && bounds.minY < bounds.maxY ? bounds : null;
|
|
3912
3974
|
}
|
|
3913
|
-
/**
|
|
3914
|
-
* Build the frame used by selection/transform/snap. Text-like owners expose
|
|
3915
|
-
* authored frame bounds that intentionally exclude paint overflow; owners
|
|
3916
|
-
* without that capability retain an explicit content/visual fallback.
|
|
3917
|
-
*/
|
|
3975
|
+
/** Build the frame used by selection/transform/snap from each visible member's logical bounds. */
|
|
3918
3976
|
buildLocalSelectionFrameBounds() {
|
|
3919
|
-
const childWorldInverse = this.getChildWorldInverseMatrixView();
|
|
3920
3977
|
let bounds = null;
|
|
3921
3978
|
for (const child of this.element.children) {
|
|
3922
3979
|
if (!child.visible) continue;
|
|
3923
|
-
const
|
|
3924
|
-
|
|
3925
|
-
const content = child.transform.getContentBoundsInParentView();
|
|
3926
|
-
return content ? rectCorners(content) : [];
|
|
3927
|
-
})();
|
|
3928
|
-
if (points.length === 0) continue;
|
|
3929
|
-
const childBounds = Bound.fromPoints(points);
|
|
3980
|
+
const childBounds = resolveGroupMemberBounds(child, getEditorCapability(child, TransformInteractionCapabilityToken), "parent");
|
|
3981
|
+
if (!childBounds) continue;
|
|
3930
3982
|
bounds = bounds ? bounds.merge(childBounds) : childBounds;
|
|
3931
3983
|
}
|
|
3932
3984
|
const clip = bounds && this.element.getChildClipRect();
|
|
@@ -3998,14 +4050,14 @@ var Group = class extends Element {
|
|
|
3998
4050
|
rotationPivot: "adjustable"
|
|
3999
4051
|
};
|
|
4000
4052
|
}
|
|
4001
|
-
captureTransformBaseline() {
|
|
4053
|
+
captureTransformBaseline(bakeGeometry) {
|
|
4002
4054
|
const children = [];
|
|
4003
|
-
for (const child of this.children) {
|
|
4055
|
+
if (bakeGeometry) for (const child of this.children) {
|
|
4004
4056
|
const capability = getEditorCapability(child, TransformInteractionCapabilityToken);
|
|
4005
4057
|
if (!capability) continue;
|
|
4006
4058
|
children.push({
|
|
4007
4059
|
capability,
|
|
4008
|
-
baseline: capability.captureTransformBaseline()
|
|
4060
|
+
baseline: capability.captureTransformBaseline(true)
|
|
4009
4061
|
});
|
|
4010
4062
|
}
|
|
4011
4063
|
return captureElementTransformBaseline(this, "pose-authored", { children });
|
|
@@ -4120,7 +4172,7 @@ var ScrollViewProperties = class extends RectangleProperties {
|
|
|
4120
4172
|
}
|
|
4121
4173
|
};
|
|
4122
4174
|
var ScrollViewTransform = class extends RectangleTransform {
|
|
4123
|
-
childWorldMatrix = new
|
|
4175
|
+
childWorldMatrix = new Matrix2D();
|
|
4124
4176
|
onChildrenChanged() {
|
|
4125
4177
|
this.markGeometryNeedsLayout(false);
|
|
4126
4178
|
}
|
|
@@ -4339,6 +4391,7 @@ var ScrollView = class extends Rectangle {
|
|
|
4339
4391
|
root.container.addEventListener("pointerdown", (event) => {
|
|
4340
4392
|
if (event.button !== 0 || !root.input.isInteractionTarget(this)) return;
|
|
4341
4393
|
const logical = root.viewport.getLogicalPosition(event.clientX, event.clientY);
|
|
4394
|
+
this.transform.updateWorldTransformChain();
|
|
4342
4395
|
const local = this.transform.toLocal(logical);
|
|
4343
4396
|
const axis = local ? this.hitThumb(local) : null;
|
|
4344
4397
|
if (!axis) return;
|
|
@@ -4346,7 +4399,7 @@ var ScrollView = class extends Rectangle {
|
|
|
4346
4399
|
this.dragging = true;
|
|
4347
4400
|
this.dragAxis = axis;
|
|
4348
4401
|
this.dragStartScroll = axis === "y" ? this.scrollY : this.scrollX;
|
|
4349
|
-
this.dragStartPointer = axis === "y" ?
|
|
4402
|
+
this.dragStartPointer = axis === "y" ? local.y : local.x;
|
|
4350
4403
|
root.input.hasLockPoint = true;
|
|
4351
4404
|
}, {
|
|
4352
4405
|
capture: true,
|
|
@@ -4354,7 +4407,11 @@ var ScrollView = class extends Rectangle {
|
|
|
4354
4407
|
});
|
|
4355
4408
|
document.addEventListener("pointermove", (event) => {
|
|
4356
4409
|
if (!this.dragging) return;
|
|
4357
|
-
const
|
|
4410
|
+
const logical = root.viewport.getLogicalPosition(event.clientX, event.clientY);
|
|
4411
|
+
this.transform.updateWorldTransformChain();
|
|
4412
|
+
const local = this.transform.toLocal(logical);
|
|
4413
|
+
if (!local) return;
|
|
4414
|
+
const delta = (this.dragAxis === "y" ? local.y : local.x) - this.dragStartPointer;
|
|
4358
4415
|
const viewSize = this.dragAxis === "y" ? this.height ?? 0 : this.width ?? 0;
|
|
4359
4416
|
const contentSize = this.dragAxis === "y" ? this.contentHeight : this.contentWidth;
|
|
4360
4417
|
const thumb = this.dragAxis === "y" ? this.verticalThumb : this.horizontalThumb;
|
|
@@ -4366,11 +4423,13 @@ var ScrollView = class extends Rectangle {
|
|
|
4366
4423
|
if (this.dragAxis === "y") this.scrollTo(this.scrollX, this.dragStartScroll + scrollDelta);
|
|
4367
4424
|
else this.scrollTo(this.dragStartScroll + scrollDelta, this.scrollY);
|
|
4368
4425
|
}, { signal });
|
|
4369
|
-
|
|
4426
|
+
const finishDrag = () => {
|
|
4370
4427
|
if (!this.dragging) return;
|
|
4371
4428
|
this.dragging = false;
|
|
4372
4429
|
root.input.hasLockPoint = false;
|
|
4373
|
-
}
|
|
4430
|
+
};
|
|
4431
|
+
document.addEventListener("pointerup", finishDrag, { signal });
|
|
4432
|
+
document.addEventListener("pointercancel", finishDrag, { signal });
|
|
4374
4433
|
}
|
|
4375
4434
|
};
|
|
4376
4435
|
//#endregion
|
|
@@ -4558,14 +4617,11 @@ function translateCreationPoints(points, left, top) {
|
|
|
4558
4617
|
translatePoint(point, left, top);
|
|
4559
4618
|
}
|
|
4560
4619
|
}
|
|
4561
|
-
function materializeEffectiveEndpointPoints(
|
|
4562
|
-
const path = line.path;
|
|
4563
|
-
const vertices = line.getEffectiveLineVerticesView();
|
|
4620
|
+
function materializeEffectiveEndpointPoints(path, headPoint, tailPoint) {
|
|
4564
4621
|
let anchors;
|
|
4565
|
-
const replace = (index,
|
|
4566
|
-
if (
|
|
4622
|
+
const replace = (index, point) => {
|
|
4623
|
+
if (point === void 0) return;
|
|
4567
4624
|
const current = path.anchors[index];
|
|
4568
|
-
const point = vertices[index].point;
|
|
4569
4625
|
if (Object.is(current.point, point)) return;
|
|
4570
4626
|
anchors ??= [...path.anchors];
|
|
4571
4627
|
anchors[index] = {
|
|
@@ -4573,8 +4629,8 @@ function materializeEffectiveEndpointPoints(line) {
|
|
|
4573
4629
|
point
|
|
4574
4630
|
};
|
|
4575
4631
|
};
|
|
4576
|
-
replace(0,
|
|
4577
|
-
replace(path.anchors.length - 1,
|
|
4632
|
+
replace(0, headPoint);
|
|
4633
|
+
if (path.anchors.length > 1) replace(path.anchors.length - 1, tailPoint);
|
|
4578
4634
|
return anchors ? {
|
|
4579
4635
|
...path,
|
|
4580
4636
|
anchors
|
|
@@ -4701,7 +4757,7 @@ var LineTransform = class extends ElementTransform {
|
|
|
4701
4757
|
return this.buildLayoutReferenceBounds();
|
|
4702
4758
|
}
|
|
4703
4759
|
worldMatrixAffectsLocalGeometry() {
|
|
4704
|
-
return
|
|
4760
|
+
return !!(this.element.headRelation || this.element.tailRelation);
|
|
4705
4761
|
}
|
|
4706
4762
|
resolveEndpointPoint(relation) {
|
|
4707
4763
|
const endpoint = relation?.target;
|
|
@@ -4907,14 +4963,15 @@ var BaseLine = class extends Element {
|
|
|
4907
4963
|
path
|
|
4908
4964
|
} : { path };
|
|
4909
4965
|
}
|
|
4910
|
-
captureTransformBaseline() {
|
|
4966
|
+
captureTransformBaseline(_bakeGeometry) {
|
|
4911
4967
|
const path = this.path;
|
|
4912
4968
|
const baseline = captureElementTransformBaseline(this, "authored-geometry", path);
|
|
4913
4969
|
if (!this.headRelation && !this.tailRelation) return {
|
|
4914
4970
|
reference: baseline.reference,
|
|
4915
4971
|
ownedState: { path }
|
|
4916
4972
|
};
|
|
4917
|
-
const
|
|
4973
|
+
const vertices = this.getEffectiveLineVerticesView();
|
|
4974
|
+
const effectivePath = materializeEffectiveEndpointPoints(path, this.headRelation ? vertices[0].point : void 0, this.tailRelation ? last(vertices).point : void 0);
|
|
4918
4975
|
const referenceBounds = effectivePath === path ? baseline.reference.referenceBounds : getAuthoredSubpathBounds(effectivePath);
|
|
4919
4976
|
return {
|
|
4920
4977
|
reference: baseline.reference,
|
|
@@ -5023,9 +5080,7 @@ var BaseLine = class extends Element {
|
|
|
5023
5080
|
patch: finalPatch
|
|
5024
5081
|
} : null;
|
|
5025
5082
|
const vertices = this.getEffectiveLineVerticesView();
|
|
5026
|
-
|
|
5027
|
-
if (detachHead) path = replaceAuthoredAnchorPoint(path, head.anchorId, localPositions?.get(head.anchorId) ?? vertices[0].point);
|
|
5028
|
-
if (detachTail && tail.anchorId !== head?.anchorId) path = replaceAuthoredAnchorPoint(path, tail.anchorId, localPositions?.get(tail.anchorId) ?? last(vertices).point);
|
|
5083
|
+
const path = materializeEffectiveEndpointPoints(beforePath, detachHead ? localPositions?.get(head.anchorId) ?? vertices[0].point : void 0, detachTail && tail.anchorId !== head?.anchorId ? localPositions?.get(tail.anchorId) ?? last(vertices).point : void 0);
|
|
5029
5084
|
const geometryPatch = finalPatch ? {
|
|
5030
5085
|
...resolveReferenceBoundsPosePatch(this, () => [getAuthoredSubpathBounds(beforePath), getAuthoredSubpathBounds(path)], finalPatch),
|
|
5031
5086
|
path
|
|
@@ -5101,13 +5156,14 @@ var BaseLine = class extends Element {
|
|
|
5101
5156
|
if (!local) return;
|
|
5102
5157
|
const appended = appendAuthoredLineAnchor(this.path, local);
|
|
5103
5158
|
this.setOptions({
|
|
5104
|
-
|
|
5159
|
+
...this.resolvePointPathPatch(appended.subpath),
|
|
5105
5160
|
relations: { tail: relation }
|
|
5106
5161
|
});
|
|
5107
5162
|
return appended.anchorId;
|
|
5108
5163
|
}
|
|
5109
5164
|
setLocalPoint(anchorId, point, endpointUpdate) {
|
|
5110
|
-
const
|
|
5165
|
+
const path = replaceAuthoredAnchorPoint(this.path, anchorId, point);
|
|
5166
|
+
const patch = this.resolvePointPathPatch(path);
|
|
5111
5167
|
if (endpointUpdate && has(endpointUpdate, "target")) {
|
|
5112
5168
|
const head = this.headAnchor?.anchorId === anchorId;
|
|
5113
5169
|
const tail = this.tailAnchor?.anchorId === anchorId;
|
|
@@ -5131,7 +5187,7 @@ var BaseLine = class extends Element {
|
|
|
5131
5187
|
const local = this.worldToLocal(worldX, worldY);
|
|
5132
5188
|
if (!local) return;
|
|
5133
5189
|
const inserted = insertAuthoredLineAnchor(this.path, segmentId, local);
|
|
5134
|
-
this.setOptions(
|
|
5190
|
+
this.setOptions(this.resolvePointPathPatch(inserted.subpath));
|
|
5135
5191
|
return inserted.anchorId;
|
|
5136
5192
|
}
|
|
5137
5193
|
removePoint(anchorId) {
|
|
@@ -5140,7 +5196,7 @@ var BaseLine = class extends Element {
|
|
|
5140
5196
|
const path = removeAuthoredAnchor(this.path, anchorId);
|
|
5141
5197
|
if (path === this.path) return;
|
|
5142
5198
|
this.setOptions({
|
|
5143
|
-
path,
|
|
5199
|
+
...this.resolvePointPathPatch(path),
|
|
5144
5200
|
...head || tail ? { relations: {
|
|
5145
5201
|
...head ? { head: void 0 } : {},
|
|
5146
5202
|
...tail ? { tail: void 0 } : {}
|
|
@@ -5351,30 +5407,6 @@ function getLineTreePointDegrees(topology) {
|
|
|
5351
5407
|
}
|
|
5352
5408
|
return degrees;
|
|
5353
5409
|
}
|
|
5354
|
-
function getLineTreeEndpointRelationBindings(topology, elementKey) {
|
|
5355
|
-
const rootAnchorId = (topology.rootSubpathId === void 0 ? void 0 : getLineTreeBranch(topology, topology.rootSubpathId))?.vertices[0]?.anchorId;
|
|
5356
|
-
const degrees = getLineTreePointDegrees(topology);
|
|
5357
|
-
const bindings = [];
|
|
5358
|
-
for (const point of topology.points) {
|
|
5359
|
-
if (!point.relation || degrees.get(point.anchorId) !== 1) continue;
|
|
5360
|
-
bindings.push({
|
|
5361
|
-
source: {
|
|
5362
|
-
elementKey,
|
|
5363
|
-
anchorId: point.anchorId
|
|
5364
|
-
},
|
|
5365
|
-
relation: point.relation,
|
|
5366
|
-
role: point.anchorId === rootAnchorId ? "output" : "input"
|
|
5367
|
-
});
|
|
5368
|
-
}
|
|
5369
|
-
return bindings;
|
|
5370
|
-
}
|
|
5371
|
-
function getLineTreeBindableEndpoints(topology, elementKey) {
|
|
5372
|
-
const degrees = getLineTreePointDegrees(topology);
|
|
5373
|
-
return topology.points.filter(({ anchorId }) => degrees.get(anchorId) === 1).map(({ anchorId }) => ({ ref: {
|
|
5374
|
-
elementKey,
|
|
5375
|
-
anchorId
|
|
5376
|
-
} }));
|
|
5377
|
-
}
|
|
5378
5410
|
function moveLineTreePoint(topology, anchorId, point, relation) {
|
|
5379
5411
|
const index = topology.points.findIndex((candidate) => candidate.anchorId === anchorId);
|
|
5380
5412
|
const current = topology.points[index];
|
|
@@ -5525,7 +5557,7 @@ function updateLineTreeBranchStyle(topology, subpathId, style) {
|
|
|
5525
5557
|
};
|
|
5526
5558
|
}
|
|
5527
5559
|
function transformLineTreeTopology(topology, matrix) {
|
|
5528
|
-
if (
|
|
5560
|
+
if (matrix.isIdentity) return topology;
|
|
5529
5561
|
return {
|
|
5530
5562
|
...topology,
|
|
5531
5563
|
points: topology.points.map((point) => ({
|
|
@@ -5567,6 +5599,7 @@ function remapLineTreeRelations(topology, keyMap) {
|
|
|
5567
5599
|
var LineTreeTransform = class extends ElementTransform {
|
|
5568
5600
|
topologySource = null;
|
|
5569
5601
|
pointById = /* @__PURE__ */ new Map();
|
|
5602
|
+
hasEndpointRelations = false;
|
|
5570
5603
|
branchById = /* @__PURE__ */ new Map();
|
|
5571
5604
|
endpointRoleById;
|
|
5572
5605
|
junctionAnchorIds = [];
|
|
@@ -5577,7 +5610,7 @@ var LineTreeTransform = class extends ElementTransform {
|
|
|
5577
5610
|
worldBranchPoints = [];
|
|
5578
5611
|
worldBranchPointsById = /* @__PURE__ */ new Map();
|
|
5579
5612
|
worldPointById = /* @__PURE__ */ new Map();
|
|
5580
|
-
worldSnapPoints
|
|
5613
|
+
worldSnapPoints;
|
|
5581
5614
|
worldMatrixA = NaN;
|
|
5582
5615
|
worldMatrixB = NaN;
|
|
5583
5616
|
worldMatrixC = NaN;
|
|
@@ -5586,14 +5619,32 @@ var LineTreeTransform = class extends ElementTransform {
|
|
|
5586
5619
|
worldMatrixF = NaN;
|
|
5587
5620
|
ensureTopologyViews() {
|
|
5588
5621
|
const topology = this.element.topology;
|
|
5589
|
-
|
|
5622
|
+
const previous = this.topologySource;
|
|
5623
|
+
if (previous === topology) return;
|
|
5624
|
+
const previousRootAnchorId = previous?.rootSubpathId === void 0 ? void 0 : this.branchById.get(previous.rootSubpathId)?.vertices[0]?.anchorId;
|
|
5590
5625
|
this.topologySource = topology;
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5626
|
+
if (!previous || previous.points !== topology.points) {
|
|
5627
|
+
this.hasEndpointRelations = false;
|
|
5628
|
+
this.pointById.clear();
|
|
5629
|
+
for (const point of topology.points) {
|
|
5630
|
+
this.hasEndpointRelations ||= point.relation !== void 0;
|
|
5631
|
+
this.pointById.set(point.anchorId, point);
|
|
5632
|
+
}
|
|
5633
|
+
this.layoutBounds = getLineTreeTopologyBounds(topology);
|
|
5634
|
+
}
|
|
5635
|
+
let verticesChanged = !previous;
|
|
5636
|
+
if (!previous || previous.branches !== topology.branches) {
|
|
5637
|
+
verticesChanged = !previous || previous.branches.length !== topology.branches.length || topology.branches.some((branch, index) => branch.vertices !== previous.branches[index].vertices);
|
|
5638
|
+
this.branchById.clear();
|
|
5639
|
+
for (const branch of topology.branches) this.branchById.set(branch.subpathId, branch);
|
|
5640
|
+
if (verticesChanged) {
|
|
5641
|
+
this.junctionAnchorIds = getLineTreeJunctionAnchorIds(topology);
|
|
5642
|
+
this.junctionAnchorIdSet.clear();
|
|
5643
|
+
for (const anchorId of this.junctionAnchorIds) this.junctionAnchorIdSet.add(anchorId);
|
|
5644
|
+
}
|
|
5645
|
+
}
|
|
5646
|
+
const rootAnchorId = topology.rootSubpathId === void 0 ? void 0 : this.branchById.get(topology.rootSubpathId)?.vertices[0]?.anchorId;
|
|
5647
|
+
if (verticesChanged || rootAnchorId !== previousRootAnchorId) this.endpointRoleById = void 0;
|
|
5597
5648
|
}
|
|
5598
5649
|
buildEndpointRoles() {
|
|
5599
5650
|
const topology = this.element.topology;
|
|
@@ -5639,7 +5690,8 @@ var LineTreeTransform = class extends ElementTransform {
|
|
|
5639
5690
|
return this.buildLayoutReferenceBounds();
|
|
5640
5691
|
}
|
|
5641
5692
|
worldMatrixAffectsLocalGeometry() {
|
|
5642
|
-
|
|
5693
|
+
this.ensureTopologyViews();
|
|
5694
|
+
return this.hasEndpointRelations;
|
|
5643
5695
|
}
|
|
5644
5696
|
resolveEndpointPoint(point) {
|
|
5645
5697
|
const endpoint = point.relation?.target;
|
|
@@ -5740,9 +5792,7 @@ var LineTreeTransform = class extends ElementTransform {
|
|
|
5740
5792
|
snapshot.subpaths.forEach((subpath, index) => {
|
|
5741
5793
|
if (subpath.subpathId !== void 0) this.worldBranchPointsById.set(subpath.subpathId, this.worldBranchPoints[index]);
|
|
5742
5794
|
});
|
|
5743
|
-
this.worldSnapPoints =
|
|
5744
|
-
return this.worldPointById.get(point.anchorId);
|
|
5745
|
-
});
|
|
5795
|
+
this.worldSnapPoints = void 0;
|
|
5746
5796
|
}
|
|
5747
5797
|
getWorldBranchPointsView(subpathId) {
|
|
5748
5798
|
this.updateWorldPoints();
|
|
@@ -5754,7 +5804,7 @@ var LineTreeTransform = class extends ElementTransform {
|
|
|
5754
5804
|
}
|
|
5755
5805
|
getWorldSnapPointsView() {
|
|
5756
5806
|
this.updateWorldPoints();
|
|
5757
|
-
return this.worldSnapPoints;
|
|
5807
|
+
return this.worldSnapPoints ??= this.element.topology.points.map((point) => this.worldPointById.get(point.anchorId));
|
|
5758
5808
|
}
|
|
5759
5809
|
getBranchTailSource(subpathId) {
|
|
5760
5810
|
const anchorId = last(this.getBranch(subpathId).vertices).anchorId;
|
|
@@ -5838,10 +5888,32 @@ var LineTree = class extends Element {
|
|
|
5838
5888
|
return [];
|
|
5839
5889
|
}
|
|
5840
5890
|
getBindableEndpoints() {
|
|
5841
|
-
|
|
5891
|
+
const endpoints = [];
|
|
5892
|
+
for (const point of this.topology.points) {
|
|
5893
|
+
if (this.transform.getEndpointRole(point.anchorId) === null) continue;
|
|
5894
|
+
endpoints.push({ ref: {
|
|
5895
|
+
elementKey: this.key,
|
|
5896
|
+
anchorId: point.anchorId
|
|
5897
|
+
} });
|
|
5898
|
+
}
|
|
5899
|
+
return endpoints;
|
|
5842
5900
|
}
|
|
5843
5901
|
getEndpointRelationBindings() {
|
|
5844
|
-
|
|
5902
|
+
const bindings = [];
|
|
5903
|
+
for (const point of this.topology.points) {
|
|
5904
|
+
if (!point.relation) continue;
|
|
5905
|
+
const role = this.transform.getEndpointRole(point.anchorId);
|
|
5906
|
+
if (role === null) continue;
|
|
5907
|
+
bindings.push({
|
|
5908
|
+
source: {
|
|
5909
|
+
elementKey: this.key,
|
|
5910
|
+
anchorId: point.anchorId
|
|
5911
|
+
},
|
|
5912
|
+
relation: point.relation,
|
|
5913
|
+
role
|
|
5914
|
+
});
|
|
5915
|
+
}
|
|
5916
|
+
return bindings;
|
|
5845
5917
|
}
|
|
5846
5918
|
resolveOptions(options) {
|
|
5847
5919
|
return prepareTopologyOption(options);
|
|
@@ -5884,28 +5956,14 @@ var LineTree = class extends Element {
|
|
|
5884
5956
|
points
|
|
5885
5957
|
};
|
|
5886
5958
|
}
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
const referenceBounds = getLineTreeTopologyBounds(topology);
|
|
5890
|
-
const baseline = captureElementTransformBaseline(this, "pose-authored", void 0).reference;
|
|
5891
|
-
const worldMatrix = baseline.startWorldMatrix;
|
|
5892
|
-
const worldCenter = transformPoint(worldMatrix, {
|
|
5893
|
-
x: referenceBounds.left + referenceBounds.width / 2,
|
|
5894
|
-
y: referenceBounds.top + referenceBounds.height / 2
|
|
5895
|
-
});
|
|
5959
|
+
/** @internal Point edits and branch extension retain the current world pose. */
|
|
5960
|
+
resolvePointTopologyPatch(topology) {
|
|
5896
5961
|
return {
|
|
5897
|
-
...
|
|
5898
|
-
...baseline,
|
|
5899
|
-
referenceBounds
|
|
5900
|
-
}, {
|
|
5901
|
-
worldMatrix,
|
|
5902
|
-
worldCenter,
|
|
5903
|
-
parentInverseMatrix: baseline.startParentWorldInverseMatrix
|
|
5904
|
-
}).framePatch,
|
|
5962
|
+
...resolveReferenceBoundsPosePatch(this, () => [this.transform.getLayoutReferenceBoundsView(), getLineTreeTopologyBounds(topology)]),
|
|
5905
5963
|
topology
|
|
5906
5964
|
};
|
|
5907
5965
|
}
|
|
5908
|
-
captureTransformBaseline() {
|
|
5966
|
+
captureTransformBaseline(_bakeGeometry) {
|
|
5909
5967
|
const topology = this.topology;
|
|
5910
5968
|
const baseline = captureElementTransformBaseline(this, "pose-authored", { topology });
|
|
5911
5969
|
if (!topology.points.some((point) => point.relation)) return baseline;
|
|
@@ -6034,7 +6092,7 @@ var LineTree = class extends Element {
|
|
|
6034
6092
|
kind: "owner-change",
|
|
6035
6093
|
change: {
|
|
6036
6094
|
owner: this,
|
|
6037
|
-
patch: this.
|
|
6095
|
+
patch: this.resolvePointTopologyPatch(removal.topology)
|
|
6038
6096
|
},
|
|
6039
6097
|
...removal.parentSubpathId === void 0 ? {} : { nextScope: {
|
|
6040
6098
|
kind: "subpath",
|
|
@@ -6048,7 +6106,7 @@ var LineTree = class extends Element {
|
|
|
6048
6106
|
kind: "owner-change",
|
|
6049
6107
|
change: {
|
|
6050
6108
|
owner: this,
|
|
6051
|
-
patch: this.
|
|
6109
|
+
patch: this.resolvePointTopologyPatch(inserted.topology)
|
|
6052
6110
|
},
|
|
6053
6111
|
nextTarget: {
|
|
6054
6112
|
kind: "anchor",
|
|
@@ -6073,7 +6131,7 @@ var LineTree = class extends Element {
|
|
|
6073
6131
|
kind: "owner-change",
|
|
6074
6132
|
change: {
|
|
6075
6133
|
owner: this,
|
|
6076
|
-
patch: this.
|
|
6134
|
+
patch: this.resolvePointTopologyPatch(topology)
|
|
6077
6135
|
}
|
|
6078
6136
|
};
|
|
6079
6137
|
}
|
|
@@ -6144,6 +6202,7 @@ function samePoint(left, right) {
|
|
|
6144
6202
|
return left === right || left.anchorId === right.anchorId && left.point.x === right.point.x && left.point.y === right.point.y && sameEndpointRelation(left.relation, right.relation);
|
|
6145
6203
|
}
|
|
6146
6204
|
function diffRecords(before, after, getId, sameValue) {
|
|
6205
|
+
if (before === after) return [];
|
|
6147
6206
|
const beforeById = /* @__PURE__ */ new Map();
|
|
6148
6207
|
const afterById = /* @__PURE__ */ new Map();
|
|
6149
6208
|
before.forEach((value, index) => {
|
|
@@ -6212,4 +6271,4 @@ function applyLineTreeTopologyDelta(topology, delta, direction) {
|
|
|
6212
6271
|
};
|
|
6213
6272
|
}
|
|
6214
6273
|
//#endregion
|
|
6215
|
-
export { BaseLine, Bitmap, Circle, CircleTransform, ContentEditingCapabilityToken, DEFAULT_LINE_TREE_BRANCH_STYLE, EMPTY_LINE_TREE_TOPOLOGY, EditorFrameFlush, EndpointRelationIndex, Group, GroupTransform, Image, ImageProperties, ImageTransform, Line, LineTransform, LineTree, LineTreeProperties, LineTreeTransform, PointEditingCapabilityToken, Polygon, PolygonTransform, Rectangle, RectangleProperties, RectangleTransform, RippleOverlay, ScrollView, ScrollViewTransform, SelectionBehaviorCapabilityToken, SelectionBehaviorMode, SelectionDiveMode, SelectionSnapMode, SnapSourceCapabilityToken, Text, TextBlock, TextProperties, TextTransform, TransformInteractionCapabilityToken, Triangle, TriangleTransform, VectorPath, VectorPathProperties, VectorPathTransform, WorkerSurfacePool, Workspace, WorkspaceProperties, addLineTreeBranchAtTail, applyLineTreeTopologyDelta, computePosition, connectEndpoint, connectionPortAccepts, createLineTreeTopology, createLineTreeTopologyDelta, defineEditorCapability, disconnectEndpoint, fitWorkspace, flip, getEditorCapability, getEditorFrameFlush, getEndpointRelationIndex,
|
|
6274
|
+
export { BaseLine, Bitmap, Circle, CircleTransform, ContentEditingCapabilityToken, DEFAULT_LINE_TREE_BRANCH_STYLE, EMPTY_LINE_TREE_TOPOLOGY, EditorFrameFlush, EndpointRelationIndex, Group, GroupTransform, Image, ImageProperties, ImageTransform, Line, LineTransform, LineTree, LineTreeProperties, LineTreeTransform, PointEditingCapabilityToken, Polygon, PolygonTransform, Rectangle, RectangleProperties, RectangleTransform, RippleOverlay, ScrollView, ScrollViewTransform, SelectionBehaviorCapabilityToken, SelectionBehaviorMode, SelectionDiveMode, SelectionSnapMode, SnapSourceCapabilityToken, Text, TextBlock, TextProperties, TextTransform, TransformInteractionCapabilityToken, Triangle, TriangleTransform, VectorPath, VectorPathProperties, VectorPathTransform, WorkerSurfacePool, Workspace, WorkspaceProperties, addLineTreeBranchAtTail, applyLineTreeTopologyDelta, computePosition, connectEndpoint, connectionPortAccepts, createLineTreeTopology, createLineTreeTopologyDelta, defineEditorCapability, disconnectEndpoint, fitWorkspace, flip, getEditorCapability, getEditorFrameFlush, getEndpointRelationIndex, getLineTreeBranch, getLineTreeJunctionAnchorIds, getLineTreePoint, getLineTreePointReferenceCounts, getTextBlockVisualBounds, hasConnectionPortCapacity, insertLineTreePoint, isEditorCapabilityHost, isEndpointRelationSource, measureTextRun, measureTextWidth, moveLineTreePoint, offset, paintTextBlock, remapLineTreeRelations, removeLineTreeBranch, removeLineTreePoint, resolveConnectEndpointChange, resolveConnectionPortChanges, resolveDisconnectEndpointChanges, resolveGroupMemberBounds, resolveSelectionFrameBounds, resolveTextStyle, shift, subscribeTextMeasurementChanges, transformLineTreeTopology, updateLineTreeBranchStyle, workspaceFocusInsetsKey };
|