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