@bendyline/docblocks-react 2.6.2 → 2.7.1
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/README.md +3 -10
- package/THIRD_PARTY_NOTICES.txt +4284 -3651
- package/dist/AiDiagrams-LFV4YU6W.js +13 -0
- package/dist/AiEditorAssistant-GN2KXKZD.js +786 -0
- package/dist/AudioExportDialog-F23QXNPB.js +253 -0
- package/dist/DocumentConflictDialog-5LRVIGXS.js +111 -0
- package/dist/ExportDialog-IMBVGRYG.js +9 -0
- package/dist/{ExportToolbarControls-QYLBRWM7.js → ExportToolbarControls-MUM6HM3K.js} +117 -49
- package/dist/{GitToolbarControl-O5AXBC6T.js → GitToolbarControl-B7KG4MFP.js} +6 -6
- package/dist/{GitUI-L5T3XHZG.js → GitUI-RCWUZVS6.js} +6 -6
- package/dist/PresentationMaker-W2JIBHRN.js +9 -0
- package/dist/QuickOpenDialog-2KK4SEBU.js +356 -0
- package/dist/Settings-DuXk6baH.d.ts +144 -0
- package/dist/ShareDialog-XUA2OVGI.js +292 -0
- package/dist/SpeechToolbarControl-OSQS7NVY.js +434 -0
- package/dist/TextFromNarration-XYRAB6O2.js +598 -0
- package/dist/WorkspaceSearchPanel-BKZJRPMY.js +334 -0
- package/dist/chunk-2IYBBFQX.js +201 -0
- package/dist/{chunk-LG6HAWCK.js → chunk-56KO2LYN.js} +35 -4
- package/dist/chunk-6B7G33D5.js +88 -0
- package/dist/chunk-ARATARVJ.js +40 -0
- package/dist/{chunk-ODYNOPC3.js → chunk-BCQZTWE5.js} +57 -17
- package/dist/{chunk-FMDLZ4ZG.js → chunk-BD54Z5XP.js} +12 -3
- package/dist/chunk-EA4BO6E4.js +73 -0
- package/dist/chunk-EPOLZNFD.js +518 -0
- package/dist/chunk-G4MFB3IO.js +208 -0
- package/dist/{chunk-MRUK56JS.js → chunk-GMA4KGGO.js} +7 -3
- package/dist/chunk-I44HKDQX.js +314 -0
- package/dist/chunk-K4I3NJFL.js +49 -0
- package/dist/chunk-KBDZDFPU.js +61 -0
- package/dist/{chunk-FNSRCCBC.js → chunk-KWG6UP5O.js} +0 -10
- package/dist/chunk-NAH52736.js +1884 -0
- package/dist/chunk-RP3DVNTI.js +62 -0
- package/dist/chunk-SPUPWCSI.js +111 -0
- package/dist/chunk-TBLZBNQF.js +25 -0
- package/dist/{chunk-M5Y5WO7Z.js → chunk-UG4G7PJ4.js} +1 -1
- package/dist/chunk-UONFWKJ7.js +22 -0
- package/dist/chunk-VO2JYYQZ.js +40 -0
- package/dist/chunk-W55E6TE2.js +1714 -0
- package/dist/chunk-X3DDTJKR.js +574 -0
- package/dist/{chunk-EBWYGTN7.js → chunk-X437UAF7.js} +6 -0
- package/dist/editor.d.ts +36 -1
- package/dist/editor.js +16 -1
- package/dist/export/index.d.ts +27 -11
- package/dist/export/index.js +11 -7
- package/dist/index.d.ts +100 -13
- package/dist/index.js +3927 -1638
- package/dist/proofing/index.js +11 -1
- package/dist/{run-export-I2XOVGG4.js → run-export-47X5FTYZ.js} +3 -3
- package/dist/settings/index.d.ts +32 -101
- package/dist/settings/index.js +14 -2
- package/package.json +9 -9
- package/src/styles/docblocks.css +2344 -657
- package/dist/ExportDialog-Q4VWI43H.js +0 -9
- package/dist/ShareDialog-4OX3UPJ4.js +0 -359
- package/dist/chunk-JDJVRDOP.js +0 -92
- package/dist/chunk-Q6XNIKDG.js +0 -669
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildSharedDocumentQrUrl,
|
|
3
|
+
buildSharedDocumentUrl,
|
|
4
|
+
createSharedDocumentArchive,
|
|
5
|
+
sharedDocumentQrFilename
|
|
6
|
+
} from "./chunk-SPUPWCSI.js";
|
|
7
|
+
import {
|
|
8
|
+
Dialog
|
|
9
|
+
} from "./chunk-56KO2LYN.js";
|
|
10
|
+
|
|
11
|
+
// src/Export/ShareDialog.tsx
|
|
12
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
13
|
+
import { SHARED_DOCUMENT_LIMITS } from "@bendyline/docblocks/share";
|
|
14
|
+
|
|
15
|
+
// src/Export/share-qr.ts
|
|
16
|
+
import QRCode from "qrcode";
|
|
17
|
+
async function renderSharedDocumentQrPng(url) {
|
|
18
|
+
return QRCode.toDataURL(url, {
|
|
19
|
+
type: "image/png",
|
|
20
|
+
errorCorrectionLevel: "M",
|
|
21
|
+
margin: 4,
|
|
22
|
+
width: 1024,
|
|
23
|
+
color: {
|
|
24
|
+
dark: "#111111ff",
|
|
25
|
+
light: "#ffffffff"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function qrPngDataUrlToBlob(dataUrl) {
|
|
30
|
+
const prefix = "data:image/png;base64,";
|
|
31
|
+
if (!dataUrl.startsWith(prefix)) {
|
|
32
|
+
throw new Error("The QR code renderer returned an unsupported image format.");
|
|
33
|
+
}
|
|
34
|
+
const binary = atob(dataUrl.slice(prefix.length));
|
|
35
|
+
const bytes = new Uint8Array(binary.length);
|
|
36
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
37
|
+
bytes[index] = binary.charCodeAt(index);
|
|
38
|
+
}
|
|
39
|
+
return new Blob([bytes], { type: "image/png" });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/Export/ShareDialog.tsx
|
|
43
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
44
|
+
var MODES = [
|
|
45
|
+
{ value: "", label: "Write (no default)" },
|
|
46
|
+
{ value: "slideshow", label: "Slideshow" },
|
|
47
|
+
{ value: "video", label: "Video" },
|
|
48
|
+
{ value: "page", label: "Page" },
|
|
49
|
+
{ value: "document", label: "Document" },
|
|
50
|
+
{ value: "narrate", label: "Narrate" }
|
|
51
|
+
];
|
|
52
|
+
function ShareDialog({
|
|
53
|
+
markdown,
|
|
54
|
+
selectedFile,
|
|
55
|
+
baseUrl,
|
|
56
|
+
onClose
|
|
57
|
+
}) {
|
|
58
|
+
const [mode, setMode] = useState("");
|
|
59
|
+
const [archive, setArchive] = useState(null);
|
|
60
|
+
const [archiveError, setArchiveError] = useState(null);
|
|
61
|
+
const [copyStatus, setCopyStatus] = useState("idle");
|
|
62
|
+
const [qrDataUrl, setQrDataUrl] = useState(null);
|
|
63
|
+
const [qrRenderError, setQrRenderError] = useState(null);
|
|
64
|
+
const [qrCopyStatus, setQrCopyStatus] = useState("idle");
|
|
65
|
+
const linkRef = useRef(null);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
let cancelled = false;
|
|
68
|
+
setArchive(null);
|
|
69
|
+
setArchiveError(null);
|
|
70
|
+
void createSharedDocumentArchive(markdown, selectedFile).then((nextArchive) => {
|
|
71
|
+
if (!cancelled) setArchive(nextArchive);
|
|
72
|
+
}).catch((error) => {
|
|
73
|
+
if (!cancelled) {
|
|
74
|
+
setArchiveError(
|
|
75
|
+
error instanceof Error ? error.message : "DocBlocks could not create the shared link."
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return () => {
|
|
80
|
+
cancelled = true;
|
|
81
|
+
};
|
|
82
|
+
}, [markdown, selectedFile]);
|
|
83
|
+
const linkResult = useMemo(() => {
|
|
84
|
+
if (!archive) return { url: "", error: archiveError };
|
|
85
|
+
try {
|
|
86
|
+
return { url: buildSharedDocumentUrl(baseUrl, archive, mode || null), error: null };
|
|
87
|
+
} catch (error) {
|
|
88
|
+
return {
|
|
89
|
+
url: "",
|
|
90
|
+
error: error instanceof Error ? error.message : "DocBlocks could not create the shared link."
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}, [archive, archiveError, baseUrl, mode]);
|
|
94
|
+
const qrLinkResult = useMemo(() => {
|
|
95
|
+
if (!archive) return { url: "", error: archiveError };
|
|
96
|
+
try {
|
|
97
|
+
return { url: buildSharedDocumentQrUrl(archive, mode || null), error: null };
|
|
98
|
+
} catch (error) {
|
|
99
|
+
return {
|
|
100
|
+
url: "",
|
|
101
|
+
error: error instanceof Error ? error.message : "DocBlocks could not create the QR code."
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}, [archive, archiveError, mode]);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
let cancelled = false;
|
|
107
|
+
setQrDataUrl(null);
|
|
108
|
+
setQrRenderError(null);
|
|
109
|
+
setQrCopyStatus("idle");
|
|
110
|
+
if (!qrLinkResult.url) return;
|
|
111
|
+
void renderSharedDocumentQrPng(qrLinkResult.url).then((dataUrl) => {
|
|
112
|
+
if (!cancelled) setQrDataUrl(dataUrl);
|
|
113
|
+
}).catch((error) => {
|
|
114
|
+
if (!cancelled) {
|
|
115
|
+
setQrRenderError(
|
|
116
|
+
error instanceof Error ? error.message : "DocBlocks could not render the QR code."
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return () => {
|
|
121
|
+
cancelled = true;
|
|
122
|
+
};
|
|
123
|
+
}, [qrLinkResult.url]);
|
|
124
|
+
useEffect(() => setCopyStatus("idle"), [linkResult.url]);
|
|
125
|
+
const copyLink = useCallback(async () => {
|
|
126
|
+
if (!linkResult.url) return;
|
|
127
|
+
try {
|
|
128
|
+
if (navigator.clipboard?.writeText) {
|
|
129
|
+
await navigator.clipboard.writeText(linkResult.url);
|
|
130
|
+
} else {
|
|
131
|
+
linkRef.current?.focus();
|
|
132
|
+
linkRef.current?.select();
|
|
133
|
+
if (typeof document.execCommand !== "function" || !document.execCommand("copy")) {
|
|
134
|
+
throw new Error("Clipboard access is unavailable.");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
setCopyStatus("copied");
|
|
138
|
+
} catch {
|
|
139
|
+
linkRef.current?.focus();
|
|
140
|
+
linkRef.current?.select();
|
|
141
|
+
setCopyStatus("failed");
|
|
142
|
+
}
|
|
143
|
+
}, [linkResult.url]);
|
|
144
|
+
const copyQrImage = useCallback(async () => {
|
|
145
|
+
if (!qrDataUrl) return;
|
|
146
|
+
try {
|
|
147
|
+
if (!navigator.clipboard?.write || typeof ClipboardItem === "undefined") {
|
|
148
|
+
throw new Error("Image clipboard access is unavailable.");
|
|
149
|
+
}
|
|
150
|
+
const png = qrPngDataUrlToBlob(qrDataUrl);
|
|
151
|
+
await navigator.clipboard.write([new ClipboardItem({ "image/png": png })]);
|
|
152
|
+
setQrCopyStatus("copied");
|
|
153
|
+
} catch {
|
|
154
|
+
setQrCopyStatus("failed");
|
|
155
|
+
}
|
|
156
|
+
}, [qrDataUrl]);
|
|
157
|
+
const saveQrImage = useCallback(() => {
|
|
158
|
+
if (!qrDataUrl) return;
|
|
159
|
+
const download = document.createElement("a");
|
|
160
|
+
download.href = qrDataUrl;
|
|
161
|
+
download.download = sharedDocumentQrFilename(selectedFile);
|
|
162
|
+
download.style.display = "none";
|
|
163
|
+
document.body.append(download);
|
|
164
|
+
download.click();
|
|
165
|
+
download.remove();
|
|
166
|
+
}, [qrDataUrl, selectedFile]);
|
|
167
|
+
const isLong = linkResult.url.length > SHARED_DOCUMENT_LIMITS.portableUrlCharacters;
|
|
168
|
+
const qrError = qrLinkResult.error ?? qrRenderError;
|
|
169
|
+
return /* @__PURE__ */ jsxs(
|
|
170
|
+
Dialog,
|
|
171
|
+
{
|
|
172
|
+
title: "Share document",
|
|
173
|
+
onClose,
|
|
174
|
+
className: "db-export-dialog db-share-dialog",
|
|
175
|
+
footerClassName: "db-export-footer",
|
|
176
|
+
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
"button",
|
|
179
|
+
{
|
|
180
|
+
className: "db-export-btn db-export-btn--secondary",
|
|
181
|
+
type: "button",
|
|
182
|
+
onClick: onClose,
|
|
183
|
+
children: "Close"
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ jsx(
|
|
187
|
+
"button",
|
|
188
|
+
{
|
|
189
|
+
className: "db-export-btn db-export-btn--primary",
|
|
190
|
+
type: "button",
|
|
191
|
+
onClick: () => void copyLink(),
|
|
192
|
+
disabled: !linkResult.url,
|
|
193
|
+
children: copyStatus === "copied" ? "Copied" : copyStatus === "failed" ? "Select and copy" : "Copy link"
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] }),
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ jsx("div", { className: "db-share-warning", role: "note", children: "The text and formatting of this document are embedded in the URL. Anyone with the link can read the shared copy, so do not use it for secrets." }),
|
|
199
|
+
/* @__PURE__ */ jsx("p", { className: "db-export-hint", role: "note", children: "Images are excluded from share links. Image descriptions are kept when available. Your original document is unchanged." }),
|
|
200
|
+
/* @__PURE__ */ jsxs("div", { className: "db-export-field", children: [
|
|
201
|
+
/* @__PURE__ */ jsx("label", { className: "db-export-label", htmlFor: "db-share-mode", children: "Default mode (optional)" }),
|
|
202
|
+
/* @__PURE__ */ jsx(
|
|
203
|
+
"select",
|
|
204
|
+
{
|
|
205
|
+
id: "db-share-mode",
|
|
206
|
+
className: "db-export-select",
|
|
207
|
+
value: mode,
|
|
208
|
+
onChange: (event) => setMode(event.target.value),
|
|
209
|
+
children: MODES.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value || "write"))
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ jsx("span", { className: "db-export-hint", children: "Without a default, the copied document opens in Write. Other choices open directly in Use." })
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ jsxs("div", { className: "db-export-field", children: [
|
|
215
|
+
/* @__PURE__ */ jsx("label", { className: "db-export-label", htmlFor: "db-share-link", children: "Share link" }),
|
|
216
|
+
/* @__PURE__ */ jsx(
|
|
217
|
+
"textarea",
|
|
218
|
+
{
|
|
219
|
+
ref: linkRef,
|
|
220
|
+
id: "db-share-link",
|
|
221
|
+
className: "db-share-link",
|
|
222
|
+
value: linkResult.url,
|
|
223
|
+
readOnly: true,
|
|
224
|
+
rows: 3,
|
|
225
|
+
spellCheck: false,
|
|
226
|
+
"aria-describedby": "db-share-link-status",
|
|
227
|
+
placeholder: linkResult.error ? "" : "Creating link..."
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
/* @__PURE__ */ jsx(
|
|
231
|
+
"span",
|
|
232
|
+
{
|
|
233
|
+
id: "db-share-link-status",
|
|
234
|
+
className: `db-export-hint${isLong ? " db-share-length-warning" : ""}`,
|
|
235
|
+
children: linkResult.error ? linkResult.error : linkResult.url ? isLong ? `${linkResult.url.length.toLocaleString()} characters. Links longer than 4,096 characters may be truncated by messaging or email tools.` : `${linkResult.url.length.toLocaleString()} characters.` : "Creating a link with the shared text and formatting..."
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
] }),
|
|
239
|
+
/* @__PURE__ */ jsxs("section", { className: "db-share-qr", "aria-labelledby": "db-share-qr-title", children: [
|
|
240
|
+
/* @__PURE__ */ jsxs("div", { className: "db-share-qr-heading", children: [
|
|
241
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
242
|
+
/* @__PURE__ */ jsx("h3", { id: "db-share-qr-title", children: "QR code" }),
|
|
243
|
+
/* @__PURE__ */ jsx("span", { className: "db-export-hint", children: "A self-contained docblocks.com link to the shared text. No document content is uploaded." })
|
|
244
|
+
] }),
|
|
245
|
+
/* @__PURE__ */ jsxs("div", { className: "db-share-qr-actions", children: [
|
|
246
|
+
/* @__PURE__ */ jsx(
|
|
247
|
+
"button",
|
|
248
|
+
{
|
|
249
|
+
className: "db-export-btn db-export-btn--secondary",
|
|
250
|
+
type: "button",
|
|
251
|
+
onClick: () => void copyQrImage(),
|
|
252
|
+
disabled: !qrDataUrl,
|
|
253
|
+
children: qrCopyStatus === "copied" ? "Copied QR" : qrCopyStatus === "failed" ? "Copy unavailable" : "Copy QR image"
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
/* @__PURE__ */ jsx(
|
|
257
|
+
"button",
|
|
258
|
+
{
|
|
259
|
+
className: "db-export-btn db-export-btn--secondary",
|
|
260
|
+
type: "button",
|
|
261
|
+
onClick: saveQrImage,
|
|
262
|
+
disabled: !qrDataUrl,
|
|
263
|
+
children: "Save QR PNG"
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
] })
|
|
267
|
+
] }),
|
|
268
|
+
qrDataUrl ? /* @__PURE__ */ jsx(
|
|
269
|
+
"img",
|
|
270
|
+
{
|
|
271
|
+
className: "db-share-qr-image",
|
|
272
|
+
src: qrDataUrl,
|
|
273
|
+
alt: "QR code for this shared DocBlocks document"
|
|
274
|
+
}
|
|
275
|
+
) : /* @__PURE__ */ jsx(
|
|
276
|
+
"div",
|
|
277
|
+
{
|
|
278
|
+
className: `db-share-qr-placeholder${qrError ? " db-share-qr-placeholder--error" : ""}`,
|
|
279
|
+
role: qrError ? "note" : "status",
|
|
280
|
+
children: qrError ?? "Rendering QR code..."
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
/* @__PURE__ */ jsx("span", { className: "db-export-hint db-share-qr-status", "aria-live": "polite", children: qrCopyStatus === "failed" ? "This browser could not copy the PNG. Save it instead." : qrDataUrl ? `${qrLinkResult.url.length.toLocaleString()} of ${SHARED_DOCUMENT_LIMITS.qrUrlCharacters.toLocaleString()} supported QR characters.` : "" })
|
|
284
|
+
] }),
|
|
285
|
+
/* @__PURE__ */ jsx("p", { className: "db-share-temporary-note", children: "Opening the link creates a temporary workspace. Changes there do not alter this document or the link." })
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
export {
|
|
291
|
+
ShareDialog
|
|
292
|
+
};
|