@w100n/documents 0.16.1 → 0.16.3

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 (40) hide show
  1. package/dist/{SheetView-FVLKQR7J.js → SheetView-KXFUAILH.js} +7 -5
  2. package/dist/SheetView-KXFUAILH.js.map +1 -0
  3. package/dist/{TextEditor-BF6HCNHL.js → TextEditor-RNHXPYJX.js} +19 -15
  4. package/dist/TextEditor-RNHXPYJX.js.map +1 -0
  5. package/dist/{chunk-GN3ZOD36.js → chunk-E2FVJNDT.js} +3 -3
  6. package/dist/{chunk-GN3ZOD36.js.map → chunk-E2FVJNDT.js.map} +1 -1
  7. package/dist/{chunk-LZYITB56.js → chunk-VNXZVOPN.js} +37 -1
  8. package/dist/chunk-VNXZVOPN.js.map +1 -0
  9. package/dist/{chunk-NPVH2YDI.js → chunk-XFLYD3JS.js} +2 -2
  10. package/dist/collab.cjs +37 -1
  11. package/dist/collab.cjs.map +1 -1
  12. package/dist/collab.d.cts +1 -1
  13. package/dist/collab.d.ts +1 -1
  14. package/dist/collab.js +2 -2
  15. package/dist/{grid-Q4XBPQFY.js → grid-IR5YFFSF.js} +33 -6
  16. package/dist/grid-IR5YFFSF.js.map +1 -0
  17. package/dist/index.cjs +313 -32
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.css +90 -6
  20. package/dist/index.css.map +1 -1
  21. package/dist/index.d.cts +2 -2
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +232 -18
  24. package/dist/index.js.map +1 -1
  25. package/dist/kinds.d.cts +1 -1
  26. package/dist/kinds.d.ts +1 -1
  27. package/dist/memory.cjs +6 -0
  28. package/dist/memory.cjs.map +1 -1
  29. package/dist/memory.d.cts +1 -1
  30. package/dist/memory.d.ts +1 -1
  31. package/dist/memory.js +6 -0
  32. package/dist/memory.js.map +1 -1
  33. package/dist/{types-DNcaU6SK.d.cts → types-BUO0OzOl.d.cts} +5 -0
  34. package/dist/{types-DNcaU6SK.d.ts → types-BUO0OzOl.d.ts} +5 -0
  35. package/package.json +1 -1
  36. package/dist/SheetView-FVLKQR7J.js.map +0 -1
  37. package/dist/TextEditor-BF6HCNHL.js.map +0 -1
  38. package/dist/chunk-LZYITB56.js.map +0 -1
  39. package/dist/grid-Q4XBPQFY.js.map +0 -1
  40. /package/dist/{chunk-NPVH2YDI.js.map → chunk-XFLYD3JS.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -98,6 +98,18 @@ var init_text = __esm({
98
98
  retry: "Try again",
99
99
  loading: "Loading",
100
100
  unsupported: "This file cannot be shown yet",
101
+ sendChat: "Send to chat",
102
+ openFile: "Open",
103
+ openTab: "Open in a new tab",
104
+ copyLink: "Copy link",
105
+ linkCopied: "Link copied",
106
+ trash: "Move to trash",
107
+ trashAsk: "Move {name} to trash?",
108
+ trashed: "Moved to trash",
109
+ createdOn: "Created {when}",
110
+ updatedOn: "Updated {when}",
111
+ actionFailed: "Could not do that",
112
+ fileActions: "File actions",
101
113
  teamTemplates: "Team templates",
102
114
  saveTemplate: "Save as template",
103
115
  templateSaved: "Saved to Templates",
@@ -439,6 +451,18 @@ var init_text = __esm({
439
451
  retry: "Spr\xF3buj ponownie",
440
452
  loading: "Wczytywanie",
441
453
  unsupported: "Tego pliku nie da si\u0119 jeszcze pokaza\u0107",
454
+ sendChat: "Wy\u015Blij na czat",
455
+ openFile: "Otw\xF3rz",
456
+ openTab: "Otw\xF3rz w nowej karcie",
457
+ copyLink: "Kopiuj link",
458
+ linkCopied: "Skopiowano link",
459
+ trash: "Przenie\u015B do kosza",
460
+ trashAsk: "Przenie\u015B\u0107 {name} do kosza?",
461
+ trashed: "Przeniesiono do kosza",
462
+ createdOn: "Utworzono {when}",
463
+ updatedOn: "Zmieniono {when}",
464
+ actionFailed: "Nie uda\u0142o si\u0119",
465
+ fileActions: "Dzia\u0142ania na pliku",
442
466
  teamTemplates: "Szablony zespo\u0142u",
443
467
  saveTemplate: "Zapisz jako szablon",
444
468
  templateSaved: "Zapisano w Szablonach",
@@ -780,6 +804,18 @@ var init_text = __esm({
780
804
  retry: "\u0421\u043F\u0440\u043E\u0431\u0443\u0432\u0430\u0442\u0438 \u0449\u0435",
781
805
  loading: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",
782
806
  unsupported: "\u0426\u0435\u0439 \u0444\u0430\u0439\u043B \u043F\u043E\u043A\u0438 \u043D\u0435 \u043C\u043E\u0436\u043D\u0430 \u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438",
807
+ sendChat: "\u041D\u0430\u0434\u0456\u0441\u043B\u0430\u0442\u0438 \u0432 \u0447\u0430\u0442",
808
+ openFile: "\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438",
809
+ openTab: "\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u0432 \u043D\u043E\u0432\u0456\u0439 \u0432\u043A\u043B\u0430\u0434\u0446\u0456",
810
+ copyLink: "\u041A\u043E\u043F\u0456\u044E\u0432\u0430\u0442\u0438 \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
811
+ linkCopied: "\u041F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F \u0441\u043A\u043E\u043F\u0456\u0439\u043E\u0432\u0430\u043D\u043E",
812
+ trash: "\u0423 \u043A\u043E\u0448\u0438\u043A",
813
+ trashAsk: "\u041F\u0435\u0440\u0435\u043C\u0456\u0441\u0442\u0438\u0442\u0438 {name} \u0443 \u043A\u043E\u0448\u0438\u043A?",
814
+ trashed: "\u041F\u0435\u0440\u0435\u043C\u0456\u0449\u0435\u043D\u043E \u0432 \u043A\u043E\u0448\u0438\u043A",
815
+ createdOn: "\u0421\u0442\u0432\u043E\u0440\u0435\u043D\u043E {when}",
816
+ updatedOn: "\u0417\u043C\u0456\u043D\u0435\u043D\u043E {when}",
817
+ actionFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F",
818
+ fileActions: "\u0414\u0456\u0457 \u0437 \u0444\u0430\u0439\u043B\u043E\u043C",
783
819
  teamTemplates: "\u0428\u0430\u0431\u043B\u043E\u043D\u0438 \u043A\u043E\u043C\u0430\u043D\u0434\u0438",
784
820
  saveTemplate: "\u0417\u0431\u0435\u0440\u0435\u0433\u0442\u0438 \u044F\u043A \u0448\u0430\u0431\u043B\u043E\u043D",
785
821
  templateSaved: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E \u0432 Templates",
@@ -4735,7 +4771,7 @@ var init_extensions = __esm({
4735
4771
  var version;
4736
4772
  var init_package = __esm({
4737
4773
  "package.json"() {
4738
- version = "0.16.1";
4774
+ version = "0.16.3";
4739
4775
  }
4740
4776
  });
4741
4777
 
@@ -8827,20 +8863,24 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
8827
8863
  }
8828
8864
  }
8829
8865
  ),
8830
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("small", { "aria-live": "polite", children: query ? found?.hits.length ? `${(found.at ?? 0) + 1} / ${found.hits.length}` : t.noHits : "" }),
8831
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", "aria-label": t.previous, title: t.previous, disabled: !found?.hits.length, onClick: () => seek({ at: found.at - 1 }), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.ChevronUp, { "aria-hidden": true }) }),
8832
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", "aria-label": t.next, title: t.next, disabled: !found?.hits.length, onClick: () => seek({ at: found.at + 1 }), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.ChevronDown, { "aria-hidden": true }) })
8866
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "w100n-text-find-end", children: [
8867
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("small", { "aria-live": "polite", children: query ? found?.hits.length ? `${(found.at ?? 0) + 1} / ${found.hits.length}` : t.noHits : "" }),
8868
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", "aria-label": t.previous, title: t.previous, disabled: !found?.hits.length, onClick: () => seek({ at: found.at - 1 }), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.ChevronUp, { "aria-hidden": true }) }),
8869
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", "aria-label": t.next, title: t.next, disabled: !found?.hits.length, onClick: () => seek({ at: found.at + 1 }), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.ChevronDown, { "aria-hidden": true }) })
8870
+ ] })
8833
8871
  ] }),
8834
8872
  can.edit && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "w100n-docs-row", children: [
8835
8873
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { value: swap, placeholder: t.replaceWith, "aria-label": t.replaceWith, onChange: (e) => setSwap(e.target.value) }),
8836
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "w100n-pdf-link", disabled: !found?.hits.length, onClick: () => {
8837
- replace(editor, swap, false);
8838
- seek({});
8839
- }, children: t.replaceOne }),
8840
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "w100n-docs-action", disabled: !found?.hits.length, onClick: () => {
8841
- replace(editor, swap, true);
8842
- seek({});
8843
- }, children: t.replaceAll })
8874
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "w100n-text-find-end", children: [
8875
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "w100n-pdf-link", disabled: !found?.hits.length, onClick: () => {
8876
+ replace(editor, swap, false);
8877
+ seek({});
8878
+ }, children: t.replaceOne }),
8879
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "w100n-docs-action", disabled: !found?.hits.length, onClick: () => {
8880
+ replace(editor, swap, true);
8881
+ seek({});
8882
+ }, children: t.replaceAll })
8883
+ ] })
8844
8884
  ] }),
8845
8885
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "w100n-setup-check", children: [
8846
8886
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { type: "checkbox", checked: matchCase, onChange: (e) => {
@@ -10075,9 +10115,36 @@ var init_sheets = __esm({
10075
10115
  }
10076
10116
  });
10077
10117
 
10118
+ // src/sheets/calm.ts
10119
+ function bolder(injector) {
10120
+ const theme = injector.get(import_core5.ThemeService);
10121
+ const tone = (color2) => theme.isValidThemeColor(color2) ? theme.getColorFromTheme(color2) : color2;
10122
+ const refs3 = new Set(Array.from({ length: 12 }, (_, i) => tone(theme.getColorFromTheme(`loop-color.${i + 1}`))));
10123
+ return injector.get(import_core5.ICommandService).beforeCommandExecuted(({ id, params }) => {
10124
+ if (id !== "doc.command.replace-text-runs") return;
10125
+ params?.body?.textRuns?.forEach((run3) => {
10126
+ if (run3.ts?.cl?.rgb && refs3.has(run3.ts.cl.rgb)) run3.ts.bl = 1;
10127
+ });
10128
+ });
10129
+ }
10130
+ var import_core5, pale, calm;
10131
+ var init_calm = __esm({
10132
+ "src/sheets/calm.ts"() {
10133
+ "use strict";
10134
+ import_core5 = require("@univerjs/core");
10135
+ pale = (color2) => /^#[0-9a-f]{6}$/i.test(color2) ? `${color2}24` : color2.replace(/^rgb\(([^)]+)\)$/i, "rgba($1, 0.14)");
10136
+ calm = (selection) => {
10137
+ const style = selection.style;
10138
+ if (!style?.widgets || !Object.values(style.widgets).some(Boolean)) return selection;
10139
+ return { ...selection, style: { ...style, widgets: {}, strokeWidth: 3, fill: style.stroke ? pale(style.stroke) : style.fill } };
10140
+ };
10141
+ }
10142
+ });
10143
+
10078
10144
  // src/sheets/grid.ts
10079
10145
  var grid_exports = {};
10080
10146
  __export(grid_exports, {
10147
+ bolder: () => bolder,
10081
10148
  grid: () => grid2,
10082
10149
  marks: () => marks
10083
10150
  });
@@ -10088,7 +10155,7 @@ function grid2(container, language, edit) {
10088
10155
  [import_presets.LocaleType.EN_US]: (0, import_presets.mergeLocales)(import_en_US.default, import_en_US2.default, import_en_US3.default, import_en_US4.default, import_en_US5.default, import_en_US6.default),
10089
10156
  [import_presets.LocaleType.PL_PL]: (0, import_presets.mergeLocales)(import_pl_PL.default, import_pl_PL2.default, import_pl_PL3.default, import_pl_PL4.default, import_pl_PL5.default, import_pl_PL6.default)
10090
10157
  },
10091
- theme: import_presets.purpleTheme,
10158
+ theme: { ...import_presets.purpleTheme, "loop-color": { 1: "blue.500", 2: "red.500", 3: "green.600", 4: "orange.500", 5: "purple.500", 6: "jiqing.600", 7: "pink.500", 8: "yellow.700", 9: "indigo.600", 10: "red.700", 11: "green.800", 12: "blue.800" } },
10092
10159
  darkMode: false,
10093
10160
  presets: [
10094
10161
  (0, import_preset_sheets_core.UniverSheetsCorePreset)({
@@ -10112,7 +10179,7 @@ function marks({ univer, univerAPI: api }) {
10112
10179
  const service = univer.__getInjector().get(import_preset_sheets_core.IMarkSelectionService);
10113
10180
  let list = [];
10114
10181
  let ids = [];
10115
- const draw = () => {
10182
+ const draw2 = () => {
10116
10183
  ids.forEach((id) => service.removeShape(id));
10117
10184
  const sid = api.getActiveWorkbook()?.getActiveSheet().getSheetId();
10118
10185
  ids = list.filter((m) => m.sheet === sid).flatMap((m) => {
@@ -10121,11 +10188,11 @@ function marks({ univer, univerAPI: api }) {
10121
10188
  return id ? [id] : [];
10122
10189
  });
10123
10190
  };
10124
- const turn2 = api.addEvent(api.Event.ActiveSheetChanged, draw);
10191
+ const turn2 = api.addEvent(api.Event.ActiveSheetChanged, draw2);
10125
10192
  return {
10126
10193
  show: (next) => {
10127
10194
  list = next;
10128
- draw();
10195
+ draw2();
10129
10196
  },
10130
10197
  dispose: () => {
10131
10198
  turn2.dispose();
@@ -10133,7 +10200,7 @@ function marks({ univer, univerAPI: api }) {
10133
10200
  }
10134
10201
  };
10135
10202
  }
10136
- var import_lib, import_lib2, import_lib3, import_lib4, import_lib5, import_lib6, import_presets, import_preset_sheets_core, import_preset_sheets_data_validation, import_preset_sheets_filter, import_preset_sheets_find_replace, import_preset_sheets_note, import_preset_sheets_sort, import_en_US, import_pl_PL, import_en_US2, import_pl_PL2, import_en_US3, import_pl_PL3, import_en_US4, import_pl_PL4, import_en_US5, import_pl_PL5, import_en_US6, import_pl_PL6;
10203
+ var import_lib, import_lib2, import_lib3, import_lib4, import_lib5, import_lib6, import_presets, import_preset_sheets_core, import_preset_sheets_data_validation, import_preset_sheets_filter, import_preset_sheets_find_replace, import_preset_sheets_note, import_preset_sheets_sort, import_en_US, import_pl_PL, import_en_US2, import_pl_PL2, import_en_US3, import_pl_PL3, import_en_US4, import_pl_PL4, import_en_US5, import_pl_PL5, import_en_US6, import_pl_PL6, draw;
10137
10204
  var init_grid = __esm({
10138
10205
  "src/sheets/grid.ts"() {
10139
10206
  "use strict";
@@ -10162,7 +10229,12 @@ var init_grid = __esm({
10162
10229
  import_pl_PL5 = __toESM(require("@univerjs/preset-sheets-note/locales/pl-PL"), 1);
10163
10230
  import_en_US6 = __toESM(require("@univerjs/preset-sheets-sort/locales/en-US"), 1);
10164
10231
  import_pl_PL6 = __toESM(require("@univerjs/preset-sheets-sort/locales/pl-PL"), 1);
10232
+ init_calm();
10165
10233
  init_refs();
10234
+ draw = import_preset_sheets_core.SelectionControl.prototype.updateRangeBySelectionWithCoord;
10235
+ import_preset_sheets_core.SelectionControl.prototype.updateRangeBySelectionWithCoord = function(selection, ...rest) {
10236
+ draw.call(this, calm(selection), ...rest);
10237
+ };
10166
10238
  }
10167
10239
  });
10168
10240
 
@@ -10227,7 +10299,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10227
10299
  setDirty(false);
10228
10300
  const families = new Set([model.book.defaultStyle, ...Object.values(model.book.styles)].map((s) => typeof s === "object" ? s?.ff : null).filter(Boolean));
10229
10301
  const fonts = Promise.race([Promise.all([...families].flatMap((f) => ["", "bold ", "italic "].map((w) => document.fonts.load(`${w}11pt "${f}"`).catch(() => [])))), new Promise((r) => setTimeout(r, 800))]);
10230
- Promise.all([Promise.resolve().then(() => (init_grid(), grid_exports)), fonts]).then(([{ grid: grid3, marks: marks2 }]) => {
10302
+ Promise.all([Promise.resolve().then(() => (init_grid(), grid_exports)), fonts]).then(([{ bolder: bolder2, grid: grid3, marks: marks2 }]) => {
10231
10303
  if (gone) return;
10232
10304
  shared?.doc.off("update", change);
10233
10305
  if (shared && moved) model = extras(shared.doc, build(shared.doc));
@@ -10237,6 +10309,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10237
10309
  const view = grid3(host2, language, edit);
10238
10310
  const { univer, univerAPI: api2 } = view;
10239
10311
  const wb = api2.createWorkbook(model.book);
10312
+ const unbold = bolder2(univer.__getInjector());
10240
10313
  if (model.active) wb.setActiveSheet(model.active);
10241
10314
  if (!edit) wb.setEditable(false);
10242
10315
  const state = { api: api2, model, original: bytes, changes: 0 };
@@ -10276,6 +10349,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10276
10349
  live.current = state;
10277
10350
  stop = () => {
10278
10351
  unbind();
10352
+ unbold.dispose();
10279
10353
  state.marks?.dispose();
10280
10354
  untrack();
10281
10355
  selection.dispose();
@@ -10399,7 +10473,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10399
10473
  const sum = () => {
10400
10474
  const r = range()?.getRange();
10401
10475
  const ws = sheet2();
10402
- const numeric2 = (row2, c) => ws?.getRange(row2, c).getCellData()?.t === import_core5.CellValueType.NUMBER;
10476
+ const numeric2 = (row2, c) => ws?.getRange(row2, c).getCellData()?.t === import_core6.CellValueType.NUMBER;
10403
10477
  if (r && ws) for (const x of autoSum(r, numeric2)) ws.getRange(x.row, x.col).setValue({ f: x.f });
10404
10478
  };
10405
10479
  const shown = formats.find(([, p]) => p === look?.n)?.[0] ?? (look && look.n !== "General" ? look.n : t.general);
@@ -10566,13 +10640,13 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10566
10640
  ] })
10567
10641
  ] });
10568
10642
  }
10569
- var import_react12, import_lucide_react6, import_core5, import_jsx_runtime8, decimals, letters2, SheetView_default;
10643
+ var import_react12, import_lucide_react6, import_core6, import_jsx_runtime8, decimals, letters2, SheetView_default;
10570
10644
  var init_SheetView = __esm({
10571
10645
  "src/sheets/SheetView.tsx"() {
10572
10646
  "use strict";
10573
10647
  import_react12 = require("react");
10574
10648
  import_lucide_react6 = require("lucide-react");
10575
- import_core5 = require("@univerjs/core");
10649
+ import_core6 = require("@univerjs/core");
10576
10650
  init_live();
10577
10651
  init_focus();
10578
10652
  init_bind();
@@ -12813,7 +12887,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
12813
12887
  setSigning(null);
12814
12888
  setTool("place");
12815
12889
  };
12816
- const draw = (e) => {
12890
+ const draw2 = (e) => {
12817
12891
  const r = e.currentTarget.getBoundingClientRect();
12818
12892
  const p = { x: e.clientX - r.left, y: e.clientY - r.top };
12819
12893
  const ctx = e.currentTarget.getContext("2d");
@@ -13077,7 +13151,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
13077
13151
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "w100n-pdf-script", style: { fontSize: Math.min(52, Math.floor(680 / Math.max(1, (signing.name || t.yourName).length))) }, children: signing.name || t.yourName })
13078
13152
  ] }),
13079
13153
  signing.tab === "drawn" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
13080
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("canvas", { ref: pad, className: "w100n-pdf-pad", "aria-label": t.drawHere, onPointerDown: draw, onPointerMove: draw }),
13154
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("canvas", { ref: pad, className: "w100n-pdf-pad", "aria-label": t.drawHere, onPointerDown: draw2, onPointerMove: draw2 }),
13081
13155
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "w100n-docs-row", children: [
13082
13156
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { className: "w100n-docs-muted", children: t.drawHere }),
13083
13157
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => {
@@ -13888,6 +13962,27 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13888
13962
  document.addEventListener("pointerdown", close);
13889
13963
  return () => document.removeEventListener("pointerdown", close);
13890
13964
  }, [picking]);
13965
+ const [menu, setMenu] = (0, import_react17.useState)(null);
13966
+ const [naming, setNaming] = (0, import_react17.useState)(null);
13967
+ const [notice, setNotice] = (0, import_react17.useState)(null);
13968
+ const early = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
13969
+ const hover = (0, import_react17.useRef)(0);
13970
+ (0, import_react17.useEffect)(() => {
13971
+ if (!menu) return;
13972
+ const close = (e) => {
13973
+ if (e.type === "pointerdown" && e.target.closest(".w100n-docs-context")) return;
13974
+ if (e.type === "keydown" && e.key !== "Escape") return;
13975
+ setMenu(null);
13976
+ };
13977
+ document.addEventListener("pointerdown", close);
13978
+ window.addEventListener("keydown", close);
13979
+ window.addEventListener("scroll", close, true);
13980
+ return () => {
13981
+ document.removeEventListener("pointerdown", close);
13982
+ window.removeEventListener("keydown", close);
13983
+ window.removeEventListener("scroll", close, true);
13984
+ };
13985
+ }, [menu]);
13891
13986
  const [tab, setTab] = (0, import_react17.useState)("outline");
13892
13987
  const [outline2, setOutline] = (0, import_react17.useState)([]);
13893
13988
  const [reading, setReading] = (0, import_react17.useState)(null);
@@ -13929,9 +14024,15 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
13929
14024
  document.removeEventListener("visibilitychange", sync);
13930
14025
  };
13931
14026
  }, []);
13932
- const doc = useLoad((signal) => here.documentId ? host.document(here.documentId, { signal }) : Promise.resolve(null), [host, here.documentId]);
14027
+ const take = (id, key2) => {
14028
+ const kept2 = early.current.get(id);
14029
+ const found = kept2 && Date.now() - kept2.at < 15e3 ? kept2[key2] : void 0;
14030
+ if (kept2) delete kept2[key2];
14031
+ return found;
14032
+ };
14033
+ const doc = useLoad((signal) => here.documentId ? take(here.documentId, "doc") ?? host.document(here.documentId, { signal }) : Promise.resolve(null), [host, here.documentId]);
13933
14034
  const versions = useLoad((signal) => here.documentId ? host.versions(here.documentId, { signal }) : Promise.resolve([]), [host, here.documentId]);
13934
- const content = useLoad((signal) => here.documentId ? host.content(here.documentId, versionId, { signal }) : Promise.resolve(null), [host, here.documentId, versionId]);
14035
+ const content = useLoad((signal) => here.documentId ? !versionId && take(here.documentId, "bytes") || host.content(here.documentId, versionId, { signal }) : Promise.resolve(null), [host, here.documentId, versionId]);
13935
14036
  const pdf = doc.data?.kind === "pdf";
13936
14037
  const text = doc.data?.kind === "markdown" || doc.data?.kind === "docx";
13937
14038
  const docbar = text && !versionId && !narrow;
@@ -14063,6 +14164,52 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14063
14164
  setKept({ id: file.id, state: "failed" });
14064
14165
  }
14065
14166
  };
14167
+ const warm = (item) => {
14168
+ clearTimeout(hover.current);
14169
+ hover.current = window.setTimeout(() => {
14170
+ if (item.id === here.documentId) return;
14171
+ if (item.kind === "docx" || item.kind === "markdown") void Promise.resolve().then(() => (init_TextEditor(), TextEditor_exports));
14172
+ if (item.kind === "sheet") void Promise.resolve().then(() => (init_SheetView(), SheetView_exports));
14173
+ const kept2 = early.current.get(item.id);
14174
+ if (kept2 && Date.now() - kept2.at < 15e3 || item.size > 5e6) return;
14175
+ const next = { at: Date.now(), doc: host.document(item.id), bytes: host.content(item.id, null) };
14176
+ next.doc.catch(() => {
14177
+ });
14178
+ next.bytes.catch(() => {
14179
+ });
14180
+ early.current.set(item.id, next);
14181
+ }, 150);
14182
+ };
14183
+ const act = async (run3, done) => {
14184
+ setMenu(null);
14185
+ setNotice(null);
14186
+ try {
14187
+ await run3();
14188
+ if (done) setNotice(done);
14189
+ } catch {
14190
+ setNotice(t.actionFailed);
14191
+ }
14192
+ };
14193
+ const fetchFile = async (item) => {
14194
+ const url = URL.createObjectURL(new Blob([await host.content(item.id)]));
14195
+ const link = Object.assign(document.createElement("a"), { href: url, download: item.name });
14196
+ link.click();
14197
+ setTimeout(() => URL.revokeObjectURL(url), 1e3);
14198
+ };
14199
+ const retitle = async (item, draft) => {
14200
+ setNaming(null);
14201
+ const ext = /\.[^.]+$/.exec(item.name)?.[0] ?? "";
14202
+ const name = draft.trim() && (/\.[^.\s]+$/.test(draft.trim()) ? draft.trim() : draft.trim() + ext);
14203
+ if (!name || name === item.name) return;
14204
+ await act(() => host.rename(item.id, name));
14205
+ list.retry();
14206
+ if (item.id === here.documentId) doc.retry();
14207
+ };
14208
+ const drop2 = async (item) => {
14209
+ await act(() => host.remove(item.id), t.trashed);
14210
+ list.retry();
14211
+ if (item.id === here.documentId) go({ spaceId: here.spaceId, documentId: null });
14212
+ };
14066
14213
  const rename = async (file, draft) => {
14067
14214
  setRenaming(null);
14068
14215
  const ext = /\.[^.]+$/.exec(file.name)?.[0] ?? "";
@@ -14309,6 +14456,21 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14309
14456
  kept?.id === here.documentId && kept.state === "failed" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-muted", role: "alert", children: t.templateFailed }),
14310
14457
  renamed2 === "failed" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-muted", children: t.renameFailed }),
14311
14458
  docbar && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { ref: setStatusAt, className: "w100n-docs-status" }),
14459
+ host.send && doc.data && !versionId && !doc.data.id.includes(":") && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
14460
+ "button",
14461
+ {
14462
+ type: "button",
14463
+ className: "w100n-docs-action",
14464
+ "data-tone": "blue",
14465
+ "aria-label": t.sendChat,
14466
+ title: t.sendChat,
14467
+ onClick: () => host.send(doc.data.id),
14468
+ children: [
14469
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Send, { "aria-hidden": true }),
14470
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.sendChat })
14471
+ ]
14472
+ }
14473
+ ),
14312
14474
  sharing && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-label": t.share, title: t.share, onClick: () => {
14313
14475
  setTab("sharing");
14314
14476
  side2("panel", true);
@@ -14437,17 +14599,56 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14437
14599
  sending === "failed" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted", role: "alert", children: t.uploadFailed }),
14438
14600
  list.error && failed(list.retry),
14439
14601
  list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted", children: t.loading }),
14602
+ notice && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted", role: "status", children: notice }),
14440
14603
  list.data && !shown.length && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted", children: all.length ? t.nothing : t.empty }),
14441
14604
  folders.map((folder2) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-folder", role: "group", "aria-label": folder2 || t.loose, children: [
14442
14605
  folders.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-group", children: folder2 || t.loose }),
14443
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-grid", children: shown.filter((item) => !spaceId || (item.folder ?? "") === folder2).map((item) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", className: "w100n-docs-card", "aria-current": item.id === here.documentId, onClick: () => open(item), title: item.name, children: [
14606
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-grid", children: shown.filter((item) => !spaceId || (item.folder ?? "") === folder2).map((item) => naming?.id === item.id ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-card", children: [
14444
14607
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Thumb, { host, item, label: t.kinds[item.kind] }),
14445
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "w100n-docs-card-text", children: [
14446
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("b", { children: item.name }),
14447
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: [!spaceId && names2.get(item.spaceId), ago(item.updatedAt)].filter(Boolean).join(" \xB7 ") }),
14448
- inside2.get(item.id) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { className: "w100n-docs-hit", children: inside2.get(item.id).split(/[«»]/).map((part, i) => i % 2 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("mark", { children: part }, i) : part) })
14449
- ] })
14450
- ] }, item.id)) })
14608
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-card-text", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
14609
+ "input",
14610
+ {
14611
+ className: "w100n-docs-field",
14612
+ autoFocus: true,
14613
+ value: naming.text,
14614
+ "aria-label": t.rename,
14615
+ onFocus: (e) => e.currentTarget.select(),
14616
+ onChange: (e) => setNaming({ ...naming, text: e.target.value }),
14617
+ onBlur: () => void retitle(item, naming.text),
14618
+ onKeyDown: (e) => {
14619
+ if (e.key === "Enter") e.currentTarget.blur();
14620
+ if (e.key === "Escape") {
14621
+ e.stopPropagation();
14622
+ setNaming(null);
14623
+ }
14624
+ }
14625
+ }
14626
+ ) })
14627
+ ] }, item.id) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
14628
+ "button",
14629
+ {
14630
+ type: "button",
14631
+ className: "w100n-docs-card",
14632
+ "aria-current": item.id === here.documentId,
14633
+ onClick: () => open(item),
14634
+ title: item.name,
14635
+ onPointerEnter: () => warm(item),
14636
+ onPointerLeave: () => clearTimeout(hover.current),
14637
+ onContextMenu: (e) => {
14638
+ e.preventDefault();
14639
+ setMenu({ item, x: Math.min(e.clientX, innerWidth - 290), y: Math.min(e.clientY, innerHeight - 440), sure: false });
14640
+ },
14641
+ children: [
14642
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Thumb, { host, item, label: t.kinds[item.kind] }),
14643
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "w100n-docs-card-text", children: [
14644
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("b", { children: item.name }),
14645
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: [!spaceId && names2.get(item.spaceId), ago(item.updatedAt)].filter(Boolean).join(" \xB7 ") }),
14646
+ inside2.get(item.id) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { className: "w100n-docs-hit", children: inside2.get(item.id).split(/[«»]/).map((part, i) => i % 2 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("mark", { children: part }, i) : part) })
14647
+ ] })
14648
+ ]
14649
+ },
14650
+ item.id
14651
+ )) })
14451
14652
  ] }, folder2))
14452
14653
  ] })
14453
14654
  ] }),
@@ -14616,6 +14817,86 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14616
14817
  setMaking(false);
14617
14818
  opened2(made2);
14618
14819
  } }),
14820
+ menu && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-menu w100n-docs-context", role: "menu", "aria-label": t.fileActions, style: { left: menu.x, top: menu.y }, children: [
14821
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-context-head", children: [
14822
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("b", { children: menu.item.name }),
14823
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: [t.kinds[menu.item.kind], size2(menu.item.size), names2.get(menu.item.spaceId), menu.item.folder].filter(Boolean).join(" \xB7 ") }),
14824
+ menu.item.createdAt && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: [t.createdOn.replace("{when}", date(menu.item.createdAt)), menu.item.createdBy?.name].filter(Boolean).join(" \xB7 ") }),
14825
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: [t.updatedOn.replace("{when}", ago(menu.item.updatedAt)), menu.item.updatedBy?.name].filter(Boolean).join(" \xB7 ") })
14826
+ ] }),
14827
+ menu.sure ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-context-ask", children: [
14828
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children: t.trashAsk.replace("{name}", menu.item.name) }),
14829
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "w100n-pdf-dialog-end", children: [
14830
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => setMenu({ ...menu, sure: false }), children: t.cancel }),
14831
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "red", onClick: () => void drop2(menu.item), children: [
14832
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Trash2, { "aria-hidden": true }),
14833
+ t.trash
14834
+ ] })
14835
+ ] })
14836
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
14837
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
14838
+ setMenu(null);
14839
+ open(menu.item);
14840
+ }, children: [
14841
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.FileText, { "aria-hidden": true }),
14842
+ t.openFile
14843
+ ] }),
14844
+ host.href && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
14845
+ setMenu(null);
14846
+ window.open(host.href(menu.item.id), "_blank", "noopener");
14847
+ }, children: [
14848
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.ExternalLink, { "aria-hidden": true }),
14849
+ t.openTab
14850
+ ] }),
14851
+ host.href && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => void act(() => navigator.clipboard.writeText(host.href(menu.item.id)), t.linkCopied), children: [
14852
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Link, { "aria-hidden": true }),
14853
+ t.copyLink
14854
+ ] }),
14855
+ host.send && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
14856
+ setMenu(null);
14857
+ host.send(menu.item.id);
14858
+ }, children: [
14859
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Send, { "aria-hidden": true }),
14860
+ t.sendChat
14861
+ ] }),
14862
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("hr", {}),
14863
+ host.rename && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
14864
+ setMenu(null);
14865
+ setNaming({ id: menu.item.id, text: menu.item.name.replace(/\.[^.]+$/, "") });
14866
+ }, children: [
14867
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Pencil, { "aria-hidden": true }),
14868
+ t.rename
14869
+ ] }),
14870
+ host.create && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => void act(async () => copy2(await host.document(menu.item.id))), children: [
14871
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Copy, { "aria-hidden": true }),
14872
+ t.makeCopy
14873
+ ] }),
14874
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => void act(() => fetchFile(menu.item)), children: [
14875
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Download, { "aria-hidden": true }),
14876
+ t.download
14877
+ ] }),
14878
+ host.saveTemplate && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => void act(() => host.saveTemplate(menu.item.id), t.templateSaved), children: [
14879
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Bookmark, { "aria-hidden": true }),
14880
+ t.saveTemplate
14881
+ ] }),
14882
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
14883
+ setMenu(null);
14884
+ open(menu.item);
14885
+ setTab("details");
14886
+ side2("panel", true);
14887
+ }, children: [
14888
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Info, { "aria-hidden": true }),
14889
+ t.details
14890
+ ] }),
14891
+ host.remove && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
14892
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("hr", {}),
14893
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", role: "menuitem", "data-tone": "red", onClick: () => setMenu({ ...menu, sure: true }), children: [
14894
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react10.Trash2, { "aria-hidden": true }),
14895
+ t.trash
14896
+ ] })
14897
+ ] })
14898
+ ] })
14899
+ ] }),
14619
14900
  dialog
14620
14901
  ] });
14621
14902
  }