@stll/folio-react 0.13.5 → 0.15.0

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-DWI5zwPp.js";
1
+ import { d as containedHandler } from "./renderAsync-nQ5eeFE1.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";
@@ -1,4 +1,4 @@
1
- import { c as DocxEditorRef, i as renderAsync, n as EditorHandle, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle } from "../renderAsync-B_Bi9oSr.js";
1
+ import { c as DocxEditorRef, i as renderAsync, n as EditorHandle, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle } from "../renderAsync-DD_yAlp1.js";
2
2
  import { ReactNode } from "react";
3
3
  import { CreateEmptyDocumentOptions, createDocumentWithText, createEmptyDocument } from "@stll/folio-core/utils/createDocument";
4
4
  //#region src/compat/eigenpal.d.ts
@@ -1,4 +1,4 @@
1
- import { n as DocxEditor$1, t as renderAsync } from "../renderAsync-DWI5zwPp.js";
1
+ import { n as DocxEditor$1, t as renderAsync } from "../renderAsync-nQ5eeFE1.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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as FolioUIProvider, a as DocxEditorApplyDocumentOperationsOptions, c as DocxEditorRef, d as ToolbarProps, f as EditorMode, g as FolioUIComponents, h as FolioButtonProps, i as renderAsync, l as HighlightPassageOptions, m as ColorPreset, n as EditorHandle, o as DocxEditorCollaboration, p as FontOption, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle, u as HighlightPassageResult, v as OutlineItem, y as FontDefinition } from "./renderAsync-B_Bi9oSr.js";
1
+ import { _ as FolioUIProvider, a as DocxEditorApplyDocumentOperationsOptions, c as DocxEditorRef, d as ToolbarProps, f as EditorMode, g as FolioUIComponents, h as FolioButtonProps, i as renderAsync, l as HighlightPassageOptions, m as ColorPreset, n as EditorHandle, o as DocxEditorCollaboration, p as FontOption, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle, u as HighlightPassageResult, v as OutlineItem, y as FontDefinition } from "./renderAsync-DD_yAlp1.js";
2
2
  import { A as HyperlinkDialog, C as ImagePropertiesData, D as ImagePositionDialog, E as ImagePositionData, F as FindReplaceDialog, I as FindReplaceDialogProps, M as HyperlinkDialogProps, N as FootnotePropertiesDialog, O as ImagePositionDialogProps, P as FootnotePropertiesDialogProps, S as InsertImageDialogProps, T as ImagePropertiesDialogProps, _ as InsertTableStyleOption, a as TablePropertiesDialogProps, b as InsertImageDialog, c as SplitCellDialogProps, d as PasteSpecialMode, f as PageSetupDialog, g as InsertTableDialogProps, h as InsertTableDialogData, i as TablePropertiesDialog, j as HyperlinkDialogData, k as HyperlinkBookmarkOption, l as PasteSpecialDialog, m as InsertTableDialog, n as WatermarkDialogProps, o as SplitCellDialog, p as PageSetupDialogProps, r as TableProperties, s as SplitCellDialogData, t as WatermarkDialog, u as PasteSpecialDialogProps, v as InsertSymbolDialog, w as ImagePropertiesDialog, x as InsertImageDialogData, y as InsertSymbolDialogProps } from "./dialogs-lCOx21mG.js";
3
3
  import React, { CSSProperties, ReactNode, RefObject } from "react";
4
4
  import { CreateEmptyDocumentOptions, createEmptyDocument } from "@stll/folio-core/utils/createDocument";
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-DWI5zwPp.js";
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-nQ5eeFE1.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";
@@ -611,13 +611,6 @@ type DocxEditorProps = {
611
611
  password?: string | undefined;
612
612
  /** Pre-parsed document (alternative to documentBuffer) */
613
613
  document?: Document | null;
614
- /**
615
- * Stable identity of the loaded document (same across internal edits, distinct
616
- * per loaded file, e.g. a file/document id). Used to distinguish a genuine
617
- * external load from an edited document round-tripped back through state.
618
- * Falls back to a document-metadata signature when omitted.
619
- */
620
- documentKey?: string;
621
614
  /** Callback when document is saved */
622
615
  onSave?: (buffer: ArrayBuffer) => void;
623
616
  /** Author name used for comments and track changes */
@@ -1192,14 +1192,14 @@ const HIDDEN_HOST_STYLES = {
1192
1192
  * HiddenProseMirror - Off-screen ProseMirror editor for keyboard input
1193
1193
  */
1194
1194
  const HiddenProseMirror = forwardRef((props, ref) => {
1195
- const { document, documentKey, styles, theme: _theme, widthPx = 612, readOnly = false, onTransaction, onSelectionChange, externalPlugins = EMPTY_EXTERNAL_PLUGINS, collaboration, extensionManager, onEditorViewReady, onEditorViewDestroy, onKeyDown, onCopy, onCut, onPaste, onReadOnlyEditAttempt, onRemoteSelectionsChange, precomputedInitialState } = props;
1195
+ const { document, documentIdentity, styles, theme: _theme, widthPx = 612, readOnly = false, onTransaction, onSelectionChange, externalPlugins = EMPTY_EXTERNAL_PLUGINS, collaboration, extensionManager, onEditorViewReady, onEditorViewDestroy, onKeyDown, onCopy, onCut, onPaste, onReadOnlyEditAttempt, onRemoteSelectionsChange, precomputedInitialState } = props;
1196
1196
  const [collaborationModules, setCollaborationModules] = useState(null);
1197
1197
  const [collaborationModulesError, setCollaborationModulesError] = useState(null);
1198
1198
  const hasCollaboration = collaboration !== void 0;
1199
1199
  const hostRef = useRef(null);
1200
1200
  const readOnlyRef = useRef(readOnly);
1201
1201
  const documentRef = useRef(document);
1202
- const documentKeyRef = useRef(documentKey);
1202
+ const documentIdentityRef = useRef(documentIdentity);
1203
1203
  const stylesRef = useRef(styles);
1204
1204
  const extensionManagerRef = useRef(extensionManager);
1205
1205
  const externalPluginsRef = useRef(externalPlugins);
@@ -1234,7 +1234,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1234
1234
  collaborationRef.current = collaboration;
1235
1235
  collaborationModulesRef.current = collaborationModules;
1236
1236
  documentRef.current = document;
1237
- documentKeyRef.current = documentKey;
1237
+ documentIdentityRef.current = documentIdentity;
1238
1238
  const managerRef = useRef(null);
1239
1239
  if (managerRef.current === null) managerRef.current = createHiddenEditorManager({
1240
1240
  getHost: () => hostRef.current,
@@ -1246,7 +1246,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1246
1246
  getCollaborationModules: () => collaborationModulesRef.current,
1247
1247
  getPrecomputedInitialState: () => precomputedInitialStateRef.current,
1248
1248
  getReadOnly: () => readOnlyRef.current,
1249
- getDocumentKey: () => documentKeyRef.current,
1249
+ getDocumentIdentity: () => documentIdentityRef.current,
1250
1250
  getDocumentContext: () => documentRef.current,
1251
1251
  onTransaction: (transaction, newState) => onTransactionRef.current?.(transaction, newState),
1252
1252
  onSelectionChange: (state) => onSelectionChangeRef.current?.(state),
@@ -1311,7 +1311,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1311
1311
  managerRef.current?.syncExternalDocument();
1312
1312
  }, [
1313
1313
  document,
1314
- documentKey,
1314
+ documentIdentity,
1315
1315
  styles,
1316
1316
  extensionManager,
1317
1317
  externalPlugins,
@@ -3113,7 +3113,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
3113
3113
  * PagedEditor - Main paginated editing component.
3114
3114
  */
3115
3115
  const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3116
- const { document, documentKey, 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;
3116
+ 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;
3117
3117
  const getScrollContainer = useCallback(() => {
3118
3118
  if (scrollContainerRefProp && typeof scrollContainerRefProp === "object") return scrollContainerRefProp.current;
3119
3119
  return containerRef.current;
@@ -6012,7 +6012,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6012
6012
  /* @__PURE__ */ jsx(HiddenProseMirror, {
6013
6013
  ref: hiddenPMRef,
6014
6014
  document,
6015
- ...documentKey !== void 0 ? { documentKey } : {},
6015
+ documentIdentity,
6016
6016
  widthPx: contentWidth,
6017
6017
  precomputedInitialState: validPrecomputedInitialState,
6018
6018
  readOnly,
@@ -10146,9 +10146,10 @@ function useContextMenu(t0) {
10146
10146
  * callbacks each render.
10147
10147
  */
10148
10148
  const useDocumentLoader = (t0) => {
10149
- const $ = c(20);
10149
+ const $ = c(21);
10150
10150
  const { documentBuffer, initialDocument, password, history, onError, onCompatibilityChange, onReset, setDocumentLoadState } = t0;
10151
10151
  const originalBufferRef = useRef(null);
10152
+ const [loadedDocumentIdentity, setLoadedDocumentIdentity] = useState("0");
10152
10153
  let t1;
10153
10154
  if ($[0] !== history || $[1] !== onCompatibilityChange || $[2] !== onError || $[3] !== onReset || $[4] !== setDocumentLoadState) {
10154
10155
  t1 = () => {
@@ -10157,7 +10158,8 @@ const useDocumentLoader = (t0) => {
10157
10158
  onError,
10158
10159
  onCompatibilityChange,
10159
10160
  onReset,
10160
- setDocumentLoadState
10161
+ setDocumentLoadState,
10162
+ setLoadedDocumentIdentity
10161
10163
  });
10162
10164
  return {
10163
10165
  manager: instance,
@@ -10182,7 +10184,8 @@ const useDocumentLoader = (t0) => {
10182
10184
  onError,
10183
10185
  onCompatibilityChange,
10184
10186
  onReset,
10185
- setDocumentLoadState
10187
+ setDocumentLoadState,
10188
+ setLoadedDocumentIdentity
10186
10189
  });
10187
10190
  let t3;
10188
10191
  let t4;
@@ -10237,18 +10240,20 @@ const useDocumentLoader = (t0) => {
10237
10240
  }
10238
10241
  useEffect(t5, t6);
10239
10242
  let t7;
10240
- if ($[16] !== api.loadBuffer || $[17] !== api.loadParsedDocument || $[18] !== api.resetForNewDocument) {
10243
+ if ($[16] !== api.loadBuffer || $[17] !== api.loadParsedDocument || $[18] !== api.resetForNewDocument || $[19] !== loadedDocumentIdentity) {
10241
10244
  t7 = {
10242
10245
  loadBuffer: api.loadBuffer,
10243
10246
  loadParsedDocument: api.loadParsedDocument,
10244
10247
  resetForNewDocument: api.resetForNewDocument,
10245
- originalBufferRef
10248
+ originalBufferRef,
10249
+ loadedDocumentIdentity
10246
10250
  };
10247
10251
  $[16] = api.loadBuffer;
10248
10252
  $[17] = api.loadParsedDocument;
10249
10253
  $[18] = api.resetForNewDocument;
10250
- $[19] = t7;
10251
- } else t7 = $[19];
10254
+ $[19] = loadedDocumentIdentity;
10255
+ $[20] = t7;
10256
+ } else t7 = $[20];
10252
10257
  return t7;
10253
10258
  };
10254
10259
  //#endregion
@@ -12593,7 +12598,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
12593
12598
  * - Error boundary
12594
12599
  * - Loading states
12595
12600
  */
12596
- const CommentsSidebar = lazy(() => import("./CommentsSidebar-Dlm746vL.js").then((m) => ({ default: m.CommentsSidebar })));
12601
+ const CommentsSidebar = lazy(() => import("./CommentsSidebar-DhAbtuuQ.js").then((m) => ({ default: m.CommentsSidebar })));
12597
12602
  const TextContextMenu = lazy(() => import("./TextContextMenu-Ci7-M4oU.js").then((m) => ({ default: m.TextContextMenu })));
12598
12603
  const loadAttemptSelectiveSave = async () => {
12599
12604
  const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
@@ -12655,7 +12660,7 @@ function areActiveTrackedChangesEqual(a, b) {
12655
12660
  /**
12656
12661
  * DocxEditor - Complete DOCX editor component
12657
12662
  */
12658
- const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, document: initialDocument, documentKey, onSave, author = "User", onChange, onSelectionChange, onSelectionTextChange, onError, onFontsLoaded: onFontsLoadedCallback, fontFamilies, fonts, theme, showToolbar = true, showZoomControl = true, showReviewControls = true, showHeaderFooterEditing = true, showMarginGuides = false, marginGuideColor, showRuler: showRulerProp = false, rulerUnit = "inch", initialZoom = 1, enableWheelZoom = true, readOnly: readOnlyProp = false, autoOpenReviewSidebar = true, components, toolbarExtra, className = "", style, placeholder, loadingIndicator, preserveDocumentWhileLoading = false, initialScrollTop, onScrollTopChange, showOutline: showOutlineProp = true, onPrint, onInsertImage, onInsertTable, showTableInsert = true, onInsertPageBreak, onInsertTOC, onCopy, onCut, onPaste, mode: modeProp, onModeChange, onReadonlyEditAttempt, onCompatibilityChange, onEditorViewReady, onAnonymizationMatchesChange, onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq, showTemplateDirectives = false, onSlashMenuChange, onSlashMenuKeyAction, customContextMenuItems, onCustomContextAction, comments: commentsProp, onCommentsChange, collaboration, featureFlags, onSelectiveSaveTripwire }, ref) {
12663
+ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, document: initialDocument, onSave, author = "User", onChange, onSelectionChange, onSelectionTextChange, onError, onFontsLoaded: onFontsLoadedCallback, fontFamilies, fonts, theme, showToolbar = true, showZoomControl = true, showReviewControls = true, showHeaderFooterEditing = true, showMarginGuides = false, marginGuideColor, showRuler: showRulerProp = false, rulerUnit = "inch", initialZoom = 1, enableWheelZoom = true, readOnly: readOnlyProp = false, autoOpenReviewSidebar = true, components, toolbarExtra, className = "", style, placeholder, loadingIndicator, preserveDocumentWhileLoading = false, initialScrollTop, onScrollTopChange, showOutline: showOutlineProp = true, onPrint, onInsertImage, onInsertTable, showTableInsert = true, onInsertPageBreak, onInsertTOC, onCopy, onCut, onPaste, mode: modeProp, onModeChange, onReadonlyEditAttempt, onCompatibilityChange, onEditorViewReady, onAnonymizationMatchesChange, onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq, showTemplateDirectives = false, onSlashMenuChange, onSlashMenuKeyAction, customContextMenuItems, onCustomContextAction, comments: commentsProp, onCommentsChange, collaboration, featureFlags, onSelectiveSaveTripwire }, ref) {
12659
12664
  const t = useTranslations("folio");
12660
12665
  useEffect(() => {
12661
12666
  const onClipboardReadError = () => {
@@ -12990,7 +12995,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12990
12995
  focusActiveEditor,
12991
12996
  pmImageContext: state.pmImageContext
12992
12997
  });
12993
- const { loadBuffer, loadParsedDocument, originalBufferRef } = useDocumentLoader({
12998
+ const { loadBuffer, loadParsedDocument, originalBufferRef, loadedDocumentIdentity } = useDocumentLoader({
12994
12999
  documentBuffer: documentBuffer ?? null,
12995
13000
  initialDocument: initialDocument ?? null,
12996
13001
  password,
@@ -15267,7 +15272,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15267
15272
  /* @__PURE__ */ jsx(PagedEditor, {
15268
15273
  ref: pagedEditorRef,
15269
15274
  document: history.state,
15270
- ...documentKey !== void 0 ? { documentKey } : {},
15275
+ documentIdentity: loadedDocumentIdentity,
15271
15276
  ...fonts !== void 0 ? { fonts } : {},
15272
15277
  theme: history.state.package.theme || theme || null,
15273
15278
  sectionProperties: effectiveSectionProperties ?? null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-react",
3
- "version": "0.13.5",
3
+ "version": "0.15.0",
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.18.0",
71
+ "@stll/folio-core": "^0.20.0",
72
72
  "better-result": "2.10.0",
73
73
  "lucide-react": "1.24.0",
74
74
  "prosemirror-history": "^1.5.0",