@w100n/documents 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SheetView-SBLAFGTL.js → SheetView-F4CBWEOS.js} +4 -4
- package/dist/{TextEditor-X2GSL4QM.js → TextEditor-ZY4B7YIF.js} +5 -5
- package/dist/{chunk-A6AHJCEK.js → chunk-2G34AIPU.js} +3 -3
- package/dist/{chunk-A6AHJCEK.js.map → chunk-2G34AIPU.js.map} +1 -1
- package/dist/{chunk-B7C6NBBQ.js → chunk-BWU6FPPZ.js} +28 -1
- package/dist/chunk-BWU6FPPZ.js.map +1 -0
- package/dist/{chunk-ASTNK6WZ.js → chunk-TSB2QS56.js} +2 -2
- package/dist/{chunk-FFXAOK4A.js → chunk-Z5STMOD6.js} +2 -2
- package/dist/collab.cjs +28 -1
- package/dist/collab.cjs.map +1 -1
- package/dist/collab.d.cts +1 -1
- package/dist/collab.d.ts +1 -1
- package/dist/collab.js +2 -2
- package/dist/index.cjs +277 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +28 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +261 -53
- package/dist/index.js.map +1 -1
- package/dist/kinds.d.cts +1 -1
- package/dist/kinds.d.ts +1 -1
- package/dist/memory.cjs +33 -5
- package/dist/memory.cjs.map +1 -1
- package/dist/memory.d.cts +1 -1
- package/dist/memory.d.ts +1 -1
- package/dist/memory.js +33 -5
- package/dist/memory.js.map +1 -1
- package/dist/{types-CHmV8GLx.d.cts → types-DyonaPQf.d.cts} +11 -1
- package/dist/{types-CHmV8GLx.d.ts → types-DyonaPQf.d.ts} +11 -1
- package/package.json +1 -1
- package/dist/chunk-B7C6NBBQ.js.map +0 -1
- /package/dist/{SheetView-SBLAFGTL.js.map → SheetView-F4CBWEOS.js.map} +0 -0
- /package/dist/{TextEditor-X2GSL4QM.js.map → TextEditor-ZY4B7YIF.js.map} +0 -0
- /package/dist/{chunk-ASTNK6WZ.js.map → chunk-TSB2QS56.js.map} +0 -0
- /package/dist/{chunk-FFXAOK4A.js.map → chunk-Z5STMOD6.js.map} +0 -0
package/dist/collab.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSONContent } from '@tiptap/core';
|
|
2
2
|
import * as Y from 'yjs';
|
|
3
3
|
import { I as Img } from './write-BCI8yool.cjs';
|
|
4
|
-
import { L as Language } from './types-
|
|
4
|
+
import { L as Language } from './types-DyonaPQf.cjs';
|
|
5
5
|
|
|
6
6
|
declare function applyCells(doc: Y.Doc, list: {
|
|
7
7
|
sheet: string;
|
package/dist/collab.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSONContent } from '@tiptap/core';
|
|
2
2
|
import * as Y from 'yjs';
|
|
3
3
|
import { I as Img } from './write-BCI8yool.js';
|
|
4
|
-
import { L as Language } from './types-
|
|
4
|
+
import { L as Language } from './types-DyonaPQf.js';
|
|
5
5
|
|
|
6
6
|
declare function applyCells(doc: Y.Doc, list: {
|
|
7
7
|
sheet: string;
|
package/dist/collab.js
CHANGED
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
pending,
|
|
12
12
|
save,
|
|
13
13
|
seed
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2G34AIPU.js";
|
|
15
15
|
import "./chunk-GSIPTCQH.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-BWU6FPPZ.js";
|
|
17
17
|
import "./chunk-ZAVXCH7V.js";
|
|
18
18
|
import "./chunk-ISOOUYLI.js";
|
|
19
19
|
export {
|
package/dist/index.cjs
CHANGED
|
@@ -68,6 +68,15 @@ var init_text = __esm({
|
|
|
68
68
|
"use strict";
|
|
69
69
|
en2 = {
|
|
70
70
|
elsewhere: "Other",
|
|
71
|
+
newFolder: "New folder",
|
|
72
|
+
newNoteHere: "New note here",
|
|
73
|
+
renameFolder: "Rename folder",
|
|
74
|
+
trashFolder: "Move folder to trash",
|
|
75
|
+
folderTrashAsk: "Move {name} and everything in it to trash?",
|
|
76
|
+
moveTo: "Move to",
|
|
77
|
+
folderActions: "Folder actions",
|
|
78
|
+
folderName: "Folder name",
|
|
79
|
+
topLevel: "Top level",
|
|
71
80
|
wikiCreate: "Create \u201C{name}\u201D",
|
|
72
81
|
wikiNew: "new note",
|
|
73
82
|
wikiKeys: "\u2191\u2193 pick \xB7 \u21B5 link \xB7 | alias",
|
|
@@ -444,6 +453,15 @@ var init_text = __esm({
|
|
|
444
453
|
};
|
|
445
454
|
pl2 = {
|
|
446
455
|
elsewhere: "Inne",
|
|
456
|
+
newFolder: "Nowy folder",
|
|
457
|
+
newNoteHere: "Nowa notatka tutaj",
|
|
458
|
+
renameFolder: "Zmie\u0144 nazw\u0119 folderu",
|
|
459
|
+
trashFolder: "Przenie\u015B folder do kosza",
|
|
460
|
+
folderTrashAsk: "Przenie\u015B\u0107 {name} z ca\u0142\u0105 zawarto\u015Bci\u0105 do kosza?",
|
|
461
|
+
moveTo: "Przenie\u015B do",
|
|
462
|
+
folderActions: "Dzia\u0142ania na folderze",
|
|
463
|
+
folderName: "Nazwa folderu",
|
|
464
|
+
topLevel: "Najwy\u017Cszy poziom",
|
|
447
465
|
wikiCreate: "Utw\xF3rz \u201E{name}\u201D",
|
|
448
466
|
wikiNew: "nowa notatka",
|
|
449
467
|
wikiKeys: "\u2191\u2193 wyb\xF3r \xB7 \u21B5 link \xB7 | alias",
|
|
@@ -820,6 +838,15 @@ var init_text = __esm({
|
|
|
820
838
|
};
|
|
821
839
|
uk2 = {
|
|
822
840
|
elsewhere: "\u0406\u043D\u0448\u0435",
|
|
841
|
+
newFolder: "\u041D\u043E\u0432\u0430 \u043F\u0430\u043F\u043A\u0430",
|
|
842
|
+
newNoteHere: "\u041D\u043E\u0432\u0430 \u043D\u043E\u0442\u0430\u0442\u043A\u0430 \u0442\u0443\u0442",
|
|
843
|
+
renameFolder: "\u041F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438 \u043F\u0430\u043F\u043A\u0443",
|
|
844
|
+
trashFolder: "\u041F\u0430\u043F\u043A\u0443 \u0432 \u043A\u043E\u0448\u0438\u043A",
|
|
845
|
+
folderTrashAsk: "\u041F\u0435\u0440\u0435\u043C\u0456\u0441\u0442\u0438\u0442\u0438 {name} \u0437 \u0443\u0441\u0456\u043C \u0432\u043C\u0456\u0441\u0442\u043E\u043C \u0443 \u043A\u043E\u0448\u0438\u043A?",
|
|
846
|
+
moveTo: "\u041F\u0435\u0440\u0435\u043D\u0435\u0441\u0442\u0438 \u0432",
|
|
847
|
+
folderActions: "\u0414\u0456\u0457 \u0437 \u043F\u0430\u043F\u043A\u043E\u044E",
|
|
848
|
+
folderName: "\u041D\u0430\u0437\u0432\u0430 \u043F\u0430\u043F\u043A\u0438",
|
|
849
|
+
topLevel: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u0440\u0456\u0432\u0435\u043D\u044C",
|
|
823
850
|
wikiCreate: "\u0421\u0442\u0432\u043E\u0440\u0438\u0442\u0438 \xAB{name}\xBB",
|
|
824
851
|
wikiNew: "\u043D\u043E\u0432\u0430 \u043D\u043E\u0442\u0430\u0442\u043A\u0430",
|
|
825
852
|
wikiKeys: "\u2191\u2193 \u0432\u0438\u0431\u0456\u0440 \xB7 \u21B5 \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F \xB7 | \u043F\u0456\u0434\u043F\u0438\u0441",
|
|
@@ -4966,7 +4993,7 @@ var init_wiki = __esm({
|
|
|
4966
4993
|
var version;
|
|
4967
4994
|
var init_package = __esm({
|
|
4968
4995
|
"package.json"() {
|
|
4969
|
-
version = "0.
|
|
4996
|
+
version = "0.18.1";
|
|
4970
4997
|
}
|
|
4971
4998
|
});
|
|
4972
4999
|
|
|
@@ -14362,21 +14389,31 @@ var import_react18 = require("react");
|
|
|
14362
14389
|
var import_lucide_react12 = require("lucide-react");
|
|
14363
14390
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
14364
14391
|
var icons3 = { docx: import_lucide_react12.FileText, markdown: import_lucide_react12.FileType, pdf: import_lucide_react12.Files, sheet: import_lucide_react12.FileSpreadsheet, slides: import_lucide_react12.Presentation };
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
}
|
|
14378
|
-
|
|
14392
|
+
var dragged = "application/x-w100n-document";
|
|
14393
|
+
function grow(items, folders, names2, spaceId, other) {
|
|
14394
|
+
const root = { key: "", name: "", at: spaceId ? { spaceId, folder: "" } : null, folders: [], files: [], count: 0 };
|
|
14395
|
+
const step = (from, name, at2, count) => {
|
|
14396
|
+
const key2 = `${from.key}/${name}`;
|
|
14397
|
+
let next = from.folders.find((f) => f.key === key2);
|
|
14398
|
+
if (!next) from.folders.push(next = { key: key2, name, at: at2, folders: [], files: [], count: 0 });
|
|
14399
|
+
if (count) next.count++;
|
|
14400
|
+
return next;
|
|
14401
|
+
};
|
|
14402
|
+
const reach = (space, folder2, count) => {
|
|
14403
|
+
if (count) root.count++;
|
|
14404
|
+
let at2 = spaceId ? root : step(root, names2.get(space) ?? other, { spaceId: space, folder: "" }, count);
|
|
14405
|
+
let path = "";
|
|
14406
|
+
for (const part of folder2.split("/").filter(Boolean)) {
|
|
14407
|
+
path = path ? `${path}/${part}` : part;
|
|
14408
|
+
at2 = step(at2, part, { spaceId: space, folder: path }, count);
|
|
14409
|
+
}
|
|
14410
|
+
return at2;
|
|
14411
|
+
};
|
|
14412
|
+
if (!spaceId) {
|
|
14413
|
+
for (const id of names2.keys()) if (folders.has(id)) reach(id, "", false);
|
|
14379
14414
|
}
|
|
14415
|
+
for (const [space, paths] of folders) for (const path of paths) reach(space, path, false);
|
|
14416
|
+
for (const item of items) reach(item.spaceId, item.folder ?? "", true).files.push(item);
|
|
14380
14417
|
const sort = (b) => {
|
|
14381
14418
|
b.folders.sort((x, y) => x.name.localeCompare(y.name));
|
|
14382
14419
|
b.files.sort((x, y) => x.name.localeCompare(y.name));
|
|
@@ -14392,29 +14429,84 @@ var remembered = () => {
|
|
|
14392
14429
|
return /* @__PURE__ */ new Set();
|
|
14393
14430
|
}
|
|
14394
14431
|
};
|
|
14395
|
-
function Tree({ items, names: names2,
|
|
14432
|
+
function Tree({ items, folders, names: names2, spaceId, current, t, edit, onOpen, onMenu, onFolderMenu, onMove, onEdit, onEditDone, onWarm }) {
|
|
14396
14433
|
const [closed2, setClosed] = (0, import_react18.useState)(remembered);
|
|
14434
|
+
const [over, setOver] = (0, import_react18.useState)(null);
|
|
14397
14435
|
const flip = (key2) => {
|
|
14398
14436
|
const next = new Set(closed2);
|
|
14399
14437
|
if (!next.delete(key2)) next.add(key2);
|
|
14400
14438
|
setClosed(next);
|
|
14401
14439
|
localStorage.setItem("w100n-docs-closed", JSON.stringify([...next]));
|
|
14402
14440
|
};
|
|
14441
|
+
const field = (pad, label) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
14442
|
+
"input",
|
|
14443
|
+
{
|
|
14444
|
+
className: "w100n-tree-row w100n-tree-input",
|
|
14445
|
+
style: { paddingLeft: pad },
|
|
14446
|
+
autoFocus: true,
|
|
14447
|
+
value: edit.text,
|
|
14448
|
+
"aria-label": label,
|
|
14449
|
+
onFocus: (e) => e.currentTarget.select(),
|
|
14450
|
+
onChange: (e) => onEdit(e.target.value),
|
|
14451
|
+
onBlur: onEditDone,
|
|
14452
|
+
onKeyDown: (e) => {
|
|
14453
|
+
if (e.key === "Enter") e.currentTarget.blur();
|
|
14454
|
+
if (e.key === "Escape") {
|
|
14455
|
+
e.stopPropagation();
|
|
14456
|
+
onEdit(null);
|
|
14457
|
+
}
|
|
14458
|
+
}
|
|
14459
|
+
}
|
|
14460
|
+
);
|
|
14461
|
+
const target = (b) => onMove && b.at ? {
|
|
14462
|
+
onDragOver: (e) => {
|
|
14463
|
+
if (!e.dataTransfer.types.includes(dragged)) return;
|
|
14464
|
+
e.preventDefault();
|
|
14465
|
+
e.stopPropagation();
|
|
14466
|
+
setOver(b.key);
|
|
14467
|
+
},
|
|
14468
|
+
onDragLeave: () => setOver(null),
|
|
14469
|
+
onDrop: (e) => {
|
|
14470
|
+
const id = e.dataTransfer.getData(dragged);
|
|
14471
|
+
setOver(null);
|
|
14472
|
+
if (!id) return;
|
|
14473
|
+
e.preventDefault();
|
|
14474
|
+
e.stopPropagation();
|
|
14475
|
+
onMove(id, b.at);
|
|
14476
|
+
}
|
|
14477
|
+
} : {};
|
|
14403
14478
|
const branch = (b, depth) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
14479
|
+
edit?.key === `new:${b.key}` && field(24 + depth * 16, t.folderName),
|
|
14404
14480
|
b.folders.map((f) => {
|
|
14405
|
-
const open = !closed2.has(f.key)
|
|
14406
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { role: "group", "aria-label": f.name, children: [
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
|
|
14481
|
+
const open = !closed2.has(f.key) || edit?.key === `new:${f.key}`;
|
|
14482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { role: "group", "aria-label": f.name, "data-over": over === f.key || void 0, ...target(f), children: [
|
|
14483
|
+
edit?.key === `dir:${f.key}` ? field(24 + depth * 16, t.renameFolder) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
14484
|
+
"button",
|
|
14485
|
+
{
|
|
14486
|
+
type: "button",
|
|
14487
|
+
className: "w100n-tree-row",
|
|
14488
|
+
"aria-expanded": open,
|
|
14489
|
+
style: { paddingLeft: 24 + depth * 16 },
|
|
14490
|
+
onClick: () => flip(f.key),
|
|
14491
|
+
onContextMenu: onFolderMenu && f.at ? (e) => {
|
|
14492
|
+
e.preventDefault();
|
|
14493
|
+
e.stopPropagation();
|
|
14494
|
+
onFolderMenu(f.at, f.key, e);
|
|
14495
|
+
} : void 0,
|
|
14496
|
+
children: [
|
|
14497
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react12.ChevronDown, { "aria-hidden": true, className: "w100n-tree-fold" }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react12.ChevronRight, { "aria-hidden": true, className: "w100n-tree-fold" }),
|
|
14498
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react12.Folder, { "aria-hidden": true }),
|
|
14499
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: f.name }),
|
|
14500
|
+
f.count > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { children: f.count })
|
|
14501
|
+
]
|
|
14502
|
+
}
|
|
14503
|
+
),
|
|
14413
14504
|
open && branch(f, depth + 1)
|
|
14414
14505
|
] }, f.key);
|
|
14415
14506
|
}),
|
|
14416
14507
|
b.files.map((item) => {
|
|
14417
14508
|
const Icon = icons3[item.kind];
|
|
14509
|
+
if (edit?.key === `file:${item.id}`) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { children: field(24 + depth * 16, t.rename) }, item.id);
|
|
14418
14510
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
14419
14511
|
"button",
|
|
14420
14512
|
{
|
|
@@ -14423,11 +14515,17 @@ function Tree({ items, names: names2, bySpace, current, t, onOpen, onMenu, onWar
|
|
|
14423
14515
|
"aria-current": item.id === current,
|
|
14424
14516
|
title: item.name,
|
|
14425
14517
|
style: { paddingLeft: 24 + depth * 16 },
|
|
14518
|
+
draggable: !!onMove,
|
|
14519
|
+
onDragStart: (e) => {
|
|
14520
|
+
e.dataTransfer.setData(dragged, item.id);
|
|
14521
|
+
e.dataTransfer.effectAllowed = "move";
|
|
14522
|
+
},
|
|
14426
14523
|
onClick: () => onOpen(item),
|
|
14427
14524
|
onPointerEnter: () => onWarm(item),
|
|
14428
14525
|
onPointerLeave: () => onWarm(null),
|
|
14429
14526
|
onContextMenu: (e) => {
|
|
14430
14527
|
e.preventDefault();
|
|
14528
|
+
e.stopPropagation();
|
|
14431
14529
|
onMenu(item, e);
|
|
14432
14530
|
},
|
|
14433
14531
|
children: [
|
|
@@ -14440,7 +14538,21 @@ function Tree({ items, names: names2, bySpace, current, t, onOpen, onMenu, onWar
|
|
|
14440
14538
|
);
|
|
14441
14539
|
})
|
|
14442
14540
|
] });
|
|
14443
|
-
|
|
14541
|
+
const root = grow(items, folders, names2, spaceId, t.elsewhere);
|
|
14542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
14543
|
+
"nav",
|
|
14544
|
+
{
|
|
14545
|
+
className: "w100n-tree",
|
|
14546
|
+
"aria-label": t.tree,
|
|
14547
|
+
"data-over": over === "" || void 0,
|
|
14548
|
+
...target(root),
|
|
14549
|
+
onContextMenu: onFolderMenu && root.at ? (e) => {
|
|
14550
|
+
e.preventDefault();
|
|
14551
|
+
onFolderMenu(root.at, "", e);
|
|
14552
|
+
} : void 0,
|
|
14553
|
+
children: branch(root, 0)
|
|
14554
|
+
}
|
|
14555
|
+
);
|
|
14444
14556
|
}
|
|
14445
14557
|
|
|
14446
14558
|
// src/DocumentsWorkspace.tsx
|
|
@@ -14522,16 +14634,27 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14522
14634
|
return () => document.removeEventListener("pointerdown", close);
|
|
14523
14635
|
}, [picking]);
|
|
14524
14636
|
const [menu, setMenu] = (0, import_react19.useState)(null);
|
|
14637
|
+
const [spot3, setSpot] = (0, import_react19.useState)(null);
|
|
14638
|
+
const [edit, setEdit] = (0, import_react19.useState)(null);
|
|
14639
|
+
const popup = (0, import_react19.useRef)(null);
|
|
14640
|
+
(0, import_react19.useLayoutEffect)(() => {
|
|
14641
|
+
const el = popup.current;
|
|
14642
|
+
const at2 = menu ?? spot3;
|
|
14643
|
+
if (!el || !at2) return;
|
|
14644
|
+
el.style.top = `${Math.max(8, Math.min(at2.y, innerHeight - el.offsetHeight - 8))}px`;
|
|
14645
|
+
el.style.left = `${Math.max(8, Math.min(at2.x, innerWidth - el.offsetWidth - 8))}px`;
|
|
14646
|
+
}, [menu, spot3]);
|
|
14525
14647
|
const [naming, setNaming] = (0, import_react19.useState)(null);
|
|
14526
14648
|
const [notice, setNotice] = (0, import_react19.useState)(null);
|
|
14527
14649
|
const early = (0, import_react19.useRef)(/* @__PURE__ */ new Map());
|
|
14528
14650
|
const hover = (0, import_react19.useRef)(0);
|
|
14529
14651
|
(0, import_react19.useEffect)(() => {
|
|
14530
|
-
if (!menu) return;
|
|
14652
|
+
if (!menu && !spot3) return;
|
|
14531
14653
|
const close = (e) => {
|
|
14532
14654
|
if (e.type === "pointerdown" && e.target.closest(".w100n-docs-context")) return;
|
|
14533
14655
|
if (e.type === "keydown" && e.key !== "Escape") return;
|
|
14534
14656
|
setMenu(null);
|
|
14657
|
+
setSpot(null);
|
|
14535
14658
|
};
|
|
14536
14659
|
document.addEventListener("pointerdown", close);
|
|
14537
14660
|
window.addEventListener("keydown", close);
|
|
@@ -14541,7 +14664,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14541
14664
|
window.removeEventListener("keydown", close);
|
|
14542
14665
|
window.removeEventListener("scroll", close, true);
|
|
14543
14666
|
};
|
|
14544
|
-
}, [menu]);
|
|
14667
|
+
}, [menu, spot3]);
|
|
14545
14668
|
const [tab, setTab] = (0, import_react19.useState)("outline");
|
|
14546
14669
|
const [outline2, setOutline] = (0, import_react19.useState)([]);
|
|
14547
14670
|
const [reading, setReading] = (0, import_react19.useState)(null);
|
|
@@ -14568,11 +14691,17 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14568
14691
|
const all2 = await host.spaces({ signal });
|
|
14569
14692
|
return (await Promise.all(all2.map((item) => host.documents(item.id, { signal })))).flat();
|
|
14570
14693
|
}, [host, spaceId]);
|
|
14694
|
+
const dirs = useLoad(async (signal) => {
|
|
14695
|
+
if (!host.folders) return /* @__PURE__ */ new Map();
|
|
14696
|
+
const ids = spaceId ? [spaceId] : (await host.spaces({ signal })).map((item) => item.id);
|
|
14697
|
+
return new Map(await Promise.all(ids.map(async (id) => [id, await host.folders(id, { signal })])));
|
|
14698
|
+
}, [host, spaceId]);
|
|
14571
14699
|
(0, import_react19.useEffect)(() => {
|
|
14572
14700
|
const sync = () => {
|
|
14573
14701
|
if (document.visibilityState !== "visible") return;
|
|
14574
14702
|
spaces.retry();
|
|
14575
14703
|
list.retry();
|
|
14704
|
+
dirs.retry();
|
|
14576
14705
|
};
|
|
14577
14706
|
const timer = window.setInterval(sync, 3e4);
|
|
14578
14707
|
window.addEventListener("focus", sync);
|
|
@@ -14750,6 +14879,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14750
14879
|
};
|
|
14751
14880
|
const act = async (run3, done) => {
|
|
14752
14881
|
setMenu(null);
|
|
14882
|
+
setSpot(null);
|
|
14753
14883
|
setNotice(null);
|
|
14754
14884
|
try {
|
|
14755
14885
|
await run3();
|
|
@@ -14806,10 +14936,25 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14806
14936
|
setSending("failed");
|
|
14807
14937
|
}
|
|
14808
14938
|
};
|
|
14939
|
+
const refresh = () => {
|
|
14940
|
+
list.retry();
|
|
14941
|
+
dirs.retry();
|
|
14942
|
+
};
|
|
14943
|
+
const moveTo = (item, to) => {
|
|
14944
|
+
if (item.spaceId === to.spaceId && (item.folder ?? "") === to.folder) return setMenu(null);
|
|
14945
|
+
void act(() => host.move(item.id, to)).then(refresh);
|
|
14946
|
+
};
|
|
14947
|
+
const folderNamed = (at2) => at2.folder.split("/").pop() || names2.get(at2.spaceId) || t.topLevel;
|
|
14948
|
+
const commit = () => {
|
|
14949
|
+
if (!edit) return;
|
|
14950
|
+
setEdit(null);
|
|
14951
|
+
const text2 = edit.text.trim();
|
|
14952
|
+
if (text2) void edit.run(text2);
|
|
14953
|
+
};
|
|
14809
14954
|
const notes3 = doc.data?.kind === "markdown" ? all.filter((item) => item.kind === "markdown" && item.spaceId === doc.data.spaceId) : [];
|
|
14810
|
-
const note = async (name, show) => {
|
|
14955
|
+
const note = async (name, show, at2) => {
|
|
14811
14956
|
try {
|
|
14812
|
-
const made2 = await host.create({ name: `${name}.md`, bytes: new TextEncoder().encode("").buffer, mimeType: "text/markdown", near: here.documentId ?? void 0 });
|
|
14957
|
+
const made2 = await host.create({ name: `${name}.md`, bytes: new TextEncoder().encode("").buffer, mimeType: "text/markdown", near: at2 ? void 0 : here.documentId ?? void 0, at: at2 });
|
|
14813
14958
|
list.retry();
|
|
14814
14959
|
if (show) opened2(made2);
|
|
14815
14960
|
return made2.id;
|
|
@@ -15086,28 +15231,22 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
15086
15231
|
kept?.id === here.documentId && kept.state === "failed" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "w100n-docs-muted", role: "alert", children: t.templateFailed }),
|
|
15087
15232
|
renamed2 === "failed" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "w100n-docs-muted", children: t.renameFailed }),
|
|
15088
15233
|
docbar && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { ref: setStatusAt, className: "w100n-docs-status" }),
|
|
15089
|
-
host.send && doc.data && !versionId && !doc.data.id.includes(":") && /* @__PURE__ */ (0, import_jsx_runtime17.
|
|
15234
|
+
host.send && doc.data && !versionId && !doc.data.id.includes(":") && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
15090
15235
|
"button",
|
|
15091
15236
|
{
|
|
15092
15237
|
type: "button",
|
|
15093
|
-
className: "w100n-docs-action",
|
|
15238
|
+
className: "w100n-docs-action w100n-docs-square",
|
|
15094
15239
|
"data-tone": "blue",
|
|
15095
15240
|
"aria-label": t.sendChat,
|
|
15096
15241
|
title: t.sendChat,
|
|
15097
15242
|
onClick: () => host.send(doc.data.id),
|
|
15098
|
-
children:
|
|
15099
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Send, { "aria-hidden": true }),
|
|
15100
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: t.sendChat })
|
|
15101
|
-
]
|
|
15243
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Send, { "aria-hidden": true })
|
|
15102
15244
|
}
|
|
15103
15245
|
),
|
|
15104
|
-
sharing && /* @__PURE__ */ (0, import_jsx_runtime17.
|
|
15246
|
+
sharing && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "w100n-docs-action w100n-docs-square", "aria-label": t.share, title: t.share, onClick: () => {
|
|
15105
15247
|
setTab("sharing");
|
|
15106
15248
|
side2("panel", true);
|
|
15107
|
-
}, children:
|
|
15108
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Share2, { "aria-hidden": true }),
|
|
15109
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: t.share })
|
|
15110
|
-
] }),
|
|
15249
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Share2, { "aria-hidden": true }) }),
|
|
15111
15250
|
doc.data && !versionId && actions?.(doc.data),
|
|
15112
15251
|
narrow && panelToggle,
|
|
15113
15252
|
end && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w100n-docs-end w100n-docs-slot", children: slot(end) })
|
|
@@ -15243,12 +15382,27 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
15243
15382
|
Tree,
|
|
15244
15383
|
{
|
|
15245
15384
|
items: shown,
|
|
15385
|
+
folders: query.trim() || picked.length ? /* @__PURE__ */ new Map() : dirs.data ?? /* @__PURE__ */ new Map(),
|
|
15246
15386
|
names: names2,
|
|
15247
|
-
|
|
15387
|
+
spaceId,
|
|
15248
15388
|
current: here.documentId,
|
|
15249
15389
|
t,
|
|
15390
|
+
edit,
|
|
15391
|
+
onEdit: (text2) => setEdit(text2 === null ? null : edit && { ...edit, text: text2 }),
|
|
15392
|
+
onEditDone: commit,
|
|
15250
15393
|
onOpen: open,
|
|
15251
|
-
onMenu: (item, e) =>
|
|
15394
|
+
onMenu: (item, e) => {
|
|
15395
|
+
setSpot(null);
|
|
15396
|
+
setMenu({ item, x: Math.min(e.clientX, innerWidth - 290), y: Math.min(e.clientY, innerHeight - 440), sure: false });
|
|
15397
|
+
},
|
|
15398
|
+
onFolderMenu: host.create || host.makeFolder ? (at2, key2, e) => {
|
|
15399
|
+
setMenu(null);
|
|
15400
|
+
setSpot({ at: at2, key: key2, x: Math.min(e.clientX, innerWidth - 250), y: Math.min(e.clientY, innerHeight - 260), sure: false });
|
|
15401
|
+
} : void 0,
|
|
15402
|
+
onMove: host.move ? (id, to) => {
|
|
15403
|
+
const item = all.find((x) => x.id === id);
|
|
15404
|
+
if (item) moveTo(item, to);
|
|
15405
|
+
} : void 0,
|
|
15252
15406
|
onWarm: (item) => item ? warm(item) : clearTimeout(hover.current)
|
|
15253
15407
|
}
|
|
15254
15408
|
),
|
|
@@ -15482,14 +15636,28 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
15482
15636
|
setMaking(false);
|
|
15483
15637
|
opened2(made2);
|
|
15484
15638
|
} }),
|
|
15485
|
-
menu && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-menu w100n-docs-context", role: "menu", "aria-label": t.fileActions, style: { left: menu.x, top: menu.y }, children: [
|
|
15639
|
+
menu && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: popup, className: "w100n-docs-menu w100n-docs-context", role: "menu", "aria-label": t.fileActions, style: { left: menu.x, top: menu.y }, children: [
|
|
15486
15640
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-context-head", children: [
|
|
15487
15641
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("b", { children: menu.item.name }),
|
|
15488
15642
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: [t.kinds[menu.item.kind], size2(menu.item.size), names2.get(menu.item.spaceId), menu.item.folder].filter(Boolean).join(" \xB7 ") }),
|
|
15489
15643
|
menu.item.createdAt && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: [t.createdOn.replace("{when}", date(menu.item.createdAt)), menu.item.createdBy?.name].filter(Boolean).join(" \xB7 ") }),
|
|
15490
15644
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: [t.updatedOn.replace("{when}", ago(menu.item.updatedAt)), menu.item.updatedBy?.name].filter(Boolean).join(" \xB7 ") })
|
|
15491
15645
|
] }),
|
|
15492
|
-
menu.
|
|
15646
|
+
menu.moving ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w100n-docs-context-list", children: ["", ...dirs.data.get(menu.item.spaceId)].map((folder2) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
15647
|
+
"button",
|
|
15648
|
+
{
|
|
15649
|
+
type: "button",
|
|
15650
|
+
role: "menuitem",
|
|
15651
|
+
disabled: (menu.item.folder ?? "") === folder2,
|
|
15652
|
+
onClick: () => moveTo(menu.item, { spaceId: menu.item.spaceId, folder: folder2 }),
|
|
15653
|
+
style: { paddingLeft: 10 + 14 * (folder2 ? folder2.split("/").length : 0) },
|
|
15654
|
+
children: [
|
|
15655
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Folder, { "aria-hidden": true }),
|
|
15656
|
+
folder2 ? folder2.split("/").pop() : names2.get(menu.item.spaceId) ?? t.topLevel
|
|
15657
|
+
]
|
|
15658
|
+
},
|
|
15659
|
+
folder2
|
|
15660
|
+
)) }) : menu.sure ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-context-ask", children: [
|
|
15493
15661
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { children: t.trashAsk.replace("{name}", menu.item.name) }),
|
|
15494
15662
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "w100n-pdf-dialog-end", children: [
|
|
15495
15663
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => setMenu({ ...menu, sure: false }), children: t.cancel }),
|
|
@@ -15526,12 +15694,18 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
15526
15694
|
] }),
|
|
15527
15695
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", {}),
|
|
15528
15696
|
host.rename && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
15697
|
+
const item = menu.item;
|
|
15529
15698
|
setMenu(null);
|
|
15530
|
-
|
|
15699
|
+
if (shape3 === "tree") setEdit({ key: `file:${item.id}`, text: item.name.replace(/\.[^.]+$/, ""), run: (text2) => retitle(item, text2) });
|
|
15700
|
+
else setNaming({ id: item.id, text: item.name.replace(/\.[^.]+$/, "") });
|
|
15531
15701
|
}, children: [
|
|
15532
15702
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Pencil, { "aria-hidden": true }),
|
|
15533
15703
|
t.rename
|
|
15534
15704
|
] }),
|
|
15705
|
+
host.move && dirs.data?.has(menu.item.spaceId) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", "aria-haspopup": "menu", onClick: () => setMenu({ ...menu, moving: true }), children: [
|
|
15706
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.FolderInput, { "aria-hidden": true }),
|
|
15707
|
+
t.moveTo
|
|
15708
|
+
] }),
|
|
15535
15709
|
host.create && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => void act(async () => copy2(await host.document(menu.item.id))), children: [
|
|
15536
15710
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Copy, { "aria-hidden": true }),
|
|
15537
15711
|
t.makeCopy
|
|
@@ -15562,6 +15736,64 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
15562
15736
|
] })
|
|
15563
15737
|
] })
|
|
15564
15738
|
] }),
|
|
15739
|
+
spot3 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: popup, className: "w100n-docs-menu w100n-docs-context", role: "menu", "aria-label": t.folderActions, style: { left: spot3.x, top: spot3.y }, children: [
|
|
15740
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-context-head", children: [
|
|
15741
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("b", { children: folderNamed(spot3.at) }),
|
|
15742
|
+
spot3.at.folder && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: [names2.get(spot3.at.spaceId), ...spot3.at.folder.split("/").slice(0, -1)].filter(Boolean).join(" / ") })
|
|
15743
|
+
] }),
|
|
15744
|
+
spot3.sure ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-context-ask", children: [
|
|
15745
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { children: t.folderTrashAsk.replace("{name}", folderNamed(spot3.at)) }),
|
|
15746
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "w100n-pdf-dialog-end", children: [
|
|
15747
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => setSpot({ ...spot3, sure: false }), children: t.cancel }),
|
|
15748
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "red", onClick: () => {
|
|
15749
|
+
const at2 = spot3.at;
|
|
15750
|
+
const inside3 = doc.data && doc.data.spaceId === at2.spaceId && `${doc.data.folder ?? ""}/`.startsWith(`${at2.folder}/`);
|
|
15751
|
+
void act(() => host.removeFolder(at2), t.trashed).then(() => {
|
|
15752
|
+
refresh();
|
|
15753
|
+
if (inside3) go({ spaceId: here.spaceId, documentId: null });
|
|
15754
|
+
});
|
|
15755
|
+
}, children: [
|
|
15756
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Trash2, { "aria-hidden": true }),
|
|
15757
|
+
t.trash
|
|
15758
|
+
] })
|
|
15759
|
+
] })
|
|
15760
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
15761
|
+
host.create && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
15762
|
+
const at2 = spot3.at;
|
|
15763
|
+
setSpot(null);
|
|
15764
|
+
void note(t.untitled, true, at2);
|
|
15765
|
+
}, children: [
|
|
15766
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.FilePlus, { "aria-hidden": true }),
|
|
15767
|
+
t.newNoteHere
|
|
15768
|
+
] }),
|
|
15769
|
+
host.makeFolder && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
15770
|
+
const at2 = spot3.at;
|
|
15771
|
+
setSpot(null);
|
|
15772
|
+
setEdit({ key: `new:${spot3.key}`, text: t.newFolder, run: (name) => act(() => host.makeFolder(at2, name)).then(refresh) });
|
|
15773
|
+
}, children: [
|
|
15774
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.FolderPlus, { "aria-hidden": true }),
|
|
15775
|
+
t.newFolder
|
|
15776
|
+
] }),
|
|
15777
|
+
spot3.at.folder && host.renameFolder && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
15778
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", {}),
|
|
15779
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
15780
|
+
const at2 = spot3.at;
|
|
15781
|
+
setSpot(null);
|
|
15782
|
+
setEdit({ key: `dir:${spot3.key}`, text: folderNamed(at2), run: (name) => name === folderNamed(at2) ? Promise.resolve() : act(() => host.renameFolder(at2, name)).then(refresh) });
|
|
15783
|
+
}, children: [
|
|
15784
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Pencil, { "aria-hidden": true }),
|
|
15785
|
+
t.renameFolder
|
|
15786
|
+
] })
|
|
15787
|
+
] }),
|
|
15788
|
+
spot3.at.folder && host.removeFolder && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
15789
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", {}),
|
|
15790
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", "data-tone": "red", onClick: () => setSpot({ ...spot3, sure: true }), children: [
|
|
15791
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Trash2, { "aria-hidden": true }),
|
|
15792
|
+
t.trashFolder
|
|
15793
|
+
] })
|
|
15794
|
+
] })
|
|
15795
|
+
] })
|
|
15796
|
+
] }),
|
|
15565
15797
|
dialog
|
|
15566
15798
|
] });
|
|
15567
15799
|
}
|