@johnoscott/isometric-engine 0.9.0 → 0.12.3
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/EDITOR-GUIDE.md +54 -6
- package/README.md +1 -1
- package/assets/app.css +38 -3
- package/assets/icons.svg +1 -1
- package/assets/marks.css +5 -1
- package/iso-editor.js +173 -173
- package/iso-render.js +97 -97
- package/iso-systems.js +104 -104
- package/js/iso-editor/doc.js +4 -0
- package/js/iso-editor/splice.js +3 -1
- package/js/iso-editor/ui/canvas.js +393 -18
- package/js/iso-editor/ui/plain-icons.js +2 -0
- package/js/iso-editor/ui/setup.js +7 -2
- package/js/iso-objects/board.js +6 -1
- package/js/iso-objects/scene.js +3 -2
- package/js/iso-viewer/index.js +4 -1
- package/package.json +101 -92
- package/src/iso-core/compile-schema.ts +3 -1
- package/src/iso-editor/adapter.ts +19 -0
- package/src/iso-editor/doc.ts +6 -0
- package/src/iso-editor/index.ts +2 -2
- package/src/iso-editor/splice.ts +8 -3
- package/src/iso-editor/ui/app.css +33 -2
- package/src/iso-editor/ui/canvas.ts +299 -23
- package/src/iso-editor/ui/marks.css +5 -1
- package/src/iso-editor/ui/plain-icons.ts +2 -0
- package/src/iso-editor/ui/setup.ts +16 -3
- package/src/iso-objects/board.ts +6 -2
- package/src/iso-objects/route.ts +1 -1
- package/src/iso-objects/scene.ts +4 -2
- package/src/iso-viewer/index.ts +2 -2
- package/src/iso-viewer/morph.ts +5 -2
- package/types/iso-core/compile-schema.d.ts +2 -2
- package/types/iso-editor/adapter.d.ts +33 -0
- package/types/iso-editor/index.d.ts +2 -2
- package/types/iso-editor/ui/canvas.d.ts +44 -8
- package/types/iso-editor/ui/monaco-entry.d.ts +2 -0
- package/types/iso-editor/ui/setup.d.ts +13 -0
- package/types/iso-objects/route.d.ts +1 -1
- package/types/iso-systems/validate.d.ts +4 -0
- package/types/iso-viewer/bundle.d.ts +1 -0
- package/types/iso-viewer/index.d.ts +2 -2
- package/types/iso-viewer/morph.d.ts +6 -3
package/js/iso-editor/doc.js
CHANGED
|
@@ -145,6 +145,10 @@ function parentByIndent(d, lineStart, indent, forList = false) {
|
|
|
145
145
|
if (a.where === "key") return a.path.slice(0, -1);
|
|
146
146
|
if (line.slice(ind).startsWith("- ")) return a.path.slice(0, -1);
|
|
147
147
|
}
|
|
148
|
+
if (!forList && /^- /.test(line.slice(ind)) && ind + 2 === indent) {
|
|
149
|
+
const a = d.at(s + ind + 2);
|
|
150
|
+
if (a.where === "key") return a.path.slice(0, -1);
|
|
151
|
+
}
|
|
148
152
|
if (ind < indent || forList && ind <= indent && /:\s*$/.test(line)) {
|
|
149
153
|
const m = /^(\s*)(- )?([^\s:#][^:#]*?)\s*:/.exec(line);
|
|
150
154
|
if (m) {
|
package/js/iso-editor/splice.js
CHANGED
|
@@ -334,7 +334,9 @@ function insertItem(text, listPath, value, index, order) {
|
|
|
334
334
|
s.items.splice(at, 0, d.createNode(value));
|
|
335
335
|
}, true);
|
|
336
336
|
const indent = prefix.indexOf("-");
|
|
337
|
-
const
|
|
337
|
+
const near = items[Math.min(at, items.length - 1)];
|
|
338
|
+
const inline = isObj(value) && isMap(near) && near.flow;
|
|
339
|
+
const body = " ".repeat(indent) + "- " + (inline ? flowText(value) : isObj(value) && Object.keys(value).length ? reindent(yamlText(value), indent + 2).slice(indent + 2) : scalarText(value, { flow: false, indent: indent + 2 })) + "\n";
|
|
338
340
|
if (at < items.length) {
|
|
339
341
|
const s = lineStart(text, items[at].range[0]);
|
|
340
342
|
return { steps: [[{ start: s, end: s, text: body }]] };
|
|
@@ -12,11 +12,12 @@ import { viewport } from "../../iso-viewer/viewport.js";
|
|
|
12
12
|
const SVGNS = "http://www.w3.org/2000/svg";
|
|
13
13
|
function canvasView(host, doc, opts) {
|
|
14
14
|
const K = opts.kit, ui = K.ui, T = ui.text;
|
|
15
|
-
const { setCmd, deleteCmd, insertCmd, pinsCmd, withPinsMoved, freshName, describe } = K.commands;
|
|
15
|
+
const { setCmd, deleteCmd, insertCmd, insertItemCmd, pinsCmd, withPinsMoved, freshName, describe } = K.commands;
|
|
16
16
|
const { deletePaths, renameDialog, duplicate, connected } = K.actions;
|
|
17
17
|
const resourceOf = (ptr) => K.objectOf(ptr);
|
|
18
18
|
const kindOf = (k) => K.kinds.find((x) => x.kind === k);
|
|
19
19
|
const PINS_KEY = K.pins.key;
|
|
20
|
+
let linking;
|
|
20
21
|
host.classList.add("canvas");
|
|
21
22
|
const stage = h("div", { class: `${ui.rootClass} canvas-stage`, tabindex: "0", role: "application", "aria-label": T.stage });
|
|
22
23
|
const tools = h("div", { class: "canvas-tools", role: "toolbar", "aria-label": "Canvas" });
|
|
@@ -252,7 +253,9 @@ function canvasView(host, doc, opts) {
|
|
|
252
253
|
const live = layer?.extent?.() ?? [];
|
|
253
254
|
return union([...ptrs.flatMap((p) => elementsFor(p)).filter((e) => e.getBBox().width || e.getBBox().height).map(boxOf), ...live]);
|
|
254
255
|
}
|
|
255
|
-
const
|
|
256
|
+
const docked = ui.paletteLayout === "docked";
|
|
257
|
+
const viewEl = docked ? stage : host;
|
|
258
|
+
const V = viewport(viewEl, {
|
|
256
259
|
svg: () => svg,
|
|
257
260
|
onApply: (k) => {
|
|
258
261
|
svg.classList.toggle("zoom-near", k >= 1);
|
|
@@ -374,6 +377,35 @@ function canvasView(host, doc, opts) {
|
|
|
374
377
|
};
|
|
375
378
|
if (hoverId !== void 0 && !doc.selection.some((p) => toPointer(p) === hoverId)) draw2(hoverId, "hover");
|
|
376
379
|
for (const p of doc.selection) draw2(toPointer(p), "ring");
|
|
380
|
+
const one = connectable();
|
|
381
|
+
const from = linking?.from ?? one;
|
|
382
|
+
const fb = from ? boxFor(fromPointer(from.path)) : void 0;
|
|
383
|
+
if (fb && K.connect) {
|
|
384
|
+
const k = scale(), hx = fb.x + fb.w + 10 / k, hy = fb.y + fb.h / 2;
|
|
385
|
+
if (linking && linking.x !== void 0 && linking.y !== void 0) {
|
|
386
|
+
if (linking.over) draw2(linking.over, "hover");
|
|
387
|
+
const l = d.createElementNS(SVGNS, "line");
|
|
388
|
+
l.setAttribute("class", `connect-line${linking.over ? " ok" : ""}`);
|
|
389
|
+
l.setAttribute("x1", String(hx));
|
|
390
|
+
l.setAttribute("y1", String(hy));
|
|
391
|
+
l.setAttribute("x2", String(linking.x));
|
|
392
|
+
l.setAttribute("y2", String(linking.y));
|
|
393
|
+
overlay.append(l);
|
|
394
|
+
}
|
|
395
|
+
if (!linking) {
|
|
396
|
+
const c = d.createElementNS(SVGNS, "circle");
|
|
397
|
+
c.setAttribute("class", "connect-handle");
|
|
398
|
+
c.setAttribute("cx", String(hx));
|
|
399
|
+
c.setAttribute("cy", String(hy));
|
|
400
|
+
c.setAttribute("r", String(7 / k));
|
|
401
|
+
c.style.pointerEvents = "all";
|
|
402
|
+
c.style.cursor = "crosshair";
|
|
403
|
+
const t = d.createElementNS(SVGNS, "title");
|
|
404
|
+
t.textContent = `Drag to what ${from.name} connects to`;
|
|
405
|
+
c.append(t);
|
|
406
|
+
overlay.append(c);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
377
409
|
const counts = /* @__PURE__ */ new Map();
|
|
378
410
|
for (const pr of opts.problems()) {
|
|
379
411
|
if (pr.file) continue;
|
|
@@ -431,6 +463,22 @@ function canvasView(host, doc, opts) {
|
|
|
431
463
|
stage.focus({ preventScroll: true });
|
|
432
464
|
if (layer?.down?.(e)) return;
|
|
433
465
|
const { x, y } = pageXY(e);
|
|
466
|
+
if (e.button === 0 && linking?.pick) {
|
|
467
|
+
e.preventDefault();
|
|
468
|
+
endConnect(pathAtEvent(e.target));
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (e.button === 0 && e.target?.closest?.(".connect-handle")) {
|
|
472
|
+
const one = connectable();
|
|
473
|
+
if (one) {
|
|
474
|
+
capture(e);
|
|
475
|
+
e.preventDefault();
|
|
476
|
+
const p2 = toSvg(x, y);
|
|
477
|
+
linking = { from: one, x: p2.x, y: p2.y };
|
|
478
|
+
paintOverlay();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
434
482
|
if (e.button === 0 || e.button === 1) capture(e);
|
|
435
483
|
const pan = () => {
|
|
436
484
|
drag = { kind: "pan", x0: x, y0: y, v0: { ...V.view } };
|
|
@@ -493,6 +541,13 @@ function canvasView(host, doc, opts) {
|
|
|
493
541
|
}
|
|
494
542
|
function move(e) {
|
|
495
543
|
const { x, y } = pageXY(e);
|
|
544
|
+
if (linking) {
|
|
545
|
+
const p = toSvg(x, y), under = pathAtEvent(document.elementFromPoint(x, y));
|
|
546
|
+
const r = under === void 0 ? void 0 : resourceOf(under);
|
|
547
|
+
linking = { ...linking, x: p.x, y: p.y, over: r && r.path !== linking.from.path ? r.path : void 0 };
|
|
548
|
+
paintOverlay();
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
496
551
|
if (!drag) {
|
|
497
552
|
const p = pathAtEvent(e.target);
|
|
498
553
|
if (p !== hoverId) {
|
|
@@ -740,6 +795,11 @@ function canvasView(host, doc, opts) {
|
|
|
740
795
|
}
|
|
741
796
|
}
|
|
742
797
|
function up(e) {
|
|
798
|
+
if (linking && !linking.pick) {
|
|
799
|
+
const { x: x2, y: y2 } = pageXY(e);
|
|
800
|
+
endConnect(pathAtEvent(document.elementFromPoint(x2, y2)));
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
743
803
|
const d0 = drag;
|
|
744
804
|
drag = void 0;
|
|
745
805
|
svg?.classList.remove("panning");
|
|
@@ -834,6 +894,8 @@ function canvasView(host, doc, opts) {
|
|
|
834
894
|
items.push({ label: "Show in text", icon: "code-xml", onSelect: () => opts.showInText(one) });
|
|
835
895
|
items.push({ label: "Show in tree", icon: "list-tree", onSelect: () => opts.showInTree(one) });
|
|
836
896
|
}
|
|
897
|
+
if (K.connect && one && isRes) items.push({ label: "Connect to\u2026", icon: "link", desc: "Then click what it connects to (Esc cancels)", disabled: ro, onSelect: () => startPick() });
|
|
898
|
+
if (K.group) items.push({ label: sel.length > 1 ? `Group ${sel.length} items` : "Group", icon: "box", keys: "\u2318G", desc: "Into a new container, as one step", disabled: ro || !members().length, why: "Only objects are grouped", onSelect: groupSelection });
|
|
837
899
|
items.push({ label: "Select parent", icon: "arrow-up-right", keys: "\u2318\u2191", onSelect: selectParent });
|
|
838
900
|
items.push({ label: "Select connected", icon: "link", desc: "What refers to it, and what it refers to", onSelect: () => doc.select(connected(doc, sel), "canvas") });
|
|
839
901
|
items.push({ label: "Zoom to selection", keys: "\u21E72", onSelect: zoomToSelection });
|
|
@@ -841,6 +903,75 @@ function canvasView(host, doc, opts) {
|
|
|
841
903
|
items.push({ sep: true }, { label: sel.length > 1 ? `Delete ${sel.length} items` : "Delete", icon: "trash-2", keys: "\u232B", danger: true, disabled: ro, onSelect: () => deletePaths(doc, sel, "canvas", opts.note) });
|
|
842
904
|
return items;
|
|
843
905
|
}
|
|
906
|
+
function connectable() {
|
|
907
|
+
if (!K.connect || !doc.doc.ok || doc.selection.length !== 1) return void 0;
|
|
908
|
+
const ptr = toPointer(doc.selection[0]), r = resourceOf(ptr);
|
|
909
|
+
return r && r.path === ptr ? r : void 0;
|
|
910
|
+
}
|
|
911
|
+
function startPick() {
|
|
912
|
+
const from = connectable();
|
|
913
|
+
if (!from) return;
|
|
914
|
+
linking = { from, pick: true };
|
|
915
|
+
opts.note(`Click what ${from.name} connects to (Esc cancels)`);
|
|
916
|
+
paintOverlay();
|
|
917
|
+
}
|
|
918
|
+
function endConnect(ptr) {
|
|
919
|
+
const from = linking?.from;
|
|
920
|
+
linking = void 0;
|
|
921
|
+
paintOverlay();
|
|
922
|
+
if (!from || ptr === void 0) return;
|
|
923
|
+
const to = resourceOf(ptr);
|
|
924
|
+
if (!to || to.path === from.path) {
|
|
925
|
+
opts.note("Not connected: drop it on another object", "warn");
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
const data = doc.goodDoc.data;
|
|
929
|
+
const plan = K.connect?.(from, to, data);
|
|
930
|
+
if (!plan) {
|
|
931
|
+
opts.note(`${from.name} and ${to.name} can't be connected`, "warn");
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
const label = plan.label ?? `Connect ${from.name} to ${to.name}`;
|
|
935
|
+
let cmd, path;
|
|
936
|
+
if (plan.name !== void 0) {
|
|
937
|
+
const name = freshName(doc.text, plan.name);
|
|
938
|
+
cmd = insertCmd(plan.at, name, plan.value, { label });
|
|
939
|
+
path = [...plan.at, name];
|
|
940
|
+
} else {
|
|
941
|
+
const list = plan.at.reduce((x, k) => x && typeof x === "object" ? x[k] : void 0, data);
|
|
942
|
+
path = [...plan.at, Array.isArray(list) ? list.length : 0];
|
|
943
|
+
cmd = insertItemCmd(plan.at, plan.value, void 0, label);
|
|
944
|
+
}
|
|
945
|
+
if (run(doc, { ...cmd, select: [path] }, "canvas", opts.note)) doc.select([path], "canvas");
|
|
946
|
+
}
|
|
947
|
+
function members() {
|
|
948
|
+
const out = /* @__PURE__ */ new Map();
|
|
949
|
+
for (const p of doc.selection) {
|
|
950
|
+
const r = resourceOf(toPointer(p));
|
|
951
|
+
if (r) out.set(r.path, r);
|
|
952
|
+
}
|
|
953
|
+
return [...out.values()];
|
|
954
|
+
}
|
|
955
|
+
function groupSelection() {
|
|
956
|
+
if (!K.group || !doc.doc.ok) return;
|
|
957
|
+
const ms = members();
|
|
958
|
+
if (!ms.length) {
|
|
959
|
+
opts.note("Only objects are grouped", "warn");
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
const plan = K.group(ms, doc.goodDoc.data);
|
|
963
|
+
if (!plan) {
|
|
964
|
+
opts.note(ms.length > 1 ? `These ${ms.length} can't be grouped` : `${ms[0].name} can't be grouped`, "warn");
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
const name = freshName(doc.text, plan.name);
|
|
968
|
+
const pins = K.pins.of(doc.goodDoc.data) ?? {};
|
|
969
|
+
const unpin = ms.filter((m) => pins[m.name] !== void 0).map((m) => withPinsMoved(deleteCmd([PINS_KEY, "layout", m.name])));
|
|
970
|
+
const label = plan.label ?? `Group ${ms.length > 1 ? `${ms.length} items` : ms[0].name} into ${name}`;
|
|
971
|
+
const p = [...plan.at, name];
|
|
972
|
+
const cmd = seqCmd(label, [insertCmd(plan.at, name, plan.value, { label }), ...plan.members(name).map((m) => setCmd(m.path, m.value)), ...unpin]);
|
|
973
|
+
if (run(doc, { ...cmd, select: [p] }, "canvas", opts.note)) doc.select([p], "canvas");
|
|
974
|
+
}
|
|
844
975
|
function addResource(s) {
|
|
845
976
|
const k = kindOf(s);
|
|
846
977
|
const name = freshName(doc.text, k.singular);
|
|
@@ -902,37 +1033,258 @@ function canvasView(host, doc, opts) {
|
|
|
902
1033
|
}
|
|
903
1034
|
return void 0;
|
|
904
1035
|
}
|
|
905
|
-
function
|
|
1036
|
+
function objectsUnder(at) {
|
|
1037
|
+
if (!cd) return [];
|
|
1038
|
+
const p = toSvg(at.x, at.y);
|
|
1039
|
+
const refOf = (id) => {
|
|
1040
|
+
const ptr = cd.pathOf.get(id);
|
|
1041
|
+
const r = ptr === void 0 ? void 0 : resourceOf(ptr);
|
|
1042
|
+
return r && r.path === ptr ? r : void 0;
|
|
1043
|
+
};
|
|
1044
|
+
if (flat) return flat.panelsAt(p.x, p.y).map(refOf).filter((r) => !!r);
|
|
1045
|
+
const inside = (poly) => {
|
|
1046
|
+
let c = false;
|
|
1047
|
+
for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {
|
|
1048
|
+
const [xi, yi] = poly[i], [xj, yj] = poly[j];
|
|
1049
|
+
if (yi > p.y !== yj > p.y && p.x < (xj - xi) * (p.y - yi) / (yj - yi) + xi) c = !c;
|
|
1050
|
+
}
|
|
1051
|
+
return c;
|
|
1052
|
+
};
|
|
1053
|
+
const depth = (i) => {
|
|
1054
|
+
let n = 0;
|
|
1055
|
+
for (let q = i.parent; q; q = q.parent) n++;
|
|
1056
|
+
return n;
|
|
1057
|
+
};
|
|
1058
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1059
|
+
for (const e of fdoc().elementsFromPoint(at.x, at.y)) {
|
|
1060
|
+
if (!svg?.contains(e)) continue;
|
|
1061
|
+
for (let el = e.closest("[data-id]"); el; el = el.parentElement?.closest("[data-id]") ?? null) {
|
|
1062
|
+
const r = refOf(el.getAttribute("data-id") ?? "");
|
|
1063
|
+
if (r && !seen.has(r.path)) seen.set(r.path, r);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
const hits = [];
|
|
1067
|
+
for (const [, id] of cd.pinId) {
|
|
1068
|
+
const item = cd.scene.layout.byId.get(id), r = refOf(id);
|
|
1069
|
+
if (item && r && !seen.has(r.path) && inside(floorOf(item.box))) hits.push({ r, d: depth(item), a: (item.box.x1 - item.box.x0) * (item.box.y1 - item.box.y0) });
|
|
1070
|
+
}
|
|
1071
|
+
return [...seen.values(), ...hits.sort((x, y) => y.d - x.d || x.a - y.a).map((h2) => h2.r)];
|
|
1072
|
+
}
|
|
1073
|
+
function addFromPalette(sec, at, item) {
|
|
906
1074
|
if (!doc.doc.ok) {
|
|
907
1075
|
opts.note("Fix the YAML first", "warn");
|
|
908
1076
|
return void 0;
|
|
909
1077
|
}
|
|
910
1078
|
const k = kindOf(sec);
|
|
911
|
-
const
|
|
1079
|
+
const preset = item?.value?.();
|
|
1080
|
+
const what = item && preset !== void 0 ? item.label.toLowerCase() : k.singular;
|
|
1081
|
+
const name = freshName(doc.text, item?.name ?? k.singular);
|
|
912
1082
|
const p = [...k.section, name];
|
|
913
|
-
let value = k.template();
|
|
1083
|
+
let value = preset ?? k.template();
|
|
914
1084
|
let into;
|
|
915
1085
|
const drop = at ? K.dropInto?.(sec) : void 0;
|
|
916
1086
|
if (at && drop) {
|
|
917
1087
|
const c = containerAt(drop.container, at);
|
|
918
1088
|
if (c) {
|
|
919
1089
|
into = c;
|
|
920
|
-
value = drop.value(c);
|
|
1090
|
+
value = { ...drop.value(c), ...preset ?? {} };
|
|
921
1091
|
}
|
|
922
1092
|
}
|
|
923
|
-
|
|
1093
|
+
let intoLabel = into ? drop.label(into) : "";
|
|
1094
|
+
if (at && !into && K.dropOnto) {
|
|
1095
|
+
for (const t of objectsUnder(at)) {
|
|
1096
|
+
const plan = K.dropOnto(t, value, sec, doc.goodDoc.data);
|
|
1097
|
+
if (plan) {
|
|
1098
|
+
into = t.name;
|
|
1099
|
+
value = plan.value;
|
|
1100
|
+
intoLabel = plan.label ? ` ${plan.label}` : ` in ${t.name}`;
|
|
1101
|
+
break;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
const label = `Add ${what} ${name}${intoLabel}`;
|
|
924
1106
|
const add = insertCmd(p.slice(0, -1), name, value, { label });
|
|
925
1107
|
const pin = at && !into && mode === "3d" ? placeAt(name, add, at) : void 0;
|
|
926
1108
|
const cmd = pin ? seqCmd(`${label} at [${pin.join(", ")}]`, [add, withPinsMoved(setCmd([PINS_KEY, "layout", name], { at: pin }))]) : add;
|
|
927
1109
|
if (!run(doc, { ...cmd, select: [p] }, "canvas", opts.note)) return void 0;
|
|
928
1110
|
if (at && !into && !pin) opts.note(mode === "2d" ? `${k.singular} ${name} added; the layout placed it (in 3D a drop pins it where it lands)` : `${k.singular} ${name} added; that spot is taken, so the layout placed it`);
|
|
929
1111
|
doc.select([p], "canvas");
|
|
1112
|
+
stage.focus({ preventScroll: true });
|
|
930
1113
|
renameDialog(doc, p, "canvas", opts.note);
|
|
931
1114
|
return p;
|
|
932
1115
|
}
|
|
933
1116
|
const palette = h("div", { class: "palette", role: "toolbar", "aria-label": T.palette, "aria-orientation": "vertical" });
|
|
934
|
-
|
|
935
|
-
|
|
1117
|
+
const sections = /* @__PURE__ */ new Map();
|
|
1118
|
+
const PAL_KEY = "canvas-palette";
|
|
1119
|
+
let lastSection;
|
|
1120
|
+
try {
|
|
1121
|
+
const v = JSON.parse(opts.store?.get(PAL_KEY) ?? "{}");
|
|
1122
|
+
if (typeof v.last === "string") lastSection = v.last;
|
|
1123
|
+
} catch {
|
|
1124
|
+
}
|
|
1125
|
+
const named = [...new Set(ui.palette.map((i) => i.section).filter((x) => x !== void 0))];
|
|
1126
|
+
const openAtStart = lastSection !== void 0 && named.includes(lastSection) ? lastSection : named[0];
|
|
1127
|
+
const setOpen = (sec, open) => {
|
|
1128
|
+
const g = sections.get(sec);
|
|
1129
|
+
if (!g) return;
|
|
1130
|
+
g.head.setAttribute("aria-expanded", String(open));
|
|
1131
|
+
g.body.hidden = !open;
|
|
1132
|
+
};
|
|
1133
|
+
function sectionBody(sec) {
|
|
1134
|
+
const have = sections.get(sec);
|
|
1135
|
+
if (have) return have.body;
|
|
1136
|
+
const id = `pal-sec-${sections.size}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1137
|
+
const head = h("button", { type: "button", class: "pal-head", "aria-expanded": "false", "aria-controls": id, "data-section-head": sec }, icon("chevron-right", "pal-chev"), h("span", { class: "pal-head-label" }, sec));
|
|
1138
|
+
const body = h("div", { class: "pal-body", id, role: "group", "aria-label": sec, "data-section-body": sec });
|
|
1139
|
+
head.addEventListener("click", () => setOpen(sec, head.getAttribute("aria-expanded") !== "true"));
|
|
1140
|
+
palette.append(h("div", { class: "pal-section", "data-pal-section": sec }, head, body));
|
|
1141
|
+
sections.set(sec, { head, body });
|
|
1142
|
+
setOpen(sec, sec === openAtStart);
|
|
1143
|
+
return body;
|
|
1144
|
+
}
|
|
1145
|
+
const DOCK_KEY = "canvas-palette-dock";
|
|
1146
|
+
const dockPref = {};
|
|
1147
|
+
try {
|
|
1148
|
+
const v = JSON.parse(opts.store?.get(DOCK_KEY) ?? "{}");
|
|
1149
|
+
if (typeof v.w === "number" && Number.isFinite(v.w)) dockPref.w = v.w;
|
|
1150
|
+
if (v.collapsed === true) dockPref.collapsed = true;
|
|
1151
|
+
} catch {
|
|
1152
|
+
}
|
|
1153
|
+
const saveDock = () => {
|
|
1154
|
+
try {
|
|
1155
|
+
opts.store?.set(DOCK_KEY, JSON.stringify(dockPref));
|
|
1156
|
+
} catch {
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
const DOCK_MIN = 160, DOCK_MAX = 440;
|
|
1160
|
+
const palHome = docked ? h("aside", { class: "pal-dock", "aria-label": "Palette" }) : palette;
|
|
1161
|
+
const palGrip = h("div", { class: "pal-grip", role: "separator", "aria-orientation": "vertical", "aria-label": "Resize the palette", tabindex: "0" });
|
|
1162
|
+
const search = h("input", { type: "search", class: "pal-search", placeholder: "Search", "aria-label": "Search the palette", autocomplete: "off", spellcheck: "false" });
|
|
1163
|
+
const none = h("p", { class: "pal-none", role: "status", hidden: "" });
|
|
1164
|
+
const collapseBtn = h("button", { type: "button", class: "btn sm quiet icon-only pal-collapse", "aria-expanded": "true", "aria-label": "Collapse the palette", title: "Collapse the palette" }, icon("chevron-left"));
|
|
1165
|
+
const visibleItems = () => [...palette.querySelectorAll(".pal-item")].filter((b) => !b.hidden && !b.closest("[hidden]"));
|
|
1166
|
+
let before;
|
|
1167
|
+
function filter() {
|
|
1168
|
+
const words = search.value.toLowerCase().split(/\s+/).filter(Boolean);
|
|
1169
|
+
if (words.length && !before) before = new Map([...sections].map(([k, g]) => [k, g.head.getAttribute("aria-expanded") === "true"]));
|
|
1170
|
+
let shown = 0;
|
|
1171
|
+
for (const b of palette.querySelectorAll(".pal-item")) {
|
|
1172
|
+
const item = ui.palette[Number(b.dataset.entry)];
|
|
1173
|
+
const hay = `${item.label} ${item.section ?? ""}`.toLowerCase();
|
|
1174
|
+
b.hidden = !words.every((w) => hay.includes(w));
|
|
1175
|
+
if (!b.hidden) shown++;
|
|
1176
|
+
}
|
|
1177
|
+
for (const [sec, g] of sections) {
|
|
1178
|
+
const any = [...g.body.querySelectorAll(".pal-item")].some((b) => !b.hidden);
|
|
1179
|
+
g.head.parentElement.hidden = words.length > 0 && !any;
|
|
1180
|
+
if (words.length) setOpen(sec, any);
|
|
1181
|
+
}
|
|
1182
|
+
if (!words.length && before) {
|
|
1183
|
+
for (const [sec, open] of before) setOpen(sec, open);
|
|
1184
|
+
before = void 0;
|
|
1185
|
+
}
|
|
1186
|
+
none.hidden = shown > 0;
|
|
1187
|
+
none.textContent = shown ? "" : `Nothing matches "${search.value.trim()}"`;
|
|
1188
|
+
}
|
|
1189
|
+
const setDockW = (w, keep = true) => {
|
|
1190
|
+
const v = Math.round(Math.min(DOCK_MAX, Math.max(DOCK_MIN, w)));
|
|
1191
|
+
host.style.setProperty("--pal-w", `${v}px`);
|
|
1192
|
+
palGrip.setAttribute("aria-valuenow", String(v));
|
|
1193
|
+
if (keep) {
|
|
1194
|
+
dockPref.w = v;
|
|
1195
|
+
saveDock();
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
const setCollapsed = (c, keep = true) => {
|
|
1199
|
+
host.classList.toggle("pal-collapsed", c);
|
|
1200
|
+
collapseBtn.setAttribute("aria-expanded", String(!c));
|
|
1201
|
+
const say = c ? "Show the palette" : "Collapse the palette";
|
|
1202
|
+
collapseBtn.setAttribute("aria-label", say);
|
|
1203
|
+
collapseBtn.title = say;
|
|
1204
|
+
collapseBtn.replaceChildren(icon(c ? "chevron-right" : "chevron-left"));
|
|
1205
|
+
if (keep) {
|
|
1206
|
+
if (c) dockPref.collapsed = true;
|
|
1207
|
+
else delete dockPref.collapsed;
|
|
1208
|
+
saveDock();
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
if (docked) {
|
|
1212
|
+
host.classList.add("pal-docked");
|
|
1213
|
+
palette.classList.add("pal-list");
|
|
1214
|
+
palHome.append(h("div", { class: "pal-dock-head" }, collapseBtn, h("label", { class: "pal-search-wrap" }, icon("search"), search)), palette, none);
|
|
1215
|
+
palGrip.setAttribute("aria-valuemin", String(DOCK_MIN));
|
|
1216
|
+
palGrip.setAttribute("aria-valuemax", String(DOCK_MAX));
|
|
1217
|
+
setDockW(dockPref.w ?? 220, false);
|
|
1218
|
+
setCollapsed(!!dockPref.collapsed, false);
|
|
1219
|
+
collapseBtn.addEventListener("click", () => {
|
|
1220
|
+
setCollapsed(!host.classList.contains("pal-collapsed"));
|
|
1221
|
+
if (!host.classList.contains("pal-collapsed")) search.focus();
|
|
1222
|
+
});
|
|
1223
|
+
search.addEventListener("input", filter);
|
|
1224
|
+
search.addEventListener("keydown", (e) => {
|
|
1225
|
+
if (e.key === "Escape" && search.value) {
|
|
1226
|
+
e.preventDefault();
|
|
1227
|
+
e.stopPropagation();
|
|
1228
|
+
search.value = "";
|
|
1229
|
+
filter();
|
|
1230
|
+
} else if (e.key === "ArrowDown") {
|
|
1231
|
+
const first = visibleItems()[0];
|
|
1232
|
+
if (first) {
|
|
1233
|
+
e.preventDefault();
|
|
1234
|
+
first.focus();
|
|
1235
|
+
}
|
|
1236
|
+
} else if (e.key === "Enter") {
|
|
1237
|
+
const first = visibleItems()[0];
|
|
1238
|
+
if (first) {
|
|
1239
|
+
e.preventDefault();
|
|
1240
|
+
first.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
});
|
|
1244
|
+
palette.addEventListener("keydown", (e) => {
|
|
1245
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
1246
|
+
const all = [...palette.querySelectorAll(".pal-head, .pal-item")].filter((b) => !b.hidden && !b.parentElement?.closest("[hidden]") && (b.classList.contains("pal-head") || !b.closest(".pal-body[hidden]")));
|
|
1247
|
+
const i = all.indexOf(document.activeElement);
|
|
1248
|
+
if (i < 0) return;
|
|
1249
|
+
e.preventDefault();
|
|
1250
|
+
if (e.key === "ArrowUp" && i === 0) search.focus();
|
|
1251
|
+
else all[Math.min(all.length - 1, Math.max(0, i + (e.key === "ArrowDown" ? 1 : -1)))].focus();
|
|
1252
|
+
});
|
|
1253
|
+
palGrip.addEventListener("pointerdown", (e) => {
|
|
1254
|
+
if (e.button !== 0) return;
|
|
1255
|
+
try {
|
|
1256
|
+
palGrip.setPointerCapture(e.pointerId);
|
|
1257
|
+
} catch {
|
|
1258
|
+
}
|
|
1259
|
+
const x0 = e.clientX, w0 = palHome.getBoundingClientRect().width;
|
|
1260
|
+
const mv = (ev) => setDockW(w0 + ev.clientX - x0, false);
|
|
1261
|
+
const up2 = (ev) => {
|
|
1262
|
+
palGrip.removeEventListener("pointermove", mv);
|
|
1263
|
+
palGrip.removeEventListener("pointerup", up2);
|
|
1264
|
+
setDockW(w0 + ev.clientX - x0);
|
|
1265
|
+
};
|
|
1266
|
+
palGrip.addEventListener("pointermove", mv);
|
|
1267
|
+
palGrip.addEventListener("pointerup", up2);
|
|
1268
|
+
});
|
|
1269
|
+
palGrip.addEventListener("keydown", (e) => {
|
|
1270
|
+
const d = e.key === "ArrowLeft" ? -16 : e.key === "ArrowRight" ? 16 : 0;
|
|
1271
|
+
if (d) {
|
|
1272
|
+
e.preventDefault();
|
|
1273
|
+
setDockW(palHome.getBoundingClientRect().width + d);
|
|
1274
|
+
}
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
const usedSection = (item) => {
|
|
1278
|
+
if (item.section === void 0 || item.section === lastSection) return;
|
|
1279
|
+
lastSection = item.section;
|
|
1280
|
+
try {
|
|
1281
|
+
opts.store?.set(PAL_KEY, JSON.stringify({ last: lastSection }));
|
|
1282
|
+
} catch {
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
ui.palette.forEach((item, idx) => {
|
|
1286
|
+
const { kind: sec, icon: ic, label } = item;
|
|
1287
|
+
const b = h("button", { type: "button", class: "pal-item", "data-section": sec, "data-entry": String(idx), title: `Add ${label.toLowerCase()} (click), or drag it where it goes` }, icon(ic), h("span", { class: "pal-label" }, label));
|
|
936
1288
|
b.addEventListener("pointerdown", (e) => {
|
|
937
1289
|
if (e.button !== 0) return;
|
|
938
1290
|
e.preventDefault();
|
|
@@ -944,7 +1296,7 @@ function canvasView(host, doc, opts) {
|
|
|
944
1296
|
let ghost;
|
|
945
1297
|
const over = (ev) => {
|
|
946
1298
|
const r = stage.getBoundingClientRect();
|
|
947
|
-
return ev.clientX >= r.left && ev.clientX <= r.right && ev.clientY >= r.top && ev.clientY <= r.bottom && !
|
|
1299
|
+
return ev.clientX >= r.left && ev.clientX <= r.right && ev.clientY >= r.top && ev.clientY <= r.bottom && !palHome.contains(document.elementFromPoint(ev.clientX, ev.clientY));
|
|
948
1300
|
};
|
|
949
1301
|
const mv = (ev) => {
|
|
950
1302
|
if (!ghost && Math.hypot(ev.clientX - x0, ev.clientY - y0) < 4) return;
|
|
@@ -965,8 +1317,13 @@ function canvasView(host, doc, opts) {
|
|
|
965
1317
|
const dragged = !!ghost;
|
|
966
1318
|
ghost?.remove();
|
|
967
1319
|
if (!drop) return;
|
|
968
|
-
if (!dragged)
|
|
969
|
-
|
|
1320
|
+
if (!dragged) {
|
|
1321
|
+
usedSection(item);
|
|
1322
|
+
addFromPalette(sec, void 0, item);
|
|
1323
|
+
} else if (over(ev)) {
|
|
1324
|
+
usedSection(item);
|
|
1325
|
+
addFromPalette(sec, { x: ev.clientX, y: ev.clientY }, item);
|
|
1326
|
+
}
|
|
970
1327
|
};
|
|
971
1328
|
const upH = (ev) => done(ev, true), cancelH = (ev) => done(ev, false);
|
|
972
1329
|
const esc = (ev) => {
|
|
@@ -984,12 +1341,14 @@ function canvasView(host, doc, opts) {
|
|
|
984
1341
|
b.addEventListener("keydown", (e) => {
|
|
985
1342
|
if (e.key === "Enter" || e.key === " ") {
|
|
986
1343
|
e.preventDefault();
|
|
987
|
-
|
|
1344
|
+
usedSection(item);
|
|
1345
|
+
addFromPalette(sec, void 0, item);
|
|
988
1346
|
}
|
|
989
1347
|
});
|
|
990
|
-
palette.append(b);
|
|
991
|
-
}
|
|
992
|
-
host.
|
|
1348
|
+
(item.section === void 0 ? palette : sectionBody(item.section)).append(b);
|
|
1349
|
+
});
|
|
1350
|
+
if (docked) host.prepend(palHome, palGrip);
|
|
1351
|
+
else host.append(palette);
|
|
993
1352
|
function resetLayout() {
|
|
994
1353
|
const key2 = K.pins.keyOf(doc.goodDoc.data);
|
|
995
1354
|
const x = doc.goodDoc.data?.[key2];
|
|
@@ -1045,6 +1404,12 @@ function canvasView(host, doc, opts) {
|
|
|
1045
1404
|
else return;
|
|
1046
1405
|
break;
|
|
1047
1406
|
case "Escape":
|
|
1407
|
+
if (linking) {
|
|
1408
|
+
linking = void 0;
|
|
1409
|
+
paintOverlay();
|
|
1410
|
+
opts.note("Not connected");
|
|
1411
|
+
break;
|
|
1412
|
+
}
|
|
1048
1413
|
if (pinDrag()) {
|
|
1049
1414
|
endPin(false);
|
|
1050
1415
|
break;
|
|
@@ -1081,7 +1446,7 @@ function canvasView(host, doc, opts) {
|
|
|
1081
1446
|
if (e.key === "F10" && !e.shiftKey) return;
|
|
1082
1447
|
{
|
|
1083
1448
|
const b = unionBox(sel);
|
|
1084
|
-
const r =
|
|
1449
|
+
const r = viewEl.getBoundingClientRect();
|
|
1085
1450
|
const k = scale();
|
|
1086
1451
|
openMenu(menuItems(sel.length ? toPointer(sel[0]) : void 0), b ? { x: r.left + (b.x + b.w - V.view.x) * k, y: r.top + (b.y - V.view.y) * k } : { x: r.left + 40, y: r.top + 40 }, "Canvas");
|
|
1087
1452
|
}
|
|
@@ -1095,6 +1460,10 @@ function canvasView(host, doc, opts) {
|
|
|
1095
1460
|
doc.select(drawn.map(fromPointer), "canvas");
|
|
1096
1461
|
break;
|
|
1097
1462
|
}
|
|
1463
|
+
if (mod && e.key.toLowerCase() === "g" && K.group && sel.length && !ro) {
|
|
1464
|
+
groupSelection();
|
|
1465
|
+
break;
|
|
1466
|
+
}
|
|
1098
1467
|
return;
|
|
1099
1468
|
}
|
|
1100
1469
|
e.preventDefault();
|
|
@@ -1139,6 +1508,12 @@ function canvasView(host, doc, opts) {
|
|
|
1139
1508
|
const base = {
|
|
1140
1509
|
addFromPalette,
|
|
1141
1510
|
palette,
|
|
1511
|
+
groupSelection,
|
|
1512
|
+
startPick,
|
|
1513
|
+
objectsUnder,
|
|
1514
|
+
get linking() {
|
|
1515
|
+
return linking;
|
|
1516
|
+
},
|
|
1142
1517
|
render,
|
|
1143
1518
|
setTheme,
|
|
1144
1519
|
paintOverlay,
|
|
@@ -1192,7 +1567,7 @@ function canvasView(host, doc, opts) {
|
|
|
1192
1567
|
boxFor,
|
|
1193
1568
|
pageXYOf: (p) => {
|
|
1194
1569
|
const b = boxFor(p);
|
|
1195
|
-
const r =
|
|
1570
|
+
const r = viewEl.getBoundingClientRect();
|
|
1196
1571
|
const k = scale();
|
|
1197
1572
|
return b && V.view ? { x: r.left + (b.x + b.w / 2 - V.view.x) * k, y: r.top + (b.y + b.h / 2 - V.view.y) * k } : void 0;
|
|
1198
1573
|
}
|
|
@@ -2,6 +2,7 @@ const PLAIN_ICON_SVG = {
|
|
|
2
2
|
"arrow-up-right": '<path d="M7 7h10v10" /> <path d="M7 17 17 7" />',
|
|
3
3
|
"box": '<path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z" /> <path d="m3.3 7 8.7 5 8.7-5" /> <path d="M12 22V12" />',
|
|
4
4
|
"chevron-down": '<path d="m6 9 6 6 6-6" />',
|
|
5
|
+
"chevron-left": '<path d="m15 18-6-6 6-6" />',
|
|
5
6
|
"chevron-right": '<path d="m9 18 6-6-6-6" />',
|
|
6
7
|
"circle-dot": '<circle cx="12" cy="12" r="1" /> <circle cx="12" cy="12" r="10" />',
|
|
7
8
|
"circle-x": '<circle cx="12" cy="12" r="10" /> <path d="m15 9-6 6" /> <path d="m9 9 6 6" />',
|
|
@@ -17,6 +18,7 @@ const PLAIN_ICON_SVG = {
|
|
|
17
18
|
"pencil": '<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /> <path d="m15 5 4 4" />',
|
|
18
19
|
"plus": '<path d="M5 12h14" /> <path d="M12 5v14" />',
|
|
19
20
|
"rotate-ccw": '<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /> <path d="M3 3v5h5" />',
|
|
21
|
+
"search": '<path d="m21 21-4.34-4.34" /> <circle cx="11" cy="11" r="8" />',
|
|
20
22
|
"trash-2": '<path d="M10 11v6" /> <path d="M14 11v6" /> <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /> <path d="M3 6h18" /> <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',
|
|
21
23
|
"triangle-alert": '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /> <path d="M12 9v4" /> <path d="M12 17h.01" />',
|
|
22
24
|
"x": '<path d="M18 6 6 18" /> <path d="m6 6 12 12" />'
|
|
@@ -76,7 +76,8 @@ function setupFor(a, v, textPane) {
|
|
|
76
76
|
rootClass: "iso-canvas",
|
|
77
77
|
panKeyClass: "pan-key",
|
|
78
78
|
newOrder: a.kinds.map((k) => k.kind),
|
|
79
|
-
palette: a.kinds.map((k) => ({ kind: k.kind, icon: icon(k.kind), label: k.singular[0].toUpperCase() + k.singular.slice(1) })),
|
|
79
|
+
palette: v.palette ? v.palette.map((e) => ({ kind: e.kind, label: e.label, icon: e.icon ?? icon(e.kind), name: e.name, ...e.section === void 0 ? {} : { section: e.section }, ...e.value === void 0 ? {} : { value: () => structuredClone(e.value) } })) : a.kinds.map((k) => ({ kind: k.kind, icon: icon(k.kind), label: k.singular[0].toUpperCase() + k.singular.slice(1) })),
|
|
80
|
+
...v.paletteLayout === void 0 ? {} : { paletteLayout: v.paletteLayout },
|
|
80
81
|
text: {
|
|
81
82
|
stage: "The file, drawn: arrow keys and Tab move through what is drawn; + and \u2212 zoom, 0 fits",
|
|
82
83
|
dragGroup: "A drag on nothing",
|
|
@@ -99,6 +100,9 @@ function setupFor(a, v, textPane) {
|
|
|
99
100
|
pins,
|
|
100
101
|
ui: canvasUi,
|
|
101
102
|
flat: v.flat,
|
|
103
|
+
...a.connect ? { connect: (f, t, d) => a.connect(f, t, d) } : {},
|
|
104
|
+
...a.group ? { group: (m, d) => a.group(m, d) } : {},
|
|
105
|
+
...a.dropInto ? { dropOnto: (t, v2, k, d) => a.dropInto(t, v2, k, d) } : {},
|
|
102
106
|
trial: (text, theme) => {
|
|
103
107
|
const r = read(text);
|
|
104
108
|
return r.read === void 0 || r.diags.some((d) => d.severity === "error") ? void 0 : v.draw(r.read, r.read.data, theme);
|
|
@@ -119,7 +123,8 @@ function setupFor(a, v, textPane) {
|
|
|
119
123
|
return void 0;
|
|
120
124
|
},
|
|
121
125
|
extraLabel: () => ({ text: "", cls: "" }),
|
|
122
|
-
|
|
126
|
+
// (0.10.0) the plain keymap says ⌘G where the domain groups
|
|
127
|
+
keymap: v.keymap ?? (a.group ? PLAIN_KEYMAP.map((g) => g.where === "The tree and the canvas" ? { ...g, keys: [...g.keys, ["\u2318G", "Group the selection"]] } : g) : PLAIN_KEYMAP)
|
|
123
128
|
};
|
|
124
129
|
const features = {
|
|
125
130
|
canvas: { canvasView: (host, doc, o) => canvasView(host, doc, { ...o, theme: v.theme, kit: canvas, layer: v.layer }) },
|
package/js/iso-objects/board.js
CHANGED
|
@@ -5,7 +5,8 @@ import { placeBoard } from "./flat.js";
|
|
|
5
5
|
function boardOf(scene, visible = () => true) {
|
|
6
6
|
const items = scene.layout.items.filter((p) => visible(p.id));
|
|
7
7
|
const cat = scene.layout.catalog;
|
|
8
|
-
const
|
|
8
|
+
const bare = !scene.layout.items.some((p) => p.type === "node");
|
|
9
|
+
const isCard = (p) => bare ? !p.children.some((c) => visible(c.id)) : p.type === "node" && !p.children.some((c) => c.type === "node" && visible(c.id));
|
|
9
10
|
const cardsP = items.filter(isCard);
|
|
10
11
|
const line = (p) => {
|
|
11
12
|
const a = [];
|
|
@@ -57,6 +58,10 @@ function boardOf(scene, visible = () => true) {
|
|
|
57
58
|
} else taken.set(String(c), p.id);
|
|
58
59
|
}
|
|
59
60
|
const cards = cardsP.map((p) => {
|
|
61
|
+
if (p.region) {
|
|
62
|
+
const r = p.region;
|
|
63
|
+
return { id: p.id, label: r.label ?? p.id, sub: void 0, role: r.role ?? regionKind(cat, r.kind)?.role ?? "grey", ghost: r.ghost || void 0, cell: cell.get(p.id) };
|
|
64
|
+
}
|
|
60
65
|
const n = p.node, a = nodeKindOr(cat, n.asset);
|
|
61
66
|
return { id: p.id, label: n.label ?? p.id, sub: n.sub, role: n.role ?? a.role, ghost: n.ghost || void 0, cell: cell.get(p.id) };
|
|
62
67
|
});
|
package/js/iso-objects/scene.js
CHANGED
|
@@ -160,8 +160,9 @@ function drawFlatRegion(k, cat, r, vis, gridStep = 1) {
|
|
|
160
160
|
const style = R["label-style"] ?? rk?.labelStyle;
|
|
161
161
|
if (R.label && style !== "none") {
|
|
162
162
|
if (style === "face") {
|
|
163
|
-
const
|
|
164
|
-
const
|
|
163
|
+
const h = b.z1 - b.z0, cap = (f) => f.size * 0.73 / S, thin = shape === "slab" && 0.28 + cap(FONTS.slabname) + 0.08 > h;
|
|
164
|
+
const big = shape === "slab" && !thin;
|
|
165
|
+
const z = big ? b.z0 + 0.28 : thin ? b.z0 + Math.max(0.02, (h - cap(FONTS.sm)) / 2) : b.z0 + Math.min(0.1, h * 0.25);
|
|
165
166
|
s += tag("g", attrs, k.faceText(b.x0 + (big ? 0.6 : 0.3), b.y1, z, R.label, big ? "slabname" : "slabname sm", big ? FONTS.slabname : FONTS.sm, "left", "start"));
|
|
166
167
|
} else if (style === "face-right") {
|
|
167
168
|
s += tag("g", attrs, k.faceText(b.x1, b.y0 + 0.6, b.z0 + Math.max(0.14, (b.z1 - b.z0) * 0.2), R.label, "slabname", FONTS.slabname, "right", "end"));
|