@fieldnotes/core 0.7.0 → 0.7.1
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 +25 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1769,7 +1769,7 @@ function createImage(input) {
|
|
|
1769
1769
|
};
|
|
1770
1770
|
}
|
|
1771
1771
|
function createHtmlElement(input) {
|
|
1772
|
-
|
|
1772
|
+
const el = {
|
|
1773
1773
|
id: createId("html"),
|
|
1774
1774
|
type: "html",
|
|
1775
1775
|
position: input.position,
|
|
@@ -1778,6 +1778,8 @@ function createHtmlElement(input) {
|
|
|
1778
1778
|
layerId: input.layerId ?? "",
|
|
1779
1779
|
size: input.size
|
|
1780
1780
|
};
|
|
1781
|
+
if (input.domId) el.domId = input.domId;
|
|
1782
|
+
return el;
|
|
1781
1783
|
}
|
|
1782
1784
|
function createShape(input) {
|
|
1783
1785
|
return {
|
|
@@ -2095,6 +2097,7 @@ var Viewport = class {
|
|
|
2095
2097
|
if (state.layers && state.layers.length > 0) {
|
|
2096
2098
|
this.layerManager.loadSnapshot(state.layers);
|
|
2097
2099
|
}
|
|
2100
|
+
this.reattachHtmlContent();
|
|
2098
2101
|
this.history.clear();
|
|
2099
2102
|
this.historyRecorder.resume();
|
|
2100
2103
|
this.camera.moveTo(state.camera.position.x, state.camera.position.y);
|
|
@@ -2126,7 +2129,8 @@ var Viewport = class {
|
|
|
2126
2129
|
return image.id;
|
|
2127
2130
|
}
|
|
2128
2131
|
addHtmlElement(dom, position, size = { w: 200, h: 150 }) {
|
|
2129
|
-
const
|
|
2132
|
+
const domId = dom.id || void 0;
|
|
2133
|
+
const el = createHtmlElement({ position, size, domId, layerId: this.layerManager.activeLayerId });
|
|
2130
2134
|
this.htmlContent.set(el.id, dom);
|
|
2131
2135
|
this.historyRecorder.begin();
|
|
2132
2136
|
this.store.add(el);
|
|
@@ -2495,6 +2499,16 @@ var Viewport = class {
|
|
|
2495
2499
|
this.htmlContent.clear();
|
|
2496
2500
|
this.requestRender();
|
|
2497
2501
|
}
|
|
2502
|
+
reattachHtmlContent() {
|
|
2503
|
+
for (const el of this.store.getElementsByType("html")) {
|
|
2504
|
+
if (el.domId) {
|
|
2505
|
+
const dom = document.getElementById(el.domId);
|
|
2506
|
+
if (dom) {
|
|
2507
|
+
this.htmlContent.set(el.id, dom);
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2498
2512
|
createWrapper() {
|
|
2499
2513
|
const el = document.createElement("div");
|
|
2500
2514
|
Object.assign(el.style, {
|
|
@@ -2753,10 +2767,11 @@ function applyArrowHandleDrag(handle, elementId, world, ctx) {
|
|
|
2753
2767
|
const el = ctx.store.getById(elementId);
|
|
2754
2768
|
if (!el || el.type !== "arrow") return;
|
|
2755
2769
|
const threshold = BIND_THRESHOLD / ctx.camera.zoom;
|
|
2770
|
+
const layerFilter = (candidate) => candidate.layerId === el.layerId;
|
|
2756
2771
|
switch (handle) {
|
|
2757
2772
|
case "start": {
|
|
2758
2773
|
const excludeId = el.toBinding?.elementId;
|
|
2759
|
-
const target = findBindTarget(world, ctx.store, threshold, excludeId);
|
|
2774
|
+
const target = findBindTarget(world, ctx.store, threshold, excludeId, layerFilter);
|
|
2760
2775
|
if (target) {
|
|
2761
2776
|
const center = getElementCenter(target);
|
|
2762
2777
|
ctx.store.update(elementId, {
|
|
@@ -2775,7 +2790,7 @@ function applyArrowHandleDrag(handle, elementId, world, ctx) {
|
|
|
2775
2790
|
}
|
|
2776
2791
|
case "end": {
|
|
2777
2792
|
const excludeId = el.fromBinding?.elementId;
|
|
2778
|
-
const target = findBindTarget(world, ctx.store, threshold, excludeId);
|
|
2793
|
+
const target = findBindTarget(world, ctx.store, threshold, excludeId, layerFilter);
|
|
2779
2794
|
if (target) {
|
|
2780
2795
|
const center = getElementCenter(target);
|
|
2781
2796
|
ctx.store.update(elementId, {
|
|
@@ -2804,7 +2819,8 @@ function getArrowHandleDragTarget(handle, elementId, world, ctx) {
|
|
|
2804
2819
|
if (!el || el.type !== "arrow") return null;
|
|
2805
2820
|
const threshold = BIND_THRESHOLD / ctx.camera.zoom;
|
|
2806
2821
|
const excludeId = handle === "start" ? el.toBinding?.elementId : el.fromBinding?.elementId;
|
|
2807
|
-
const
|
|
2822
|
+
const layerFilter = (candidate) => candidate.layerId === el.layerId;
|
|
2823
|
+
const target = findBindTarget(world, ctx.store, threshold, excludeId, layerFilter);
|
|
2808
2824
|
if (!target) return null;
|
|
2809
2825
|
return getElementBounds(target);
|
|
2810
2826
|
}
|
|
@@ -3264,8 +3280,10 @@ var ArrowTool = class {
|
|
|
3264
3280
|
if (options.width !== void 0) this.width = options.width;
|
|
3265
3281
|
}
|
|
3266
3282
|
layerFilter(ctx) {
|
|
3267
|
-
|
|
3283
|
+
const activeLayerId = ctx.activeLayerId;
|
|
3284
|
+
if (!activeLayerId && !ctx.isLayerVisible && !ctx.isLayerLocked) return void 0;
|
|
3268
3285
|
return (el) => {
|
|
3286
|
+
if (activeLayerId && el.layerId !== activeLayerId) return false;
|
|
3269
3287
|
if (ctx.isLayerVisible && !ctx.isLayerVisible(el.layerId)) return false;
|
|
3270
3288
|
if (ctx.isLayerLocked && ctx.isLayerLocked(el.layerId)) return false;
|
|
3271
3289
|
return true;
|
|
@@ -3649,7 +3667,7 @@ var UpdateLayerCommand = class {
|
|
|
3649
3667
|
};
|
|
3650
3668
|
|
|
3651
3669
|
// src/index.ts
|
|
3652
|
-
var VERSION = "0.
|
|
3670
|
+
var VERSION = "0.7.0";
|
|
3653
3671
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3654
3672
|
0 && (module.exports = {
|
|
3655
3673
|
AddElementCommand,
|