@canvas-harness/core 0.1.9 → 0.1.11
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 +42 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -7
- package/dist/index.d.ts +37 -7
- package/dist/index.js +42 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2338,6 +2338,7 @@ var createDefaultTextareaEditor = ({
|
|
|
2338
2338
|
wrap.style.borderRadius = "4px";
|
|
2339
2339
|
wrap.style.background = style.backgroundColor ?? "#ffffff";
|
|
2340
2340
|
wrap.style.zIndex = "20";
|
|
2341
|
+
wrap.style.pointerEvents = "auto";
|
|
2341
2342
|
const ta = document.createElement("textarea");
|
|
2342
2343
|
ta.value = node.content ?? "";
|
|
2343
2344
|
ta.spellcheck = false;
|
|
@@ -4786,7 +4787,13 @@ var paintAtomicRough = (rc, ctx, type, w, h, style, scale, theme, seed) => {
|
|
|
4786
4787
|
strokeWidth,
|
|
4787
4788
|
roughness,
|
|
4788
4789
|
seed,
|
|
4789
|
-
|
|
4790
|
+
// Always pass an explicit array (empty = solid) so rough.js calls
|
|
4791
|
+
// ctx.setLineDash() to a known state. Passing `undefined` makes
|
|
4792
|
+
// rough skip that call, and the canvas inherits whatever the
|
|
4793
|
+
// previous draw left behind — a transparent-stroke node's
|
|
4794
|
+
// fill-derived outline would pick up the dash from an earlier
|
|
4795
|
+
// dashed node in the same paint pass.
|
|
4796
|
+
strokeLineDash: dash,
|
|
4790
4797
|
curveStepCount: detail.curveStepCount,
|
|
4791
4798
|
maxRandomnessOffset: detail.maxRandomnessOffset
|
|
4792
4799
|
});
|
|
@@ -5959,8 +5966,30 @@ var endInside = (end, ids) => {
|
|
|
5959
5966
|
if (!isAttached(end)) return true;
|
|
5960
5967
|
return ids.has(end.nodeId);
|
|
5961
5968
|
};
|
|
5969
|
+
var clipBboxCenter = (nodes) => {
|
|
5970
|
+
if (nodes.length === 0) return { x: 0, y: 0 };
|
|
5971
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
5972
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
5973
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
5974
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
5975
|
+
for (const n of nodes) {
|
|
5976
|
+
if (n.x < minX) minX = n.x;
|
|
5977
|
+
if (n.y < minY) minY = n.y;
|
|
5978
|
+
if (n.x + n.w > maxX) maxX = n.x + n.w;
|
|
5979
|
+
if (n.y + n.h > maxY) maxY = n.y + n.h;
|
|
5980
|
+
}
|
|
5981
|
+
return { x: (minX + maxX) / 2, y: (minY + maxY) / 2 };
|
|
5982
|
+
};
|
|
5962
5983
|
var deserializeClipboard = (store, clip, opts = {}) => {
|
|
5963
|
-
|
|
5984
|
+
let offset;
|
|
5985
|
+
if (opts.offset) {
|
|
5986
|
+
offset = opts.offset;
|
|
5987
|
+
} else if (opts.at && clip.nodes.length > 0) {
|
|
5988
|
+
const center = clipBboxCenter(clip.nodes);
|
|
5989
|
+
offset = { x: opts.at.x - center.x, y: opts.at.y - center.y };
|
|
5990
|
+
} else {
|
|
5991
|
+
offset = { x: 20, y: 20 };
|
|
5992
|
+
}
|
|
5964
5993
|
const select = opts.select ?? true;
|
|
5965
5994
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
5966
5995
|
const edgeMap = /* @__PURE__ */ new Map();
|
|
@@ -5973,7 +6002,9 @@ var deserializeClipboard = (store, clip, opts = {}) => {
|
|
|
5973
6002
|
y: n.y + offset.y
|
|
5974
6003
|
}));
|
|
5975
6004
|
const remapEnd = (end) => {
|
|
5976
|
-
if (!isAttached(end))
|
|
6005
|
+
if (!isAttached(end)) {
|
|
6006
|
+
return { worldPoint: { x: end.worldPoint.x + offset.x, y: end.worldPoint.y + offset.y } };
|
|
6007
|
+
}
|
|
5977
6008
|
const newId = nodeMap.get(end.nodeId);
|
|
5978
6009
|
return newId ? { nodeId: newId, localOffset: end.localOffset } : end;
|
|
5979
6010
|
};
|
|
@@ -6016,7 +6047,14 @@ var cut = async (store) => {
|
|
|
6016
6047
|
var paste = async (store, payload, opts) => {
|
|
6017
6048
|
const clip = payload ?? await readClipboard();
|
|
6018
6049
|
if (!clip) return null;
|
|
6019
|
-
|
|
6050
|
+
let effective = opts;
|
|
6051
|
+
if (!opts?.offset && !opts?.at) {
|
|
6052
|
+
const pointer = store.getInteractionState().pointer;
|
|
6053
|
+
if (pointer) {
|
|
6054
|
+
effective = { ...opts, at: { x: pointer.worldX, y: pointer.worldY } };
|
|
6055
|
+
}
|
|
6056
|
+
}
|
|
6057
|
+
const ids = deserializeClipboard(store, clip, effective);
|
|
6020
6058
|
return ids;
|
|
6021
6059
|
};
|
|
6022
6060
|
var writeClipboard = async (clip) => {
|