@fieldnotes/core 0.50.3 → 0.50.5
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 +31 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2032,7 +2032,11 @@ var InputHandler = class {
|
|
|
2032
2032
|
if (this.lastPinchDistance > 0) {
|
|
2033
2033
|
const scale = dist / this.lastPinchDistance;
|
|
2034
2034
|
const newZoom = this.camera.zoom * scale;
|
|
2035
|
-
this.
|
|
2035
|
+
const rect = this.element.getBoundingClientRect();
|
|
2036
|
+
this.camera.zoomAt(newZoom, {
|
|
2037
|
+
x: center2.x - rect.left,
|
|
2038
|
+
y: center2.y - rect.top
|
|
2039
|
+
});
|
|
2036
2040
|
}
|
|
2037
2041
|
const dx = center2.x - this.lastPointer.x;
|
|
2038
2042
|
const dy = center2.y - this.lastPointer.y;
|
|
@@ -8447,7 +8451,8 @@ function hitTestArrowHandles(world, selectedIds, ctx) {
|
|
|
8447
8451
|
const hitRadius = (HANDLE_RADIUS + HANDLE_HIT_PADDING) / zoom;
|
|
8448
8452
|
for (const id of selectedIds) {
|
|
8449
8453
|
const el = ctx.store.getById(id);
|
|
8450
|
-
if (!el || el.type !== "arrow")
|
|
8454
|
+
if (!el || el.type !== "arrow" || el.locked || (ctx.isLayerLocked?.(el.layerId) ?? false))
|
|
8455
|
+
continue;
|
|
8451
8456
|
const handles = getArrowHandlePositions(el);
|
|
8452
8457
|
for (const [handle, pos] of handles) {
|
|
8453
8458
|
const dx = world.x - pos.x;
|
|
@@ -8461,7 +8466,7 @@ function hitTestArrowHandles(world, selectedIds, ctx) {
|
|
|
8461
8466
|
}
|
|
8462
8467
|
function applyArrowHandleDrag(handle, elementId, world, ctx) {
|
|
8463
8468
|
const el = ctx.store.getById(elementId);
|
|
8464
|
-
if (!el || el.type !== "arrow") return;
|
|
8469
|
+
if (!el || el.type !== "arrow" || el.locked || (ctx.isLayerLocked?.(el.layerId) ?? false)) return;
|
|
8465
8470
|
const threshold = BIND_THRESHOLD / ctx.camera.zoom;
|
|
8466
8471
|
const layerFilter = (candidate) => candidate.layerId === el.layerId;
|
|
8467
8472
|
switch (handle) {
|
|
@@ -8512,7 +8517,9 @@ function applyArrowHandleDrag(handle, elementId, world, ctx) {
|
|
|
8512
8517
|
function getArrowHandleDragTarget(handle, elementId, world, ctx) {
|
|
8513
8518
|
if (handle === "mid") return null;
|
|
8514
8519
|
const el = ctx.store.getById(elementId);
|
|
8515
|
-
if (!el || el.type !== "arrow")
|
|
8520
|
+
if (!el || el.type !== "arrow" || el.locked || (ctx.isLayerLocked?.(el.layerId) ?? false)) {
|
|
8521
|
+
return null;
|
|
8522
|
+
}
|
|
8516
8523
|
const threshold = BIND_THRESHOLD / ctx.camera.zoom;
|
|
8517
8524
|
const excludeId = handle === "start" ? el.toBinding?.elementId : el.fromBinding?.elementId;
|
|
8518
8525
|
const layerFilter = (candidate) => candidate.layerId === el.layerId;
|
|
@@ -8704,22 +8711,25 @@ function renderSelectionBoxes(ctx, p) {
|
|
|
8704
8711
|
for (const id of p.selectedIds) {
|
|
8705
8712
|
const el = p.store.getById(id);
|
|
8706
8713
|
if (!el) continue;
|
|
8714
|
+
const locked = el.locked || (p.isLayerLocked?.(el.layerId) ?? false);
|
|
8707
8715
|
if (el.type === "arrow") {
|
|
8708
|
-
renderArrowHandles(ctx, el, zoom);
|
|
8716
|
+
if (!locked) renderArrowHandles(ctx, el, zoom);
|
|
8709
8717
|
renderBindingHighlights(ctx, el, zoom, p.store);
|
|
8710
8718
|
continue;
|
|
8711
8719
|
}
|
|
8712
8720
|
if (el.type === "shape" && el.shape === "line") {
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
+
if (!locked) {
|
|
8722
|
+
ctx.setLineDash([]);
|
|
8723
|
+
ctx.fillStyle = "#ffffff";
|
|
8724
|
+
const r = handleWorldSize / 2;
|
|
8725
|
+
for (const pt of lineEndpoints(el)) {
|
|
8726
|
+
ctx.beginPath();
|
|
8727
|
+
ctx.arc(pt.x, pt.y, r, 0, Math.PI * 2);
|
|
8728
|
+
ctx.fill();
|
|
8729
|
+
ctx.stroke();
|
|
8730
|
+
}
|
|
8731
|
+
ctx.setLineDash([4 / zoom, 4 / zoom]);
|
|
8721
8732
|
}
|
|
8722
|
-
ctx.setLineDash([4 / zoom, 4 / zoom]);
|
|
8723
8733
|
continue;
|
|
8724
8734
|
}
|
|
8725
8735
|
const bounds = getElementBounds(el);
|
|
@@ -8954,7 +8964,8 @@ function hitTestLineHandles(world, ctx, selectedIds) {
|
|
|
8954
8964
|
const r2 = r * r;
|
|
8955
8965
|
for (const id of selectedIds) {
|
|
8956
8966
|
const el = ctx.store.getById(id);
|
|
8957
|
-
if (!el || el.type !== "shape" || el.shape !== "line")
|
|
8967
|
+
if (!el || el.type !== "shape" || el.shape !== "line" || el.locked || (ctx.isLayerLocked?.(el.layerId) ?? false))
|
|
8968
|
+
continue;
|
|
8958
8969
|
const [a, b] = lineEndpoints(el);
|
|
8959
8970
|
if ((world.x - a.x) ** 2 + (world.y - a.y) ** 2 <= r2) return { elementId: id, fixed: b };
|
|
8960
8971
|
if ((world.x - b.x) ** 2 + (world.y - b.y) ** 2 <= r2) return { elementId: id, fixed: a };
|
|
@@ -9388,10 +9399,10 @@ var SelectTool = class {
|
|
|
9388
9399
|
if (this.mode.type === "line-handle") {
|
|
9389
9400
|
ctx.setCursor?.("grabbing");
|
|
9390
9401
|
const el = ctx.store.getById(this.mode.elementId);
|
|
9391
|
-
if (el && el.type === "shape") {
|
|
9402
|
+
if (el && el.type === "shape" && el.shape === "line" && !el.locked && !(ctx.isLayerLocked?.(el.layerId) ?? false)) {
|
|
9392
9403
|
ctx.store.update(el.id, lineFromEndpoints(this.mode.fixed, world));
|
|
9404
|
+
ctx.requestRender();
|
|
9393
9405
|
}
|
|
9394
|
-
ctx.requestRender();
|
|
9395
9406
|
return;
|
|
9396
9407
|
}
|
|
9397
9408
|
if (this.mode.type === "resizing-template") {
|
|
@@ -9549,7 +9560,8 @@ var SelectTool = class {
|
|
|
9549
9560
|
renderSelectionBoxes(canvasCtx, {
|
|
9550
9561
|
selectedIds: this._selectedIds,
|
|
9551
9562
|
store: this.ctx.store,
|
|
9552
|
-
zoom: this.ctx.camera.zoom
|
|
9563
|
+
zoom: this.ctx.camera.zoom,
|
|
9564
|
+
isLayerLocked: this.ctx.isLayerLocked
|
|
9553
9565
|
});
|
|
9554
9566
|
if (this.mode.type === "arrow-handle" && this.ctx) {
|
|
9555
9567
|
const target = getArrowHandleDragTarget(
|
|
@@ -10706,7 +10718,7 @@ var LaserTool = class {
|
|
|
10706
10718
|
};
|
|
10707
10719
|
|
|
10708
10720
|
// src/index.ts
|
|
10709
|
-
var VERSION = "0.50.
|
|
10721
|
+
var VERSION = "0.50.5";
|
|
10710
10722
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10711
10723
|
0 && (module.exports = {
|
|
10712
10724
|
ArrowTool,
|