@skillre/dsh-plugin-sticky-wall 0.6.0 → 0.8.0
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/README.en.md +38 -15
- package/README.md +39 -18
- package/UNINSTALL.md +22 -7
- package/compatibility.json +83 -4
- package/lib/client.js +1174 -369
- package/lib/config.d.ts +18 -0
- package/lib/config.js +27 -0
- package/lib/frontmatter.d.ts +81 -0
- package/lib/frontmatter.js +440 -0
- package/lib/index.d.ts +9 -4
- package/lib/index.js +153 -36
- package/lib/layout.d.ts +27 -5
- package/lib/layout.js +82 -25
- package/lib/migrate.d.ts +53 -0
- package/lib/migrate.js +156 -0
- package/lib/store.d.ts +123 -68
- package/lib/store.js +305 -96
- package/lib/transport.d.ts +7 -4
- package/lib/transport.js +25 -4
- package/lib/types.d.ts +117 -7
- package/lib/types.js +38 -5
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +3 -3
- package/docs/PREVIEW.md +0 -39
package/lib/client.js
CHANGED
|
@@ -34,8 +34,15 @@ window.__ModuleLoader__.load({
|
|
|
34
34
|
var ENDPOINT = "skillre-sticky-wall/execute";
|
|
35
35
|
var PANEL_ID = "skillre-sticky-wall";
|
|
36
36
|
var LIMITS = Object.freeze({
|
|
37
|
-
/**
|
|
38
|
-
|
|
37
|
+
/**
|
|
38
|
+
* One note's body, in characters.
|
|
39
|
+
*
|
|
40
|
+
* 0.8.0 lifted the old 4000-character cap, because the body now lives in a
|
|
41
|
+
* plain `.md` file rather than a JSON record and a note is allowed to be a
|
|
42
|
+
* real document. This is a resource guard against a pathological file, not a
|
|
43
|
+
* product limit: at 200k characters a note is a short book.
|
|
44
|
+
*/
|
|
45
|
+
body: 2e5,
|
|
39
46
|
/** One note's title, in characters. */
|
|
40
47
|
title: 120,
|
|
41
48
|
/** A note's free-form tag list. */
|
|
@@ -45,7 +52,11 @@ window.__ModuleLoader__.load({
|
|
|
45
52
|
/** Live (non-archived) notes a wall may hold. */
|
|
46
53
|
notes: 400,
|
|
47
54
|
/** Note ids accepted in one request. */
|
|
48
|
-
bulk: 200
|
|
55
|
+
bulk: 200,
|
|
56
|
+
/** One note file's size on disk, in bytes; larger files are refused unread. */
|
|
57
|
+
fileBytes: 4 * 1024 * 1024,
|
|
58
|
+
/** Newest notes the agent `list` action returns. */
|
|
59
|
+
listLimit: 50
|
|
49
60
|
});
|
|
50
61
|
var COLORS = Object.freeze([
|
|
51
62
|
"yellow",
|
|
@@ -92,7 +103,16 @@ window.__ModuleLoader__.load({
|
|
|
92
103
|
return {
|
|
93
104
|
async list(includeArchived, sort, signal) {
|
|
94
105
|
const value = await call({ action: "list", includeArchived, sort }, signal);
|
|
95
|
-
return
|
|
106
|
+
return {
|
|
107
|
+
notes: Array.isArray(value?.notes) ? value.notes : [],
|
|
108
|
+
revision: typeof value?.revision === "number" ? value.revision : 0,
|
|
109
|
+
notesDir: typeof value?.notesDir === "string" ? value.notesDir : "",
|
|
110
|
+
domain: value?.domain ?? { name: "", version: 0 }
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
async revision(signal) {
|
|
114
|
+
const value = await call({ action: "revision" }, signal);
|
|
115
|
+
return typeof value?.revision === "number" ? value.revision : -1;
|
|
96
116
|
},
|
|
97
117
|
async create(input, signal, options) {
|
|
98
118
|
const value = await call(
|
|
@@ -142,13 +162,11 @@ window.__ModuleLoader__.load({
|
|
|
142
162
|
var zh = {
|
|
143
163
|
"nav": "\u4FBF\u7B7E\u5899",
|
|
144
164
|
"title": "\u4FBF\u7B7E\u5899",
|
|
145
|
-
"subtitle": "\u968F\u624B\u8BB0\u4E0B\u4E00\u95EA\u800C\u8FC7\u7684\u7075\u611F\uFF0C\u548C\u4E34\u65F6\u7684\u6D3B\u513F\uFF1B\u62D6\u4E00\u62D6\uFF0C\u628A\u5B83\u4EEC\u6446\u6210\u4F60\u81EA\u5DF1\u7684\u6837\u5B50\u3002",
|
|
146
165
|
"empty": "\u8FD8\u6CA1\u6709\u4FBF\u7B7E\u3002\u70B9\u300C\u65B0\u5EFA\u300D\u5199\u4E0B\u7B2C\u4E00\u6761\u3002",
|
|
147
166
|
"emptyArchived": "\u5F52\u6863\u533A\u662F\u7A7A\u7684\u3002",
|
|
148
167
|
"new": "\u65B0\u5EFA",
|
|
149
168
|
"save": "\u4FDD\u5B58",
|
|
150
169
|
"cancel": "\u53D6\u6D88",
|
|
151
|
-
"close": "\u5173\u95ED",
|
|
152
170
|
"edit": "\u7F16\u8F91",
|
|
153
171
|
"pin": "\u7F6E\u9876",
|
|
154
172
|
"unpin": "\u53D6\u6D88\u7F6E\u9876",
|
|
@@ -173,20 +191,13 @@ window.__ModuleLoader__.load({
|
|
|
173
191
|
"colorLabel": "\u989C\u8272",
|
|
174
192
|
"saveHint": "\u2318/Ctrl + Enter \u4FDD\u5B58 \xB7 Esc \u53D6\u6D88",
|
|
175
193
|
"count": "{count} \u5F20\u4FBF\u7B7E",
|
|
176
|
-
"countArchived": "{count} \u5F20\u5DF2\u5F52\u6863",
|
|
177
|
-
"updated": "\u66F4\u65B0\u4E8E {time}",
|
|
178
|
-
"created": "\u521B\u5EFA\u4E8E {time}",
|
|
179
194
|
"loading": "\u52A0\u8F7D\u4E2D\u2026",
|
|
180
|
-
"failed": "\u64CD\u4F5C\u5931\u8D25",
|
|
181
195
|
"noResults": "\u6CA1\u6709\u5339\u914D\u7684\u4FBF\u7B7E",
|
|
182
196
|
"retry": "\u91CD\u8BD5",
|
|
183
197
|
"tooLong": "\u5185\u5BB9\u592A\u957F\u4E86",
|
|
184
198
|
"emptyBody": "\u4FBF\u7B7E\u4E0D\u80FD\u4E3A\u7A7A",
|
|
185
199
|
"wallFull": "\u4FBF\u7B7E\u5899\u6EE1\u4E86\uFF0C\u8BF7\u5148\u5F52\u6863\u6216\u5220\u9664\u4E00\u4E9B\u4FBF\u7B7E",
|
|
186
|
-
"emptyTags": "\u8FD8\u6CA1\u6709\u6807\u7B7E",
|
|
187
|
-
"pinHint": "\u7F6E\u9876\u7684\u4FBF\u7B7E\u6392\u5728\u6700\u524D",
|
|
188
200
|
"more": "\u66F4\u591A",
|
|
189
|
-
"agentHint": "\u4E5F\u53EF\u4EE5\u8BA9\u6211\u5E2E\u4F60\u8BB0\uFF1A\u76F4\u63A5\u8BF4\u300C\u8BB0\u4E00\u4E0B\u2026\u2026\u300D",
|
|
190
201
|
"preview": "\u9884\u89C8",
|
|
191
202
|
"widthLabel": "\u5361\u7247\u5BBD\u5EA6",
|
|
192
203
|
"width_sm": "\u5C0F",
|
|
@@ -202,26 +213,64 @@ window.__ModuleLoader__.load({
|
|
|
202
213
|
"zoomIn": "\u653E\u5927",
|
|
203
214
|
"zoomOut": "\u7F29\u5C0F",
|
|
204
215
|
"zoomReset": "\u91CD\u7F6E\u89C6\u56FE",
|
|
205
|
-
"dragHint": "\u62D6\u52A8\u5361\u7247\u6446\u653E\u4F4D\u7F6E\uFF0C\u2318/Ctrl + \u6EDA\u8F6E\u7F29\u653E",
|
|
206
|
-
"markdownHint": "\u6B63\u6587\u652F\u6301 Markdown\uFF1A\u6807\u9898\u3001\u5217\u8868\u3001\u7C97\u4F53\u3001\u4EE3\u7801\u5757\u3001\u94FE\u63A5\u3001\u8868\u683C",
|
|
207
216
|
"greetMorning": "\u65E9\u4E0A\u597D\uFF0C\u4ECA\u5929\u60F3\u8BB0\u70B9\u4EC0\u4E48\uFF1F",
|
|
208
217
|
"greetAfternoon": "\u4E0B\u5348\u597D\uFF0C\u6709\u4EC0\u4E48\u60F3\u7559\u4E0B\u6765\u7684\uFF1F",
|
|
209
218
|
"greetEvening": "\u665A\u4E0A\u597D\uFF0C\u6536\u4E00\u4E0B\u4ECA\u5929\u7684\u788E\u7247\u3002",
|
|
210
219
|
"greetNight": "\u591C\u6DF1\u4E86\uFF0C\u60F3\u5230\u4EC0\u4E48\u5C31\u5148\u8BB0\u4E0B\u6765\u3002",
|
|
211
220
|
"centreTally": "{count} \u5F20\u4FBF\u7B7E \xB7 {archived} \u5F20\u5DF2\u5F52\u6863",
|
|
212
221
|
"capturePlaceholder": "\u8BB0\u4E0B\u4E00\u4E2A\u7075\u611F\uFF0C\u6216\u7C98\u8D34\u4E00\u4E2A\u94FE\u63A5",
|
|
213
|
-
"captureGo": "\u8BB0\u4E0B"
|
|
222
|
+
"captureGo": "\u8BB0\u4E0B",
|
|
223
|
+
// The Markdown body editor and its toolbar. The toolbar groups are ordered
|
|
224
|
+
// from structure to inline so the buttons read as a document outline.
|
|
225
|
+
"editorTitle": "\u7F16\u8F91\u6B63\u6587",
|
|
226
|
+
"editorPreview": "\u9884\u89C8",
|
|
227
|
+
"editorSource": "\u6E90\u7801",
|
|
228
|
+
"editorSaved": "\u5DF2\u4FDD\u5B58",
|
|
229
|
+
"editorSaving": "\u4FDD\u5B58\u4E2D\u2026",
|
|
230
|
+
"editorUnsaved": "\u672A\u4FDD\u5B58",
|
|
231
|
+
"editorSaveFailed": "\u4FDD\u5B58\u5931\u8D25\uFF1A{message}",
|
|
232
|
+
"toolbarStructure": "\u7ED3\u6784",
|
|
233
|
+
"toolbarList": "\u5217\u8868",
|
|
234
|
+
"toolbarTable": "\u8868\u683C",
|
|
235
|
+
"toolbarInline": "\u884C\u5185",
|
|
236
|
+
"toolbarOther": "\u5176\u4ED6",
|
|
237
|
+
"mdH1": "\u6807\u9898 1",
|
|
238
|
+
"mdH2": "\u6807\u9898 2",
|
|
239
|
+
"mdH3": "\u6807\u9898 3",
|
|
240
|
+
"mdQuote": "\u5F15\u7528",
|
|
241
|
+
"mdHr": "\u5206\u5272\u7EBF",
|
|
242
|
+
"mdCodeBlock": "\u4EE3\u7801\u5757",
|
|
243
|
+
"mdBullet": "\u65E0\u5E8F\u5217\u8868",
|
|
244
|
+
"mdOrdered": "\u6709\u5E8F\u5217\u8868",
|
|
245
|
+
"mdTodo": "\u5F85\u529E",
|
|
246
|
+
"mdTable": "\u8868\u683C",
|
|
247
|
+
"mdBold": "\u7C97\u4F53",
|
|
248
|
+
"mdItalic": "\u659C\u4F53",
|
|
249
|
+
"mdStrike": "\u5220\u9664\u7EBF",
|
|
250
|
+
"mdCode": "\u884C\u5185\u4EE3\u7801",
|
|
251
|
+
"mdLink": "\u94FE\u63A5",
|
|
252
|
+
"mdTimestamp": "\u5F53\u524D\u65F6\u95F4",
|
|
253
|
+
// File-level metadata the wall surfaces instead of hiding: a note written by
|
|
254
|
+
// a newer DSH line may carry fields this build cannot honour.
|
|
255
|
+
"metaErrorBadge": "\u5143\u6570\u636E\u5F02\u5E38",
|
|
256
|
+
"metaErrorNewer": "\u7531\u8F83\u65B0\u7248\u672C\u5199\u5165",
|
|
257
|
+
"revealPath": "\u590D\u5236\u6587\u4EF6\u8DEF\u5F84",
|
|
258
|
+
"pathCopied": "\u8DEF\u5F84\u5DF2\u590D\u5236",
|
|
259
|
+
"longNote": "\u957F\u6587",
|
|
260
|
+
// The leave-guard for an unsaved draft: an explicit keep-or-discard choice,
|
|
261
|
+
// never a silent loss.
|
|
262
|
+
"discardDraft": "\u653E\u5F03\u672A\u4FDD\u5B58\u7684\u5185\u5BB9\uFF1F",
|
|
263
|
+
"keepEditing": "\u7EE7\u7EED\u7F16\u8F91",
|
|
264
|
+
"discard": "\u653E\u5F03"
|
|
214
265
|
};
|
|
215
266
|
var en = {
|
|
216
267
|
"nav": "Notes",
|
|
217
268
|
"title": "Sticky wall",
|
|
218
|
-
"subtitle": "Jot down a passing idea or a piece of temporary work \u2014 then drag the cards into your own arrangement.",
|
|
219
269
|
"empty": 'No notes yet. Hit "New" to write the first one.',
|
|
220
270
|
"emptyArchived": "Nothing archived yet.",
|
|
221
271
|
"new": "New",
|
|
222
272
|
"save": "Save",
|
|
223
273
|
"cancel": "Cancel",
|
|
224
|
-
"close": "Close",
|
|
225
274
|
"edit": "Edit",
|
|
226
275
|
"pin": "Pin",
|
|
227
276
|
"unpin": "Unpin",
|
|
@@ -246,20 +295,13 @@ window.__ModuleLoader__.load({
|
|
|
246
295
|
"colorLabel": "Color",
|
|
247
296
|
"saveHint": "\u2318/Ctrl + Enter to save \xB7 Esc to cancel",
|
|
248
297
|
"count": "{count} notes",
|
|
249
|
-
"countArchived": "{count} archived",
|
|
250
|
-
"updated": "Updated {time}",
|
|
251
|
-
"created": "Created {time}",
|
|
252
298
|
"loading": "Loading\u2026",
|
|
253
|
-
"failed": "Something went wrong",
|
|
254
299
|
"noResults": "No matching notes",
|
|
255
300
|
"retry": "Retry",
|
|
256
301
|
"tooLong": "Too long",
|
|
257
302
|
"emptyBody": "A note cannot be empty",
|
|
258
303
|
"wallFull": "The wall is full \u2014 archive or delete a note first",
|
|
259
|
-
"emptyTags": "No tags yet",
|
|
260
|
-
"pinHint": "Pinned notes stay on top",
|
|
261
304
|
"more": "More",
|
|
262
|
-
"agentHint": 'You can also ask me to note it: say "note that \u2026"',
|
|
263
305
|
"preview": "Preview",
|
|
264
306
|
"widthLabel": "Card width",
|
|
265
307
|
"width_sm": "S",
|
|
@@ -275,19 +317,53 @@ window.__ModuleLoader__.load({
|
|
|
275
317
|
"zoomIn": "Zoom in",
|
|
276
318
|
"zoomOut": "Zoom out",
|
|
277
319
|
"zoomReset": "Reset view",
|
|
278
|
-
"dragHint": "Drag a card to place it \xB7 \u2318/Ctrl + wheel to zoom",
|
|
279
|
-
"markdownHint": "The body renders Markdown: headings, lists, bold, code blocks, links, tables",
|
|
280
320
|
"greetMorning": "Good morning \u2014 what is worth keeping today?",
|
|
281
321
|
"greetAfternoon": "Good afternoon \u2014 anything to jot down?",
|
|
282
322
|
"greetEvening": "Good evening \u2014 collect the loose pieces.",
|
|
283
323
|
"greetNight": "Late night \u2014 capture it before it goes.",
|
|
284
324
|
"centreTally": "{count} notes \xB7 {archived} archived",
|
|
285
325
|
"capturePlaceholder": "Jot an idea, or paste a link",
|
|
286
|
-
"captureGo": "Capture"
|
|
326
|
+
"captureGo": "Capture",
|
|
327
|
+
"editorTitle": "Edit body",
|
|
328
|
+
"editorPreview": "Preview",
|
|
329
|
+
"editorSource": "Source",
|
|
330
|
+
"editorSaved": "Saved",
|
|
331
|
+
"editorSaving": "Saving\u2026",
|
|
332
|
+
"editorUnsaved": "Unsaved",
|
|
333
|
+
"editorSaveFailed": "Save failed: {message}",
|
|
334
|
+
"toolbarStructure": "Structure",
|
|
335
|
+
"toolbarList": "Lists",
|
|
336
|
+
"toolbarTable": "Table",
|
|
337
|
+
"toolbarInline": "Inline",
|
|
338
|
+
"toolbarOther": "Other",
|
|
339
|
+
"mdH1": "Heading 1",
|
|
340
|
+
"mdH2": "Heading 2",
|
|
341
|
+
"mdH3": "Heading 3",
|
|
342
|
+
"mdQuote": "Quote",
|
|
343
|
+
"mdHr": "Divider",
|
|
344
|
+
"mdCodeBlock": "Code block",
|
|
345
|
+
"mdBullet": "Bullet list",
|
|
346
|
+
"mdOrdered": "Ordered list",
|
|
347
|
+
"mdTodo": "To-do",
|
|
348
|
+
"mdTable": "Table",
|
|
349
|
+
"mdBold": "Bold",
|
|
350
|
+
"mdItalic": "Italic",
|
|
351
|
+
"mdStrike": "Strikethrough",
|
|
352
|
+
"mdCode": "Inline code",
|
|
353
|
+
"mdLink": "Link",
|
|
354
|
+
"mdTimestamp": "Now",
|
|
355
|
+
"metaErrorBadge": "Metadata issue",
|
|
356
|
+
"metaErrorNewer": "Written by a newer version",
|
|
357
|
+
"revealPath": "Copy file path",
|
|
358
|
+
"pathCopied": "Path copied",
|
|
359
|
+
"longNote": "Long note",
|
|
360
|
+
"discardDraft": "Discard unsaved changes?",
|
|
361
|
+
"keepEditing": "Keep editing",
|
|
362
|
+
"discard": "Discard"
|
|
287
363
|
};
|
|
288
364
|
|
|
289
365
|
// src/client/view.tsx
|
|
290
|
-
var
|
|
366
|
+
var import_react2 = require("react");
|
|
291
367
|
|
|
292
368
|
// src/layout.ts
|
|
293
369
|
var GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5));
|
|
@@ -386,22 +462,38 @@ window.__ModuleLoader__.load({
|
|
|
386
462
|
const sin = Math.sin(radians);
|
|
387
463
|
return { width: width * cos + height * sin, height: height * cos + width * sin };
|
|
388
464
|
}
|
|
389
|
-
function intersectsReserve(box, reserve = CENTRE_RESERVE) {
|
|
390
|
-
const clear = clearsReserve(box, reserve);
|
|
391
|
-
return !clear;
|
|
392
|
-
}
|
|
393
465
|
var RESERVE_EPSILON = 0.05;
|
|
394
466
|
function clearsReserve(box, reserve) {
|
|
395
|
-
return !(box.x < reserve.halfWidth - RESERVE_EPSILON && box.x + box.width > -reserve.halfWidth + RESERVE_EPSILON && box.y < reserve.halfHeight - RESERVE_EPSILON && box.y + box.height > -reserve.halfHeight + RESERVE_EPSILON);
|
|
467
|
+
return !(box.x < reserve.x + reserve.halfWidth - RESERVE_EPSILON && box.x + box.width > reserve.x - reserve.halfWidth + RESERVE_EPSILON && box.y < reserve.y + reserve.halfHeight - RESERVE_EPSILON && box.y + box.height > reserve.y - reserve.halfHeight + RESERVE_EPSILON);
|
|
468
|
+
}
|
|
469
|
+
function normalizeReserve(raw) {
|
|
470
|
+
const cap = LAYOUT_LIMITS.coord / 4;
|
|
471
|
+
const clampHalf = (value) => {
|
|
472
|
+
const number = Number(value);
|
|
473
|
+
if (!Number.isFinite(number) || number <= 0) return 0;
|
|
474
|
+
return Math.min(cap, number);
|
|
475
|
+
};
|
|
476
|
+
const clampCoord = (value) => {
|
|
477
|
+
const number = Number(value);
|
|
478
|
+
if (!Number.isFinite(number)) return 0;
|
|
479
|
+
return Math.min(LAYOUT_LIMITS.coord, Math.max(-LAYOUT_LIMITS.coord, number));
|
|
480
|
+
};
|
|
481
|
+
return {
|
|
482
|
+
x: clampCoord(raw?.x ?? 0),
|
|
483
|
+
y: clampCoord(raw?.y ?? 0),
|
|
484
|
+
halfWidth: clampHalf(raw?.halfWidth),
|
|
485
|
+
halfHeight: clampHalf(raw?.halfHeight)
|
|
486
|
+
};
|
|
396
487
|
}
|
|
397
488
|
function pushOutOfReserve(note, layout, reserve = CENTRE_RESERVE) {
|
|
489
|
+
const rect = normalizeReserve(reserve);
|
|
398
490
|
const box = footprintOf(note, layout);
|
|
399
|
-
if (
|
|
491
|
+
if (clearsReserve(box, rect)) return layout;
|
|
400
492
|
const moves = [
|
|
401
|
-
{ dx: -
|
|
402
|
-
{ dx:
|
|
403
|
-
{ dx: 0, dy: -
|
|
404
|
-
{ dx: 0, dy:
|
|
493
|
+
{ dx: rect.x - rect.halfWidth - (box.x + box.width), dy: 0 },
|
|
494
|
+
{ dx: rect.x + rect.halfWidth - box.x, dy: 0 },
|
|
495
|
+
{ dx: 0, dy: rect.y - rect.halfHeight - (box.y + box.height) },
|
|
496
|
+
{ dx: 0, dy: rect.y + rect.halfHeight - box.y }
|
|
405
497
|
];
|
|
406
498
|
let best = moves[0];
|
|
407
499
|
for (const move of moves) {
|
|
@@ -517,6 +609,56 @@ window.__ModuleLoader__.load({
|
|
|
517
609
|
}
|
|
518
610
|
return blocks;
|
|
519
611
|
}
|
|
612
|
+
function stripInlineMarkdown(text) {
|
|
613
|
+
let out = text;
|
|
614
|
+
out = out.replace(/!\[([^\]]*)\]\([^)\s]*\)/g, "$1");
|
|
615
|
+
out = out.replace(/\[([^\]]*)\]\([^)\s]*\)/g, "$1");
|
|
616
|
+
out = out.replace(/`+([^`]*)`+/g, "$1");
|
|
617
|
+
out = out.replace(/\*\*\*([^*]+)\*\*\*/g, "$1");
|
|
618
|
+
out = out.replace(/\*\*([^*]+)\*\*/g, "$1");
|
|
619
|
+
out = out.replace(/\*([^*]+)\*/g, "$1");
|
|
620
|
+
out = out.replace(/~~([^~]+)~~/g, "$1");
|
|
621
|
+
out = out.replace(/(^|[^A-Za-z0-9])__([^_]+)__(?![A-Za-z0-9])/g, "$1$2");
|
|
622
|
+
out = out.replace(/(^|[^A-Za-z0-9])_([^_]+)_(?![A-Za-z0-9])/g, "$1$2");
|
|
623
|
+
return out;
|
|
624
|
+
}
|
|
625
|
+
function flattenWhitespace(text) {
|
|
626
|
+
return text.replace(/\s+/g, " ").trim();
|
|
627
|
+
}
|
|
628
|
+
function truncateDigest(text, limit) {
|
|
629
|
+
if (text.length <= limit) return text;
|
|
630
|
+
let cut = limit;
|
|
631
|
+
const code = text.charCodeAt(cut - 1);
|
|
632
|
+
if (code >= 55296 && code <= 56319) cut -= 1;
|
|
633
|
+
return `${text.slice(0, cut).replace(/\s+$/, "")}\u2026`;
|
|
634
|
+
}
|
|
635
|
+
function plainTextSummary(source, max = 90) {
|
|
636
|
+
const limit = Number.isFinite(max) ? Math.floor(max) : 0;
|
|
637
|
+
if (limit <= 0) return "";
|
|
638
|
+
const raw = typeof source === "string" ? source : "";
|
|
639
|
+
let blocks;
|
|
640
|
+
try {
|
|
641
|
+
blocks = parseBlocks(raw);
|
|
642
|
+
} catch {
|
|
643
|
+
return truncateDigest(flattenWhitespace(stripInlineMarkdown(raw)), limit);
|
|
644
|
+
}
|
|
645
|
+
for (const block of blocks) {
|
|
646
|
+
if (block.kind === "rule") continue;
|
|
647
|
+
let candidate;
|
|
648
|
+
if (block.kind === "code") {
|
|
649
|
+
candidate = block.text.split("\n")[0] ?? "";
|
|
650
|
+
} else if (block.kind === "list") {
|
|
651
|
+
candidate = (block.items[0] ?? "").replace(/^\[[ xX]\]\s*/, "");
|
|
652
|
+
} else if (block.kind === "table") {
|
|
653
|
+
candidate = block.header.join(" ");
|
|
654
|
+
} else {
|
|
655
|
+
candidate = block.text;
|
|
656
|
+
}
|
|
657
|
+
const digest = flattenWhitespace(stripInlineMarkdown(candidate));
|
|
658
|
+
if (digest !== "") return truncateDigest(digest, limit);
|
|
659
|
+
}
|
|
660
|
+
return "";
|
|
661
|
+
}
|
|
520
662
|
function safeHref(raw) {
|
|
521
663
|
const value = raw.trim();
|
|
522
664
|
if (value === "") return void 0;
|
|
@@ -614,6 +756,502 @@ window.__ModuleLoader__.load({
|
|
|
614
756
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "skw-md", "data-compact": compact, children: blocks.map((block, index) => renderBlock(block, `b${index}`)) });
|
|
615
757
|
}
|
|
616
758
|
|
|
759
|
+
// src/client/editor.tsx
|
|
760
|
+
var import_react = require("react");
|
|
761
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
762
|
+
var INDENT = " ";
|
|
763
|
+
var MIN_HEIGHT_PX = 88;
|
|
764
|
+
var VIEWPORT_SHARE = 0.6;
|
|
765
|
+
function clampRange(value, start, end) {
|
|
766
|
+
const length = value.length;
|
|
767
|
+
const from = Math.min(Math.max(0, start), length);
|
|
768
|
+
const to = Math.min(Math.max(from, end), length);
|
|
769
|
+
return { start: from, end: to };
|
|
770
|
+
}
|
|
771
|
+
function lineBounds(value, position) {
|
|
772
|
+
const at = Math.min(Math.max(0, position), value.length);
|
|
773
|
+
const from = value.lastIndexOf("\n", at - 1) + 1;
|
|
774
|
+
const next = value.indexOf("\n", at);
|
|
775
|
+
return { from, to: next === -1 ? value.length : next };
|
|
776
|
+
}
|
|
777
|
+
function touchedLines(value, start, end) {
|
|
778
|
+
const first = lineBounds(value, start);
|
|
779
|
+
const tail = end > start && value[end - 1] === "\n" ? end - 1 : end;
|
|
780
|
+
const last = lineBounds(value, tail);
|
|
781
|
+
return { from: first.from, to: last.to };
|
|
782
|
+
}
|
|
783
|
+
function rewriteLines(value, start, end, rewrite) {
|
|
784
|
+
const range = touchedLines(value, start, end);
|
|
785
|
+
const lines = value.slice(range.from, range.to).split("\n");
|
|
786
|
+
const spans = [];
|
|
787
|
+
const out = [];
|
|
788
|
+
let consumed = 0;
|
|
789
|
+
lines.forEach((line, index) => {
|
|
790
|
+
const next = rewrite(line, index);
|
|
791
|
+
const from = range.from + consumed;
|
|
792
|
+
spans.push({ from, to: from + line.length, delta: next.length - line.length });
|
|
793
|
+
consumed += line.length + 1;
|
|
794
|
+
out.push(next);
|
|
795
|
+
});
|
|
796
|
+
const collapsed = start === end;
|
|
797
|
+
const mapPosition = (position) => {
|
|
798
|
+
let shift = 0;
|
|
799
|
+
for (const span of spans) {
|
|
800
|
+
if (position > span.to) {
|
|
801
|
+
shift += span.delta;
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
if (position >= span.from) {
|
|
805
|
+
shift += position === span.from ? collapsed ? Math.max(span.delta, 0) : 0 : span.delta;
|
|
806
|
+
}
|
|
807
|
+
break;
|
|
808
|
+
}
|
|
809
|
+
return position + shift;
|
|
810
|
+
};
|
|
811
|
+
const nextValue = value.slice(0, range.from) + out.join("\n") + value.slice(range.to);
|
|
812
|
+
const caret = clampRange(nextValue, mapPosition(start), mapPosition(end));
|
|
813
|
+
return { value: nextValue, start: caret.start, end: caret.end };
|
|
814
|
+
}
|
|
815
|
+
function leadingSpace(line) {
|
|
816
|
+
return /^[ \t]*/.exec(line)?.[0] ?? "";
|
|
817
|
+
}
|
|
818
|
+
var HEADING_MARKER = /^([ \t]*)(#{1,4})[ \t]+/;
|
|
819
|
+
var TODO_MARKER = /^([ \t]*)([-*+])[ \t]+\[[ xX]\][ \t]+/;
|
|
820
|
+
var ORDERED_MARKER = /^([ \t]*)(\d{1,3})([.)])[ \t]+/;
|
|
821
|
+
var BULLET_MARKER = /^([ \t]*)([-*+])[ \t]+/;
|
|
822
|
+
var QUOTE_MARKER = /^([ \t]*)>[ \t]?/;
|
|
823
|
+
function stripBlockMarker(line) {
|
|
824
|
+
for (const marker of [HEADING_MARKER, TODO_MARKER, ORDERED_MARKER, BULLET_MARKER, QUOTE_MARKER]) {
|
|
825
|
+
const match = marker.exec(line);
|
|
826
|
+
if (match !== null) return line.slice(match[0].length);
|
|
827
|
+
}
|
|
828
|
+
return line.slice(leadingSpace(line).length);
|
|
829
|
+
}
|
|
830
|
+
function wrapSelection(ctx, open, close) {
|
|
831
|
+
const selected = ctx.value.slice(ctx.start, ctx.end);
|
|
832
|
+
const inner = ctx.start + open.length;
|
|
833
|
+
return {
|
|
834
|
+
value: `${ctx.value.slice(0, ctx.start)}${open}${selected}${close}${ctx.value.slice(ctx.end)}`,
|
|
835
|
+
// An empty selection leaves the caret BETWEEN the markers, which is where
|
|
836
|
+
// the user is about to type; a selection stays selected so it can be
|
|
837
|
+
// wrapped again or typed over.
|
|
838
|
+
start: inner,
|
|
839
|
+
end: inner + selected.length
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function applyHeading(level) {
|
|
843
|
+
return (ctx) => rewriteLines(ctx.value, ctx.start, ctx.end, (line) => {
|
|
844
|
+
const indent = leadingSpace(line);
|
|
845
|
+
return `${indent}${"#".repeat(level)} ${stripBlockMarker(line)}`;
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
function applyList(kind) {
|
|
849
|
+
return (ctx) => {
|
|
850
|
+
let nextNumber = null;
|
|
851
|
+
return rewriteLines(ctx.value, ctx.start, ctx.end, (line) => {
|
|
852
|
+
const indent = leadingSpace(line);
|
|
853
|
+
const body = stripBlockMarker(line);
|
|
854
|
+
if (kind === "bullet") return `${indent}- ${body}`;
|
|
855
|
+
if (kind === "todo") return `${indent}- [ ] ${body}`;
|
|
856
|
+
if (nextNumber === null) {
|
|
857
|
+
const existing = ORDERED_MARKER.exec(line);
|
|
858
|
+
nextNumber = existing === null ? 1 : Number(existing[2]);
|
|
859
|
+
}
|
|
860
|
+
const number = nextNumber;
|
|
861
|
+
nextNumber += 1;
|
|
862
|
+
return `${indent}${number}. ${body}`;
|
|
863
|
+
});
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function applyQuote(ctx) {
|
|
867
|
+
const range = touchedLines(ctx.value, ctx.start, ctx.end);
|
|
868
|
+
const lines = ctx.value.slice(range.from, range.to).split("\n");
|
|
869
|
+
const quoted = lines.every((line) => line.trim() === "" || QUOTE_MARKER.test(line));
|
|
870
|
+
return rewriteLines(ctx.value, ctx.start, ctx.end, (line) => {
|
|
871
|
+
if (line.trim() === "") return line;
|
|
872
|
+
if (!quoted) return QUOTE_MARKER.test(line) ? line : `> ${line}`;
|
|
873
|
+
const match = QUOTE_MARKER.exec(line);
|
|
874
|
+
return match === null ? line : `${match[1] ?? ""}${line.slice(match[0].length)}`;
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
function insertBlock(ctx, block, caretInBlock) {
|
|
878
|
+
const before = ctx.value.slice(0, ctx.start);
|
|
879
|
+
const after = ctx.value.slice(ctx.end);
|
|
880
|
+
const lead = before === "" || before.endsWith("\n") ? "" : "\n";
|
|
881
|
+
const trail = after.startsWith("\n") ? "" : "\n";
|
|
882
|
+
const position = before.length + lead.length;
|
|
883
|
+
return {
|
|
884
|
+
value: `${before}${lead}${block}${trail}${after}`,
|
|
885
|
+
start: position + caretInBlock,
|
|
886
|
+
end: position + caretInBlock
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
function tableSkeleton(locale) {
|
|
890
|
+
const cell = (index) => locale === "zh" ? `\u5217 ${index}` : `Column ${index}`;
|
|
891
|
+
const header = `| ${cell(1)} | ${cell(2)} | ${cell(3)} |`;
|
|
892
|
+
const divider = "| --- | --- | --- |";
|
|
893
|
+
const empty = "| | | |";
|
|
894
|
+
const rows = [header, divider, empty, empty];
|
|
895
|
+
return {
|
|
896
|
+
block: rows.join("\n"),
|
|
897
|
+
// Park the caret in the first empty body cell: the header labels are
|
|
898
|
+
// placeholders to overwrite, the body is what the user came to fill in.
|
|
899
|
+
caretInBlock: header.length + 1 + divider.length + 1 + 2
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
function pad2(value) {
|
|
903
|
+
return String(value).padStart(2, "0");
|
|
904
|
+
}
|
|
905
|
+
function stamp(date) {
|
|
906
|
+
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ${pad2(date.getHours())}:${pad2(date.getMinutes())}`;
|
|
907
|
+
}
|
|
908
|
+
function insertStamp(ctx) {
|
|
909
|
+
const text = stamp(/* @__PURE__ */ new Date());
|
|
910
|
+
const position = ctx.start + text.length;
|
|
911
|
+
return {
|
|
912
|
+
value: `${ctx.value.slice(0, ctx.start)}${text}${ctx.value.slice(ctx.end)}`,
|
|
913
|
+
start: position,
|
|
914
|
+
end: position
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
function insertCodeBlock(ctx) {
|
|
918
|
+
const body = ctx.value.slice(ctx.start, ctx.end);
|
|
919
|
+
const block = `\`\`\`
|
|
920
|
+
${body}
|
|
921
|
+
\`\`\``;
|
|
922
|
+
return insertBlock(ctx, block, 4 + body.length);
|
|
923
|
+
}
|
|
924
|
+
var TOOLBAR_LABEL = { zh: "\u7F16\u8F91\u5DE5\u5177\u680F", en: "Formatting toolbar" };
|
|
925
|
+
var TOOLBAR = [
|
|
926
|
+
{
|
|
927
|
+
id: "structure",
|
|
928
|
+
zh: "\u7ED3\u6784",
|
|
929
|
+
en: "Structure",
|
|
930
|
+
actions: [
|
|
931
|
+
{ id: "h1", zh: "\u4E00\u7EA7\u6807\u9898", en: "Heading 1", glyph: "H1", run: applyHeading(1) },
|
|
932
|
+
{ id: "h2", zh: "\u4E8C\u7EA7\u6807\u9898", en: "Heading 2", glyph: "H2", run: applyHeading(2) },
|
|
933
|
+
{ id: "h3", zh: "\u4E09\u7EA7\u6807\u9898", en: "Heading 3", glyph: "H3", run: applyHeading(3) },
|
|
934
|
+
{ id: "quote", zh: "\u5F15\u7528", en: "Blockquote", glyph: "\u275D", run: applyQuote },
|
|
935
|
+
{ id: "rule", zh: "\u5206\u5272\u7EBF", en: "Divider", glyph: "\u2014", run: (ctx) => insertBlock(ctx, "---", 4) },
|
|
936
|
+
{ id: "code-block", zh: "\u4EE3\u7801\u5757", en: "Code block", glyph: "{ }", run: insertCodeBlock }
|
|
937
|
+
]
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
id: "lists",
|
|
941
|
+
zh: "\u5217\u8868",
|
|
942
|
+
en: "Lists",
|
|
943
|
+
actions: [
|
|
944
|
+
{ id: "bullet", zh: "\u65E0\u5E8F\u5217\u8868", en: "Bullet list", glyph: "\u2022", run: applyList("bullet") },
|
|
945
|
+
{ id: "ordered", zh: "\u6709\u5E8F\u5217\u8868", en: "Numbered list", glyph: "1.", run: applyList("ordered") },
|
|
946
|
+
{ id: "todo", zh: "\u5F85\u529E", en: "Todo", glyph: "\u2611", run: applyList("todo") }
|
|
947
|
+
]
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
id: "table",
|
|
951
|
+
zh: "\u8868\u683C",
|
|
952
|
+
en: "Table",
|
|
953
|
+
actions: [
|
|
954
|
+
{
|
|
955
|
+
id: "table",
|
|
956
|
+
zh: "\u63D2\u5165\u8868\u683C",
|
|
957
|
+
en: "Insert table",
|
|
958
|
+
glyph: "\u25A6",
|
|
959
|
+
run: (ctx) => {
|
|
960
|
+
const { block, caretInBlock } = tableSkeleton(ctx.locale);
|
|
961
|
+
return insertBlock(ctx, block, caretInBlock);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
]
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
id: "inline",
|
|
968
|
+
zh: "\u884C\u5185",
|
|
969
|
+
en: "Inline",
|
|
970
|
+
actions: [
|
|
971
|
+
{ id: "bold", zh: "\u7C97\u4F53", en: "Bold", glyph: "B", style: "bold", run: (ctx) => wrapSelection(ctx, "**", "**") },
|
|
972
|
+
{ id: "italic", zh: "\u659C\u4F53", en: "Italic", glyph: "I", style: "italic", run: (ctx) => wrapSelection(ctx, "_", "_") },
|
|
973
|
+
{ id: "strike", zh: "\u5220\u9664\u7EBF", en: "Strikethrough", glyph: "S", style: "strike", run: (ctx) => wrapSelection(ctx, "~~", "~~") },
|
|
974
|
+
{ id: "code", zh: "\u884C\u5185\u4EE3\u7801", en: "Inline code", glyph: "<>", run: (ctx) => wrapSelection(ctx, "`", "`") },
|
|
975
|
+
{ id: "link", zh: "\u94FE\u63A5", en: "Link", glyph: "\u26D3", run: (ctx) => wrapSelection(ctx, "[", "](https://)") }
|
|
976
|
+
]
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
id: "other",
|
|
980
|
+
zh: "\u5176\u4ED6",
|
|
981
|
+
en: "Other",
|
|
982
|
+
actions: [{ id: "timestamp", zh: "\u65E5\u671F\u65F6\u95F4", en: "Date and time", glyph: "\u231A", run: insertStamp }]
|
|
983
|
+
}
|
|
984
|
+
];
|
|
985
|
+
function indentSelection(value, start, end, direction) {
|
|
986
|
+
return rewriteLines(value, start, end, (line) => {
|
|
987
|
+
if (direction === 1) return `${INDENT}${line}`;
|
|
988
|
+
if (line.startsWith(INDENT)) return line.slice(INDENT.length);
|
|
989
|
+
if (line.startsWith(" ")) return line.slice(1);
|
|
990
|
+
return line.replace(/^ {1,2}/, "");
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
var CONTINUE_TODO = /^([ \t]*)([-*+])[ \t]+\[[ xX]\][ \t]+/;
|
|
994
|
+
var CONTINUE_BULLET = /^([ \t]*)([-*+])[ \t]+/;
|
|
995
|
+
var CONTINUE_ORDERED = /^([ \t]*)(\d{1,3})([.)])[ \t]+/;
|
|
996
|
+
function continueList(value, start, end) {
|
|
997
|
+
const line = lineBounds(value, start);
|
|
998
|
+
const text = value.slice(line.from, line.to);
|
|
999
|
+
const todo = CONTINUE_TODO.exec(text);
|
|
1000
|
+
const bullet = todo === null ? CONTINUE_BULLET.exec(text) : null;
|
|
1001
|
+
const ordered = todo === null && bullet === null ? CONTINUE_ORDERED.exec(text) : null;
|
|
1002
|
+
const marker = (todo ?? bullet ?? ordered)?.[0];
|
|
1003
|
+
if (marker === void 0) return null;
|
|
1004
|
+
if (start - line.from < marker.length) return null;
|
|
1005
|
+
const body = text.slice(marker.length);
|
|
1006
|
+
if (body.trim() === "") {
|
|
1007
|
+
return { value: value.slice(0, line.from) + value.slice(line.to), start: line.from, end: line.from };
|
|
1008
|
+
}
|
|
1009
|
+
const nextMarker = todo !== null ? `${todo[1] ?? ""}${todo[2] ?? "-"} [ ] ` : bullet !== null ? `${bullet[1] ?? ""}${bullet[2] ?? "-"} ` : `${ordered?.[1] ?? ""}${Number(ordered?.[2] ?? "1") + 1}${ordered?.[3] ?? "."} `;
|
|
1010
|
+
const insert = `
|
|
1011
|
+
${nextMarker}`;
|
|
1012
|
+
const caret = start + insert.length;
|
|
1013
|
+
return { value: value.slice(0, start) + insert + value.slice(end), start: caret, end: caret };
|
|
1014
|
+
}
|
|
1015
|
+
function MarkdownEditor(props) {
|
|
1016
|
+
const {
|
|
1017
|
+
value,
|
|
1018
|
+
onChange,
|
|
1019
|
+
onSave,
|
|
1020
|
+
onEscape,
|
|
1021
|
+
maxLength,
|
|
1022
|
+
placeholder,
|
|
1023
|
+
label,
|
|
1024
|
+
toolbar = true,
|
|
1025
|
+
autoFocus = true,
|
|
1026
|
+
disabled = false,
|
|
1027
|
+
locale = "zh"
|
|
1028
|
+
} = props;
|
|
1029
|
+
const areaRef = (0, import_react.useRef)(null);
|
|
1030
|
+
const composing = (0, import_react.useRef)(false);
|
|
1031
|
+
const justEnded = (0, import_react.useRef)(false);
|
|
1032
|
+
const tabEscape = (0, import_react.useRef)(false);
|
|
1033
|
+
const pending = (0, import_react.useRef)(null);
|
|
1034
|
+
const guarded = (0, import_react.useCallback)((event) => {
|
|
1035
|
+
const native = event.nativeEvent;
|
|
1036
|
+
return composing.current || justEnded.current || native.isComposing || native.keyCode === 229;
|
|
1037
|
+
}, []);
|
|
1038
|
+
(0, import_react.useEffect)(() => {
|
|
1039
|
+
const node = areaRef.current;
|
|
1040
|
+
if (node === null) return;
|
|
1041
|
+
const open = () => {
|
|
1042
|
+
composing.current = true;
|
|
1043
|
+
justEnded.current = false;
|
|
1044
|
+
};
|
|
1045
|
+
const close = () => {
|
|
1046
|
+
composing.current = false;
|
|
1047
|
+
justEnded.current = true;
|
|
1048
|
+
tabEscape.current = false;
|
|
1049
|
+
};
|
|
1050
|
+
const settle = () => {
|
|
1051
|
+
justEnded.current = false;
|
|
1052
|
+
};
|
|
1053
|
+
const reset = () => {
|
|
1054
|
+
composing.current = false;
|
|
1055
|
+
justEnded.current = false;
|
|
1056
|
+
tabEscape.current = false;
|
|
1057
|
+
};
|
|
1058
|
+
node.addEventListener("compositionstart", open);
|
|
1059
|
+
node.addEventListener("compositionend", close);
|
|
1060
|
+
node.addEventListener("keyup", settle);
|
|
1061
|
+
window.addEventListener("blur", reset);
|
|
1062
|
+
return () => {
|
|
1063
|
+
node.removeEventListener("compositionstart", open);
|
|
1064
|
+
node.removeEventListener("compositionend", close);
|
|
1065
|
+
node.removeEventListener("keyup", settle);
|
|
1066
|
+
window.removeEventListener("blur", reset);
|
|
1067
|
+
};
|
|
1068
|
+
}, []);
|
|
1069
|
+
const applyPending = (0, import_react.useCallback)(() => {
|
|
1070
|
+
const node = areaRef.current;
|
|
1071
|
+
const slot = pending.current;
|
|
1072
|
+
if (node === null || slot === null) return;
|
|
1073
|
+
if (node.value !== slot.expected) {
|
|
1074
|
+
pending.current = null;
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
pending.current = null;
|
|
1078
|
+
if (composing.current) return;
|
|
1079
|
+
if (slot.focus && node.ownerDocument.activeElement !== node) node.focus();
|
|
1080
|
+
node.setSelectionRange(slot.start, slot.end);
|
|
1081
|
+
}, []);
|
|
1082
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
1083
|
+
applyPending();
|
|
1084
|
+
}, [applyPending, value]);
|
|
1085
|
+
const measure = (0, import_react.useCallback)(() => {
|
|
1086
|
+
const node = areaRef.current;
|
|
1087
|
+
if (node === null) return;
|
|
1088
|
+
const view = node.ownerDocument.defaultView;
|
|
1089
|
+
const cap = Math.max(MIN_HEIGHT_PX, Math.round((view === null ? 0 : view.innerHeight) * VIEWPORT_SHARE));
|
|
1090
|
+
node.style.height = "auto";
|
|
1091
|
+
const border = Math.max(0, node.offsetHeight - node.clientHeight);
|
|
1092
|
+
const wanted = node.scrollHeight + border;
|
|
1093
|
+
node.style.height = `${Math.min(Math.max(wanted, MIN_HEIGHT_PX), cap)}px`;
|
|
1094
|
+
node.style.overflowY = wanted > cap ? "auto" : "hidden";
|
|
1095
|
+
}, []);
|
|
1096
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
1097
|
+
measure();
|
|
1098
|
+
}, [measure, value, disabled]);
|
|
1099
|
+
(0, import_react.useEffect)(() => {
|
|
1100
|
+
const node = areaRef.current;
|
|
1101
|
+
if (node === null) return;
|
|
1102
|
+
let lastWidth = 0;
|
|
1103
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver((entries) => {
|
|
1104
|
+
const width = Math.round(entries[0]?.contentRect.width ?? 0);
|
|
1105
|
+
if (width === lastWidth) return;
|
|
1106
|
+
lastWidth = width;
|
|
1107
|
+
measure();
|
|
1108
|
+
});
|
|
1109
|
+
observer?.observe(node.parentElement ?? node);
|
|
1110
|
+
window.addEventListener("resize", measure);
|
|
1111
|
+
return () => {
|
|
1112
|
+
observer?.disconnect();
|
|
1113
|
+
window.removeEventListener("resize", measure);
|
|
1114
|
+
};
|
|
1115
|
+
}, [measure]);
|
|
1116
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
1117
|
+
if (!autoFocus) return;
|
|
1118
|
+
const node = areaRef.current;
|
|
1119
|
+
if (node === null) return;
|
|
1120
|
+
node.focus();
|
|
1121
|
+
const end = node.value.length;
|
|
1122
|
+
if (!composing.current) node.setSelectionRange(end, end);
|
|
1123
|
+
}, [autoFocus]);
|
|
1124
|
+
const commit = (0, import_react.useCallback)(
|
|
1125
|
+
(edit) => {
|
|
1126
|
+
if (edit === null) return;
|
|
1127
|
+
const node = areaRef.current;
|
|
1128
|
+
if (node === null) return;
|
|
1129
|
+
if (maxLength !== void 0 && edit.value.length > maxLength) return;
|
|
1130
|
+
if (edit.value === value) {
|
|
1131
|
+
if (!composing.current) node.setSelectionRange(edit.start, edit.end);
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
pending.current = {
|
|
1135
|
+
expected: edit.value,
|
|
1136
|
+
start: edit.start,
|
|
1137
|
+
end: edit.end,
|
|
1138
|
+
focus: node.ownerDocument.activeElement === node
|
|
1139
|
+
};
|
|
1140
|
+
onChange(edit.value);
|
|
1141
|
+
},
|
|
1142
|
+
[maxLength, onChange, value]
|
|
1143
|
+
);
|
|
1144
|
+
function onKeyDown(event) {
|
|
1145
|
+
if (guarded(event)) return;
|
|
1146
|
+
const node = event.currentTarget;
|
|
1147
|
+
const modifier = event.metaKey || event.ctrlKey;
|
|
1148
|
+
if (event.key !== "Tab" && event.key !== "Escape") tabEscape.current = false;
|
|
1149
|
+
if (modifier && (event.key === "s" || event.key === "S")) {
|
|
1150
|
+
event.preventDefault();
|
|
1151
|
+
if (!event.repeat) onSave?.();
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
if (modifier && event.key === "Enter") {
|
|
1155
|
+
event.preventDefault();
|
|
1156
|
+
if (!event.repeat) onSave?.();
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
if (event.key === "Escape") {
|
|
1160
|
+
tabEscape.current = true;
|
|
1161
|
+
onEscape?.();
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
if (event.key === "Tab") {
|
|
1165
|
+
if (tabEscape.current) {
|
|
1166
|
+
tabEscape.current = false;
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
event.preventDefault();
|
|
1170
|
+
commit(indentSelection(value, node.selectionStart, node.selectionEnd, event.shiftKey ? -1 : 1));
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
if (event.key === "Enter" && !modifier && !event.shiftKey && !event.altKey) {
|
|
1174
|
+
const continuation = continueList(value, node.selectionStart, node.selectionEnd);
|
|
1175
|
+
if (continuation === null) return;
|
|
1176
|
+
event.preventDefault();
|
|
1177
|
+
commit(continuation);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function onToolbarMouseDown(event) {
|
|
1181
|
+
event.preventDefault();
|
|
1182
|
+
}
|
|
1183
|
+
function runAction(action) {
|
|
1184
|
+
const node = areaRef.current;
|
|
1185
|
+
if (node === null) return;
|
|
1186
|
+
commit(action.run({ value, start: node.selectionStart, end: node.selectionEnd, locale }));
|
|
1187
|
+
}
|
|
1188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-ed-root", "data-disabled": disabled ? "true" : void 0, children: [
|
|
1189
|
+
toolbar && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1190
|
+
"div",
|
|
1191
|
+
{
|
|
1192
|
+
className: "skw-ed-toolbar",
|
|
1193
|
+
role: "toolbar",
|
|
1194
|
+
"aria-label": TOOLBAR_LABEL[locale],
|
|
1195
|
+
onMouseDown: onToolbarMouseDown,
|
|
1196
|
+
children: TOOLBAR.map((group) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-ed-group", role: "group", "aria-label": group[locale], children: group.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1197
|
+
"button",
|
|
1198
|
+
{
|
|
1199
|
+
type: "button",
|
|
1200
|
+
className: "skw-ed-btn",
|
|
1201
|
+
"data-action": action.id,
|
|
1202
|
+
"data-style": action.style,
|
|
1203
|
+
"aria-label": action[locale],
|
|
1204
|
+
title: action[locale],
|
|
1205
|
+
disabled,
|
|
1206
|
+
onClick: () => {
|
|
1207
|
+
runAction(action);
|
|
1208
|
+
},
|
|
1209
|
+
children: action.glyph
|
|
1210
|
+
},
|
|
1211
|
+
action.id
|
|
1212
|
+
)) }, group.id))
|
|
1213
|
+
}
|
|
1214
|
+
),
|
|
1215
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1216
|
+
"textarea",
|
|
1217
|
+
{
|
|
1218
|
+
ref: areaRef,
|
|
1219
|
+
className: "skw-ed-input",
|
|
1220
|
+
value,
|
|
1221
|
+
onChange: (event) => {
|
|
1222
|
+
onChange(event.target.value);
|
|
1223
|
+
},
|
|
1224
|
+
onKeyDown,
|
|
1225
|
+
placeholder,
|
|
1226
|
+
maxLength,
|
|
1227
|
+
disabled,
|
|
1228
|
+
"aria-label": label,
|
|
1229
|
+
autoComplete: "off",
|
|
1230
|
+
spellCheck: true
|
|
1231
|
+
}
|
|
1232
|
+
)
|
|
1233
|
+
] });
|
|
1234
|
+
}
|
|
1235
|
+
var EDITOR_CSS = `
|
|
1236
|
+
.skw-ed-root { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
|
|
1237
|
+
.skw-ed-root *, .skw-ed-root *::before, .skw-ed-root *::after { box-sizing: border-box; }
|
|
1238
|
+
.skw-ed-root[data-disabled="true"] { opacity: .7; }
|
|
1239
|
+
.skw-ed-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 2px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); }
|
|
1240
|
+
.skw-ed-group { display: inline-flex; align-items: center; gap: 1px; padding: 0 2px; }
|
|
1241
|
+
.skw-ed-group + .skw-ed-group { border-left: 1px solid var(--dsw-alias-border-l1); }
|
|
1242
|
+
.skw-ed-btn { min-width: 24px; height: 24px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 5px; background: transparent; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 12px; line-height: 1; cursor: pointer; }
|
|
1243
|
+
.skw-ed-btn:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
1244
|
+
.skw-ed-btn:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }
|
|
1245
|
+
.skw-ed-btn[data-style="bold"] { font-weight: 650; }
|
|
1246
|
+
.skw-ed-btn[data-style="italic"] { font-style: italic; }
|
|
1247
|
+
.skw-ed-btn[data-style="strike"] { text-decoration: line-through; }
|
|
1248
|
+
.skw-ed-btn[disabled] { opacity: .45; cursor: default; }
|
|
1249
|
+
.skw-ed-input { width: 100%; min-height: ${MIN_HEIGHT_PX}px; padding: 8px 10px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 20px; resize: none; overflow-y: auto; overflow-x: hidden; }
|
|
1250
|
+
.skw-ed-input::placeholder { color: var(--dsw-alias-label-tertiary); }
|
|
1251
|
+
.skw-ed-input:focus-visible { outline: none; border-color: var(--dsw-alias-brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-brand-primary) 18%, transparent); }
|
|
1252
|
+
.skw-ed-input:disabled { opacity: .7; }
|
|
1253
|
+
`;
|
|
1254
|
+
|
|
617
1255
|
// src/client/styles.ts
|
|
618
1256
|
var WALL_CSS = `
|
|
619
1257
|
.skw-page {
|
|
@@ -1012,6 +1650,10 @@ window.__ModuleLoader__.load({
|
|
|
1012
1650
|
.skw-note-foot { display: flex; align-items: center; gap: 5px; font-size: 11px; line-height: 16px; color: var(--skw-note-ink); opacity: .58; margin-top: 2px; }
|
|
1013
1651
|
.skw-note-foot .skw-spacer { flex: 1; }
|
|
1014
1652
|
.skw-note-badge { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; height: 17px; border-radius: 999px; background: color-mix(in srgb, var(--skw-note-accent) 26%, transparent); font-weight: 550; opacity: 1; }
|
|
1653
|
+
/* A note whose frontmatter could not be read stays visible with defaults, so the
|
|
1654
|
+
card has to WARN. The app's own error colour makes it read as a fault rather
|
|
1655
|
+
than as another decorative badge. */
|
|
1656
|
+
.skw-note-badge[data-warn="true"] { background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 20%, transparent); color: var(--skw-note-ink); font-weight: 600; }
|
|
1015
1657
|
/* In-flow, never absolute: the buttons can no longer sit on top of the text.
|
|
1016
1658
|
They fade in on hover/focus for calm cards, and stay visible where hover is
|
|
1017
1659
|
not a thing (touch/coarse pointers) so the actions remain reachable. */
|
|
@@ -1187,7 +1829,11 @@ window.__ModuleLoader__.load({
|
|
|
1187
1829
|
];
|
|
1188
1830
|
|
|
1189
1831
|
// src/client/view.tsx
|
|
1190
|
-
var
|
|
1832
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1833
|
+
function isComposingEvent(event) {
|
|
1834
|
+
const native = "nativeEvent" in event ? event.nativeEvent : event;
|
|
1835
|
+
return native.isComposing === true || native.keyCode === 229;
|
|
1836
|
+
}
|
|
1191
1837
|
var ZOOM_MIN = 0.35;
|
|
1192
1838
|
var ZOOM_MAX = 2;
|
|
1193
1839
|
var DRAG_THRESHOLD = 3;
|
|
@@ -1196,18 +1842,19 @@ window.__ModuleLoader__.load({
|
|
|
1196
1842
|
var WHEEL_PAN = 1;
|
|
1197
1843
|
var REVEAL_MS = 340;
|
|
1198
1844
|
var ARRIVAL_MS = 900;
|
|
1845
|
+
var REFRESH_MS = 4e3;
|
|
1199
1846
|
function SidebarGlyph({ size = 18 }) {
|
|
1200
|
-
return /* @__PURE__ */ (0,
|
|
1201
|
-
/* @__PURE__ */ (0,
|
|
1202
|
-
/* @__PURE__ */ (0,
|
|
1203
|
-
/* @__PURE__ */ (0,
|
|
1847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { className: "skw-glyph", width: size, height: size, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
1848
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "4", y: "7.5", width: "11.5", height: "11.5", rx: "2", stroke: "currentColor", strokeWidth: "1.6" }),
|
|
1849
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M8.5 5.2h8.2a2.4 2.4 0 0 1 2.4 2.4v8.2", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }),
|
|
1850
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M6.9 11h5.7M6.9 14.4h4", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", opacity: "0.75" })
|
|
1204
1851
|
] });
|
|
1205
1852
|
}
|
|
1206
1853
|
function formatTime(iso, locale) {
|
|
1207
|
-
const
|
|
1208
|
-
if (Number.isNaN(
|
|
1854
|
+
const stamp2 = new Date(iso);
|
|
1855
|
+
if (Number.isNaN(stamp2.getTime())) return iso;
|
|
1209
1856
|
const now = Date.now();
|
|
1210
|
-
const minutes = Math.round((now -
|
|
1857
|
+
const minutes = Math.round((now - stamp2.getTime()) / 6e4);
|
|
1211
1858
|
const zh2 = locale.toLowerCase().startsWith("zh");
|
|
1212
1859
|
if (minutes < 1) return zh2 ? "\u521A\u521A" : "just now";
|
|
1213
1860
|
if (minutes < 60) return zh2 ? `${minutes} \u5206\u949F\u524D` : `${minutes}m ago`;
|
|
@@ -1215,7 +1862,7 @@ window.__ModuleLoader__.load({
|
|
|
1215
1862
|
if (hours < 24) return zh2 ? `${hours} \u5C0F\u65F6\u524D` : `${hours}h ago`;
|
|
1216
1863
|
const days = Math.round(hours / 24);
|
|
1217
1864
|
if (days < 7) return zh2 ? `${days} \u5929\u524D` : `${days}d ago`;
|
|
1218
|
-
return
|
|
1865
|
+
return stamp2.toLocaleDateString(zh2 ? "zh-CN" : "en-US", { month: "short", day: "numeric" });
|
|
1219
1866
|
}
|
|
1220
1867
|
function parseTags(raw) {
|
|
1221
1868
|
return raw.split(/[,,\s]+/).map((tag) => tag.trim()).filter((tag) => tag !== "");
|
|
@@ -1245,123 +1892,156 @@ window.__ModuleLoader__.load({
|
|
|
1245
1892
|
function Composer({
|
|
1246
1893
|
draft,
|
|
1247
1894
|
t,
|
|
1895
|
+
locale,
|
|
1248
1896
|
busy,
|
|
1249
1897
|
error,
|
|
1898
|
+
status,
|
|
1250
1899
|
onChange,
|
|
1251
1900
|
onSave,
|
|
1252
1901
|
onCancel
|
|
1253
1902
|
}) {
|
|
1254
|
-
const
|
|
1255
|
-
const [
|
|
1256
|
-
(0,
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
if (
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
)
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
"input",
|
|
1295
|
-
{
|
|
1296
|
-
className: "skw-input",
|
|
1297
|
-
value: draft.title,
|
|
1298
|
-
placeholder: t("titlePlaceholder"),
|
|
1299
|
-
maxLength: LIMITS.title,
|
|
1300
|
-
onChange: (event) => onChange({ title: event.target.value }),
|
|
1301
|
-
"aria-label": t("titlePlaceholder")
|
|
1302
|
-
}
|
|
1303
|
-
),
|
|
1304
|
-
preview ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-preview-box", children: draft.body.trim() === "" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skw-preview-empty", children: t("bodyPlaceholder") }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Markdown, { source: draft.body }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1305
|
-
"textarea",
|
|
1306
|
-
{
|
|
1307
|
-
ref: bodyRef,
|
|
1308
|
-
className: "skw-textarea",
|
|
1309
|
-
value: draft.body,
|
|
1310
|
-
placeholder: t("bodyPlaceholder"),
|
|
1311
|
-
maxLength: LIMITS.body,
|
|
1312
|
-
onChange: (event) => onChange({ body: event.target.value }),
|
|
1313
|
-
"aria-label": t("bodyPlaceholder")
|
|
1314
|
-
}
|
|
1315
|
-
),
|
|
1316
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1317
|
-
"input",
|
|
1318
|
-
{
|
|
1319
|
-
className: "skw-input",
|
|
1320
|
-
value: draft.tags,
|
|
1321
|
-
placeholder: t("tagsPlaceholder"),
|
|
1322
|
-
onChange: (event) => onChange({ tags: event.target.value }),
|
|
1323
|
-
"aria-label": t("tagsPlaceholder")
|
|
1324
|
-
}
|
|
1325
|
-
),
|
|
1326
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-sheet-row", children: [
|
|
1327
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-swatches", role: "group", "aria-label": t("colorLabel"), children: SWATCHES.map((swatch) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1903
|
+
const [preview, setPreview] = (0, import_react2.useState)(false);
|
|
1904
|
+
const [confirmDiscard, setConfirmDiscard] = (0, import_react2.useState)(false);
|
|
1905
|
+
const initial = (0, import_react2.useRef)(JSON.stringify(draft));
|
|
1906
|
+
const dirty = JSON.stringify(draft) !== initial.current;
|
|
1907
|
+
const requestClose = () => {
|
|
1908
|
+
if (busy) return;
|
|
1909
|
+
if (dirty) {
|
|
1910
|
+
setConfirmDiscard(true);
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1913
|
+
onCancel();
|
|
1914
|
+
};
|
|
1915
|
+
const save = () => {
|
|
1916
|
+
if (busy) return;
|
|
1917
|
+
onSave();
|
|
1918
|
+
};
|
|
1919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-scrim", role: "presentation", onMouseDown: (event) => {
|
|
1920
|
+
if (event.target === event.currentTarget) requestClose();
|
|
1921
|
+
}, children: [
|
|
1922
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1923
|
+
"div",
|
|
1924
|
+
{
|
|
1925
|
+
className: "skw-sheet",
|
|
1926
|
+
role: "dialog",
|
|
1927
|
+
"aria-modal": "true",
|
|
1928
|
+
"aria-label": draft.id ? t("edit") : t("new"),
|
|
1929
|
+
onKeyDown: (event) => {
|
|
1930
|
+
if (event.repeat) return;
|
|
1931
|
+
if (isComposingEvent(event.nativeEvent)) return;
|
|
1932
|
+
if (event.key === "Escape") requestClose();
|
|
1933
|
+
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
|
|
1934
|
+
event.preventDefault();
|
|
1935
|
+
save();
|
|
1936
|
+
}
|
|
1937
|
+
},
|
|
1938
|
+
children: [
|
|
1939
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-sheet-head", children: [
|
|
1940
|
+
draft.id ? t("edit") : t("new"),
|
|
1941
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
|
|
1942
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1328
1943
|
"button",
|
|
1329
1944
|
{
|
|
1945
|
+
className: "skw-btn skw-btn-quiet",
|
|
1330
1946
|
type: "button",
|
|
1331
|
-
|
|
1332
|
-
"
|
|
1333
|
-
|
|
1334
|
-
"
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-sizes", role: "group", "aria-label": t("widthLabel"), children: WIDTH_CYCLE.map((width) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1342
|
-
"button",
|
|
1947
|
+
"data-on": preview,
|
|
1948
|
+
"aria-pressed": preview,
|
|
1949
|
+
onClick: () => setPreview((value) => !value),
|
|
1950
|
+
children: preview ? t("editorSource") : t("editorPreview")
|
|
1951
|
+
}
|
|
1952
|
+
)
|
|
1953
|
+
] }),
|
|
1954
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-sheet-body", children: [
|
|
1955
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1956
|
+
"input",
|
|
1343
1957
|
{
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
"
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
)) })
|
|
1958
|
+
className: "skw-input",
|
|
1959
|
+
value: draft.title,
|
|
1960
|
+
placeholder: t("titlePlaceholder"),
|
|
1961
|
+
maxLength: LIMITS.title,
|
|
1962
|
+
onChange: (event) => onChange({ title: event.target.value }),
|
|
1963
|
+
"aria-label": t("titlePlaceholder")
|
|
1964
|
+
}
|
|
1965
|
+
),
|
|
1966
|
+
preview ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-preview-box", children: draft.body.trim() === "" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "skw-preview-empty", children: t("bodyPlaceholder") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { source: draft.body }) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1967
|
+
MarkdownEditor,
|
|
1968
|
+
{
|
|
1969
|
+
value: draft.body,
|
|
1970
|
+
onChange: (body) => onChange({ body }),
|
|
1971
|
+
onSave: save,
|
|
1972
|
+
onEscape: requestClose,
|
|
1973
|
+
maxLength: LIMITS.body,
|
|
1974
|
+
placeholder: t("bodyPlaceholder"),
|
|
1975
|
+
label: t("bodyPlaceholder"),
|
|
1976
|
+
locale: locale.toLowerCase().startsWith("zh") ? "zh" : "en",
|
|
1977
|
+
disabled: busy
|
|
1978
|
+
}
|
|
1979
|
+
),
|
|
1980
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1981
|
+
"input",
|
|
1982
|
+
{
|
|
1983
|
+
className: "skw-input",
|
|
1984
|
+
value: draft.tags,
|
|
1985
|
+
placeholder: t("tagsPlaceholder"),
|
|
1986
|
+
onChange: (event) => onChange({ tags: event.target.value }),
|
|
1987
|
+
"aria-label": t("tagsPlaceholder")
|
|
1988
|
+
}
|
|
1989
|
+
),
|
|
1990
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-sheet-row", children: [
|
|
1991
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-swatches", role: "group", "aria-label": t("colorLabel"), children: SWATCHES.map((swatch) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1992
|
+
"button",
|
|
1993
|
+
{
|
|
1994
|
+
type: "button",
|
|
1995
|
+
className: "skw-swatch",
|
|
1996
|
+
"data-on": draft.color === swatch.key,
|
|
1997
|
+
style: { background: swatch.css },
|
|
1998
|
+
"aria-label": swatch.key,
|
|
1999
|
+
"aria-pressed": draft.color === swatch.key,
|
|
2000
|
+
onClick: () => onChange({ color: swatch.key })
|
|
2001
|
+
},
|
|
2002
|
+
swatch.key
|
|
2003
|
+
)) }),
|
|
2004
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
|
|
2005
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-sizes", role: "group", "aria-label": t("widthLabel"), children: WIDTH_CYCLE.map((width) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2006
|
+
"button",
|
|
2007
|
+
{
|
|
2008
|
+
type: "button",
|
|
2009
|
+
className: "skw-size",
|
|
2010
|
+
"data-on": draft.width === width,
|
|
2011
|
+
"aria-pressed": draft.width === width,
|
|
2012
|
+
onClick: () => onChange({ width }),
|
|
2013
|
+
children: t(`width_${width}`)
|
|
2014
|
+
},
|
|
2015
|
+
width
|
|
2016
|
+
)) })
|
|
2017
|
+
] }),
|
|
2018
|
+
error !== "" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "skw-error", role: "alert", children: error })
|
|
1353
2019
|
] }),
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
2020
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-sheet-foot", children: [
|
|
2021
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-hint", "data-status": status, children: status === "saving" ? t("editorSaving") : status === "saved" ? t("editorSaved") : dirty ? t("editorUnsaved") : t("saveHint") }),
|
|
2022
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
|
|
2023
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "skw-btn", type: "button", onClick: requestClose, disabled: busy, children: t("cancel") }),
|
|
2024
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "skw-btn skw-btn-primary", type: "button", onClick: save, disabled: busy, children: t("save") })
|
|
2025
|
+
] })
|
|
2026
|
+
]
|
|
2027
|
+
}
|
|
2028
|
+
),
|
|
2029
|
+
confirmDiscard && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2030
|
+
ConfirmDialog,
|
|
2031
|
+
{
|
|
2032
|
+
title: t("discardDraft"),
|
|
2033
|
+
message: t("discardDraft"),
|
|
2034
|
+
confirmLabel: t("discard"),
|
|
2035
|
+
cancelLabel: t("keepEditing"),
|
|
2036
|
+
busy: false,
|
|
2037
|
+
onConfirm: () => {
|
|
2038
|
+
setConfirmDiscard(false);
|
|
2039
|
+
onCancel();
|
|
2040
|
+
},
|
|
2041
|
+
onCancel: () => setConfirmDiscard(false)
|
|
2042
|
+
}
|
|
2043
|
+
)
|
|
2044
|
+
] });
|
|
1365
2045
|
}
|
|
1366
2046
|
function ConfirmDialog({
|
|
1367
2047
|
title,
|
|
@@ -1372,15 +2052,15 @@ window.__ModuleLoader__.load({
|
|
|
1372
2052
|
onConfirm,
|
|
1373
2053
|
onCancel
|
|
1374
2054
|
}) {
|
|
1375
|
-
const cancelRef = (0,
|
|
1376
|
-
(0,
|
|
2055
|
+
const cancelRef = (0, import_react2.useRef)(null);
|
|
2056
|
+
(0, import_react2.useEffect)(() => {
|
|
1377
2057
|
const previous = typeof document === "undefined" ? null : document.activeElement;
|
|
1378
2058
|
cancelRef.current?.focus();
|
|
1379
2059
|
return () => {
|
|
1380
2060
|
if (previous !== null && typeof previous.focus === "function") previous.focus();
|
|
1381
2061
|
};
|
|
1382
2062
|
}, []);
|
|
1383
|
-
return /* @__PURE__ */ (0,
|
|
2063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1384
2064
|
"div",
|
|
1385
2065
|
{
|
|
1386
2066
|
className: "skw-scrim",
|
|
@@ -1388,7 +2068,7 @@ window.__ModuleLoader__.load({
|
|
|
1388
2068
|
onMouseDown: (event) => {
|
|
1389
2069
|
if (event.target === event.currentTarget && !busy) onCancel();
|
|
1390
2070
|
},
|
|
1391
|
-
children: /* @__PURE__ */ (0,
|
|
2071
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1392
2072
|
"div",
|
|
1393
2073
|
{
|
|
1394
2074
|
className: "skw-sheet",
|
|
@@ -1404,12 +2084,12 @@ window.__ModuleLoader__.load({
|
|
|
1404
2084
|
}
|
|
1405
2085
|
},
|
|
1406
2086
|
children: [
|
|
1407
|
-
/* @__PURE__ */ (0,
|
|
1408
|
-
/* @__PURE__ */ (0,
|
|
1409
|
-
/* @__PURE__ */ (0,
|
|
1410
|
-
/* @__PURE__ */ (0,
|
|
1411
|
-
/* @__PURE__ */ (0,
|
|
1412
|
-
/* @__PURE__ */ (0,
|
|
2087
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-sheet-head", children: title }),
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-sheet-body", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { style: { margin: 0 }, children: message }) }),
|
|
2089
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-sheet-foot", children: [
|
|
2090
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
|
|
2091
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { ref: cancelRef, className: "skw-btn", type: "button", onClick: onCancel, disabled: busy, children: cancelLabel }),
|
|
2092
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "skw-btn skw-btn-danger", type: "button", onClick: onConfirm, disabled: busy, children: confirmLabel })
|
|
1413
2093
|
] })
|
|
1414
2094
|
]
|
|
1415
2095
|
}
|
|
@@ -1417,7 +2097,7 @@ window.__ModuleLoader__.load({
|
|
|
1417
2097
|
}
|
|
1418
2098
|
);
|
|
1419
2099
|
}
|
|
1420
|
-
var NoteCard = (0,
|
|
2100
|
+
var NoteCard = (0, import_react2.memo)(function NoteCard2({
|
|
1421
2101
|
note,
|
|
1422
2102
|
index,
|
|
1423
2103
|
surface,
|
|
@@ -1427,6 +2107,7 @@ window.__ModuleLoader__.load({
|
|
|
1427
2107
|
arrived = false
|
|
1428
2108
|
}) {
|
|
1429
2109
|
const layout = layoutOf(note, index);
|
|
2110
|
+
const metaIssue = note.metaError === void 0 ? void 0 : note.metaError.startsWith("newer-schema") ? "newer" : note.metaError;
|
|
1430
2111
|
const style = surface === "canvas" ? {
|
|
1431
2112
|
left: `${layout.x}px`,
|
|
1432
2113
|
top: `${layout.y}px`,
|
|
@@ -1441,7 +2122,7 @@ window.__ModuleLoader__.load({
|
|
|
1441
2122
|
height: `${estimateHeight(note, layout.width)}px`,
|
|
1442
2123
|
transform: `rotate(${layout.rotate}deg)`
|
|
1443
2124
|
} : {};
|
|
1444
|
-
return /* @__PURE__ */ (0,
|
|
2125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1445
2126
|
"article",
|
|
1446
2127
|
{
|
|
1447
2128
|
className: "skw-note",
|
|
@@ -1452,7 +2133,7 @@ window.__ModuleLoader__.load({
|
|
|
1452
2133
|
"data-width": layout.width,
|
|
1453
2134
|
"data-arrived": arrived,
|
|
1454
2135
|
style,
|
|
1455
|
-
"aria-label": note.title || note.body
|
|
2136
|
+
"aria-label": note.title || plainTextSummary(note.body, 60),
|
|
1456
2137
|
tabIndex: 0,
|
|
1457
2138
|
onPointerDown: (event) => actions.drag(note, event),
|
|
1458
2139
|
onDoubleClick: () => actions.edit(note),
|
|
@@ -1463,11 +2144,11 @@ window.__ModuleLoader__.load({
|
|
|
1463
2144
|
}
|
|
1464
2145
|
},
|
|
1465
2146
|
children: [
|
|
1466
|
-
/* @__PURE__ */ (0,
|
|
1467
|
-
/* @__PURE__ */ (0,
|
|
1468
|
-
/* @__PURE__ */ (0,
|
|
1469
|
-
/* @__PURE__ */ (0,
|
|
1470
|
-
/* @__PURE__ */ (0,
|
|
2147
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-note-bar", children: [
|
|
2148
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-note-dot", "aria-hidden": "true" }),
|
|
2149
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
|
|
2150
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-note-tools", children: [
|
|
2151
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1471
2152
|
"button",
|
|
1472
2153
|
{
|
|
1473
2154
|
className: "skw-icon-btn",
|
|
@@ -1477,10 +2158,10 @@ window.__ModuleLoader__.load({
|
|
|
1477
2158
|
"aria-label": note.pinned ? t("unpin") : t("pin"),
|
|
1478
2159
|
onPointerDown: (event) => event.stopPropagation(),
|
|
1479
2160
|
onClick: () => actions.patch(note, { pinned: !note.pinned }),
|
|
1480
|
-
children: /* @__PURE__ */ (0,
|
|
2161
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-pin", "aria-hidden": "true", children: note.pinned ? "\u2605" : "\u2606" })
|
|
1481
2162
|
}
|
|
1482
2163
|
),
|
|
1483
|
-
/* @__PURE__ */ (0,
|
|
2164
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1484
2165
|
"button",
|
|
1485
2166
|
{
|
|
1486
2167
|
className: "skw-icon-btn",
|
|
@@ -1492,7 +2173,7 @@ window.__ModuleLoader__.load({
|
|
|
1492
2173
|
children: "\u2922"
|
|
1493
2174
|
}
|
|
1494
2175
|
),
|
|
1495
|
-
/* @__PURE__ */ (0,
|
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1496
2177
|
"button",
|
|
1497
2178
|
{
|
|
1498
2179
|
className: "skw-icon-btn",
|
|
@@ -1504,7 +2185,7 @@ window.__ModuleLoader__.load({
|
|
|
1504
2185
|
children: "\u270E"
|
|
1505
2186
|
}
|
|
1506
2187
|
),
|
|
1507
|
-
/* @__PURE__ */ (0,
|
|
2188
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1508
2189
|
"button",
|
|
1509
2190
|
{
|
|
1510
2191
|
className: "skw-icon-btn",
|
|
@@ -1516,7 +2197,7 @@ window.__ModuleLoader__.load({
|
|
|
1516
2197
|
children: note.archived ? "\u21A9" : "\u25A4"
|
|
1517
2198
|
}
|
|
1518
2199
|
),
|
|
1519
|
-
/* @__PURE__ */ (0,
|
|
2200
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1520
2201
|
"button",
|
|
1521
2202
|
{
|
|
1522
2203
|
className: "skw-icon-btn",
|
|
@@ -1530,17 +2211,18 @@ window.__ModuleLoader__.load({
|
|
|
1530
2211
|
)
|
|
1531
2212
|
] })
|
|
1532
2213
|
] }),
|
|
1533
|
-
note.title !== "" && /* @__PURE__ */ (0,
|
|
1534
|
-
/* @__PURE__ */ (0,
|
|
1535
|
-
note.tags.length > 0 && /* @__PURE__ */ (0,
|
|
2214
|
+
note.title !== "" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-note-head", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-note-title", children: note.title }) }),
|
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-note-body is-clamped", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { source: note.body, compact: true }) }),
|
|
2216
|
+
note.tags.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-note-tags", children: note.tags.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "skw-tag", children: [
|
|
1536
2217
|
"#",
|
|
1537
2218
|
tag
|
|
1538
2219
|
] }, tag)) }),
|
|
1539
|
-
/* @__PURE__ */ (0,
|
|
1540
|
-
/* @__PURE__ */ (0,
|
|
1541
|
-
/* @__PURE__ */ (0,
|
|
1542
|
-
|
|
1543
|
-
note.
|
|
2220
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-note-foot", children: [
|
|
2221
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formatTime(note.updatedAt, locale) }),
|
|
2222
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
|
|
2223
|
+
metaIssue !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-note-badge", "data-warn": "true", title: metaIssue, children: metaIssue === "newer" ? t("metaErrorNewer") : t("metaErrorBadge") }),
|
|
2224
|
+
note.archived && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-note-badge", children: t("archive") }),
|
|
2225
|
+
note.pinned && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "skw-note-badge", "aria-hidden": "true", children: [
|
|
1544
2226
|
"\u2605 ",
|
|
1545
2227
|
t("pin")
|
|
1546
2228
|
] })
|
|
@@ -1550,67 +2232,74 @@ window.__ModuleLoader__.load({
|
|
|
1550
2232
|
);
|
|
1551
2233
|
});
|
|
1552
2234
|
function NoteRow({ note, t, locale, onEdit }) {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
/* @__PURE__ */ (0,
|
|
1556
|
-
|
|
1557
|
-
/* @__PURE__ */ (0,
|
|
1558
|
-
|
|
1559
|
-
/* @__PURE__ */ (0,
|
|
2235
|
+
const summary = plainTextSummary(note.body, 80);
|
|
2236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { className: "skw-row", type: "button", "data-color": note.color, "data-archived": note.archived, onClick: () => onEdit(note), children: [
|
|
2237
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-row-dot", "aria-hidden": "true" }),
|
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-row-title", children: note.title || summary }),
|
|
2239
|
+
note.tags.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-row-tags", children: note.tags.map((tag) => `#${tag}`).join(" ") }),
|
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-spacer" }),
|
|
2241
|
+
note.pinned && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-row-badge", "aria-hidden": "true", children: "\u2605" }),
|
|
2242
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-row-time", children: formatTime(note.updatedAt, locale) })
|
|
1560
2243
|
] });
|
|
1561
2244
|
}
|
|
1562
2245
|
function WallPage({ api, locale, t }) {
|
|
1563
|
-
const [notes, setNotes] = (0,
|
|
1564
|
-
const [filter, setFilter] = (0,
|
|
1565
|
-
const [sort, setSort] = (0,
|
|
1566
|
-
const [view, setView] = (0,
|
|
1567
|
-
const [query, setQuery] = (0,
|
|
1568
|
-
const [showArchived, setShowArchived] = (0,
|
|
1569
|
-
const [loading, setLoading] = (0,
|
|
1570
|
-
const [busy, setBusy] = (0,
|
|
1571
|
-
const [error, setError] = (0,
|
|
1572
|
-
const [draft, setDraft] = (0,
|
|
1573
|
-
const [draftError, setDraftError] = (0,
|
|
1574
|
-
const [
|
|
1575
|
-
const [
|
|
1576
|
-
const [
|
|
1577
|
-
const [
|
|
1578
|
-
const [
|
|
1579
|
-
const [
|
|
1580
|
-
const [,
|
|
1581
|
-
const
|
|
1582
|
-
const
|
|
1583
|
-
const
|
|
1584
|
-
const
|
|
1585
|
-
const
|
|
1586
|
-
const
|
|
1587
|
-
const
|
|
1588
|
-
const
|
|
1589
|
-
const
|
|
1590
|
-
const
|
|
1591
|
-
const
|
|
1592
|
-
const
|
|
1593
|
-
const
|
|
1594
|
-
const
|
|
1595
|
-
const
|
|
2246
|
+
const [notes, setNotes] = (0, import_react2.useState)([]);
|
|
2247
|
+
const [filter, setFilter] = (0, import_react2.useState)("all");
|
|
2248
|
+
const [sort, setSort] = (0, import_react2.useState)("pinned");
|
|
2249
|
+
const [view, setView] = (0, import_react2.useState)("canvas");
|
|
2250
|
+
const [query, setQuery] = (0, import_react2.useState)("");
|
|
2251
|
+
const [showArchived, setShowArchived] = (0, import_react2.useState)(false);
|
|
2252
|
+
const [loading, setLoading] = (0, import_react2.useState)(true);
|
|
2253
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
2254
|
+
const [error, setError] = (0, import_react2.useState)("");
|
|
2255
|
+
const [draft, setDraft] = (0, import_react2.useState)(null);
|
|
2256
|
+
const [draftError, setDraftError] = (0, import_react2.useState)("");
|
|
2257
|
+
const [draftStatus, setDraftStatus] = (0, import_react2.useState)("idle");
|
|
2258
|
+
const [notesDir, setNotesDir] = (0, import_react2.useState)("");
|
|
2259
|
+
const [confirming, setConfirming] = (0, import_react2.useState)(null);
|
|
2260
|
+
const [zoom, setZoom] = (0, import_react2.useState)(1);
|
|
2261
|
+
const [viewportTick, setViewportTick] = (0, import_react2.useState)(0);
|
|
2262
|
+
const [capture, setCapture] = (0, import_react2.useState)("");
|
|
2263
|
+
const [arrivedId, setArrivedId] = (0, import_react2.useState)(null);
|
|
2264
|
+
const [menuOpen, setMenuOpen] = (0, import_react2.useState)(false);
|
|
2265
|
+
const [, setLocaleRevision] = (0, import_react2.useState)(0);
|
|
2266
|
+
const alive = (0, import_react2.useRef)(true);
|
|
2267
|
+
const life = (0, import_react2.useRef)(new AbortController());
|
|
2268
|
+
const sequence = (0, import_react2.useRef)(0);
|
|
2269
|
+
const inFlight = (0, import_react2.useRef)(false);
|
|
2270
|
+
const queue = (0, import_react2.useRef)(Promise.resolve());
|
|
2271
|
+
const revision = (0, import_react2.useRef)(0);
|
|
2272
|
+
const draftOpen = (0, import_react2.useRef)(false);
|
|
2273
|
+
const viewportRefCurrent = (0, import_react2.useRef)(null);
|
|
2274
|
+
const worldRef = (0, import_react2.useRef)(null);
|
|
2275
|
+
const centreRef = (0, import_react2.useRef)(null);
|
|
2276
|
+
const menuRef = (0, import_react2.useRef)(null);
|
|
2277
|
+
const dockRef = (0, import_react2.useRef)(null);
|
|
2278
|
+
const detachWheel = (0, import_react2.useRef)(null);
|
|
2279
|
+
const camera = (0, import_react2.useRef)({ zoom: 1, panX: 0, panY: 0 });
|
|
2280
|
+
const centreRequest = (0, import_react2.useRef)(true);
|
|
2281
|
+
const drag = (0, import_react2.useRef)(null);
|
|
2282
|
+
const pan = (0, import_react2.useRef)(null);
|
|
2283
|
+
const live = (0, import_react2.useRef)({ mutate: (_run) => {
|
|
1596
2284
|
} });
|
|
1597
2285
|
live.current.mutate = (run) => {
|
|
1598
2286
|
void mutate(run);
|
|
1599
2287
|
};
|
|
1600
2288
|
const activeLocale = locale.getSnapshot().active;
|
|
1601
|
-
|
|
2289
|
+
draftOpen.current = draft !== null;
|
|
2290
|
+
const stableIndex = (0, import_react2.useMemo)(() => {
|
|
1602
2291
|
const map = /* @__PURE__ */ new Map();
|
|
1603
2292
|
notes.forEach((note, index) => map.set(note.id, index));
|
|
1604
2293
|
return map;
|
|
1605
2294
|
}, [notes]);
|
|
1606
2295
|
const indexOf = (note) => stableIndex.get(note.id) ?? 0;
|
|
1607
|
-
(0,
|
|
2296
|
+
(0, import_react2.useEffect)(() => {
|
|
1608
2297
|
const unsubscribe = locale.subscribe(() => {
|
|
1609
2298
|
if (alive.current) setLocaleRevision((value) => value + 1);
|
|
1610
2299
|
});
|
|
1611
2300
|
return unsubscribe;
|
|
1612
2301
|
}, [locale]);
|
|
1613
|
-
(0,
|
|
2302
|
+
(0, import_react2.useEffect)(() => {
|
|
1614
2303
|
if (!menuOpen) return;
|
|
1615
2304
|
const onPointerDown = (event) => {
|
|
1616
2305
|
const node = menuRef.current;
|
|
@@ -1627,13 +2316,15 @@ window.__ModuleLoader__.load({
|
|
|
1627
2316
|
window.removeEventListener("keydown", onKeyDown);
|
|
1628
2317
|
};
|
|
1629
2318
|
}, [menuOpen]);
|
|
1630
|
-
const reload = (0,
|
|
2319
|
+
const reload = (0, import_react2.useMemo)(() => async (options) => {
|
|
1631
2320
|
const seq = ++sequence.current;
|
|
1632
2321
|
setLoading(true);
|
|
1633
2322
|
try {
|
|
1634
|
-
const
|
|
2323
|
+
const snapshot = await api.list(options.includeArchived, options.sort, life.current.signal);
|
|
1635
2324
|
if (alive.current && seq === sequence.current) {
|
|
1636
|
-
setNotes((previous) => reconcileNotes(previous,
|
|
2325
|
+
setNotes((previous) => reconcileNotes(previous, snapshot.notes));
|
|
2326
|
+
if (snapshot.revision > 0) revision.current = snapshot.revision;
|
|
2327
|
+
if (snapshot.notesDir !== "") setNotesDir(snapshot.notesDir);
|
|
1637
2328
|
if (options.clearError !== false) setError("");
|
|
1638
2329
|
}
|
|
1639
2330
|
} catch (cause) {
|
|
@@ -1643,7 +2334,7 @@ window.__ModuleLoader__.load({
|
|
|
1643
2334
|
}
|
|
1644
2335
|
}, [api, t]);
|
|
1645
2336
|
const includeArchived = showArchived || filter === "archived";
|
|
1646
|
-
(0,
|
|
2337
|
+
(0, import_react2.useEffect)(() => {
|
|
1647
2338
|
alive.current = true;
|
|
1648
2339
|
life.current = new AbortController();
|
|
1649
2340
|
void reload({ includeArchived, sort });
|
|
@@ -1653,24 +2344,67 @@ window.__ModuleLoader__.load({
|
|
|
1653
2344
|
sequence.current += 1;
|
|
1654
2345
|
};
|
|
1655
2346
|
}, [reload, includeArchived, sort]);
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
}
|
|
1669
|
-
|
|
2347
|
+
(0, import_react2.useEffect)(() => {
|
|
2348
|
+
let timer = 0;
|
|
2349
|
+
const check = async () => {
|
|
2350
|
+
if (!alive.current || life.current.signal.aborted) return;
|
|
2351
|
+
if (typeof document !== "undefined" && document.hidden) return;
|
|
2352
|
+
if (inFlight.current) return;
|
|
2353
|
+
try {
|
|
2354
|
+
const next = await api.revision(life.current.signal);
|
|
2355
|
+
if (!alive.current) return;
|
|
2356
|
+
if (next === -1 || next !== revision.current) {
|
|
2357
|
+
if (next !== -1) revision.current = next;
|
|
2358
|
+
await reload({ includeArchived, sort, clearError: false });
|
|
2359
|
+
}
|
|
2360
|
+
} catch {
|
|
1670
2361
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
2362
|
+
};
|
|
2363
|
+
const onFocus = () => {
|
|
2364
|
+
void check();
|
|
2365
|
+
};
|
|
2366
|
+
const onVisible = () => {
|
|
2367
|
+
if (!document.hidden) void check();
|
|
2368
|
+
};
|
|
2369
|
+
window.addEventListener("focus", onFocus);
|
|
2370
|
+
document.addEventListener("visibilitychange", onVisible);
|
|
2371
|
+
timer = window.setInterval(() => {
|
|
2372
|
+
void check();
|
|
2373
|
+
}, REFRESH_MS);
|
|
2374
|
+
return () => {
|
|
2375
|
+
window.removeEventListener("focus", onFocus);
|
|
2376
|
+
document.removeEventListener("visibilitychange", onVisible);
|
|
2377
|
+
window.clearInterval(timer);
|
|
2378
|
+
};
|
|
2379
|
+
}, [api, reload, includeArchived, sort]);
|
|
2380
|
+
function mutate(run) {
|
|
2381
|
+
queue.current = queue.current.then(async () => {
|
|
2382
|
+
if (!alive.current) return;
|
|
2383
|
+
inFlight.current = true;
|
|
2384
|
+
setBusy(true);
|
|
2385
|
+
setError("");
|
|
2386
|
+
try {
|
|
2387
|
+
await run();
|
|
2388
|
+
} catch (cause) {
|
|
2389
|
+
if (alive.current && !life.current.signal.aborted) {
|
|
2390
|
+
const message = errorText(cause, t);
|
|
2391
|
+
if (draftOpen.current) {
|
|
2392
|
+
setDraftError(message);
|
|
2393
|
+
setDraftStatus("failed");
|
|
2394
|
+
} else {
|
|
2395
|
+
setError(message);
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
} finally {
|
|
2399
|
+
if (alive.current) {
|
|
2400
|
+
await reload({ includeArchived, sort, clearError: false }).catch(() => {
|
|
2401
|
+
});
|
|
2402
|
+
setBusy(false);
|
|
2403
|
+
}
|
|
2404
|
+
inFlight.current = false;
|
|
2405
|
+
}
|
|
2406
|
+
});
|
|
2407
|
+
return queue.current.then(() => true, () => false);
|
|
1674
2408
|
}
|
|
1675
2409
|
async function tidyWall() {
|
|
1676
2410
|
const ran = await mutate(async () => {
|
|
@@ -1686,6 +2420,7 @@ window.__ModuleLoader__.load({
|
|
|
1686
2420
|
}
|
|
1687
2421
|
function openComposer(note) {
|
|
1688
2422
|
setDraftError("");
|
|
2423
|
+
setDraftStatus("idle");
|
|
1689
2424
|
setDraft(note ? { id: note.id, title: note.title, body: note.body, tags: note.tags.join(" "), color: note.color, width: layoutOf(note, 0).width } : { id: null, title: "", body: "", tags: "", color: "yellow", width: "md" });
|
|
1690
2425
|
}
|
|
1691
2426
|
async function saveDraft() {
|
|
@@ -1693,9 +2428,11 @@ window.__ModuleLoader__.load({
|
|
|
1693
2428
|
const body = draft.body.trim();
|
|
1694
2429
|
if (body === "") {
|
|
1695
2430
|
setDraftError(t("emptyBody"));
|
|
2431
|
+
setDraftStatus("failed");
|
|
1696
2432
|
return;
|
|
1697
2433
|
}
|
|
1698
2434
|
setDraftError("");
|
|
2435
|
+
setDraftStatus("saving");
|
|
1699
2436
|
await mutate(async () => {
|
|
1700
2437
|
const tags = parseTags(draft.tags);
|
|
1701
2438
|
if (draft.id === null) {
|
|
@@ -1715,9 +2452,10 @@ window.__ModuleLoader__.load({
|
|
|
1715
2452
|
}
|
|
1716
2453
|
}
|
|
1717
2454
|
setDraft(null);
|
|
2455
|
+
setDraftStatus("idle");
|
|
1718
2456
|
});
|
|
1719
2457
|
}
|
|
1720
|
-
const visible = (0,
|
|
2458
|
+
const visible = (0, import_react2.useMemo)(() => {
|
|
1721
2459
|
const needle = query.trim().toLowerCase();
|
|
1722
2460
|
return notes.filter((note) => {
|
|
1723
2461
|
if (filter === "archived" && !note.archived) return false;
|
|
@@ -1728,13 +2466,13 @@ window.__ModuleLoader__.load({
|
|
|
1728
2466
|
});
|
|
1729
2467
|
}, [notes, filter, query, showArchived]);
|
|
1730
2468
|
const archivedCount = notes.filter((note) => note.archived).length;
|
|
1731
|
-
const greeting = (0,
|
|
2469
|
+
const greeting = (0, import_react2.useMemo)(() => {
|
|
1732
2470
|
const hour = (/* @__PURE__ */ new Date()).getHours();
|
|
1733
2471
|
const key = hour < 5 ? "greetNight" : hour < 12 ? "greetMorning" : hour < 18 ? "greetAfternoon" : "greetEvening";
|
|
1734
2472
|
return t(key);
|
|
1735
2473
|
}, [t, activeLocale]);
|
|
1736
2474
|
const emptyCopy = filter === "archived" ? t("emptyArchived") : query.trim() !== "" ? t("noResults") : t("empty");
|
|
1737
|
-
const wallBounds = (0,
|
|
2475
|
+
const wallBounds = (0, import_react2.useMemo)(() => {
|
|
1738
2476
|
let minX = Number.POSITIVE_INFINITY;
|
|
1739
2477
|
let minY = Number.POSITIVE_INFINITY;
|
|
1740
2478
|
let maxX = Number.NEGATIVE_INFINITY;
|
|
@@ -1769,10 +2507,10 @@ window.__ModuleLoader__.load({
|
|
|
1769
2507
|
};
|
|
1770
2508
|
}, [visible, stableIndex]);
|
|
1771
2509
|
const wallCentre = wallBounds.centre;
|
|
1772
|
-
const boundsRef = (0,
|
|
2510
|
+
const boundsRef = (0, import_react2.useRef)(wallBounds);
|
|
1773
2511
|
boundsRef.current = wallBounds;
|
|
1774
2512
|
const hasNotes = visible.length > 0;
|
|
1775
|
-
const applyCamera = (0,
|
|
2513
|
+
const applyCamera = (0, import_react2.useCallback)(() => {
|
|
1776
2514
|
const current = camera.current;
|
|
1777
2515
|
const world = worldRef.current;
|
|
1778
2516
|
const viewport = viewportRefCurrent.current;
|
|
@@ -1787,23 +2525,18 @@ window.__ModuleLoader__.load({
|
|
|
1787
2525
|
viewport.style.backgroundPosition = `${current.panX}px ${current.panY}px`;
|
|
1788
2526
|
}
|
|
1789
2527
|
}, []);
|
|
1790
|
-
const tween = (0,
|
|
1791
|
-
const stopTween = (0,
|
|
2528
|
+
const tween = (0, import_react2.useRef)(0);
|
|
2529
|
+
const stopTween = (0, import_react2.useCallback)(() => {
|
|
1792
2530
|
if (tween.current !== 0) {
|
|
1793
2531
|
cancelAnimationFrame(tween.current);
|
|
1794
2532
|
tween.current = 0;
|
|
1795
2533
|
}
|
|
1796
2534
|
}, []);
|
|
1797
|
-
const
|
|
1798
|
-
const
|
|
1799
|
-
|
|
2535
|
+
const glideCameraTo = (0, import_react2.useCallback)((zoomTarget, panX, panY) => {
|
|
2536
|
+
const target = clampZoom(zoomTarget);
|
|
2537
|
+
const to = { zoom: target, panX, panY };
|
|
1800
2538
|
stopTween();
|
|
1801
2539
|
const from = { ...camera.current };
|
|
1802
|
-
const to = {
|
|
1803
|
-
zoom: clampZoom(zoomTarget),
|
|
1804
|
-
panX: viewport.clientWidth / 2 - worldX * clampZoom(zoomTarget),
|
|
1805
|
-
panY: viewport.clientHeight / 2 - worldY * clampZoom(zoomTarget)
|
|
1806
|
-
};
|
|
1807
2540
|
if (typeof requestAnimationFrame !== "function") {
|
|
1808
2541
|
camera.current = { ...to };
|
|
1809
2542
|
setZoom(to.zoom);
|
|
@@ -1832,7 +2565,13 @@ window.__ModuleLoader__.load({
|
|
|
1832
2565
|
tween.current = requestAnimationFrame(frame);
|
|
1833
2566
|
setZoom(to.zoom);
|
|
1834
2567
|
}, [applyCamera, stopTween]);
|
|
1835
|
-
const
|
|
2568
|
+
const glideTo = (0, import_react2.useCallback)((zoomTarget, worldX, worldY) => {
|
|
2569
|
+
const viewport = viewportRefCurrent.current;
|
|
2570
|
+
if (viewport === null) return;
|
|
2571
|
+
const target = clampZoom(zoomTarget);
|
|
2572
|
+
glideCameraTo(target, viewport.clientWidth / 2 - worldX * target, viewport.clientHeight / 2 - worldY * target);
|
|
2573
|
+
}, [glideCameraTo]);
|
|
2574
|
+
const centreOn = (0, import_react2.useCallback)((worldX, worldY) => {
|
|
1836
2575
|
stopTween();
|
|
1837
2576
|
const viewport = viewportRefCurrent.current;
|
|
1838
2577
|
const current = camera.current;
|
|
@@ -1844,11 +2583,11 @@ window.__ModuleLoader__.load({
|
|
|
1844
2583
|
}
|
|
1845
2584
|
applyCamera();
|
|
1846
2585
|
}, [applyCamera, stopTween]);
|
|
1847
|
-
(0,
|
|
2586
|
+
(0, import_react2.useEffect)(() => {
|
|
1848
2587
|
if (hasNotes) centreRequest.current = true;
|
|
1849
2588
|
setViewportTick((value) => value + 1);
|
|
1850
2589
|
}, [hasNotes, view]);
|
|
1851
|
-
const zoomTo = (0,
|
|
2590
|
+
const zoomTo = (0, import_react2.useCallback)((next, anchor) => {
|
|
1852
2591
|
const viewport = viewportRefCurrent.current;
|
|
1853
2592
|
const current = camera.current;
|
|
1854
2593
|
const target = clampZoom(next);
|
|
@@ -1867,7 +2606,7 @@ window.__ModuleLoader__.load({
|
|
|
1867
2606
|
setZoom(target);
|
|
1868
2607
|
applyCamera();
|
|
1869
2608
|
}, [applyCamera]);
|
|
1870
|
-
const fitWall = (0,
|
|
2609
|
+
const fitWall = (0, import_react2.useCallback)(() => {
|
|
1871
2610
|
const viewport = viewportRefCurrent.current;
|
|
1872
2611
|
if (viewport === null) return;
|
|
1873
2612
|
const availableWidth = viewport.clientWidth || 960;
|
|
@@ -1910,32 +2649,95 @@ window.__ModuleLoader__.load({
|
|
|
1910
2649
|
setZoom(target);
|
|
1911
2650
|
centreOn(centreX, centreY);
|
|
1912
2651
|
}, [centreOn]);
|
|
1913
|
-
const resetView = (0,
|
|
2652
|
+
const resetView = (0, import_react2.useCallback)(() => {
|
|
1914
2653
|
fitWall();
|
|
1915
2654
|
}, [fitWall]);
|
|
1916
|
-
const centreReserve = (0,
|
|
1917
|
-
|
|
2655
|
+
const centreReserve = (0, import_react2.useCallback)(() => {
|
|
2656
|
+
const base = CENTRE_RESERVE;
|
|
1918
2657
|
const viewport = viewportRefCurrent.current;
|
|
1919
|
-
|
|
2658
|
+
const centre = centreRef.current;
|
|
2659
|
+
if (viewport === null || centre === null) return base;
|
|
2660
|
+
const view2 = viewport.getBoundingClientRect();
|
|
2661
|
+
const block = centre.getBoundingClientRect();
|
|
2662
|
+
if (view2.width === 0 || view2.height === 0 || block.width === 0 || block.height === 0) return base;
|
|
1920
2663
|
const zoomNow = camera.current.zoom;
|
|
1921
|
-
const
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1924
|
-
|
|
2664
|
+
const screenX = block.left + block.width / 2 - view2.left;
|
|
2665
|
+
const screenY = block.top + block.height / 2 - view2.top;
|
|
2666
|
+
return {
|
|
2667
|
+
x: (screenX - camera.current.panX) / zoomNow,
|
|
2668
|
+
y: (screenY - camera.current.panY) / zoomNow,
|
|
2669
|
+
halfWidth: base.halfWidth,
|
|
2670
|
+
halfHeight: base.halfHeight
|
|
2671
|
+
};
|
|
2672
|
+
}, []);
|
|
2673
|
+
const revealBox = (0, import_react2.useCallback)((box) => {
|
|
2674
|
+
const viewport = viewportRefCurrent.current;
|
|
2675
|
+
if (viewport === null) return;
|
|
2676
|
+
const width = viewport.clientWidth || 960;
|
|
2677
|
+
const height = viewport.clientHeight || 640;
|
|
1925
2678
|
const margin = 72;
|
|
1926
|
-
const
|
|
1927
|
-
|
|
1928
|
-
const
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2679
|
+
const dock = dockRef.current;
|
|
2680
|
+
const bottomInset = dock === null ? 0 : dock.offsetHeight + 24;
|
|
2681
|
+
const usableBottom = height - margin - bottomInset;
|
|
2682
|
+
const view2 = viewport.getBoundingClientRect();
|
|
2683
|
+
const centre = centreRef.current;
|
|
2684
|
+
const blockRect = centre === null ? null : centre.getBoundingClientRect();
|
|
2685
|
+
const fieldX = blockRect === null ? width / 2 : blockRect.left + blockRect.width / 2 - view2.left;
|
|
2686
|
+
const fieldY = blockRect === null ? height / 2 : blockRect.top + blockRect.height / 2 - view2.top;
|
|
2687
|
+
const reserve = CENTRE_RESERVE;
|
|
2688
|
+
const blockHalf = (zoom2) => ({
|
|
2689
|
+
// The painted overlay is counter-scaled by `min(1, zoom)`, while its world
|
|
2690
|
+
// footprint stays fixed; taking the larger of the two keeps the card clear
|
|
2691
|
+
// of whichever is actually on screen.
|
|
2692
|
+
halfW: reserve.halfWidth * Math.max(1, zoom2),
|
|
2693
|
+
halfH: reserve.halfHeight * Math.max(1, zoom2)
|
|
2694
|
+
});
|
|
2695
|
+
const cardX = box.x + box.width / 2;
|
|
2696
|
+
const cardY = box.y + box.height / 2;
|
|
2697
|
+
const screenX = cardX * camera.current.zoom + camera.current.panX;
|
|
2698
|
+
const screenY = cardY * camera.current.zoom + camera.current.panY;
|
|
2699
|
+
const fitsAt = (x, y2, zoom2) => x - box.width * zoom2 / 2 >= margin && x + box.width * zoom2 / 2 <= width - margin && y2 - box.height * zoom2 / 2 >= margin && y2 + box.height * zoom2 / 2 <= usableBottom;
|
|
2700
|
+
const hiddenAt = (x, y2, zoom2) => {
|
|
2701
|
+
const { halfW, halfH: halfH2 } = blockHalf(zoom2);
|
|
2702
|
+
return x - box.width * zoom2 / 2 < fieldX + halfW && x + box.width * zoom2 / 2 > fieldX - halfW && y2 - box.height * zoom2 / 2 < fieldY + halfH2 && y2 + box.height * zoom2 / 2 > fieldY - halfH2;
|
|
2703
|
+
};
|
|
2704
|
+
if (fitsAt(screenX, screenY, camera.current.zoom) && !hiddenAt(screenX, screenY, camera.current.zoom)) return;
|
|
2705
|
+
const gap = 26;
|
|
2706
|
+
for (let step = 0; step <= 8; step += 1) {
|
|
2707
|
+
const zoom2 = step === 0 ? camera.current.zoom : Math.max(ZOOM_MIN, camera.current.zoom * 0.88 ** step);
|
|
2708
|
+
const { halfW, halfH: halfH2 } = blockHalf(zoom2);
|
|
2709
|
+
const halfCardW = box.width * zoom2 / 2;
|
|
2710
|
+
const halfCardH = box.height * zoom2 / 2;
|
|
2711
|
+
const candidates = [
|
|
2712
|
+
{ x: fieldX, y: fieldY - halfH2 - gap - halfCardH },
|
|
2713
|
+
{ x: fieldX, y: fieldY + halfH2 + gap + halfCardH },
|
|
2714
|
+
{ x: fieldX - halfW - gap - halfCardW, y: fieldY },
|
|
2715
|
+
{ x: fieldX + halfW + gap + halfCardW, y: fieldY }
|
|
2716
|
+
];
|
|
2717
|
+
let best = null;
|
|
2718
|
+
for (const candidate of candidates) {
|
|
2719
|
+
if (!fitsAt(candidate.x, candidate.y, zoom2)) continue;
|
|
2720
|
+
if (hiddenAt(candidate.x, candidate.y, zoom2)) continue;
|
|
2721
|
+
const cost = Math.hypot(candidate.x - screenX, candidate.y - screenY);
|
|
2722
|
+
if (best === null || cost < best.cost) best = { x: candidate.x, y: candidate.y, zoom: zoom2, cost };
|
|
2723
|
+
}
|
|
2724
|
+
if (best !== null) {
|
|
2725
|
+
glideCameraTo(best.zoom, best.x - cardX * best.zoom, best.y - cardY * best.zoom);
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
if (zoom2 <= ZOOM_MIN) break;
|
|
2729
|
+
}
|
|
2730
|
+
const targetZoom = Math.max(ZOOM_MIN, Math.min(
|
|
2731
|
+
camera.current.zoom,
|
|
2732
|
+
(width - margin * 2) / Math.max(1, box.width),
|
|
2733
|
+
(usableBottom - margin) / Math.max(1, box.height)
|
|
2734
|
+
));
|
|
2735
|
+
const { halfH } = blockHalf(targetZoom);
|
|
2736
|
+
const y = fieldY + halfH + gap + box.height * targetZoom / 2;
|
|
2737
|
+
glideCameraTo(targetZoom, width / 2 - cardX * targetZoom, y - cardY * targetZoom);
|
|
2738
|
+
}, [glideCameraTo]);
|
|
2739
|
+
const arrival = (0, import_react2.useRef)(null);
|
|
2740
|
+
(0, import_react2.useEffect)(() => {
|
|
1939
2741
|
const pending = arrival.current;
|
|
1940
2742
|
if (pending === null) return;
|
|
1941
2743
|
const note = notes.find((candidate) => candidate.id === pending.id);
|
|
@@ -1954,7 +2756,7 @@ window.__ModuleLoader__.load({
|
|
|
1954
2756
|
clearTimeout(timer);
|
|
1955
2757
|
};
|
|
1956
2758
|
}, [notes]);
|
|
1957
|
-
const onWheel = (0,
|
|
2759
|
+
const onWheel = (0, import_react2.useCallback)((event) => {
|
|
1958
2760
|
const node = viewportRefCurrent.current;
|
|
1959
2761
|
if (node === null) return;
|
|
1960
2762
|
if (event.ctrlKey || event.metaKey) {
|
|
@@ -1968,7 +2770,7 @@ window.__ModuleLoader__.load({
|
|
|
1968
2770
|
camera.current.panY -= event.deltaY * WHEEL_PAN;
|
|
1969
2771
|
applyCamera();
|
|
1970
2772
|
}, [applyCamera, zoomTo]);
|
|
1971
|
-
const bindViewport = (0,
|
|
2773
|
+
const bindViewport = (0, import_react2.useCallback)((node) => {
|
|
1972
2774
|
viewportRefCurrent.current = node;
|
|
1973
2775
|
detachWheel.current?.();
|
|
1974
2776
|
detachWheel.current = null;
|
|
@@ -1976,14 +2778,14 @@ window.__ModuleLoader__.load({
|
|
|
1976
2778
|
node.addEventListener("wheel", onWheel, { passive: false });
|
|
1977
2779
|
detachWheel.current = () => node.removeEventListener("wheel", onWheel);
|
|
1978
2780
|
}, [onWheel]);
|
|
1979
|
-
(0,
|
|
2781
|
+
(0, import_react2.useEffect)(() => {
|
|
1980
2782
|
const node = viewportRefCurrent.current;
|
|
1981
2783
|
if (node === null) return;
|
|
1982
2784
|
detachWheel.current?.();
|
|
1983
2785
|
node.addEventListener("wheel", onWheel, { passive: false });
|
|
1984
2786
|
detachWheel.current = () => node.removeEventListener("wheel", onWheel);
|
|
1985
2787
|
}, [onWheel]);
|
|
1986
|
-
(0,
|
|
2788
|
+
(0, import_react2.useEffect)(() => {
|
|
1987
2789
|
const node = viewportRefCurrent.current;
|
|
1988
2790
|
if (node === null || typeof ResizeObserver === "undefined") return;
|
|
1989
2791
|
const observer = new ResizeObserver(() => {
|
|
@@ -1994,7 +2796,7 @@ window.__ModuleLoader__.load({
|
|
|
1994
2796
|
observer.observe(node);
|
|
1995
2797
|
return () => observer.disconnect();
|
|
1996
2798
|
}, [view]);
|
|
1997
|
-
(0,
|
|
2799
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
1998
2800
|
if (view !== "canvas") return;
|
|
1999
2801
|
if (centreRequest.current) {
|
|
2000
2802
|
centreRequest.current = false;
|
|
@@ -2050,7 +2852,7 @@ window.__ModuleLoader__.load({
|
|
|
2050
2852
|
lastY: event.clientY
|
|
2051
2853
|
};
|
|
2052
2854
|
}
|
|
2053
|
-
(0,
|
|
2855
|
+
(0, import_react2.useEffect)(() => {
|
|
2054
2856
|
const paintDrag = (current) => {
|
|
2055
2857
|
current.frame = 0;
|
|
2056
2858
|
const node = current.node;
|
|
@@ -2151,7 +2953,7 @@ window.__ModuleLoader__.load({
|
|
|
2151
2953
|
pan.current?.node?.removeAttribute("data-panning");
|
|
2152
2954
|
};
|
|
2153
2955
|
}, [api, applyCamera]);
|
|
2154
|
-
const latestActions = (0,
|
|
2956
|
+
const latestActions = (0, import_react2.useRef)(null);
|
|
2155
2957
|
latestActions.current = {
|
|
2156
2958
|
edit: openComposer,
|
|
2157
2959
|
patch: (note, patch) => {
|
|
@@ -2168,29 +2970,30 @@ window.__ModuleLoader__.load({
|
|
|
2168
2970
|
},
|
|
2169
2971
|
drag: startDrag
|
|
2170
2972
|
};
|
|
2171
|
-
const actions = (0,
|
|
2973
|
+
const actions = (0, import_react2.useMemo)(() => ({
|
|
2172
2974
|
edit: (note) => latestActions.current?.edit(note),
|
|
2173
2975
|
patch: (note, patch) => latestActions.current?.patch(note, patch),
|
|
2174
2976
|
remove: (note) => latestActions.current?.remove(note),
|
|
2175
2977
|
resize: (note, width) => latestActions.current?.resize(note, width),
|
|
2176
2978
|
drag: (note, event) => latestActions.current?.drag(note, event)
|
|
2177
2979
|
}), []);
|
|
2178
|
-
return /* @__PURE__ */ (0,
|
|
2179
|
-
/* @__PURE__ */ (0,
|
|
2180
|
-
/* @__PURE__ */ (0,
|
|
2181
|
-
|
|
2980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "skw-page", "aria-label": t("title"), children: [
|
|
2981
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: WALL_CSS }),
|
|
2982
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: EDITOR_CSS }),
|
|
2983
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-body", "data-view": view, children: [
|
|
2984
|
+
error !== "" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "skw-error", role: "alert", children: [
|
|
2182
2985
|
error,
|
|
2183
2986
|
" ",
|
|
2184
|
-
/* @__PURE__ */ (0,
|
|
2987
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "skw-btn skw-btn-quiet", type: "button", onClick: () => void reload({ includeArchived, sort }), children: t("retry") })
|
|
2185
2988
|
] }),
|
|
2186
|
-
loading && notes.length === 0 ? /* @__PURE__ */ (0,
|
|
2187
|
-
visible.map((note) => /* @__PURE__ */ (0,
|
|
2188
|
-
visible.length === 0 && /* @__PURE__ */ (0,
|
|
2189
|
-
] }) : view === "grid" ? /* @__PURE__ */ (0,
|
|
2190
|
-
visible.map((note) => /* @__PURE__ */ (0,
|
|
2191
|
-
visible.length === 0 && /* @__PURE__ */ (0,
|
|
2192
|
-
] }) : /* @__PURE__ */ (0,
|
|
2193
|
-
/* @__PURE__ */ (0,
|
|
2989
|
+
loading && notes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-empty", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t("loading") }) }) : view === "list" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-list", children: [
|
|
2990
|
+
visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NoteRow, { note, t, locale: activeLocale, onEdit: openComposer }, note.id)),
|
|
2991
|
+
visible.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "skw-list-empty", children: emptyCopy })
|
|
2992
|
+
] }) : view === "grid" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-grid", children: [
|
|
2993
|
+
visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NoteCard, { note, index: indexOf(note), surface: "grid", t, locale: activeLocale, actions }, note.id)),
|
|
2994
|
+
visible.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "skw-list-empty", children: emptyCopy })
|
|
2995
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { ref: bindViewport, className: "skw-canvas", "data-zoomed": zoom !== 1, onPointerDown: startPan, children: [
|
|
2996
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: worldRef, className: "skw-world", children: visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2194
2997
|
NoteCard,
|
|
2195
2998
|
{
|
|
2196
2999
|
note,
|
|
@@ -2203,10 +3006,10 @@ window.__ModuleLoader__.load({
|
|
|
2203
3006
|
},
|
|
2204
3007
|
note.id
|
|
2205
3008
|
)) }),
|
|
2206
|
-
/* @__PURE__ */ (0,
|
|
2207
|
-
/* @__PURE__ */ (0,
|
|
2208
|
-
/* @__PURE__ */ (0,
|
|
2209
|
-
/* @__PURE__ */ (0,
|
|
3009
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-centre", ref: centreRef, "aria-hidden": false, children: [
|
|
3010
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "skw-centre-hello", children: greeting }),
|
|
3011
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "skw-centre-tally", "data-empty": visible.length === 0, children: visible.length === 0 ? emptyCopy : t("centreTally", { count: visible.length, archived: archivedCount }) }),
|
|
3012
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2210
3013
|
"form",
|
|
2211
3014
|
{
|
|
2212
3015
|
className: "skw-capture",
|
|
@@ -2222,8 +3025,8 @@ window.__ModuleLoader__.load({
|
|
|
2222
3025
|
});
|
|
2223
3026
|
},
|
|
2224
3027
|
children: [
|
|
2225
|
-
/* @__PURE__ */ (0,
|
|
2226
|
-
/* @__PURE__ */ (0,
|
|
3028
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-capture-icon", "aria-hidden": "true", children: "\u270E" }),
|
|
3029
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2227
3030
|
"input",
|
|
2228
3031
|
{
|
|
2229
3032
|
className: "skw-capture-input",
|
|
@@ -2234,20 +3037,20 @@ window.__ModuleLoader__.load({
|
|
|
2234
3037
|
onChange: (event) => setCapture(event.target.value)
|
|
2235
3038
|
}
|
|
2236
3039
|
),
|
|
2237
|
-
/* @__PURE__ */ (0,
|
|
3040
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "skw-capture-go", type: "submit", disabled: busy || capture.trim() === "", "aria-label": t("captureGo"), children: "\u21B5" })
|
|
2238
3041
|
]
|
|
2239
3042
|
}
|
|
2240
3043
|
)
|
|
2241
3044
|
] })
|
|
2242
3045
|
] })
|
|
2243
3046
|
] }),
|
|
2244
|
-
/* @__PURE__ */ (0,
|
|
2245
|
-
/* @__PURE__ */ (0,
|
|
2246
|
-
/* @__PURE__ */ (0,
|
|
2247
|
-
/* @__PURE__ */ (0,
|
|
2248
|
-
/* @__PURE__ */ (0,
|
|
3047
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-dock", ref: dockRef, role: "toolbar", "aria-label": t("title"), children: [
|
|
3048
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-search-wrap", children: [
|
|
3049
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-search-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", children: [
|
|
3050
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "10.5", cy: "10.5", r: "6.2", stroke: "currentColor", strokeWidth: "1.8" }),
|
|
3051
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M15.4 15.4L20 20", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
|
|
2249
3052
|
] }) }),
|
|
2250
|
-
/* @__PURE__ */ (0,
|
|
3053
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2251
3054
|
"input",
|
|
2252
3055
|
{
|
|
2253
3056
|
className: "skw-search",
|
|
@@ -2259,8 +3062,8 @@ window.__ModuleLoader__.load({
|
|
|
2259
3062
|
}
|
|
2260
3063
|
)
|
|
2261
3064
|
] }),
|
|
2262
|
-
/* @__PURE__ */ (0,
|
|
2263
|
-
/* @__PURE__ */ (0,
|
|
3065
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-dock-divider", "aria-hidden": "true" }),
|
|
3066
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-seg", role: "group", "aria-label": t("filters"), children: ["all", "pinned", "archived"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2264
3067
|
"button",
|
|
2265
3068
|
{
|
|
2266
3069
|
type: "button",
|
|
@@ -2271,8 +3074,8 @@ window.__ModuleLoader__.load({
|
|
|
2271
3074
|
},
|
|
2272
3075
|
key
|
|
2273
3076
|
)) }),
|
|
2274
|
-
/* @__PURE__ */ (0,
|
|
2275
|
-
/* @__PURE__ */ (0,
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-dock-divider", "aria-hidden": "true" }),
|
|
3078
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-seg skw-seg-icons", role: "group", "aria-label": t("viewLabel"), children: ["canvas", "grid", "list"].map((mode) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2276
3079
|
"button",
|
|
2277
3080
|
{
|
|
2278
3081
|
type: "button",
|
|
@@ -2281,23 +3084,23 @@ window.__ModuleLoader__.load({
|
|
|
2281
3084
|
"aria-label": t(`view_${mode}`),
|
|
2282
3085
|
title: t(`view_${mode}`),
|
|
2283
3086
|
"aria-pressed": view === mode,
|
|
2284
|
-
children: mode === "canvas" ? /* @__PURE__ */ (0,
|
|
2285
|
-
/* @__PURE__ */ (0,
|
|
2286
|
-
/* @__PURE__ */ (0,
|
|
2287
|
-
/* @__PURE__ */ (0,
|
|
2288
|
-
] }) : mode === "grid" ? /* @__PURE__ */ (0,
|
|
2289
|
-
/* @__PURE__ */ (0,
|
|
2290
|
-
/* @__PURE__ */ (0,
|
|
2291
|
-
/* @__PURE__ */ (0,
|
|
2292
|
-
/* @__PURE__ */ (0,
|
|
2293
|
-
] }) : /* @__PURE__ */ (0,
|
|
3087
|
+
children: mode === "canvas" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
3088
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "3", y: "4", width: "8", height: "7", rx: "1.6", stroke: "currentColor", strokeWidth: "1.7" }),
|
|
3089
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "13", y: "7", width: "8", height: "6", rx: "1.6", stroke: "currentColor", strokeWidth: "1.7" }),
|
|
3090
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "6", y: "14", width: "8", height: "6", rx: "1.6", stroke: "currentColor", strokeWidth: "1.7" })
|
|
3091
|
+
] }) : mode === "grid" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
3092
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "3.5", y: "3.5", width: "7", height: "7", rx: "1.6", stroke: "currentColor", strokeWidth: "1.7" }),
|
|
3093
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "13.5", y: "3.5", width: "7", height: "7", rx: "1.6", stroke: "currentColor", strokeWidth: "1.7" }),
|
|
3094
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "3.5", y: "13.5", width: "7", height: "7", rx: "1.6", stroke: "currentColor", strokeWidth: "1.7" }),
|
|
3095
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "13.5", y: "13.5", width: "7", height: "7", rx: "1.6", stroke: "currentColor", strokeWidth: "1.7" })
|
|
3096
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 6.5h16M4 12h16M4 17.5h11", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" }) })
|
|
2294
3097
|
},
|
|
2295
3098
|
mode
|
|
2296
3099
|
)) }),
|
|
2297
|
-
view === "canvas" && /* @__PURE__ */ (0,
|
|
2298
|
-
/* @__PURE__ */ (0,
|
|
2299
|
-
/* @__PURE__ */ (0,
|
|
2300
|
-
/* @__PURE__ */ (0,
|
|
3100
|
+
view === "canvas" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
3101
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-dock-divider", "aria-hidden": "true" }),
|
|
3102
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-dock-zoom", role: "group", "aria-label": t("zoomLabel"), children: [
|
|
3103
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2301
3104
|
"button",
|
|
2302
3105
|
{
|
|
2303
3106
|
className: "skw-camera-btn",
|
|
@@ -2308,7 +3111,7 @@ window.__ModuleLoader__.load({
|
|
|
2308
3111
|
children: "\u2212"
|
|
2309
3112
|
}
|
|
2310
3113
|
),
|
|
2311
|
-
/* @__PURE__ */ (0,
|
|
3114
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2312
3115
|
"button",
|
|
2313
3116
|
{
|
|
2314
3117
|
className: "skw-camera-value",
|
|
@@ -2322,7 +3125,7 @@ window.__ModuleLoader__.load({
|
|
|
2322
3125
|
]
|
|
2323
3126
|
}
|
|
2324
3127
|
),
|
|
2325
|
-
/* @__PURE__ */ (0,
|
|
3128
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2326
3129
|
"button",
|
|
2327
3130
|
{
|
|
2328
3131
|
className: "skw-camera-btn",
|
|
@@ -2333,7 +3136,7 @@ window.__ModuleLoader__.load({
|
|
|
2333
3136
|
children: "+"
|
|
2334
3137
|
}
|
|
2335
3138
|
),
|
|
2336
|
-
/* @__PURE__ */ (0,
|
|
3139
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2337
3140
|
"button",
|
|
2338
3141
|
{
|
|
2339
3142
|
className: "skw-camera-btn",
|
|
@@ -2342,8 +3145,8 @@ window.__ModuleLoader__.load({
|
|
|
2342
3145
|
title: t("arrange"),
|
|
2343
3146
|
disabled: busy || visible.length === 0,
|
|
2344
3147
|
onClick: () => void tidyWall(),
|
|
2345
|
-
children: /* @__PURE__ */ (0,
|
|
2346
|
-
/* @__PURE__ */ (0,
|
|
3148
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
3149
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2347
3150
|
"path",
|
|
2348
3151
|
{
|
|
2349
3152
|
d: "M12 3.5l1.9 5.1 5.1 1.9-5.1 1.9L12 17.5l-1.9-5.1L5 10.5l5.1-1.9L12 3.5Z",
|
|
@@ -2352,15 +3155,15 @@ window.__ModuleLoader__.load({
|
|
|
2352
3155
|
strokeLinejoin: "round"
|
|
2353
3156
|
}
|
|
2354
3157
|
),
|
|
2355
|
-
/* @__PURE__ */ (0,
|
|
3158
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M18.5 16.5l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8.8-2Z", fill: "currentColor" })
|
|
2356
3159
|
] })
|
|
2357
3160
|
}
|
|
2358
3161
|
)
|
|
2359
3162
|
] })
|
|
2360
3163
|
] }),
|
|
2361
|
-
/* @__PURE__ */ (0,
|
|
2362
|
-
/* @__PURE__ */ (0,
|
|
2363
|
-
/* @__PURE__ */ (0,
|
|
3164
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-dock-divider", "aria-hidden": "true" }),
|
|
3165
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-menu-wrap", ref: menuRef, children: [
|
|
3166
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2364
3167
|
"button",
|
|
2365
3168
|
{
|
|
2366
3169
|
className: "skw-camera-btn",
|
|
@@ -2371,16 +3174,16 @@ window.__ModuleLoader__.load({
|
|
|
2371
3174
|
"aria-expanded": menuOpen,
|
|
2372
3175
|
"aria-haspopup": "menu",
|
|
2373
3176
|
onClick: () => setMenuOpen((value) => !value),
|
|
2374
|
-
children: /* @__PURE__ */ (0,
|
|
2375
|
-
/* @__PURE__ */ (0,
|
|
2376
|
-
/* @__PURE__ */ (0,
|
|
2377
|
-
/* @__PURE__ */ (0,
|
|
3177
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
3178
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "6", cy: "12", r: "1.6", fill: "currentColor" }),
|
|
3179
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "1.6", fill: "currentColor" }),
|
|
3180
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "18", cy: "12", r: "1.6", fill: "currentColor" })
|
|
2378
3181
|
] })
|
|
2379
3182
|
}
|
|
2380
3183
|
),
|
|
2381
|
-
menuOpen && /* @__PURE__ */ (0,
|
|
2382
|
-
/* @__PURE__ */ (0,
|
|
2383
|
-
["pinned", "created", "updated"].map((key) => /* @__PURE__ */ (0,
|
|
3184
|
+
menuOpen && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "skw-menu", role: "menu", "aria-label": t("more"), children: [
|
|
3185
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-menu-label", children: t("sortLabel") }),
|
|
3186
|
+
["pinned", "created", "updated"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2384
3187
|
"button",
|
|
2385
3188
|
{
|
|
2386
3189
|
type: "button",
|
|
@@ -2392,14 +3195,14 @@ window.__ModuleLoader__.load({
|
|
|
2392
3195
|
setMenuOpen(false);
|
|
2393
3196
|
},
|
|
2394
3197
|
children: [
|
|
2395
|
-
/* @__PURE__ */ (0,
|
|
3198
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-menu-tick", "aria-hidden": "true", children: sort === key ? "\u2713" : "" }),
|
|
2396
3199
|
key === "pinned" ? t("sortPinned") : key === "created" ? t("sortCreated") : t("sortUpdated")
|
|
2397
3200
|
]
|
|
2398
3201
|
},
|
|
2399
3202
|
key
|
|
2400
3203
|
)),
|
|
2401
|
-
/* @__PURE__ */ (0,
|
|
2402
|
-
/* @__PURE__ */ (0,
|
|
3204
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "skw-menu-rule", role: "separator" }),
|
|
3205
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2403
3206
|
"button",
|
|
2404
3207
|
{
|
|
2405
3208
|
type: "button",
|
|
@@ -2408,12 +3211,12 @@ window.__ModuleLoader__.load({
|
|
|
2408
3211
|
"data-on": showArchived,
|
|
2409
3212
|
onClick: () => setShowArchived((value) => !value),
|
|
2410
3213
|
children: [
|
|
2411
|
-
/* @__PURE__ */ (0,
|
|
3214
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-menu-tick", "aria-hidden": "true", children: showArchived ? "\u2713" : "" }),
|
|
2412
3215
|
showArchived ? t("hideArchived") : t("showArchived")
|
|
2413
3216
|
]
|
|
2414
3217
|
}
|
|
2415
3218
|
),
|
|
2416
|
-
archivedCount > 0 && /* @__PURE__ */ (0,
|
|
3219
|
+
archivedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2417
3220
|
"button",
|
|
2418
3221
|
{
|
|
2419
3222
|
type: "button",
|
|
@@ -2425,23 +3228,25 @@ window.__ModuleLoader__.load({
|
|
|
2425
3228
|
setConfirming("clear");
|
|
2426
3229
|
},
|
|
2427
3230
|
children: [
|
|
2428
|
-
/* @__PURE__ */ (0,
|
|
3231
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-menu-tick", "aria-hidden": "true" }),
|
|
2429
3232
|
t("clearArchived")
|
|
2430
3233
|
]
|
|
2431
3234
|
}
|
|
2432
3235
|
)
|
|
2433
3236
|
] })
|
|
2434
3237
|
] }),
|
|
2435
|
-
/* @__PURE__ */ (0,
|
|
2436
|
-
/* @__PURE__ */ (0,
|
|
3238
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "skw-count", children: t("count", { count: visible.length }) }),
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "skw-dock-new", type: "button", onClick: () => openComposer(), disabled: busy, "aria-label": t("new"), title: t("new"), children: "+" })
|
|
2437
3240
|
] }),
|
|
2438
|
-
draft && /* @__PURE__ */ (0,
|
|
3241
|
+
draft && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2439
3242
|
Composer,
|
|
2440
3243
|
{
|
|
2441
3244
|
draft,
|
|
2442
3245
|
t,
|
|
3246
|
+
locale: activeLocale,
|
|
2443
3247
|
busy,
|
|
2444
3248
|
error: draftError,
|
|
3249
|
+
status: draftStatus,
|
|
2445
3250
|
onChange: (patch) => setDraft((current) => current === null ? current : { ...current, ...patch }),
|
|
2446
3251
|
onSave: () => void saveDraft(),
|
|
2447
3252
|
onCancel: () => {
|
|
@@ -2452,7 +3257,7 @@ window.__ModuleLoader__.load({
|
|
|
2452
3257
|
}
|
|
2453
3258
|
}
|
|
2454
3259
|
),
|
|
2455
|
-
confirming !== null && /* @__PURE__ */ (0,
|
|
3260
|
+
confirming !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2456
3261
|
ConfirmDialog,
|
|
2457
3262
|
{
|
|
2458
3263
|
title: confirming === "clear" ? t("clearArchived") : t("delete"),
|
|
@@ -2488,7 +3293,7 @@ window.__ModuleLoader__.load({
|
|
|
2488
3293
|
}
|
|
2489
3294
|
|
|
2490
3295
|
// src/client/index.tsx
|
|
2491
|
-
var
|
|
3296
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2492
3297
|
var inject = ["slots", "locale", "connection"];
|
|
2493
3298
|
var SIDEBAR_SLOT = "sidebar.panellist";
|
|
2494
3299
|
var MAIN_SLOT = "main";
|
|
@@ -2521,7 +3326,7 @@ window.__ModuleLoader__.load({
|
|
|
2521
3326
|
"skillre-sticky-wall sidebar entry"
|
|
2522
3327
|
);
|
|
2523
3328
|
ctx.effect(
|
|
2524
|
-
() => ctx.slots.inject(MAIN_SLOT, () => ctx.slots.register({ name: MAIN_SLOT, key: PANEL_ID }, () => /* @__PURE__ */ (0,
|
|
3329
|
+
() => ctx.slots.inject(MAIN_SLOT, () => ctx.slots.register({ name: MAIN_SLOT, key: PANEL_ID }, () => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WallPage, { api, locale: ctx.locale, t }))),
|
|
2525
3330
|
"skillre-sticky-wall wall page"
|
|
2526
3331
|
);
|
|
2527
3332
|
}
|