@w100n/documents 0.19.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/collab.d.cts CHANGED
@@ -19,6 +19,11 @@ type Clash = Spot & {
19
19
  };
20
20
  type Value = string | number | boolean | null;
21
21
  declare function clashes(doc: Y.Doc, kind: 'xlsx' | 'csv', seen: ArrayBuffer, list: Spot[]): Clash[];
22
+ declare function addSheet(doc: Y.Doc, name: string, origin: unknown): boolean;
23
+ declare function where(doc: Y.Doc, sheet: string, refs: string[]): {
24
+ sheet: string;
25
+ range: string;
26
+ } | null;
22
27
  declare function appendRows(doc: Y.Doc, sheet: string, lines: Value[][], origin: unknown): string | null;
23
28
  declare function compute(doc: Y.Doc, origin: unknown): Promise<number>;
24
29
 
@@ -62,4 +67,4 @@ declare function applySteps(doc: Y.Doc, kind: Prose, steps: Step[], seen: JSONCo
62
67
  };
63
68
  declare function save(doc: Y.Doc, kind: Kind, base: ArrayBuffer, put: (bytes: ArrayBuffer, note: string) => Promise<string>, load?: (src: string) => Promise<Img>, note?: string): Promise<Saved | null>;
64
69
 
65
- export { type Author, type Clash, type Kind, type Prose, Refusal, type Saved, type SectionClash, type Step, appendRows, applyCells, applySteps, applyText, clashes, compute, edits, filled, follow, ours, parse, pending, save, seed };
70
+ export { type Author, type Clash, type Kind, type Prose, Refusal, type Saved, type SectionClash, type Step, addSheet, appendRows, applyCells, applySteps, applyText, clashes, compute, edits, filled, follow, ours, parse, pending, save, seed, where };
package/dist/collab.d.ts CHANGED
@@ -19,6 +19,11 @@ type Clash = Spot & {
19
19
  };
20
20
  type Value = string | number | boolean | null;
21
21
  declare function clashes(doc: Y.Doc, kind: 'xlsx' | 'csv', seen: ArrayBuffer, list: Spot[]): Clash[];
22
+ declare function addSheet(doc: Y.Doc, name: string, origin: unknown): boolean;
23
+ declare function where(doc: Y.Doc, sheet: string, refs: string[]): {
24
+ sheet: string;
25
+ range: string;
26
+ } | null;
22
27
  declare function appendRows(doc: Y.Doc, sheet: string, lines: Value[][], origin: unknown): string | null;
23
28
  declare function compute(doc: Y.Doc, origin: unknown): Promise<number>;
24
29
 
@@ -62,4 +67,4 @@ declare function applySteps(doc: Y.Doc, kind: Prose, steps: Step[], seen: JSONCo
62
67
  };
63
68
  declare function save(doc: Y.Doc, kind: Kind, base: ArrayBuffer, put: (bytes: ArrayBuffer, note: string) => Promise<string>, load?: (src: string) => Promise<Img>, note?: string): Promise<Saved | null>;
64
69
 
65
- export { type Author, type Clash, type Kind, type Prose, Refusal, type Saved, type SectionClash, type Step, appendRows, applyCells, applySteps, applyText, clashes, compute, edits, filled, follow, ours, parse, pending, save, seed };
70
+ export { type Author, type Clash, type Kind, type Prose, Refusal, type Saved, type SectionClash, type Step, addSheet, appendRows, applyCells, applySteps, applyText, clashes, compute, edits, filled, follow, ours, parse, pending, save, seed, where };
package/dist/collab.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import {
3
3
  Refusal,
4
+ addSheet,
4
5
  appendRows,
5
6
  applyCells,
6
7
  applySteps,
@@ -14,14 +15,16 @@ import {
14
15
  parse,
15
16
  pending,
16
17
  save,
17
- seed
18
- } from "./chunk-VG7UW2CQ.js";
18
+ seed,
19
+ where
20
+ } from "./chunk-2JGDV5HG.js";
19
21
  import "./chunk-GSIPTCQH.js";
20
22
  import "./chunk-BWU6FPPZ.js";
21
23
  import "./chunk-ZAVXCH7V.js";
22
24
  import "./chunk-ISOOUYLI.js";
23
25
  export {
24
26
  Refusal,
27
+ addSheet,
25
28
  appendRows,
26
29
  applyCells,
27
30
  applySteps,
@@ -35,6 +38,7 @@ export {
35
38
  parse,
36
39
  pending,
37
40
  save,
38
- seed
41
+ seed,
42
+ where
39
43
  };
40
44
  //# sourceMappingURL=collab.js.map
@@ -71,7 +71,7 @@ function grid(container, language, edit) {
71
71
  toolbar: false,
72
72
  formulaBar: true,
73
73
  contextMenu: true,
74
- disableAutoFocus: true,
74
+ disableAutoFocus: matchMedia("(pointer: coarse)").matches,
75
75
  footer: { sheetBar: true, statisticBar: true, menus: edit, zoomSlider: true, addSheetButtonConfig: { show: edit } },
76
76
  formula: { initialFormulaComputing: CalculationMode.WHEN_EMPTY }
77
77
  }),
@@ -137,4 +137,4 @@ export {
137
137
  grid,
138
138
  marks
139
139
  };
140
- //# sourceMappingURL=grid-7OGS3FPU.js.map
140
+ //# sourceMappingURL=grid-FUHH7UHO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sheets/grid.ts","../src/sheets/calm.ts"],"sourcesContent":["import '@univerjs/preset-sheets-core/lib/index.css';\nimport '@univerjs/preset-sheets-sort/lib/index.css';\nimport '@univerjs/preset-sheets-filter/lib/index.css';\nimport '@univerjs/preset-sheets-find-replace/lib/index.css';\nimport '@univerjs/preset-sheets-data-validation/lib/index.css';\nimport '@univerjs/preset-sheets-note/lib/index.css';\nimport { createUniver, LocaleType, mergeLocales, purpleTheme } from '@univerjs/presets';\nimport { ICommandService, IUniverInstanceService, WrapStrategy, type Injector, type Workbook } from '@univerjs/core';\nimport { CalculationMode, IMarkSelectionService, IRenderManagerService, SelectionControl, SetWorksheetRowAutoHeightMutation, SetWorksheetRowIsAutoHeightMutation, SheetSkeletonManagerService, UniverSheetsCorePreset } from '@univerjs/preset-sheets-core';\nimport { UniverSheetsDataValidationPreset } from '@univerjs/preset-sheets-data-validation';\nimport { UniverSheetsFilterPreset } from '@univerjs/preset-sheets-filter';\nimport { UniverSheetsFindReplacePreset } from '@univerjs/preset-sheets-find-replace';\nimport { UniverSheetsNotePreset } from '@univerjs/preset-sheets-note';\nimport { UniverSheetsSortPreset } from '@univerjs/preset-sheets-sort';\nimport coreEn from '@univerjs/preset-sheets-core/locales/en-US';\nimport corePl from '@univerjs/preset-sheets-core/locales/pl-PL';\nimport checkEn from '@univerjs/preset-sheets-data-validation/locales/en-US';\nimport checkPl from '@univerjs/preset-sheets-data-validation/locales/pl-PL';\nimport filterEn from '@univerjs/preset-sheets-filter/locales/en-US';\nimport filterPl from '@univerjs/preset-sheets-filter/locales/pl-PL';\nimport findEn from '@univerjs/preset-sheets-find-replace/locales/en-US';\nimport findPl from '@univerjs/preset-sheets-find-replace/locales/pl-PL';\nimport noteEn from '@univerjs/preset-sheets-note/locales/en-US';\nimport notePl from '@univerjs/preset-sheets-note/locales/pl-PL';\nimport sortEn from '@univerjs/preset-sheets-sort/locales/en-US';\nimport sortPl from '@univerjs/preset-sheets-sort/locales/pl-PL';\nimport type { Language } from '../types';\nimport { bolder, calm } from './calm';\nimport { box } from './refs';\n\nexport type Mark = { sheet: string; range: string; color: string };\n\nconst draw = SelectionControl.prototype.updateRangeBySelectionWithCoord;\n// Univer draws eight resize handles on every formula reference and offers no option to turn them off.\nSelectionControl.prototype.updateRangeBySelectionWithCoord = function (selection, ...rest) { draw.call(this, calm(selection), ...rest); };\n\nexport function grid(container: HTMLElement, language: Language, edit: boolean) {\n return createUniver({\n locale: language === 'pl' ? LocaleType.PL_PL : LocaleType.EN_US,\n locales: {\n [LocaleType.EN_US]: mergeLocales(coreEn, checkEn, filterEn, findEn, noteEn, sortEn),\n [LocaleType.PL_PL]: mergeLocales(corePl, checkPl, filterPl, findPl, notePl, sortPl),\n },\n theme: { ...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' } },\n darkMode: false,\n presets: [\n UniverSheetsCorePreset({\n container, toolbar: false, formulaBar: true, contextMenu: true, disableAutoFocus: matchMedia('(pointer: coarse)').matches,\n footer: { sheetBar: true, statisticBar: true, menus: edit, zoomSlider: true, addSheetButtonConfig: { show: edit } },\n formula: { initialFormulaComputing: CalculationMode.WHEN_EMPTY },\n }),\n UniverSheetsSortPreset(),\n UniverSheetsFilterPreset(),\n UniverSheetsFindReplacePreset(),\n UniverSheetsDataValidationPreset(),\n UniverSheetsNotePreset(),\n ],\n });\n}\n\nexport function fit(injector: Injector, unitId: string) {\n const book = injector.get(IUniverInstanceService).getUnit<Workbook>(unitId);\n const skeletons = injector.get(IRenderManagerService).getRenderUnitById(unitId)?.with(SheetSkeletonManagerService);\n if (!book || !skeletons) return;\n const commands = injector.get(ICommandService);\n for (const sheet of book.getSheets()) {\n const rows = new Set<number>();\n sheet.getCellMatrix().forValue((r, _, cell) => { if (book.getStyles().getStyleByCell(cell)?.tb === WrapStrategy.WRAP) rows.add(r); });\n if (!rows.size) continue;\n const subUnitId = sheet.getSheetId(), last = sheet.getMaxColumns() - 1, all = [...rows];\n const line = (r: number) => ({ startRow: r, endRow: r, startColumn: 0, endColumn: last });\n const was = Object.fromEntries(all.map(r => [r, sheet.getConfig().rowData[r]?.ia ?? null]));\n const stored = Object.fromEntries(all.map(r => [r, sheet.getRowHeight(r)]));\n const auto = (list: number[], info: number | Record<number, number | null>) => commands.syncExecuteCommand(SetWorksheetRowIsAutoHeightMutation.id, { unitId, subUnitId, ranges: list.map(line), autoHeightInfo: info }, { onlyLocal: true });\n auto(all, 1);\n const grow = (skeletons.ensureSkeleton(subUnitId)?.calculateAutoHeightInRange(all.map(line)) ?? []).filter(x => (x.autoHeight ?? 0) > stored[x.row]);\n const keep = all.filter(r => !grow.some(x => x.row === r));\n if (keep.length) auto(keep, was);\n if (grow.length) commands.syncExecuteCommand(SetWorksheetRowAutoHeightMutation.id, { unitId, subUnitId, rowsAutoHeightInfo: grow }, { onlyLocal: true });\n }\n}\n\nexport { bolder };\n\nexport function marks({ univer, univerAPI: api }: ReturnType<typeof grid>) {\n const service = univer.__getInjector().get(IMarkSelectionService);\n let list: Mark[] = [];\n let ids: string[] = [];\n const draw = () => {\n ids.forEach(id => service.removeShape(id));\n const sid = api.getActiveWorkbook()?.getActiveSheet().getSheetId();\n ids = list.filter(m => m.sheet === sid).flatMap(m => {\n const b = box(m.range);\n const id = b && service.addShape({ range: b, primary: null, style: { stroke: m.color, fill: `${m.color}1f`, strokeWidth: 2, widgets: {} } }, [], 1000);\n return id ? [id] : [];\n });\n };\n const turn = api.addEvent(api.Event.ActiveSheetChanged, draw);\n return {\n show: (next: Mark[]) => { list = next; draw(); },\n dispose: () => { turn.dispose(); ids.forEach(id => service.removeShape(id)); },\n };\n}\n","import { ICommandService, ThemeService, type Injector } from '@univerjs/core';\n\ntype Style = { widgets?: object; strokeWidth?: number; stroke?: string; fill?: string };\ntype Run = { ts?: { cl?: { rgb?: string | null } | null; bl?: number } };\n\nconst pale = (color: string) => /^#[0-9a-f]{6}$/i.test(color) ? `${color}24` : color.replace(/^rgb\\(([^)]+)\\)$/i, 'rgba($1, 0.14)');\n\nexport const calm = <T extends { style?: Style | null | void }>(selection: T): T => {\n const style = selection.style;\n if (!style?.widgets || !Object.values(style.widgets).some(Boolean)) return selection;\n return { ...selection, style: { ...style, widgets: {}, strokeWidth: 3, fill: style.stroke ? pale(style.stroke) : style.fill } };\n};\n\nexport function bolder(injector: Injector) {\n const theme = injector.get(ThemeService);\n const tone = (color: string) => theme.isValidThemeColor(color) ? theme.getColorFromTheme(color) : color;\n const refs = new Set(Array.from({ length: 12 }, (_, i) => tone(theme.getColorFromTheme(`loop-color.${i + 1}`))));\n return injector.get(ICommandService).beforeCommandExecuted(({ id, params }) => {\n if (id !== 'doc.command.replace-text-runs') return;\n (params as { body?: { textRuns?: Run[] } } | undefined)?.body?.textRuns?.forEach(run => {\n if (run.ts?.cl?.rgb && refs.has(run.ts.cl.rgb)) run.ts.bl = 1;\n });\n });\n}\n"],"mappings":";;;;;;AAAA,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,SAAS,cAAc,YAAY,cAAc,mBAAmB;AACpE,SAAS,mBAAAA,kBAAiB,wBAAwB,oBAAkD;AACpG,SAAS,iBAAiB,uBAAuB,uBAAuB,kBAAkB,mCAAmC,qCAAqC,6BAA6B,8BAA8B;AAC7N,SAAS,wCAAwC;AAC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
4993
4993
  var version;
4994
4994
  var init_package = __esm({
4995
4995
  "package.json"() {
4996
- version = "0.19.1";
4996
+ version = "0.20.0";
4997
4997
  }
4998
4998
  });
4999
4999
 
@@ -8419,7 +8419,7 @@ var TextEditor_exports = {};
8419
8419
  __export(TextEditor_exports, {
8420
8420
  default: () => TextEditor
8421
8421
  });
8422
- function TextEditor({ kind, bytes, t, language, rights, host, together, documentId, onSaved, onOutline, onReading, onPanel, slot, head: head2, file, guard, wiki }) {
8422
+ function TextEditor({ kind, bytes, t, language, rights, host, together, documentId, onSaved, onOutline, onReading, onSpot, onPanel, slot, head: head2, file, guard, wiki }) {
8423
8423
  const docx2 = kind === "docx";
8424
8424
  const can = { edit: !!host?.save && !!rights?.edit, comment: !!host?.comment && !!rights && (rights.comment || rights.edit) };
8425
8425
  const source = useLoad(async () => {
@@ -8487,6 +8487,10 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
8487
8487
  transformPastedHTML: cleanPaste,
8488
8488
  handleKeyDown: (view, event) => !!wikiAsk.getState(view.state) && !!wikiKeys.current?.(event.key)
8489
8489
  },
8490
+ onSelectionUpdate: ({ editor: e }) => {
8491
+ const { from, to, empty } = e.state.selection;
8492
+ onSpot?.(empty ? null : { quote: e.state.doc.textBetween(from, to, " ").slice(0, 300) });
8493
+ },
8490
8494
  onCreate: ({ editor: made2 }) => {
8491
8495
  if (source.data && !live) baseline.current = { bytes, doc: made2.state.doc, base: source.data.md && track(source.data.md, made2.state.doc) };
8492
8496
  }
@@ -10550,7 +10554,7 @@ function grid2(container, language, edit) {
10550
10554
  toolbar: false,
10551
10555
  formulaBar: true,
10552
10556
  contextMenu: true,
10553
- disableAutoFocus: true,
10557
+ disableAutoFocus: matchMedia("(pointer: coarse)").matches,
10554
10558
  footer: { sheetBar: true, statisticBar: true, menus: edit, zoomSlider: true, addSheetButtonConfig: { show: edit } },
10555
10559
  formula: { initialFormulaComputing: import_preset_sheets_core.CalculationMode.WHEN_EMPTY }
10556
10560
  }),
@@ -10674,7 +10678,7 @@ function autoSum(r, numeric2) {
10674
10678
  while (left > 0 && numeric2(r.startRow, left - 1)) left--;
10675
10679
  return left < r.startColumn ? [{ row: r.startRow, col: r.startColumn, f: `=SUM(${letters2(left)}${r.startRow + 1}:${letters2(r.startColumn - 1)}${r.startRow + 1})` }] : [];
10676
10680
  }
10677
- function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSaveRequest, guard, host, together, documentId = "", onSaved }) {
10681
+ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSaveRequest, guard, host, together, documentId = "", onSaved, onSpot }) {
10678
10682
  const t = sheetTexts[language];
10679
10683
  const box2 = (0, import_react12.useRef)(null);
10680
10684
  const live = (0, import_react12.useRef)(null);
@@ -10743,6 +10747,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10743
10747
  }
10744
10748
  let frame = 0;
10745
10749
  let last2 = "";
10750
+ let told = "";
10746
10751
  const refresh = () => {
10747
10752
  frame = 0;
10748
10753
  const range2 = api2.getActiveWorkbook()?.getActiveRange();
@@ -10753,6 +10758,11 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
10753
10758
  last2 = JSON.stringify(here);
10754
10759
  people.setLocalStateField("selection", here);
10755
10760
  }
10761
+ const spot3 = { sheet: api2.getActiveWorkbook()?.getActiveSheet().getSheetName() ?? "", range: here.range };
10762
+ if (JSON.stringify(spot3) !== told) {
10763
+ told = JSON.stringify(spot3);
10764
+ onSpot?.(spot3);
10765
+ }
10756
10766
  setLook({ bl: s.bl === 1, it: s.it === 1, ul: !!s.ul?.s, st: !!s.st?.s, fs: s.fs ?? 11, ht: s.ht ?? 0, tb: s.tb === 3, merged: range2.isMerged() || range2.isPartOfMerge(), n: s.n?.pattern ?? "General", cl: s.cl?.rgb ?? "", bg: s.bg?.rgb ?? "" });
10757
10767
  };
10758
10768
  const later = () => {
@@ -11050,6 +11060,25 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
11050
11060
  room.denied ? t.liveOff : t.offline
11051
11061
  ] }),
11052
11062
  room && room.people.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w100n-text-people", role: "group", "aria-label": t.people, children: room.people.map((p) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w100n-text-face", title: p.me ? `${p.name} (${t.you})` : p.name, style: { "--face": p.color }, children: p.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("img", { src: p.avatarUrl, alt: "" }) : p.name.split(/\s+/).map((w) => w[0]).join("").slice(0, 2).toUpperCase() }, p.id)) }),
11063
+ room?.people.filter((p) => !p.me && p.selection).map((p) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
11064
+ "button",
11065
+ {
11066
+ type: "button",
11067
+ className: "w100n-sheet-where",
11068
+ style: { "--face": p.color },
11069
+ onClick: () => {
11070
+ const ws = live.current?.api.getActiveWorkbook()?.getSheetBySheetId(p.selection.sheet);
11071
+ ws?.activate();
11072
+ ws?.getRange(p.selection.range).activate();
11073
+ },
11074
+ children: [
11075
+ p.name,
11076
+ " \xB7 ",
11077
+ p.selection.range
11078
+ ]
11079
+ },
11080
+ p.id
11081
+ )),
11053
11082
  !edit && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w100n-docs-badge", children: notes3 ? t.notesOnly : t.viewOnly }),
11054
11083
  saving === "failed" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w100n-sheet-muted", role: "alert", children: refusal ? t.refused[refusal.code].replace("{sheet}", refusal.sheet) : t.saveFailed }),
11055
11084
  (edit || notes3) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: !pending2 || saving === "busy" || phase !== "ready" || !!room && !room.online, onClick: () => void save2(), children: [
@@ -14694,7 +14723,7 @@ var import_jsx_runtime19 = require("react/jsx-runtime");
14694
14723
  var TextEditor3 = (0, import_react19.lazy)(() => Promise.resolve().then(() => (init_TextEditor(), TextEditor_exports)));
14695
14724
  var SheetView3 = (0, import_react19.lazy)(() => Promise.resolve().then(() => (init_SheetView(), SheetView_exports)));
14696
14725
  var Compare2 = (0, import_react19.lazy)(() => Promise.resolve().then(() => (init_Compare(), Compare_exports)));
14697
- function DocumentsWorkspace({ host, language = "en", theme = "light", place: place2, onPlace, start, end, aside, actions }) {
14726
+ function DocumentsWorkspace({ host, language = "en", theme = "light", place: place2, onPlace, start, end, aside, actions, tabs }) {
14698
14727
  const t = texts[language];
14699
14728
  const [own, setOwn] = (0, import_react19.useState)({ spaceId: null, documentId: null });
14700
14729
  const here = place2 ?? own;
@@ -14796,6 +14825,8 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14796
14825
  };
14797
14826
  }, [menu, spot3]);
14798
14827
  const [tab, setTab] = (0, import_react19.useState)("outline");
14828
+ const [heard, setHeard] = (0, import_react19.useState)(0);
14829
+ const [aim, setAim] = (0, import_react19.useState)(null);
14799
14830
  const [outline2, setOutline] = (0, import_react19.useState)([]);
14800
14831
  const [reading, setReading] = (0, import_react19.useState)(null);
14801
14832
  const [hunt, setHunt] = (0, import_react19.useState)("");
@@ -14912,6 +14943,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
14912
14943
  setHunt("");
14913
14944
  setFold({});
14914
14945
  setTab("outline");
14946
+ setAim(null);
14915
14947
  go({ spaceId: here.spaceId, documentId: item.id });
14916
14948
  if (narrow) setListOpen(false);
14917
14949
  });
@@ -15168,6 +15200,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15168
15200
  documentId: doc.data.id,
15169
15201
  onOutline: setOutline,
15170
15202
  onReading: setReading,
15203
+ onSpot: setAim,
15171
15204
  onPanel: (next) => {
15172
15205
  setPanelOpen(true);
15173
15206
  setTab(next);
@@ -15246,6 +15279,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15246
15279
  host: versionId ? void 0 : host,
15247
15280
  together: doc.data.live,
15248
15281
  documentId: doc.data.id,
15282
+ onSpot: setAim,
15249
15283
  onSaved: () => {
15250
15284
  versions.retry();
15251
15285
  doc.retry();
@@ -15285,6 +15319,16 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15285
15319
  if (text && host.comments && !versionId) panelTabs.push(["comments", import_lucide_react14.MessagesSquare, t.comments]);
15286
15320
  const sharing = !!host.links && !!doc.data?.rights.edit && !versionId;
15287
15321
  if (sharing) panelTabs.push(["sharing", import_lucide_react14.Share2, t.sharing]);
15322
+ const extra = doc.data ? tabs?.(doc.data, aim) ?? [] : [];
15323
+ const waiting2 = extra.find((x) => x.count);
15324
+ const pending2 = extra.reduce((n, x) => n + (x.count ?? 0), 0);
15325
+ if (pending2 !== heard) {
15326
+ setHeard(pending2);
15327
+ if (waiting2 && pending2 > heard) {
15328
+ setTab(`host:${waiting2.id}`);
15329
+ setPanelOpen(true);
15330
+ }
15331
+ }
15288
15332
  const listToggle = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
15289
15333
  "button",
15290
15334
  {
@@ -15544,15 +15588,23 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15544
15588
  !narrow && !panelOpen && panelToggle,
15545
15589
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w100n-docs-bare", children: stage })
15546
15590
  ] }),
15547
- doc.data && panelOpen && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("aside", { ref: panel, className: "w100n-docs-side w100n-docs-panel", "aria-label": t.details, children: [
15548
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w100n-docs-head", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "w100n-docs-row", children: [
15549
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w100n-docs-tabs", role: "tablist", "aria-label": t.details, "data-compact": panelTabs.length > 3, onKeyDown: rove, children: panelTabs.map(([key2, Icon, label]) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { type: "button", role: "tab", "aria-selected": tab === key2, tabIndex: tab === key2 ? 0 : -1, "aria-label": label, title: label, onClick: () => setTab(key2), children: [
15550
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { "aria-hidden": true }),
15551
- (panelTabs.length < 4 || tab === key2 && panelTabs.length < 5) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: label })
15552
- ] }, key2)) }),
15553
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => side2("panel", false), "aria-label": t.closePanel, title: t.closePanel, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react14.X, { "aria-hidden": true }) })
15554
- ] }) }),
15555
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "w100n-docs-panel-body", role: "tabpanel", "aria-label": panelTabs.find(([key2]) => key2 === tab)?.[2], children: [
15591
+ doc.data && panelOpen && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("aside", { ref: panel, className: "w100n-docs-side w100n-docs-panel", "data-wide": !!extra.find((x) => `host:${x.id}` === tab)?.wide, "aria-label": t.details, children: [
15592
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "w100n-docs-head", children: [
15593
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "w100n-docs-row", children: [
15594
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w100n-docs-tabs", role: "tablist", "aria-label": t.details, "data-compact": panelTabs.length > 3, onKeyDown: rove, children: panelTabs.map(([key2, Icon, label, count]) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { type: "button", role: "tab", "aria-selected": tab === key2, tabIndex: tab === key2 ? 0 : -1, "aria-label": label, title: label, onClick: () => setTab(key2), children: [
15595
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { "aria-hidden": true }),
15596
+ (panelTabs.length < 4 || tab === key2 && panelTabs.length < 5) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: label }),
15597
+ !!count && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("b", { className: "w100n-docs-count", children: count })
15598
+ ] }, key2)) }),
15599
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => side2("panel", false), "aria-label": t.closePanel, title: t.closePanel, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react14.X, { "aria-hidden": true }) })
15600
+ ] }),
15601
+ !!extra.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w100n-docs-hosttabs", role: "tablist", "aria-label": t.details, children: extra.map((x) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { type: "button", role: "tab", "aria-selected": tab === `host:${x.id}`, onClick: () => setTab(`host:${x.id}`), children: [
15602
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(x.icon, { "aria-hidden": true }),
15603
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: x.label }),
15604
+ !!x.count && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("b", { className: "w100n-docs-count", children: x.count })
15605
+ ] }, x.id)) })
15606
+ ] }),
15607
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "w100n-docs-panel-body", role: "tabpanel", "aria-label": panelTabs.find(([key2]) => key2 === tab)?.[2] ?? extra.find((x) => `host:${x.id}` === tab)?.label, children: [
15556
15608
  tab === "outline" && (outline2.length ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("nav", { className: "w100n-docs-outline", "aria-label": t.outline, children: [
15557
15609
  now && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "w100n-docs-reading", children: [
15558
15610
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("i", { style: { width: `${Math.round(now.progress * 100)}%` } }) }),
@@ -15697,6 +15749,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
15697
15749
  );
15698
15750
  })
15699
15751
  ] }),
15752
+ extra.find((x) => `host:${x.id}` === tab)?.body,
15700
15753
  aside?.(doc.data)
15701
15754
  ] })
15702
15755
  ] })