@arbidocs/blocks 0.4.96 → 0.4.98
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/agents/index.cjs +280 -280
- package/dist/agents/index.js +4 -4
- package/dist/{chunk-3WW32OUU.cjs → chunk-3US5OIDQ.cjs} +3 -3
- package/dist/{chunk-3WW32OUU.cjs.map → chunk-3US5OIDQ.cjs.map} +1 -1
- package/dist/{chunk-SJVUKXS6.js → chunk-5NQIBJPP.js} +5 -5
- package/dist/{chunk-SJVUKXS6.js.map → chunk-5NQIBJPP.js.map} +1 -1
- package/dist/{chunk-Y52CEKVD.js → chunk-6B2AWE3I.js} +3 -3
- package/dist/{chunk-Y52CEKVD.js.map → chunk-6B2AWE3I.js.map} +1 -1
- package/dist/chunk-D54JXTPG.cjs +164 -0
- package/dist/chunk-D54JXTPG.cjs.map +1 -0
- package/dist/{chunk-MROSCSPW.cjs → chunk-DDYXFALG.cjs} +43 -43
- package/dist/{chunk-MROSCSPW.cjs.map → chunk-DDYXFALG.cjs.map} +1 -1
- package/dist/{chunk-K27SDLLN.js → chunk-FIEAWH4K.js} +644 -116
- package/dist/chunk-FIEAWH4K.js.map +1 -0
- package/dist/{chunk-PSN4VWI7.cjs → chunk-LENXDIMY.cjs} +5 -5
- package/dist/{chunk-PSN4VWI7.cjs.map → chunk-LENXDIMY.cjs.map} +1 -1
- package/dist/{chunk-H4SVY5FH.js → chunk-LZ5AFAWC.js} +3 -3
- package/dist/{chunk-H4SVY5FH.js.map → chunk-LZ5AFAWC.js.map} +1 -1
- package/dist/{chunk-7RI3G5BO.cjs → chunk-MIMVRMKC.cjs} +647 -112
- package/dist/chunk-MIMVRMKC.cjs.map +1 -0
- package/dist/{chunk-SC33PQTQ.cjs → chunk-MUYZP5FB.cjs} +5 -5
- package/dist/{chunk-SC33PQTQ.cjs.map → chunk-MUYZP5FB.cjs.map} +1 -1
- package/dist/{chunk-SF4BDUZS.js → chunk-PGDL26TQ.js} +3 -3
- package/dist/{chunk-SF4BDUZS.js.map → chunk-PGDL26TQ.js.map} +1 -1
- package/dist/{chunk-CK6TU76J.cjs → chunk-VJO66VVF.cjs} +5 -5
- package/dist/{chunk-CK6TU76J.cjs.map → chunk-VJO66VVF.cjs.map} +1 -1
- package/dist/{chunk-JID3CZSY.js → chunk-Z3G65XHZ.js} +3 -3
- package/dist/{chunk-JID3CZSY.js.map → chunk-Z3G65XHZ.js.map} +1 -1
- package/dist/chunk-ZCOVDK2E.js +153 -0
- package/dist/chunk-ZCOVDK2E.js.map +1 -0
- package/dist/components/DetailPanel.d.ts +106 -0
- package/dist/connect/docx.cjs +6 -6
- package/dist/connect/docx.js +4 -4
- package/dist/connect/index.cjs +25 -25
- package/dist/connect/index.js +5 -5
- package/dist/databases/DatabaseRowDetail.d.ts +32 -0
- package/dist/databases/DatabaseTable.d.ts +3 -1
- package/dist/databases/DatabaseToolbar.d.ts +9 -1
- package/dist/databases/PickCellEditor.d.ts +8 -1
- package/dist/databases/SelectCellEditor.d.ts +6 -1
- package/dist/databases/column-types.d.ts +5 -0
- package/dist/databases/databaseColumns.d.ts +7 -0
- package/dist/databases/index.cjs +381 -11
- package/dist/databases/index.cjs.map +1 -1
- package/dist/databases/index.d.ts +7 -5
- package/dist/databases/index.js +379 -14
- package/dist/databases/index.js.map +1 -1
- package/dist/databases/linkCells.d.ts +4 -2
- package/dist/docx/NativeDocxEditor.d.ts +7 -0
- package/dist/docx/RibbonMenu.d.ts +17 -0
- package/dist/docx/StyleGallery.d.ts +9 -0
- package/dist/docx/WordReferences.d.ts +21 -0
- package/dist/docx/index.cjs +52 -24
- package/dist/docx/index.d.ts +2 -0
- package/dist/docx/index.js +3 -3
- package/dist/docx/template/HouseTemplate.d.ts +64 -0
- package/dist/docx/template/HouseTemplatePanel.d.ts +6 -0
- package/dist/docx/template/QuickParts.d.ts +7 -0
- package/dist/docx/wordStyles.d.ts +24 -0
- package/dist/files/index.cjs +308 -0
- package/dist/files/index.cjs.map +1 -1
- package/dist/files/index.js +298 -2
- package/dist/files/index.js.map +1 -1
- package/dist/files/views/gridViews.d.ts +80 -0
- package/dist/files/views/index.d.ts +2 -0
- package/dist/files/views/useGridViews.d.ts +38 -0
- package/dist/index.cjs +428 -428
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +87 -126
- package/dist/index.js.map +1 -1
- package/dist/tags/TagDetail.d.ts +1 -0
- package/dist/workflow-canvas/index.cjs +47 -47
- package/dist/workflow-canvas/index.js +4 -4
- package/package.json +4 -4
- package/src/docx/styles.css +193 -0
- package/dist/chunk-7RI3G5BO.cjs.map +0 -1
- package/dist/chunk-K27SDLLN.js.map +0 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { stylesXml, definitionBookmark, DEFINITION_BOOKMARK_PREFIX, compareTerms, groupDefinitions, definitionLabels, filterTermGroups, toDefinition, definitionIdOfBookmark, esc, parseDefinition, docxPackage, documentXml } from './chunk-D3QPYKZG.js';
|
|
3
|
-
import { filterMentionCandidates, MentionMenu, findMentionQuery, listOptionId, extractMentions } from './chunk-AA3PT6KR.js';
|
|
3
|
+
import { filterMentionCandidates, MentionMenu, findMentionQuery, listOptionId, extractMentions, useListKeyNav } from './chunk-AA3PT6KR.js';
|
|
4
4
|
import { unzipSync, strFromU8, strToU8, zipSync } from 'fflate';
|
|
5
5
|
import { collectReviewItems, revisionItemsOf } from '@docx-editor.dev/core/store';
|
|
6
6
|
import React3, { createContext, useContext, useState, useRef, useCallback, useEffect, useLayoutEffect, useMemo } from 'react';
|
|
7
|
-
import { useDocxEditor, ReviewRailContext, useEditorSnapshot, useChromeTranslate, DocxEditor, createFontSource } from '@docx-editor.dev/react';
|
|
7
|
+
import { useDocxEditor, ReviewRailContext, useEditorSnapshot, useChromeTranslate, DocxEditor, createFontSource, useParagraphStyle, useEditorCommand } from '@docx-editor.dev/react';
|
|
8
8
|
import { AiMarkdown, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Button, DialogFooter, cn, splitMarkdownBlocks } from '@arbidocs/react/ui';
|
|
9
|
-
import { MessageSquarePlus, MessageSquare, PencilLine, ChevronLeft, ChevronRight, X, ChevronUp, ChevronDown, CheckCheck, RotateCcw, CircleCheck, Trash2, Check, SendHorizontal, Type, Ellipsis, RefreshCw, WifiOff, Download, Save, BookA, ListRestart } from 'lucide-react';
|
|
9
|
+
import { MessageSquarePlus, MessageSquare, PencilLine, ChevronLeft, ChevronRight, X, ChevronUp, ChevronDown, CheckCheck, RotateCcw, CircleCheck, Trash2, Check, SendHorizontal, Type, Ellipsis, RefreshCw, WifiOff, Download, Save, BookA, ListRestart, Blocks, Superscript, NotebookText } from 'lucide-react';
|
|
10
10
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
|
+
import { defaultLegalTemplate, listBuildingBlocks, attachedTemplateOf, linkedLevelStyles, styleDivergence, buildingBlockFragment, fragmentClipboardHtml, newFromTemplate } from '@arbidocs/coedit/template';
|
|
12
13
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
13
14
|
import * as Y from 'yjs';
|
|
14
15
|
import { DOCUMENT_COLLABORATION_VERSIONS, collaborationModule } from '@arbidocs/coedit';
|
|
@@ -2122,6 +2123,130 @@ function DefinedTermHover({
|
|
|
2122
2123
|
document.body
|
|
2123
2124
|
);
|
|
2124
2125
|
}
|
|
2126
|
+
var BUILTIN_TEMPLATE_NAME = "ARBI legal template";
|
|
2127
|
+
var templateFileName = (t) => /\.(dotx|dotm|docx|docm)$/i.test(t.name) ? t.name : `${t.name}.dotx`;
|
|
2128
|
+
var builtin;
|
|
2129
|
+
function builtinHouseTemplate() {
|
|
2130
|
+
builtin ??= { bytes: defaultLegalTemplate(), name: BUILTIN_TEMPLATE_NAME, source: "builtin" };
|
|
2131
|
+
return builtin;
|
|
2132
|
+
}
|
|
2133
|
+
async function resolveHouseTemplate(host) {
|
|
2134
|
+
if (!host) return builtinHouseTemplate();
|
|
2135
|
+
try {
|
|
2136
|
+
return await host.load();
|
|
2137
|
+
} catch {
|
|
2138
|
+
return builtinHouseTemplate();
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
var HouseTemplateContext = createContext(null);
|
|
2142
|
+
var useHouseTemplate = () => useContext(HouseTemplateContext);
|
|
2143
|
+
function HouseTemplateProvider({
|
|
2144
|
+
host,
|
|
2145
|
+
documentId,
|
|
2146
|
+
editable,
|
|
2147
|
+
notify,
|
|
2148
|
+
enabled = true,
|
|
2149
|
+
children
|
|
2150
|
+
}) {
|
|
2151
|
+
const editor = useDocxEditor();
|
|
2152
|
+
const [template, setTemplate] = useState(builtinHouseTemplate);
|
|
2153
|
+
const [divergence, setDivergence] = useState(null);
|
|
2154
|
+
const [basedOnTemplate, setBasedOnTemplate] = useState(false);
|
|
2155
|
+
const [levels, setLevels] = useState({});
|
|
2156
|
+
const [generation, setGeneration] = useState(0);
|
|
2157
|
+
useEffect(() => {
|
|
2158
|
+
let live = true;
|
|
2159
|
+
void resolveHouseTemplate(host).then((t) => live && setTemplate(t));
|
|
2160
|
+
return () => {
|
|
2161
|
+
live = false;
|
|
2162
|
+
};
|
|
2163
|
+
}, [host]);
|
|
2164
|
+
const blocks = useMemo(() => {
|
|
2165
|
+
try {
|
|
2166
|
+
return listBuildingBlocks(template.bytes);
|
|
2167
|
+
} catch {
|
|
2168
|
+
return [];
|
|
2169
|
+
}
|
|
2170
|
+
}, [template]);
|
|
2171
|
+
useEffect(() => {
|
|
2172
|
+
if (!editor || !enabled) return;
|
|
2173
|
+
let live = true;
|
|
2174
|
+
void editor.save().then((saved) => {
|
|
2175
|
+
if (!live || !saved) return;
|
|
2176
|
+
const bytes = new Uint8Array(saved);
|
|
2177
|
+
setBasedOnTemplate(attachedTemplateOf(bytes) === templateFileName(template));
|
|
2178
|
+
setLevels(linkedLevelStyles(bytes));
|
|
2179
|
+
setDivergence(styleDivergence(bytes, template.bytes));
|
|
2180
|
+
}).catch(() => live && setDivergence(null));
|
|
2181
|
+
return () => {
|
|
2182
|
+
live = false;
|
|
2183
|
+
};
|
|
2184
|
+
}, [editor, template, generation, enabled]);
|
|
2185
|
+
const refresh = useCallback(() => setGeneration((g) => g + 1), []);
|
|
2186
|
+
const insertBlock = useCallback(
|
|
2187
|
+
(name) => {
|
|
2188
|
+
if (!editor || !editable) return false;
|
|
2189
|
+
const fragment = buildingBlockFragment(template.bytes, name);
|
|
2190
|
+
if (!fragment) return false;
|
|
2191
|
+
try {
|
|
2192
|
+
const result = withDirectEditing(
|
|
2193
|
+
editor,
|
|
2194
|
+
() => editor.exec({ type: "paste", text: "", html: fragmentClipboardHtml(fragment) })
|
|
2195
|
+
);
|
|
2196
|
+
if (!result.ok) throw new Error(result.reason ?? "The block could not be inserted here.");
|
|
2197
|
+
refresh();
|
|
2198
|
+
return true;
|
|
2199
|
+
} catch (failure) {
|
|
2200
|
+
notify?.(
|
|
2201
|
+
failure instanceof Error ? failure.message : "Could not insert the block.",
|
|
2202
|
+
"error"
|
|
2203
|
+
);
|
|
2204
|
+
return false;
|
|
2205
|
+
}
|
|
2206
|
+
},
|
|
2207
|
+
[editor, editable, template, notify, refresh]
|
|
2208
|
+
);
|
|
2209
|
+
const setAsHouseTemplate = useMemo(
|
|
2210
|
+
() => host?.setFromDocument && documentId ? async () => {
|
|
2211
|
+
try {
|
|
2212
|
+
await host.setFromDocument(documentId);
|
|
2213
|
+
setTemplate(await resolveHouseTemplate(host));
|
|
2214
|
+
notify?.("This document is now the house template for new documents.", "success");
|
|
2215
|
+
} catch (failure) {
|
|
2216
|
+
notify?.(
|
|
2217
|
+
failure instanceof Error ? failure.message : "Could not set the house template.",
|
|
2218
|
+
"error"
|
|
2219
|
+
);
|
|
2220
|
+
}
|
|
2221
|
+
} : void 0,
|
|
2222
|
+
[host, documentId, notify]
|
|
2223
|
+
);
|
|
2224
|
+
const value = useMemo(
|
|
2225
|
+
() => ({
|
|
2226
|
+
template,
|
|
2227
|
+
blocks,
|
|
2228
|
+
divergence,
|
|
2229
|
+
basedOnTemplate,
|
|
2230
|
+
levels,
|
|
2231
|
+
insertBlock,
|
|
2232
|
+
refresh,
|
|
2233
|
+
setAsHouseTemplate,
|
|
2234
|
+
editable
|
|
2235
|
+
}),
|
|
2236
|
+
[
|
|
2237
|
+
template,
|
|
2238
|
+
blocks,
|
|
2239
|
+
divergence,
|
|
2240
|
+
basedOnTemplate,
|
|
2241
|
+
levels,
|
|
2242
|
+
insertBlock,
|
|
2243
|
+
refresh,
|
|
2244
|
+
setAsHouseTemplate,
|
|
2245
|
+
editable
|
|
2246
|
+
]
|
|
2247
|
+
);
|
|
2248
|
+
return /* @__PURE__ */ jsx(HouseTemplateContext.Provider, { value: enabled ? value : null, children });
|
|
2249
|
+
}
|
|
2125
2250
|
function wordDraftHtml(markdown) {
|
|
2126
2251
|
const template = document.createElement("template");
|
|
2127
2252
|
template.innerHTML = renderToStaticMarkup(/* @__PURE__ */ jsx(AiMarkdown, { children: markdown }));
|
|
@@ -2209,57 +2334,13 @@ var WordDraftStream = class {
|
|
|
2209
2334
|
}
|
|
2210
2335
|
}
|
|
2211
2336
|
};
|
|
2212
|
-
function contentPath(documentId) {
|
|
2213
|
-
const match = /^(doc-[A-Za-z0-9]+)@v([1-9][0-9]*)$/.exec(documentId);
|
|
2214
|
-
return match ? `/${encodeURIComponent(match[1])}/content?version=${match[2]}` : `/${encodeURIComponent(documentId)}/content`;
|
|
2215
|
-
}
|
|
2216
|
-
var drafts = /* @__PURE__ */ new Map();
|
|
2217
|
-
var stateBytes = (room) => Y.encodeStateAsUpdate(room.ydoc);
|
|
2218
|
-
var encodeState = (room) => {
|
|
2219
|
-
let binary = "";
|
|
2220
|
-
for (const byte of stateBytes(room)) binary += String.fromCharCode(byte);
|
|
2221
|
-
return btoa(binary);
|
|
2222
|
-
};
|
|
2223
|
-
function covered(room, vector, receipt) {
|
|
2224
|
-
const decode = (value) => Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
|
|
2225
|
-
const server = Y.decodeStateVector(decode(vector)), local = Y.decodeStateVector(Y.encodeStateVector(room.ydoc));
|
|
2226
|
-
for (const [client, clock] of local) if ((server.get(client) || 0) < clock) return false;
|
|
2227
|
-
const deleted = Y.decodeUpdate(stateBytes(room)).ds.clients;
|
|
2228
|
-
const saved = Y.decodeUpdate(decode(receipt)).ds.clients;
|
|
2229
|
-
for (const [client, ranges] of deleted)
|
|
2230
|
-
for (const range of ranges) {
|
|
2231
|
-
if (!(saved.get(client) || []).some(
|
|
2232
|
-
(s) => s.clock <= range.clock && s.clock + s.len >= range.clock + range.len
|
|
2233
|
-
))
|
|
2234
|
-
return false;
|
|
2235
|
-
}
|
|
2236
|
-
return true;
|
|
2237
|
-
}
|
|
2238
|
-
var EditorBoundary = class extends React3.Component {
|
|
2239
|
-
state = {};
|
|
2240
|
-
static getDerivedStateFromError(error) {
|
|
2241
|
-
return { error };
|
|
2242
|
-
}
|
|
2243
|
-
render() {
|
|
2244
|
-
return this.state.error ? /* @__PURE__ */ jsxs("div", { role: "alert", className: "native-docx-error", children: [
|
|
2245
|
-
"Could not render this Word document: ",
|
|
2246
|
-
this.state.error.message
|
|
2247
|
-
] }) : this.props.children;
|
|
2248
|
-
}
|
|
2249
|
-
};
|
|
2250
|
-
function DocxParticipants({ session }) {
|
|
2251
|
-
const [people, setPeople] = useState([]);
|
|
2252
|
-
useEffect(() => {
|
|
2253
|
-
if (!session) return;
|
|
2254
|
-
setPeople(session.participants());
|
|
2255
|
-
return session.subscribeParticipants(setPeople);
|
|
2256
|
-
}, [session]);
|
|
2257
|
-
return /* @__PURE__ */ jsx("div", { className: "native-docx-presence", "aria-label": "People viewing this document", children: people.map((p) => /* @__PURE__ */ jsx("span", { className: "native-docx-avatar", title: p.name, children: p.name.split(" ").map((s) => s[0]).slice(0, 2).join("") }, p.actorId)) });
|
|
2258
|
-
}
|
|
2259
2337
|
function RibbonMenu({
|
|
2260
2338
|
label,
|
|
2261
2339
|
icon,
|
|
2262
|
-
children
|
|
2340
|
+
children,
|
|
2341
|
+
className,
|
|
2342
|
+
testId,
|
|
2343
|
+
title
|
|
2263
2344
|
}) {
|
|
2264
2345
|
const [open, setOpen] = useState(false);
|
|
2265
2346
|
const element = useRef(null);
|
|
@@ -2283,10 +2364,11 @@ function RibbonMenu({
|
|
|
2283
2364
|
"button",
|
|
2284
2365
|
{
|
|
2285
2366
|
type: "button",
|
|
2286
|
-
className: "native-docx-ribbon-trigger",
|
|
2367
|
+
className: ["native-docx-ribbon-trigger", className].filter(Boolean).join(" "),
|
|
2287
2368
|
"aria-label": label,
|
|
2288
|
-
title: label,
|
|
2369
|
+
title: title ?? label,
|
|
2289
2370
|
"aria-expanded": open,
|
|
2371
|
+
"data-testid": testId,
|
|
2290
2372
|
onMouseDown: (event) => event.preventDefault(),
|
|
2291
2373
|
onClick: () => setOpen((value) => !value),
|
|
2292
2374
|
children: icon
|
|
@@ -2302,11 +2384,436 @@ function RibbonMenu({
|
|
|
2302
2384
|
if (!(event.target instanceof HTMLInputElement || event.target instanceof HTMLSelectElement))
|
|
2303
2385
|
event.preventDefault();
|
|
2304
2386
|
},
|
|
2305
|
-
children
|
|
2387
|
+
children: typeof children === "function" ? children(() => setOpen(false)) : children
|
|
2306
2388
|
}
|
|
2307
2389
|
)
|
|
2308
2390
|
] });
|
|
2309
2391
|
}
|
|
2392
|
+
|
|
2393
|
+
// src/docx/wordStyles.ts
|
|
2394
|
+
var QUICK_STYLES = ["Normal", "Title", "heading 1", "heading 2", "heading 3"];
|
|
2395
|
+
function findStyle(options, name) {
|
|
2396
|
+
const wanted = name.toLowerCase();
|
|
2397
|
+
const id = name.replace(/(^|\s)(\w)/g, (_, _s, c) => c.toUpperCase());
|
|
2398
|
+
return options.find((o) => o.name.toLowerCase() === wanted) ?? options.find((o) => o.styleId.toLowerCase() === id.toLowerCase());
|
|
2399
|
+
}
|
|
2400
|
+
function styleLabel(name) {
|
|
2401
|
+
return name === name.toLowerCase() ? name.replace(/(^|\s)(\w)/g, (m) => m.toUpperCase()) : name;
|
|
2402
|
+
}
|
|
2403
|
+
function wordShortcut(event) {
|
|
2404
|
+
const mod = event.ctrlKey || event.metaKey;
|
|
2405
|
+
if (!mod) return null;
|
|
2406
|
+
if (event.altKey && !event.shiftKey) {
|
|
2407
|
+
switch (event.code) {
|
|
2408
|
+
case "KeyF":
|
|
2409
|
+
return "footnote";
|
|
2410
|
+
case "KeyD":
|
|
2411
|
+
return "endnote";
|
|
2412
|
+
case "Digit1":
|
|
2413
|
+
case "Numpad1":
|
|
2414
|
+
return "heading 1";
|
|
2415
|
+
case "Digit2":
|
|
2416
|
+
case "Numpad2":
|
|
2417
|
+
return "heading 2";
|
|
2418
|
+
case "Digit3":
|
|
2419
|
+
case "Numpad3":
|
|
2420
|
+
return "heading 3";
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
if (event.shiftKey && !event.altKey && event.code === "KeyN") return "Normal";
|
|
2424
|
+
return null;
|
|
2425
|
+
}
|
|
2426
|
+
function divergenceSummary(divergence) {
|
|
2427
|
+
if (!divergence) return null;
|
|
2428
|
+
const changed = divergence.styles.filter((s) => s.kind === "changed").map((s) => styleLabel(s.name));
|
|
2429
|
+
const missing = divergence.styles.filter((s) => s.kind === "missing").map((s) => styleLabel(s.name));
|
|
2430
|
+
const parts = [
|
|
2431
|
+
divergence.docDefaults ? "default text formatting" : "",
|
|
2432
|
+
changed.length ? `${changed.length === 1 ? "style" : "styles"} ${changed.slice(0, 6).join(", ")}${changed.length > 6 ? "\u2026" : ""}` : "",
|
|
2433
|
+
missing.length ? `${missing.length} house ${missing.length === 1 ? "style" : "styles"} missing` : ""
|
|
2434
|
+
].filter(Boolean);
|
|
2435
|
+
return parts.length ? `Differs from the house template: ${parts.join("; ")}.` : null;
|
|
2436
|
+
}
|
|
2437
|
+
var FILTER_FROM = 8;
|
|
2438
|
+
function previewStyle(option) {
|
|
2439
|
+
const { fontFamily, fontSizePt, bold, italic, color } = option.preview;
|
|
2440
|
+
return {
|
|
2441
|
+
fontFamily: fontFamily ? `"${fontFamily}", serif` : void 0,
|
|
2442
|
+
// In the face of the style, but within a row: 9-18pt.
|
|
2443
|
+
fontSize: fontSizePt ? `${Math.min(18, Math.max(9, fontSizePt))}pt` : void 0,
|
|
2444
|
+
fontWeight: bold ? 700 : void 0,
|
|
2445
|
+
fontStyle: italic ? "italic" : void 0,
|
|
2446
|
+
color: color ? `#${color}` : void 0
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2449
|
+
function Gallery({ close }) {
|
|
2450
|
+
const { value, setValue, options, isEnabled } = useParagraphStyle();
|
|
2451
|
+
const editor = useDocxEditor();
|
|
2452
|
+
const house = useHouseTemplate();
|
|
2453
|
+
const changed = new Set(
|
|
2454
|
+
house?.basedOnTemplate ? house.divergence?.styles.filter((s) => s.kind === "changed").map((s) => s.styleId) : []
|
|
2455
|
+
);
|
|
2456
|
+
const [query, setQuery] = useState("");
|
|
2457
|
+
const quick = useMemo(
|
|
2458
|
+
() => QUICK_STYLES.map((name) => findStyle(options, name)).filter(
|
|
2459
|
+
(o) => !!o
|
|
2460
|
+
),
|
|
2461
|
+
[options]
|
|
2462
|
+
);
|
|
2463
|
+
const shown = useMemo(() => {
|
|
2464
|
+
const q = query.trim().toLowerCase();
|
|
2465
|
+
return q ? options.filter(
|
|
2466
|
+
(o) => o.name.toLowerCase().includes(q) || o.styleId.toLowerCase().includes(q)
|
|
2467
|
+
) : options;
|
|
2468
|
+
}, [options, query]);
|
|
2469
|
+
const apply = (option) => {
|
|
2470
|
+
setValue(option.styleId);
|
|
2471
|
+
close();
|
|
2472
|
+
editor?.surface?.focus();
|
|
2473
|
+
};
|
|
2474
|
+
const nav = useListKeyNav({
|
|
2475
|
+
open: true,
|
|
2476
|
+
items: shown,
|
|
2477
|
+
onPick: apply,
|
|
2478
|
+
onDismiss: close,
|
|
2479
|
+
resetKey: query
|
|
2480
|
+
});
|
|
2481
|
+
return /* @__PURE__ */ jsxs("div", { className: "native-docx-style-gallery", "data-testid": "docx-style-gallery", children: [
|
|
2482
|
+
quick.length > 0 && /* @__PURE__ */ jsx("div", { className: "native-docx-style-quick", role: "group", "aria-label": "Quick styles", children: quick.map((option) => /* @__PURE__ */ jsx(
|
|
2483
|
+
"button",
|
|
2484
|
+
{
|
|
2485
|
+
type: "button",
|
|
2486
|
+
"aria-pressed": value === option.styleId,
|
|
2487
|
+
disabled: !isEnabled,
|
|
2488
|
+
"data-style-id": option.styleId,
|
|
2489
|
+
title: styleLabel(option.name),
|
|
2490
|
+
onClick: () => apply(option),
|
|
2491
|
+
children: /* @__PURE__ */ jsx("span", { style: previewStyle(option), children: styleLabel(option.name) })
|
|
2492
|
+
},
|
|
2493
|
+
option.styleId
|
|
2494
|
+
)) }),
|
|
2495
|
+
options.length > FILTER_FROM && /* @__PURE__ */ jsx(
|
|
2496
|
+
"input",
|
|
2497
|
+
{
|
|
2498
|
+
className: "native-docx-style-filter",
|
|
2499
|
+
placeholder: "Find a style",
|
|
2500
|
+
"aria-label": "Find a style",
|
|
2501
|
+
value: query,
|
|
2502
|
+
autoFocus: true,
|
|
2503
|
+
onChange: (event) => setQuery(event.target.value),
|
|
2504
|
+
onKeyDown: (event) => {
|
|
2505
|
+
nav.handleKeyDown(event);
|
|
2506
|
+
},
|
|
2507
|
+
...nav.comboboxProps
|
|
2508
|
+
}
|
|
2509
|
+
),
|
|
2510
|
+
/* @__PURE__ */ jsxs(
|
|
2511
|
+
"ul",
|
|
2512
|
+
{
|
|
2513
|
+
className: "native-docx-style-list",
|
|
2514
|
+
role: "listbox",
|
|
2515
|
+
id: nav.listboxId,
|
|
2516
|
+
"aria-label": "Document styles",
|
|
2517
|
+
children: [
|
|
2518
|
+
shown.map((option, index) => /* @__PURE__ */ jsxs(
|
|
2519
|
+
"li",
|
|
2520
|
+
{
|
|
2521
|
+
id: listOptionId(nav.listboxId, index),
|
|
2522
|
+
role: "option",
|
|
2523
|
+
"aria-selected": value === option.styleId,
|
|
2524
|
+
"aria-disabled": !isEnabled,
|
|
2525
|
+
"data-active": index === nav.selectedIndex || void 0,
|
|
2526
|
+
"data-style-id": option.styleId,
|
|
2527
|
+
onMouseEnter: () => nav.setSelectedIndex(index),
|
|
2528
|
+
onClick: () => isEnabled && apply(option),
|
|
2529
|
+
children: [
|
|
2530
|
+
/* @__PURE__ */ jsx("span", { style: previewStyle(option), children: styleLabel(option.name) }),
|
|
2531
|
+
changed.has(option.styleId) && /* @__PURE__ */ jsx(
|
|
2532
|
+
"span",
|
|
2533
|
+
{
|
|
2534
|
+
className: "native-docx-style-diverged",
|
|
2535
|
+
title: "Defined differently from the house template",
|
|
2536
|
+
"aria-label": "Defined differently from the house template"
|
|
2537
|
+
}
|
|
2538
|
+
)
|
|
2539
|
+
]
|
|
2540
|
+
},
|
|
2541
|
+
option.styleId
|
|
2542
|
+
)),
|
|
2543
|
+
shown.length === 0 && /* @__PURE__ */ jsx("li", { className: "native-docx-style-empty", children: "No matching style" })
|
|
2544
|
+
]
|
|
2545
|
+
}
|
|
2546
|
+
)
|
|
2547
|
+
] });
|
|
2548
|
+
}
|
|
2549
|
+
function StyleGallery() {
|
|
2550
|
+
const { value, options } = useParagraphStyle();
|
|
2551
|
+
const current = options.find((o) => o.styleId === value);
|
|
2552
|
+
const name = current ? styleLabel(current.name) : "Styles";
|
|
2553
|
+
const house = useHouseTemplate();
|
|
2554
|
+
const diverged = house?.basedOnTemplate ? divergenceSummary(house.divergence) : null;
|
|
2555
|
+
return /* @__PURE__ */ jsx(
|
|
2556
|
+
RibbonMenu,
|
|
2557
|
+
{
|
|
2558
|
+
label: "Styles",
|
|
2559
|
+
title: diverged ? `Styles. ${diverged}` : void 0,
|
|
2560
|
+
className: "native-docx-style-trigger",
|
|
2561
|
+
testId: "docx-style-trigger",
|
|
2562
|
+
icon: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2563
|
+
/* @__PURE__ */ jsx("span", { className: "native-docx-style-current", "data-testid": "docx-current-style", children: name }),
|
|
2564
|
+
diverged && /* @__PURE__ */ jsx(
|
|
2565
|
+
"span",
|
|
2566
|
+
{
|
|
2567
|
+
className: "native-docx-style-diverged",
|
|
2568
|
+
"data-testid": "docx-style-diverged",
|
|
2569
|
+
"aria-label": diverged
|
|
2570
|
+
}
|
|
2571
|
+
),
|
|
2572
|
+
/* @__PURE__ */ jsx(ChevronDown, { size: 12, "aria-hidden": true })
|
|
2573
|
+
] }),
|
|
2574
|
+
children: (close) => /* @__PURE__ */ jsx(Gallery, { close })
|
|
2575
|
+
}
|
|
2576
|
+
);
|
|
2577
|
+
}
|
|
2578
|
+
function useInsertNote(kind) {
|
|
2579
|
+
const command = useEditorCommand(kind === "footnote" ? "insert.footnote" : "insert.endnote");
|
|
2580
|
+
const { options } = useParagraphStyle();
|
|
2581
|
+
const editor = useDocxEditor();
|
|
2582
|
+
const insert = () => {
|
|
2583
|
+
if (!command.execute()) return false;
|
|
2584
|
+
const text = findStyle(options, `${kind} text`);
|
|
2585
|
+
if (text && editor)
|
|
2586
|
+
withDirectEditing(
|
|
2587
|
+
editor,
|
|
2588
|
+
() => editor.exec({ type: "setParagraphStyle", styleId: text.styleId })
|
|
2589
|
+
);
|
|
2590
|
+
return true;
|
|
2591
|
+
};
|
|
2592
|
+
return { insert, isEnabled: command.isEnabled, disabledReason: command.disabledReason };
|
|
2593
|
+
}
|
|
2594
|
+
function NoteAction({
|
|
2595
|
+
kind,
|
|
2596
|
+
label,
|
|
2597
|
+
shortcut,
|
|
2598
|
+
icon
|
|
2599
|
+
}) {
|
|
2600
|
+
const note = useInsertNote(kind);
|
|
2601
|
+
return /* @__PURE__ */ jsx(
|
|
2602
|
+
DocxEditor.Toolbar.Action,
|
|
2603
|
+
{
|
|
2604
|
+
label: `${label} (${shortcut})`,
|
|
2605
|
+
icon,
|
|
2606
|
+
disabled: !note.isEnabled,
|
|
2607
|
+
disabledReason: note.disabledReason ?? void 0,
|
|
2608
|
+
onSelect: () => void note.insert(),
|
|
2609
|
+
className: `native-docx-insert-${kind}`
|
|
2610
|
+
}
|
|
2611
|
+
);
|
|
2612
|
+
}
|
|
2613
|
+
function NoteButtons() {
|
|
2614
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2615
|
+
/* @__PURE__ */ jsx(
|
|
2616
|
+
NoteAction,
|
|
2617
|
+
{
|
|
2618
|
+
kind: "footnote",
|
|
2619
|
+
label: "Insert footnote",
|
|
2620
|
+
shortcut: "Ctrl+Alt+F",
|
|
2621
|
+
icon: /* @__PURE__ */ jsx(Superscript, { size: 16 })
|
|
2622
|
+
}
|
|
2623
|
+
),
|
|
2624
|
+
/* @__PURE__ */ jsx(
|
|
2625
|
+
NoteAction,
|
|
2626
|
+
{
|
|
2627
|
+
kind: "endnote",
|
|
2628
|
+
label: "Insert endnote",
|
|
2629
|
+
shortcut: "Ctrl+Alt+D",
|
|
2630
|
+
icon: /* @__PURE__ */ jsx(NotebookText, { size: 16 })
|
|
2631
|
+
}
|
|
2632
|
+
)
|
|
2633
|
+
] });
|
|
2634
|
+
}
|
|
2635
|
+
function WordShortcuts({ scope }) {
|
|
2636
|
+
const footnote = useInsertNote("footnote");
|
|
2637
|
+
const endnote = useInsertNote("endnote");
|
|
2638
|
+
const styles = useParagraphStyle();
|
|
2639
|
+
const editor = useDocxEditor();
|
|
2640
|
+
const levels = useHouseTemplate()?.levels;
|
|
2641
|
+
const latest = useRef({ footnote, endnote, styles, editor, levels });
|
|
2642
|
+
latest.current = { footnote, endnote, styles, editor, levels };
|
|
2643
|
+
useEffect(() => {
|
|
2644
|
+
const element = scope.current;
|
|
2645
|
+
if (!element) return;
|
|
2646
|
+
const onKeyDown = (event) => {
|
|
2647
|
+
if (outlineTab(event)) {
|
|
2648
|
+
event.preventDefault();
|
|
2649
|
+
event.stopPropagation();
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
const action = wordShortcut(event);
|
|
2653
|
+
if (!action) return;
|
|
2654
|
+
const { footnote: footnote2, endnote: endnote2, styles: styles2, editor: editor2 } = latest.current;
|
|
2655
|
+
if (action === "footnote" || action === "endnote") {
|
|
2656
|
+
if (!(action === "footnote" ? footnote2 : endnote2).insert()) return;
|
|
2657
|
+
} else {
|
|
2658
|
+
const style = findStyle(styles2.options, action);
|
|
2659
|
+
if (!style) return;
|
|
2660
|
+
styles2.setValue(style.styleId);
|
|
2661
|
+
}
|
|
2662
|
+
event.preventDefault();
|
|
2663
|
+
event.stopPropagation();
|
|
2664
|
+
editor2?.surface?.focus();
|
|
2665
|
+
};
|
|
2666
|
+
const outlineTab = (event) => {
|
|
2667
|
+
if (event.key !== "Tab" || event.ctrlKey || event.metaKey || event.altKey) return false;
|
|
2668
|
+
const { editor: editor2, levels: levels2, styles: styles2 } = latest.current;
|
|
2669
|
+
const current = editor2?.getSelectionFormatting()?.styleId;
|
|
2670
|
+
const link = current ? levels2?.[current] : void 0;
|
|
2671
|
+
const target = event.shiftKey ? link?.previous : link?.next;
|
|
2672
|
+
if (!target || !editor2 || editorPort(editor2).caret()?.offset !== 0) return false;
|
|
2673
|
+
styles2.setValue(target);
|
|
2674
|
+
return true;
|
|
2675
|
+
};
|
|
2676
|
+
element.addEventListener("keydown", onKeyDown, true);
|
|
2677
|
+
return () => element.removeEventListener("keydown", onKeyDown, true);
|
|
2678
|
+
}, [scope]);
|
|
2679
|
+
return null;
|
|
2680
|
+
}
|
|
2681
|
+
function QuickParts() {
|
|
2682
|
+
const house = useHouseTemplate();
|
|
2683
|
+
if (!house || house.blocks.length === 0) return null;
|
|
2684
|
+
const categories = [...new Set(house.blocks.map((b) => b.category))];
|
|
2685
|
+
return /* @__PURE__ */ jsx(RibbonMenu, { label: "Quick Parts", icon: /* @__PURE__ */ jsx(Blocks, { size: 16 }), testId: "docx-quick-parts", children: (close) => /* @__PURE__ */ jsxs("div", { className: "native-docx-quick-parts", "data-testid": "docx-quick-parts-panel", children: [
|
|
2686
|
+
categories.map((category) => /* @__PURE__ */ jsxs("section", { "aria-label": category, children: [
|
|
2687
|
+
/* @__PURE__ */ jsx("h3", { children: category }),
|
|
2688
|
+
/* @__PURE__ */ jsx("ul", { children: house.blocks.filter((b) => b.category === category).map((block) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
2689
|
+
"button",
|
|
2690
|
+
{
|
|
2691
|
+
type: "button",
|
|
2692
|
+
disabled: !house.editable,
|
|
2693
|
+
title: block.description || block.name,
|
|
2694
|
+
onClick: () => {
|
|
2695
|
+
close();
|
|
2696
|
+
house.insertBlock(block.name);
|
|
2697
|
+
},
|
|
2698
|
+
children: [
|
|
2699
|
+
/* @__PURE__ */ jsx("span", { className: "native-docx-quick-part-name", children: block.name }),
|
|
2700
|
+
/* @__PURE__ */ jsx("span", { className: "native-docx-quick-part-preview", children: block.text })
|
|
2701
|
+
]
|
|
2702
|
+
}
|
|
2703
|
+
) }, block.name)) })
|
|
2704
|
+
] }, category)),
|
|
2705
|
+
/* @__PURE__ */ jsxs("p", { className: "native-docx-quick-parts-source", children: [
|
|
2706
|
+
"From ",
|
|
2707
|
+
house.template.name
|
|
2708
|
+
] })
|
|
2709
|
+
] }) });
|
|
2710
|
+
}
|
|
2711
|
+
var SOURCE = {
|
|
2712
|
+
workspace: "This workspace's house template",
|
|
2713
|
+
deployment: "The house template for all workspaces",
|
|
2714
|
+
builtin: "ARBI\u2019s built-in template (no house template has been set)"
|
|
2715
|
+
};
|
|
2716
|
+
function download(bytes, name) {
|
|
2717
|
+
const isTemplate = !/\.docx$/i.test(name);
|
|
2718
|
+
const url = URL.createObjectURL(
|
|
2719
|
+
new Blob([bytes], {
|
|
2720
|
+
type: isTemplate ? "application/vnd.openxmlformats-officedocument.wordprocessingml.template" : "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
2721
|
+
})
|
|
2722
|
+
);
|
|
2723
|
+
const a = document.createElement("a");
|
|
2724
|
+
a.href = url;
|
|
2725
|
+
a.download = /\.(dotx|docx)$/i.test(name) ? name : `${name}.dotx`;
|
|
2726
|
+
a.click();
|
|
2727
|
+
setTimeout(() => URL.revokeObjectURL(url), 5e3);
|
|
2728
|
+
}
|
|
2729
|
+
function HouseTemplatePanel() {
|
|
2730
|
+
const house = useHouseTemplate();
|
|
2731
|
+
if (!house) return null;
|
|
2732
|
+
const summary = divergenceSummary(house.divergence);
|
|
2733
|
+
return /* @__PURE__ */ jsx(
|
|
2734
|
+
RibbonMenu,
|
|
2735
|
+
{
|
|
2736
|
+
label: "House template",
|
|
2737
|
+
className: "native-docx-style-trigger",
|
|
2738
|
+
testId: "docx-house-template",
|
|
2739
|
+
icon: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2740
|
+
/* @__PURE__ */ jsx("span", { className: "native-docx-style-current", children: "House template" }),
|
|
2741
|
+
/* @__PURE__ */ jsx(ChevronDown, { size: 12, "aria-hidden": true })
|
|
2742
|
+
] }),
|
|
2743
|
+
children: /* @__PURE__ */ jsxs("div", { className: "native-docx-house-template", "data-testid": "docx-house-template-panel", children: [
|
|
2744
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
2745
|
+
/* @__PURE__ */ jsx("strong", { children: house.template.name }),
|
|
2746
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
2747
|
+
SOURCE[house.template.source],
|
|
2748
|
+
". New documents start from it."
|
|
2749
|
+
] }),
|
|
2750
|
+
/* @__PURE__ */ jsx("p", { "data-testid": "docx-house-template-status", children: house.divergence === null ? "Comparing this document\u2019s styles\u2026" : !house.basedOnTemplate ? "This document was not started from the house template." : summary ?? "This document\u2019s styles match the house template." }),
|
|
2751
|
+
/* @__PURE__ */ jsxs("div", { className: "native-docx-house-template-actions", children: [
|
|
2752
|
+
/* @__PURE__ */ jsxs("button", { type: "button", onClick: () => download(house.template.bytes, house.template.name), children: [
|
|
2753
|
+
/* @__PURE__ */ jsx(Download, { size: 14 }),
|
|
2754
|
+
" Download template"
|
|
2755
|
+
] }),
|
|
2756
|
+
house.setAsHouseTemplate && /* @__PURE__ */ jsx(
|
|
2757
|
+
"button",
|
|
2758
|
+
{
|
|
2759
|
+
type: "button",
|
|
2760
|
+
"data-testid": "docx-set-house-template",
|
|
2761
|
+
onClick: () => void house.setAsHouseTemplate(),
|
|
2762
|
+
children: "Use this document as the house template"
|
|
2763
|
+
}
|
|
2764
|
+
)
|
|
2765
|
+
] })
|
|
2766
|
+
] })
|
|
2767
|
+
}
|
|
2768
|
+
);
|
|
2769
|
+
}
|
|
2770
|
+
function contentPath(documentId) {
|
|
2771
|
+
const match = /^(doc-[A-Za-z0-9]+)@v([1-9][0-9]*)$/.exec(documentId);
|
|
2772
|
+
return match ? `/${encodeURIComponent(match[1])}/content?version=${match[2]}` : `/${encodeURIComponent(documentId)}/content`;
|
|
2773
|
+
}
|
|
2774
|
+
var drafts = /* @__PURE__ */ new Map();
|
|
2775
|
+
var stateBytes = (room) => Y.encodeStateAsUpdate(room.ydoc);
|
|
2776
|
+
var encodeState = (room) => {
|
|
2777
|
+
let binary = "";
|
|
2778
|
+
for (const byte of stateBytes(room)) binary += String.fromCharCode(byte);
|
|
2779
|
+
return btoa(binary);
|
|
2780
|
+
};
|
|
2781
|
+
function covered(room, vector, receipt) {
|
|
2782
|
+
const decode = (value) => Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
|
|
2783
|
+
const server = Y.decodeStateVector(decode(vector)), local = Y.decodeStateVector(Y.encodeStateVector(room.ydoc));
|
|
2784
|
+
for (const [client, clock] of local) if ((server.get(client) || 0) < clock) return false;
|
|
2785
|
+
const deleted = Y.decodeUpdate(stateBytes(room)).ds.clients;
|
|
2786
|
+
const saved = Y.decodeUpdate(decode(receipt)).ds.clients;
|
|
2787
|
+
for (const [client, ranges] of deleted)
|
|
2788
|
+
for (const range of ranges) {
|
|
2789
|
+
if (!(saved.get(client) || []).some(
|
|
2790
|
+
(s) => s.clock <= range.clock && s.clock + s.len >= range.clock + range.len
|
|
2791
|
+
))
|
|
2792
|
+
return false;
|
|
2793
|
+
}
|
|
2794
|
+
return true;
|
|
2795
|
+
}
|
|
2796
|
+
var EditorBoundary = class extends React3.Component {
|
|
2797
|
+
state = {};
|
|
2798
|
+
static getDerivedStateFromError(error) {
|
|
2799
|
+
return { error };
|
|
2800
|
+
}
|
|
2801
|
+
render() {
|
|
2802
|
+
return this.state.error ? /* @__PURE__ */ jsxs("div", { role: "alert", className: "native-docx-error", children: [
|
|
2803
|
+
"Could not render this Word document: ",
|
|
2804
|
+
this.state.error.message
|
|
2805
|
+
] }) : this.props.children;
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
function DocxParticipants({ session }) {
|
|
2809
|
+
const [people, setPeople] = useState([]);
|
|
2810
|
+
useEffect(() => {
|
|
2811
|
+
if (!session) return;
|
|
2812
|
+
setPeople(session.participants());
|
|
2813
|
+
return session.subscribeParticipants(setPeople);
|
|
2814
|
+
}, [session]);
|
|
2815
|
+
return /* @__PURE__ */ jsx("div", { className: "native-docx-presence", "aria-label": "People viewing this document", children: people.map((p) => /* @__PURE__ */ jsx("span", { className: "native-docx-avatar", title: p.name, children: p.name.split(" ").map((s) => s[0]).slice(0, 2).join("") }, p.actorId)) });
|
|
2816
|
+
}
|
|
2310
2817
|
function DefinedTermButtons() {
|
|
2311
2818
|
const terms = useDefinedTerms();
|
|
2312
2819
|
if (!terms) return null;
|
|
@@ -2349,6 +2856,8 @@ function DocxRibbon({
|
|
|
2349
2856
|
/* @__PURE__ */ jsxs("select", { "aria-label": "Ribbon tab", value: tab, onChange: (event) => setTab(event.target.value), children: [
|
|
2350
2857
|
/* @__PURE__ */ jsx("option", { children: "Home" }),
|
|
2351
2858
|
/* @__PURE__ */ jsx("option", { children: "Insert" }),
|
|
2859
|
+
/* @__PURE__ */ jsx("option", { children: "Design" }),
|
|
2860
|
+
/* @__PURE__ */ jsx("option", { children: "References" }),
|
|
2352
2861
|
/* @__PURE__ */ jsx("option", { children: "Review" })
|
|
2353
2862
|
] }),
|
|
2354
2863
|
/* @__PURE__ */ jsxs(DocxEditor.Toolbar, { t, preset: false, onSave, children: [
|
|
@@ -2356,6 +2865,7 @@ function DocxRibbon({
|
|
|
2356
2865
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Redo, {}),
|
|
2357
2866
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Save, {}),
|
|
2358
2867
|
tab === "Home" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2868
|
+
/* @__PURE__ */ jsx(StyleGallery, {}),
|
|
2359
2869
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Bold, {}),
|
|
2360
2870
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Italic, {}),
|
|
2361
2871
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Underline, {}),
|
|
@@ -2366,7 +2876,6 @@ function DocxRibbon({
|
|
|
2366
2876
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Highlight, {})
|
|
2367
2877
|
] }),
|
|
2368
2878
|
/* @__PURE__ */ jsxs(RibbonMenu, { label: "More formatting", icon: /* @__PURE__ */ jsx(Ellipsis, { size: 16 }), children: [
|
|
2369
|
-
/* @__PURE__ */ jsx(DocxEditor.Toolbar.StylePicker, {}),
|
|
2370
2879
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Alignment, {}),
|
|
2371
2880
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.BulletList, {}),
|
|
2372
2881
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.NumberedList, {}),
|
|
@@ -2381,8 +2890,11 @@ function DocxRibbon({
|
|
|
2381
2890
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.TableInsert, {}),
|
|
2382
2891
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.ImageInsert, {}),
|
|
2383
2892
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Link, {}),
|
|
2384
|
-
/* @__PURE__ */ jsx(DefinedTermButtons, {})
|
|
2893
|
+
/* @__PURE__ */ jsx(DefinedTermButtons, {}),
|
|
2894
|
+
/* @__PURE__ */ jsx(QuickParts, {})
|
|
2385
2895
|
] }),
|
|
2896
|
+
tab === "Design" && /* @__PURE__ */ jsx(HouseTemplatePanel, {}),
|
|
2897
|
+
tab === "References" && /* @__PURE__ */ jsx(NoteButtons, {}),
|
|
2386
2898
|
tab === "Review" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2387
2899
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.EditingMode, {}),
|
|
2388
2900
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Comments, {}),
|
|
@@ -2456,11 +2968,16 @@ function NativeDocxEditor({
|
|
|
2456
2968
|
async function start() {
|
|
2457
2969
|
const fonts = await adapter.loadFonts();
|
|
2458
2970
|
if (isDraft || snapshot) {
|
|
2459
|
-
const data = isDraft ? !streamRef.current && drafts.get(documentId) ||
|
|
2971
|
+
const data = isDraft ? !streamRef.current && drafts.get(documentId) || (draftContent === "" && adapter.houseTemplate ? await (async () => {
|
|
2972
|
+
const template = await resolveHouseTemplate(adapter.houseTemplate);
|
|
2973
|
+
return newFromTemplate(template.bytes, {
|
|
2974
|
+
attachedTemplate: templateFileName(template)
|
|
2975
|
+
});
|
|
2976
|
+
})() : await (await adapter.request("/prepare", {
|
|
2460
2977
|
method: "POST",
|
|
2461
2978
|
headers: { "Content-Type": "application/json" },
|
|
2462
2979
|
body: JSON.stringify({ content: draftContent })
|
|
2463
|
-
})).arrayBuffer() : await (await adapter.request(contentPath(documentId))).arrayBuffer();
|
|
2980
|
+
})).arrayBuffer()) : await (await adapter.request(contentPath(documentId))).arrayBuffer();
|
|
2464
2981
|
if (!cancelled) {
|
|
2465
2982
|
setReady({
|
|
2466
2983
|
document: new Uint8Array(data),
|
|
@@ -2722,67 +3239,78 @@ function NativeDocxEditor({
|
|
|
2722
3239
|
if (change.source !== "load") changed();
|
|
2723
3240
|
},
|
|
2724
3241
|
onFontError: (e) => setError(e.message),
|
|
2725
|
-
children: /* @__PURE__ */
|
|
3242
|
+
children: /* @__PURE__ */ jsx(
|
|
2726
3243
|
DefinedTermsProvider,
|
|
2727
3244
|
{
|
|
2728
3245
|
load: adapter.definitions,
|
|
2729
3246
|
editable: !stream && !snapshot && ready.canEdit,
|
|
2730
3247
|
notify: adapter.notify,
|
|
2731
|
-
children:
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
3248
|
+
children: /* @__PURE__ */ jsxs(
|
|
3249
|
+
HouseTemplateProvider,
|
|
3250
|
+
{
|
|
3251
|
+
enabled: !stream,
|
|
3252
|
+
host: adapter.houseTemplate,
|
|
3253
|
+
documentId: isDraft || snapshot ? void 0 : documentId,
|
|
3254
|
+
editable: !stream && !snapshot && ready.canEdit,
|
|
3255
|
+
notify: adapter.notify,
|
|
3256
|
+
children: [
|
|
3257
|
+
/* @__PURE__ */ jsx(
|
|
3258
|
+
DocxEditor.RevisionMarkup,
|
|
3259
|
+
{
|
|
3260
|
+
insertions: { mark: "underline", color: "blue" },
|
|
3261
|
+
deletions: { mark: "strikethrough", color: "red" },
|
|
3262
|
+
movedFrom: { mark: "doubleStrikethrough", color: "green" },
|
|
3263
|
+
movedTo: { mark: "doubleUnderline", color: "green" },
|
|
3264
|
+
trackMoves: true
|
|
3265
|
+
}
|
|
3266
|
+
),
|
|
3267
|
+
!stream && /* @__PURE__ */ jsx(
|
|
3268
|
+
DocxRibbon,
|
|
3269
|
+
{
|
|
3270
|
+
onSave: () => void saveVersion(),
|
|
3271
|
+
badge: (
|
|
3272
|
+
// Says the document is shared live, in place of a title row above the ribbon.
|
|
3273
|
+
ready.room && ready.canEdit && !snapshot ? /* @__PURE__ */ jsx("span", { title: "Edits sync live with everyone who has this document open", children: "Co-edit mode" }) : void 0
|
|
3274
|
+
)
|
|
3275
|
+
}
|
|
3276
|
+
),
|
|
3277
|
+
!stream && /* @__PURE__ */ jsx(WordShortcuts, { scope: stageRef }),
|
|
3278
|
+
/* @__PURE__ */ jsxs(
|
|
3279
|
+
"div",
|
|
3280
|
+
{
|
|
3281
|
+
className: "native-docx-stage",
|
|
3282
|
+
ref: stageRef,
|
|
3283
|
+
onMouseDownCapture: (event) => {
|
|
3284
|
+
if (event.button === 2 && ref.current?.getSelectionPlacement())
|
|
3285
|
+
event.preventDefault();
|
|
3286
|
+
},
|
|
3287
|
+
children: [
|
|
3288
|
+
/* @__PURE__ */ jsxs(DocxEditor.Viewport, { className: "native-docx-viewport", children: [
|
|
3289
|
+
/* @__PURE__ */ jsx(DocxEditor.Content, {}),
|
|
3290
|
+
/* @__PURE__ */ jsx(
|
|
3291
|
+
DocxMentions,
|
|
3292
|
+
{
|
|
3293
|
+
initialCommentId,
|
|
3294
|
+
mentions: adapter.mentions,
|
|
3295
|
+
notify: adapter.notify,
|
|
3296
|
+
getAgentStatus: adapter.getAgentStatus,
|
|
3297
|
+
requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
|
|
3298
|
+
children: /* @__PURE__ */ jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsx(DocxEditorReview.Card, { children: /* @__PURE__ */ jsx(DocxCommentActivity, {}) }) })
|
|
3299
|
+
}
|
|
3300
|
+
),
|
|
3301
|
+
/* @__PURE__ */ jsx(DocxEditor.HeaderFooterChrome, {}),
|
|
3302
|
+
/* @__PURE__ */ jsx(DocxEditor.NotesChrome, {}),
|
|
3303
|
+
/* @__PURE__ */ jsx(DocxEditor.Equation, {}),
|
|
3304
|
+
/* @__PURE__ */ jsx(DocxEditor.HyperLink, {}),
|
|
3305
|
+
/* @__PURE__ */ jsx(DocxEditor.ContextMenu, {})
|
|
3306
|
+
] }),
|
|
3307
|
+
/* @__PURE__ */ jsx(DocxEditor.PageNumber, {})
|
|
3308
|
+
]
|
|
3309
|
+
}
|
|
2749
3310
|
)
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
"div",
|
|
2754
|
-
{
|
|
2755
|
-
className: "native-docx-stage",
|
|
2756
|
-
ref: stageRef,
|
|
2757
|
-
onMouseDownCapture: (event) => {
|
|
2758
|
-
if (event.button === 2 && ref.current?.getSelectionPlacement())
|
|
2759
|
-
event.preventDefault();
|
|
2760
|
-
},
|
|
2761
|
-
children: [
|
|
2762
|
-
/* @__PURE__ */ jsxs(DocxEditor.Viewport, { className: "native-docx-viewport", children: [
|
|
2763
|
-
/* @__PURE__ */ jsx(DocxEditor.Content, {}),
|
|
2764
|
-
/* @__PURE__ */ jsx(
|
|
2765
|
-
DocxMentions,
|
|
2766
|
-
{
|
|
2767
|
-
initialCommentId,
|
|
2768
|
-
mentions: adapter.mentions,
|
|
2769
|
-
notify: adapter.notify,
|
|
2770
|
-
getAgentStatus: adapter.getAgentStatus,
|
|
2771
|
-
requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
|
|
2772
|
-
children: /* @__PURE__ */ jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsx(DocxEditorReview.Card, { children: /* @__PURE__ */ jsx(DocxCommentActivity, {}) }) })
|
|
2773
|
-
}
|
|
2774
|
-
),
|
|
2775
|
-
/* @__PURE__ */ jsx(DocxEditor.HeaderFooterChrome, {}),
|
|
2776
|
-
/* @__PURE__ */ jsx(DocxEditor.NotesChrome, {}),
|
|
2777
|
-
/* @__PURE__ */ jsx(DocxEditor.Equation, {}),
|
|
2778
|
-
/* @__PURE__ */ jsx(DocxEditor.HyperLink, {}),
|
|
2779
|
-
/* @__PURE__ */ jsx(DocxEditor.ContextMenu, {})
|
|
2780
|
-
] }),
|
|
2781
|
-
/* @__PURE__ */ jsx(DocxEditor.PageNumber, {})
|
|
2782
|
-
]
|
|
2783
|
-
}
|
|
2784
|
-
)
|
|
2785
|
-
]
|
|
3311
|
+
]
|
|
3312
|
+
}
|
|
3313
|
+
)
|
|
2786
3314
|
}
|
|
2787
3315
|
)
|
|
2788
3316
|
}
|
|
@@ -2879,6 +3407,6 @@ async function loadFonts(baseUrl) {
|
|
|
2879
3407
|
};
|
|
2880
3408
|
}
|
|
2881
3409
|
|
|
2882
|
-
export { DEFAULT_DEFINED_TERMS_LABELS, DEFINED_TERM_TRIGGER, DefinedTermsProvider, DocxCommentActivity, DocxEditorReview, DocxMentions, DocxParticipants, DocxRibbon, NativeDocxEditor, editorPort, findDefinitionsSection, insertDefinedTerm, loadDocxFonts, normalizeDocxExport, reviewModule, updateDefinitions, useDefinedTerms, useReview, useReviewItem, withDirectEditing };
|
|
2883
|
-
//# sourceMappingURL=chunk-
|
|
2884
|
-
//# sourceMappingURL=chunk-
|
|
3410
|
+
export { BUILTIN_TEMPLATE_NAME, DEFAULT_DEFINED_TERMS_LABELS, DEFINED_TERM_TRIGGER, DefinedTermsProvider, DocxCommentActivity, DocxEditorReview, DocxMentions, DocxParticipants, DocxRibbon, HouseTemplateProvider, NativeDocxEditor, builtinHouseTemplate, contentPath, editorPort, findDefinitionsSection, insertDefinedTerm, loadDocxFonts, normalizeDocxExport, resolveHouseTemplate, reviewModule, templateFileName, updateDefinitions, useDefinedTerms, useHouseTemplate, useReview, useReviewItem, withDirectEditing };
|
|
3411
|
+
//# sourceMappingURL=chunk-FIEAWH4K.js.map
|
|
3412
|
+
//# sourceMappingURL=chunk-FIEAWH4K.js.map
|