@stll/folio-react 0.18.0 → 0.18.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.
@@ -1,4 +1,4 @@
1
- import { d as containedHandler } from "./renderAsync-PBU6Wru3.js";
1
+ import { d as containedHandler } from "./renderAsync-Dy_3LIbV.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 { n as DocxEditor$1, t as renderAsync } from "../renderAsync-PBU6Wru3.js";
1
+ import { n as DocxEditor$1, t as renderAsync } from "../renderAsync-Dy_3LIbV.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-PBU6Wru3.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-Dy_3LIbV.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";
@@ -9,6 +9,7 @@ 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
11
  import { FOLIO_DOCX_SERIALIZATION_MODE, createFolioEditor } from "@stll/folio-core/controller/folioEditor";
12
+ import { cloneDocumentWithParagraphPropertySources } from "@stll/folio-core/docx/document-clone";
12
13
  import { normalizeBaseDirection } from "@stll/folio-core/docx/normalizeBaseDirection";
13
14
  import { getCachedNumberingMap } from "@stll/folio-core/docx/numberingParser";
14
15
  import { computeScrollPageInfo, updateScrollPageTotal } from "@stll/folio-core/paged-layout/scrollPageInfo";
@@ -10585,6 +10586,26 @@ function useFindReplace(t0) {
10585
10586
  * glue — the edit-position state, the memoised resolution, the host
10586
10587
  * `pushDocument` routing, and reading the live hidden HF PM doc at save time.
10587
10588
  */
10589
+ const saveAndCloseHeaderFooterEdit = ({ activeRId, document, editPosition, isFirstPage, pushDocument, setEditPosition, view }) => {
10590
+ if (!activeRId || !view) {
10591
+ setEditPosition(null);
10592
+ return;
10593
+ }
10594
+ const source = (editPosition === "header" ? document.package.headers : document.package.footers)?.get(activeRId);
10595
+ if (!source) {
10596
+ setEditPosition(null);
10597
+ return;
10598
+ }
10599
+ const newDocument = saveHeaderFooterContent({
10600
+ document,
10601
+ position: editPosition,
10602
+ isFirstPage,
10603
+ activeRId,
10604
+ blocks: proseDocToBlocks(view.state.doc, source.content)
10605
+ });
10606
+ if (newDocument) pushDocument(newDocument);
10607
+ setEditPosition(null);
10608
+ };
10588
10609
  const useHeaderFooterEditor = ({ history, pushDocument, getHfView }) => {
10589
10610
  const [hfEditPosition, setHfEditPosition] = useState(null);
10590
10611
  const [hfEditIsFirstPage, setHfEditIsFirstPage] = useState(false);
@@ -10624,17 +10645,15 @@ const useHeaderFooterEditor = ({ history, pushDocument, getHfView }) => {
10624
10645
  }
10625
10646
  const activeRId = pickActiveHeaderFooterRId(resolution, hfEditPosition, hfEditIsFirstPage);
10626
10647
  const view = activeRId ? getHfView(activeRId) : null;
10627
- if (activeRId && view) {
10628
- const newDoc_0 = saveHeaderFooterContent({
10629
- document: history.state,
10630
- position: hfEditPosition,
10631
- isFirstPage: hfEditIsFirstPage,
10632
- activeRId,
10633
- blocks: proseDocToBlocks(view.state.doc)
10634
- });
10635
- if (newDoc_0) pushDocument(newDoc_0);
10636
- }
10637
- setHfEditPosition(null);
10648
+ saveAndCloseHeaderFooterEdit({
10649
+ activeRId,
10650
+ document: history.state,
10651
+ editPosition: hfEditPosition,
10652
+ isFirstPage: hfEditIsFirstPage,
10653
+ pushDocument,
10654
+ setEditPosition: setHfEditPosition,
10655
+ view
10656
+ });
10638
10657
  }, [
10639
10658
  hfEditPosition,
10640
10659
  hfEditIsFirstPage,
@@ -12680,7 +12699,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
12680
12699
  * - Error boundary
12681
12700
  * - Loading states
12682
12701
  */
12683
- const CommentsSidebar = lazy(() => import("./CommentsSidebar-TCygZ9-U.js").then((m) => ({ default: m.CommentsSidebar })));
12702
+ const CommentsSidebar = lazy(() => import("./CommentsSidebar-DWEKDq08.js").then((m) => ({ default: m.CommentsSidebar })));
12684
12703
  const TextContextMenu = lazy(() => import("./TextContextMenu-Ci7-M4oU.js").then((m) => ({ default: m.TextContextMenu })));
12685
12704
  const loadAttemptSelectiveSave = async () => {
12686
12705
  const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
@@ -13211,7 +13230,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13211
13230
  ]);
13212
13231
  const buildCurrentDocument = useCallback(() => {
13213
13232
  if (!history.state) return null;
13214
- let doc_0 = structuredClone(history.state);
13233
+ let doc_0 = cloneDocumentWithParagraphPropertySources(history.state);
13215
13234
  const pmDoc = pagedEditorRef.current?.getDocument();
13216
13235
  if (pmDoc) {
13217
13236
  doc_0.package.document.content = pmDoc.package.document.content;
@@ -13224,7 +13243,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13224
13243
  if (!bag) return;
13225
13244
  for (const [rId_0, hf] of bag) {
13226
13245
  const view_5 = editor.getHfView(rId_0);
13227
- if (view_5) hf.content = proseDocToBlocks(view_5.state.doc);
13246
+ if (view_5) hf.content = proseDocToBlocks(view_5.state.doc, hf.content);
13228
13247
  }
13229
13248
  };
13230
13249
  flushBag(doc_0.package.headers);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-react",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
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.35.0",
71
+ "@stll/folio-core": "^0.36.0",
72
72
  "better-result": "3.0.1",
73
73
  "lucide-react": "1.24.0",
74
74
  "prosemirror-history": "^1.5.0",