@arbidocs/blocks 0.5.122 → 0.5.123
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/ConnectedNativeDocxComparison-QKHCYD6W.cjs +1 -1
- package/dist/{ConnectedPresentation-AU25OW25.cjs → ConnectedPresentation-5DOJ35XL.cjs} +7 -7
- package/dist/{ConnectedPresentation-AU25OW25.cjs.map → ConnectedPresentation-5DOJ35XL.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-I75LKKN7.cjs → ConnectedSlidesTab-7YMEDGUU.cjs} +40 -18
- package/dist/ConnectedSlidesTab-7YMEDGUU.cjs.map +1 -0
- package/dist/ConnectedStreamedWordArtifact-AG62232A.cjs +1 -1
- package/dist/{FilesViewerDialog-4352KIOG.cjs → FilesViewerDialog-2QCCRWF2.cjs} +7 -7
- package/dist/{FilesViewerDialog-4352KIOG.cjs.map → FilesViewerDialog-2QCCRWF2.cjs.map} +1 -1
- package/dist/agents/index.cjs +176 -176
- package/dist/{chunk-LHWOKOMP.cjs → chunk-46P7IDBX.cjs} +3 -3
- package/dist/chunk-46P7IDBX.cjs.map +1 -0
- package/dist/{chunk-USNTRL22.cjs → chunk-DWMWEALB.cjs} +288 -214
- package/dist/chunk-DWMWEALB.cjs.map +1 -0
- package/dist/{chunk-UTJ223TI.cjs → chunk-JD2HX2BR.cjs} +98 -78
- package/dist/chunk-JD2HX2BR.cjs.map +1 -0
- package/dist/{chunk-QG2U2JGX.cjs → chunk-L4CIFLCU.cjs} +4 -4
- package/dist/{chunk-QG2U2JGX.cjs.map → chunk-L4CIFLCU.cjs.map} +1 -1
- package/dist/{chunk-CQQQIZU4.cjs → chunk-NQML7IUC.cjs} +3 -3
- package/dist/{chunk-CQQQIZU4.cjs.map → chunk-NQML7IUC.cjs.map} +1 -1
- package/dist/{chunk-WRLGLZIA.cjs → chunk-SNPK3R3O.cjs} +5 -5
- package/dist/{chunk-WRLGLZIA.cjs.map → chunk-SNPK3R3O.cjs.map} +1 -1
- package/dist/{chunk-XGM4VVNV.cjs → chunk-WV7BCGCK.cjs} +19 -19
- package/dist/{chunk-XGM4VVNV.cjs.map → chunk-WV7BCGCK.cjs.map} +1 -1
- package/dist/connect/docx.cjs +1 -1
- package/dist/connect/index.cjs +161 -161
- package/dist/connect/viewer.cjs +5 -5
- package/dist/connection/presentation/ConnectedSlidesTab.js +35 -13
- package/dist/connection/presentation/ConnectedSlidesTab.js.map +2 -2
- package/dist/connection/viewer/ConnectedDocumentViewer.js +51 -60
- package/dist/connection/viewer/ConnectedDocumentViewer.js.map +2 -2
- package/dist/connection/viewer/ViewerMoreMenu.d.ts +18 -0
- package/dist/connection/viewer/ViewerMoreMenu.js +45 -0
- package/dist/connection/viewer/ViewerMoreMenu.js.map +7 -0
- package/dist/connection/viewer/pdf/PdfPassageHighlights.js +3 -2
- package/dist/connection/viewer/pdf/PdfPassageHighlights.js.map +2 -2
- package/dist/document-tools/DocumentToolButtons.js +2 -2
- package/dist/document-tools/DocumentToolButtons.js.map +2 -2
- package/dist/document-tools/index.cjs +13 -13
- package/dist/embed/index.cjs +2 -2
- package/dist/index.cjs +234 -234
- package/dist/presentation/BoxActionBar.d.ts +2 -2
- package/dist/presentation/BoxActionBar.js +62 -30
- package/dist/presentation/BoxActionBar.js.map +2 -2
- package/dist/presentation/ClipActionBar.js +60 -7
- package/dist/presentation/ClipActionBar.js.map +2 -2
- package/dist/presentation/ClipViewControls.d.ts +3 -3
- package/dist/presentation/ClipViewControls.js +59 -64
- package/dist/presentation/ClipViewControls.js.map +2 -2
- package/dist/presentation/SlidesEditor.js +56 -42
- package/dist/presentation/SlidesEditor.js.map +2 -2
- package/dist/presentation/StageItem.js +0 -5
- package/dist/presentation/StageItem.js.map +2 -2
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +12 -12
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/ConnectedSlidesTab-I75LKKN7.cjs.map +0 -1
- package/dist/chunk-LHWOKOMP.cjs.map +0 -1
- package/dist/chunk-USNTRL22.cjs.map +0 -1
- package/dist/chunk-UTJ223TI.cjs.map +0 -1
package/dist/connect/viewer.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkJD2HX2BR_cjs = require('../chunk-JD2HX2BR.cjs');
|
|
5
5
|
require('../chunk-WFMWKPGY.cjs');
|
|
6
6
|
require('../chunk-4TTX6ZNS.cjs');
|
|
7
7
|
require('../chunk-4CIVQWAX.cjs');
|
|
@@ -20,7 +20,7 @@ require('../chunk-4ONPEVTP.cjs');
|
|
|
20
20
|
require('../chunk-V3KLUWQQ.cjs');
|
|
21
21
|
require('../chunk-P5AQYC4D.cjs');
|
|
22
22
|
require('../chunk-WAV762GP.cjs');
|
|
23
|
-
require('../chunk-
|
|
23
|
+
require('../chunk-46P7IDBX.cjs');
|
|
24
24
|
require('../chunk-GNZAH6UI.cjs');
|
|
25
25
|
require('../chunk-JH6JTI76.cjs');
|
|
26
26
|
require('../chunk-QQMMCXBP.cjs');
|
|
@@ -38,9 +38,9 @@ require('../chunk-WQMR3O2D.cjs');
|
|
|
38
38
|
require('../chunk-ORELHENJ.cjs');
|
|
39
39
|
require('../chunk-NWNVWO6L.cjs');
|
|
40
40
|
require('../chunk-SK6HQ46Q.cjs');
|
|
41
|
+
require('../chunk-TG2GM7WJ.cjs');
|
|
41
42
|
require('../chunk-MNIQDXM6.cjs');
|
|
42
43
|
require('../chunk-E3Y7RI3J.cjs');
|
|
43
|
-
require('../chunk-TG2GM7WJ.cjs');
|
|
44
44
|
require('../chunk-VKH3BEZE.cjs');
|
|
45
45
|
require('../chunk-OEJQFPWO.cjs');
|
|
46
46
|
require('../chunk-OYXWQTHF.cjs');
|
|
@@ -51,9 +51,9 @@ require('../chunk-3YEXZX4H.cjs');
|
|
|
51
51
|
require('../chunk-4PA6VCCR.cjs');
|
|
52
52
|
require('../chunk-WXUU3COI.cjs');
|
|
53
53
|
require('../chunk-AHDJXIUB.cjs');
|
|
54
|
+
require('../chunk-YVCOQHCE.cjs');
|
|
54
55
|
require('../chunk-RL2HI6NP.cjs');
|
|
55
56
|
require('../chunk-6UZC4XVV.cjs');
|
|
56
|
-
require('../chunk-YVCOQHCE.cjs');
|
|
57
57
|
require('../chunk-JV5TVUOU.cjs');
|
|
58
58
|
require('../chunk-ZVEW3JBT.cjs');
|
|
59
59
|
require('../chunk-EG7EJFUE.cjs');
|
|
@@ -92,7 +92,7 @@ require('../chunk-PLIF5CUV.cjs');
|
|
|
92
92
|
|
|
93
93
|
Object.defineProperty(exports, "ConnectedDocumentViewer", {
|
|
94
94
|
enumerable: true,
|
|
95
|
-
get: function () { return
|
|
95
|
+
get: function () { return chunkJD2HX2BR_cjs.ConnectedDocumentViewer; }
|
|
96
96
|
});
|
|
97
97
|
Object.defineProperty(exports, "ConnectedDocumentToolsProvider", {
|
|
98
98
|
enumerable: true,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useArbiSessionState,
|
|
9
9
|
useArbiSessionStore
|
|
10
10
|
} from "@arbidocs/react";
|
|
11
|
-
import { Button } from "@arbidocs/react/ui";
|
|
11
|
+
import { Button, DropdownMenuItem } from "@arbidocs/react/ui";
|
|
12
12
|
import { useBlocksEnvironment } from "../../provider/environment.js";
|
|
13
13
|
import { usePanelHostSupport } from "../../shell/panel-host.js";
|
|
14
14
|
import {
|
|
@@ -23,6 +23,8 @@ import { editPresentation } from "./requests.js";
|
|
|
23
23
|
import { usePresentationController } from "./usePresentationController.js";
|
|
24
24
|
import { usePresentationFiles } from "./usePresentationFiles.js";
|
|
25
25
|
const listOf = (numbers) => numbers.length < 2 ? String(numbers[0] ?? "") : `${numbers.slice(0, -1).join(", ")} and ${numbers[numbers.length - 1]}`;
|
|
26
|
+
const AUTO_SAVE_AFTER_MS = 2500;
|
|
27
|
+
const DEFAULT_NAMES = /^(new|untitled) presentation( \d+)?$/i;
|
|
26
28
|
const STALE = "This presentation was changed outside the editor: Save to draw its slides again.";
|
|
27
29
|
const hasContent = () => hasUnsavedChanges(usePresentation.getState());
|
|
28
30
|
function ConnectedSlidesTab({
|
|
@@ -138,6 +140,29 @@ function ConnectedSlidesTab({
|
|
|
138
140
|
)
|
|
139
141
|
).finally(() => setLoading(false));
|
|
140
142
|
}, [currentVersion, heldVersion, isDraft, version, loading, open, documentId, target, notify]);
|
|
143
|
+
const draftHasContent = usePresentation(
|
|
144
|
+
(state) => isDraft && state.boundTo === target && state.savedId === null && hasUnsavedChanges(state)
|
|
145
|
+
);
|
|
146
|
+
const autoSaved = useRef(null);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (!draftHasContent || autoSaved.current === target) return;
|
|
149
|
+
const timer = setTimeout(() => {
|
|
150
|
+
autoSaved.current = target;
|
|
151
|
+
const state = usePresentation.getState();
|
|
152
|
+
const firstTitle = state.slides.find((slide) => slide.caption.trim())?.caption.trim();
|
|
153
|
+
const named = state.title && !DEFAULT_NAMES.test(state.title) ? state.title : null;
|
|
154
|
+
const title = named ?? firstTitle ?? (state.title || "Untitled presentation");
|
|
155
|
+
if (title !== state.title) state.setTitle(title);
|
|
156
|
+
void save(title).catch((error) => {
|
|
157
|
+
autoSaved.current = null;
|
|
158
|
+
notify(
|
|
159
|
+
error instanceof Error ? error.message : "The presentation could not be saved",
|
|
160
|
+
"error"
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
}, AUTO_SAVE_AFTER_MS);
|
|
164
|
+
return () => clearTimeout(timer);
|
|
165
|
+
}, [draftHasContent, target, save, draftTitle, notify]);
|
|
141
166
|
useEffect(() => {
|
|
142
167
|
if (isDraft || version || savedId !== documentId || boundTo !== target) return;
|
|
143
168
|
return registerDocumentTurnFlush(documentId, async () => {
|
|
@@ -194,20 +219,17 @@ function ConnectedSlidesTab({
|
|
|
194
219
|
SlidesEditor,
|
|
195
220
|
{
|
|
196
221
|
...controller.editor,
|
|
197
|
-
|
|
198
|
-
controller.editor.
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
|
|
222
|
+
menuItems: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
223
|
+
controller.editor.menuItems,
|
|
224
|
+
/* @__PURE__ */ jsxs(
|
|
225
|
+
DropdownMenuItem,
|
|
201
226
|
{
|
|
202
|
-
|
|
203
|
-
size: "icon",
|
|
204
|
-
variant: "ghost",
|
|
205
|
-
className: "size-8 text-muted-foreground hover:text-foreground pointer-coarse:size-11",
|
|
206
|
-
title: "Edit in its own window, beside the documents you clip from",
|
|
207
|
-
"aria-label": "Pop out",
|
|
208
|
-
onClick: () => openPresentation(session, { windows, title: popoutTitle("Presentation") }),
|
|
227
|
+
onSelect: () => openPresentation(session, { windows, title: popoutTitle("Presentation") }),
|
|
209
228
|
"data-testid": "presentation-pop-out",
|
|
210
|
-
children:
|
|
229
|
+
children: [
|
|
230
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "size-4" }),
|
|
231
|
+
/* @__PURE__ */ jsx("span", { className: "ml-2", children: "Edit in its own window" })
|
|
232
|
+
]
|
|
211
233
|
}
|
|
212
234
|
)
|
|
213
235
|
] }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/presentation/ConnectedSlidesTab.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * A presentation's slides tab in the document viewer: the slides editor, on the presentation the\n * viewer shows. Opening a saved presentation loads it (unless it is the one being edited); a new\n * one (a presentation draft) takes the clips gathered so far. Clips gathered with no presentation\n * open join the one opened next. Saving a draft makes it a document, and the tab moves to it.\n *\n * The editor can also move to the presentation's own window (Pop out), beside the documents its\n * clips come from; the tab then says so. Present opens that window with the slides alone.\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { ExternalLink, Loader2, PanelLeftClose, Presentation } from 'lucide-react'\nimport {\n isPanelOpen,\n registerDocumentTurnFlush,\n useArbiSessionState,\n useArbiSessionStore,\n} from '@arbidocs/react'\nimport { Button } from '@arbidocs/react/ui'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { usePanelHostSupport } from '../../shell/panel-host'\nimport {\n PRESENTATION_PANEL,\n openPresentation,\n presentationWindowOnlyPresents,\n} from '../../presentation/panel-id'\nimport { SlidesEditor } from '../../presentation/SlidesEditor'\nimport { hasUnsavedChanges, usePresentation } from '../../presentation/store'\nimport { EmptyState } from '../../components/EmptyState'\nimport { editPresentation } from './requests'\nimport { usePresentationController } from './usePresentationController'\nimport { usePresentationFiles } from './usePresentationFiles'\n\nexport interface ConnectedSlidesTabProps {\n /** The viewed document's id, or a presentation draft's (`draft-\u2026`). */\n documentId: string\n /** The version on screen, when an older one. */\n version?: number\n /** The document's current version: a newer one than the one being edited is opened. */\n currentVersion?: number\n /** A new presentation, not saved yet: its draft title. */\n draftTitle?: string\n}\n\n/** \"2, 3 and 5\". */\nconst listOf = (numbers: number[]) =>\n numbers.length < 2\n ? String(numbers[0] ?? '')\n : `${numbers.slice(0, -1).join(', ')} and ${numbers[numbers.length - 1]}`\n\nconst STALE = 'This presentation was changed outside the editor: Save to draw its slides again.'\n\n/** The presentation has anything in it worth asking about before it is replaced. */\nconst hasContent = () => hasUnsavedChanges(usePresentation.getState())\n\nexport function ConnectedSlidesTab({\n documentId,\n version,\n currentVersion,\n draftTitle,\n}: ConnectedSlidesTabProps) {\n const session = useArbiSessionStore()\n const { windows, popoutTitle } = usePanelHostSupport()\n const { confirm } = useBlocksEnvironment()\n const { open, save } = usePresentationFiles()\n const notify = usePresentation((s) => s.notify)\n const boundTo = usePresentation((s) => s.boundTo)\n const savedId = usePresentation((s) => s.savedId)\n const [loading, setLoading] = useState(false)\n const isDraft = draftTitle !== undefined\n const target = version ? `${documentId}@v${version}` : documentId\n const poppedOut = useArbiSessionState(\n (state) => isPanelOpen(state, PRESENTATION_PANEL) && !presentationWindowOnlyPresents()\n )\n const controller = usePresentationController(!poppedOut)\n const asked = useRef<string | null>(null)\n // Another presentation, with changes, is being edited and the user kept it.\n const [declined, setDeclined] = useState(false)\n const [force, setForce] = useState(0)\n\n // Show the presentation this tab is for (once per presentation: a remount does not ask again).\n useEffect(() => {\n const state = usePresentation.getState()\n if (state.boundTo === target || asked.current === `${target}#${force}`) return\n asked.current = `${target}#${force}`\n setDeclined(false)\n void (async () => {\n // Clips gathered with no presentation open join this one.\n const gathered = state.boundTo === null ? state.clips : []\n if (state.boundTo !== null && hasContent() && !force) {\n const ok = await confirm({\n title: 'Open presentation',\n message: 'Replace the presentation being edited? Save it first to keep its changes.',\n kind: 'confirm',\n })\n if (!ok) return setDeclined(true)\n }\n if (isDraft) {\n if (state.boundTo !== null) state.reset()\n usePresentation.getState().bind(target)\n usePresentation.getState().setTitle(draftTitle || 'Untitled presentation')\n return\n }\n setLoading(true)\n try {\n const { missing, stale, imported, changedOutside } = await open(documentId, version)\n usePresentation.getState().bind(target)\n if (gathered.length) usePresentation.getState().adoptClips(gathered)\n if (stale) notify(STALE, 'error')\n if (imported) {\n notify(\n ['Opened from PowerPoint, ready to edit.', ...imported.notes].join(' \u00B7 '),\n 'success'\n )\n }\n if (changedOutside) {\n notify(\n `${changedOutside.length === 1 ? `Slide ${changedOutside[0]} was` : `Slides ${listOf(changedOutside)} were`} changed in PowerPoint: brought in as changed there.`,\n 'success'\n )\n }\n if (missing) {\n notify(\n `${missing} clip${missing === 1 ? '' : 's'} could not be opened (moved, deleted or not shared with you)`,\n 'error'\n )\n }\n } catch (error) {\n notify(\n error instanceof Error ? error.message : 'The presentation could not be opened',\n 'error'\n )\n } finally {\n setLoading(false)\n }\n })()\n // eslint-disable-next-line react-hooks/exhaustive-deps -- a draft's title changes as it is typed\n }, [target, documentId, version, isDraft, force, open, confirm, notify])\n\n // A draft's title is the presentation's.\n useEffect(() => {\n if (isDraft && boundTo === target && draftTitle) usePresentation.getState().setTitle(draftTitle)\n }, [isDraft, boundTo, target, draftTitle])\n\n // Saved as another document (a draft's first save, Save as, an older file saved as a\n // PowerPoint): the viewer follows it. Only once this tab's presentation was the one edited\n // (another, still bound as the tab opens, is not \"its\" save).\n const wasBound = useRef(false)\n useEffect(() => {\n if (boundTo === target) wasBound.current = true\n if (!wasBound.current || !savedId || boundTo !== savedId || savedId === target) return\n if (isDraft) session.clearDraftDocument(documentId)\n editPresentation(session, { kind: 'open', documentId: savedId })\n }, [isDraft, savedId, boundTo, target, documentId, session])\n\n // A newer version saved meanwhile (by ARBI, asked in the chat beside the deck, or by someone\n // else): shown at once, unless this one has changes of its own, which are never thrown away.\n const heldVersion = usePresentation((s) => (s.boundTo === target ? s.version : null))\n const toldNewer = useRef<number | null>(null)\n useEffect(() => {\n if (isDraft || version || !currentVersion || heldVersion === null) return\n if (currentVersion <= heldVersion || loading) return\n if (hasContent()) {\n if (toldNewer.current === currentVersion) return\n toldNewer.current = currentVersion\n notify(\n `A newer version (${currentVersion}) was saved while you edited. Save as\u2026 keeps yours; reopen the presentation to see it.`,\n 'error'\n )\n return\n }\n setLoading(true)\n void open(documentId)\n .then(() => {\n usePresentation.getState().bind(target)\n notify(`Updated to version ${currentVersion}.`, 'success')\n })\n .catch((error: unknown) =>\n notify(\n error instanceof Error ? error.message : 'The new version could not be opened',\n 'error'\n )\n )\n .finally(() => setLoading(false))\n }, [currentVersion, heldVersion, isDraft, version, loading, open, documentId, target, notify])\n\n // A chat turn about this presentation (the chat beside it) saves its unsaved changes first, so\n // ARBI works on the slides as they are on screen.\n useEffect(() => {\n if (isDraft || version || savedId !== documentId || boundTo !== target) return\n return registerDocumentTurnFlush(documentId, async () => {\n const state = usePresentation.getState()\n if (state.savedId === documentId && hasUnsavedChanges(state)) await save(state.title)\n })\n }, [isDraft, version, savedId, boundTo, documentId, target, save])\n\n const present = useCallback(() => {\n openPresentation(session, { present: true, windows, title: popoutTitle('Presentation') })\n usePresentation.getState().setPresenting(true)\n }, [session, windows, popoutTitle])\n\n if (poppedOut) {\n return (\n <div className=\"flex h-full items-center justify-center p-6\" data-testid=\"slides-popped-out\">\n <EmptyState\n icon={ExternalLink}\n title=\"Editing in its own window\"\n description=\"The presentation is open in its own window, beside the documents you clip from.\"\n action={\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => session.closePanel(PRESENTATION_PANEL)}\n >\n <PanelLeftClose className=\"size-4\" />\n Bring it back here\n </Button>\n }\n />\n </div>\n )\n }\n if (declined && boundTo !== target) {\n return (\n <div className=\"flex h-full items-center justify-center p-6\" data-testid=\"slides-declined\">\n <EmptyState\n icon={Presentation}\n title=\"Another presentation is being edited\"\n description=\"It has changes. Save it first, or open this one in its place.\"\n action={\n <Button type=\"button\" variant=\"outline\" onClick={() => setForce((n) => n + 1)}>\n Open this one instead\n </Button>\n }\n />\n </div>\n )\n }\n if (loading || boundTo !== target) {\n return (\n <div className=\"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground\">\n <Loader2 className=\"size-4 animate-spin\" />\n Opening the presentation\u2026\n </div>\n )\n }\n return (\n <>\n {controller.dialogs}\n <SlidesEditor\n {...controller.editor}\n actions={\n <>\n {controller.editor.actions}\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n className=\"size-8 text-muted-foreground hover:text-foreground pointer-coarse:size-11\"\n title=\"Edit in its own window, beside the documents you clip from\"\n aria-label=\"Pop out\"\n onClick={() =>\n openPresentation(session, { windows, title: popoutTitle('Presentation') })\n }\n data-testid=\"presentation-pop-out\"\n >\n <ExternalLink className=\"size-4\" />\n </Button>\n </>\n }\n onPresent={present}\n />\n </>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * A presentation's slides tab in the document viewer: the slides editor, on the presentation the\n * viewer shows. Opening a saved presentation loads it (unless it is the one being edited); a new\n * one (a presentation draft) takes the clips gathered so far. Clips gathered with no presentation\n * open join the one opened next. Saving a draft makes it a document, and the tab moves to it.\n *\n * The editor can also move to the presentation's own window (Pop out), beside the documents its\n * clips come from; the tab then says so. Present opens that window with the slides alone.\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { ExternalLink, Loader2, PanelLeftClose, Presentation } from 'lucide-react'\nimport {\n isPanelOpen,\n registerDocumentTurnFlush,\n useArbiSessionState,\n useArbiSessionStore,\n} from '@arbidocs/react'\nimport { Button, DropdownMenuItem } from '@arbidocs/react/ui'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { usePanelHostSupport } from '../../shell/panel-host'\nimport {\n PRESENTATION_PANEL,\n openPresentation,\n presentationWindowOnlyPresents,\n} from '../../presentation/panel-id'\nimport { SlidesEditor } from '../../presentation/SlidesEditor'\nimport { hasUnsavedChanges, usePresentation } from '../../presentation/store'\nimport { EmptyState } from '../../components/EmptyState'\nimport { editPresentation } from './requests'\nimport { usePresentationController } from './usePresentationController'\nimport { usePresentationFiles } from './usePresentationFiles'\n\nexport interface ConnectedSlidesTabProps {\n /** The viewed document's id, or a presentation draft's (`draft-\u2026`). */\n documentId: string\n /** The version on screen, when an older one. */\n version?: number\n /** The document's current version: a newer one than the one being edited is opened. */\n currentVersion?: number\n /** A new presentation, not saved yet: its draft title. */\n draftTitle?: string\n}\n\n/** \"2, 3 and 5\". */\nconst listOf = (numbers: number[]) =>\n numbers.length < 2\n ? String(numbers[0] ?? '')\n : `${numbers.slice(0, -1).join(', ')} and ${numbers[numbers.length - 1]}`\n\n/** A new presentation saves itself this long after its first content (typing settles first). */\nconst AUTO_SAVE_AFTER_MS = 2500\n/** The names a new presentation starts with (not chosen by anyone). */\nconst DEFAULT_NAMES = /^(new|untitled) presentation( \\d+)?$/i\n\nconst STALE = 'This presentation was changed outside the editor: Save to draw its slides again.'\n\n/** The presentation has anything in it worth asking about before it is replaced. */\nconst hasContent = () => hasUnsavedChanges(usePresentation.getState())\n\nexport function ConnectedSlidesTab({\n documentId,\n version,\n currentVersion,\n draftTitle,\n}: ConnectedSlidesTabProps) {\n const session = useArbiSessionStore()\n const { windows, popoutTitle } = usePanelHostSupport()\n const { confirm } = useBlocksEnvironment()\n const { open, save } = usePresentationFiles()\n const notify = usePresentation((s) => s.notify)\n const boundTo = usePresentation((s) => s.boundTo)\n const savedId = usePresentation((s) => s.savedId)\n const [loading, setLoading] = useState(false)\n const isDraft = draftTitle !== undefined\n const target = version ? `${documentId}@v${version}` : documentId\n const poppedOut = useArbiSessionState(\n (state) => isPanelOpen(state, PRESENTATION_PANEL) && !presentationWindowOnlyPresents()\n )\n const controller = usePresentationController(!poppedOut)\n const asked = useRef<string | null>(null)\n // Another presentation, with changes, is being edited and the user kept it.\n const [declined, setDeclined] = useState(false)\n const [force, setForce] = useState(0)\n\n // Show the presentation this tab is for (once per presentation: a remount does not ask again).\n useEffect(() => {\n const state = usePresentation.getState()\n if (state.boundTo === target || asked.current === `${target}#${force}`) return\n asked.current = `${target}#${force}`\n setDeclined(false)\n void (async () => {\n // Clips gathered with no presentation open join this one.\n const gathered = state.boundTo === null ? state.clips : []\n if (state.boundTo !== null && hasContent() && !force) {\n const ok = await confirm({\n title: 'Open presentation',\n message: 'Replace the presentation being edited? Save it first to keep its changes.',\n kind: 'confirm',\n })\n if (!ok) return setDeclined(true)\n }\n if (isDraft) {\n if (state.boundTo !== null) state.reset()\n usePresentation.getState().bind(target)\n usePresentation.getState().setTitle(draftTitle || 'Untitled presentation')\n return\n }\n setLoading(true)\n try {\n const { missing, stale, imported, changedOutside } = await open(documentId, version)\n usePresentation.getState().bind(target)\n if (gathered.length) usePresentation.getState().adoptClips(gathered)\n if (stale) notify(STALE, 'error')\n if (imported) {\n notify(\n ['Opened from PowerPoint, ready to edit.', ...imported.notes].join(' \u00B7 '),\n 'success'\n )\n }\n if (changedOutside) {\n notify(\n `${changedOutside.length === 1 ? `Slide ${changedOutside[0]} was` : `Slides ${listOf(changedOutside)} were`} changed in PowerPoint: brought in as changed there.`,\n 'success'\n )\n }\n if (missing) {\n notify(\n `${missing} clip${missing === 1 ? '' : 's'} could not be opened (moved, deleted or not shared with you)`,\n 'error'\n )\n }\n } catch (error) {\n notify(\n error instanceof Error ? error.message : 'The presentation could not be opened',\n 'error'\n )\n } finally {\n setLoading(false)\n }\n })()\n // eslint-disable-next-line react-hooks/exhaustive-deps -- a draft's title changes as it is typed\n }, [target, documentId, version, isDraft, force, open, confirm, notify])\n\n // A draft's title is the presentation's.\n useEffect(() => {\n if (isDraft && boundTo === target && draftTitle) usePresentation.getState().setTitle(draftTitle)\n }, [isDraft, boundTo, target, draftTitle])\n\n // Saved as another document (a draft's first save, Save as, an older file saved as a\n // PowerPoint): the viewer follows it. Only once this tab's presentation was the one edited\n // (another, still bound as the tab opens, is not \"its\" save).\n const wasBound = useRef(false)\n useEffect(() => {\n if (boundTo === target) wasBound.current = true\n if (!wasBound.current || !savedId || boundTo !== savedId || savedId === target) return\n if (isDraft) session.clearDraftDocument(documentId)\n editPresentation(session, { kind: 'open', documentId: savedId })\n }, [isDraft, savedId, boundTo, target, documentId, session])\n\n // A newer version saved meanwhile (by ARBI, asked in the chat beside the deck, or by someone\n // else): shown at once, unless this one has changes of its own, which are never thrown away.\n const heldVersion = usePresentation((s) => (s.boundTo === target ? s.version : null))\n const toldNewer = useRef<number | null>(null)\n useEffect(() => {\n if (isDraft || version || !currentVersion || heldVersion === null) return\n if (currentVersion <= heldVersion || loading) return\n if (hasContent()) {\n if (toldNewer.current === currentVersion) return\n toldNewer.current = currentVersion\n notify(\n `A newer version (${currentVersion}) was saved while you edited. Save as\u2026 keeps yours; reopen the presentation to see it.`,\n 'error'\n )\n return\n }\n setLoading(true)\n void open(documentId)\n .then(() => {\n usePresentation.getState().bind(target)\n notify(`Updated to version ${currentVersion}.`, 'success')\n })\n .catch((error: unknown) =>\n notify(\n error instanceof Error ? error.message : 'The new version could not be opened',\n 'error'\n )\n )\n .finally(() => setLoading(false))\n }, [currentVersion, heldVersion, isDraft, version, loading, open, documentId, target, notify])\n\n // A new presentation saves itself once it has something in it (a clip, a title, a point): from\n // then on it is a document of Presentations, which a chat can work in and look at (its PDF), and\n // which is not lost with the tab. Later saves stay the person's (each a version they chose).\n const draftHasContent = usePresentation(\n (state) =>\n isDraft && state.boundTo === target && state.savedId === null && hasUnsavedChanges(state)\n )\n const autoSaved = useRef<string | null>(null)\n useEffect(() => {\n if (!draftHasContent || autoSaved.current === target) return\n const timer = setTimeout(() => {\n autoSaved.current = target\n const state = usePresentation.getState()\n // Still called what every new one is called: named after its first slide's title instead.\n const firstTitle = state.slides.find((slide) => slide.caption.trim())?.caption.trim()\n const named = state.title && !DEFAULT_NAMES.test(state.title) ? state.title : null\n const title = named ?? firstTitle ?? (state.title || 'Untitled presentation')\n if (title !== state.title) state.setTitle(title)\n void save(title).catch((error: unknown) => {\n autoSaved.current = null\n notify(\n error instanceof Error ? error.message : 'The presentation could not be saved',\n 'error'\n )\n })\n }, AUTO_SAVE_AFTER_MS)\n return () => clearTimeout(timer)\n }, [draftHasContent, target, save, draftTitle, notify])\n\n // A chat turn about this presentation (the chat beside it) saves its unsaved changes first, so\n // ARBI works on the slides as they are on screen.\n useEffect(() => {\n if (isDraft || version || savedId !== documentId || boundTo !== target) return\n return registerDocumentTurnFlush(documentId, async () => {\n const state = usePresentation.getState()\n if (state.savedId === documentId && hasUnsavedChanges(state)) await save(state.title)\n })\n }, [isDraft, version, savedId, boundTo, documentId, target, save])\n\n const present = useCallback(() => {\n openPresentation(session, { present: true, windows, title: popoutTitle('Presentation') })\n usePresentation.getState().setPresenting(true)\n }, [session, windows, popoutTitle])\n\n if (poppedOut) {\n return (\n <div className=\"flex h-full items-center justify-center p-6\" data-testid=\"slides-popped-out\">\n <EmptyState\n icon={ExternalLink}\n title=\"Editing in its own window\"\n description=\"The presentation is open in its own window, beside the documents you clip from.\"\n action={\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => session.closePanel(PRESENTATION_PANEL)}\n >\n <PanelLeftClose className=\"size-4\" />\n Bring it back here\n </Button>\n }\n />\n </div>\n )\n }\n if (declined && boundTo !== target) {\n return (\n <div className=\"flex h-full items-center justify-center p-6\" data-testid=\"slides-declined\">\n <EmptyState\n icon={Presentation}\n title=\"Another presentation is being edited\"\n description=\"It has changes. Save it first, or open this one in its place.\"\n action={\n <Button type=\"button\" variant=\"outline\" onClick={() => setForce((n) => n + 1)}>\n Open this one instead\n </Button>\n }\n />\n </div>\n )\n }\n if (loading || boundTo !== target) {\n return (\n <div className=\"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground\">\n <Loader2 className=\"size-4 animate-spin\" />\n Opening the presentation\u2026\n </div>\n )\n }\n return (\n <>\n {controller.dialogs}\n <SlidesEditor\n {...controller.editor}\n menuItems={\n <>\n {controller.editor.menuItems}\n <DropdownMenuItem\n onSelect={() =>\n openPresentation(session, { windows, title: popoutTitle('Presentation') })\n }\n data-testid=\"presentation-pop-out\"\n >\n <ExternalLink className=\"size-4\" />\n <span className=\"ml-2\">Edit in its own window</span>\n </DropdownMenuItem>\n </>\n }\n onPresent={present}\n />\n </>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAmPY,SA2CF,UAtCI,KALF;AAzOZ,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AACzD,SAAS,cAAc,SAAS,gBAAgB,oBAAoB;AACpE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAQ,wBAAwB;AACzC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB,uBAAuB;AACnD,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AAcrC,MAAM,SAAS,CAAC,YACd,QAAQ,SAAS,IACb,OAAO,QAAQ,CAAC,KAAK,EAAE,IACvB,GAAG,QAAQ,MAAM,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,QAAQ,QAAQ,QAAQ,SAAS,CAAC,CAAC;AAG3E,MAAM,qBA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
|
@@ -4,10 +4,12 @@ import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react"
|
|
|
4
4
|
import {
|
|
5
5
|
ChevronDown,
|
|
6
6
|
Languages,
|
|
7
|
+
Link2,
|
|
7
8
|
Mail,
|
|
8
9
|
MessageSquare,
|
|
9
10
|
MessageSquarePlus,
|
|
10
11
|
PenLine,
|
|
12
|
+
Signature,
|
|
11
13
|
Users
|
|
12
14
|
} from "lucide-react";
|
|
13
15
|
import { useArbi, useArbiSessionState, useArbiSessionStore } from "@arbidocs/react";
|
|
@@ -86,6 +88,7 @@ import { FinaliseTranslationButton } from "./FinaliseTranslationButton.js";
|
|
|
86
88
|
import { useDocumentViewerSupport } from "./support.js";
|
|
87
89
|
import { useImageCrop } from "./useImageCrop.js";
|
|
88
90
|
import { ViewerCropModal } from "./ViewerCropModal.js";
|
|
91
|
+
import { ViewerMoreMenu } from "./ViewerMoreMenu.js";
|
|
89
92
|
import { useViewedDocument } from "./useViewedDocument.js";
|
|
90
93
|
import { useViewerBlobs } from "./useViewerBlobs.js";
|
|
91
94
|
import { useViewerTabs } from "./useViewerTabs.js";
|
|
@@ -512,28 +515,15 @@ function DocumentViewerContent({
|
|
|
512
515
|
]
|
|
513
516
|
}
|
|
514
517
|
),
|
|
515
|
-
documentId && documentData && !isDraft && !isStreaming && /* @__PURE__ */
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
children: "Share file"
|
|
525
|
-
}
|
|
526
|
-
),
|
|
527
|
-
/* @__PURE__ */ jsx(
|
|
528
|
-
FileShareDialog,
|
|
529
|
-
{
|
|
530
|
-
open: sharingFile,
|
|
531
|
-
onOpenChange: setSharingFile,
|
|
532
|
-
documentId,
|
|
533
|
-
version: pdfSnapshotNumber ?? documentData.current_version ?? 1
|
|
534
|
-
}
|
|
535
|
-
)
|
|
536
|
-
] }),
|
|
518
|
+
documentId && documentData && !isDraft && !isStreaming && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
519
|
+
FileShareDialog,
|
|
520
|
+
{
|
|
521
|
+
open: sharingFile,
|
|
522
|
+
onOpenChange: setSharingFile,
|
|
523
|
+
documentId,
|
|
524
|
+
version: pdfSnapshotNumber ?? documentData.current_version ?? 1
|
|
525
|
+
}
|
|
526
|
+
) }),
|
|
537
527
|
doc.savedDocumentId && !snapshotDocumentId && /* @__PURE__ */ jsxs(
|
|
538
528
|
Button,
|
|
539
529
|
{
|
|
@@ -571,43 +561,6 @@ function DocumentViewerContent({
|
|
|
571
561
|
stateTestId: "document-title-shared-indicator"
|
|
572
562
|
}
|
|
573
563
|
),
|
|
574
|
-
tools.emailDocument && !isDraft && !isStreaming && documentData?.file_name && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
575
|
-
/* @__PURE__ */ jsx("span", { className: "mx-1 h-5 w-px bg-border", "aria-hidden": "true" }),
|
|
576
|
-
/* @__PURE__ */ jsxs(
|
|
577
|
-
Button,
|
|
578
|
-
{
|
|
579
|
-
type: "button",
|
|
580
|
-
variant: "outline",
|
|
581
|
-
size: isCompact ? "icon" : "sm",
|
|
582
|
-
title: "Email this document",
|
|
583
|
-
"aria-label": "Email",
|
|
584
|
-
"data-testid": "email-document-button",
|
|
585
|
-
className: "pointer-coarse:min-h-11",
|
|
586
|
-
onClick: () => tools.emailDocument?.(shownRef),
|
|
587
|
-
children: [
|
|
588
|
-
/* @__PURE__ */ jsx(Mail, { className: "size-4" }),
|
|
589
|
-
!isCompact && /* @__PURE__ */ jsx("span", { className: "ml-1", children: "Email" })
|
|
590
|
-
]
|
|
591
|
-
}
|
|
592
|
-
)
|
|
593
|
-
] }),
|
|
594
|
-
support.translate && !isDraft && !isStreaming && !liveKind && !isImage && documentData?.file_name && /* @__PURE__ */ jsxs(
|
|
595
|
-
Button,
|
|
596
|
-
{
|
|
597
|
-
type: "button",
|
|
598
|
-
variant: "outline",
|
|
599
|
-
size: isCompact ? "icon" : "sm",
|
|
600
|
-
title: "Translate into another language: a new editable document, original and translation side by side",
|
|
601
|
-
"aria-label": "Translate",
|
|
602
|
-
"data-testid": "translate-document-button",
|
|
603
|
-
className: "pointer-coarse:min-h-11",
|
|
604
|
-
onClick: () => support.translate(shownRef),
|
|
605
|
-
children: [
|
|
606
|
-
/* @__PURE__ */ jsx(Languages, { className: "size-4" }),
|
|
607
|
-
!isCompact && /* @__PURE__ */ jsx("span", { className: "ml-1", children: "Translate" })
|
|
608
|
-
]
|
|
609
|
-
}
|
|
610
|
-
),
|
|
611
564
|
!isStreaming && !snapshotDocumentId && /* @__PURE__ */ jsx(FinaliseTranslationButton, { document: documentData ?? void 0, isCompact }),
|
|
612
565
|
annotatable && /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
613
566
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
@@ -621,7 +574,7 @@ function DocumentViewerContent({
|
|
|
621
574
|
"data-testid": "signing-menu-trigger",
|
|
622
575
|
className: "pointer-coarse:min-h-11",
|
|
623
576
|
children: [
|
|
624
|
-
/* @__PURE__ */ jsx(
|
|
577
|
+
/* @__PURE__ */ jsx(Signature, { className: "size-4" }),
|
|
625
578
|
!isCompact && /* @__PURE__ */ jsx("span", { className: "ml-1", children: "Sign" }),
|
|
626
579
|
/* @__PURE__ */ jsx(ChevronDown, { className: "ml-1 size-3" })
|
|
627
580
|
]
|
|
@@ -690,6 +643,44 @@ function DocumentViewerContent({
|
|
|
690
643
|
appearance: signAppearance
|
|
691
644
|
}
|
|
692
645
|
),
|
|
646
|
+
/* @__PURE__ */ jsx(
|
|
647
|
+
ViewerMoreMenu,
|
|
648
|
+
{
|
|
649
|
+
compact: isCompact,
|
|
650
|
+
items: [
|
|
651
|
+
...documentId && documentData && !isDraft && !isStreaming ? [
|
|
652
|
+
{
|
|
653
|
+
key: "share-file",
|
|
654
|
+
label: "Share file\u2026",
|
|
655
|
+
icon: /* @__PURE__ */ jsx(Link2, { className: "size-4" }),
|
|
656
|
+
description: "Send a link to this version of the file",
|
|
657
|
+
onSelect: () => setSharingFile(true),
|
|
658
|
+
testId: "share-file-button"
|
|
659
|
+
}
|
|
660
|
+
] : [],
|
|
661
|
+
...tools.emailDocument && !isDraft && !isStreaming && documentData?.file_name ? [
|
|
662
|
+
{
|
|
663
|
+
key: "email",
|
|
664
|
+
label: "Email\u2026",
|
|
665
|
+
icon: /* @__PURE__ */ jsx(Mail, { className: "size-4" }),
|
|
666
|
+
description: "Email this document (attached)",
|
|
667
|
+
onSelect: () => tools.emailDocument?.(shownRef),
|
|
668
|
+
testId: "email-document-button"
|
|
669
|
+
}
|
|
670
|
+
] : [],
|
|
671
|
+
...support.translate && !isDraft && !isStreaming && !liveKind && !isImage && documentData?.file_name ? [
|
|
672
|
+
{
|
|
673
|
+
key: "translate",
|
|
674
|
+
label: "Translate\u2026",
|
|
675
|
+
icon: /* @__PURE__ */ jsx(Languages, { className: "size-4" }),
|
|
676
|
+
description: "A new editable document, original and translation side by side",
|
|
677
|
+
onSelect: () => support.translate(shownRef),
|
|
678
|
+
testId: "translate-document-button"
|
|
679
|
+
}
|
|
680
|
+
] : []
|
|
681
|
+
]
|
|
682
|
+
}
|
|
683
|
+
),
|
|
693
684
|
headerActions
|
|
694
685
|
] });
|
|
695
686
|
const viewerProps = {
|