@stll/folio-react 0.16.4 → 0.16.5
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as containedHandler } from "./renderAsync
|
|
1
|
+
import { d as containedHandler } from "./renderAsync-D5MafItf.js";
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { CheckIcon, MoreVerticalIcon } from "lucide-react";
|
|
4
4
|
import { useLocale, useTranslations } from "use-intl";
|
package/dist/compat/eigenpal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as DocxEditor$1, t as renderAsync } from "../renderAsync
|
|
1
|
+
import { n as DocxEditor$1, t as renderAsync } from "../renderAsync-D5MafItf.js";
|
|
2
2
|
import { t as messages_exports } from "../messages.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { forwardRef } from "react";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as formatZoom, c as FormattingBar, i as clampZoom, l as ZoomControl, n as DocxEditor, o as parseZoom, r as ZOOM_PRESETS, s as useWheelZoom, t as renderAsync, u as AutocompleteCaretOverlay } from "./renderAsync
|
|
1
|
+
import { a as formatZoom, c as FormattingBar, i as clampZoom, l as ZoomControl, n as DocxEditor, o as parseZoom, r as ZOOM_PRESETS, s as useWheelZoom, t as renderAsync, u as AutocompleteCaretOverlay } from "./renderAsync-D5MafItf.js";
|
|
2
2
|
import { n as FolioUIProvider } from "./folio-ui-BgDDRsUX.js";
|
|
3
3
|
import { t as FindReplaceDialog } from "./FindReplaceDialog-CqKK82nE.js";
|
|
4
4
|
import { t as FootnotePropertiesDialog } from "./FootnotePropertiesDialog-CixRdIiT.js";
|
|
@@ -8,6 +8,7 @@ import { closeHistory, redo, undo } from "prosemirror-history";
|
|
|
8
8
|
import { IntlProvider, useTranslations } from "use-intl";
|
|
9
9
|
import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, createFolioAIEditSnapshot, getCommentAnchorsFromDoc, getFolioDocumentOperationIssues, getTrackedChangesFromDoc } from "@stll/folio-core/ai-edits";
|
|
10
10
|
import { resolveActiveEditorStory } from "@stll/folio-core/controller/activeEditorStory";
|
|
11
|
+
import { FOLIO_DOCX_SERIALIZATION_MODE, createFolioEditor } from "@stll/folio-core/controller/folioEditor";
|
|
11
12
|
import { normalizeBaseDirection } from "@stll/folio-core/docx/normalizeBaseDirection";
|
|
12
13
|
import { getCachedNumberingMap } from "@stll/folio-core/docx/numberingParser";
|
|
13
14
|
import { computeScrollPageInfo, updateScrollPageTotal } from "@stll/folio-core/paged-layout/scrollPageInfo";
|
|
@@ -44,7 +45,6 @@ import { createHeaderFooterEditorManager } from "@stll/folio-core/controller/hea
|
|
|
44
45
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
45
46
|
import { createNoteEditorManager } from "@stll/folio-core/controller/noteEditorManager";
|
|
46
47
|
import { createFolioAIEditSnapshot as createFolioAIEditSnapshot$1 } from "@stll/folio-core/ai-edits/snapshot";
|
|
47
|
-
import { createFolioEditor } from "@stll/folio-core/controller/folioEditor";
|
|
48
48
|
import { createFolioEditorEmitter } from "@stll/folio-core/controller/folioEditorEvents";
|
|
49
49
|
import { createLatestRequestGate } from "@stll/folio-core/controller/latestRequestGate";
|
|
50
50
|
import { runLayoutPipeline } from "@stll/folio-core/controller/layoutPipeline";
|
|
@@ -3129,7 +3129,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
|
|
|
3129
3129
|
* PagedEditor - Main paginated editing component.
|
|
3130
3130
|
*/
|
|
3131
3131
|
const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
3132
|
-
const { document, documentIdentity, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, showMarginGuides = false, marginGuideColor, onDocumentChange, onReadOnlyEditAttempt, onCopy, onCut, onPaste, onSelectionChange, onSelectionTextChange, onEditorViewReady, externalPlugins = EMPTY_PLUGINS, showTemplateDirectives = true, collaboration, extensionManager, suggestionModeActive = false, suggestionAuthor, onActiveNoteStoryChange, onHeaderFooterDoubleClick, hfEditMode, activeHeaderFooterRId, onBodyClick, className, style, commentsSidebarOpen = false, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
|
|
3132
|
+
const { document, documentIO, documentIdentity, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, showMarginGuides = false, marginGuideColor, onDocumentChange, onReadOnlyEditAttempt, onCopy, onCut, onPaste, onSelectionChange, onSelectionTextChange, onEditorViewReady, externalPlugins = EMPTY_PLUGINS, showTemplateDirectives = true, collaboration, extensionManager, suggestionModeActive = false, suggestionAuthor, onActiveNoteStoryChange, onHeaderFooterDoubleClick, hfEditMode, activeHeaderFooterRId, onBodyClick, className, style, commentsSidebarOpen = false, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
|
|
3133
3133
|
const getScrollContainer = useCallback(() => {
|
|
3134
3134
|
if (scrollContainerRefProp && typeof scrollContainerRefProp === "object") return scrollContainerRefProp.current;
|
|
3135
3135
|
return containerRef.current;
|
|
@@ -3469,11 +3469,14 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3469
3469
|
]);
|
|
3470
3470
|
const runLayoutPipelineRef = useRef(runLayoutPipeline$1);
|
|
3471
3471
|
runLayoutPipelineRef.current = runLayoutPipeline$1;
|
|
3472
|
+
const documentIORef = useRef(documentIO);
|
|
3473
|
+
documentIORef.current = documentIO;
|
|
3472
3474
|
const folioEditorRef = useRef(null);
|
|
3473
3475
|
if (!folioEditorRef.current) folioEditorRef.current = createFolioEditor({
|
|
3474
3476
|
getEditorApi: () => hiddenPMRef.current,
|
|
3475
3477
|
getLayout: () => layoutRef.current,
|
|
3476
3478
|
runLayout: (state_0, options_0) => runLayoutPipelineRef.current(state_0, options_0),
|
|
3479
|
+
getDocumentIO: () => documentIORef.current,
|
|
3477
3480
|
emitter: folioEmitterRef.current
|
|
3478
3481
|
});
|
|
3479
3482
|
const folioEditor = folioEditorRef.current;
|
|
@@ -12649,7 +12652,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
|
|
|
12649
12652
|
* - Error boundary
|
|
12650
12653
|
* - Loading states
|
|
12651
12654
|
*/
|
|
12652
|
-
const CommentsSidebar = lazy(() => import("./CommentsSidebar-
|
|
12655
|
+
const CommentsSidebar = lazy(() => import("./CommentsSidebar-DsY20BSs.js").then((m) => ({ default: m.CommentsSidebar })));
|
|
12653
12656
|
const TextContextMenu = lazy(() => import("./TextContextMenu-Ci7-M4oU.js").then((m) => ({ default: m.TextContextMenu })));
|
|
12654
12657
|
const loadAttemptSelectiveSave = async () => {
|
|
12655
12658
|
const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
|
|
@@ -14142,7 +14145,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14142
14145
|
if (!view_16) return;
|
|
14143
14146
|
removeTabStop(positionTwips)(view_16.state, view_16.dispatch);
|
|
14144
14147
|
}, [getActiveEditorView]);
|
|
14145
|
-
const
|
|
14148
|
+
const serializeCurrentDocx = useCallback(async (options) => {
|
|
14146
14149
|
let tripwireResult = null;
|
|
14147
14150
|
let savedBuffer = null;
|
|
14148
14151
|
try {
|
|
@@ -14150,7 +14153,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14150
14153
|
if (!doc_1) return null;
|
|
14151
14154
|
const { resolveSelectiveSaveFlags } = await import("@stll/folio-core/docx/selectiveSaveFlags");
|
|
14152
14155
|
const flags = resolveSelectiveSaveFlags(featureFlags);
|
|
14153
|
-
const useSelectiveForSave = flags.selectiveSave && options?.
|
|
14156
|
+
const useSelectiveForSave = flags.selectiveSave && options?.mode !== FOLIO_DOCX_SERIALIZATION_MODE.full;
|
|
14154
14157
|
const shouldAttemptSelective = useSelectiveForSave || flags.selectiveSaveTripwire;
|
|
14155
14158
|
const view_17 = pagedEditorRef.current?.getView();
|
|
14156
14159
|
const baselineBuffer = originalBufferRef.current;
|
|
@@ -14184,8 +14187,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14184
14187
|
originalBufferRef.current = buffer;
|
|
14185
14188
|
view_17.dispatch(clearTrackedChanges(view_17.state));
|
|
14186
14189
|
}
|
|
14187
|
-
commentsDirtyRef.current = false;
|
|
14188
|
-
onSave?.(buffer);
|
|
14189
14190
|
savedBuffer = buffer;
|
|
14190
14191
|
} catch (error) {
|
|
14191
14192
|
onError?.(error instanceof Error ? error : /* @__PURE__ */ new Error("Failed to save document"));
|
|
@@ -14195,12 +14196,32 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14195
14196
|
return savedBuffer;
|
|
14196
14197
|
}, [
|
|
14197
14198
|
buildCurrentDocument,
|
|
14198
|
-
onSave,
|
|
14199
14199
|
onError,
|
|
14200
14200
|
originalBufferRef,
|
|
14201
14201
|
featureFlags,
|
|
14202
|
-
onSelectiveSaveTripwire
|
|
14203
|
-
|
|
14202
|
+
onSelectiveSaveTripwire
|
|
14203
|
+
]);
|
|
14204
|
+
const handleSave = useCallback(async (options_0) => {
|
|
14205
|
+
const editor_1 = pagedEditorRef.current?.getEditor();
|
|
14206
|
+
const serializationOptions = { mode: options_0?.selective === false ? FOLIO_DOCX_SERIALIZATION_MODE.full : FOLIO_DOCX_SERIALIZATION_MODE.preferSelective };
|
|
14207
|
+
const buffer_0 = editor_1 ? await editor_1.getDocx(serializationOptions) : await serializeCurrentDocx(serializationOptions);
|
|
14208
|
+
if (!buffer_0) return null;
|
|
14209
|
+
commentsDirtyRef.current = false;
|
|
14210
|
+
onSave?.(buffer_0);
|
|
14211
|
+
return buffer_0;
|
|
14212
|
+
}, [
|
|
14213
|
+
commentsDirtyRef,
|
|
14214
|
+
onSave,
|
|
14215
|
+
serializeCurrentDocx
|
|
14216
|
+
]);
|
|
14217
|
+
const documentIO = useMemo(() => ({
|
|
14218
|
+
getDocx: serializeCurrentDocx,
|
|
14219
|
+
loadDocument: loadParsedDocument,
|
|
14220
|
+
loadDocx: loadBuffer
|
|
14221
|
+
}), [
|
|
14222
|
+
loadBuffer,
|
|
14223
|
+
loadParsedDocument,
|
|
14224
|
+
serializeCurrentDocx
|
|
14204
14225
|
]);
|
|
14205
14226
|
const handleEditorError = useCallback((error_0) => {
|
|
14206
14227
|
onError?.(error_0);
|
|
@@ -14225,13 +14246,20 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14225
14246
|
scrollToPage: (pageNumber_0) => {
|
|
14226
14247
|
pagedEditorRef.current?.scrollToPage(pageNumber_0);
|
|
14227
14248
|
},
|
|
14228
|
-
scrollToParaId: (paraId,
|
|
14249
|
+
scrollToParaId: (paraId, options_1) => pagedEditorRef.current?.scrollToParaId(paraId, options_1) ?? false,
|
|
14229
14250
|
openPrintPreview: handleDirectPrint,
|
|
14230
14251
|
print: handleDirectPrint,
|
|
14231
|
-
loadDocument:
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14252
|
+
loadDocument: (document_0) => {
|
|
14253
|
+
const editor_2 = pagedEditorRef.current?.getEditor();
|
|
14254
|
+
if (editor_2) {
|
|
14255
|
+
editor_2.loadDocument(document_0);
|
|
14256
|
+
return;
|
|
14257
|
+
}
|
|
14258
|
+
loadParsedDocument(document_0);
|
|
14259
|
+
},
|
|
14260
|
+
loadDocumentBuffer: (buffer_1) => pagedEditorRef.current?.getEditor().loadDocx(buffer_1) ?? loadBuffer(buffer_1),
|
|
14261
|
+
ensureEditorView: (options_2) => {
|
|
14262
|
+
pagedEditorRef.current?.ensureView(options_2);
|
|
14235
14263
|
},
|
|
14236
14264
|
createAIEditSnapshot: () => {
|
|
14237
14265
|
const view_19 = pagedEditorRef.current?.getView();
|
|
@@ -14479,14 +14507,14 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14479
14507
|
const view_29 = pagedEditorRef.current?.getView();
|
|
14480
14508
|
return view_29 ? getSuggestions(view_29.state) : [];
|
|
14481
14509
|
},
|
|
14482
|
-
acceptSuggestion: (suggestionId,
|
|
14510
|
+
acceptSuggestion: (suggestionId, options_3) => {
|
|
14483
14511
|
const view_30 = pagedEditorRef.current?.getView();
|
|
14484
14512
|
if (!view_30) return {
|
|
14485
14513
|
accepted: false,
|
|
14486
14514
|
appliedAs: null
|
|
14487
14515
|
};
|
|
14488
14516
|
const appliedAs = getSuggestions(view_30.state).find((s_0) => s_0.suggestionId === suggestionId)?.appliedAs ?? null;
|
|
14489
|
-
const accepted = acceptSuggestion(suggestionId, { author:
|
|
14517
|
+
const accepted = acceptSuggestion(suggestionId, { author: options_3?.author ?? author })(view_30.state, view_30.dispatch);
|
|
14490
14518
|
return {
|
|
14491
14519
|
accepted,
|
|
14492
14520
|
appliedAs: accepted ? appliedAs : null
|
|
@@ -14569,26 +14597,26 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14569
14597
|
});
|
|
14570
14598
|
return true;
|
|
14571
14599
|
},
|
|
14572
|
-
setContentControlContent: (filter_1, input,
|
|
14600
|
+
setContentControlContent: (filter_1, input, options_4 = {}) => {
|
|
14573
14601
|
const view_40 = pagedEditorRef.current?.getView();
|
|
14574
14602
|
if (!view_40) return false;
|
|
14575
|
-
const tr_0 = typeof input === "string" ? setContentControlContentTr(view_40.state, filter_1, input,
|
|
14603
|
+
const tr_0 = typeof input === "string" ? setContentControlContentTr(view_40.state, filter_1, input, options_4) : setContentControlContentBlocksTr(view_40.state, filter_1, input, options_4);
|
|
14576
14604
|
if (!tr_0) return false;
|
|
14577
14605
|
view_40.dispatch(tr_0);
|
|
14578
14606
|
return true;
|
|
14579
14607
|
},
|
|
14580
|
-
setContentControlValue: (filter_2, input_0,
|
|
14608
|
+
setContentControlValue: (filter_2, input_0, options_5 = {}) => {
|
|
14581
14609
|
const view_41 = pagedEditorRef.current?.getView();
|
|
14582
14610
|
if (!view_41) return false;
|
|
14583
|
-
const tr_1 = setContentControlValueTr(view_41.state, filter_2, input_0,
|
|
14611
|
+
const tr_1 = setContentControlValueTr(view_41.state, filter_2, input_0, options_5);
|
|
14584
14612
|
if (!tr_1) return false;
|
|
14585
14613
|
view_41.dispatch(tr_1);
|
|
14586
14614
|
return true;
|
|
14587
14615
|
},
|
|
14588
|
-
removeContentControl: (filter_3,
|
|
14616
|
+
removeContentControl: (filter_3, options_6 = {}) => {
|
|
14589
14617
|
const view_42 = pagedEditorRef.current?.getView();
|
|
14590
14618
|
if (!view_42) return false;
|
|
14591
|
-
const tr_2 = removeContentControlTr(view_42.state, filter_3,
|
|
14619
|
+
const tr_2 = removeContentControlTr(view_42.state, filter_3, options_6);
|
|
14592
14620
|
if (!tr_2) return false;
|
|
14593
14621
|
view_42.dispatch(tr_2);
|
|
14594
14622
|
return true;
|
|
@@ -15332,6 +15360,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15332
15360
|
/* @__PURE__ */ jsx(PagedEditor, {
|
|
15333
15361
|
ref: pagedEditorRef,
|
|
15334
15362
|
document: history.state,
|
|
15363
|
+
documentIO,
|
|
15335
15364
|
documentIdentity: loadedDocumentIdentity,
|
|
15336
15365
|
...fonts !== void 0 ? { fonts } : {},
|
|
15337
15366
|
theme: history.state.package.theme || theme || null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-react",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.5",
|
|
4
4
|
"description": "React editor for folio: a Word-document (.docx) editor for the browser, built on @stll/folio-core and ProseMirror.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-editor",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@fontsource/noto-sans-arabic": "^5.2.7",
|
|
69
69
|
"@fontsource/source-sans-3": "^5.2.9",
|
|
70
70
|
"@fontsource/tinos": "^5.2.7",
|
|
71
|
-
"@stll/folio-core": "^0.
|
|
71
|
+
"@stll/folio-core": "^0.30.0",
|
|
72
72
|
"better-result": "3.0.1",
|
|
73
73
|
"lucide-react": "1.24.0",
|
|
74
74
|
"prosemirror-history": "^1.5.0",
|