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