@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
|
@@ -11,6 +11,7 @@ var ui = require('@arbidocs/react/ui');
|
|
|
11
11
|
var lucideReact = require('lucide-react');
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var reactDom = require('react-dom');
|
|
14
|
+
var template = require('@arbidocs/coedit/template');
|
|
14
15
|
var server = require('react-dom/server');
|
|
15
16
|
var Y = require('yjs');
|
|
16
17
|
var coedit = require('@arbidocs/coedit');
|
|
@@ -2147,6 +2148,130 @@ function DefinedTermHover({
|
|
|
2147
2148
|
document.body
|
|
2148
2149
|
);
|
|
2149
2150
|
}
|
|
2151
|
+
var BUILTIN_TEMPLATE_NAME = "ARBI legal template";
|
|
2152
|
+
var templateFileName = (t) => /\.(dotx|dotm|docx|docm)$/i.test(t.name) ? t.name : `${t.name}.dotx`;
|
|
2153
|
+
var builtin;
|
|
2154
|
+
function builtinHouseTemplate() {
|
|
2155
|
+
builtin ??= { bytes: template.defaultLegalTemplate(), name: BUILTIN_TEMPLATE_NAME, source: "builtin" };
|
|
2156
|
+
return builtin;
|
|
2157
|
+
}
|
|
2158
|
+
async function resolveHouseTemplate(host) {
|
|
2159
|
+
if (!host) return builtinHouseTemplate();
|
|
2160
|
+
try {
|
|
2161
|
+
return await host.load();
|
|
2162
|
+
} catch {
|
|
2163
|
+
return builtinHouseTemplate();
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
var HouseTemplateContext = React3.createContext(null);
|
|
2167
|
+
var useHouseTemplate = () => React3.useContext(HouseTemplateContext);
|
|
2168
|
+
function HouseTemplateProvider({
|
|
2169
|
+
host,
|
|
2170
|
+
documentId,
|
|
2171
|
+
editable,
|
|
2172
|
+
notify,
|
|
2173
|
+
enabled = true,
|
|
2174
|
+
children
|
|
2175
|
+
}) {
|
|
2176
|
+
const editor = react.useDocxEditor();
|
|
2177
|
+
const [template$1, setTemplate] = React3.useState(builtinHouseTemplate);
|
|
2178
|
+
const [divergence, setDivergence] = React3.useState(null);
|
|
2179
|
+
const [basedOnTemplate, setBasedOnTemplate] = React3.useState(false);
|
|
2180
|
+
const [levels, setLevels] = React3.useState({});
|
|
2181
|
+
const [generation, setGeneration] = React3.useState(0);
|
|
2182
|
+
React3.useEffect(() => {
|
|
2183
|
+
let live = true;
|
|
2184
|
+
void resolveHouseTemplate(host).then((t) => live && setTemplate(t));
|
|
2185
|
+
return () => {
|
|
2186
|
+
live = false;
|
|
2187
|
+
};
|
|
2188
|
+
}, [host]);
|
|
2189
|
+
const blocks = React3.useMemo(() => {
|
|
2190
|
+
try {
|
|
2191
|
+
return template.listBuildingBlocks(template$1.bytes);
|
|
2192
|
+
} catch {
|
|
2193
|
+
return [];
|
|
2194
|
+
}
|
|
2195
|
+
}, [template$1]);
|
|
2196
|
+
React3.useEffect(() => {
|
|
2197
|
+
if (!editor || !enabled) return;
|
|
2198
|
+
let live = true;
|
|
2199
|
+
void editor.save().then((saved) => {
|
|
2200
|
+
if (!live || !saved) return;
|
|
2201
|
+
const bytes = new Uint8Array(saved);
|
|
2202
|
+
setBasedOnTemplate(template.attachedTemplateOf(bytes) === templateFileName(template$1));
|
|
2203
|
+
setLevels(template.linkedLevelStyles(bytes));
|
|
2204
|
+
setDivergence(template.styleDivergence(bytes, template$1.bytes));
|
|
2205
|
+
}).catch(() => live && setDivergence(null));
|
|
2206
|
+
return () => {
|
|
2207
|
+
live = false;
|
|
2208
|
+
};
|
|
2209
|
+
}, [editor, template$1, generation, enabled]);
|
|
2210
|
+
const refresh = React3.useCallback(() => setGeneration((g) => g + 1), []);
|
|
2211
|
+
const insertBlock = React3.useCallback(
|
|
2212
|
+
(name) => {
|
|
2213
|
+
if (!editor || !editable) return false;
|
|
2214
|
+
const fragment = template.buildingBlockFragment(template$1.bytes, name);
|
|
2215
|
+
if (!fragment) return false;
|
|
2216
|
+
try {
|
|
2217
|
+
const result = withDirectEditing(
|
|
2218
|
+
editor,
|
|
2219
|
+
() => editor.exec({ type: "paste", text: "", html: template.fragmentClipboardHtml(fragment) })
|
|
2220
|
+
);
|
|
2221
|
+
if (!result.ok) throw new Error(result.reason ?? "The block could not be inserted here.");
|
|
2222
|
+
refresh();
|
|
2223
|
+
return true;
|
|
2224
|
+
} catch (failure) {
|
|
2225
|
+
notify?.(
|
|
2226
|
+
failure instanceof Error ? failure.message : "Could not insert the block.",
|
|
2227
|
+
"error"
|
|
2228
|
+
);
|
|
2229
|
+
return false;
|
|
2230
|
+
}
|
|
2231
|
+
},
|
|
2232
|
+
[editor, editable, template$1, notify, refresh]
|
|
2233
|
+
);
|
|
2234
|
+
const setAsHouseTemplate = React3.useMemo(
|
|
2235
|
+
() => host?.setFromDocument && documentId ? async () => {
|
|
2236
|
+
try {
|
|
2237
|
+
await host.setFromDocument(documentId);
|
|
2238
|
+
setTemplate(await resolveHouseTemplate(host));
|
|
2239
|
+
notify?.("This document is now the house template for new documents.", "success");
|
|
2240
|
+
} catch (failure) {
|
|
2241
|
+
notify?.(
|
|
2242
|
+
failure instanceof Error ? failure.message : "Could not set the house template.",
|
|
2243
|
+
"error"
|
|
2244
|
+
);
|
|
2245
|
+
}
|
|
2246
|
+
} : void 0,
|
|
2247
|
+
[host, documentId, notify]
|
|
2248
|
+
);
|
|
2249
|
+
const value = React3.useMemo(
|
|
2250
|
+
() => ({
|
|
2251
|
+
template: template$1,
|
|
2252
|
+
blocks,
|
|
2253
|
+
divergence,
|
|
2254
|
+
basedOnTemplate,
|
|
2255
|
+
levels,
|
|
2256
|
+
insertBlock,
|
|
2257
|
+
refresh,
|
|
2258
|
+
setAsHouseTemplate,
|
|
2259
|
+
editable
|
|
2260
|
+
}),
|
|
2261
|
+
[
|
|
2262
|
+
template$1,
|
|
2263
|
+
blocks,
|
|
2264
|
+
divergence,
|
|
2265
|
+
basedOnTemplate,
|
|
2266
|
+
levels,
|
|
2267
|
+
insertBlock,
|
|
2268
|
+
refresh,
|
|
2269
|
+
setAsHouseTemplate,
|
|
2270
|
+
editable
|
|
2271
|
+
]
|
|
2272
|
+
);
|
|
2273
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HouseTemplateContext.Provider, { value: enabled ? value : null, children });
|
|
2274
|
+
}
|
|
2150
2275
|
function wordDraftHtml(markdown) {
|
|
2151
2276
|
const template = document.createElement("template");
|
|
2152
2277
|
template.innerHTML = server.renderToStaticMarkup(/* @__PURE__ */ jsxRuntime.jsx(ui.AiMarkdown, { children: markdown }));
|
|
@@ -2234,57 +2359,13 @@ var WordDraftStream = class {
|
|
|
2234
2359
|
}
|
|
2235
2360
|
}
|
|
2236
2361
|
};
|
|
2237
|
-
function contentPath(documentId) {
|
|
2238
|
-
const match = /^(doc-[A-Za-z0-9]+)@v([1-9][0-9]*)$/.exec(documentId);
|
|
2239
|
-
return match ? `/${encodeURIComponent(match[1])}/content?version=${match[2]}` : `/${encodeURIComponent(documentId)}/content`;
|
|
2240
|
-
}
|
|
2241
|
-
var drafts = /* @__PURE__ */ new Map();
|
|
2242
|
-
var stateBytes = (room) => Y__namespace.encodeStateAsUpdate(room.ydoc);
|
|
2243
|
-
var encodeState = (room) => {
|
|
2244
|
-
let binary = "";
|
|
2245
|
-
for (const byte of stateBytes(room)) binary += String.fromCharCode(byte);
|
|
2246
|
-
return btoa(binary);
|
|
2247
|
-
};
|
|
2248
|
-
function covered(room, vector, receipt) {
|
|
2249
|
-
const decode = (value) => Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
|
|
2250
|
-
const server = Y__namespace.decodeStateVector(decode(vector)), local = Y__namespace.decodeStateVector(Y__namespace.encodeStateVector(room.ydoc));
|
|
2251
|
-
for (const [client, clock] of local) if ((server.get(client) || 0) < clock) return false;
|
|
2252
|
-
const deleted = Y__namespace.decodeUpdate(stateBytes(room)).ds.clients;
|
|
2253
|
-
const saved = Y__namespace.decodeUpdate(decode(receipt)).ds.clients;
|
|
2254
|
-
for (const [client, ranges] of deleted)
|
|
2255
|
-
for (const range of ranges) {
|
|
2256
|
-
if (!(saved.get(client) || []).some(
|
|
2257
|
-
(s) => s.clock <= range.clock && s.clock + s.len >= range.clock + range.len
|
|
2258
|
-
))
|
|
2259
|
-
return false;
|
|
2260
|
-
}
|
|
2261
|
-
return true;
|
|
2262
|
-
}
|
|
2263
|
-
var EditorBoundary = class extends React3__default.default.Component {
|
|
2264
|
-
state = {};
|
|
2265
|
-
static getDerivedStateFromError(error) {
|
|
2266
|
-
return { error };
|
|
2267
|
-
}
|
|
2268
|
-
render() {
|
|
2269
|
-
return this.state.error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "alert", className: "native-docx-error", children: [
|
|
2270
|
-
"Could not render this Word document: ",
|
|
2271
|
-
this.state.error.message
|
|
2272
|
-
] }) : this.props.children;
|
|
2273
|
-
}
|
|
2274
|
-
};
|
|
2275
|
-
function DocxParticipants({ session }) {
|
|
2276
|
-
const [people, setPeople] = React3.useState([]);
|
|
2277
|
-
React3.useEffect(() => {
|
|
2278
|
-
if (!session) return;
|
|
2279
|
-
setPeople(session.participants());
|
|
2280
|
-
return session.subscribeParticipants(setPeople);
|
|
2281
|
-
}, [session]);
|
|
2282
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "native-docx-presence", "aria-label": "People viewing this document", children: people.map((p) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-avatar", title: p.name, children: p.name.split(" ").map((s) => s[0]).slice(0, 2).join("") }, p.actorId)) });
|
|
2283
|
-
}
|
|
2284
2362
|
function RibbonMenu({
|
|
2285
2363
|
label,
|
|
2286
2364
|
icon,
|
|
2287
|
-
children
|
|
2365
|
+
children,
|
|
2366
|
+
className,
|
|
2367
|
+
testId,
|
|
2368
|
+
title
|
|
2288
2369
|
}) {
|
|
2289
2370
|
const [open, setOpen] = React3.useState(false);
|
|
2290
2371
|
const element = React3.useRef(null);
|
|
@@ -2308,10 +2389,11 @@ function RibbonMenu({
|
|
|
2308
2389
|
"button",
|
|
2309
2390
|
{
|
|
2310
2391
|
type: "button",
|
|
2311
|
-
className: "native-docx-ribbon-trigger",
|
|
2392
|
+
className: ["native-docx-ribbon-trigger", className].filter(Boolean).join(" "),
|
|
2312
2393
|
"aria-label": label,
|
|
2313
|
-
title: label,
|
|
2394
|
+
title: title ?? label,
|
|
2314
2395
|
"aria-expanded": open,
|
|
2396
|
+
"data-testid": testId,
|
|
2315
2397
|
onMouseDown: (event) => event.preventDefault(),
|
|
2316
2398
|
onClick: () => setOpen((value) => !value),
|
|
2317
2399
|
children: icon
|
|
@@ -2327,11 +2409,436 @@ function RibbonMenu({
|
|
|
2327
2409
|
if (!(event.target instanceof HTMLInputElement || event.target instanceof HTMLSelectElement))
|
|
2328
2410
|
event.preventDefault();
|
|
2329
2411
|
},
|
|
2330
|
-
children
|
|
2412
|
+
children: typeof children === "function" ? children(() => setOpen(false)) : children
|
|
2413
|
+
}
|
|
2414
|
+
)
|
|
2415
|
+
] });
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
// src/docx/wordStyles.ts
|
|
2419
|
+
var QUICK_STYLES = ["Normal", "Title", "heading 1", "heading 2", "heading 3"];
|
|
2420
|
+
function findStyle(options, name) {
|
|
2421
|
+
const wanted = name.toLowerCase();
|
|
2422
|
+
const id = name.replace(/(^|\s)(\w)/g, (_, _s, c) => c.toUpperCase());
|
|
2423
|
+
return options.find((o) => o.name.toLowerCase() === wanted) ?? options.find((o) => o.styleId.toLowerCase() === id.toLowerCase());
|
|
2424
|
+
}
|
|
2425
|
+
function styleLabel(name) {
|
|
2426
|
+
return name === name.toLowerCase() ? name.replace(/(^|\s)(\w)/g, (m) => m.toUpperCase()) : name;
|
|
2427
|
+
}
|
|
2428
|
+
function wordShortcut(event) {
|
|
2429
|
+
const mod = event.ctrlKey || event.metaKey;
|
|
2430
|
+
if (!mod) return null;
|
|
2431
|
+
if (event.altKey && !event.shiftKey) {
|
|
2432
|
+
switch (event.code) {
|
|
2433
|
+
case "KeyF":
|
|
2434
|
+
return "footnote";
|
|
2435
|
+
case "KeyD":
|
|
2436
|
+
return "endnote";
|
|
2437
|
+
case "Digit1":
|
|
2438
|
+
case "Numpad1":
|
|
2439
|
+
return "heading 1";
|
|
2440
|
+
case "Digit2":
|
|
2441
|
+
case "Numpad2":
|
|
2442
|
+
return "heading 2";
|
|
2443
|
+
case "Digit3":
|
|
2444
|
+
case "Numpad3":
|
|
2445
|
+
return "heading 3";
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
if (event.shiftKey && !event.altKey && event.code === "KeyN") return "Normal";
|
|
2449
|
+
return null;
|
|
2450
|
+
}
|
|
2451
|
+
function divergenceSummary(divergence) {
|
|
2452
|
+
if (!divergence) return null;
|
|
2453
|
+
const changed = divergence.styles.filter((s) => s.kind === "changed").map((s) => styleLabel(s.name));
|
|
2454
|
+
const missing = divergence.styles.filter((s) => s.kind === "missing").map((s) => styleLabel(s.name));
|
|
2455
|
+
const parts = [
|
|
2456
|
+
divergence.docDefaults ? "default text formatting" : "",
|
|
2457
|
+
changed.length ? `${changed.length === 1 ? "style" : "styles"} ${changed.slice(0, 6).join(", ")}${changed.length > 6 ? "\u2026" : ""}` : "",
|
|
2458
|
+
missing.length ? `${missing.length} house ${missing.length === 1 ? "style" : "styles"} missing` : ""
|
|
2459
|
+
].filter(Boolean);
|
|
2460
|
+
return parts.length ? `Differs from the house template: ${parts.join("; ")}.` : null;
|
|
2461
|
+
}
|
|
2462
|
+
var FILTER_FROM = 8;
|
|
2463
|
+
function previewStyle(option) {
|
|
2464
|
+
const { fontFamily, fontSizePt, bold, italic, color } = option.preview;
|
|
2465
|
+
return {
|
|
2466
|
+
fontFamily: fontFamily ? `"${fontFamily}", serif` : void 0,
|
|
2467
|
+
// In the face of the style, but within a row: 9-18pt.
|
|
2468
|
+
fontSize: fontSizePt ? `${Math.min(18, Math.max(9, fontSizePt))}pt` : void 0,
|
|
2469
|
+
fontWeight: bold ? 700 : void 0,
|
|
2470
|
+
fontStyle: italic ? "italic" : void 0,
|
|
2471
|
+
color: color ? `#${color}` : void 0
|
|
2472
|
+
};
|
|
2473
|
+
}
|
|
2474
|
+
function Gallery({ close }) {
|
|
2475
|
+
const { value, setValue, options, isEnabled } = react.useParagraphStyle();
|
|
2476
|
+
const editor = react.useDocxEditor();
|
|
2477
|
+
const house = useHouseTemplate();
|
|
2478
|
+
const changed = new Set(
|
|
2479
|
+
house?.basedOnTemplate ? house.divergence?.styles.filter((s) => s.kind === "changed").map((s) => s.styleId) : []
|
|
2480
|
+
);
|
|
2481
|
+
const [query, setQuery] = React3.useState("");
|
|
2482
|
+
const quick = React3.useMemo(
|
|
2483
|
+
() => QUICK_STYLES.map((name) => findStyle(options, name)).filter(
|
|
2484
|
+
(o) => !!o
|
|
2485
|
+
),
|
|
2486
|
+
[options]
|
|
2487
|
+
);
|
|
2488
|
+
const shown = React3.useMemo(() => {
|
|
2489
|
+
const q = query.trim().toLowerCase();
|
|
2490
|
+
return q ? options.filter(
|
|
2491
|
+
(o) => o.name.toLowerCase().includes(q) || o.styleId.toLowerCase().includes(q)
|
|
2492
|
+
) : options;
|
|
2493
|
+
}, [options, query]);
|
|
2494
|
+
const apply = (option) => {
|
|
2495
|
+
setValue(option.styleId);
|
|
2496
|
+
close();
|
|
2497
|
+
editor?.surface?.focus();
|
|
2498
|
+
};
|
|
2499
|
+
const nav = chunk7UTB4PHM_cjs.useListKeyNav({
|
|
2500
|
+
open: true,
|
|
2501
|
+
items: shown,
|
|
2502
|
+
onPick: apply,
|
|
2503
|
+
onDismiss: close,
|
|
2504
|
+
resetKey: query
|
|
2505
|
+
});
|
|
2506
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-style-gallery", "data-testid": "docx-style-gallery", children: [
|
|
2507
|
+
quick.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "native-docx-style-quick", role: "group", "aria-label": "Quick styles", children: quick.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2508
|
+
"button",
|
|
2509
|
+
{
|
|
2510
|
+
type: "button",
|
|
2511
|
+
"aria-pressed": value === option.styleId,
|
|
2512
|
+
disabled: !isEnabled,
|
|
2513
|
+
"data-style-id": option.styleId,
|
|
2514
|
+
title: styleLabel(option.name),
|
|
2515
|
+
onClick: () => apply(option),
|
|
2516
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: previewStyle(option), children: styleLabel(option.name) })
|
|
2517
|
+
},
|
|
2518
|
+
option.styleId
|
|
2519
|
+
)) }),
|
|
2520
|
+
options.length > FILTER_FROM && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2521
|
+
"input",
|
|
2522
|
+
{
|
|
2523
|
+
className: "native-docx-style-filter",
|
|
2524
|
+
placeholder: "Find a style",
|
|
2525
|
+
"aria-label": "Find a style",
|
|
2526
|
+
value: query,
|
|
2527
|
+
autoFocus: true,
|
|
2528
|
+
onChange: (event) => setQuery(event.target.value),
|
|
2529
|
+
onKeyDown: (event) => {
|
|
2530
|
+
nav.handleKeyDown(event);
|
|
2531
|
+
},
|
|
2532
|
+
...nav.comboboxProps
|
|
2533
|
+
}
|
|
2534
|
+
),
|
|
2535
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2536
|
+
"ul",
|
|
2537
|
+
{
|
|
2538
|
+
className: "native-docx-style-list",
|
|
2539
|
+
role: "listbox",
|
|
2540
|
+
id: nav.listboxId,
|
|
2541
|
+
"aria-label": "Document styles",
|
|
2542
|
+
children: [
|
|
2543
|
+
shown.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2544
|
+
"li",
|
|
2545
|
+
{
|
|
2546
|
+
id: chunk7UTB4PHM_cjs.listOptionId(nav.listboxId, index),
|
|
2547
|
+
role: "option",
|
|
2548
|
+
"aria-selected": value === option.styleId,
|
|
2549
|
+
"aria-disabled": !isEnabled,
|
|
2550
|
+
"data-active": index === nav.selectedIndex || void 0,
|
|
2551
|
+
"data-style-id": option.styleId,
|
|
2552
|
+
onMouseEnter: () => nav.setSelectedIndex(index),
|
|
2553
|
+
onClick: () => isEnabled && apply(option),
|
|
2554
|
+
children: [
|
|
2555
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: previewStyle(option), children: styleLabel(option.name) }),
|
|
2556
|
+
changed.has(option.styleId) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2557
|
+
"span",
|
|
2558
|
+
{
|
|
2559
|
+
className: "native-docx-style-diverged",
|
|
2560
|
+
title: "Defined differently from the house template",
|
|
2561
|
+
"aria-label": "Defined differently from the house template"
|
|
2562
|
+
}
|
|
2563
|
+
)
|
|
2564
|
+
]
|
|
2565
|
+
},
|
|
2566
|
+
option.styleId
|
|
2567
|
+
)),
|
|
2568
|
+
shown.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "native-docx-style-empty", children: "No matching style" })
|
|
2569
|
+
]
|
|
2331
2570
|
}
|
|
2332
2571
|
)
|
|
2333
2572
|
] });
|
|
2334
2573
|
}
|
|
2574
|
+
function StyleGallery() {
|
|
2575
|
+
const { value, options } = react.useParagraphStyle();
|
|
2576
|
+
const current = options.find((o) => o.styleId === value);
|
|
2577
|
+
const name = current ? styleLabel(current.name) : "Styles";
|
|
2578
|
+
const house = useHouseTemplate();
|
|
2579
|
+
const diverged = house?.basedOnTemplate ? divergenceSummary(house.divergence) : null;
|
|
2580
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2581
|
+
RibbonMenu,
|
|
2582
|
+
{
|
|
2583
|
+
label: "Styles",
|
|
2584
|
+
title: diverged ? `Styles. ${diverged}` : void 0,
|
|
2585
|
+
className: "native-docx-style-trigger",
|
|
2586
|
+
testId: "docx-style-trigger",
|
|
2587
|
+
icon: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2588
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-style-current", "data-testid": "docx-current-style", children: name }),
|
|
2589
|
+
diverged && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2590
|
+
"span",
|
|
2591
|
+
{
|
|
2592
|
+
className: "native-docx-style-diverged",
|
|
2593
|
+
"data-testid": "docx-style-diverged",
|
|
2594
|
+
"aria-label": diverged
|
|
2595
|
+
}
|
|
2596
|
+
),
|
|
2597
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 12, "aria-hidden": true })
|
|
2598
|
+
] }),
|
|
2599
|
+
children: (close) => /* @__PURE__ */ jsxRuntime.jsx(Gallery, { close })
|
|
2600
|
+
}
|
|
2601
|
+
);
|
|
2602
|
+
}
|
|
2603
|
+
function useInsertNote(kind) {
|
|
2604
|
+
const command = react.useEditorCommand(kind === "footnote" ? "insert.footnote" : "insert.endnote");
|
|
2605
|
+
const { options } = react.useParagraphStyle();
|
|
2606
|
+
const editor = react.useDocxEditor();
|
|
2607
|
+
const insert = () => {
|
|
2608
|
+
if (!command.execute()) return false;
|
|
2609
|
+
const text = findStyle(options, `${kind} text`);
|
|
2610
|
+
if (text && editor)
|
|
2611
|
+
withDirectEditing(
|
|
2612
|
+
editor,
|
|
2613
|
+
() => editor.exec({ type: "setParagraphStyle", styleId: text.styleId })
|
|
2614
|
+
);
|
|
2615
|
+
return true;
|
|
2616
|
+
};
|
|
2617
|
+
return { insert, isEnabled: command.isEnabled, disabledReason: command.disabledReason };
|
|
2618
|
+
}
|
|
2619
|
+
function NoteAction({
|
|
2620
|
+
kind,
|
|
2621
|
+
label,
|
|
2622
|
+
shortcut,
|
|
2623
|
+
icon
|
|
2624
|
+
}) {
|
|
2625
|
+
const note = useInsertNote(kind);
|
|
2626
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2627
|
+
react.DocxEditor.Toolbar.Action,
|
|
2628
|
+
{
|
|
2629
|
+
label: `${label} (${shortcut})`,
|
|
2630
|
+
icon,
|
|
2631
|
+
disabled: !note.isEnabled,
|
|
2632
|
+
disabledReason: note.disabledReason ?? void 0,
|
|
2633
|
+
onSelect: () => void note.insert(),
|
|
2634
|
+
className: `native-docx-insert-${kind}`
|
|
2635
|
+
}
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
function NoteButtons() {
|
|
2639
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2640
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2641
|
+
NoteAction,
|
|
2642
|
+
{
|
|
2643
|
+
kind: "footnote",
|
|
2644
|
+
label: "Insert footnote",
|
|
2645
|
+
shortcut: "Ctrl+Alt+F",
|
|
2646
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Superscript, { size: 16 })
|
|
2647
|
+
}
|
|
2648
|
+
),
|
|
2649
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2650
|
+
NoteAction,
|
|
2651
|
+
{
|
|
2652
|
+
kind: "endnote",
|
|
2653
|
+
label: "Insert endnote",
|
|
2654
|
+
shortcut: "Ctrl+Alt+D",
|
|
2655
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.NotebookText, { size: 16 })
|
|
2656
|
+
}
|
|
2657
|
+
)
|
|
2658
|
+
] });
|
|
2659
|
+
}
|
|
2660
|
+
function WordShortcuts({ scope }) {
|
|
2661
|
+
const footnote = useInsertNote("footnote");
|
|
2662
|
+
const endnote = useInsertNote("endnote");
|
|
2663
|
+
const styles = react.useParagraphStyle();
|
|
2664
|
+
const editor = react.useDocxEditor();
|
|
2665
|
+
const levels = useHouseTemplate()?.levels;
|
|
2666
|
+
const latest = React3.useRef({ footnote, endnote, styles, editor, levels });
|
|
2667
|
+
latest.current = { footnote, endnote, styles, editor, levels };
|
|
2668
|
+
React3.useEffect(() => {
|
|
2669
|
+
const element = scope.current;
|
|
2670
|
+
if (!element) return;
|
|
2671
|
+
const onKeyDown = (event) => {
|
|
2672
|
+
if (outlineTab(event)) {
|
|
2673
|
+
event.preventDefault();
|
|
2674
|
+
event.stopPropagation();
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2677
|
+
const action = wordShortcut(event);
|
|
2678
|
+
if (!action) return;
|
|
2679
|
+
const { footnote: footnote2, endnote: endnote2, styles: styles2, editor: editor2 } = latest.current;
|
|
2680
|
+
if (action === "footnote" || action === "endnote") {
|
|
2681
|
+
if (!(action === "footnote" ? footnote2 : endnote2).insert()) return;
|
|
2682
|
+
} else {
|
|
2683
|
+
const style = findStyle(styles2.options, action);
|
|
2684
|
+
if (!style) return;
|
|
2685
|
+
styles2.setValue(style.styleId);
|
|
2686
|
+
}
|
|
2687
|
+
event.preventDefault();
|
|
2688
|
+
event.stopPropagation();
|
|
2689
|
+
editor2?.surface?.focus();
|
|
2690
|
+
};
|
|
2691
|
+
const outlineTab = (event) => {
|
|
2692
|
+
if (event.key !== "Tab" || event.ctrlKey || event.metaKey || event.altKey) return false;
|
|
2693
|
+
const { editor: editor2, levels: levels2, styles: styles2 } = latest.current;
|
|
2694
|
+
const current = editor2?.getSelectionFormatting()?.styleId;
|
|
2695
|
+
const link = current ? levels2?.[current] : void 0;
|
|
2696
|
+
const target = event.shiftKey ? link?.previous : link?.next;
|
|
2697
|
+
if (!target || !editor2 || editorPort(editor2).caret()?.offset !== 0) return false;
|
|
2698
|
+
styles2.setValue(target);
|
|
2699
|
+
return true;
|
|
2700
|
+
};
|
|
2701
|
+
element.addEventListener("keydown", onKeyDown, true);
|
|
2702
|
+
return () => element.removeEventListener("keydown", onKeyDown, true);
|
|
2703
|
+
}, [scope]);
|
|
2704
|
+
return null;
|
|
2705
|
+
}
|
|
2706
|
+
function QuickParts() {
|
|
2707
|
+
const house = useHouseTemplate();
|
|
2708
|
+
if (!house || house.blocks.length === 0) return null;
|
|
2709
|
+
const categories = [...new Set(house.blocks.map((b) => b.category))];
|
|
2710
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RibbonMenu, { label: "Quick Parts", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Blocks, { size: 16 }), testId: "docx-quick-parts", children: (close) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-quick-parts", "data-testid": "docx-quick-parts-panel", children: [
|
|
2711
|
+
categories.map((category) => /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": category, children: [
|
|
2712
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { children: category }),
|
|
2713
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { children: house.blocks.filter((b) => b.category === category).map((block) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2714
|
+
"button",
|
|
2715
|
+
{
|
|
2716
|
+
type: "button",
|
|
2717
|
+
disabled: !house.editable,
|
|
2718
|
+
title: block.description || block.name,
|
|
2719
|
+
onClick: () => {
|
|
2720
|
+
close();
|
|
2721
|
+
house.insertBlock(block.name);
|
|
2722
|
+
},
|
|
2723
|
+
children: [
|
|
2724
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-quick-part-name", children: block.name }),
|
|
2725
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-quick-part-preview", children: block.text })
|
|
2726
|
+
]
|
|
2727
|
+
}
|
|
2728
|
+
) }, block.name)) })
|
|
2729
|
+
] }, category)),
|
|
2730
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "native-docx-quick-parts-source", children: [
|
|
2731
|
+
"From ",
|
|
2732
|
+
house.template.name
|
|
2733
|
+
] })
|
|
2734
|
+
] }) });
|
|
2735
|
+
}
|
|
2736
|
+
var SOURCE = {
|
|
2737
|
+
workspace: "This workspace's house template",
|
|
2738
|
+
deployment: "The house template for all workspaces",
|
|
2739
|
+
builtin: "ARBI\u2019s built-in template (no house template has been set)"
|
|
2740
|
+
};
|
|
2741
|
+
function download(bytes, name) {
|
|
2742
|
+
const isTemplate = !/\.docx$/i.test(name);
|
|
2743
|
+
const url = URL.createObjectURL(
|
|
2744
|
+
new Blob([bytes], {
|
|
2745
|
+
type: isTemplate ? "application/vnd.openxmlformats-officedocument.wordprocessingml.template" : "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
2746
|
+
})
|
|
2747
|
+
);
|
|
2748
|
+
const a = document.createElement("a");
|
|
2749
|
+
a.href = url;
|
|
2750
|
+
a.download = /\.(dotx|docx)$/i.test(name) ? name : `${name}.dotx`;
|
|
2751
|
+
a.click();
|
|
2752
|
+
setTimeout(() => URL.revokeObjectURL(url), 5e3);
|
|
2753
|
+
}
|
|
2754
|
+
function HouseTemplatePanel() {
|
|
2755
|
+
const house = useHouseTemplate();
|
|
2756
|
+
if (!house) return null;
|
|
2757
|
+
const summary = divergenceSummary(house.divergence);
|
|
2758
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2759
|
+
RibbonMenu,
|
|
2760
|
+
{
|
|
2761
|
+
label: "House template",
|
|
2762
|
+
className: "native-docx-style-trigger",
|
|
2763
|
+
testId: "docx-house-template",
|
|
2764
|
+
icon: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2765
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-style-current", children: "House template" }),
|
|
2766
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 12, "aria-hidden": true })
|
|
2767
|
+
] }),
|
|
2768
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-house-template", "data-testid": "docx-house-template-panel", children: [
|
|
2769
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
|
|
2770
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: house.template.name }),
|
|
2771
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
2772
|
+
SOURCE[house.template.source],
|
|
2773
|
+
". New documents start from it."
|
|
2774
|
+
] }),
|
|
2775
|
+
/* @__PURE__ */ jsxRuntime.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." }),
|
|
2776
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-house-template-actions", children: [
|
|
2777
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", onClick: () => download(house.template.bytes, house.template.name), children: [
|
|
2778
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { size: 14 }),
|
|
2779
|
+
" Download template"
|
|
2780
|
+
] }),
|
|
2781
|
+
house.setAsHouseTemplate && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2782
|
+
"button",
|
|
2783
|
+
{
|
|
2784
|
+
type: "button",
|
|
2785
|
+
"data-testid": "docx-set-house-template",
|
|
2786
|
+
onClick: () => void house.setAsHouseTemplate(),
|
|
2787
|
+
children: "Use this document as the house template"
|
|
2788
|
+
}
|
|
2789
|
+
)
|
|
2790
|
+
] })
|
|
2791
|
+
] })
|
|
2792
|
+
}
|
|
2793
|
+
);
|
|
2794
|
+
}
|
|
2795
|
+
function contentPath(documentId) {
|
|
2796
|
+
const match = /^(doc-[A-Za-z0-9]+)@v([1-9][0-9]*)$/.exec(documentId);
|
|
2797
|
+
return match ? `/${encodeURIComponent(match[1])}/content?version=${match[2]}` : `/${encodeURIComponent(documentId)}/content`;
|
|
2798
|
+
}
|
|
2799
|
+
var drafts = /* @__PURE__ */ new Map();
|
|
2800
|
+
var stateBytes = (room) => Y__namespace.encodeStateAsUpdate(room.ydoc);
|
|
2801
|
+
var encodeState = (room) => {
|
|
2802
|
+
let binary = "";
|
|
2803
|
+
for (const byte of stateBytes(room)) binary += String.fromCharCode(byte);
|
|
2804
|
+
return btoa(binary);
|
|
2805
|
+
};
|
|
2806
|
+
function covered(room, vector, receipt) {
|
|
2807
|
+
const decode = (value) => Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
|
|
2808
|
+
const server = Y__namespace.decodeStateVector(decode(vector)), local = Y__namespace.decodeStateVector(Y__namespace.encodeStateVector(room.ydoc));
|
|
2809
|
+
for (const [client, clock] of local) if ((server.get(client) || 0) < clock) return false;
|
|
2810
|
+
const deleted = Y__namespace.decodeUpdate(stateBytes(room)).ds.clients;
|
|
2811
|
+
const saved = Y__namespace.decodeUpdate(decode(receipt)).ds.clients;
|
|
2812
|
+
for (const [client, ranges] of deleted)
|
|
2813
|
+
for (const range of ranges) {
|
|
2814
|
+
if (!(saved.get(client) || []).some(
|
|
2815
|
+
(s) => s.clock <= range.clock && s.clock + s.len >= range.clock + range.len
|
|
2816
|
+
))
|
|
2817
|
+
return false;
|
|
2818
|
+
}
|
|
2819
|
+
return true;
|
|
2820
|
+
}
|
|
2821
|
+
var EditorBoundary = class extends React3__default.default.Component {
|
|
2822
|
+
state = {};
|
|
2823
|
+
static getDerivedStateFromError(error) {
|
|
2824
|
+
return { error };
|
|
2825
|
+
}
|
|
2826
|
+
render() {
|
|
2827
|
+
return this.state.error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "alert", className: "native-docx-error", children: [
|
|
2828
|
+
"Could not render this Word document: ",
|
|
2829
|
+
this.state.error.message
|
|
2830
|
+
] }) : this.props.children;
|
|
2831
|
+
}
|
|
2832
|
+
};
|
|
2833
|
+
function DocxParticipants({ session }) {
|
|
2834
|
+
const [people, setPeople] = React3.useState([]);
|
|
2835
|
+
React3.useEffect(() => {
|
|
2836
|
+
if (!session) return;
|
|
2837
|
+
setPeople(session.participants());
|
|
2838
|
+
return session.subscribeParticipants(setPeople);
|
|
2839
|
+
}, [session]);
|
|
2840
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "native-docx-presence", "aria-label": "People viewing this document", children: people.map((p) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-avatar", title: p.name, children: p.name.split(" ").map((s) => s[0]).slice(0, 2).join("") }, p.actorId)) });
|
|
2841
|
+
}
|
|
2335
2842
|
function DefinedTermButtons() {
|
|
2336
2843
|
const terms = useDefinedTerms();
|
|
2337
2844
|
if (!terms) return null;
|
|
@@ -2374,6 +2881,8 @@ function DocxRibbon({
|
|
|
2374
2881
|
/* @__PURE__ */ jsxRuntime.jsxs("select", { "aria-label": "Ribbon tab", value: tab, onChange: (event) => setTab(event.target.value), children: [
|
|
2375
2882
|
/* @__PURE__ */ jsxRuntime.jsx("option", { children: "Home" }),
|
|
2376
2883
|
/* @__PURE__ */ jsxRuntime.jsx("option", { children: "Insert" }),
|
|
2884
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { children: "Design" }),
|
|
2885
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { children: "References" }),
|
|
2377
2886
|
/* @__PURE__ */ jsxRuntime.jsx("option", { children: "Review" })
|
|
2378
2887
|
] }),
|
|
2379
2888
|
/* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Toolbar, { t, preset: false, onSave, children: [
|
|
@@ -2381,6 +2890,7 @@ function DocxRibbon({
|
|
|
2381
2890
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Redo, {}),
|
|
2382
2891
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Save, {}),
|
|
2383
2892
|
tab === "Home" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2893
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyleGallery, {}),
|
|
2384
2894
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Bold, {}),
|
|
2385
2895
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Italic, {}),
|
|
2386
2896
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Underline, {}),
|
|
@@ -2391,7 +2901,6 @@ function DocxRibbon({
|
|
|
2391
2901
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Highlight, {})
|
|
2392
2902
|
] }),
|
|
2393
2903
|
/* @__PURE__ */ jsxRuntime.jsxs(RibbonMenu, { label: "More formatting", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Ellipsis, { size: 16 }), children: [
|
|
2394
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.StylePicker, {}),
|
|
2395
2904
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Alignment, {}),
|
|
2396
2905
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.BulletList, {}),
|
|
2397
2906
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.NumberedList, {}),
|
|
@@ -2406,8 +2915,11 @@ function DocxRibbon({
|
|
|
2406
2915
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.TableInsert, {}),
|
|
2407
2916
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.ImageInsert, {}),
|
|
2408
2917
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Link, {}),
|
|
2409
|
-
/* @__PURE__ */ jsxRuntime.jsx(DefinedTermButtons, {})
|
|
2918
|
+
/* @__PURE__ */ jsxRuntime.jsx(DefinedTermButtons, {}),
|
|
2919
|
+
/* @__PURE__ */ jsxRuntime.jsx(QuickParts, {})
|
|
2410
2920
|
] }),
|
|
2921
|
+
tab === "Design" && /* @__PURE__ */ jsxRuntime.jsx(HouseTemplatePanel, {}),
|
|
2922
|
+
tab === "References" && /* @__PURE__ */ jsxRuntime.jsx(NoteButtons, {}),
|
|
2411
2923
|
tab === "Review" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2412
2924
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.EditingMode, {}),
|
|
2413
2925
|
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Comments, {}),
|
|
@@ -2481,11 +2993,16 @@ function NativeDocxEditor({
|
|
|
2481
2993
|
async function start() {
|
|
2482
2994
|
const fonts = await adapter.loadFonts();
|
|
2483
2995
|
if (isDraft || snapshot) {
|
|
2484
|
-
const data = isDraft ? !streamRef.current && drafts.get(documentId) ||
|
|
2996
|
+
const data = isDraft ? !streamRef.current && drafts.get(documentId) || (draftContent === "" && adapter.houseTemplate ? await (async () => {
|
|
2997
|
+
const template$1 = await resolveHouseTemplate(adapter.houseTemplate);
|
|
2998
|
+
return template.newFromTemplate(template$1.bytes, {
|
|
2999
|
+
attachedTemplate: templateFileName(template$1)
|
|
3000
|
+
});
|
|
3001
|
+
})() : await (await adapter.request("/prepare", {
|
|
2485
3002
|
method: "POST",
|
|
2486
3003
|
headers: { "Content-Type": "application/json" },
|
|
2487
3004
|
body: JSON.stringify({ content: draftContent })
|
|
2488
|
-
})).arrayBuffer() : await (await adapter.request(contentPath(documentId))).arrayBuffer();
|
|
3005
|
+
})).arrayBuffer()) : await (await adapter.request(contentPath(documentId))).arrayBuffer();
|
|
2489
3006
|
if (!cancelled) {
|
|
2490
3007
|
setReady({
|
|
2491
3008
|
document: new Uint8Array(data),
|
|
@@ -2747,67 +3264,78 @@ function NativeDocxEditor({
|
|
|
2747
3264
|
if (change.source !== "load") changed();
|
|
2748
3265
|
},
|
|
2749
3266
|
onFontError: (e) => setError(e.message),
|
|
2750
|
-
children: /* @__PURE__ */ jsxRuntime.
|
|
3267
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2751
3268
|
DefinedTermsProvider,
|
|
2752
3269
|
{
|
|
2753
3270
|
load: adapter.definitions,
|
|
2754
3271
|
editable: !stream && !snapshot && ready.canEdit,
|
|
2755
3272
|
notify: adapter.notify,
|
|
2756
|
-
children:
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
3273
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3274
|
+
HouseTemplateProvider,
|
|
3275
|
+
{
|
|
3276
|
+
enabled: !stream,
|
|
3277
|
+
host: adapter.houseTemplate,
|
|
3278
|
+
documentId: isDraft || snapshot ? void 0 : documentId,
|
|
3279
|
+
editable: !stream && !snapshot && ready.canEdit,
|
|
3280
|
+
notify: adapter.notify,
|
|
3281
|
+
children: [
|
|
3282
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3283
|
+
react.DocxEditor.RevisionMarkup,
|
|
3284
|
+
{
|
|
3285
|
+
insertions: { mark: "underline", color: "blue" },
|
|
3286
|
+
deletions: { mark: "strikethrough", color: "red" },
|
|
3287
|
+
movedFrom: { mark: "doubleStrikethrough", color: "green" },
|
|
3288
|
+
movedTo: { mark: "doubleUnderline", color: "green" },
|
|
3289
|
+
trackMoves: true
|
|
3290
|
+
}
|
|
3291
|
+
),
|
|
3292
|
+
!stream && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3293
|
+
DocxRibbon,
|
|
3294
|
+
{
|
|
3295
|
+
onSave: () => void saveVersion(),
|
|
3296
|
+
badge: (
|
|
3297
|
+
// Says the document is shared live, in place of a title row above the ribbon.
|
|
3298
|
+
ready.room && ready.canEdit && !snapshot ? /* @__PURE__ */ jsxRuntime.jsx("span", { title: "Edits sync live with everyone who has this document open", children: "Co-edit mode" }) : void 0
|
|
3299
|
+
)
|
|
3300
|
+
}
|
|
3301
|
+
),
|
|
3302
|
+
!stream && /* @__PURE__ */ jsxRuntime.jsx(WordShortcuts, { scope: stageRef }),
|
|
3303
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3304
|
+
"div",
|
|
3305
|
+
{
|
|
3306
|
+
className: "native-docx-stage",
|
|
3307
|
+
ref: stageRef,
|
|
3308
|
+
onMouseDownCapture: (event) => {
|
|
3309
|
+
if (event.button === 2 && ref.current?.getSelectionPlacement())
|
|
3310
|
+
event.preventDefault();
|
|
3311
|
+
},
|
|
3312
|
+
children: [
|
|
3313
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Viewport, { className: "native-docx-viewport", children: [
|
|
3314
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Content, {}),
|
|
3315
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3316
|
+
DocxMentions,
|
|
3317
|
+
{
|
|
3318
|
+
initialCommentId,
|
|
3319
|
+
mentions: adapter.mentions,
|
|
3320
|
+
notify: adapter.notify,
|
|
3321
|
+
getAgentStatus: adapter.getAgentStatus,
|
|
3322
|
+
requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
|
|
3323
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(DocxCommentActivity, {}) }) })
|
|
3324
|
+
}
|
|
3325
|
+
),
|
|
3326
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HeaderFooterChrome, {}),
|
|
3327
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.NotesChrome, {}),
|
|
3328
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Equation, {}),
|
|
3329
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HyperLink, {}),
|
|
3330
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.ContextMenu, {})
|
|
3331
|
+
] }),
|
|
3332
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.PageNumber, {})
|
|
3333
|
+
]
|
|
3334
|
+
}
|
|
2774
3335
|
)
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
"div",
|
|
2779
|
-
{
|
|
2780
|
-
className: "native-docx-stage",
|
|
2781
|
-
ref: stageRef,
|
|
2782
|
-
onMouseDownCapture: (event) => {
|
|
2783
|
-
if (event.button === 2 && ref.current?.getSelectionPlacement())
|
|
2784
|
-
event.preventDefault();
|
|
2785
|
-
},
|
|
2786
|
-
children: [
|
|
2787
|
-
/* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Viewport, { className: "native-docx-viewport", children: [
|
|
2788
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Content, {}),
|
|
2789
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2790
|
-
DocxMentions,
|
|
2791
|
-
{
|
|
2792
|
-
initialCommentId,
|
|
2793
|
-
mentions: adapter.mentions,
|
|
2794
|
-
notify: adapter.notify,
|
|
2795
|
-
getAgentStatus: adapter.getAgentStatus,
|
|
2796
|
-
requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
|
|
2797
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(DocxCommentActivity, {}) }) })
|
|
2798
|
-
}
|
|
2799
|
-
),
|
|
2800
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HeaderFooterChrome, {}),
|
|
2801
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.NotesChrome, {}),
|
|
2802
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Equation, {}),
|
|
2803
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HyperLink, {}),
|
|
2804
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.ContextMenu, {})
|
|
2805
|
-
] }),
|
|
2806
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.PageNumber, {})
|
|
2807
|
-
]
|
|
2808
|
-
}
|
|
2809
|
-
)
|
|
2810
|
-
]
|
|
3336
|
+
]
|
|
3337
|
+
}
|
|
3338
|
+
)
|
|
2811
3339
|
}
|
|
2812
3340
|
)
|
|
2813
3341
|
}
|
|
@@ -2904,6 +3432,7 @@ async function loadFonts(baseUrl) {
|
|
|
2904
3432
|
};
|
|
2905
3433
|
}
|
|
2906
3434
|
|
|
3435
|
+
exports.BUILTIN_TEMPLATE_NAME = BUILTIN_TEMPLATE_NAME;
|
|
2907
3436
|
exports.DEFAULT_DEFINED_TERMS_LABELS = DEFAULT_DEFINED_TERMS_LABELS;
|
|
2908
3437
|
exports.DEFINED_TERM_TRIGGER = DEFINED_TERM_TRIGGER;
|
|
2909
3438
|
exports.DefinedTermsProvider = DefinedTermsProvider;
|
|
@@ -2912,17 +3441,23 @@ exports.DocxEditorReview = DocxEditorReview;
|
|
|
2912
3441
|
exports.DocxMentions = DocxMentions;
|
|
2913
3442
|
exports.DocxParticipants = DocxParticipants;
|
|
2914
3443
|
exports.DocxRibbon = DocxRibbon;
|
|
3444
|
+
exports.HouseTemplateProvider = HouseTemplateProvider;
|
|
2915
3445
|
exports.NativeDocxEditor = NativeDocxEditor;
|
|
3446
|
+
exports.builtinHouseTemplate = builtinHouseTemplate;
|
|
3447
|
+
exports.contentPath = contentPath;
|
|
2916
3448
|
exports.editorPort = editorPort;
|
|
2917
3449
|
exports.findDefinitionsSection = findDefinitionsSection;
|
|
2918
3450
|
exports.insertDefinedTerm = insertDefinedTerm;
|
|
2919
3451
|
exports.loadDocxFonts = loadDocxFonts;
|
|
2920
3452
|
exports.normalizeDocxExport = normalizeDocxExport;
|
|
3453
|
+
exports.resolveHouseTemplate = resolveHouseTemplate;
|
|
2921
3454
|
exports.reviewModule = reviewModule;
|
|
3455
|
+
exports.templateFileName = templateFileName;
|
|
2922
3456
|
exports.updateDefinitions = updateDefinitions;
|
|
2923
3457
|
exports.useDefinedTerms = useDefinedTerms;
|
|
3458
|
+
exports.useHouseTemplate = useHouseTemplate;
|
|
2924
3459
|
exports.useReview = useReview;
|
|
2925
3460
|
exports.useReviewItem = useReviewItem;
|
|
2926
3461
|
exports.withDirectEditing = withDirectEditing;
|
|
2927
|
-
//# sourceMappingURL=chunk-
|
|
2928
|
-
//# sourceMappingURL=chunk-
|
|
3462
|
+
//# sourceMappingURL=chunk-MIMVRMKC.cjs.map
|
|
3463
|
+
//# sourceMappingURL=chunk-MIMVRMKC.cjs.map
|