@floegence/floe-webapp-core 0.35.46 → 0.35.47
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/notes/NotesBoard.d.ts +4 -0
- package/dist/components/notes/NotesBoard.js +37 -34
- package/dist/components/notes/NotesBoardNote.d.ts +1 -0
- package/dist/components/notes/NotesBoardNote.js +29 -29
- package/dist/components/notes/NotesOverlay.js +19 -16
- package/dist/components/notes/useNotesOverlayModel.d.ts +4 -0
- package/dist/components/notes/useNotesOverlayModel.js +339 -305
- package/package.json +1 -1
|
@@ -1,127 +1,150 @@
|
|
|
1
|
-
import { createSignal as
|
|
2
|
-
import { Paste as
|
|
3
|
-
import { NOTES_CONTEXT_MENU_WIDTH_PX as
|
|
4
|
-
import { resolveFrameSize as
|
|
5
|
-
import { normalizeNotesSnapshot as
|
|
6
|
-
import { useNotification as
|
|
7
|
-
function
|
|
1
|
+
import { createSignal as l, createMemo as c, createEffect as w, onCleanup as X } from "solid-js";
|
|
2
|
+
import { Paste as zt, Plus as At, Trash as Ft } from "../icons/index.js";
|
|
3
|
+
import { NOTES_CONTEXT_MENU_WIDTH_PX as kt, estimateNotesContextMenuHeight as Bt } from "./NotesContextMenu.js";
|
|
4
|
+
import { samePoint as ie, resolveFrameSize as W, resolveOverviewBounds as Vt, createOverviewItem as jt, clamp as _, createContextMenuPosition as Wt, NOTES_MOBILE_BREAKPOINT_PX as Ht, getNormalizedOverviewPoint as je, findTrashTopicNoteCount as $t, hasLiveNotesForTopic as Kt, NOTES_CANVAS_ZOOM_STEP as We, resolveCenteredViewport as Zt } from "./notesOverlayHelpers.js";
|
|
5
|
+
import { normalizeNotesSnapshot as qt, groupTrashItems as Gt, visibleWorldRect as Ut, computeBoardBounds as Jt } from "./types.js";
|
|
6
|
+
import { useNotification as Qt } from "../../context/NotificationContext.js";
|
|
7
|
+
function m(r) {
|
|
8
8
|
return r instanceof Error ? r.message : String(r);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
let
|
|
13
|
-
const
|
|
14
|
-
() =>
|
|
15
|
-
),
|
|
10
|
+
function co(r) {
|
|
11
|
+
const a = Qt(), [ce, He] = l(), [M, $e] = l({ width: 0, height: 0 }), [T, d] = l(null), [se, ae] = l(""), [H, le] = l(null), [de, $] = l(""), [K, S] = l(null), [ue, pe] = l(""), [fe, me] = l("amber"), [we, he] = l(!1), [ve, Te] = l(!1), [Z, ge] = l(null), [q, G] = l(""), [Ke, Y] = l(null), [Ze, qe] = l(Date.now()), [Ge, Ue] = l(!1), [ye, y] = l(null), [Je, xe] = l(null), [Ce, b] = l(null), [Ne, E] = l(/* @__PURE__ */ new Map());
|
|
12
|
+
let P, U, J = null;
|
|
13
|
+
const p = c(() => qt(r.controller.snapshot())), g = c(
|
|
14
|
+
() => p().topics.filter((e) => e.deleted_at_unix_ms <= 0)
|
|
15
|
+
), Qe = c(() => g().length), x = c(() => {
|
|
16
16
|
const e = r.controller.activeTopicID();
|
|
17
17
|
return g().some((t) => t.topic_id === e) ? e : g()[0]?.topic_id ?? "";
|
|
18
|
-
}),
|
|
19
|
-
() => g().find((e) => e.topic_id ===
|
|
20
|
-
), E = c(
|
|
21
|
-
() => f().items.filter((e) => e.topic_id === C())
|
|
22
|
-
), qe = c(() => Ht(f().trash_items)), ye = c(() => f().trash_items.length), Ge = c(() => f().items.length), Ue = c(
|
|
23
|
-
() => E().reduce((e, t) => Math.max(e, t.z_index), 1)
|
|
24
|
-
), h = c(
|
|
25
|
-
() => ge() ?? r.controller.viewport()
|
|
26
|
-
), Je = c(() => P()?.name ?? "No topic"), Qe = c(
|
|
27
|
-
() => `${Math.round(h().scale * 100)}%`
|
|
18
|
+
}), I = c(
|
|
19
|
+
() => g().find((e) => e.topic_id === x())
|
|
28
20
|
), et = c(() => {
|
|
29
|
-
const e =
|
|
30
|
-
return
|
|
21
|
+
const e = Ne();
|
|
22
|
+
return p().items.map((t) => {
|
|
23
|
+
const o = e.get(t.note_id);
|
|
24
|
+
return !o || ie({ x: t.x, y: t.y }, o) ? t : {
|
|
25
|
+
...t,
|
|
26
|
+
x: o.x,
|
|
27
|
+
y: o.y
|
|
28
|
+
};
|
|
29
|
+
});
|
|
31
30
|
}), L = c(
|
|
32
|
-
() =>
|
|
33
|
-
), tt = c(
|
|
34
|
-
() =>
|
|
35
|
-
),
|
|
36
|
-
|
|
31
|
+
() => et().filter((e) => e.topic_id === x())
|
|
32
|
+
), tt = c(() => Gt(p().trash_items)), _e = c(() => p().trash_items.length), ot = c(() => p().items.length), nt = c(
|
|
33
|
+
() => L().reduce((e, t) => Math.max(e, t.z_index), 1)
|
|
34
|
+
), h = c(
|
|
35
|
+
() => Ce() ?? r.controller.viewport()
|
|
36
|
+
), rt = c(() => I()?.name ?? "No topic"), it = c(
|
|
37
|
+
() => `${Math.round(h().scale * 100)}%`
|
|
38
|
+
), ct = c(() => {
|
|
39
|
+
const e = W(M());
|
|
40
|
+
return Ut(h(), e.width, e.height);
|
|
41
|
+
}), R = c(
|
|
42
|
+
() => Vt(Jt(L()), ct())
|
|
43
|
+
), st = c(
|
|
44
|
+
() => L().map((e) => jt(e, R()))
|
|
45
|
+
), Me = c(() => {
|
|
46
|
+
const e = R(), t = W(M()), o = h(), n = -o.x / o.scale, i = -o.y / o.scale, s = t.width / o.scale, u = t.height / o.scale, f = _(n, e.minX, e.maxX), C = _(i, e.minY, e.maxY), N = _(n + s, e.minX, e.maxX), re = _(i + u, e.minY, e.maxY), O = Math.max((N - f) / e.width * 100, 6), v = Math.max((re - C) / e.height * 100, 8), Be = (f - e.minX) / e.width * 100, Ve = (C - e.minY) / e.height * 100;
|
|
37
47
|
return {
|
|
38
|
-
left:
|
|
39
|
-
top:
|
|
48
|
+
left: Be,
|
|
49
|
+
top: Ve,
|
|
40
50
|
width: O,
|
|
41
|
-
height:
|
|
42
|
-
centerX:
|
|
43
|
-
centerY:
|
|
51
|
+
height: v,
|
|
52
|
+
centerX: Be + O / 2,
|
|
53
|
+
centerY: Ve + v / 2
|
|
44
54
|
};
|
|
45
|
-
}),
|
|
46
|
-
const e =
|
|
55
|
+
}), at = c(() => {
|
|
56
|
+
const e = Me();
|
|
47
57
|
return {
|
|
48
58
|
left: `${e.left}%`,
|
|
49
59
|
top: `${e.top}%`,
|
|
50
60
|
width: `${e.width}%`,
|
|
51
61
|
height: `${e.height}%`
|
|
52
62
|
};
|
|
53
|
-
}),
|
|
54
|
-
const e =
|
|
55
|
-
return e ?
|
|
56
|
-
}),
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
}), be = c(() => {
|
|
64
|
+
const e = K();
|
|
65
|
+
return e ? p().items.find((t) => t.note_id === e) : void 0;
|
|
66
|
+
}), Q = () => {
|
|
67
|
+
P !== void 0 && (window.clearTimeout(P), P = void 0);
|
|
68
|
+
}, Pe = (e, t) => {
|
|
69
|
+
E((o) => {
|
|
70
|
+
const n = o.get(e);
|
|
71
|
+
if (n && ie(n, t)) return o;
|
|
72
|
+
const i = new Map(o);
|
|
73
|
+
return i.set(e, t), i;
|
|
74
|
+
});
|
|
75
|
+
}, z = (e) => {
|
|
76
|
+
E((t) => {
|
|
77
|
+
if (!t.has(e)) return t;
|
|
78
|
+
const o = new Map(t);
|
|
79
|
+
return o.delete(e), o;
|
|
80
|
+
});
|
|
81
|
+
}, A = () => {
|
|
82
|
+
ge(null), G("");
|
|
83
|
+
}, F = () => {
|
|
61
84
|
S(null);
|
|
62
|
-
},
|
|
63
|
-
|
|
85
|
+
}, D = () => {
|
|
86
|
+
Te(!1);
|
|
64
87
|
}, Ie = () => {
|
|
88
|
+
Te(!0);
|
|
89
|
+
}, k = () => {
|
|
90
|
+
he(!1);
|
|
91
|
+
}, ee = () => {
|
|
65
92
|
he(!0);
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
ce(null), H("");
|
|
72
|
-
}, nt = () => {
|
|
73
|
-
d(null), A(), M(), z(), R();
|
|
74
|
-
}, rt = () => {
|
|
93
|
+
}, B = () => {
|
|
94
|
+
le(null), $("");
|
|
95
|
+
}, lt = () => {
|
|
96
|
+
d(null), k(), D(), F(), A(), E(/* @__PURE__ */ new Map());
|
|
97
|
+
}, dt = () => {
|
|
75
98
|
if (T()) {
|
|
76
99
|
d(null);
|
|
77
100
|
return;
|
|
78
101
|
}
|
|
79
|
-
if (
|
|
80
|
-
|
|
102
|
+
if (K()) {
|
|
103
|
+
F();
|
|
81
104
|
return;
|
|
82
105
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
106
|
+
if (Z()) {
|
|
107
|
+
A();
|
|
85
108
|
return;
|
|
86
109
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
110
|
+
if (ve()) {
|
|
111
|
+
D();
|
|
89
112
|
return;
|
|
90
113
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
114
|
+
if (we()) {
|
|
115
|
+
k();
|
|
93
116
|
return;
|
|
94
117
|
}
|
|
95
118
|
r.onClose();
|
|
96
|
-
},
|
|
119
|
+
}, V = (e) => {
|
|
97
120
|
r.controller.setActiveTopicID(e);
|
|
98
|
-
},
|
|
121
|
+
}, De = (e) => Kt(p().items, e), ut = (e, t, o = I()?.topic_id) => {
|
|
99
122
|
if (!o) return null;
|
|
100
|
-
const n = g().find((
|
|
123
|
+
const n = g().find((f) => f.topic_id === o);
|
|
101
124
|
if (!n) return null;
|
|
102
|
-
const i =
|
|
125
|
+
const i = ce();
|
|
103
126
|
if (!i) return null;
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
127
|
+
const s = i.getBoundingClientRect();
|
|
128
|
+
if (s.width <= 0 || s.height <= 0 || e < s.left || e > s.right || t < s.top || t > s.bottom)
|
|
106
129
|
return null;
|
|
107
|
-
const
|
|
130
|
+
const u = h();
|
|
108
131
|
return {
|
|
109
132
|
topicID: n.topic_id,
|
|
110
|
-
worldX: (e -
|
|
111
|
-
worldY: (t -
|
|
133
|
+
worldX: (e - s.left - u.x) / u.scale,
|
|
134
|
+
worldY: (t - s.top - u.y) / u.scale
|
|
112
135
|
};
|
|
113
|
-
},
|
|
136
|
+
}, pt = (e, t) => {
|
|
114
137
|
if (typeof document > "u") return [];
|
|
115
138
|
if (typeof document.elementsFromPoint == "function")
|
|
116
139
|
return document.elementsFromPoint(e, t);
|
|
117
140
|
const o = document.elementFromPoint(e, t);
|
|
118
141
|
return o ? [o] : [];
|
|
119
|
-
},
|
|
120
|
-
const o =
|
|
142
|
+
}, ft = (e, t) => {
|
|
143
|
+
const o = pt(e, t).filter((n) => n instanceof HTMLElement).map((n) => n.closest("[data-floe-notes-note-id]")).find(Boolean)?.dataset.floeNotesNoteId?.trim();
|
|
121
144
|
if (o)
|
|
122
|
-
return
|
|
123
|
-
},
|
|
124
|
-
const n =
|
|
145
|
+
return p().items.find((n) => n.note_id === o);
|
|
146
|
+
}, te = (e, t, o) => {
|
|
147
|
+
const n = ut(e, t, o?.topicID);
|
|
125
148
|
return n ? {
|
|
126
149
|
clientX: e,
|
|
127
150
|
clientY: t,
|
|
@@ -130,86 +153,86 @@ function eo(r) {
|
|
|
130
153
|
topicID: n.topicID,
|
|
131
154
|
noteID: o?.noteID ?? null
|
|
132
155
|
} : null;
|
|
133
|
-
},
|
|
134
|
-
const e =
|
|
156
|
+
}, Oe = () => {
|
|
157
|
+
const e = I();
|
|
135
158
|
if (!e) return null;
|
|
136
|
-
const t =
|
|
159
|
+
const t = W(M()), o = h();
|
|
137
160
|
return {
|
|
138
161
|
topicID: e.topic_id,
|
|
139
162
|
worldX: (t.width / 2 - o.x) / o.scale,
|
|
140
163
|
worldY: (t.height / 2 - o.y) / o.scale
|
|
141
164
|
};
|
|
142
|
-
},
|
|
143
|
-
const n =
|
|
165
|
+
}, Xe = (e, t, o) => {
|
|
166
|
+
const n = te(e, t, o);
|
|
144
167
|
return n ? (d(n), !0) : !1;
|
|
145
|
-
},
|
|
146
|
-
const o =
|
|
168
|
+
}, mt = (e, t) => {
|
|
169
|
+
const o = ft(e, t);
|
|
147
170
|
if (o) {
|
|
148
|
-
|
|
149
|
-
const n =
|
|
171
|
+
j(o.note_id);
|
|
172
|
+
const n = te(e, t, {
|
|
150
173
|
topicID: o.topic_id,
|
|
151
174
|
noteID: o.note_id
|
|
152
175
|
});
|
|
153
176
|
d(n);
|
|
154
177
|
return;
|
|
155
178
|
}
|
|
156
|
-
d(
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
},
|
|
179
|
+
d(te(e, t));
|
|
180
|
+
}, Se = (e) => {
|
|
181
|
+
b(e), r.controller.setViewport(e), b(null);
|
|
182
|
+
}, Ye = (e, t, o) => Zt({
|
|
160
183
|
viewport: h(),
|
|
161
|
-
frame:
|
|
162
|
-
bounds:
|
|
184
|
+
frame: M(),
|
|
185
|
+
bounds: R(),
|
|
163
186
|
worldX: e,
|
|
164
187
|
worldY: t,
|
|
165
188
|
scale: o
|
|
166
|
-
}),
|
|
167
|
-
const t = h(), o =
|
|
168
|
-
|
|
169
|
-
},
|
|
189
|
+
}), Ee = (e) => {
|
|
190
|
+
const t = h(), o = W(M()), n = (o.width / 2 - t.x) / t.scale, i = (o.height / 2 - t.y) / t.scale, s = e === "in" ? t.scale * We : t.scale / We;
|
|
191
|
+
Se(Ye(n, i, s));
|
|
192
|
+
}, Le = (e, t, o) => {
|
|
170
193
|
const n = o.surfaceRect;
|
|
171
194
|
if (n.width <= 0 || n.height <= 0) return;
|
|
172
|
-
const i =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
195
|
+
const i = je(e, t, n), s = _(i.x - o.centerOffsetX, 0, 1), u = _(i.y - o.centerOffsetY, 0, 1), f = o.bounds;
|
|
196
|
+
b(
|
|
197
|
+
Ye(
|
|
198
|
+
f.minX + s * f.width,
|
|
199
|
+
f.minY + u * f.height
|
|
177
200
|
)
|
|
178
201
|
);
|
|
179
|
-
},
|
|
180
|
-
if (
|
|
181
|
-
const t =
|
|
202
|
+
}, oe = (e) => {
|
|
203
|
+
if (U?.abort(), U = void 0, e) {
|
|
204
|
+
const t = Ce();
|
|
182
205
|
t && r.controller.setViewport(t);
|
|
183
206
|
}
|
|
184
|
-
|
|
185
|
-
},
|
|
207
|
+
b(null), xe(null);
|
|
208
|
+
}, wt = (e) => {
|
|
186
209
|
if (e.button !== 0 && e.pointerType !== "touch" && e.pointerType !== "pen")
|
|
187
210
|
return;
|
|
188
211
|
const t = e.currentTarget, o = t.getBoundingClientRect();
|
|
189
212
|
if (o.width <= 0 || o.height <= 0) return;
|
|
190
|
-
const n =
|
|
213
|
+
const n = je(e.clientX, e.clientY, o), i = Me(), s = n.x * 100, u = n.y * 100, f = s >= i.left && s <= i.left + i.width && u >= i.top && u <= i.top + i.height, C = {
|
|
191
214
|
pointerId: e.pointerId,
|
|
192
|
-
bounds:
|
|
215
|
+
bounds: R(),
|
|
193
216
|
surfaceRect: o,
|
|
194
|
-
centerOffsetX:
|
|
195
|
-
centerOffsetY:
|
|
217
|
+
centerOffsetX: f ? n.x - i.centerX / 100 : 0,
|
|
218
|
+
centerOffsetY: f ? n.y - i.centerY / 100 : 0
|
|
196
219
|
};
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
}, O = (
|
|
203
|
-
|
|
220
|
+
oe(!1), e.preventDefault(), e.stopPropagation(), xe(C), Le(e.clientX, e.clientY, C), t.setPointerCapture?.(e.pointerId);
|
|
221
|
+
const N = new AbortController();
|
|
222
|
+
U = N;
|
|
223
|
+
const re = (v) => {
|
|
224
|
+
v.pointerId === e.pointerId && Le(v.clientX, v.clientY, C);
|
|
225
|
+
}, O = (v) => {
|
|
226
|
+
v.pointerId === e.pointerId && (t.hasPointerCapture?.(e.pointerId) && t.releasePointerCapture(e.pointerId), oe(!0));
|
|
204
227
|
};
|
|
205
|
-
t.addEventListener("pointermove",
|
|
228
|
+
t.addEventListener("pointermove", re, { signal: N.signal }), t.addEventListener("pointerup", O, {
|
|
206
229
|
once: !0,
|
|
207
|
-
signal:
|
|
230
|
+
signal: N.signal
|
|
208
231
|
}), t.addEventListener("pointercancel", O, {
|
|
209
232
|
once: !0,
|
|
210
|
-
signal:
|
|
233
|
+
signal: N.signal
|
|
211
234
|
});
|
|
212
|
-
},
|
|
235
|
+
}, Re = async (e) => {
|
|
213
236
|
try {
|
|
214
237
|
const t = await r.controller.createNote({
|
|
215
238
|
topic_id: e.topicID,
|
|
@@ -219,152 +242,153 @@ function eo(r) {
|
|
|
219
242
|
});
|
|
220
243
|
S(t.note_id);
|
|
221
244
|
} catch (t) {
|
|
222
|
-
|
|
245
|
+
a.error("Create failed", m(t));
|
|
223
246
|
}
|
|
224
|
-
},
|
|
247
|
+
}, ze = async (e, t) => {
|
|
225
248
|
try {
|
|
226
249
|
await r.controller.createNote({
|
|
227
250
|
topic_id: e.topicID,
|
|
228
251
|
x: e.worldX,
|
|
229
252
|
y: e.worldY,
|
|
230
253
|
body: t
|
|
231
|
-
}),
|
|
254
|
+
}), a.success("Pasted", "Created a new note from clipboard text.");
|
|
232
255
|
} catch (o) {
|
|
233
|
-
|
|
256
|
+
a.error("Paste failed", m(o));
|
|
234
257
|
}
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
},
|
|
258
|
+
}, Ae = (e) => {
|
|
259
|
+
G(""), ge(e);
|
|
260
|
+
}, Fe = async (e) => {
|
|
238
261
|
try {
|
|
239
262
|
const t = await navigator.clipboard.readText();
|
|
240
263
|
if (!t.trim()) {
|
|
241
|
-
|
|
264
|
+
a.info("Clipboard empty", "Paste text into the dialog to create a note."), Ae(e);
|
|
242
265
|
return;
|
|
243
266
|
}
|
|
244
|
-
await
|
|
267
|
+
await ze(e, t);
|
|
245
268
|
} catch {
|
|
246
|
-
|
|
269
|
+
a.info("Clipboard blocked", "Manual paste is available as a fallback."), Ae(e);
|
|
247
270
|
}
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
|
|
271
|
+
}, ht = (e) => {
|
|
272
|
+
Q(), Y(e), P = window.setTimeout(() => {
|
|
273
|
+
P = void 0, Y((t) => t === e ? null : t);
|
|
251
274
|
}, 1100);
|
|
252
|
-
},
|
|
275
|
+
}, vt = (e) => {
|
|
253
276
|
y(e);
|
|
254
|
-
},
|
|
277
|
+
}, j = (e) => {
|
|
255
278
|
y(e), Promise.resolve(r.controller.bringNoteToFront(e)).catch((t) => {
|
|
256
|
-
|
|
279
|
+
a.error("Bring forward failed", m(t)), y((o) => o === e ? null : o);
|
|
257
280
|
});
|
|
258
|
-
},
|
|
281
|
+
}, Tt = (e) => {
|
|
259
282
|
d(null), S(e);
|
|
260
|
-
},
|
|
283
|
+
}, gt = async (e) => {
|
|
261
284
|
if (!e.body.trim()) {
|
|
262
285
|
d(null), S(e.note_id);
|
|
263
286
|
return;
|
|
264
287
|
}
|
|
265
288
|
try {
|
|
266
|
-
|
|
289
|
+
j(e.note_id), await navigator.clipboard.writeText(e.body), ht(e.note_id);
|
|
267
290
|
} catch {
|
|
268
|
-
|
|
291
|
+
a.error("Copy failed", "Clipboard write was not available.");
|
|
269
292
|
}
|
|
270
|
-
},
|
|
293
|
+
}, ke = async (e) => {
|
|
271
294
|
try {
|
|
272
|
-
await r.controller.deleteNote(e),
|
|
295
|
+
z(e), await r.controller.deleteNote(e), Q(), Y((t) => t === e ? null : t), ee();
|
|
273
296
|
} catch (t) {
|
|
274
|
-
|
|
297
|
+
a.error("Delete failed", m(t));
|
|
275
298
|
}
|
|
276
|
-
},
|
|
299
|
+
}, yt = async (e) => {
|
|
277
300
|
try {
|
|
278
|
-
await r.controller.restoreNote(e);
|
|
301
|
+
z(e), await r.controller.restoreNote(e);
|
|
279
302
|
} catch (t) {
|
|
280
|
-
|
|
303
|
+
a.error("Restore failed", m(t));
|
|
281
304
|
}
|
|
282
|
-
},
|
|
305
|
+
}, xt = async (e) => {
|
|
283
306
|
if (r.controller.deleteTrashedNotePermanently)
|
|
284
307
|
try {
|
|
285
|
-
await r.controller.deleteTrashedNotePermanently(e);
|
|
308
|
+
z(e), await r.controller.deleteTrashedNotePermanently(e);
|
|
286
309
|
} catch (t) {
|
|
287
|
-
|
|
310
|
+
a.error("Delete failed", m(t));
|
|
288
311
|
}
|
|
289
|
-
},
|
|
312
|
+
}, Ct = async (e) => {
|
|
290
313
|
try {
|
|
291
314
|
await r.controller.clearTrashTopic(e);
|
|
292
315
|
} catch (t) {
|
|
293
|
-
|
|
316
|
+
a.error("Trash failed", m(t));
|
|
294
317
|
}
|
|
295
|
-
},
|
|
296
|
-
const e =
|
|
318
|
+
}, Nt = async () => {
|
|
319
|
+
const e = K();
|
|
297
320
|
if (e)
|
|
298
321
|
try {
|
|
299
322
|
await r.controller.updateNote(e, {
|
|
300
|
-
body:
|
|
301
|
-
color_token:
|
|
302
|
-
}),
|
|
323
|
+
body: ue(),
|
|
324
|
+
color_token: fe()
|
|
325
|
+
}), a.success("Saved", "Note updated."), F();
|
|
303
326
|
} catch (t) {
|
|
304
|
-
|
|
327
|
+
a.error("Save failed", m(t));
|
|
305
328
|
}
|
|
306
|
-
},
|
|
307
|
-
const e =
|
|
308
|
-
!e || !
|
|
309
|
-
},
|
|
310
|
-
const e =
|
|
329
|
+
}, _t = async () => {
|
|
330
|
+
const e = Z();
|
|
331
|
+
!e || !q().trim() || (await ze(e, q()), A());
|
|
332
|
+
}, Mt = async () => {
|
|
333
|
+
const e = se().trim();
|
|
311
334
|
if (e)
|
|
312
335
|
try {
|
|
313
336
|
const t = await r.controller.createTopic({ name: e });
|
|
314
|
-
|
|
337
|
+
ae(""), V(t.topic_id);
|
|
315
338
|
} catch (t) {
|
|
316
|
-
|
|
339
|
+
a.error("Topic failed", m(t));
|
|
317
340
|
}
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
},
|
|
321
|
-
const e =
|
|
341
|
+
}, bt = (e) => {
|
|
342
|
+
le(e.topic_id), $(e.name);
|
|
343
|
+
}, Pt = async () => {
|
|
344
|
+
const e = H();
|
|
322
345
|
if (!e) return;
|
|
323
|
-
const t =
|
|
324
|
-
if (
|
|
346
|
+
const t = de().trim();
|
|
347
|
+
if (B(), !!t)
|
|
325
348
|
try {
|
|
326
349
|
await r.controller.updateTopic(e, { name: t });
|
|
327
350
|
} catch (o) {
|
|
328
|
-
|
|
351
|
+
a.error("Rename failed", m(o));
|
|
329
352
|
}
|
|
330
|
-
},
|
|
331
|
-
const t =
|
|
332
|
-
|
|
353
|
+
}, It = async (e) => {
|
|
354
|
+
const t = De(e.topic_id) + $t(p().trash_items, e.topic_id);
|
|
355
|
+
H() === e.topic_id && B();
|
|
333
356
|
try {
|
|
334
357
|
if (await r.controller.deleteTopic(e.topic_id) === !1) {
|
|
335
|
-
|
|
358
|
+
a.info(
|
|
336
359
|
"Keep one topic",
|
|
337
360
|
"At least one topic needs to remain available."
|
|
338
361
|
);
|
|
339
362
|
return;
|
|
340
363
|
}
|
|
341
364
|
if (t > 0) {
|
|
342
|
-
|
|
365
|
+
ee(), a.success(
|
|
343
366
|
"Topic deleted",
|
|
344
367
|
"Live notes moved into trash for this topic."
|
|
345
368
|
);
|
|
346
369
|
return;
|
|
347
370
|
}
|
|
348
|
-
|
|
371
|
+
a.success("Topic deleted", "The empty topic was removed.");
|
|
349
372
|
} catch (o) {
|
|
350
|
-
|
|
373
|
+
a.error("Delete failed", m(o));
|
|
351
374
|
}
|
|
352
|
-
},
|
|
375
|
+
}, Dt = async (e, t) => {
|
|
376
|
+
Pe(e, t);
|
|
353
377
|
try {
|
|
354
378
|
await r.controller.updateNote(e, {
|
|
355
379
|
x: t.x,
|
|
356
380
|
y: t.y
|
|
357
381
|
});
|
|
358
382
|
} catch (o) {
|
|
359
|
-
|
|
383
|
+
z(e), a.error("Move failed", m(o));
|
|
360
384
|
}
|
|
361
|
-
},
|
|
362
|
-
const e =
|
|
363
|
-
e && (
|
|
364
|
-
},
|
|
365
|
-
const e =
|
|
366
|
-
e && (
|
|
367
|
-
},
|
|
385
|
+
}, Ot = async () => {
|
|
386
|
+
const e = Oe();
|
|
387
|
+
e && (D(), await Re(e));
|
|
388
|
+
}, Xt = async () => {
|
|
389
|
+
const e = Oe();
|
|
390
|
+
e && (D(), await Fe(e));
|
|
391
|
+
}, ne = c(() => {
|
|
368
392
|
const e = T();
|
|
369
393
|
if (!e) return [];
|
|
370
394
|
const t = [
|
|
@@ -372,20 +396,20 @@ function eo(r) {
|
|
|
372
396
|
id: "paste",
|
|
373
397
|
kind: "action",
|
|
374
398
|
label: "Paste here",
|
|
375
|
-
icon:
|
|
399
|
+
icon: zt,
|
|
376
400
|
onSelect: () => {
|
|
377
401
|
const o = T();
|
|
378
|
-
o && (d(null),
|
|
402
|
+
o && (d(null), Fe(o));
|
|
379
403
|
}
|
|
380
404
|
},
|
|
381
405
|
{
|
|
382
406
|
id: "new",
|
|
383
407
|
kind: "action",
|
|
384
408
|
label: "New note",
|
|
385
|
-
icon:
|
|
409
|
+
icon: At,
|
|
386
410
|
onSelect: () => {
|
|
387
411
|
const o = T();
|
|
388
|
-
o && (d(null),
|
|
412
|
+
o && (d(null), Re(o));
|
|
389
413
|
}
|
|
390
414
|
}
|
|
391
415
|
];
|
|
@@ -393,25 +417,25 @@ function eo(r) {
|
|
|
393
417
|
id: "delete",
|
|
394
418
|
kind: "action",
|
|
395
419
|
label: "Delete",
|
|
396
|
-
icon:
|
|
420
|
+
icon: Ft,
|
|
397
421
|
destructive: !0,
|
|
398
422
|
onSelect: () => {
|
|
399
423
|
const o = T();
|
|
400
|
-
o?.noteID && (d(null),
|
|
424
|
+
o?.noteID && (d(null), ke(o.noteID));
|
|
401
425
|
}
|
|
402
426
|
})), t;
|
|
403
|
-
}),
|
|
427
|
+
}), St = c(() => {
|
|
404
428
|
const e = T();
|
|
405
429
|
if (!e) return;
|
|
406
|
-
const t =
|
|
407
|
-
return
|
|
430
|
+
const t = ne().filter((n) => n.kind === "action").length, o = ne().filter((n) => n.kind === "separator").length;
|
|
431
|
+
return Wt({
|
|
408
432
|
clientX: e.clientX,
|
|
409
433
|
clientY: e.clientY,
|
|
410
|
-
menuWidth:
|
|
411
|
-
menuHeight:
|
|
434
|
+
menuWidth: kt,
|
|
435
|
+
menuHeight: Bt(t, o)
|
|
412
436
|
});
|
|
413
|
-
}),
|
|
414
|
-
const t =
|
|
437
|
+
}), Yt = (e) => {
|
|
438
|
+
const t = I();
|
|
415
439
|
t && d({
|
|
416
440
|
clientX: e.clientX,
|
|
417
441
|
clientY: e.clientY,
|
|
@@ -419,52 +443,61 @@ function eo(r) {
|
|
|
419
443
|
worldY: e.worldY,
|
|
420
444
|
topicID: t.topic_id
|
|
421
445
|
});
|
|
422
|
-
},
|
|
423
|
-
|
|
446
|
+
}, Et = (e, t) => {
|
|
447
|
+
j(t.note_id), Xe(e.clientX, e.clientY, {
|
|
424
448
|
topicID: t.topic_id,
|
|
425
449
|
noteID: t.note_id
|
|
426
450
|
});
|
|
427
|
-
},
|
|
428
|
-
|
|
429
|
-
},
|
|
430
|
-
e.preventDefault(), e.stopPropagation(),
|
|
451
|
+
}, Lt = (e) => {
|
|
452
|
+
k(), Xe(e.clientX, e.clientY);
|
|
453
|
+
}, Rt = (e) => {
|
|
454
|
+
e.preventDefault(), e.stopPropagation(), mt(e.clientX, e.clientY);
|
|
431
455
|
};
|
|
432
|
-
return
|
|
433
|
-
r.open || (
|
|
434
|
-
}),
|
|
435
|
-
const e =
|
|
436
|
-
e && r.controller.activeTopicID() !== e &&
|
|
437
|
-
}),
|
|
438
|
-
const e =
|
|
456
|
+
return w(() => {
|
|
457
|
+
r.open || (lt(), B(), b(null), y(null), Y(null));
|
|
458
|
+
}), w(() => {
|
|
459
|
+
const e = x();
|
|
460
|
+
e && r.controller.activeTopicID() !== e && V(e);
|
|
461
|
+
}), w(() => {
|
|
462
|
+
const e = be();
|
|
439
463
|
if (!e) {
|
|
440
|
-
|
|
464
|
+
J = null;
|
|
441
465
|
return;
|
|
442
466
|
}
|
|
443
|
-
|
|
444
|
-
}),
|
|
445
|
-
const e =
|
|
467
|
+
J !== e.note_id && (J = e.note_id, pe(e.body), me(e.color_token));
|
|
468
|
+
}), w(() => {
|
|
469
|
+
const e = ye();
|
|
446
470
|
if (!e) return;
|
|
447
|
-
const t =
|
|
471
|
+
const t = p().items.find((n) => n.note_id === e);
|
|
448
472
|
if (!t) {
|
|
449
473
|
y(null);
|
|
450
474
|
return;
|
|
451
475
|
}
|
|
452
|
-
const o =
|
|
476
|
+
const o = p().items.reduce(
|
|
453
477
|
(n, i) => Math.max(n, i.z_index),
|
|
454
478
|
0
|
|
455
479
|
);
|
|
456
480
|
t.z_index >= o && y(null);
|
|
457
|
-
}),
|
|
481
|
+
}), w(() => {
|
|
482
|
+
const e = p().items, t = Ne();
|
|
483
|
+
if (t.size === 0) return;
|
|
484
|
+
let o = null;
|
|
485
|
+
for (const [n, i] of t) {
|
|
486
|
+
const s = e.find((u) => u.note_id === n);
|
|
487
|
+
(!s || ie({ x: s.x, y: s.y }, i)) && (o ??= new Map(t), o.delete(n));
|
|
488
|
+
}
|
|
489
|
+
o && E(o);
|
|
490
|
+
}), w(() => {
|
|
458
491
|
if (!r.open) return;
|
|
459
492
|
const e = () => {
|
|
460
|
-
|
|
493
|
+
Ue(window.innerWidth < Ht);
|
|
461
494
|
};
|
|
462
495
|
e(), window.addEventListener("resize", e), X(() => window.removeEventListener("resize", e));
|
|
463
|
-
}),
|
|
464
|
-
const e =
|
|
496
|
+
}), w(() => {
|
|
497
|
+
const e = ce();
|
|
465
498
|
if (!e) return;
|
|
466
499
|
const t = () => {
|
|
467
|
-
|
|
500
|
+
$e({
|
|
468
501
|
width: e.clientWidth,
|
|
469
502
|
height: e.clientHeight
|
|
470
503
|
});
|
|
@@ -475,113 +508,114 @@ function eo(r) {
|
|
|
475
508
|
}
|
|
476
509
|
const o = new ResizeObserver(t);
|
|
477
510
|
o.observe(e), X(() => o.disconnect());
|
|
478
|
-
}),
|
|
511
|
+
}), w(() => {
|
|
479
512
|
if (!r.open) return;
|
|
480
|
-
const e = window.setInterval(() =>
|
|
513
|
+
const e = window.setInterval(() => qe(Date.now()), 60 * 1e3);
|
|
481
514
|
X(() => window.clearInterval(e));
|
|
482
|
-
}),
|
|
483
|
-
|
|
515
|
+
}), w(() => {
|
|
516
|
+
x() && d(null);
|
|
484
517
|
}), X(() => {
|
|
485
|
-
|
|
518
|
+
Q(), oe(!1);
|
|
486
519
|
}), {
|
|
487
520
|
header: {
|
|
488
|
-
topicCount:
|
|
489
|
-
totalLiveNotes:
|
|
490
|
-
trashCount:
|
|
521
|
+
topicCount: Qe,
|
|
522
|
+
totalLiveNotes: ot,
|
|
523
|
+
trashCount: _e
|
|
491
524
|
},
|
|
492
525
|
rail: {
|
|
493
526
|
topics: g,
|
|
494
|
-
activeTopicID:
|
|
495
|
-
draftTopicTitle:
|
|
496
|
-
renamingTopicID:
|
|
497
|
-
renamingTopicTitle:
|
|
498
|
-
getLiveNoteCount:
|
|
499
|
-
setDraftTopicTitle:
|
|
500
|
-
submitTopic:
|
|
501
|
-
selectTopic:
|
|
502
|
-
startTopicRename:
|
|
503
|
-
setRenamingTopicTitle:
|
|
504
|
-
saveTopicRename:
|
|
505
|
-
cancelTopicRename:
|
|
506
|
-
deleteTopic:
|
|
527
|
+
activeTopicID: x,
|
|
528
|
+
draftTopicTitle: se,
|
|
529
|
+
renamingTopicID: H,
|
|
530
|
+
renamingTopicTitle: de,
|
|
531
|
+
getLiveNoteCount: De,
|
|
532
|
+
setDraftTopicTitle: ae,
|
|
533
|
+
submitTopic: Mt,
|
|
534
|
+
selectTopic: V,
|
|
535
|
+
startTopicRename: bt,
|
|
536
|
+
setRenamingTopicTitle: $,
|
|
537
|
+
saveTopicRename: Pt,
|
|
538
|
+
cancelTopicRename: B,
|
|
539
|
+
deleteTopic: It
|
|
507
540
|
},
|
|
508
541
|
board: {
|
|
509
|
-
activeTopic:
|
|
510
|
-
activeTopicLabel:
|
|
511
|
-
activeItems:
|
|
512
|
-
activeTopicID:
|
|
542
|
+
activeTopic: I,
|
|
543
|
+
activeTopicLabel: rt,
|
|
544
|
+
activeItems: L,
|
|
545
|
+
activeTopicID: x,
|
|
513
546
|
topics: g,
|
|
514
|
-
topZIndex:
|
|
547
|
+
topZIndex: nt,
|
|
515
548
|
viewport: h,
|
|
516
|
-
boardScaleLabel:
|
|
517
|
-
isMobile:
|
|
518
|
-
overviewOpen:
|
|
519
|
-
optimisticFrontNoteID:
|
|
520
|
-
copiedNoteID:
|
|
521
|
-
setCanvasFrameRef:
|
|
522
|
-
commitViewport:
|
|
523
|
-
openCanvasContextMenu:
|
|
524
|
-
zoomOut: () =>
|
|
525
|
-
zoomIn: () =>
|
|
549
|
+
boardScaleLabel: it,
|
|
550
|
+
isMobile: Ge,
|
|
551
|
+
overviewOpen: ve,
|
|
552
|
+
optimisticFrontNoteID: ye,
|
|
553
|
+
copiedNoteID: Ke,
|
|
554
|
+
setCanvasFrameRef: He,
|
|
555
|
+
commitViewport: Se,
|
|
556
|
+
openCanvasContextMenu: Yt,
|
|
557
|
+
zoomOut: () => Ee("out"),
|
|
558
|
+
zoomIn: () => Ee("in"),
|
|
526
559
|
openOverview: Ie,
|
|
527
|
-
selectTopic:
|
|
528
|
-
mobileCreateNote:
|
|
529
|
-
mobilePaste:
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
560
|
+
selectTopic: V,
|
|
561
|
+
mobileCreateNote: Ot,
|
|
562
|
+
mobilePaste: Xt,
|
|
563
|
+
seedMoveProjection: Pe,
|
|
564
|
+
copyNote: gt,
|
|
565
|
+
openNoteContextMenu: Et,
|
|
566
|
+
openEditor: Tt,
|
|
567
|
+
moveToTrash: ke,
|
|
568
|
+
startOptimisticFront: vt,
|
|
569
|
+
commitFront: j,
|
|
570
|
+
commitMove: Dt
|
|
537
571
|
},
|
|
538
572
|
overview: {
|
|
539
|
-
items:
|
|
540
|
-
viewportStyle:
|
|
541
|
-
navigationState:
|
|
542
|
-
beginNavigation:
|
|
543
|
-
close:
|
|
573
|
+
items: st,
|
|
574
|
+
viewportStyle: at,
|
|
575
|
+
navigationState: Je,
|
|
576
|
+
beginNavigation: wt,
|
|
577
|
+
close: D,
|
|
544
578
|
open: Ie
|
|
545
579
|
},
|
|
546
580
|
trash: {
|
|
547
|
-
open:
|
|
548
|
-
groups:
|
|
549
|
-
count:
|
|
550
|
-
now:
|
|
581
|
+
open: we,
|
|
582
|
+
groups: tt,
|
|
583
|
+
count: _e,
|
|
584
|
+
now: Ze,
|
|
551
585
|
canDeleteNow: !!r.controller.deleteTrashedNotePermanently,
|
|
552
|
-
close:
|
|
553
|
-
openDock:
|
|
554
|
-
backdropContextMenu:
|
|
555
|
-
restore:
|
|
556
|
-
deleteNow:
|
|
557
|
-
clearTopic:
|
|
586
|
+
close: k,
|
|
587
|
+
openDock: ee,
|
|
588
|
+
backdropContextMenu: Lt,
|
|
589
|
+
restore: yt,
|
|
590
|
+
deleteNow: xt,
|
|
591
|
+
clearTopic: Ct
|
|
558
592
|
},
|
|
559
593
|
contextMenu: {
|
|
560
594
|
state: T,
|
|
561
|
-
items:
|
|
562
|
-
position:
|
|
595
|
+
items: ne,
|
|
596
|
+
position: St,
|
|
563
597
|
close: () => d(null),
|
|
564
|
-
retarget:
|
|
598
|
+
retarget: Rt
|
|
565
599
|
},
|
|
566
600
|
editor: {
|
|
567
|
-
note:
|
|
568
|
-
draftBody:
|
|
569
|
-
draftColor:
|
|
570
|
-
setDraftBody:
|
|
571
|
-
setDraftColor:
|
|
572
|
-
close:
|
|
573
|
-
save:
|
|
601
|
+
note: be,
|
|
602
|
+
draftBody: ue,
|
|
603
|
+
draftColor: fe,
|
|
604
|
+
setDraftBody: pe,
|
|
605
|
+
setDraftColor: me,
|
|
606
|
+
close: F,
|
|
607
|
+
save: Nt
|
|
574
608
|
},
|
|
575
609
|
manualPaste: {
|
|
576
|
-
open: () => !!
|
|
577
|
-
text:
|
|
578
|
-
setText:
|
|
579
|
-
close:
|
|
580
|
-
confirm:
|
|
610
|
+
open: () => !!Z(),
|
|
611
|
+
text: q,
|
|
612
|
+
setText: G,
|
|
613
|
+
close: A,
|
|
614
|
+
confirm: _t
|
|
581
615
|
},
|
|
582
|
-
handleCloseRequest:
|
|
616
|
+
handleCloseRequest: dt
|
|
583
617
|
};
|
|
584
618
|
}
|
|
585
619
|
export {
|
|
586
|
-
|
|
620
|
+
co as useNotesOverlayModel
|
|
587
621
|
};
|