@arbidocs/blocks 0.4.96 → 0.4.97
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-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-CK6TU76J.cjs → chunk-EHB7J6SR.cjs} +5 -5
- package/dist/{chunk-CK6TU76J.cjs.map → chunk-EHB7J6SR.cjs.map} +1 -1
- package/dist/{chunk-SC33PQTQ.cjs → chunk-GVOTXXZG.cjs} +5 -5
- package/dist/{chunk-SC33PQTQ.cjs.map → chunk-GVOTXXZG.cjs.map} +1 -1
- package/dist/{chunk-7RI3G5BO.cjs → chunk-HGJGALLN.cjs} +296 -53
- package/dist/chunk-HGJGALLN.cjs.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-SF4BDUZS.js → chunk-PGDL26TQ.js} +3 -3
- package/dist/{chunk-SF4BDUZS.js.map → chunk-PGDL26TQ.js.map} +1 -1
- package/dist/{chunk-K27SDLLN.js → chunk-QIEEFBZ5.js} +299 -56
- package/dist/chunk-QIEEFBZ5.js.map +1 -0
- package/dist/{chunk-Y52CEKVD.js → chunk-RSUOOMPT.js} +3 -3
- package/dist/{chunk-Y52CEKVD.js.map → chunk-RSUOOMPT.js.map} +1 -1
- package/dist/{chunk-H4SVY5FH.js → chunk-YH6SSJDW.js} +3 -3
- package/dist/{chunk-H4SVY5FH.js.map → chunk-YH6SSJDW.js.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/RibbonMenu.d.ts +15 -0
- package/dist/docx/StyleGallery.d.ts +9 -0
- package/dist/docx/WordReferences.d.ts +21 -0
- package/dist/docx/index.cjs +24 -24
- package/dist/docx/index.js +3 -3
- package/dist/docx/wordStyles.d.ts +21 -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 +91 -0
- package/dist/chunk-7RI3G5BO.cjs.map +0 -1
- package/dist/chunk-K27SDLLN.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
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, Superscript, NotebookText } from 'lucide-react';
|
|
10
10
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
12
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
@@ -2209,57 +2209,12 @@ var WordDraftStream = class {
|
|
|
2209
2209
|
}
|
|
2210
2210
|
}
|
|
2211
2211
|
};
|
|
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
2212
|
function RibbonMenu({
|
|
2260
2213
|
label,
|
|
2261
2214
|
icon,
|
|
2262
|
-
children
|
|
2215
|
+
children,
|
|
2216
|
+
className,
|
|
2217
|
+
testId
|
|
2263
2218
|
}) {
|
|
2264
2219
|
const [open, setOpen] = useState(false);
|
|
2265
2220
|
const element = useRef(null);
|
|
@@ -2283,10 +2238,11 @@ function RibbonMenu({
|
|
|
2283
2238
|
"button",
|
|
2284
2239
|
{
|
|
2285
2240
|
type: "button",
|
|
2286
|
-
className: "native-docx-ribbon-trigger",
|
|
2241
|
+
className: ["native-docx-ribbon-trigger", className].filter(Boolean).join(" "),
|
|
2287
2242
|
"aria-label": label,
|
|
2288
2243
|
title: label,
|
|
2289
2244
|
"aria-expanded": open,
|
|
2245
|
+
"data-testid": testId,
|
|
2290
2246
|
onMouseDown: (event) => event.preventDefault(),
|
|
2291
2247
|
onClick: () => setOpen((value) => !value),
|
|
2292
2248
|
children: icon
|
|
@@ -2302,11 +2258,295 @@ function RibbonMenu({
|
|
|
2302
2258
|
if (!(event.target instanceof HTMLInputElement || event.target instanceof HTMLSelectElement))
|
|
2303
2259
|
event.preventDefault();
|
|
2304
2260
|
},
|
|
2305
|
-
children
|
|
2261
|
+
children: typeof children === "function" ? children(() => setOpen(false)) : children
|
|
2262
|
+
}
|
|
2263
|
+
)
|
|
2264
|
+
] });
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
// src/docx/wordStyles.ts
|
|
2268
|
+
var QUICK_STYLES = ["Normal", "Title", "heading 1", "heading 2", "heading 3"];
|
|
2269
|
+
function findStyle(options, name) {
|
|
2270
|
+
const wanted = name.toLowerCase();
|
|
2271
|
+
const id = name.replace(/(^|\s)(\w)/g, (_, _s, c) => c.toUpperCase());
|
|
2272
|
+
return options.find((o) => o.name.toLowerCase() === wanted) ?? options.find((o) => o.styleId.toLowerCase() === id.toLowerCase());
|
|
2273
|
+
}
|
|
2274
|
+
function styleLabel(name) {
|
|
2275
|
+
return name === name.toLowerCase() ? name.replace(/(^|\s)(\w)/g, (m) => m.toUpperCase()) : name;
|
|
2276
|
+
}
|
|
2277
|
+
function wordShortcut(event) {
|
|
2278
|
+
const mod = event.ctrlKey || event.metaKey;
|
|
2279
|
+
if (!mod) return null;
|
|
2280
|
+
if (event.altKey && !event.shiftKey) {
|
|
2281
|
+
switch (event.code) {
|
|
2282
|
+
case "KeyF":
|
|
2283
|
+
return "footnote";
|
|
2284
|
+
case "KeyD":
|
|
2285
|
+
return "endnote";
|
|
2286
|
+
case "Digit1":
|
|
2287
|
+
case "Numpad1":
|
|
2288
|
+
return "heading 1";
|
|
2289
|
+
case "Digit2":
|
|
2290
|
+
case "Numpad2":
|
|
2291
|
+
return "heading 2";
|
|
2292
|
+
case "Digit3":
|
|
2293
|
+
case "Numpad3":
|
|
2294
|
+
return "heading 3";
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
if (event.shiftKey && !event.altKey && event.code === "KeyN") return "Normal";
|
|
2298
|
+
return null;
|
|
2299
|
+
}
|
|
2300
|
+
var FILTER_FROM = 8;
|
|
2301
|
+
function previewStyle(option) {
|
|
2302
|
+
const { fontFamily, fontSizePt, bold, italic, color } = option.preview;
|
|
2303
|
+
return {
|
|
2304
|
+
fontFamily: fontFamily ? `"${fontFamily}", serif` : void 0,
|
|
2305
|
+
// In the face of the style, but within a row: 9-18pt.
|
|
2306
|
+
fontSize: fontSizePt ? `${Math.min(18, Math.max(9, fontSizePt))}pt` : void 0,
|
|
2307
|
+
fontWeight: bold ? 700 : void 0,
|
|
2308
|
+
fontStyle: italic ? "italic" : void 0,
|
|
2309
|
+
color: color ? `#${color}` : void 0
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
function Gallery({ close }) {
|
|
2313
|
+
const { value, setValue, options, isEnabled } = useParagraphStyle();
|
|
2314
|
+
const editor = useDocxEditor();
|
|
2315
|
+
const [query, setQuery] = useState("");
|
|
2316
|
+
const quick = useMemo(
|
|
2317
|
+
() => QUICK_STYLES.map((name) => findStyle(options, name)).filter(
|
|
2318
|
+
(o) => !!o
|
|
2319
|
+
),
|
|
2320
|
+
[options]
|
|
2321
|
+
);
|
|
2322
|
+
const shown = useMemo(() => {
|
|
2323
|
+
const q = query.trim().toLowerCase();
|
|
2324
|
+
return q ? options.filter(
|
|
2325
|
+
(o) => o.name.toLowerCase().includes(q) || o.styleId.toLowerCase().includes(q)
|
|
2326
|
+
) : options;
|
|
2327
|
+
}, [options, query]);
|
|
2328
|
+
const apply = (option) => {
|
|
2329
|
+
setValue(option.styleId);
|
|
2330
|
+
close();
|
|
2331
|
+
editor?.surface?.focus();
|
|
2332
|
+
};
|
|
2333
|
+
const nav = useListKeyNav({
|
|
2334
|
+
open: true,
|
|
2335
|
+
items: shown,
|
|
2336
|
+
onPick: apply,
|
|
2337
|
+
onDismiss: close,
|
|
2338
|
+
resetKey: query
|
|
2339
|
+
});
|
|
2340
|
+
return /* @__PURE__ */ jsxs("div", { className: "native-docx-style-gallery", "data-testid": "docx-style-gallery", children: [
|
|
2341
|
+
quick.length > 0 && /* @__PURE__ */ jsx("div", { className: "native-docx-style-quick", role: "group", "aria-label": "Quick styles", children: quick.map((option) => /* @__PURE__ */ jsx(
|
|
2342
|
+
"button",
|
|
2343
|
+
{
|
|
2344
|
+
type: "button",
|
|
2345
|
+
"aria-pressed": value === option.styleId,
|
|
2346
|
+
disabled: !isEnabled,
|
|
2347
|
+
"data-style-id": option.styleId,
|
|
2348
|
+
title: styleLabel(option.name),
|
|
2349
|
+
onClick: () => apply(option),
|
|
2350
|
+
children: /* @__PURE__ */ jsx("span", { style: previewStyle(option), children: styleLabel(option.name) })
|
|
2351
|
+
},
|
|
2352
|
+
option.styleId
|
|
2353
|
+
)) }),
|
|
2354
|
+
options.length > FILTER_FROM && /* @__PURE__ */ jsx(
|
|
2355
|
+
"input",
|
|
2356
|
+
{
|
|
2357
|
+
className: "native-docx-style-filter",
|
|
2358
|
+
placeholder: "Find a style",
|
|
2359
|
+
"aria-label": "Find a style",
|
|
2360
|
+
value: query,
|
|
2361
|
+
autoFocus: true,
|
|
2362
|
+
onChange: (event) => setQuery(event.target.value),
|
|
2363
|
+
onKeyDown: (event) => {
|
|
2364
|
+
nav.handleKeyDown(event);
|
|
2365
|
+
},
|
|
2366
|
+
...nav.comboboxProps
|
|
2367
|
+
}
|
|
2368
|
+
),
|
|
2369
|
+
/* @__PURE__ */ jsxs(
|
|
2370
|
+
"ul",
|
|
2371
|
+
{
|
|
2372
|
+
className: "native-docx-style-list",
|
|
2373
|
+
role: "listbox",
|
|
2374
|
+
id: nav.listboxId,
|
|
2375
|
+
"aria-label": "Document styles",
|
|
2376
|
+
children: [
|
|
2377
|
+
shown.map((option, index) => /* @__PURE__ */ jsx(
|
|
2378
|
+
"li",
|
|
2379
|
+
{
|
|
2380
|
+
id: listOptionId(nav.listboxId, index),
|
|
2381
|
+
role: "option",
|
|
2382
|
+
"aria-selected": value === option.styleId,
|
|
2383
|
+
"aria-disabled": !isEnabled,
|
|
2384
|
+
"data-active": index === nav.selectedIndex || void 0,
|
|
2385
|
+
"data-style-id": option.styleId,
|
|
2386
|
+
onMouseEnter: () => nav.setSelectedIndex(index),
|
|
2387
|
+
onClick: () => isEnabled && apply(option),
|
|
2388
|
+
children: /* @__PURE__ */ jsx("span", { style: previewStyle(option), children: styleLabel(option.name) })
|
|
2389
|
+
},
|
|
2390
|
+
option.styleId
|
|
2391
|
+
)),
|
|
2392
|
+
shown.length === 0 && /* @__PURE__ */ jsx("li", { className: "native-docx-style-empty", children: "No matching style" })
|
|
2393
|
+
]
|
|
2306
2394
|
}
|
|
2307
2395
|
)
|
|
2308
2396
|
] });
|
|
2309
2397
|
}
|
|
2398
|
+
function StyleGallery() {
|
|
2399
|
+
const { value, options } = useParagraphStyle();
|
|
2400
|
+
const current = options.find((o) => o.styleId === value);
|
|
2401
|
+
const name = current ? styleLabel(current.name) : "Styles";
|
|
2402
|
+
return /* @__PURE__ */ jsx(
|
|
2403
|
+
RibbonMenu,
|
|
2404
|
+
{
|
|
2405
|
+
label: "Styles",
|
|
2406
|
+
className: "native-docx-style-trigger",
|
|
2407
|
+
testId: "docx-style-trigger",
|
|
2408
|
+
icon: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2409
|
+
/* @__PURE__ */ jsx("span", { className: "native-docx-style-current", "data-testid": "docx-current-style", children: name }),
|
|
2410
|
+
/* @__PURE__ */ jsx(ChevronDown, { size: 12, "aria-hidden": true })
|
|
2411
|
+
] }),
|
|
2412
|
+
children: (close) => /* @__PURE__ */ jsx(Gallery, { close })
|
|
2413
|
+
}
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
function useInsertNote(kind) {
|
|
2417
|
+
const command = useEditorCommand(kind === "footnote" ? "insert.footnote" : "insert.endnote");
|
|
2418
|
+
const { options } = useParagraphStyle();
|
|
2419
|
+
const editor = useDocxEditor();
|
|
2420
|
+
const insert = () => {
|
|
2421
|
+
if (!command.execute()) return false;
|
|
2422
|
+
const text = findStyle(options, `${kind} text`);
|
|
2423
|
+
if (text && editor)
|
|
2424
|
+
withDirectEditing(
|
|
2425
|
+
editor,
|
|
2426
|
+
() => editor.exec({ type: "setParagraphStyle", styleId: text.styleId })
|
|
2427
|
+
);
|
|
2428
|
+
return true;
|
|
2429
|
+
};
|
|
2430
|
+
return { insert, isEnabled: command.isEnabled, disabledReason: command.disabledReason };
|
|
2431
|
+
}
|
|
2432
|
+
function NoteAction({
|
|
2433
|
+
kind,
|
|
2434
|
+
label,
|
|
2435
|
+
shortcut,
|
|
2436
|
+
icon
|
|
2437
|
+
}) {
|
|
2438
|
+
const note = useInsertNote(kind);
|
|
2439
|
+
return /* @__PURE__ */ jsx(
|
|
2440
|
+
DocxEditor.Toolbar.Action,
|
|
2441
|
+
{
|
|
2442
|
+
label: `${label} (${shortcut})`,
|
|
2443
|
+
icon,
|
|
2444
|
+
disabled: !note.isEnabled,
|
|
2445
|
+
disabledReason: note.disabledReason ?? void 0,
|
|
2446
|
+
onSelect: () => void note.insert(),
|
|
2447
|
+
className: `native-docx-insert-${kind}`
|
|
2448
|
+
}
|
|
2449
|
+
);
|
|
2450
|
+
}
|
|
2451
|
+
function NoteButtons() {
|
|
2452
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2453
|
+
/* @__PURE__ */ jsx(
|
|
2454
|
+
NoteAction,
|
|
2455
|
+
{
|
|
2456
|
+
kind: "footnote",
|
|
2457
|
+
label: "Insert footnote",
|
|
2458
|
+
shortcut: "Ctrl+Alt+F",
|
|
2459
|
+
icon: /* @__PURE__ */ jsx(Superscript, { size: 16 })
|
|
2460
|
+
}
|
|
2461
|
+
),
|
|
2462
|
+
/* @__PURE__ */ jsx(
|
|
2463
|
+
NoteAction,
|
|
2464
|
+
{
|
|
2465
|
+
kind: "endnote",
|
|
2466
|
+
label: "Insert endnote",
|
|
2467
|
+
shortcut: "Ctrl+Alt+D",
|
|
2468
|
+
icon: /* @__PURE__ */ jsx(NotebookText, { size: 16 })
|
|
2469
|
+
}
|
|
2470
|
+
)
|
|
2471
|
+
] });
|
|
2472
|
+
}
|
|
2473
|
+
function WordShortcuts({ scope }) {
|
|
2474
|
+
const footnote = useInsertNote("footnote");
|
|
2475
|
+
const endnote = useInsertNote("endnote");
|
|
2476
|
+
const styles = useParagraphStyle();
|
|
2477
|
+
const editor = useDocxEditor();
|
|
2478
|
+
const latest = useRef({ footnote, endnote, styles, editor });
|
|
2479
|
+
latest.current = { footnote, endnote, styles, editor };
|
|
2480
|
+
useEffect(() => {
|
|
2481
|
+
const element = scope.current;
|
|
2482
|
+
if (!element) return;
|
|
2483
|
+
const onKeyDown = (event) => {
|
|
2484
|
+
const action = wordShortcut(event);
|
|
2485
|
+
if (!action) return;
|
|
2486
|
+
const { footnote: footnote2, endnote: endnote2, styles: styles2, editor: editor2 } = latest.current;
|
|
2487
|
+
if (action === "footnote" || action === "endnote") {
|
|
2488
|
+
if (!(action === "footnote" ? footnote2 : endnote2).insert()) return;
|
|
2489
|
+
} else {
|
|
2490
|
+
const style = findStyle(styles2.options, action);
|
|
2491
|
+
if (!style) return;
|
|
2492
|
+
styles2.setValue(style.styleId);
|
|
2493
|
+
}
|
|
2494
|
+
event.preventDefault();
|
|
2495
|
+
event.stopPropagation();
|
|
2496
|
+
editor2?.surface?.focus();
|
|
2497
|
+
};
|
|
2498
|
+
element.addEventListener("keydown", onKeyDown, true);
|
|
2499
|
+
return () => element.removeEventListener("keydown", onKeyDown, true);
|
|
2500
|
+
}, [scope]);
|
|
2501
|
+
return null;
|
|
2502
|
+
}
|
|
2503
|
+
function contentPath(documentId) {
|
|
2504
|
+
const match = /^(doc-[A-Za-z0-9]+)@v([1-9][0-9]*)$/.exec(documentId);
|
|
2505
|
+
return match ? `/${encodeURIComponent(match[1])}/content?version=${match[2]}` : `/${encodeURIComponent(documentId)}/content`;
|
|
2506
|
+
}
|
|
2507
|
+
var drafts = /* @__PURE__ */ new Map();
|
|
2508
|
+
var stateBytes = (room) => Y.encodeStateAsUpdate(room.ydoc);
|
|
2509
|
+
var encodeState = (room) => {
|
|
2510
|
+
let binary = "";
|
|
2511
|
+
for (const byte of stateBytes(room)) binary += String.fromCharCode(byte);
|
|
2512
|
+
return btoa(binary);
|
|
2513
|
+
};
|
|
2514
|
+
function covered(room, vector, receipt) {
|
|
2515
|
+
const decode = (value) => Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
|
|
2516
|
+
const server = Y.decodeStateVector(decode(vector)), local = Y.decodeStateVector(Y.encodeStateVector(room.ydoc));
|
|
2517
|
+
for (const [client, clock] of local) if ((server.get(client) || 0) < clock) return false;
|
|
2518
|
+
const deleted = Y.decodeUpdate(stateBytes(room)).ds.clients;
|
|
2519
|
+
const saved = Y.decodeUpdate(decode(receipt)).ds.clients;
|
|
2520
|
+
for (const [client, ranges] of deleted)
|
|
2521
|
+
for (const range of ranges) {
|
|
2522
|
+
if (!(saved.get(client) || []).some(
|
|
2523
|
+
(s) => s.clock <= range.clock && s.clock + s.len >= range.clock + range.len
|
|
2524
|
+
))
|
|
2525
|
+
return false;
|
|
2526
|
+
}
|
|
2527
|
+
return true;
|
|
2528
|
+
}
|
|
2529
|
+
var EditorBoundary = class extends React3.Component {
|
|
2530
|
+
state = {};
|
|
2531
|
+
static getDerivedStateFromError(error) {
|
|
2532
|
+
return { error };
|
|
2533
|
+
}
|
|
2534
|
+
render() {
|
|
2535
|
+
return this.state.error ? /* @__PURE__ */ jsxs("div", { role: "alert", className: "native-docx-error", children: [
|
|
2536
|
+
"Could not render this Word document: ",
|
|
2537
|
+
this.state.error.message
|
|
2538
|
+
] }) : this.props.children;
|
|
2539
|
+
}
|
|
2540
|
+
};
|
|
2541
|
+
function DocxParticipants({ session }) {
|
|
2542
|
+
const [people, setPeople] = useState([]);
|
|
2543
|
+
useEffect(() => {
|
|
2544
|
+
if (!session) return;
|
|
2545
|
+
setPeople(session.participants());
|
|
2546
|
+
return session.subscribeParticipants(setPeople);
|
|
2547
|
+
}, [session]);
|
|
2548
|
+
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)) });
|
|
2549
|
+
}
|
|
2310
2550
|
function DefinedTermButtons() {
|
|
2311
2551
|
const terms = useDefinedTerms();
|
|
2312
2552
|
if (!terms) return null;
|
|
@@ -2349,6 +2589,7 @@ function DocxRibbon({
|
|
|
2349
2589
|
/* @__PURE__ */ jsxs("select", { "aria-label": "Ribbon tab", value: tab, onChange: (event) => setTab(event.target.value), children: [
|
|
2350
2590
|
/* @__PURE__ */ jsx("option", { children: "Home" }),
|
|
2351
2591
|
/* @__PURE__ */ jsx("option", { children: "Insert" }),
|
|
2592
|
+
/* @__PURE__ */ jsx("option", { children: "References" }),
|
|
2352
2593
|
/* @__PURE__ */ jsx("option", { children: "Review" })
|
|
2353
2594
|
] }),
|
|
2354
2595
|
/* @__PURE__ */ jsxs(DocxEditor.Toolbar, { t, preset: false, onSave, children: [
|
|
@@ -2356,6 +2597,7 @@ function DocxRibbon({
|
|
|
2356
2597
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Redo, {}),
|
|
2357
2598
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Save, {}),
|
|
2358
2599
|
tab === "Home" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2600
|
+
/* @__PURE__ */ jsx(StyleGallery, {}),
|
|
2359
2601
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Bold, {}),
|
|
2360
2602
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Italic, {}),
|
|
2361
2603
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Underline, {}),
|
|
@@ -2366,7 +2608,6 @@ function DocxRibbon({
|
|
|
2366
2608
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Highlight, {})
|
|
2367
2609
|
] }),
|
|
2368
2610
|
/* @__PURE__ */ jsxs(RibbonMenu, { label: "More formatting", icon: /* @__PURE__ */ jsx(Ellipsis, { size: 16 }), children: [
|
|
2369
|
-
/* @__PURE__ */ jsx(DocxEditor.Toolbar.StylePicker, {}),
|
|
2370
2611
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Alignment, {}),
|
|
2371
2612
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.BulletList, {}),
|
|
2372
2613
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.NumberedList, {}),
|
|
@@ -2383,6 +2624,7 @@ function DocxRibbon({
|
|
|
2383
2624
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Link, {}),
|
|
2384
2625
|
/* @__PURE__ */ jsx(DefinedTermButtons, {})
|
|
2385
2626
|
] }),
|
|
2627
|
+
tab === "References" && /* @__PURE__ */ jsx(NoteButtons, {}),
|
|
2386
2628
|
tab === "Review" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2387
2629
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.EditingMode, {}),
|
|
2388
2630
|
/* @__PURE__ */ jsx(DocxEditor.Toolbar.Comments, {}),
|
|
@@ -2749,6 +2991,7 @@ function NativeDocxEditor({
|
|
|
2749
2991
|
)
|
|
2750
2992
|
}
|
|
2751
2993
|
),
|
|
2994
|
+
!stream && /* @__PURE__ */ jsx(WordShortcuts, { scope: stageRef }),
|
|
2752
2995
|
/* @__PURE__ */ jsxs(
|
|
2753
2996
|
"div",
|
|
2754
2997
|
{
|
|
@@ -2880,5 +3123,5 @@ async function loadFonts(baseUrl) {
|
|
|
2880
3123
|
}
|
|
2881
3124
|
|
|
2882
3125
|
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-
|
|
3126
|
+
//# sourceMappingURL=chunk-QIEEFBZ5.js.map
|
|
3127
|
+
//# sourceMappingURL=chunk-QIEEFBZ5.js.map
|