@w100n/documents 0.17.0 → 0.18.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.
Files changed (37) hide show
  1. package/dist/{SheetView-SBLAFGTL.js → SheetView-43JDIP7D.js} +4 -4
  2. package/dist/{TextEditor-X2GSL4QM.js → TextEditor-CYS4U5XA.js} +5 -5
  3. package/dist/{chunk-B7C6NBBQ.js → chunk-BWU6FPPZ.js} +28 -1
  4. package/dist/chunk-BWU6FPPZ.js.map +1 -0
  5. package/dist/{chunk-ASTNK6WZ.js → chunk-DATYTA4H.js} +2 -2
  6. package/dist/{chunk-FFXAOK4A.js → chunk-Z5STMOD6.js} +2 -2
  7. package/dist/{chunk-A6AHJCEK.js → chunk-ZCSHH24C.js} +3 -3
  8. package/dist/{chunk-A6AHJCEK.js.map → chunk-ZCSHH24C.js.map} +1 -1
  9. package/dist/collab.cjs +28 -1
  10. package/dist/collab.cjs.map +1 -1
  11. package/dist/collab.d.cts +1 -1
  12. package/dist/collab.d.ts +1 -1
  13. package/dist/collab.js +2 -2
  14. package/dist/index.cjs +263 -33
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.css +17 -0
  17. package/dist/index.css.map +1 -1
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +247 -41
  21. package/dist/index.js.map +1 -1
  22. package/dist/kinds.d.cts +1 -1
  23. package/dist/kinds.d.ts +1 -1
  24. package/dist/memory.cjs +33 -5
  25. package/dist/memory.cjs.map +1 -1
  26. package/dist/memory.d.cts +1 -1
  27. package/dist/memory.d.ts +1 -1
  28. package/dist/memory.js +33 -5
  29. package/dist/memory.js.map +1 -1
  30. package/dist/{types-CHmV8GLx.d.cts → types-DyonaPQf.d.cts} +11 -1
  31. package/dist/{types-CHmV8GLx.d.ts → types-DyonaPQf.d.ts} +11 -1
  32. package/package.json +1 -1
  33. package/dist/chunk-B7C6NBBQ.js.map +0 -1
  34. /package/dist/{SheetView-SBLAFGTL.js.map → SheetView-43JDIP7D.js.map} +0 -0
  35. /package/dist/{TextEditor-X2GSL4QM.js.map → TextEditor-CYS4U5XA.js.map} +0 -0
  36. /package/dist/{chunk-ASTNK6WZ.js.map → chunk-DATYTA4H.js.map} +0 -0
  37. /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-CHmV8GLx.cjs';
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-CHmV8GLx.js';
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-A6AHJCEK.js";
14
+ } from "./chunk-ZCSHH24C.js";
15
15
  import "./chunk-GSIPTCQH.js";
16
- import "./chunk-B7C6NBBQ.js";
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.17.0";
4996
+ version = "0.18.0";
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
- function grow(items, names2, bySpace, other) {
14366
- const root = { key: "", name: "", folders: [], files: [], count: 0 };
14367
- for (const item of items) {
14368
- const path = [...bySpace ? [names2.get(item.spaceId) ?? other] : [], ...(item.folder ?? "").split("/").filter(Boolean)];
14369
- let at2 = root;
14370
- at2.count++;
14371
- for (const part of path) {
14372
- const key2 = `${at2.key}/${part}`;
14373
- let next = at2.folders.find((f) => f.key === key2);
14374
- if (!next) at2.folders.push(next = { key: key2, name: part, folders: [], files: [], count: 0 });
14375
- next.count++;
14376
- at2 = next;
14377
- }
14378
- at2.files.push(item);
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, bySpace, current, t, onOpen, onMenu, onWarm }) {
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
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("button", { type: "button", className: "w100n-tree-row", "aria-expanded": open, style: { paddingLeft: 8 + depth * 16 }, onClick: () => flip(f.key), children: [
14408
- 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" }),
14409
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react12.Folder, { "aria-hidden": true }),
14410
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: f.name }),
14411
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { children: f.count })
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
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("nav", { className: "w100n-tree", "aria-label": t.tree, children: branch(grow(items, names2, bySpace, t.elsewhere), 0) });
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,19 @@ 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);
14525
14639
  const [naming, setNaming] = (0, import_react19.useState)(null);
14526
14640
  const [notice, setNotice] = (0, import_react19.useState)(null);
14527
14641
  const early = (0, import_react19.useRef)(/* @__PURE__ */ new Map());
14528
14642
  const hover = (0, import_react19.useRef)(0);
14529
14643
  (0, import_react19.useEffect)(() => {
14530
- if (!menu) return;
14644
+ if (!menu && !spot3) return;
14531
14645
  const close = (e) => {
14532
14646
  if (e.type === "pointerdown" && e.target.closest(".w100n-docs-context")) return;
14533
14647
  if (e.type === "keydown" && e.key !== "Escape") return;
14534
14648
  setMenu(null);
14649
+ setSpot(null);
14535
14650
  };
14536
14651
  document.addEventListener("pointerdown", close);
14537
14652
  window.addEventListener("keydown", close);
@@ -14541,7 +14656,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14541
14656
  window.removeEventListener("keydown", close);
14542
14657
  window.removeEventListener("scroll", close, true);
14543
14658
  };
14544
- }, [menu]);
14659
+ }, [menu, spot3]);
14545
14660
  const [tab, setTab] = (0, import_react19.useState)("outline");
14546
14661
  const [outline2, setOutline] = (0, import_react19.useState)([]);
14547
14662
  const [reading, setReading] = (0, import_react19.useState)(null);
@@ -14568,11 +14683,17 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14568
14683
  const all2 = await host.spaces({ signal });
14569
14684
  return (await Promise.all(all2.map((item) => host.documents(item.id, { signal })))).flat();
14570
14685
  }, [host, spaceId]);
14686
+ const dirs = useLoad(async (signal) => {
14687
+ if (!host.folders) return /* @__PURE__ */ new Map();
14688
+ const ids = spaceId ? [spaceId] : (await host.spaces({ signal })).map((item) => item.id);
14689
+ return new Map(await Promise.all(ids.map(async (id) => [id, await host.folders(id, { signal })])));
14690
+ }, [host, spaceId]);
14571
14691
  (0, import_react19.useEffect)(() => {
14572
14692
  const sync = () => {
14573
14693
  if (document.visibilityState !== "visible") return;
14574
14694
  spaces.retry();
14575
14695
  list.retry();
14696
+ dirs.retry();
14576
14697
  };
14577
14698
  const timer = window.setInterval(sync, 3e4);
14578
14699
  window.addEventListener("focus", sync);
@@ -14750,6 +14871,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14750
14871
  };
14751
14872
  const act = async (run3, done) => {
14752
14873
  setMenu(null);
14874
+ setSpot(null);
14753
14875
  setNotice(null);
14754
14876
  try {
14755
14877
  await run3();
@@ -14806,10 +14928,25 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14806
14928
  setSending("failed");
14807
14929
  }
14808
14930
  };
14931
+ const refresh = () => {
14932
+ list.retry();
14933
+ dirs.retry();
14934
+ };
14935
+ const moveTo = (item, to) => {
14936
+ if (item.spaceId === to.spaceId && (item.folder ?? "") === to.folder) return setMenu(null);
14937
+ void act(() => host.move(item.id, to)).then(refresh);
14938
+ };
14939
+ const folderNamed = (at2) => at2.folder.split("/").pop() || names2.get(at2.spaceId) || t.topLevel;
14940
+ const commit = () => {
14941
+ if (!edit) return;
14942
+ setEdit(null);
14943
+ const text2 = edit.text.trim();
14944
+ if (text2) void edit.run(text2);
14945
+ };
14809
14946
  const notes3 = doc.data?.kind === "markdown" ? all.filter((item) => item.kind === "markdown" && item.spaceId === doc.data.spaceId) : [];
14810
- const note = async (name, show) => {
14947
+ const note = async (name, show, at2) => {
14811
14948
  try {
14812
- const made2 = await host.create({ name: `${name}.md`, bytes: new TextEncoder().encode("").buffer, mimeType: "text/markdown", near: here.documentId ?? void 0 });
14949
+ 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
14950
  list.retry();
14814
14951
  if (show) opened2(made2);
14815
14952
  return made2.id;
@@ -15243,12 +15380,27 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15243
15380
  Tree,
15244
15381
  {
15245
15382
  items: shown,
15383
+ folders: query.trim() || picked.length ? /* @__PURE__ */ new Map() : dirs.data ?? /* @__PURE__ */ new Map(),
15246
15384
  names: names2,
15247
- bySpace: !spaceId,
15385
+ spaceId,
15248
15386
  current: here.documentId,
15249
15387
  t,
15388
+ edit,
15389
+ onEdit: (text2) => setEdit(text2 === null ? null : edit && { ...edit, text: text2 }),
15390
+ onEditDone: commit,
15250
15391
  onOpen: open,
15251
- onMenu: (item, e) => setMenu({ item, x: Math.min(e.clientX, innerWidth - 290), y: Math.min(e.clientY, innerHeight - 440), sure: false }),
15392
+ onMenu: (item, e) => {
15393
+ setSpot(null);
15394
+ setMenu({ item, x: Math.min(e.clientX, innerWidth - 290), y: Math.min(e.clientY, innerHeight - 440), sure: false });
15395
+ },
15396
+ onFolderMenu: host.create || host.makeFolder ? (at2, key2, e) => {
15397
+ setMenu(null);
15398
+ setSpot({ at: at2, key: key2, x: Math.min(e.clientX, innerWidth - 250), y: Math.min(e.clientY, innerHeight - 260), sure: false });
15399
+ } : void 0,
15400
+ onMove: host.move ? (id, to) => {
15401
+ const item = all.find((x) => x.id === id);
15402
+ if (item) moveTo(item, to);
15403
+ } : void 0,
15252
15404
  onWarm: (item) => item ? warm(item) : clearTimeout(hover.current)
15253
15405
  }
15254
15406
  ),
@@ -15489,7 +15641,21 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15489
15641
  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
15642
  /* @__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
15643
  ] }),
15492
- menu.sure ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-context-ask", children: [
15644
+ 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)(
15645
+ "button",
15646
+ {
15647
+ type: "button",
15648
+ role: "menuitem",
15649
+ disabled: (menu.item.folder ?? "") === folder2,
15650
+ onClick: () => moveTo(menu.item, { spaceId: menu.item.spaceId, folder: folder2 }),
15651
+ style: { paddingLeft: 10 + 14 * (folder2 ? folder2.split("/").length : 0) },
15652
+ children: [
15653
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Folder, { "aria-hidden": true }),
15654
+ folder2 ? folder2.split("/").pop() : names2.get(menu.item.spaceId) ?? t.topLevel
15655
+ ]
15656
+ },
15657
+ folder2
15658
+ )) }) : menu.sure ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-context-ask", children: [
15493
15659
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { children: t.trashAsk.replace("{name}", menu.item.name) }),
15494
15660
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "w100n-pdf-dialog-end", children: [
15495
15661
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => setMenu({ ...menu, sure: false }), children: t.cancel }),
@@ -15526,12 +15692,18 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15526
15692
  ] }),
15527
15693
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", {}),
15528
15694
  host.rename && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
15695
+ const item = menu.item;
15529
15696
  setMenu(null);
15530
- setNaming({ id: menu.item.id, text: menu.item.name.replace(/\.[^.]+$/, "") });
15697
+ if (shape3 === "tree") setEdit({ key: `file:${item.id}`, text: item.name.replace(/\.[^.]+$/, ""), run: (text2) => retitle(item, text2) });
15698
+ else setNaming({ id: item.id, text: item.name.replace(/\.[^.]+$/, "") });
15531
15699
  }, children: [
15532
15700
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Pencil, { "aria-hidden": true }),
15533
15701
  t.rename
15534
15702
  ] }),
15703
+ 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: [
15704
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.FolderInput, { "aria-hidden": true }),
15705
+ t.moveTo
15706
+ ] }),
15535
15707
  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
15708
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Copy, { "aria-hidden": true }),
15537
15709
  t.makeCopy
@@ -15562,6 +15734,64 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15562
15734
  ] })
15563
15735
  ] })
15564
15736
  ] }),
15737
+ spot3 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-menu w100n-docs-context", role: "menu", "aria-label": t.folderActions, style: { left: spot3.x, top: spot3.y }, children: [
15738
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-context-head", children: [
15739
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("b", { children: folderNamed(spot3.at) }),
15740
+ 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(" / ") })
15741
+ ] }),
15742
+ spot3.sure ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w100n-docs-context-ask", children: [
15743
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { children: t.folderTrashAsk.replace("{name}", folderNamed(spot3.at)) }),
15744
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "w100n-pdf-dialog-end", children: [
15745
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => setSpot({ ...spot3, sure: false }), children: t.cancel }),
15746
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "red", onClick: () => {
15747
+ const at2 = spot3.at;
15748
+ const inside3 = doc.data && doc.data.spaceId === at2.spaceId && `${doc.data.folder ?? ""}/`.startsWith(`${at2.folder}/`);
15749
+ void act(() => host.removeFolder(at2), t.trashed).then(() => {
15750
+ refresh();
15751
+ if (inside3) go({ spaceId: here.spaceId, documentId: null });
15752
+ });
15753
+ }, children: [
15754
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Trash2, { "aria-hidden": true }),
15755
+ t.trash
15756
+ ] })
15757
+ ] })
15758
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
15759
+ host.create && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
15760
+ const at2 = spot3.at;
15761
+ setSpot(null);
15762
+ void note(t.untitled, true, at2);
15763
+ }, children: [
15764
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.FilePlus, { "aria-hidden": true }),
15765
+ t.newNoteHere
15766
+ ] }),
15767
+ host.makeFolder && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
15768
+ const at2 = spot3.at;
15769
+ setSpot(null);
15770
+ setEdit({ key: `new:${spot3.key}`, text: t.newFolder, run: (name) => act(() => host.makeFolder(at2, name)).then(refresh) });
15771
+ }, children: [
15772
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.FolderPlus, { "aria-hidden": true }),
15773
+ t.newFolder
15774
+ ] }),
15775
+ spot3.at.folder && host.renameFolder && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
15776
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", {}),
15777
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
15778
+ const at2 = spot3.at;
15779
+ setSpot(null);
15780
+ setEdit({ key: `dir:${spot3.key}`, text: folderNamed(at2), run: (name) => name === folderNamed(at2) ? Promise.resolve() : act(() => host.renameFolder(at2, name)).then(refresh) });
15781
+ }, children: [
15782
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Pencil, { "aria-hidden": true }),
15783
+ t.renameFolder
15784
+ ] })
15785
+ ] }),
15786
+ spot3.at.folder && host.removeFolder && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
15787
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", {}),
15788
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", role: "menuitem", "data-tone": "red", onClick: () => setSpot({ ...spot3, sure: true }), children: [
15789
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react13.Trash2, { "aria-hidden": true }),
15790
+ t.trashFolder
15791
+ ] })
15792
+ ] })
15793
+ ] })
15794
+ ] }),
15565
15795
  dialog
15566
15796
  ] });
15567
15797
  }