@bendyline/docblocks-react 2.7.6 → 2.7.8
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/THIRD_PARTY_NOTICES.txt +205 -35
- package/dist/{AiDiagrams-VOCEZS6U.js → AiDiagrams-2IKKSBAU.js} +6 -4
- package/dist/{AiEditorAssistant-2MW6UYNI.js → AiEditorAssistant-ANYGVG7P.js} +128 -12
- package/dist/AiImagePanel-OXWEFOBC.js +314 -0
- package/dist/{AiStudyDialog-DQZVTBI7.js → AiStudyDialog-T3FY74HY.js} +3 -3
- package/dist/{AudioExportDialog-EICCBSSE.js → AudioExportDialog-CBMSLQBS.js} +1 -1
- package/dist/DocumentConflictDialog-4R4QMKBT.js +217 -0
- package/dist/{ExportDialog-LGWBXIWN.js → ExportDialog-FNFD53SY.js} +2 -2
- package/dist/{ExportToolbarControls-4LYTXGT3.js → ExportToolbarControls-ZOYH4I36.js} +146 -68
- package/dist/{GitUI-F3CNBURE.js → GitUI-3FANM7I3.js} +88 -155
- package/dist/{KeyboardShortcutsDialog-HVKDFP5Z.js → KeyboardShortcutsDialog-7XJTDIX2.js} +1 -1
- package/dist/{PresentationMaker-T526TBRJ.js → PresentationMaker-COLTVMTS.js} +3 -3
- package/dist/{QuickOpenDialog-3QEX7RZG.js → QuickOpenDialog-U2FWCEPA.js} +1 -1
- package/dist/{Settings-CfhY489G.d.ts → Settings-ButIB78y.d.ts} +20 -4
- package/dist/{ShareDialog-PF7D7ORP.js → ShareDialog-WOWHI6YI.js} +1 -1
- package/dist/{SpeechToolbarControl-E6OSJGHL.js → SpeechToolbarControl-BZW6IVZM.js} +1 -1
- package/dist/{TextFromNarration-ME6FAYWO.js → TextFromNarration-6BYTUKVZ.js} +2 -2
- package/dist/chunk-27E2OON2.js +90 -0
- package/dist/{chunk-5O5YTOXG.js → chunk-5YMULR6A.js} +13 -1
- package/dist/{chunk-NOYDVL6M.js → chunk-6QHZNL6C.js} +45 -17
- package/dist/{chunk-45YTIVYS.js → chunk-A7BK6QFL.js} +363 -26
- package/dist/{chunk-PRUEYW3G.js → chunk-BGA5UVKL.js} +58 -17
- package/dist/{chunk-T42BH6YX.js → chunk-CXLXGFG2.js} +37 -15
- package/dist/{chunk-7CSBRAMT.js → chunk-F7TR5EKX.js} +8 -6
- package/dist/chunk-HIKMOKBQ.js +37 -0
- package/dist/chunk-OW6JWRAA.js +66 -0
- package/dist/{chunk-BNKIPCXO.js → chunk-QXBV3G6T.js} +5 -3
- package/dist/{chunk-7HBKKXRV.js → chunk-TN7BY5N3.js} +722 -281
- package/dist/{chunk-VJPGZCFS.js → chunk-UYJCL6OW.js} +4 -2
- package/dist/{chunk-GFK4TCKN.js → chunk-WDNE5TI3.js} +21 -7
- package/dist/{chunk-KBUHWZCF.js → chunk-YX275NPE.js} +1 -1
- package/dist/editor.js +3 -3
- package/dist/export/index.d.ts +16 -162
- package/dist/export/index.js +6 -4
- package/dist/image-save-D18dJrUr.d.ts +182 -0
- package/dist/index.d.ts +15 -11
- package/dist/index.js +1365 -1078
- package/dist/{run-export-SPNNH32M.js → run-export-C3PLLWLS.js} +2 -2
- package/dist/settings/index.d.ts +1 -1
- package/dist/settings/index.js +3 -2
- package/package.json +8 -8
- package/src/styles/docblocks.css +349 -11
- package/dist/DocumentConflictDialog-DZ2BV2IH.js +0 -111
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/Git/GitDiffView.tsx
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import {
|
|
4
|
+
detectLanguageFromFileName,
|
|
5
|
+
useMonacoLoader
|
|
6
|
+
} from "@bendyline/squisq-editor-react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
function languageFor(fileName) {
|
|
9
|
+
const detected = detectLanguageFromFileName(fileName);
|
|
10
|
+
if (detected) return detected;
|
|
11
|
+
return fileName.toLowerCase().endsWith(".md") ? "markdown" : "plaintext";
|
|
12
|
+
}
|
|
13
|
+
function GitDiffView({
|
|
14
|
+
original,
|
|
15
|
+
modified,
|
|
16
|
+
fileName,
|
|
17
|
+
language: languageOverride,
|
|
18
|
+
theme,
|
|
19
|
+
layout = "auto",
|
|
20
|
+
changesOnly = false,
|
|
21
|
+
labels
|
|
22
|
+
}) {
|
|
23
|
+
const language = languageOverride ?? languageFor(fileName);
|
|
24
|
+
const loader = useMonacoLoader(language);
|
|
25
|
+
const monaco = loader.ready ? loader.monaco : null;
|
|
26
|
+
const hostRef = useRef(null);
|
|
27
|
+
const editorRef = useRef(null);
|
|
28
|
+
const modelsRef = useRef(null);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const host = hostRef.current;
|
|
31
|
+
if (!monaco || !host) return;
|
|
32
|
+
const originalModel = monaco.editor.createModel("", "plaintext");
|
|
33
|
+
const modifiedModel = monaco.editor.createModel("", "plaintext");
|
|
34
|
+
const editor = monaco.editor.createDiffEditor(host, {
|
|
35
|
+
readOnly: true,
|
|
36
|
+
automaticLayout: true,
|
|
37
|
+
minimap: { enabled: false },
|
|
38
|
+
wordWrap: "on",
|
|
39
|
+
scrollBeyondLastLine: false,
|
|
40
|
+
renderOverviewRuler: false
|
|
41
|
+
});
|
|
42
|
+
editor.setModel({ original: originalModel, modified: modifiedModel });
|
|
43
|
+
editorRef.current = editor;
|
|
44
|
+
modelsRef.current = { original: originalModel, modified: modifiedModel };
|
|
45
|
+
return () => {
|
|
46
|
+
editorRef.current = null;
|
|
47
|
+
modelsRef.current = null;
|
|
48
|
+
editor.dispose();
|
|
49
|
+
originalModel.dispose();
|
|
50
|
+
modifiedModel.dispose();
|
|
51
|
+
};
|
|
52
|
+
}, [monaco]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!monaco) return;
|
|
55
|
+
const models = modelsRef.current;
|
|
56
|
+
if (!models) return;
|
|
57
|
+
if (models.original.getValue() !== original) models.original.setValue(original);
|
|
58
|
+
if (models.modified.getValue() !== modified) models.modified.setValue(modified);
|
|
59
|
+
monaco.editor.setModelLanguage(models.original, language);
|
|
60
|
+
monaco.editor.setModelLanguage(models.modified, language);
|
|
61
|
+
}, [monaco, original, modified, language]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
editorRef.current?.updateOptions({
|
|
64
|
+
renderSideBySide: layout !== "inline",
|
|
65
|
+
useInlineViewWhenSpaceIsLimited: layout === "auto",
|
|
66
|
+
hideUnchangedRegions: { enabled: changesOnly },
|
|
67
|
+
// Inline turns wrapping off for the hidden original side, and Monaco
|
|
68
|
+
// (0.50) never turns it back on; side by side would show it clipped.
|
|
69
|
+
wordWrapOverride2: "inherit"
|
|
70
|
+
});
|
|
71
|
+
}, [monaco, layout, changesOnly]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!monaco) return;
|
|
74
|
+
monaco.editor.setTheme(theme === "dark" ? "vs-dark" : "vs");
|
|
75
|
+
}, [monaco, theme]);
|
|
76
|
+
if (!monaco) {
|
|
77
|
+
return /* @__PURE__ */ jsx("div", { className: "db-git-diff-loading", children: "Loading diff\u2026" });
|
|
78
|
+
}
|
|
79
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
+
labels && /* @__PURE__ */ jsxs("div", { className: "db-git-diff-labels", children: [
|
|
81
|
+
/* @__PURE__ */ jsx("span", { children: labels.original }),
|
|
82
|
+
/* @__PURE__ */ jsx("span", { children: labels.modified })
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ jsx("div", { ref: hostRef, className: "db-git-diff-host" })
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
GitDiffView
|
|
90
|
+
};
|
|
@@ -12,6 +12,18 @@ function buildExportFilename(selectedFile, options) {
|
|
|
12
12
|
return base + FORMAT_EXTENSIONS[options.format];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
// src/Export/export-errors.ts
|
|
16
|
+
var PdfReplacementsError = class extends Error {
|
|
17
|
+
constructor(replacements) {
|
|
18
|
+
super(
|
|
19
|
+
"PDF was not saved because its fonts cannot draw all of this document\u2019s text. Save it with the replacements, or export as Word, HTML, or EPUB to keep every character. " + replacements.join(" ")
|
|
20
|
+
);
|
|
21
|
+
this.name = "PdfReplacementsError";
|
|
22
|
+
this.replacements = replacements;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
15
26
|
export {
|
|
16
|
-
buildExportFilename
|
|
27
|
+
buildExportFilename,
|
|
28
|
+
PdfReplacementsError
|
|
17
29
|
};
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-KHQ44ZFA.js";
|
|
6
6
|
|
|
7
7
|
// src/Ai/AiKnowledgeIndicator.tsx
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
var QUIET_NOTES = {
|
|
10
10
|
none: "Your knowledge catalogs were searched, and nothing in them matched this request.",
|
|
11
11
|
skipped: "Your knowledge catalogs could not be searched for this request. A long document can leave no room for reference passages."
|
|
@@ -46,7 +46,7 @@ function AiKnowledgeIndicator({ knowledge }) {
|
|
|
46
46
|
] });
|
|
47
47
|
}
|
|
48
48
|
function markDetails(text, details) {
|
|
49
|
-
const terms = details.filter(Boolean).map((detail) => detail.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")).sort((a, b) => b.length - a.length);
|
|
49
|
+
const terms = details.map((detail) => detail.replace(/ next to .+$/u, "")).filter(Boolean).map((detail) => detail.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")).sort((a, b) => b.length - a.length);
|
|
50
50
|
if (terms.length === 0) return [text];
|
|
51
51
|
const pattern = new RegExp(
|
|
52
52
|
`(?<![\\p{L}\\p{N}])(${terms.join("|")})(?=(?:st|nd|rd|th)?(?![\\p{L}\\p{N}]))`,
|
|
@@ -75,7 +75,15 @@ function AiFactsIndicator({ check }) {
|
|
|
75
75
|
" to check"
|
|
76
76
|
] }),
|
|
77
77
|
/* @__PURE__ */ jsx("p", { children: "Neither your document, your instructions nor the reference passages show the marked details. The model may have written them from memory." }),
|
|
78
|
-
/* @__PURE__ */ jsx("ul", { children: check.unsourced.map((sentence, index) => /* @__PURE__ */ jsx("li", { children:
|
|
78
|
+
/* @__PURE__ */ jsx("ul", { children: check.unsourced.map((sentence, index) => /* @__PURE__ */ jsx("li", { children: sentence.problem === "bad-citation" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
79
|
+
sentence.text,
|
|
80
|
+
" ",
|
|
81
|
+
/* @__PURE__ */ jsxs("span", { className: "db-ai-facts-note", children: [
|
|
82
|
+
"It cites ",
|
|
83
|
+
sentence.missing.join(", "),
|
|
84
|
+
", which is not one of the reference passages."
|
|
85
|
+
] })
|
|
86
|
+
] }) : markDetails(sentence.text, sentence.missing) }, index)) })
|
|
79
87
|
] });
|
|
80
88
|
}
|
|
81
89
|
|
|
@@ -101,19 +109,33 @@ function mergeAiKnowledge(current, next) {
|
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
const evidence = [...current.evidence];
|
|
104
|
-
for (const
|
|
112
|
+
for (const passage of next.evidence) {
|
|
113
|
+
if (!evidence.some((known) => known.text === passage.text)) evidence.push(passage);
|
|
114
|
+
}
|
|
105
115
|
return { outcome: "used", sources, evidence };
|
|
106
116
|
}
|
|
117
|
+
function sameEvidence(a, b) {
|
|
118
|
+
return a.length === b.length && a.every((passage, index) => passage.text === b[index]?.text);
|
|
119
|
+
}
|
|
120
|
+
function numberingHolds(current, next) {
|
|
121
|
+
return current?.outcome !== "used" || next.outcome !== "used" || sameEvidence(current.evidence, next.evidence);
|
|
122
|
+
}
|
|
107
123
|
function useAiKnowledge(ai) {
|
|
108
|
-
const [
|
|
124
|
+
const [run, setRun] = useState({
|
|
125
|
+
knowledge: null,
|
|
126
|
+
citable: true
|
|
127
|
+
});
|
|
109
128
|
const runRef = useRef(0);
|
|
110
129
|
const helpers = useMemo(() => {
|
|
111
130
|
const tapped = {
|
|
112
131
|
chat(request, onEvent) {
|
|
113
|
-
const
|
|
132
|
+
const started = runRef.current;
|
|
114
133
|
return ai.chat(request, (event) => {
|
|
115
|
-
if (event.kind === "knowledge" &&
|
|
116
|
-
|
|
134
|
+
if (event.kind === "knowledge" && started === runRef.current) {
|
|
135
|
+
setRun((current) => ({
|
|
136
|
+
knowledge: mergeAiKnowledge(current.knowledge, event.knowledge),
|
|
137
|
+
citable: current.citable && numberingHolds(current.knowledge, event.knowledge)
|
|
138
|
+
}));
|
|
117
139
|
}
|
|
118
140
|
onEvent(event);
|
|
119
141
|
});
|
|
@@ -121,32 +143,38 @@ function useAiKnowledge(ai) {
|
|
|
121
143
|
};
|
|
122
144
|
const reset = () => {
|
|
123
145
|
runRef.current += 1;
|
|
124
|
-
|
|
146
|
+
setRun({ knowledge: null, citable: true });
|
|
125
147
|
};
|
|
126
148
|
return { ai: tapped, reset };
|
|
127
149
|
}, [ai]);
|
|
128
|
-
return { knowledge, ...helpers };
|
|
150
|
+
return { knowledge: run.knowledge, citable: run.citable, ...helpers };
|
|
129
151
|
}
|
|
130
|
-
function factCheckRequest(text, knowledge, given) {
|
|
152
|
+
function factCheckRequest(text, knowledge, given, citable) {
|
|
131
153
|
if (text.length > AI_WIRE_LIMITS.factCheckTextCharacters) return null;
|
|
132
154
|
const evidence = [];
|
|
133
155
|
let total = 0;
|
|
134
156
|
for (const passage of knowledge?.outcome === "used" ? knowledge.evidence : []) {
|
|
135
|
-
total += passage.length;
|
|
157
|
+
total += passage.text.length;
|
|
136
158
|
if (evidence.length >= AI_WIRE_LIMITS.factCheckEvidence || total > AI_WIRE_LIMITS.factCheckEvidenceCharacters) {
|
|
137
159
|
break;
|
|
138
160
|
}
|
|
139
|
-
evidence.push(passage);
|
|
161
|
+
evidence.push(passage.text);
|
|
140
162
|
}
|
|
141
|
-
return {
|
|
163
|
+
return {
|
|
164
|
+
text,
|
|
165
|
+
evidence,
|
|
166
|
+
given: given.slice(0, AI_WIRE_LIMITS.factCheckGivenCharacters),
|
|
167
|
+
// Passages were numbered for citing only when there were passages.
|
|
168
|
+
citations: citable && evidence.length > 0
|
|
169
|
+
};
|
|
142
170
|
}
|
|
143
171
|
function factsNeedReview(check) {
|
|
144
172
|
return check.unsourced.some((sentence) => sentence.strong) || check.unsourced.length >= 3;
|
|
145
173
|
}
|
|
146
|
-
function useFactCheck(ai, text, knowledge, given) {
|
|
174
|
+
function useFactCheck(ai, text, knowledge, given, citable) {
|
|
147
175
|
const [result, setResult] = useState(null);
|
|
148
176
|
useEffect(() => {
|
|
149
|
-
const request = text?.trim() && ai.checkFacts ? factCheckRequest(text, knowledge, given) : null;
|
|
177
|
+
const request = text?.trim() && ai.checkFacts ? factCheckRequest(text, knowledge, given, citable) : null;
|
|
150
178
|
if (!request) {
|
|
151
179
|
setResult(null);
|
|
152
180
|
return;
|
|
@@ -166,7 +194,7 @@ function useFactCheck(ai, text, knowledge, given) {
|
|
|
166
194
|
live = false;
|
|
167
195
|
clearTimeout(timer);
|
|
168
196
|
};
|
|
169
|
-
}, [ai, text, knowledge, given]);
|
|
197
|
+
}, [ai, text, knowledge, given, citable]);
|
|
170
198
|
return result;
|
|
171
199
|
}
|
|
172
200
|
|