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