@floegence/floe-webapp-core 0.55.2 → 0.56.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/components/ui/SurfaceAnchoredLayer.d.ts +8 -0
- package/dist/components/ui/SurfaceAnchoredLayer.js +64 -52
- package/dist/components/workbench/WorkbenchCanvas.d.ts +1 -1
- package/dist/components/workbench/WorkbenchCanvas.js +139 -133
- package/dist/components/workbench/WorkbenchCanvasField.d.ts +1 -1
- package/dist/components/workbench/WorkbenchCanvasField.js +82 -76
- package/dist/components/workbench/WorkbenchCompositionToolbar.d.ts +22 -0
- package/dist/components/workbench/WorkbenchCompositionToolbar.js +261 -0
- package/dist/components/workbench/WorkbenchLayerObjects.d.ts +3 -1
- package/dist/components/workbench/WorkbenchLayerObjects.js +1020 -854
- package/dist/components/workbench/WorkbenchSurface.js +439 -437
- package/dist/components/workbench/types.d.ts +3 -1
- package/dist/components/workbench/useWorkbenchModel.d.ts +16 -1
- package/dist/components/workbench/useWorkbenchModel.js +302 -282
- package/dist/components/workbench/workbenchCompositionMessages.d.ts +37 -4
- package/dist/components/workbench/workbenchCompositionMessages.js +42 -12
- package/dist/components/workbench/workbenchHelpers.js +25 -21
- package/dist/components/workbench/workbenchInteractionAdapter.js +39 -39
- package/dist/components/workbench/workbenchOptions.d.ts +35 -5
- package/dist/components/workbench/workbenchOptions.js +29 -13
- package/dist/styles.css +1 -1
- package/dist/workbench-composition.css +911 -0
- package/dist/workbench.css +18 -536
- package/package.json +1 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { createSignal as
|
|
1
|
+
import { createSignal as it, createMemo as u, createEffect as Ae, onCleanup as Le, batch as R } from "solid-js";
|
|
2
2
|
import { clientToCanvasWorld as Ie } from "../ui/canvasGeometry.js";
|
|
3
|
-
import { ArrowUp as
|
|
4
|
-
import { WORKBENCH_STICKY_FILTER_ID as
|
|
5
|
-
import { WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as Me, WORKBENCH_DEFAULT_TEXT_COLOR as
|
|
6
|
-
import { resolveWorkbenchModeStrategy as
|
|
7
|
-
import { resolveWorkbenchWidgetDefinitions as
|
|
8
|
-
import { resolveTextAnnotationDefaultSize as
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
return o[(
|
|
3
|
+
import { ArrowUp as St, Copy as p, Trash as B, MessageSquare as Wt, Region as Ot, TextTool as De } from "../icons/index.js";
|
|
4
|
+
import { WORKBENCH_STICKY_FILTER_ID as je } from "./types.js";
|
|
5
|
+
import { WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as Me, WORKBENCH_DEFAULT_TEXT_COLOR as Fe, WORKBENCH_DEFAULT_TEXT_FONT as Tt, WORKBENCH_BACKGROUND_MATERIALS as Mt, WORKBENCH_REGION_FILL_OPTIONS as Re, WORKBENCH_STICKY_NOTE_COLORS as pe, WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as Be, WORKBENCH_DEFAULT_REGION_FILL as Xe } from "./workbenchOptions.js";
|
|
6
|
+
import { resolveWorkbenchModeStrategy as Ct, compareWorkbenchLayerRenderOrder as Nt, createContextMenuPosition as ze, resolveWorkbenchLayerFront as At, createWorkbenchWidgetFrame as Ee, createWorkbenchId as x, createWorkbenchViewportCenteredOnWidget as Lt, findNearestWidget as Ye, sanitizeFilters as He, WORKBENCH_CONTEXT_MENU_WIDTH_PX as Ve, estimateContextMenuHeight as Ke, clampScale as ve, WORKBENCH_MAX_SCALE as Ue, WORKBENCH_CANVAS_ZOOM_STEP as It, normalizeWorkbenchInteractionMode as Pe, createWorkbenchViewportAtScale as qe, WORKBENCH_WORK_MIN_SCALE as Ze, createWorkbenchViewportFitForWidget as Ge } from "./workbenchHelpers.js";
|
|
7
|
+
import { resolveWorkbenchWidgetDefinitions as $e, getWidgetEntry as Je } from "./widgets/widgetRegistry.js";
|
|
8
|
+
import { resolveTextAnnotationDefaultSize as Qe, resolveBackgroundLayerDefaultSize as tn, resolveStickyNoteDefaultSize as en } from "./workbenchPlacement.js";
|
|
9
|
+
function Ft(o, d) {
|
|
10
|
+
const s = o.findIndex((a) => a === d);
|
|
11
|
+
return o[(s + 1) % o.length] ?? o[0];
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function Dt(o, d, s) {
|
|
14
14
|
const a = String(d ?? "").trim();
|
|
15
|
-
return o.includes(a) ? a :
|
|
15
|
+
return o.includes(a) ? a : s;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
return Number.isFinite(
|
|
20
|
-
}
|
|
21
|
-
function nn(o) {
|
|
22
|
-
return jt(Re, o);
|
|
17
|
+
function nn(o, d) {
|
|
18
|
+
const s = Number(o);
|
|
19
|
+
return Number.isFinite(s) ? Math.max(0.08, Math.min(1, s)) : d;
|
|
23
20
|
}
|
|
24
21
|
function on(o) {
|
|
25
|
-
return
|
|
22
|
+
return Ft(pe, o);
|
|
23
|
+
}
|
|
24
|
+
function cn(o) {
|
|
25
|
+
return Ft(Mt, o);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function jt(o) {
|
|
28
28
|
return !("kind" in o);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return o.reduce((d,
|
|
30
|
+
function ot(o) {
|
|
31
|
+
return o.reduce((d, s) => Math.max(d, s.z_index), 1);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function dn(o, d) {
|
|
34
|
+
return ot([...o, ...d]);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function an(o) {
|
|
37
37
|
return {
|
|
38
38
|
id: o.id,
|
|
39
39
|
type: "sticky_note",
|
|
@@ -46,47 +46,48 @@ function dn(o) {
|
|
|
46
46
|
created_at_unix_ms: o.created_at_unix_ms
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
const a = Date.now(), { width: y, height: _ } =
|
|
49
|
+
function sn(o, d, s) {
|
|
50
|
+
const a = Date.now(), { width: y, height: _ } = en();
|
|
51
51
|
return {
|
|
52
|
-
id:
|
|
52
|
+
id: x(),
|
|
53
53
|
kind: "sticky_note",
|
|
54
|
-
|
|
54
|
+
title: "",
|
|
55
|
+
body: "",
|
|
55
56
|
color: Me,
|
|
56
57
|
x: o - y / 2,
|
|
57
58
|
y: d - _ / 2,
|
|
58
59
|
width: y,
|
|
59
60
|
height: _,
|
|
60
|
-
z_index:
|
|
61
|
+
z_index: s,
|
|
61
62
|
created_at_unix_ms: a,
|
|
62
63
|
updated_at_unix_ms: a
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
|
-
function rn(o, d,
|
|
66
|
-
const y = Date.now(), { width: _, height: b } =
|
|
66
|
+
function rn(o, d, s, a) {
|
|
67
|
+
const y = Date.now(), { width: _, height: b } = Qe(a);
|
|
67
68
|
return {
|
|
68
|
-
id:
|
|
69
|
+
id: x(),
|
|
69
70
|
kind: "text",
|
|
70
71
|
text: "Label this area",
|
|
71
|
-
font_family: a?.font_family ??
|
|
72
|
+
font_family: a?.font_family ?? Tt.fontFamily,
|
|
72
73
|
font_size: a?.font_size ?? 30,
|
|
73
|
-
font_weight: a?.font_weight ??
|
|
74
|
-
color: a?.color ??
|
|
74
|
+
font_weight: a?.font_weight ?? Tt.fontWeight,
|
|
75
|
+
color: a?.color ?? Fe,
|
|
75
76
|
align: a?.align ?? "left",
|
|
76
77
|
x: o - _ / 2,
|
|
77
78
|
y: d - b / 2,
|
|
78
79
|
width: _,
|
|
79
80
|
height: b,
|
|
80
|
-
z_index:
|
|
81
|
+
z_index: s,
|
|
81
82
|
created_at_unix_ms: y,
|
|
82
83
|
updated_at_unix_ms: y
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function ln(o) {
|
|
86
87
|
const d = Date.now();
|
|
87
88
|
return {
|
|
88
89
|
...o,
|
|
89
|
-
id:
|
|
90
|
+
id: x(),
|
|
90
91
|
x: o.x + 28,
|
|
91
92
|
y: o.y + 28,
|
|
92
93
|
z_index: o.z_index + 1,
|
|
@@ -94,36 +95,36 @@ function sn(o) {
|
|
|
94
95
|
updated_at_unix_ms: d
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
|
-
function
|
|
98
|
-
const y = Date.now(), { width: _, height: b } =
|
|
98
|
+
function un(o, d, s, a) {
|
|
99
|
+
const y = Date.now(), { width: _, height: b } = tn(a), f = String(a?.name ?? "").trim();
|
|
99
100
|
return {
|
|
100
|
-
id:
|
|
101
|
+
id: x(),
|
|
101
102
|
name: f,
|
|
102
|
-
fill:
|
|
103
|
-
|
|
103
|
+
fill: Dt(
|
|
104
|
+
Re,
|
|
104
105
|
a?.fill,
|
|
105
|
-
|
|
106
|
+
Xe
|
|
106
107
|
),
|
|
107
|
-
opacity:
|
|
108
|
-
material:
|
|
108
|
+
opacity: nn(a?.opacity, 1),
|
|
109
|
+
material: Dt(
|
|
109
110
|
Mt,
|
|
110
111
|
a?.material,
|
|
111
|
-
|
|
112
|
+
Be
|
|
112
113
|
),
|
|
113
114
|
x: o - _ / 2,
|
|
114
115
|
y: d - b / 2,
|
|
115
116
|
width: _,
|
|
116
117
|
height: b,
|
|
117
|
-
z_index:
|
|
118
|
+
z_index: s,
|
|
118
119
|
created_at_unix_ms: y,
|
|
119
120
|
updated_at_unix_ms: y
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
+
function gn(o) {
|
|
123
124
|
const d = Date.now();
|
|
124
125
|
return {
|
|
125
126
|
...o,
|
|
126
|
-
id:
|
|
127
|
+
id: x(),
|
|
127
128
|
name: o.name,
|
|
128
129
|
x: o.x + 36,
|
|
129
130
|
y: o.y + 36,
|
|
@@ -132,43 +133,43 @@ function un(o) {
|
|
|
132
133
|
updated_at_unix_ms: d
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
-
const [d,
|
|
136
|
+
function An(o) {
|
|
137
|
+
const [d, s] = it(null), [a, y] = it(null), [_, b] = it({ width: 0, height: 0 });
|
|
137
138
|
let f = null, C = null;
|
|
138
|
-
const
|
|
139
|
-
() =>
|
|
140
|
-
), N = u(() =>
|
|
141
|
-
|
|
139
|
+
const r = o.state, w = u(() => r().widgets), S = u(() => r().stickyNotes ?? []), ct = u(() => r().annotations ?? []), dt = u(() => r().backgroundLayers ?? []), m = u(() => r().viewport), Rt = u(() => r().locked), X = u(() => r().filters), pt = u(() => r().selectedWidgetId), z = u(
|
|
140
|
+
() => r().selectedObject ?? (r().selectedWidgetId ? { kind: "widget", id: r().selectedWidgetId } : null)
|
|
141
|
+
), N = u(() => r().mode ?? "work"), E = u(() => Ct(N())), at = u(() => r().activeTool ?? "select"), Bt = u(() => r().theme), A = u(() => dn(w(), S())), Xt = u(() => [...w(), ...S()].sort(Nt).at(-1)?.id ?? null), zt = u(() => `${Math.round(m().scale * 100)}%`);
|
|
142
|
+
Ae(() => {
|
|
142
143
|
const e = a();
|
|
143
144
|
e && e !== Xt() && y(null);
|
|
144
145
|
});
|
|
145
146
|
const O = (e) => {
|
|
146
147
|
y(e);
|
|
147
|
-
},
|
|
148
|
-
() =>
|
|
149
|
-
),
|
|
148
|
+
}, Et = () => typeof o.widgetDefinitions == "function" ? o.widgetDefinitions() : o.widgetDefinitions, Yt = () => typeof o.textAnnotationDefaults == "function" ? o.textAnnotationDefaults() : o.textAnnotationDefaults, Ht = () => typeof o.backgroundLayerDefaults == "function" ? o.backgroundLayerDefaults() : o.backgroundLayerDefaults, L = u(
|
|
149
|
+
() => $e(Et())
|
|
150
|
+
), Y = (e, t) => {
|
|
150
151
|
const n = Number.isFinite(e) && e > 0 ? e : 0, i = Number.isFinite(t) && t > 0 ? t : 0, c = { width: n, height: i }, g = _();
|
|
151
152
|
return g.width === n && g.height === i ? g : (b(c), c);
|
|
152
|
-
},
|
|
153
|
+
}, st = () => {
|
|
153
154
|
C?.disconnect(), C = null;
|
|
154
|
-
}, h = () => f ?
|
|
155
|
+
}, h = () => f ? Y(f.clientWidth, f.clientHeight) : Y(0, 0), Vt = (e) => {
|
|
155
156
|
if (f === (e ?? null)) {
|
|
156
157
|
h();
|
|
157
158
|
return;
|
|
158
159
|
}
|
|
159
|
-
|
|
160
|
+
st(), f = e ?? null, h(), !(!f || typeof ResizeObserver > "u") && (C = new ResizeObserver((t) => {
|
|
160
161
|
const n = t[0];
|
|
161
|
-
|
|
162
|
+
Y(
|
|
162
163
|
n?.contentRect.width ?? f?.clientWidth ?? 0,
|
|
163
164
|
n?.contentRect.height ?? f?.clientHeight ?? 0
|
|
164
165
|
);
|
|
165
166
|
}), C.observe(f));
|
|
166
167
|
};
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
Le(() => {
|
|
169
|
+
st(), f = null;
|
|
169
170
|
});
|
|
170
171
|
const Kt = (e) => {
|
|
171
|
-
|
|
172
|
+
s({
|
|
172
173
|
clientX: e.clientX,
|
|
173
174
|
clientY: e.clientY,
|
|
174
175
|
worldX: e.worldX,
|
|
@@ -176,7 +177,7 @@ function Nn(o) {
|
|
|
176
177
|
target: { kind: "canvas", mode: N() }
|
|
177
178
|
});
|
|
178
179
|
}, vt = (e, t) => {
|
|
179
|
-
|
|
180
|
+
W(t.id), s({
|
|
180
181
|
clientX: e.clientX,
|
|
181
182
|
clientY: e.clientY,
|
|
182
183
|
worldX: t.x,
|
|
@@ -185,7 +186,7 @@ function Nn(o) {
|
|
|
185
186
|
widgetId: t.id
|
|
186
187
|
});
|
|
187
188
|
}, Ut = (e, t) => {
|
|
188
|
-
|
|
189
|
+
j(t.id), s({
|
|
189
190
|
clientX: e.clientX,
|
|
190
191
|
clientY: e.clientY,
|
|
191
192
|
worldX: t.x,
|
|
@@ -194,7 +195,7 @@ function Nn(o) {
|
|
|
194
195
|
widgetId: t.id
|
|
195
196
|
});
|
|
196
197
|
}, Pt = (e, t) => {
|
|
197
|
-
|
|
198
|
+
s({
|
|
198
199
|
clientX: e.clientX,
|
|
199
200
|
clientY: e.clientY,
|
|
200
201
|
worldX: t.x,
|
|
@@ -202,16 +203,16 @@ function Nn(o) {
|
|
|
202
203
|
target: { kind: "annotation", id: t.id }
|
|
203
204
|
});
|
|
204
205
|
}, qt = (e, t) => {
|
|
205
|
-
|
|
206
|
+
s({
|
|
206
207
|
clientX: e.clientX,
|
|
207
208
|
clientY: e.clientY,
|
|
208
209
|
worldX: t.x,
|
|
209
210
|
worldY: t.y,
|
|
210
211
|
target: { kind: "background_layer", id: t.id }
|
|
211
212
|
});
|
|
212
|
-
}, l = () =>
|
|
213
|
+
}, l = () => s(null), Zt = (e) => r().widgets.find((t) => t.id === e) ?? null, I = (e) => r().widgets.find((t) => t.type === e) ?? null, H = (e) => r().stickyNotes?.find((t) => t.id === e) ?? null, rt = (e) => r().annotations?.find((t) => t.id === e) ?? null, lt = (e) => r().backgroundLayers?.find((t) => t.id === e) ?? null, Gt = (e) => e.target ? e.target : e.widgetId ? H(e.widgetId) ? { kind: "sticky_note", id: e.widgetId } : { kind: "widget", id: e.widgetId } : { kind: "canvas", mode: N() }, D = (e, t) => {
|
|
213
214
|
if (t?.source === "pointer") {
|
|
214
|
-
const n = f?.getBoundingClientRect(), i = n ? Ie(n,
|
|
215
|
+
const n = f?.getBoundingClientRect(), i = n ? Ie(n, m(), {
|
|
215
216
|
clientX: t.clientX,
|
|
216
217
|
clientY: t.clientY
|
|
217
218
|
}) : null;
|
|
@@ -243,58 +244,58 @@ function Nn(o) {
|
|
|
243
244
|
label: `Add ${e.label}`,
|
|
244
245
|
icon: e.icon,
|
|
245
246
|
onSelect: (i) => {
|
|
246
|
-
const c =
|
|
247
|
-
|
|
247
|
+
const c = D(t, i);
|
|
248
|
+
K(e.type, c.worldX, c.worldY), l();
|
|
248
249
|
}
|
|
249
250
|
};
|
|
250
|
-
},
|
|
251
|
+
}, ut = u(() => {
|
|
251
252
|
const e = d();
|
|
252
253
|
if (!e) return [];
|
|
253
254
|
const t = Gt(e);
|
|
254
255
|
if (t.kind === "widget") {
|
|
255
|
-
const n =
|
|
256
|
+
const n = w().find((c) => c.id === t.id), i = [];
|
|
256
257
|
return n && (i.push({
|
|
257
258
|
id: "bring-to-front",
|
|
258
259
|
kind: "action",
|
|
259
260
|
label: "Bring to Front",
|
|
260
|
-
icon:
|
|
261
|
+
icon: St,
|
|
261
262
|
onSelect: () => {
|
|
262
|
-
|
|
263
|
+
W(n.id), l();
|
|
263
264
|
}
|
|
264
265
|
}), i.push({
|
|
265
266
|
id: "duplicate",
|
|
266
267
|
kind: "action",
|
|
267
268
|
label: "Duplicate",
|
|
268
|
-
icon:
|
|
269
|
+
icon: p,
|
|
269
270
|
onSelect: () => {
|
|
270
|
-
|
|
271
|
+
gt(n.type, n.x + 32, n.y + 32), l();
|
|
271
272
|
}
|
|
272
273
|
})), i.push({ id: "separator-delete", kind: "separator" }), i.push({
|
|
273
274
|
id: "delete",
|
|
274
275
|
kind: "action",
|
|
275
276
|
label: "Delete",
|
|
276
|
-
icon:
|
|
277
|
+
icon: B,
|
|
277
278
|
destructive: !0,
|
|
278
279
|
onSelect: () => {
|
|
279
|
-
|
|
280
|
+
v(t.id), l();
|
|
280
281
|
}
|
|
281
282
|
}), i;
|
|
282
283
|
}
|
|
283
284
|
if (t.kind === "sticky_note") {
|
|
284
|
-
const n =
|
|
285
|
+
const n = H(t.id), i = [];
|
|
285
286
|
return n && (i.push({
|
|
286
287
|
id: "bring-to-front",
|
|
287
288
|
kind: "action",
|
|
288
289
|
label: "Bring to Front",
|
|
289
|
-
icon:
|
|
290
|
+
icon: St,
|
|
290
291
|
onSelect: () => {
|
|
291
|
-
|
|
292
|
+
j(n.id), l();
|
|
292
293
|
}
|
|
293
294
|
}), i.push({
|
|
294
295
|
id: "copy-content",
|
|
295
296
|
kind: "action",
|
|
296
297
|
label: "Copy Content",
|
|
297
|
-
icon:
|
|
298
|
+
icon: p,
|
|
298
299
|
onSelect: () => {
|
|
299
300
|
typeof navigator < "u" && navigator.clipboard?.writeText(n.body), l();
|
|
300
301
|
}
|
|
@@ -302,18 +303,18 @@ function Nn(o) {
|
|
|
302
303
|
id: "change-color",
|
|
303
304
|
kind: "action",
|
|
304
305
|
label: "Change Color",
|
|
305
|
-
icon:
|
|
306
|
+
icon: Wt,
|
|
306
307
|
onSelect: () => {
|
|
307
|
-
|
|
308
|
+
yt(n.id, { color: on(n.color) }), l();
|
|
308
309
|
}
|
|
309
310
|
})), i.push({ id: "separator-delete", kind: "separator" }), i.push({
|
|
310
311
|
id: "delete",
|
|
311
312
|
kind: "action",
|
|
312
313
|
label: "Delete",
|
|
313
|
-
icon:
|
|
314
|
+
icon: B,
|
|
314
315
|
destructive: !0,
|
|
315
316
|
onSelect: () => {
|
|
316
|
-
|
|
317
|
+
Z(t.id), l();
|
|
317
318
|
}
|
|
318
319
|
}), i;
|
|
319
320
|
}
|
|
@@ -323,47 +324,47 @@ function Nn(o) {
|
|
|
323
324
|
id: "duplicate",
|
|
324
325
|
kind: "action",
|
|
325
326
|
label: "Duplicate Text",
|
|
326
|
-
icon:
|
|
327
|
+
icon: p,
|
|
327
328
|
onSelect: () => {
|
|
328
|
-
|
|
329
|
+
kt(n), l();
|
|
329
330
|
}
|
|
330
331
|
}), i.push({ id: "separator-delete", kind: "separator" }), i.push({
|
|
331
332
|
id: "delete",
|
|
332
333
|
kind: "action",
|
|
333
334
|
label: "Delete Text",
|
|
334
|
-
icon:
|
|
335
|
+
icon: B,
|
|
335
336
|
destructive: !0,
|
|
336
337
|
onSelect: () => {
|
|
337
|
-
|
|
338
|
+
G(t.id), l();
|
|
338
339
|
}
|
|
339
340
|
}), i;
|
|
340
341
|
}
|
|
341
342
|
if (t.kind === "background_layer") {
|
|
342
|
-
const n =
|
|
343
|
+
const n = lt(t.id), i = [];
|
|
343
344
|
return n && (i.push({
|
|
344
345
|
id: "duplicate",
|
|
345
346
|
kind: "action",
|
|
346
347
|
label: "Duplicate Region",
|
|
347
|
-
icon:
|
|
348
|
+
icon: p,
|
|
348
349
|
onSelect: () => {
|
|
349
|
-
|
|
350
|
+
ft(n), l();
|
|
350
351
|
}
|
|
351
352
|
}), i.push({
|
|
352
353
|
id: "change-material",
|
|
353
354
|
kind: "action",
|
|
354
355
|
label: "Change Material",
|
|
355
|
-
icon:
|
|
356
|
+
icon: Ot,
|
|
356
357
|
onSelect: () => {
|
|
357
|
-
|
|
358
|
+
_t(n.id, { material: cn(n.material) }), l();
|
|
358
359
|
}
|
|
359
360
|
})), i.push({ id: "separator-delete", kind: "separator" }), i.push({
|
|
360
361
|
id: "delete",
|
|
361
362
|
kind: "action",
|
|
362
363
|
label: "Delete Region",
|
|
363
|
-
icon:
|
|
364
|
+
icon: B,
|
|
364
365
|
destructive: !0,
|
|
365
366
|
onSelect: () => {
|
|
366
|
-
|
|
367
|
+
$(t.id), l();
|
|
367
368
|
}
|
|
368
369
|
}), i;
|
|
369
370
|
}
|
|
@@ -372,20 +373,20 @@ function Nn(o) {
|
|
|
372
373
|
id: "create-background-region",
|
|
373
374
|
kind: "action",
|
|
374
375
|
label: "Add Region",
|
|
375
|
-
icon:
|
|
376
|
+
icon: Ot,
|
|
376
377
|
onSelect: (n) => {
|
|
377
|
-
const i =
|
|
378
|
-
|
|
378
|
+
const i = D(e, n);
|
|
379
|
+
q(i.worldX, i.worldY), l();
|
|
379
380
|
}
|
|
380
381
|
},
|
|
381
382
|
{
|
|
382
383
|
id: "create-text",
|
|
383
384
|
kind: "action",
|
|
384
385
|
label: "Add Text",
|
|
385
|
-
icon:
|
|
386
|
+
icon: De,
|
|
386
387
|
onSelect: (n) => {
|
|
387
|
-
const i =
|
|
388
|
-
|
|
388
|
+
const i = D(e, n);
|
|
389
|
+
P(i.worldX, i.worldY), l();
|
|
389
390
|
}
|
|
390
391
|
}
|
|
391
392
|
] : [
|
|
@@ -393,40 +394,40 @@ function Nn(o) {
|
|
|
393
394
|
id: "create-sticky-note",
|
|
394
395
|
kind: "action",
|
|
395
396
|
label: "Add Sticky",
|
|
396
|
-
icon:
|
|
397
|
+
icon: Wt,
|
|
397
398
|
onSelect: (n) => {
|
|
398
|
-
const i =
|
|
399
|
-
|
|
399
|
+
const i = D(e, n);
|
|
400
|
+
U(i.worldX, i.worldY), l();
|
|
400
401
|
}
|
|
401
402
|
},
|
|
402
|
-
...
|
|
403
|
+
...L().map((n) => $t(n, e))
|
|
403
404
|
];
|
|
404
405
|
}), Jt = u(() => {
|
|
405
406
|
const e = d();
|
|
406
407
|
if (!e) return;
|
|
407
|
-
const t =
|
|
408
|
-
return
|
|
408
|
+
const t = ut(), n = t.filter((c) => c.kind === "action").length, i = t.filter((c) => c.kind === "separator").length;
|
|
409
|
+
return ze({
|
|
409
410
|
clientX: e.clientX,
|
|
410
411
|
clientY: e.clientY,
|
|
411
|
-
menuWidth:
|
|
412
|
-
menuHeight:
|
|
412
|
+
menuWidth: Ve,
|
|
413
|
+
menuHeight: Ke(n, i)
|
|
413
414
|
});
|
|
414
|
-
}),
|
|
415
|
-
const n =
|
|
415
|
+
}), V = (e, t) => {
|
|
416
|
+
const n = Je(e, L()), i = n.singleton ? I(e) : null;
|
|
416
417
|
if (i)
|
|
417
418
|
return T(i, { centerViewport: !0 });
|
|
418
419
|
const c = Ee(n, t), g = {
|
|
419
|
-
id:
|
|
420
|
+
id: x(),
|
|
420
421
|
type: e,
|
|
421
422
|
title: n.defaultTitle,
|
|
422
423
|
x: c.x,
|
|
423
424
|
y: c.y,
|
|
424
425
|
width: c.width,
|
|
425
426
|
height: c.height,
|
|
426
|
-
z_index:
|
|
427
|
+
z_index: A() + 1,
|
|
427
428
|
created_at_unix_ms: Date.now()
|
|
428
429
|
};
|
|
429
|
-
return
|
|
430
|
+
return R(() => {
|
|
430
431
|
o.setState((k) => ({
|
|
431
432
|
...k,
|
|
432
433
|
widgets: [...k.widgets, g],
|
|
@@ -436,28 +437,28 @@ function Nn(o) {
|
|
|
436
437
|
activeTool: "select"
|
|
437
438
|
})), O(g.id);
|
|
438
439
|
}), g;
|
|
439
|
-
}, Qt = (e, t, n) =>
|
|
440
|
+
}, Qt = (e, t, n) => V(e, {
|
|
440
441
|
anchor: "top_left",
|
|
441
442
|
worldX: t,
|
|
442
443
|
worldY: n
|
|
443
|
-
}),
|
|
444
|
+
}), gt = (e, t, n) => V(e, {
|
|
444
445
|
anchor: "top_left",
|
|
445
446
|
worldX: t,
|
|
446
447
|
worldY: n
|
|
447
|
-
}),
|
|
448
|
+
}), K = (e, t, n) => V(e, {
|
|
448
449
|
anchor: "center",
|
|
449
450
|
worldX: t,
|
|
450
451
|
worldY: n
|
|
451
|
-
}),
|
|
452
|
+
}), v = (e) => {
|
|
452
453
|
o.setState((t) => ({
|
|
453
454
|
...t,
|
|
454
455
|
widgets: t.widgets.filter((n) => n.id !== e),
|
|
455
456
|
selectedWidgetId: t.selectedWidgetId === e ? null : t.selectedWidgetId,
|
|
456
457
|
selectedObject: t.selectedObject?.kind === "widget" && t.selectedObject.id === e ? null : t.selectedObject ?? null
|
|
457
458
|
}));
|
|
458
|
-
},
|
|
459
|
-
const n =
|
|
460
|
-
return
|
|
459
|
+
}, U = (e, t) => {
|
|
460
|
+
const n = sn(e, t, A() + 1);
|
|
461
|
+
return R(() => {
|
|
461
462
|
o.setState((i) => ({
|
|
462
463
|
...i,
|
|
463
464
|
stickyNotes: [...i.stickyNotes ?? [], n],
|
|
@@ -467,11 +468,27 @@ function Nn(o) {
|
|
|
467
468
|
activeTool: "select"
|
|
468
469
|
})), O(n.id);
|
|
469
470
|
}), n;
|
|
470
|
-
},
|
|
471
|
+
}, te = (e) => {
|
|
472
|
+
const t = Date.now(), n = 28 / m().scale, i = {
|
|
473
|
+
...e,
|
|
474
|
+
id: x(),
|
|
475
|
+
x: e.x + n,
|
|
476
|
+
y: e.y + n,
|
|
477
|
+
z_index: A() + 1,
|
|
478
|
+
created_at_unix_ms: t,
|
|
479
|
+
updated_at_unix_ms: t
|
|
480
|
+
};
|
|
481
|
+
return o.setState((c) => ({
|
|
482
|
+
...c,
|
|
483
|
+
stickyNotes: [...c.stickyNotes ?? [], i],
|
|
484
|
+
selectedWidgetId: null,
|
|
485
|
+
selectedObject: { kind: "sticky_note", id: i.id }
|
|
486
|
+
})), i;
|
|
487
|
+
}, P = (e, t) => {
|
|
471
488
|
const n = rn(
|
|
472
489
|
e,
|
|
473
490
|
t,
|
|
474
|
-
|
|
491
|
+
ot(ct()) + 1,
|
|
475
492
|
Yt()
|
|
476
493
|
);
|
|
477
494
|
return o.setState((i) => ({
|
|
@@ -482,8 +499,8 @@ function Nn(o) {
|
|
|
482
499
|
mode: "background",
|
|
483
500
|
activeTool: "select"
|
|
484
501
|
})), n;
|
|
485
|
-
},
|
|
486
|
-
const t =
|
|
502
|
+
}, kt = (e) => {
|
|
503
|
+
const t = ln(e);
|
|
487
504
|
return o.setState((n) => ({
|
|
488
505
|
...n,
|
|
489
506
|
annotations: [...n.annotations ?? [], t],
|
|
@@ -492,11 +509,11 @@ function Nn(o) {
|
|
|
492
509
|
mode: "background",
|
|
493
510
|
activeTool: "select"
|
|
494
511
|
})), t;
|
|
495
|
-
},
|
|
496
|
-
const n =
|
|
512
|
+
}, q = (e, t) => {
|
|
513
|
+
const n = un(
|
|
497
514
|
e,
|
|
498
515
|
t,
|
|
499
|
-
|
|
516
|
+
ot(dt()) + 1,
|
|
500
517
|
Ht()
|
|
501
518
|
);
|
|
502
519
|
return o.setState((i) => ({
|
|
@@ -507,8 +524,8 @@ function Nn(o) {
|
|
|
507
524
|
mode: "background",
|
|
508
525
|
activeTool: "select"
|
|
509
526
|
})), n;
|
|
510
|
-
},
|
|
511
|
-
const t =
|
|
527
|
+
}, ft = (e) => {
|
|
528
|
+
const t = gn(e);
|
|
512
529
|
return o.setState((n) => ({
|
|
513
530
|
...n,
|
|
514
531
|
backgroundLayers: [...n.backgroundLayers ?? [], t],
|
|
@@ -517,9 +534,9 @@ function Nn(o) {
|
|
|
517
534
|
mode: "background",
|
|
518
535
|
activeTool: "select"
|
|
519
536
|
})), t;
|
|
520
|
-
},
|
|
521
|
-
const t =
|
|
522
|
-
t &&
|
|
537
|
+
}, W = (e) => {
|
|
538
|
+
const t = At([...w(), ...S()], e);
|
|
539
|
+
t && R(() => {
|
|
523
540
|
t.isTop || o.setState((n) => ({
|
|
524
541
|
...n,
|
|
525
542
|
widgets: n.widgets.map(
|
|
@@ -527,9 +544,9 @@ function Nn(o) {
|
|
|
527
544
|
)
|
|
528
545
|
})), O(e);
|
|
529
546
|
});
|
|
530
|
-
},
|
|
531
|
-
const t =
|
|
532
|
-
t &&
|
|
547
|
+
}, j = (e) => {
|
|
548
|
+
const t = At([...w(), ...S()], e);
|
|
549
|
+
t && R(() => {
|
|
533
550
|
t.isTop || o.setState((n) => ({
|
|
534
551
|
...n,
|
|
535
552
|
stickyNotes: (n.stickyNotes ?? []).map(
|
|
@@ -537,40 +554,41 @@ function Nn(o) {
|
|
|
537
554
|
)
|
|
538
555
|
})), O(e);
|
|
539
556
|
});
|
|
540
|
-
},
|
|
557
|
+
}, ee = (e, t) => {
|
|
541
558
|
o.setState((n) => ({
|
|
542
559
|
...n,
|
|
543
560
|
widgets: n.widgets.map(
|
|
544
561
|
(i) => i.id === e ? { ...i, x: t.x, y: t.y } : i
|
|
545
562
|
)
|
|
546
563
|
}));
|
|
547
|
-
},
|
|
564
|
+
}, ne = (e, t) => {
|
|
548
565
|
o.setState((n) => ({
|
|
549
566
|
...n,
|
|
550
567
|
widgets: n.widgets.map(
|
|
551
568
|
(i) => i.id === e ? { ...i, width: t.width, height: t.height } : i
|
|
552
569
|
)
|
|
553
570
|
}));
|
|
554
|
-
},
|
|
571
|
+
}, ie = (e, t) => {
|
|
555
572
|
o.setState((n) => ({
|
|
556
573
|
...n,
|
|
557
574
|
stickyNotes: (n.stickyNotes ?? []).map(
|
|
558
575
|
(i) => i.id === e ? { ...i, x: t.x, y: t.y, updated_at_unix_ms: Date.now() } : i
|
|
559
576
|
)
|
|
560
577
|
}));
|
|
561
|
-
},
|
|
578
|
+
}, oe = (e, t) => {
|
|
562
579
|
o.setState((n) => ({
|
|
563
580
|
...n,
|
|
564
581
|
stickyNotes: (n.stickyNotes ?? []).map(
|
|
565
582
|
(i) => i.id === e ? { ...i, width: t.width, height: t.height, updated_at_unix_ms: Date.now() } : i
|
|
566
583
|
)
|
|
567
584
|
}));
|
|
568
|
-
},
|
|
585
|
+
}, yt = (e, t) => {
|
|
569
586
|
o.setState((n) => ({
|
|
570
587
|
...n,
|
|
571
588
|
stickyNotes: (n.stickyNotes ?? []).map(
|
|
572
589
|
(i) => i.id === e ? {
|
|
573
590
|
...i,
|
|
591
|
+
...typeof t.title == "string" ? { title: t.title } : {},
|
|
574
592
|
...typeof t.body == "string" ? { body: t.body } : {},
|
|
575
593
|
...t.color ? { color: t.color } : {},
|
|
576
594
|
...t.material ? { material: t.material } : {},
|
|
@@ -578,27 +596,27 @@ function Nn(o) {
|
|
|
578
596
|
} : i
|
|
579
597
|
)
|
|
580
598
|
}));
|
|
581
|
-
},
|
|
599
|
+
}, Z = (e) => {
|
|
582
600
|
o.setState((t) => ({
|
|
583
601
|
...t,
|
|
584
602
|
stickyNotes: (t.stickyNotes ?? []).filter((n) => n.id !== e),
|
|
585
603
|
selectedObject: t.selectedObject?.kind === "sticky_note" && t.selectedObject.id === e ? null : t.selectedObject ?? null
|
|
586
604
|
}));
|
|
587
|
-
},
|
|
605
|
+
}, ce = (e, t) => {
|
|
588
606
|
o.setState((n) => ({
|
|
589
607
|
...n,
|
|
590
608
|
annotations: (n.annotations ?? []).map(
|
|
591
609
|
(i) => i.id === e ? { ...i, x: t.x, y: t.y, updated_at_unix_ms: Date.now() } : i
|
|
592
610
|
)
|
|
593
611
|
}));
|
|
594
|
-
},
|
|
612
|
+
}, de = (e, t) => {
|
|
595
613
|
o.setState((n) => ({
|
|
596
614
|
...n,
|
|
597
615
|
annotations: (n.annotations ?? []).map(
|
|
598
616
|
(i) => i.id === e ? { ...i, width: t.width, height: t.height, updated_at_unix_ms: Date.now() } : i
|
|
599
617
|
)
|
|
600
618
|
}));
|
|
601
|
-
},
|
|
619
|
+
}, ae = (e, t) => {
|
|
602
620
|
o.setState((n) => ({
|
|
603
621
|
...n,
|
|
604
622
|
annotations: (n.annotations ?? []).map(
|
|
@@ -614,13 +632,13 @@ function Nn(o) {
|
|
|
614
632
|
} : i
|
|
615
633
|
)
|
|
616
634
|
}));
|
|
617
|
-
},
|
|
635
|
+
}, G = (e) => {
|
|
618
636
|
o.setState((t) => ({
|
|
619
637
|
...t,
|
|
620
638
|
annotations: (t.annotations ?? []).filter((n) => n.id !== e),
|
|
621
639
|
selectedObject: t.selectedObject?.kind === "annotation" && t.selectedObject.id === e ? null : t.selectedObject ?? null
|
|
622
640
|
}));
|
|
623
|
-
},
|
|
641
|
+
}, se = (e, t) => {
|
|
624
642
|
o.setState((n) => ({
|
|
625
643
|
...n,
|
|
626
644
|
backgroundLayers: (n.backgroundLayers ?? []).map(
|
|
@@ -634,7 +652,7 @@ function Nn(o) {
|
|
|
634
652
|
(i) => i.id === e ? { ...i, width: t.width, height: t.height, updated_at_unix_ms: Date.now() } : i
|
|
635
653
|
)
|
|
636
654
|
}));
|
|
637
|
-
},
|
|
655
|
+
}, _t = (e, t) => {
|
|
638
656
|
o.setState((n) => ({
|
|
639
657
|
...n,
|
|
640
658
|
backgroundLayers: (n.backgroundLayers ?? []).map(
|
|
@@ -648,35 +666,35 @@ function Nn(o) {
|
|
|
648
666
|
} : i
|
|
649
667
|
)
|
|
650
668
|
}));
|
|
651
|
-
},
|
|
669
|
+
}, $ = (e) => {
|
|
652
670
|
o.setState((t) => ({
|
|
653
671
|
...t,
|
|
654
672
|
backgroundLayers: (t.backgroundLayers ?? []).filter((n) => n.id !== e),
|
|
655
673
|
selectedObject: t.selectedObject?.kind === "background_layer" && t.selectedObject.id === e ? null : t.selectedObject ?? null
|
|
656
674
|
}));
|
|
657
675
|
};
|
|
658
|
-
let
|
|
659
|
-
const
|
|
676
|
+
let J = 0;
|
|
677
|
+
const Q = (e) => {
|
|
660
678
|
o.setState((t) => ({ ...t, viewport: e }));
|
|
661
|
-
},
|
|
662
|
-
|
|
679
|
+
}, le = () => {
|
|
680
|
+
J += 1;
|
|
663
681
|
}, M = (e) => {
|
|
664
|
-
const t =
|
|
665
|
-
if (
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
x: n + (e.x - n) *
|
|
669
|
-
y: i + (e.y - i) *
|
|
670
|
-
scale: c + (e.scale - c) *
|
|
671
|
-
}),
|
|
682
|
+
const t = m(), n = t.x, i = t.y, c = t.scale, g = performance.now(), k = 360, Te = ++J, Ce = (et) => 1 - Math.pow(1 - et, 3), bt = (et) => {
|
|
683
|
+
if (Te !== J) return;
|
|
684
|
+
const Ne = et - g, xt = Math.min(Math.max(Ne / k, 0), 1), nt = Ce(xt);
|
|
685
|
+
Q({
|
|
686
|
+
x: n + (e.x - n) * nt,
|
|
687
|
+
y: i + (e.y - i) * nt,
|
|
688
|
+
scale: c + (e.scale - c) * nt
|
|
689
|
+
}), xt < 1 && requestAnimationFrame(bt);
|
|
672
690
|
};
|
|
673
|
-
requestAnimationFrame(
|
|
674
|
-
},
|
|
675
|
-
const t =
|
|
691
|
+
requestAnimationFrame(bt);
|
|
692
|
+
}, ue = (e) => {
|
|
693
|
+
const t = Ct(e), n = m();
|
|
676
694
|
if (n.scale >= t.minScale) return;
|
|
677
695
|
const i = h();
|
|
678
696
|
M(
|
|
679
|
-
|
|
697
|
+
qe({
|
|
680
698
|
viewport: n,
|
|
681
699
|
scale: t.minScale,
|
|
682
700
|
minScale: t.minScale,
|
|
@@ -684,38 +702,38 @@ function Nn(o) {
|
|
|
684
702
|
frameHeight: i.height
|
|
685
703
|
})
|
|
686
704
|
);
|
|
687
|
-
},
|
|
688
|
-
const t =
|
|
705
|
+
}, mt = (e) => {
|
|
706
|
+
const t = m(), n = h(), i = (n.width / 2 - t.x) / t.scale, c = (n.height / 2 - t.y) / t.scale, g = ve(
|
|
689
707
|
e === "in" ? t.scale * It : t.scale / It,
|
|
690
|
-
|
|
691
|
-
|
|
708
|
+
E().minScale,
|
|
709
|
+
Ue
|
|
692
710
|
), k = {
|
|
693
711
|
x: n.width / 2 - i * g,
|
|
694
712
|
y: n.height / 2 - c * g,
|
|
695
713
|
scale: g
|
|
696
714
|
};
|
|
697
|
-
|
|
698
|
-
},
|
|
715
|
+
Q(k);
|
|
716
|
+
}, ge = () => {
|
|
699
717
|
o.setState((e) => ({ ...e, locked: !e.locked }));
|
|
700
|
-
},
|
|
718
|
+
}, ke = (e) => {
|
|
701
719
|
o.setState((t) => ({
|
|
702
720
|
...t,
|
|
703
721
|
filters: { ...t.filters, [e]: !t.filters[e] }
|
|
704
722
|
}));
|
|
705
|
-
},
|
|
723
|
+
}, fe = (e, t) => {
|
|
706
724
|
o.setState((n) => {
|
|
707
725
|
const i = { ...n.filters }, c = [...new Set(t.map((k) => String(k)).filter(Boolean))], g = c.length > 1 && c.every((k) => i[k] !== !1 == (k === e));
|
|
708
726
|
for (const k of c)
|
|
709
727
|
i[k] = g ? !0 : k === e;
|
|
710
728
|
return { ...n, filters: i };
|
|
711
729
|
});
|
|
712
|
-
},
|
|
713
|
-
const e =
|
|
730
|
+
}, ye = () => {
|
|
731
|
+
const e = L();
|
|
714
732
|
o.setState((t) => ({
|
|
715
733
|
...t,
|
|
716
|
-
filters:
|
|
734
|
+
filters: He(void 0, e)
|
|
717
735
|
}));
|
|
718
|
-
},
|
|
736
|
+
}, F = (e) => {
|
|
719
737
|
o.setState((t) => ({
|
|
720
738
|
...t,
|
|
721
739
|
selectedWidgetId: e,
|
|
@@ -723,25 +741,25 @@ function Nn(o) {
|
|
|
723
741
|
mode: t.mode === "background" ? "work" : t.mode,
|
|
724
742
|
activeTool: "select"
|
|
725
743
|
}));
|
|
726
|
-
},
|
|
744
|
+
}, wt = () => {
|
|
727
745
|
o.setState(
|
|
728
746
|
(e) => e.selectedWidgetId === null && !e.selectedObject ? e : { ...e, selectedWidgetId: null, selectedObject: null }
|
|
729
747
|
);
|
|
730
|
-
},
|
|
748
|
+
}, _e = (e) => {
|
|
731
749
|
o.setState((t) => ({
|
|
732
750
|
...t,
|
|
733
751
|
selectedObject: e,
|
|
734
752
|
selectedWidgetId: e?.kind === "widget" ? e.id : null,
|
|
735
753
|
activeTool: "select"
|
|
736
754
|
}));
|
|
737
|
-
},
|
|
755
|
+
}, ht = (e) => {
|
|
738
756
|
o.setState((t) => ({
|
|
739
757
|
...t,
|
|
740
758
|
selectedWidgetId: null,
|
|
741
759
|
selectedObject: { kind: "sticky_note", id: e },
|
|
742
760
|
activeTool: "select"
|
|
743
|
-
})),
|
|
744
|
-
},
|
|
761
|
+
})), j(e);
|
|
762
|
+
}, me = (e) => {
|
|
745
763
|
o.setState((t) => ({
|
|
746
764
|
...t,
|
|
747
765
|
selectedWidgetId: null,
|
|
@@ -749,7 +767,7 @@ function Nn(o) {
|
|
|
749
767
|
mode: "background",
|
|
750
768
|
activeTool: "select"
|
|
751
769
|
}));
|
|
752
|
-
},
|
|
770
|
+
}, we = (e) => {
|
|
753
771
|
o.setState((t) => ({
|
|
754
772
|
...t,
|
|
755
773
|
selectedWidgetId: null,
|
|
@@ -757,86 +775,86 @@ function Nn(o) {
|
|
|
757
775
|
mode: "background",
|
|
758
776
|
activeTool: "select"
|
|
759
777
|
}));
|
|
760
|
-
},
|
|
761
|
-
const t =
|
|
778
|
+
}, he = (e) => {
|
|
779
|
+
const t = Pe(e);
|
|
762
780
|
o.setState((n) => ({
|
|
763
781
|
...n,
|
|
764
782
|
mode: t,
|
|
765
783
|
activeTool: "select",
|
|
766
784
|
selectedWidgetId: t === "work" ? n.selectedObject?.kind === "widget" ? n.selectedObject.id : n.selectedWidgetId : null,
|
|
767
785
|
selectedObject: t === "work" ? n.selectedObject?.kind === "widget" || n.selectedObject?.kind === "sticky_note" ? n.selectedObject : n.selectedWidgetId ? { kind: "widget", id: n.selectedWidgetId } : null : n.selectedObject?.kind === "background_layer" || n.selectedObject?.kind === "annotation" ? n.selectedObject : null
|
|
768
|
-
})),
|
|
769
|
-
},
|
|
786
|
+
})), ue(t);
|
|
787
|
+
}, be = (e) => {
|
|
770
788
|
o.setState((t) => ({
|
|
771
789
|
...t,
|
|
772
790
|
activeTool: e,
|
|
773
791
|
mode: e === "text" || e === "background-region" ? "background" : e === "sticky-note" ? "work" : t.mode ?? "work"
|
|
774
792
|
}));
|
|
775
|
-
},
|
|
776
|
-
const n =
|
|
777
|
-
return n === "sticky-note" ?
|
|
778
|
-
},
|
|
779
|
-
const e = h(), t =
|
|
793
|
+
}, xe = (e, t) => {
|
|
794
|
+
const n = at();
|
|
795
|
+
return n === "sticky-note" ? U(e, t) : n === "text" ? P(e, t) : n === "background-region" ? q(e, t) : null;
|
|
796
|
+
}, Se = () => {
|
|
797
|
+
const e = h(), t = m();
|
|
780
798
|
return {
|
|
781
799
|
worldX: e.width > 0 ? (e.width / 2 - t.x) / t.scale : 240,
|
|
782
800
|
worldY: e.height > 0 ? (e.height / 2 - t.y) / t.scale : 180
|
|
783
801
|
};
|
|
784
|
-
},
|
|
802
|
+
}, tt = (e) => {
|
|
785
803
|
const t = h();
|
|
786
804
|
t.width === 0 || t.height === 0 || M(
|
|
787
|
-
|
|
805
|
+
Lt({
|
|
788
806
|
widget: e,
|
|
789
|
-
scale:
|
|
807
|
+
scale: m().scale,
|
|
790
808
|
frameWidth: t.width,
|
|
791
809
|
frameHeight: t.height
|
|
792
810
|
})
|
|
793
811
|
);
|
|
794
|
-
},
|
|
812
|
+
}, We = (e) => {
|
|
795
813
|
const t = h();
|
|
796
814
|
t.width === 0 || t.height === 0 || M(
|
|
797
|
-
|
|
815
|
+
Ge({
|
|
798
816
|
widget: e,
|
|
799
817
|
frameWidth: t.width,
|
|
800
818
|
frameHeight: t.height
|
|
801
819
|
})
|
|
802
820
|
);
|
|
803
|
-
},
|
|
821
|
+
}, Oe = (e) => {
|
|
804
822
|
const t = h();
|
|
805
823
|
t.width === 0 || t.height === 0 || M(
|
|
806
|
-
|
|
824
|
+
Lt({
|
|
807
825
|
widget: e,
|
|
808
|
-
scale:
|
|
826
|
+
scale: Ze,
|
|
809
827
|
frameWidth: t.width,
|
|
810
828
|
frameHeight: t.height
|
|
811
829
|
})
|
|
812
830
|
);
|
|
813
|
-
}, T = (e, t = {}) => (
|
|
831
|
+
}, T = (e, t = {}) => (F(e.id), W(e.id), t.centerViewport !== !1 && tt(e), e);
|
|
814
832
|
return {
|
|
815
|
-
widgets:
|
|
816
|
-
stickyNotes:
|
|
817
|
-
annotations:
|
|
818
|
-
backgroundLayers:
|
|
819
|
-
viewport:
|
|
833
|
+
widgets: w,
|
|
834
|
+
stickyNotes: S,
|
|
835
|
+
annotations: ct,
|
|
836
|
+
backgroundLayers: dt,
|
|
837
|
+
viewport: m,
|
|
820
838
|
canvasFrameSize: _,
|
|
821
|
-
locked:
|
|
822
|
-
filters:
|
|
823
|
-
selectedWidgetId:
|
|
824
|
-
selectedObject:
|
|
839
|
+
locked: Rt,
|
|
840
|
+
filters: X,
|
|
841
|
+
selectedWidgetId: pt,
|
|
842
|
+
selectedObject: z,
|
|
825
843
|
mode: N,
|
|
826
|
-
activeTool:
|
|
844
|
+
activeTool: at,
|
|
827
845
|
theme: Bt,
|
|
828
|
-
topZIndex:
|
|
829
|
-
scaleLabel:
|
|
846
|
+
topZIndex: A,
|
|
847
|
+
scaleLabel: zt,
|
|
830
848
|
visualFrontOwnerId: a,
|
|
831
|
-
widgetDefinitions:
|
|
849
|
+
widgetDefinitions: L,
|
|
832
850
|
setCanvasFrameRef: Vt,
|
|
833
851
|
contextMenu: {
|
|
834
852
|
state: d,
|
|
835
|
-
items:
|
|
853
|
+
items: ut,
|
|
836
854
|
position: Jt,
|
|
837
855
|
close: l,
|
|
838
856
|
retarget: (e) => {
|
|
839
|
-
e.preventDefault(), e.stopPropagation(),
|
|
857
|
+
e.preventDefault(), e.stopPropagation(), s({
|
|
840
858
|
clientX: e.clientX,
|
|
841
859
|
clientY: e.clientY,
|
|
842
860
|
worldX: 0,
|
|
@@ -850,112 +868,114 @@ function Nn(o) {
|
|
|
850
868
|
openStickyNoteContextMenu: Ut,
|
|
851
869
|
openAnnotationContextMenu: Pt,
|
|
852
870
|
openBackgroundLayerContextMenu: qt,
|
|
853
|
-
selectWidget:
|
|
854
|
-
selectObject:
|
|
855
|
-
selectStickyNote:
|
|
856
|
-
selectAnnotation:
|
|
857
|
-
selectBackgroundLayer:
|
|
858
|
-
clearSelection:
|
|
871
|
+
selectWidget: F,
|
|
872
|
+
selectObject: _e,
|
|
873
|
+
selectStickyNote: ht,
|
|
874
|
+
selectAnnotation: me,
|
|
875
|
+
selectBackgroundLayer: we,
|
|
876
|
+
clearSelection: wt,
|
|
859
877
|
claimVisualFrontOwner: O,
|
|
860
|
-
commitFront:
|
|
861
|
-
commitMove:
|
|
862
|
-
commitResize:
|
|
863
|
-
commitStickyFront:
|
|
864
|
-
commitStickyMove:
|
|
865
|
-
commitStickyResize:
|
|
866
|
-
commitAnnotationMove:
|
|
867
|
-
commitAnnotationResize:
|
|
868
|
-
commitBackgroundMove:
|
|
878
|
+
commitFront: W,
|
|
879
|
+
commitMove: ee,
|
|
880
|
+
commitResize: ne,
|
|
881
|
+
commitStickyFront: j,
|
|
882
|
+
commitStickyMove: ie,
|
|
883
|
+
commitStickyResize: oe,
|
|
884
|
+
commitAnnotationMove: ce,
|
|
885
|
+
commitAnnotationResize: de,
|
|
886
|
+
commitBackgroundMove: se,
|
|
869
887
|
commitBackgroundResize: re,
|
|
870
|
-
commitViewport:
|
|
871
|
-
cancelViewportNavigation:
|
|
888
|
+
commitViewport: Q,
|
|
889
|
+
cancelViewportNavigation: le
|
|
872
890
|
},
|
|
873
891
|
hud: {
|
|
874
|
-
zoomIn: () =>
|
|
875
|
-
zoomOut: () =>
|
|
892
|
+
zoomIn: () => mt("in"),
|
|
893
|
+
zoomOut: () => mt("out")
|
|
876
894
|
},
|
|
877
895
|
lock: {
|
|
878
|
-
toggle:
|
|
896
|
+
toggle: ge
|
|
879
897
|
},
|
|
880
898
|
filter: {
|
|
881
|
-
toggle:
|
|
882
|
-
solo:
|
|
883
|
-
showAll:
|
|
899
|
+
toggle: ke,
|
|
900
|
+
solo: fe,
|
|
901
|
+
showAll: ye
|
|
884
902
|
},
|
|
885
903
|
navigation: {
|
|
886
904
|
handleArrowNavigation: (e) => {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
...
|
|
890
|
-
|
|
905
|
+
if (E().workLayerLocked) return;
|
|
906
|
+
const t = z(), n = [
|
|
907
|
+
...w(),
|
|
908
|
+
...S().map((c) => an(c))
|
|
909
|
+
].sort(Nt), i = Ye(
|
|
891
910
|
n,
|
|
892
911
|
t?.kind === "widget" || t?.kind === "sticky_note" ? t.id : null,
|
|
893
912
|
e,
|
|
894
913
|
Object.fromEntries(
|
|
895
914
|
n.map((c) => [
|
|
896
|
-
|
|
897
|
-
|
|
915
|
+
jt(c) ? c.type : "sticky_note",
|
|
916
|
+
jt(c) ? X()[c.type] !== !1 : X()[je] !== !1
|
|
898
917
|
])
|
|
899
918
|
)
|
|
900
919
|
);
|
|
901
|
-
i && (
|
|
920
|
+
i && (w().some((c) => c.id === i.id) ? T(i) : ht(i.id));
|
|
902
921
|
},
|
|
903
|
-
centerOnWidget:
|
|
922
|
+
centerOnWidget: tt,
|
|
904
923
|
focusWidget: T,
|
|
905
|
-
fitWidget: (e) => (
|
|
906
|
-
overviewWidget: (e) => (
|
|
924
|
+
fitWidget: (e) => (F(e.id), W(e.id), We(e), e),
|
|
925
|
+
overviewWidget: (e) => (F(e.id), W(e.id), Oe(e), e)
|
|
907
926
|
},
|
|
908
927
|
selection: {
|
|
909
|
-
clear:
|
|
928
|
+
clear: wt
|
|
910
929
|
},
|
|
911
930
|
widgetActions: {
|
|
912
931
|
deleteSelected: () => {
|
|
913
|
-
const e =
|
|
914
|
-
e
|
|
932
|
+
const e = z();
|
|
933
|
+
!e || (e.kind === "widget" || e.kind === "sticky_note") === E().workLayerLocked || (e.kind === "widget" && v(e.id), e.kind === "sticky_note" && Z(e.id), e.kind === "annotation" && G(e.id), e.kind === "background_layer" && $(e.id));
|
|
915
934
|
},
|
|
916
|
-
deleteWidget:
|
|
917
|
-
deleteStickyNote:
|
|
918
|
-
deleteAnnotation:
|
|
919
|
-
deleteBackgroundLayer:
|
|
935
|
+
deleteWidget: v,
|
|
936
|
+
deleteStickyNote: Z,
|
|
937
|
+
deleteAnnotation: G,
|
|
938
|
+
deleteBackgroundLayer: $,
|
|
920
939
|
addWidget: Qt,
|
|
921
|
-
addWidgetAtWorldTopLeft:
|
|
922
|
-
addWidgetAtWorldCenter:
|
|
923
|
-
addStickyNoteAtCursor:
|
|
924
|
-
addTextAnnotationAtCursor:
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
940
|
+
addWidgetAtWorldTopLeft: gt,
|
|
941
|
+
addWidgetAtWorldCenter: K,
|
|
942
|
+
addStickyNoteAtCursor: U,
|
|
943
|
+
addTextAnnotationAtCursor: P,
|
|
944
|
+
duplicateStickyNoteFrom: te,
|
|
945
|
+
duplicateTextAnnotationFrom: kt,
|
|
946
|
+
addBackgroundLayerAtCursor: q,
|
|
947
|
+
duplicateBackgroundLayerFrom: ft,
|
|
948
|
+
createActiveToolAt: xe,
|
|
929
949
|
ensureWidget: (e, t) => {
|
|
930
950
|
const n = I(e);
|
|
931
951
|
if (n)
|
|
932
952
|
return T(n, { centerViewport: t?.centerViewport ?? !0 });
|
|
933
|
-
const i =
|
|
953
|
+
const i = Se(), c = K(
|
|
934
954
|
e,
|
|
935
955
|
t?.worldX ?? i.worldX,
|
|
936
956
|
t?.worldY ?? i.worldY
|
|
937
957
|
);
|
|
938
|
-
return (t?.centerViewport ?? !0) && c &&
|
|
958
|
+
return (t?.centerViewport ?? !0) && c && tt(c), c;
|
|
939
959
|
},
|
|
940
|
-
updateStickyNote:
|
|
941
|
-
updateTextAnnotation:
|
|
942
|
-
updateBackgroundLayer:
|
|
960
|
+
updateStickyNote: yt,
|
|
961
|
+
updateTextAnnotation: ae,
|
|
962
|
+
updateBackgroundLayer: _t
|
|
943
963
|
},
|
|
944
964
|
queries: {
|
|
945
965
|
findWidgetByType: I,
|
|
946
966
|
findWidgetById: Zt,
|
|
947
|
-
findStickyNoteById:
|
|
967
|
+
findStickyNoteById: H,
|
|
948
968
|
findAnnotationById: rt,
|
|
949
|
-
findBackgroundLayerById:
|
|
969
|
+
findBackgroundLayerById: lt
|
|
950
970
|
},
|
|
951
971
|
appearance: {
|
|
952
972
|
setTheme: (e) => {
|
|
953
|
-
|
|
973
|
+
r().theme !== e && o.setState((t) => ({ ...t, theme: e }));
|
|
954
974
|
}
|
|
955
975
|
},
|
|
956
976
|
modes: {
|
|
957
|
-
setMode:
|
|
958
|
-
setActiveTool:
|
|
977
|
+
setMode: he,
|
|
978
|
+
setActiveTool: be
|
|
959
979
|
},
|
|
960
980
|
handleCloseRequest: () => {
|
|
961
981
|
if (d()) {
|
|
@@ -967,5 +987,5 @@ function Nn(o) {
|
|
|
967
987
|
};
|
|
968
988
|
}
|
|
969
989
|
export {
|
|
970
|
-
|
|
990
|
+
An as useWorkbenchModel
|
|
971
991
|
};
|