@tsdraw/core 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -148,6 +148,12 @@ var DocumentStore = class {
|
|
|
148
148
|
loadSnapshot(snapshot) {
|
|
149
149
|
const pageState = cloneValue(snapshot.page);
|
|
150
150
|
const normalizedOrder = [...snapshot.order].filter((shapeId) => pageState.shapes[shapeId] != null);
|
|
151
|
+
const orderedSet = new Set(normalizedOrder);
|
|
152
|
+
for (const shapeId of Object.keys(pageState.shapes)) {
|
|
153
|
+
if (!orderedSet.has(shapeId)) {
|
|
154
|
+
normalizedOrder.push(shapeId);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
151
157
|
this.state = {
|
|
152
158
|
id: pageState.id,
|
|
153
159
|
shapes: pageState.shapes,
|
|
@@ -863,13 +869,14 @@ var PenDrawingState = class extends StateNode {
|
|
|
863
869
|
type: "straight",
|
|
864
870
|
path: encodePoints([prevEnd, { ...anchorPt, z: pressure }])
|
|
865
871
|
};
|
|
872
|
+
const withStraightSeg = [...segments, seg];
|
|
866
873
|
this.editor.updateShapes([
|
|
867
874
|
{
|
|
868
875
|
id,
|
|
869
876
|
type: "draw",
|
|
870
877
|
props: {
|
|
871
|
-
segments:
|
|
872
|
-
isClosed: this.detectClosure(
|
|
878
|
+
segments: withStraightSeg,
|
|
879
|
+
isClosed: this.detectClosure(withStraightSeg, size, scale)
|
|
873
880
|
}
|
|
874
881
|
}
|
|
875
882
|
]);
|
|
@@ -945,7 +952,7 @@ var PenDrawingState = class extends StateNode {
|
|
|
945
952
|
type: "draw",
|
|
946
953
|
props: {
|
|
947
954
|
segments: updated,
|
|
948
|
-
isClosed: this.detectClosure(
|
|
955
|
+
isClosed: this.detectClosure(updated, size, scale)
|
|
949
956
|
}
|
|
950
957
|
}
|
|
951
958
|
]);
|
|
@@ -1461,10 +1468,11 @@ var Editor = class {
|
|
|
1461
1468
|
this.emitChange();
|
|
1462
1469
|
}
|
|
1463
1470
|
setViewport(partial) {
|
|
1471
|
+
const rawZoom = partial.zoom ?? this.viewport.zoom;
|
|
1464
1472
|
this.viewport = {
|
|
1465
1473
|
x: partial.x ?? this.viewport.x,
|
|
1466
1474
|
y: partial.y ?? this.viewport.y,
|
|
1467
|
-
zoom:
|
|
1475
|
+
zoom: Math.max(0.1, Math.min(4, rawZoom))
|
|
1468
1476
|
};
|
|
1469
1477
|
this.emitChange();
|
|
1470
1478
|
}
|