@stll/folio-react 0.24.2 → 0.25.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.
- package/dist/{CommentsSidebar-Bk5pQ_2C.js → CommentsSidebar-D9vMIMl7.js} +1 -1
- package/dist/compat/eigenpal.d.ts +1 -1
- package/dist/compat/eigenpal.js +1 -1
- package/dist/i18n/messages/ar.d.ts +2 -0
- package/dist/i18n/messages/ar.js +2 -0
- package/dist/i18n/messages/cs.d.ts +2 -0
- package/dist/i18n/messages/cs.js +2 -0
- package/dist/i18n/messages/de.d.ts +2 -0
- package/dist/i18n/messages/de.js +2 -0
- package/dist/i18n/messages/en.d.ts +2 -0
- package/dist/i18n/messages/en.js +2 -0
- package/dist/i18n/messages/es.d.ts +2 -0
- package/dist/i18n/messages/es.js +2 -0
- package/dist/i18n/messages/et.d.ts +2 -0
- package/dist/i18n/messages/et.js +2 -0
- package/dist/i18n/messages/fr.d.ts +2 -0
- package/dist/i18n/messages/fr.js +2 -0
- package/dist/i18n/messages/he.d.ts +2 -0
- package/dist/i18n/messages/he.js +2 -0
- package/dist/i18n/messages/hi.d.ts +2 -0
- package/dist/i18n/messages/hi.js +2 -0
- package/dist/i18n/messages/hu.d.ts +2 -0
- package/dist/i18n/messages/hu.js +2 -0
- package/dist/i18n/messages/locales.d.ts +2 -0
- package/dist/i18n/messages/locales.js +2 -0
- package/dist/i18n/messages/lt.d.ts +2 -0
- package/dist/i18n/messages/lt.js +2 -0
- package/dist/i18n/messages/lv.d.ts +2 -0
- package/dist/i18n/messages/lv.js +2 -0
- package/dist/i18n/messages/pl.d.ts +2 -0
- package/dist/i18n/messages/pl.js +2 -0
- package/dist/i18n/messages/pt-BR.d.ts +2 -0
- package/dist/i18n/messages/pt-BR.js +2 -0
- package/dist/i18n/messages/sk.d.ts +2 -0
- package/dist/i18n/messages/sk.js +2 -0
- package/dist/i18n/messages/tr.d.ts +2 -0
- package/dist/i18n/messages/tr.js +2 -0
- package/dist/i18n/messages/zh-CN.d.ts +2 -0
- package/dist/i18n/messages/zh-CN.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{renderAsync-BYZY3FVx.d.ts → renderAsync-CfXBLJ_1.d.ts} +3 -0
- package/dist/{renderAsync-6eWf0MfZ.js → renderAsync-yYZKXh6r.js} +484 -206
- package/package.json +6 -2
|
@@ -7,6 +7,7 @@ import { AlertCircleIcon, AlertTriangleIcon, AlignCenterIcon, AlignJustifyIcon,
|
|
|
7
7
|
import { closeHistory, redo, undo } from "prosemirror-history";
|
|
8
8
|
import { IntlProvider, useFormatter, useTranslations } from "use-intl";
|
|
9
9
|
import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FolioPendingSuggestionRegistry, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, createFolioAIEditSnapshot, createPendingSuggestionSourceSnapshot, getCommentAnchorsFromDoc, getFolioDocumentOperationIssues, getTrackedChangesFromDoc } from "@stll/folio-core/ai-edits";
|
|
10
|
+
import { resolveCanonicalReviewRange } from "@stll/folio-core/controller/canonicalReview";
|
|
10
11
|
import { resolveActiveEditorStory } from "@stll/folio-core/controller/activeEditorStory";
|
|
11
12
|
import { FOLIO_DOCX_SERIALIZATION_MODE, createFolioEditor } from "@stll/folio-core/controller/folioEditor";
|
|
12
13
|
import { createNoteReferenceFollower, withoutUnreferencedNotes } from "@stll/folio-core/prosemirror/noteReferenceReview";
|
|
@@ -23,6 +24,8 @@ import { setContentControlContentBlocksTr } from "@stll/folio-core/prosemirror/c
|
|
|
23
24
|
import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice } from "@stll/folio-core/prosemirror/commands/pastePlainText";
|
|
24
25
|
import { proseDocToBlocks } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
|
|
25
26
|
import { ExtensionManager } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
|
|
27
|
+
import { executeEditorCommand, executeFirstEditorCommand } from "@stll/folio-core/prosemirror/executeEditorCommand";
|
|
28
|
+
import { insertPageBreak } from "@stll/folio-core/prosemirror/commands/pageBreak";
|
|
26
29
|
import { clearTrackedChanges, getChangedParagraphIds, hasStructuralChanges, hasUntrackedChanges, repackWithEditorSectionRemovals } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
|
|
27
30
|
import { createStarterKit } from "@stll/folio-core/prosemirror/extensions/StarterKit";
|
|
28
31
|
import { resolveFindMatchRange } from "@stll/folio-core/prosemirror/findReplaceSelection";
|
|
@@ -41,6 +44,8 @@ import { onFontsLoaded } from "@stll/folio-core/utils/fontLoader";
|
|
|
41
44
|
import { collectHeadings } from "@stll/folio-core/utils/headingCollector";
|
|
42
45
|
import { formatPx, pixelsToTwips, pointsToHalfPoints, twipsToPixels } from "@stll/folio-core/utils/units";
|
|
43
46
|
import { HistoryManager, classifyHistoryShortcut } from "@stll/folio-core/managers/HistoryManager";
|
|
47
|
+
import { createCanonicalHeaderFooterOperation, createCanonicalSectionPropertiesOperation, removeCanonicalHeaderFooterOperations } from "@stll/folio-core/controller/canonicalOperations";
|
|
48
|
+
import { repackWithCanonicalStoryRemovals } from "@stll/folio-core/docx/canonicalStoryRepack";
|
|
44
49
|
import { TableSelectionManager } from "@stll/folio-core/managers/TableSelectionManager";
|
|
45
50
|
import { DEFAULT_PAGE_HEIGHT_PX, getMargins, getPageSize, twipsToPixels as twipsToPixels$1 } from "@stll/folio-core/paged-layout/sectionGeometry";
|
|
46
51
|
import { createPortal } from "react-dom";
|
|
@@ -52,6 +57,7 @@ import { createNoteEditorManager } from "@stll/folio-core/controller/noteEditorM
|
|
|
52
57
|
import { projectMarkupView, visibleCaretPosition } from "@stll/folio-core/prosemirror/markupViewProjection";
|
|
53
58
|
import { createFolioAIEditSnapshot as createFolioAIEditSnapshot$1 } from "@stll/folio-core/ai-edits/snapshot";
|
|
54
59
|
import { createFolioEditorEmitter } from "@stll/folio-core/controller/folioEditorEvents";
|
|
60
|
+
import { CanonicalSessionRefusalError, collectRemoteSelections, createHiddenEditorManager, createHiddenEditorState } from "@stll/folio-core/controller/hiddenEditorManager";
|
|
55
61
|
import { dispatchEditorTextInput } from "@stll/folio-core/prosemirror/textInput";
|
|
56
62
|
import { createLatestRequestGate } from "@stll/folio-core/controller/latestRequestGate";
|
|
57
63
|
import { runLayoutPipeline } from "@stll/folio-core/controller/layoutPipeline";
|
|
@@ -91,7 +97,6 @@ import { allowsDirectDrawingEdit } from "@stll/folio-core/docx/imageRawXml";
|
|
|
91
97
|
import { commitImageFloatMove, commitImageInlineMove, commitImageResize, isFloatingImage } from "@stll/folio-core/prosemirror/imageCommit";
|
|
92
98
|
import { buildEmbeddedFontFamilyMap, extractEmbeddedFonts } from "@stll/folio-core/fonts/embeddedFonts";
|
|
93
99
|
import { panic } from "better-result";
|
|
94
|
-
import { collectRemoteSelections, createHiddenEditorManager, createHiddenEditorState } from "@stll/folio-core/controller/hiddenEditorManager";
|
|
95
100
|
import { loadCollaborationModules } from "@stll/folio-core/controller/collaborationModules";
|
|
96
101
|
import { createVisualLineState, handleVisualLineKeyDown } from "@stll/folio-core/prosemirror/utils/visualLineNavigation";
|
|
97
102
|
import { clampRangeToDocSize, resolveFolioAIBlockRange, resolveFolioAITextRange, resolvePassageRange } from "@stll/folio-core/ai-edits/blockRange";
|
|
@@ -339,22 +344,31 @@ const HOST_STYLES = {
|
|
|
339
344
|
zIndex: -1,
|
|
340
345
|
pointerEvents: "none"
|
|
341
346
|
};
|
|
342
|
-
const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, styles, theme, onTransaction }, ref) {
|
|
347
|
+
const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, styles, theme, onTransaction, experimentalSession, getCanonicalApi, onSessionRefusal }, ref) {
|
|
343
348
|
const hostRef = useRef(null);
|
|
344
349
|
const documentRef = useRef(document);
|
|
345
350
|
const stylesRef = useRef(styles);
|
|
346
351
|
const themeRef = useRef(theme);
|
|
347
352
|
const onTransactionRef = useRef(onTransaction);
|
|
353
|
+
const canonicalApiRef = useRef(getCanonicalApi);
|
|
354
|
+
const sessionRef = useRef(experimentalSession);
|
|
355
|
+
const refusalRef = useRef(onSessionRefusal);
|
|
348
356
|
documentRef.current = document;
|
|
349
357
|
stylesRef.current = styles;
|
|
350
358
|
themeRef.current = theme;
|
|
351
359
|
onTransactionRef.current = onTransaction;
|
|
360
|
+
canonicalApiRef.current = getCanonicalApi;
|
|
361
|
+
sessionRef.current = experimentalSession;
|
|
362
|
+
refusalRef.current = onSessionRefusal;
|
|
352
363
|
const managerRef = useRef(null);
|
|
353
364
|
managerRef.current ??= createHeaderFooterEditorManager({
|
|
354
365
|
getHost: () => hostRef.current,
|
|
355
366
|
getDocument: () => documentRef.current,
|
|
356
367
|
getStyles: () => stylesRef.current,
|
|
357
368
|
getTheme: () => themeRef.current,
|
|
369
|
+
getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
|
|
370
|
+
getExperimentalSession: () => sessionRef.current,
|
|
371
|
+
onSessionRefusal: (reason) => refusalRef.current?.(reason),
|
|
358
372
|
onTransaction: ({ rId, kind, view, docChanged, selectionChanged }) => {
|
|
359
373
|
onTransactionRef.current?.(rId, kind, view, docChanged, selectionChanged);
|
|
360
374
|
}
|
|
@@ -420,13 +434,16 @@ const hostStyle = {
|
|
|
420
434
|
};
|
|
421
435
|
const EMPTY_PLUGINS$1 = [];
|
|
422
436
|
const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
423
|
-
const $ = c(
|
|
424
|
-
const { document, onActiveChange, onDocumentChange, onStoryChange, plugins, styles, suggestionAuthor, suggestionModeActive, theme } = t0;
|
|
437
|
+
const $ = c(57);
|
|
438
|
+
const { document, experimentalSession, getCanonicalApi, onSessionRefusal, onActiveChange, onDocumentChange, onStoryChange, plugins, styles, suggestionAuthor, suggestionModeActive, theme } = t0;
|
|
425
439
|
const t = useTranslations("folio");
|
|
426
440
|
const resolvedPlugins = plugins ?? EMPTY_PLUGINS$1;
|
|
427
441
|
const isSuggestionModeActive = suggestionModeActive ?? false;
|
|
428
442
|
const hostRef = useRef(null);
|
|
429
443
|
const documentRef = useRef(document);
|
|
444
|
+
const canonicalApiRef = useRef(getCanonicalApi);
|
|
445
|
+
const sessionRef = useRef(experimentalSession);
|
|
446
|
+
const refusalRef = useRef(onSessionRefusal);
|
|
430
447
|
const stylesRef = useRef(styles);
|
|
431
448
|
const themeRef = useRef(theme);
|
|
432
449
|
const pluginsRef = useRef(resolvedPlugins);
|
|
@@ -438,9 +455,12 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
438
455
|
const footnotes = document?.package.footnotes;
|
|
439
456
|
const endnotes = document?.package.endnotes;
|
|
440
457
|
let t1;
|
|
441
|
-
if ($[0] !== active || $[1] !== document || $[2] !==
|
|
458
|
+
if ($[0] !== active || $[1] !== document || $[2] !== experimentalSession || $[3] !== getCanonicalApi || $[4] !== onActiveChange || $[5] !== onDocumentChange || $[6] !== onSessionRefusal || $[7] !== onStoryChange || $[8] !== resolvedPlugins || $[9] !== styles || $[10] !== theme) {
|
|
442
459
|
t1 = () => {
|
|
443
460
|
documentRef.current = document;
|
|
461
|
+
canonicalApiRef.current = getCanonicalApi;
|
|
462
|
+
sessionRef.current = experimentalSession;
|
|
463
|
+
refusalRef.current = onSessionRefusal;
|
|
444
464
|
stylesRef.current = styles;
|
|
445
465
|
themeRef.current = theme;
|
|
446
466
|
pluginsRef.current = resolvedPlugins;
|
|
@@ -453,9 +473,15 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
453
473
|
getPlugins: () => pluginsRef.current,
|
|
454
474
|
getStyles: () => stylesRef.current,
|
|
455
475
|
getTheme: () => themeRef.current,
|
|
476
|
+
getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
|
|
477
|
+
getExperimentalSession: () => sessionRef.current,
|
|
478
|
+
onSessionRefusal: (reason) => refusalRef.current?.(reason),
|
|
456
479
|
onTransaction: (t2) => {
|
|
457
480
|
const { docChanged, selectionChanged, view } = t2;
|
|
458
|
-
if (docChanged) {
|
|
481
|
+
if (docChanged) if (sessionRef.current === "canonical") {
|
|
482
|
+
const canonical = canonicalApiRef.current?.()?.getCanonicalDocument();
|
|
483
|
+
if (canonical) onDocumentChangeRef.current(canonical);
|
|
484
|
+
} else {
|
|
459
485
|
const current = documentRef.current;
|
|
460
486
|
if (current) onDocumentChangeRef.current(managerRef.current?.snapshotDocument(current) ?? current);
|
|
461
487
|
}
|
|
@@ -471,44 +497,53 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
471
497
|
};
|
|
472
498
|
$[0] = active;
|
|
473
499
|
$[1] = document;
|
|
474
|
-
$[2] =
|
|
475
|
-
$[3] =
|
|
476
|
-
$[4] =
|
|
477
|
-
$[5] =
|
|
478
|
-
$[6] =
|
|
479
|
-
$[7] =
|
|
480
|
-
$[8] =
|
|
481
|
-
|
|
500
|
+
$[2] = experimentalSession;
|
|
501
|
+
$[3] = getCanonicalApi;
|
|
502
|
+
$[4] = onActiveChange;
|
|
503
|
+
$[5] = onDocumentChange;
|
|
504
|
+
$[6] = onSessionRefusal;
|
|
505
|
+
$[7] = onStoryChange;
|
|
506
|
+
$[8] = resolvedPlugins;
|
|
507
|
+
$[9] = styles;
|
|
508
|
+
$[10] = theme;
|
|
509
|
+
$[11] = t1;
|
|
510
|
+
} else t1 = $[11];
|
|
482
511
|
let t2;
|
|
483
|
-
if ($[
|
|
512
|
+
if ($[12] !== active || $[13] !== document || $[14] !== endnotes || $[15] !== experimentalSession || $[16] !== footnotes || $[17] !== getCanonicalApi || $[18] !== onActiveChange || $[19] !== onDocumentChange || $[20] !== onSessionRefusal || $[21] !== onStoryChange || $[22] !== resolvedPlugins || $[23] !== styles || $[24] !== theme) {
|
|
484
513
|
t2 = [
|
|
485
514
|
active,
|
|
486
515
|
document,
|
|
487
516
|
endnotes,
|
|
517
|
+
experimentalSession,
|
|
488
518
|
footnotes,
|
|
519
|
+
getCanonicalApi,
|
|
489
520
|
onActiveChange,
|
|
490
521
|
onDocumentChange,
|
|
522
|
+
onSessionRefusal,
|
|
491
523
|
onStoryChange,
|
|
492
524
|
resolvedPlugins,
|
|
493
525
|
styles,
|
|
494
526
|
theme
|
|
495
527
|
];
|
|
496
|
-
$[
|
|
497
|
-
$[
|
|
498
|
-
$[
|
|
499
|
-
$[
|
|
500
|
-
$[
|
|
501
|
-
$[
|
|
502
|
-
$[
|
|
503
|
-
$[
|
|
504
|
-
$[
|
|
505
|
-
$[
|
|
506
|
-
$[
|
|
507
|
-
|
|
528
|
+
$[12] = active;
|
|
529
|
+
$[13] = document;
|
|
530
|
+
$[14] = endnotes;
|
|
531
|
+
$[15] = experimentalSession;
|
|
532
|
+
$[16] = footnotes;
|
|
533
|
+
$[17] = getCanonicalApi;
|
|
534
|
+
$[18] = onActiveChange;
|
|
535
|
+
$[19] = onDocumentChange;
|
|
536
|
+
$[20] = onSessionRefusal;
|
|
537
|
+
$[21] = onStoryChange;
|
|
538
|
+
$[22] = resolvedPlugins;
|
|
539
|
+
$[23] = styles;
|
|
540
|
+
$[24] = theme;
|
|
541
|
+
$[25] = t2;
|
|
542
|
+
} else t2 = $[25];
|
|
508
543
|
useEffect(t1, t2);
|
|
509
544
|
let t3;
|
|
510
545
|
let t4;
|
|
511
|
-
if ($[
|
|
546
|
+
if ($[26] !== isSuggestionModeActive || $[27] !== suggestionAuthor) {
|
|
512
547
|
t3 = () => {
|
|
513
548
|
const manager_0 = managerRef.current;
|
|
514
549
|
if (!manager_0) return;
|
|
@@ -518,41 +553,41 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
518
553
|
}
|
|
519
554
|
};
|
|
520
555
|
t4 = [isSuggestionModeActive, suggestionAuthor];
|
|
521
|
-
$[
|
|
522
|
-
$[
|
|
523
|
-
$[
|
|
524
|
-
$[
|
|
556
|
+
$[26] = isSuggestionModeActive;
|
|
557
|
+
$[27] = suggestionAuthor;
|
|
558
|
+
$[28] = t3;
|
|
559
|
+
$[29] = t4;
|
|
525
560
|
} else {
|
|
526
|
-
t3 = $[
|
|
527
|
-
t4 = $[
|
|
561
|
+
t3 = $[28];
|
|
562
|
+
t4 = $[29];
|
|
528
563
|
}
|
|
529
564
|
useEffect(t3, t4);
|
|
530
565
|
let t5;
|
|
531
566
|
let t6;
|
|
532
|
-
if ($[
|
|
567
|
+
if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
|
|
533
568
|
t5 = () => () => {
|
|
534
569
|
managerRef.current?.destroy();
|
|
535
570
|
};
|
|
536
571
|
t6 = [];
|
|
537
|
-
$[
|
|
538
|
-
$[
|
|
572
|
+
$[30] = t5;
|
|
573
|
+
$[31] = t6;
|
|
539
574
|
} else {
|
|
540
|
-
t5 = $[
|
|
541
|
-
t6 = $[
|
|
575
|
+
t5 = $[30];
|
|
576
|
+
t6 = $[31];
|
|
542
577
|
}
|
|
543
578
|
useEffect(t5, t6);
|
|
544
579
|
let t7;
|
|
545
|
-
if ($[
|
|
580
|
+
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
546
581
|
t7 = () => {
|
|
547
582
|
managerRef.current?.activate(null);
|
|
548
583
|
setActive(null);
|
|
549
584
|
onActiveChangeRef.current(null);
|
|
550
585
|
};
|
|
551
|
-
$[
|
|
552
|
-
} else t7 = $[
|
|
586
|
+
$[32] = t7;
|
|
587
|
+
} else t7 = $[32];
|
|
553
588
|
const closeEditor = t7;
|
|
554
589
|
let t8;
|
|
555
|
-
if ($[
|
|
590
|
+
if ($[33] !== isSuggestionModeActive || $[34] !== suggestionAuthor) {
|
|
556
591
|
t8 = () => ({
|
|
557
592
|
close: closeEditor,
|
|
558
593
|
getActiveView: () => {
|
|
@@ -569,63 +604,63 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
569
604
|
},
|
|
570
605
|
snapshotDocument: (current_0) => managerRef.current?.snapshotDocument(current_0) ?? current_0
|
|
571
606
|
});
|
|
572
|
-
$[
|
|
573
|
-
$[
|
|
574
|
-
$[
|
|
575
|
-
} else t8 = $[
|
|
607
|
+
$[33] = isSuggestionModeActive;
|
|
608
|
+
$[34] = suggestionAuthor;
|
|
609
|
+
$[35] = t8;
|
|
610
|
+
} else t8 = $[35];
|
|
576
611
|
useImperativeHandle(ref, t8);
|
|
577
612
|
let t9;
|
|
578
|
-
if ($[
|
|
613
|
+
if ($[36] !== active || $[37] !== t) {
|
|
579
614
|
t9 = active ? t(active.kind === "footnote" ? "dialogs.footnoteProperties.footnotes" : "dialogs.footnoteProperties.endnotes") : "";
|
|
580
|
-
$[
|
|
581
|
-
$[
|
|
582
|
-
$[
|
|
583
|
-
} else t9 = $[
|
|
615
|
+
$[36] = active;
|
|
616
|
+
$[37] = t;
|
|
617
|
+
$[38] = t9;
|
|
618
|
+
} else t9 = $[38];
|
|
584
619
|
const title = t9;
|
|
585
620
|
const t10 = active ? "block" : "none";
|
|
586
621
|
let t11;
|
|
587
|
-
if ($[
|
|
622
|
+
if ($[39] !== t10) {
|
|
588
623
|
t11 = {
|
|
589
624
|
...panelStyle,
|
|
590
625
|
display: t10
|
|
591
626
|
};
|
|
592
|
-
$[
|
|
593
|
-
$[
|
|
594
|
-
} else t11 = $[
|
|
627
|
+
$[39] = t10;
|
|
628
|
+
$[40] = t11;
|
|
629
|
+
} else t11 = $[40];
|
|
595
630
|
let t12;
|
|
596
|
-
if ($[
|
|
631
|
+
if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
|
|
597
632
|
t12 = (event) => {
|
|
598
633
|
if (event.key !== "Escape") return;
|
|
599
634
|
event.preventDefault();
|
|
600
635
|
event.stopPropagation();
|
|
601
636
|
closeEditor();
|
|
602
637
|
};
|
|
603
|
-
$[
|
|
604
|
-
} else t12 = $[
|
|
638
|
+
$[41] = t12;
|
|
639
|
+
} else t12 = $[41];
|
|
605
640
|
let t13;
|
|
606
|
-
if ($[
|
|
641
|
+
if ($[42] !== title) {
|
|
607
642
|
t13 = /* @__PURE__ */ jsx("span", { children: title });
|
|
608
|
-
$[
|
|
609
|
-
$[
|
|
610
|
-
} else t13 = $[
|
|
643
|
+
$[42] = title;
|
|
644
|
+
$[43] = t13;
|
|
645
|
+
} else t13 = $[43];
|
|
611
646
|
let t14;
|
|
612
|
-
if ($[
|
|
647
|
+
if ($[44] !== t) {
|
|
613
648
|
t14 = t("common.closeDialog");
|
|
614
|
-
$[
|
|
615
|
-
$[
|
|
616
|
-
} else t14 = $[
|
|
649
|
+
$[44] = t;
|
|
650
|
+
$[45] = t14;
|
|
651
|
+
} else t14 = $[45];
|
|
617
652
|
let t15;
|
|
618
|
-
if ($[
|
|
653
|
+
if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
|
|
619
654
|
t15 = {
|
|
620
655
|
border: 0,
|
|
621
656
|
background: "transparent",
|
|
622
657
|
color: "inherit",
|
|
623
658
|
cursor: "pointer"
|
|
624
659
|
};
|
|
625
|
-
$[
|
|
626
|
-
} else t15 = $[
|
|
660
|
+
$[46] = t15;
|
|
661
|
+
} else t15 = $[46];
|
|
627
662
|
let t16;
|
|
628
|
-
if ($[
|
|
663
|
+
if ($[47] !== t14) {
|
|
629
664
|
t16 = /* @__PURE__ */ jsx("button", {
|
|
630
665
|
type: "button",
|
|
631
666
|
"aria-label": t14,
|
|
@@ -633,40 +668,40 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
633
668
|
style: t15,
|
|
634
669
|
children: "×"
|
|
635
670
|
});
|
|
636
|
-
$[
|
|
637
|
-
$[
|
|
638
|
-
} else t16 = $[
|
|
671
|
+
$[47] = t14;
|
|
672
|
+
$[48] = t16;
|
|
673
|
+
} else t16 = $[48];
|
|
639
674
|
let t17;
|
|
640
|
-
if ($[
|
|
675
|
+
if ($[49] !== t13 || $[50] !== t16) {
|
|
641
676
|
t17 = /* @__PURE__ */ jsxs("div", {
|
|
642
677
|
style: headerStyle,
|
|
643
678
|
children: [t13, t16]
|
|
644
679
|
});
|
|
645
|
-
$[
|
|
646
|
-
$[
|
|
647
|
-
$[
|
|
648
|
-
} else t17 = $[
|
|
680
|
+
$[49] = t13;
|
|
681
|
+
$[50] = t16;
|
|
682
|
+
$[51] = t17;
|
|
683
|
+
} else t17 = $[51];
|
|
649
684
|
let t18;
|
|
650
|
-
if ($[
|
|
685
|
+
if ($[52] === Symbol.for("react.memo_cache_sentinel")) {
|
|
651
686
|
t18 = /* @__PURE__ */ jsx("div", {
|
|
652
687
|
ref: hostRef,
|
|
653
688
|
style: hostStyle
|
|
654
689
|
});
|
|
655
|
-
$[
|
|
656
|
-
} else t18 = $[
|
|
690
|
+
$[52] = t18;
|
|
691
|
+
} else t18 = $[52];
|
|
657
692
|
let t19;
|
|
658
|
-
if ($[
|
|
693
|
+
if ($[53] !== t11 || $[54] !== t17 || $[55] !== title) {
|
|
659
694
|
t19 = /* @__PURE__ */ jsxs("aside", {
|
|
660
695
|
style: t11,
|
|
661
696
|
"aria-label": title,
|
|
662
697
|
onKeyDown: t12,
|
|
663
698
|
children: [t17, t18]
|
|
664
699
|
});
|
|
665
|
-
$[
|
|
666
|
-
$[
|
|
667
|
-
$[
|
|
668
|
-
$[
|
|
669
|
-
} else t19 = $[
|
|
700
|
+
$[53] = t11;
|
|
701
|
+
$[54] = t17;
|
|
702
|
+
$[55] = title;
|
|
703
|
+
$[56] = t19;
|
|
704
|
+
} else t19 = $[56];
|
|
670
705
|
return t19;
|
|
671
706
|
});
|
|
672
707
|
NoteStoryEditor.displayName = "NoteStoryEditor";
|
|
@@ -1218,12 +1253,16 @@ const HIDDEN_HOST_STYLES = {
|
|
|
1218
1253
|
* HiddenProseMirror - Off-screen ProseMirror editor for keyboard input
|
|
1219
1254
|
*/
|
|
1220
1255
|
const HiddenProseMirror = forwardRef((props, ref) => {
|
|
1221
|
-
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;
|
|
1256
|
+
const { document, documentIdentity, experimentalSession, suggestionModeActive = false, suggestionAuthor = "User", onSessionRefusal, 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;
|
|
1222
1257
|
const [collaborationModules, setCollaborationModules] = useState(null);
|
|
1223
1258
|
const [collaborationModulesError, setCollaborationModulesError] = useState(null);
|
|
1224
1259
|
const hasCollaboration = collaboration !== void 0;
|
|
1225
1260
|
const hostRef = useRef(null);
|
|
1226
1261
|
const readOnlyRef = useRef(readOnly);
|
|
1262
|
+
const experimentalSessionRef = useRef(experimentalSession);
|
|
1263
|
+
const suggestionModeActiveRef = useRef(suggestionModeActive);
|
|
1264
|
+
const suggestionAuthorRef = useRef(suggestionAuthor);
|
|
1265
|
+
const onSessionRefusalRef = useRef(onSessionRefusal);
|
|
1227
1266
|
const documentRef = useRef(document);
|
|
1228
1267
|
const documentIdentityRef = useRef(documentIdentity);
|
|
1229
1268
|
const stylesRef = useRef(styles);
|
|
@@ -1243,6 +1282,10 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1243
1282
|
const onReadOnlyEditAttemptRef = useRef(onReadOnlyEditAttempt);
|
|
1244
1283
|
const onRemoteSelectionsChangeRef = useRef(onRemoteSelectionsChange);
|
|
1245
1284
|
readOnlyRef.current = readOnly;
|
|
1285
|
+
experimentalSessionRef.current = experimentalSession;
|
|
1286
|
+
suggestionModeActiveRef.current = suggestionModeActive;
|
|
1287
|
+
suggestionAuthorRef.current = suggestionAuthor;
|
|
1288
|
+
onSessionRefusalRef.current = onSessionRefusal;
|
|
1246
1289
|
stylesRef.current = styles;
|
|
1247
1290
|
extensionManagerRef.current = extensionManager;
|
|
1248
1291
|
externalPluginsRef.current = externalPlugins;
|
|
@@ -1272,6 +1315,10 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1272
1315
|
getCollaborationModules: () => collaborationModulesRef.current,
|
|
1273
1316
|
getPrecomputedInitialState: () => precomputedInitialStateRef.current,
|
|
1274
1317
|
getReadOnly: () => readOnlyRef.current,
|
|
1318
|
+
getExperimentalSession: () => experimentalSessionRef.current,
|
|
1319
|
+
getEditingMode: () => suggestionModeActiveRef.current ? "suggesting" : "editing",
|
|
1320
|
+
getSuggestionAuthor: () => suggestionAuthorRef.current,
|
|
1321
|
+
onSessionRefusal: (reason) => onSessionRefusalRef.current?.(reason),
|
|
1275
1322
|
getDocumentIdentity: () => documentIdentityRef.current,
|
|
1276
1323
|
getDocumentContext: () => documentRef.current,
|
|
1277
1324
|
onTransaction: (update) => onTransactionRef.current?.(update),
|
|
@@ -1331,13 +1378,19 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1331
1378
|
}, []);
|
|
1332
1379
|
useLayoutEffect(() => {
|
|
1333
1380
|
managerRef.current?.retryViewCreation();
|
|
1334
|
-
}, [
|
|
1381
|
+
}, [
|
|
1382
|
+
collaboration,
|
|
1383
|
+
collaborationModules,
|
|
1384
|
+
experimentalSession
|
|
1385
|
+
]);
|
|
1335
1386
|
useEffect(() => () => destroyView(), [destroyView]);
|
|
1336
1387
|
useEffect(() => {
|
|
1337
1388
|
managerRef.current?.syncExternalDocument();
|
|
1338
1389
|
}, [
|
|
1339
1390
|
document,
|
|
1340
1391
|
documentIdentity,
|
|
1392
|
+
experimentalSession,
|
|
1393
|
+
suggestionModeActive,
|
|
1341
1394
|
styles,
|
|
1342
1395
|
extensionManager,
|
|
1343
1396
|
externalPlugins,
|
|
@@ -2819,7 +2872,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
|
|
|
2819
2872
|
* PagedEditor - Main paginated editing component.
|
|
2820
2873
|
*/
|
|
2821
2874
|
const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
2822
|
-
const { document, documentIO, documentIdentity, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, markupView, 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, pageEndGutter = 0, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, onError, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
|
|
2875
|
+
const { document, documentIO, documentIdentity, experimentalSession, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, markupView, 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, pageEndGutter = 0, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, onError, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
|
|
2823
2876
|
const getScrollContainer = useCallback(() => {
|
|
2824
2877
|
if (scrollContainerRefProp && typeof scrollContainerRefProp === "object") return getEditorScrollRoot(scrollContainerRefProp.current);
|
|
2825
2878
|
return getEditorScrollRoot(containerRef.current);
|
|
@@ -2837,16 +2890,19 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
2837
2890
|
const hiddenPMRef = useRef(null);
|
|
2838
2891
|
const hfPMsRef = useRef(null);
|
|
2839
2892
|
const noteEditorRef = useRef(null);
|
|
2893
|
+
const activeNoteStoryRef = useRef(null);
|
|
2840
2894
|
const [noteStoryActive, setNoteStoryActive] = useState(false);
|
|
2841
2895
|
const painterRef = useRef(null);
|
|
2842
2896
|
const noteStoryPlugins = useMemo(() => externalPlugins.filter(({ spec }) => spec.key === suggestionModeKey), [externalPlugins]);
|
|
2843
2897
|
const handleActiveNoteStoryChange = useCallback((story) => {
|
|
2898
|
+
activeNoteStoryRef.current = story;
|
|
2844
2899
|
setNoteStoryActive(story !== null);
|
|
2845
2900
|
onActiveNoteStoryChange?.(story);
|
|
2846
2901
|
}, [onActiveNoteStoryChange]);
|
|
2847
2902
|
useEffect(() => {
|
|
2848
|
-
if (readOnly) noteEditorRef.current?.close();
|
|
2849
|
-
}, [readOnly]);
|
|
2903
|
+
if (readOnly || experimentalSession === "canonical") noteEditorRef.current?.close();
|
|
2904
|
+
}, [experimentalSession, readOnly]);
|
|
2905
|
+
const getCanonicalApi = useCallback(() => hiddenPMRef.current, []);
|
|
2850
2906
|
const { handlePMKeyDown } = useVisualLineNavigation({ pagesContainerRef });
|
|
2851
2907
|
const handleHiddenEditorKeyDown = useCallback((view, event) => {
|
|
2852
2908
|
if (getTemplateSlashMenu(view.state).active) return false;
|
|
@@ -2866,6 +2922,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
2866
2922
|
onDocumentChangeRef.current = onDocumentChange;
|
|
2867
2923
|
onTotalPagesChangeRef.current = onTotalPagesChange;
|
|
2868
2924
|
onErrorRef.current = onError;
|
|
2925
|
+
const handleSessionRefusal = useCallback((message) => {
|
|
2926
|
+
onErrorRef.current?.(new CanonicalSessionRefusalError({ message }));
|
|
2927
|
+
}, []);
|
|
2869
2928
|
const [layout, setLayout] = useState(null);
|
|
2870
2929
|
const layoutRef = useRef(layout);
|
|
2871
2930
|
layoutRef.current = layout;
|
|
@@ -2987,12 +3046,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
2987
3046
|
queuedInputBeforeHiddenEditorRef.current = [];
|
|
2988
3047
|
for (const input of queuedInput) {
|
|
2989
3048
|
if (input.type === "text") {
|
|
2990
|
-
|
|
3049
|
+
if (experimentalSession === "canonical") view_0.dom.dispatchEvent(new InputEvent("beforeinput", {
|
|
3050
|
+
inputType: "insertText",
|
|
3051
|
+
data: input.text,
|
|
3052
|
+
cancelable: true,
|
|
3053
|
+
bubbles: true
|
|
3054
|
+
}));
|
|
3055
|
+
else dispatchEditorTextInput(view_0, input.text);
|
|
2991
3056
|
continue;
|
|
2992
3057
|
}
|
|
2993
3058
|
replayDeferredKeyDown(view_0, input.eventInit);
|
|
2994
3059
|
}
|
|
2995
|
-
}, []);
|
|
3060
|
+
}, [experimentalSession]);
|
|
2996
3061
|
useEffect(() => {
|
|
2997
3062
|
if (collaboration !== void 0) ensureHiddenEditorView();
|
|
2998
3063
|
}, [collaboration, ensureHiddenEditorView]);
|
|
@@ -3211,6 +3276,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3211
3276
|
folioEditor,
|
|
3212
3277
|
hfEditMode
|
|
3213
3278
|
]);
|
|
3279
|
+
const getCanonicalActiveStory = useCallback(() => {
|
|
3280
|
+
const note = activeNoteStoryRef.current;
|
|
3281
|
+
if (note) return {
|
|
3282
|
+
kind: note.kind,
|
|
3283
|
+
id: note.noteId
|
|
3284
|
+
};
|
|
3285
|
+
if (hfEditMode && activeHeaderFooterRId) return {
|
|
3286
|
+
kind: hfEditMode,
|
|
3287
|
+
rId: activeHeaderFooterRId
|
|
3288
|
+
};
|
|
3289
|
+
return "main";
|
|
3290
|
+
}, [hfEditMode, activeHeaderFooterRId]);
|
|
3214
3291
|
const paintSettingsInitializedRef = useRef(false);
|
|
3215
3292
|
useEffect(() => {
|
|
3216
3293
|
if (!paintSettingsInitializedRef.current) {
|
|
@@ -3243,12 +3320,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3243
3320
|
}
|
|
3244
3321
|
let newDoc = hiddenPMRef.current?.getDocument();
|
|
3245
3322
|
const body = hiddenPMRef.current?.getState()?.doc;
|
|
3246
|
-
if (newDoc && body) newDoc = noteFollower.reconcile(newDoc, body);
|
|
3323
|
+
if (newDoc && body && experimentalSession !== "canonical") newDoc = noteFollower.reconcile(newDoc, body);
|
|
3247
3324
|
if (newDoc) {
|
|
3248
|
-
onDocumentChangeRef.current?.(newDoc);
|
|
3249
|
-
folioEmitterRef.current.emit("docChange", newDoc);
|
|
3325
|
+
onDocumentChangeRef.current?.(experimentalSession === "canonical" ? cloneDocumentWithParagraphPropertySources(newDoc) : newDoc);
|
|
3326
|
+
folioEmitterRef.current.emit("docChange", experimentalSession === "canonical" ? cloneDocumentWithParagraphPropertySources(newDoc) : newDoc);
|
|
3250
3327
|
}
|
|
3251
|
-
}, [noteFollower]);
|
|
3328
|
+
}, [experimentalSession, noteFollower]);
|
|
3252
3329
|
const scheduleDocumentChangeNotification = useCallback(() => {
|
|
3253
3330
|
if (documentChangeNotifyTimerRef.current !== null) window.clearTimeout(documentChangeNotifyTimerRef.current);
|
|
3254
3331
|
documentChangeNotifyTimerRef.current = window.setTimeout(() => {
|
|
@@ -3853,6 +3930,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3853
3930
|
if (docChanged_0) {
|
|
3854
3931
|
if (!hiddenPMRef.current?.getState() && !precomputedInitialStateRef.current) ensureHiddenEditorView({ sync: true });
|
|
3855
3932
|
scheduleLayout();
|
|
3933
|
+
if (experimentalSession === "canonical") scheduleDocumentChangeNotification();
|
|
3856
3934
|
}
|
|
3857
3935
|
if (docChanged_0 || selectionChanged) {
|
|
3858
3936
|
const { from: from_1, to: to_1 } = view_3.state.selection;
|
|
@@ -3870,7 +3948,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3870
3948
|
to: to_1
|
|
3871
3949
|
});
|
|
3872
3950
|
}
|
|
3873
|
-
}, [
|
|
3951
|
+
}, [
|
|
3952
|
+
scheduleLayout,
|
|
3953
|
+
ensureHiddenEditorView,
|
|
3954
|
+
experimentalSession,
|
|
3955
|
+
scheduleDocumentChangeNotification
|
|
3956
|
+
]);
|
|
3874
3957
|
const handleNoteStoryTransaction = useCallback((view_4, docChanged_1, selectionChanged_0) => {
|
|
3875
3958
|
if (docChanged_1) scheduleLayout();
|
|
3876
3959
|
if (docChanged_1 || selectionChanged_0) {
|
|
@@ -3883,9 +3966,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3883
3966
|
}
|
|
3884
3967
|
}, [scheduleLayout]);
|
|
3885
3968
|
const handleNoteDocumentChange = useCallback((updated) => {
|
|
3886
|
-
onDocumentChangeRef.current?.(updated);
|
|
3887
|
-
folioEmitterRef.current.emit("docChange", updated);
|
|
3888
|
-
}, []);
|
|
3969
|
+
onDocumentChangeRef.current?.(experimentalSession === "canonical" ? cloneDocumentWithParagraphPropertySources(updated) : updated);
|
|
3970
|
+
folioEmitterRef.current.emit("docChange", experimentalSession === "canonical" ? cloneDocumentWithParagraphPropertySources(updated) : updated);
|
|
3971
|
+
}, [experimentalSession]);
|
|
3889
3972
|
useEffect(() => {
|
|
3890
3973
|
if (!hfEditMode) setHfCaretSelection(null);
|
|
3891
3974
|
dragAnchorRef.current = null;
|
|
@@ -4750,6 +4833,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4750
4833
|
if (story_0) {
|
|
4751
4834
|
e_3.preventDefault();
|
|
4752
4835
|
e_3.stopPropagation();
|
|
4836
|
+
if (experimentalSession === "canonical") {
|
|
4837
|
+
handleSessionRefusal("Footnote and endnote editing is unavailable in this session.");
|
|
4838
|
+
return;
|
|
4839
|
+
}
|
|
4753
4840
|
noteEditorRef.current?.open(story_0);
|
|
4754
4841
|
return;
|
|
4755
4842
|
}
|
|
@@ -4893,7 +4980,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4893
4980
|
}
|
|
4894
4981
|
}
|
|
4895
4982
|
}, [
|
|
4983
|
+
experimentalSession,
|
|
4896
4984
|
getPositionFromMouse,
|
|
4985
|
+
handleSessionRefusal,
|
|
4897
4986
|
onHeaderFooterDoubleClick,
|
|
4898
4987
|
onHyperlinkClick,
|
|
4899
4988
|
readOnly
|
|
@@ -5401,6 +5490,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5401
5490
|
getDocument() {
|
|
5402
5491
|
if (documentChangeNotifyTimerRef.current !== null) flushDocumentChangeNotification();
|
|
5403
5492
|
const editorDocument = folioEditor.getDocument();
|
|
5493
|
+
if (experimentalSession === "canonical") return editorDocument;
|
|
5404
5494
|
const current_0 = editorDocument ? noteFollower.withPending(editorDocument) : null;
|
|
5405
5495
|
return current_0 ? noteEditorRef.current?.snapshotDocument(current_0) ?? current_0 : null;
|
|
5406
5496
|
},
|
|
@@ -5411,12 +5501,14 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5411
5501
|
return folioEditor.getView();
|
|
5412
5502
|
},
|
|
5413
5503
|
getActiveView() {
|
|
5504
|
+
if (experimentalSession === "canonical") return folioEditor.getView();
|
|
5414
5505
|
return getActiveEditorStory().view;
|
|
5415
5506
|
},
|
|
5416
5507
|
closeNoteStory() {
|
|
5417
5508
|
noteEditorRef.current?.close();
|
|
5418
5509
|
},
|
|
5419
5510
|
getHfView(rId_0) {
|
|
5511
|
+
if (experimentalSession === "canonical") return null;
|
|
5420
5512
|
return hfPMsRef.current?.getView(rId_0) ?? null;
|
|
5421
5513
|
},
|
|
5422
5514
|
ensureView(options_4) {
|
|
@@ -5442,22 +5534,34 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5442
5534
|
undo() {
|
|
5443
5535
|
const target_5 = getActiveEditorStory();
|
|
5444
5536
|
if (target_5.type === "none") return false;
|
|
5445
|
-
|
|
5537
|
+
if (experimentalSession === "canonical") return hiddenPMRef.current?.applyCanonicalStoryHistory({
|
|
5538
|
+
view: target_5.view,
|
|
5539
|
+
story: getCanonicalActiveStory(),
|
|
5540
|
+
direction: "undo"
|
|
5541
|
+
}) ?? false;
|
|
5542
|
+
if (target_5.type === "body") return hiddenPMRef.current?.undo() ?? false;
|
|
5543
|
+
return undo(target_5.view.state, target_5.view.dispatch);
|
|
5446
5544
|
},
|
|
5447
5545
|
redo() {
|
|
5448
5546
|
const target_6 = getActiveEditorStory();
|
|
5449
5547
|
if (target_6.type === "none") return false;
|
|
5450
|
-
|
|
5548
|
+
if (experimentalSession === "canonical") return hiddenPMRef.current?.applyCanonicalStoryHistory({
|
|
5549
|
+
view: target_6.view,
|
|
5550
|
+
story: getCanonicalActiveStory(),
|
|
5551
|
+
direction: "redo"
|
|
5552
|
+
}) ?? false;
|
|
5553
|
+
if (target_6.type === "body") return hiddenPMRef.current?.redo() ?? false;
|
|
5554
|
+
return redo(target_6.view.state, target_6.view.dispatch);
|
|
5451
5555
|
},
|
|
5452
5556
|
canUndo() {
|
|
5453
5557
|
const target_7 = getActiveEditorStory();
|
|
5454
5558
|
if (target_7.type === "none") return false;
|
|
5455
|
-
return target_7.type === "body" ? hiddenPMRef.current?.canUndo() ?? false : undo(target_7.view.state);
|
|
5559
|
+
return experimentalSession === "canonical" || target_7.type === "body" ? hiddenPMRef.current?.canUndo() ?? false : undo(target_7.view.state);
|
|
5456
5560
|
},
|
|
5457
5561
|
canRedo() {
|
|
5458
5562
|
const target_8 = getActiveEditorStory();
|
|
5459
5563
|
if (target_8.type === "none") return false;
|
|
5460
|
-
return target_8.type === "body" ? hiddenPMRef.current?.canRedo() ?? false : redo(target_8.view.state);
|
|
5564
|
+
return experimentalSession === "canonical" || target_8.type === "body" ? hiddenPMRef.current?.canRedo() ?? false : redo(target_8.view.state);
|
|
5461
5565
|
},
|
|
5462
5566
|
setSelection(anchor_3, head_1) {
|
|
5463
5567
|
folioEditor.setSelection(anchor_3, head_1);
|
|
@@ -5541,6 +5645,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5541
5645
|
flushDocumentChangeNotification,
|
|
5542
5646
|
folioEditor,
|
|
5543
5647
|
getActiveEditorStory,
|
|
5648
|
+
getCanonicalActiveStory,
|
|
5544
5649
|
noteFollower,
|
|
5545
5650
|
getScrollContainer,
|
|
5546
5651
|
refreshBodyImeCaretAnchor,
|
|
@@ -5614,6 +5719,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5614
5719
|
ref: hfPMsRef,
|
|
5615
5720
|
document,
|
|
5616
5721
|
onTransaction: handleHfPmTransaction,
|
|
5722
|
+
getCanonicalApi,
|
|
5723
|
+
onSessionRefusal: handleSessionRefusal,
|
|
5724
|
+
...experimentalSession === void 0 ? {} : { experimentalSession },
|
|
5617
5725
|
...styles !== void 0 ? { styles } : {},
|
|
5618
5726
|
..._theme !== void 0 ? { theme: _theme } : {}
|
|
5619
5727
|
}),
|
|
@@ -5621,6 +5729,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5621
5729
|
ref: noteEditorRef,
|
|
5622
5730
|
document,
|
|
5623
5731
|
onActiveChange: handleActiveNoteStoryChange,
|
|
5732
|
+
getCanonicalApi,
|
|
5733
|
+
onSessionRefusal: handleSessionRefusal,
|
|
5734
|
+
...experimentalSession === void 0 ? {} : { experimentalSession },
|
|
5624
5735
|
onDocumentChange: handleNoteDocumentChange,
|
|
5625
5736
|
onStoryChange: handleNoteStoryTransaction,
|
|
5626
5737
|
plugins: noteStoryPlugins,
|
|
@@ -5633,6 +5744,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5633
5744
|
ref: hiddenPMRef,
|
|
5634
5745
|
document,
|
|
5635
5746
|
documentIdentity,
|
|
5747
|
+
...experimentalSession === void 0 ? {} : { experimentalSession },
|
|
5748
|
+
onSessionRefusal: handleSessionRefusal,
|
|
5749
|
+
...suggestionAuthor !== void 0 ? { suggestionAuthor } : {},
|
|
5750
|
+
suggestionModeActive,
|
|
5636
5751
|
widthPx: contentWidth,
|
|
5637
5752
|
precomputedInitialState: validPrecomputedInitialState,
|
|
5638
5753
|
readOnly,
|
|
@@ -10060,16 +10175,17 @@ function useContextMenu(t0) {
|
|
|
10060
10175
|
* callbacks each render.
|
|
10061
10176
|
*/
|
|
10062
10177
|
const useDocumentLoader = (t0) => {
|
|
10063
|
-
const $ = c(
|
|
10064
|
-
const { documentBuffer, initialDocument, password, history, onError, onCompatibilityChange, onReset, setDocumentLoadState } = t0;
|
|
10178
|
+
const $ = c(28);
|
|
10179
|
+
const { documentBuffer, initialDocument, password, experimentalSession, history, onError, onCompatibilityChange, onReset, setDocumentLoadState } = t0;
|
|
10065
10180
|
const originalBufferRef = useRef(null);
|
|
10066
10181
|
const originalBufferIdentityRef = useRef(null);
|
|
10067
10182
|
const [loadedDocumentIdentity, setLoadedDocumentIdentity] = useState("0");
|
|
10068
10183
|
let t1;
|
|
10069
|
-
if ($[0] !==
|
|
10184
|
+
if ($[0] !== experimentalSession || $[1] !== history || $[2] !== onCompatibilityChange || $[3] !== onError || $[4] !== onReset || $[5] !== setDocumentLoadState) {
|
|
10070
10185
|
t1 = () => {
|
|
10071
10186
|
const instance = new DocumentLoaderManager({
|
|
10072
10187
|
history,
|
|
10188
|
+
getExperimentalSession: () => experimentalSession,
|
|
10073
10189
|
onError,
|
|
10074
10190
|
onCompatibilityChange,
|
|
10075
10191
|
onReset,
|
|
@@ -10085,17 +10201,19 @@ const useDocumentLoader = (t0) => {
|
|
|
10085
10201
|
}
|
|
10086
10202
|
};
|
|
10087
10203
|
};
|
|
10088
|
-
$[0] =
|
|
10089
|
-
$[1] =
|
|
10090
|
-
$[2] =
|
|
10091
|
-
$[3] =
|
|
10092
|
-
$[4] =
|
|
10093
|
-
$[5] =
|
|
10094
|
-
|
|
10204
|
+
$[0] = experimentalSession;
|
|
10205
|
+
$[1] = history;
|
|
10206
|
+
$[2] = onCompatibilityChange;
|
|
10207
|
+
$[3] = onError;
|
|
10208
|
+
$[4] = onReset;
|
|
10209
|
+
$[5] = setDocumentLoadState;
|
|
10210
|
+
$[6] = t1;
|
|
10211
|
+
} else t1 = $[6];
|
|
10095
10212
|
const [t2] = useState(t1);
|
|
10096
10213
|
const { manager, api } = t2;
|
|
10097
10214
|
manager.setCallbacks({
|
|
10098
10215
|
history,
|
|
10216
|
+
getExperimentalSession: () => experimentalSession,
|
|
10099
10217
|
onError,
|
|
10100
10218
|
onCompatibilityChange,
|
|
10101
10219
|
onReset,
|
|
@@ -10103,8 +10221,7 @@ const useDocumentLoader = (t0) => {
|
|
|
10103
10221
|
setLoadedDocumentIdentity
|
|
10104
10222
|
});
|
|
10105
10223
|
let t3;
|
|
10106
|
-
|
|
10107
|
-
if ($[6] !== api || $[7] !== documentBuffer || $[8] !== initialDocument || $[9] !== password) {
|
|
10224
|
+
if ($[7] !== api || $[8] !== documentBuffer || $[9] !== initialDocument || $[10] !== password) {
|
|
10108
10225
|
t3 = () => {
|
|
10109
10226
|
const source = getDocumentLoadSource({
|
|
10110
10227
|
documentBuffer,
|
|
@@ -10117,26 +10234,32 @@ const useDocumentLoader = (t0) => {
|
|
|
10117
10234
|
}
|
|
10118
10235
|
api.loadBuffer(source.buffer, { password });
|
|
10119
10236
|
};
|
|
10237
|
+
$[7] = api;
|
|
10238
|
+
$[8] = documentBuffer;
|
|
10239
|
+
$[9] = initialDocument;
|
|
10240
|
+
$[10] = password;
|
|
10241
|
+
$[11] = t3;
|
|
10242
|
+
} else t3 = $[11];
|
|
10243
|
+
let t4;
|
|
10244
|
+
if ($[12] !== api || $[13] !== documentBuffer || $[14] !== experimentalSession || $[15] !== initialDocument || $[16] !== password) {
|
|
10120
10245
|
t4 = [
|
|
10121
10246
|
documentBuffer,
|
|
10122
10247
|
initialDocument,
|
|
10123
10248
|
password,
|
|
10249
|
+
experimentalSession,
|
|
10124
10250
|
api
|
|
10125
10251
|
];
|
|
10126
|
-
$[
|
|
10127
|
-
$[
|
|
10128
|
-
$[
|
|
10129
|
-
$[
|
|
10130
|
-
$[
|
|
10131
|
-
$[
|
|
10132
|
-
} else
|
|
10133
|
-
t3 = $[10];
|
|
10134
|
-
t4 = $[11];
|
|
10135
|
-
}
|
|
10252
|
+
$[12] = api;
|
|
10253
|
+
$[13] = documentBuffer;
|
|
10254
|
+
$[14] = experimentalSession;
|
|
10255
|
+
$[15] = initialDocument;
|
|
10256
|
+
$[16] = password;
|
|
10257
|
+
$[17] = t4;
|
|
10258
|
+
} else t4 = $[17];
|
|
10136
10259
|
useEffect(t3, t4);
|
|
10137
10260
|
let t5;
|
|
10138
10261
|
let t6;
|
|
10139
|
-
if ($[
|
|
10262
|
+
if ($[18] !== documentBuffer || $[19] !== history.state || $[20] !== loadedDocumentIdentity) {
|
|
10140
10263
|
t5 = () => {
|
|
10141
10264
|
if (originalBufferIdentityRef.current === loadedDocumentIdentity) return;
|
|
10142
10265
|
originalBufferIdentityRef.current = loadedDocumentIdentity;
|
|
@@ -10151,18 +10274,18 @@ const useDocumentLoader = (t0) => {
|
|
|
10151
10274
|
documentBuffer,
|
|
10152
10275
|
loadedDocumentIdentity
|
|
10153
10276
|
];
|
|
10154
|
-
$[
|
|
10155
|
-
$[
|
|
10156
|
-
$[
|
|
10157
|
-
$[
|
|
10158
|
-
$[
|
|
10277
|
+
$[18] = documentBuffer;
|
|
10278
|
+
$[19] = history.state;
|
|
10279
|
+
$[20] = loadedDocumentIdentity;
|
|
10280
|
+
$[21] = t5;
|
|
10281
|
+
$[22] = t6;
|
|
10159
10282
|
} else {
|
|
10160
|
-
t5 = $[
|
|
10161
|
-
t6 = $[
|
|
10283
|
+
t5 = $[21];
|
|
10284
|
+
t6 = $[22];
|
|
10162
10285
|
}
|
|
10163
10286
|
useEffect(t5, t6);
|
|
10164
10287
|
let t7;
|
|
10165
|
-
if ($[
|
|
10288
|
+
if ($[23] !== api.loadBuffer || $[24] !== api.loadParsedDocument || $[25] !== api.resetForNewDocument || $[26] !== loadedDocumentIdentity) {
|
|
10166
10289
|
t7 = {
|
|
10167
10290
|
loadBuffer: api.loadBuffer,
|
|
10168
10291
|
loadParsedDocument: api.loadParsedDocument,
|
|
@@ -10170,12 +10293,12 @@ const useDocumentLoader = (t0) => {
|
|
|
10170
10293
|
originalBufferRef,
|
|
10171
10294
|
loadedDocumentIdentity
|
|
10172
10295
|
};
|
|
10173
|
-
$[
|
|
10174
|
-
$[
|
|
10175
|
-
$[
|
|
10176
|
-
$[
|
|
10177
|
-
$[
|
|
10178
|
-
} else t7 = $[
|
|
10296
|
+
$[23] = api.loadBuffer;
|
|
10297
|
+
$[24] = api.loadParsedDocument;
|
|
10298
|
+
$[25] = api.resetForNewDocument;
|
|
10299
|
+
$[26] = loadedDocumentIdentity;
|
|
10300
|
+
$[27] = t7;
|
|
10301
|
+
} else t7 = $[27];
|
|
10179
10302
|
return t7;
|
|
10180
10303
|
};
|
|
10181
10304
|
//#endregion
|
|
@@ -10458,7 +10581,7 @@ const saveAndCloseHeaderFooterEdit = ({ activeRId, document, editPosition, isFir
|
|
|
10458
10581
|
if (newDocument) pushDocument(newDocument);
|
|
10459
10582
|
setEditPosition(null);
|
|
10460
10583
|
};
|
|
10461
|
-
const useHeaderFooterEditor = ({ history, pushDocument, getHfView }) => {
|
|
10584
|
+
const useHeaderFooterEditor = ({ history, pushDocument, getHfView, getCanonicalApi, experimentalSession }) => {
|
|
10462
10585
|
const [hfEditPosition, setHfEditPosition] = useState(null);
|
|
10463
10586
|
const [hfEditIsFirstPage, setHfEditIsFirstPage] = useState(false);
|
|
10464
10587
|
const rawResolution = useMemo(() => resolveHeaderFooterContent(history.state?.package), [history.state]);
|
|
@@ -10476,6 +10599,19 @@ const useHeaderFooterEditor = ({ history, pushDocument, getHfView }) => {
|
|
|
10476
10599
|
setHfEditPosition(position);
|
|
10477
10600
|
return;
|
|
10478
10601
|
}
|
|
10602
|
+
if (experimentalSession === "canonical") {
|
|
10603
|
+
const api = getCanonicalApi?.();
|
|
10604
|
+
api?.ensureView();
|
|
10605
|
+
const canonical = api?.getCanonicalDocument();
|
|
10606
|
+
if (!canonical || !api) return;
|
|
10607
|
+
const operation = createCanonicalHeaderFooterOperation({
|
|
10608
|
+
document: canonical,
|
|
10609
|
+
position,
|
|
10610
|
+
referenceType: isFirstPage ? "first" : "default"
|
|
10611
|
+
});
|
|
10612
|
+
if (api.applyCanonicalOperations([operation])) setHfEditPosition(position);
|
|
10613
|
+
return;
|
|
10614
|
+
}
|
|
10479
10615
|
if (!history.state) return;
|
|
10480
10616
|
const newDoc = createEmptyHeaderFooter(history.state, position, isFirstPage);
|
|
10481
10617
|
if (!newDoc) return;
|
|
@@ -10488,9 +10624,15 @@ const useHeaderFooterEditor = ({ history, pushDocument, getHfView }) => {
|
|
|
10488
10624
|
firstPageFooterContent,
|
|
10489
10625
|
hasTitlePg,
|
|
10490
10626
|
history,
|
|
10491
|
-
pushDocument
|
|
10627
|
+
pushDocument,
|
|
10628
|
+
getCanonicalApi,
|
|
10629
|
+
experimentalSession
|
|
10492
10630
|
]);
|
|
10493
10631
|
const handleHeaderFooterSave = useCallback(() => {
|
|
10632
|
+
if (experimentalSession === "canonical") {
|
|
10633
|
+
setHfEditPosition(null);
|
|
10634
|
+
return;
|
|
10635
|
+
}
|
|
10494
10636
|
if (!hfEditPosition || !history.state?.package) {
|
|
10495
10637
|
setHfEditPosition(null);
|
|
10496
10638
|
return;
|
|
@@ -10512,7 +10654,8 @@ const useHeaderFooterEditor = ({ history, pushDocument, getHfView }) => {
|
|
|
10512
10654
|
resolution,
|
|
10513
10655
|
history,
|
|
10514
10656
|
pushDocument,
|
|
10515
|
-
getHfView
|
|
10657
|
+
getHfView,
|
|
10658
|
+
experimentalSession
|
|
10516
10659
|
]);
|
|
10517
10660
|
return {
|
|
10518
10661
|
hfEditPosition,
|
|
@@ -10540,6 +10683,17 @@ const useHeaderFooterEditor = ({ history, pushDocument, getHfView }) => {
|
|
|
10540
10683
|
return;
|
|
10541
10684
|
}
|
|
10542
10685
|
const activeRId_0 = pickActiveHeaderFooterRId(resolution, hfEditPosition, hfEditIsFirstPage);
|
|
10686
|
+
if (experimentalSession === "canonical") {
|
|
10687
|
+
const api_0 = getCanonicalApi?.();
|
|
10688
|
+
const canonical_0 = api_0?.getCanonicalDocument();
|
|
10689
|
+
if (api_0 && canonical_0 && activeRId_0) api_0.applyCanonicalOperations(removeCanonicalHeaderFooterOperations({
|
|
10690
|
+
document: canonical_0,
|
|
10691
|
+
position: hfEditPosition,
|
|
10692
|
+
rId: activeRId_0
|
|
10693
|
+
}));
|
|
10694
|
+
setHfEditPosition(null);
|
|
10695
|
+
return;
|
|
10696
|
+
}
|
|
10543
10697
|
if (activeRId_0) pushDocument(removeHeaderFooter({
|
|
10544
10698
|
document: history.state,
|
|
10545
10699
|
position: hfEditPosition,
|
|
@@ -10551,7 +10705,9 @@ const useHeaderFooterEditor = ({ history, pushDocument, getHfView }) => {
|
|
|
10551
10705
|
hfEditIsFirstPage,
|
|
10552
10706
|
resolution,
|
|
10553
10707
|
history,
|
|
10554
|
-
pushDocument
|
|
10708
|
+
pushDocument,
|
|
10709
|
+
getCanonicalApi,
|
|
10710
|
+
experimentalSession
|
|
10555
10711
|
])
|
|
10556
10712
|
};
|
|
10557
10713
|
};
|
|
@@ -12793,7 +12949,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
|
|
|
12793
12949
|
*/
|
|
12794
12950
|
/** No headings to track while the outline is not shown. */
|
|
12795
12951
|
const NO_HEADINGS = [];
|
|
12796
|
-
const CommentsSidebar = lazy(() => import("./CommentsSidebar-
|
|
12952
|
+
const CommentsSidebar = lazy(() => import("./CommentsSidebar-D9vMIMl7.js").then((m) => ({ default: m.CommentsSidebar })));
|
|
12797
12953
|
const TextContextMenu = lazy(() => import("./TextContextMenu-Bqth8itn.js").then((m) => ({ default: m.TextContextMenu })));
|
|
12798
12954
|
const loadAttemptSelectiveSave = async () => {
|
|
12799
12955
|
const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
|
|
@@ -12864,7 +13020,7 @@ function areActiveTrackedChangesEqual(a, b) {
|
|
|
12864
13020
|
/**
|
|
12865
13021
|
* DocxEditor - Complete DOCX editor component
|
|
12866
13022
|
*/
|
|
12867
|
-
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, pageRenderer, showMarginGuides = false, marginGuideColor, showRuler: showRulerProp = false, rulerUnit = "inch", initialZoom = 1, enableWheelZoom = true, keyboardShortcuts = "document", hostShortcuts: hostShortcutsProp, 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, plugins, featureFlags, onSelectiveSaveTripwire }, ref) {
|
|
13023
|
+
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, pageRenderer, showMarginGuides = false, marginGuideColor, showRuler: showRulerProp = false, rulerUnit = "inch", initialZoom = 1, enableWheelZoom = true, keyboardShortcuts = "document", hostShortcuts: hostShortcutsProp, 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, plugins, featureFlags, experimentalSession, onSelectiveSaveTripwire }, ref) {
|
|
12868
13024
|
const t = useTranslations("folio");
|
|
12869
13025
|
useEffect(() => {
|
|
12870
13026
|
const onClipboardReadError = () => {
|
|
@@ -12903,11 +13059,25 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
12903
13059
|
const [, setTrackedChanges] = useState([]);
|
|
12904
13060
|
const trackedChangesRef = useRef([]);
|
|
12905
13061
|
const [anchorPositions, setAnchorPositions] = useState(EMPTY_ANCHOR_POSITIONS);
|
|
12906
|
-
const { editingMode, readOnly, trackChangesOn, toggleTrackChanges, displayMode, setDisplayMode } = useEditorMode({
|
|
13062
|
+
const { editingMode, readOnly, trackChangesOn, toggleTrackChanges: toggleTrackChangesUnrestricted, displayMode, setDisplayMode } = useEditorMode({
|
|
12907
13063
|
modeProp,
|
|
12908
13064
|
onModeChange,
|
|
12909
13065
|
readOnlyProp
|
|
12910
13066
|
});
|
|
13067
|
+
const toggleTrackChanges = useCallback(() => {
|
|
13068
|
+
if (experimentalSession === "canonical" && !trackChangesOn) {
|
|
13069
|
+
const error = new CanonicalSessionRefusalError({ message: "Canonical sessions do not support suggesting mode." });
|
|
13070
|
+
toast(error.message);
|
|
13071
|
+
onError?.(error);
|
|
13072
|
+
return;
|
|
13073
|
+
}
|
|
13074
|
+
toggleTrackChangesUnrestricted();
|
|
13075
|
+
}, [
|
|
13076
|
+
experimentalSession,
|
|
13077
|
+
trackChangesOn,
|
|
13078
|
+
onError,
|
|
13079
|
+
toggleTrackChangesUnrestricted
|
|
13080
|
+
]);
|
|
12911
13081
|
const extractTrackedChangesTimerRef = useRef(null);
|
|
12912
13082
|
const collectHeadingsTimerRef = useRef(null);
|
|
12913
13083
|
const extractTrackedChanges = useCallback(() => {
|
|
@@ -12956,8 +13126,15 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
12956
13126
|
const history = useDocumentHistory(initialDocument || null, {
|
|
12957
13127
|
maxEntries: 100,
|
|
12958
13128
|
groupingInterval: 500,
|
|
12959
|
-
enableKeyboardShortcuts: historyShortcuts === "editor"
|
|
13129
|
+
enableKeyboardShortcuts: historyShortcuts === "editor" && experimentalSession !== "canonical"
|
|
12960
13130
|
});
|
|
13131
|
+
const refuseCanonicalModelEdit = useCallback((message) => {
|
|
13132
|
+
if (experimentalSession !== "canonical") return false;
|
|
13133
|
+
const error_0 = new CanonicalSessionRefusalError({ message });
|
|
13134
|
+
toast(error_0.message);
|
|
13135
|
+
onError?.(error_0);
|
|
13136
|
+
return true;
|
|
13137
|
+
}, [experimentalSession, onError]);
|
|
12961
13138
|
const extensionManager = useMemo(() => {
|
|
12962
13139
|
const mgr = new ExtensionManager(createStarterKit({ historyShortcuts }));
|
|
12963
13140
|
mgr.buildSchema();
|
|
@@ -13177,6 +13354,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13177
13354
|
canUndo: false
|
|
13178
13355
|
});
|
|
13179
13356
|
const [activeNoteStory, setActiveNoteStory] = useState(null);
|
|
13357
|
+
const canEditHeaderFooter = showHeaderFooterEditing;
|
|
13358
|
+
const getCanonicalApi = useCallback(() => pagedEditorRef.current?.getEditor() ?? null, []);
|
|
13180
13359
|
const pushDocument = useCallback((document) => {
|
|
13181
13360
|
history.push(document);
|
|
13182
13361
|
return document;
|
|
@@ -13192,6 +13371,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13192
13371
|
const { hfEditPosition, setHfEditPosition, hfEditIsFirstPage, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, activeHeaderRId, activeFooterRId, activeFirstHeaderRId, activeFirstFooterRId, effectiveSectionProperties, handleHeaderFooterDoubleClick, handleBodyClick, handleRemoveHeaderFooter } = useHeaderFooterEditor({
|
|
13193
13372
|
history,
|
|
13194
13373
|
pushDocument,
|
|
13374
|
+
getCanonicalApi,
|
|
13375
|
+
...experimentalSession === void 0 ? {} : { experimentalSession },
|
|
13195
13376
|
getHfView: (rId) => pagedEditorRef.current?.getHfView(rId) ?? null
|
|
13196
13377
|
});
|
|
13197
13378
|
let activeHfRId = hfEditIsFirstPage ? activeFirstFooterRId : activeFooterRId;
|
|
@@ -13224,19 +13405,27 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13224
13405
|
else pagedEditorRef.current?.focus();
|
|
13225
13406
|
}, [getActiveEditorStory]);
|
|
13226
13407
|
const undoActiveEditor = useCallback(() => {
|
|
13227
|
-
if (getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) hfEditorRef.current.undo();
|
|
13408
|
+
if (experimentalSession !== "canonical" && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) hfEditorRef.current.undo();
|
|
13228
13409
|
else {
|
|
13229
13410
|
pagedEditorRef.current?.undo();
|
|
13230
13411
|
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
13231
13412
|
}
|
|
13232
|
-
}, [
|
|
13413
|
+
}, [
|
|
13414
|
+
getActiveEditorStory,
|
|
13415
|
+
refreshBodyHistoryAvailability,
|
|
13416
|
+
experimentalSession
|
|
13417
|
+
]);
|
|
13233
13418
|
const redoActiveEditor = useCallback(() => {
|
|
13234
|
-
if (getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) hfEditorRef.current.redo();
|
|
13419
|
+
if (experimentalSession !== "canonical" && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) hfEditorRef.current.redo();
|
|
13235
13420
|
else {
|
|
13236
13421
|
pagedEditorRef.current?.redo();
|
|
13237
13422
|
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
13238
13423
|
}
|
|
13239
|
-
}, [
|
|
13424
|
+
}, [
|
|
13425
|
+
getActiveEditorStory,
|
|
13426
|
+
refreshBodyHistoryAvailability,
|
|
13427
|
+
experimentalSession
|
|
13428
|
+
]);
|
|
13240
13429
|
const handleActiveNoteStoryChange = useCallback((story) => {
|
|
13241
13430
|
setActiveNoteStory(story);
|
|
13242
13431
|
if (story && hfEditPosition) handleBodyClick();
|
|
@@ -13260,6 +13449,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13260
13449
|
documentBuffer: documentBuffer ?? null,
|
|
13261
13450
|
initialDocument: initialDocument ?? null,
|
|
13262
13451
|
password,
|
|
13452
|
+
...experimentalSession === void 0 ? {} : { experimentalSession },
|
|
13263
13453
|
history,
|
|
13264
13454
|
onError,
|
|
13265
13455
|
onCompatibilityChange,
|
|
@@ -13373,7 +13563,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13373
13563
|
}
|
|
13374
13564
|
};
|
|
13375
13565
|
pushDocument(documentWithComments);
|
|
13376
|
-
onChange?.(documentWithComments);
|
|
13566
|
+
onChange?.(experimentalSession === "canonical" ? cloneDocumentWithParagraphPropertySources(documentWithComments) : documentWithComments);
|
|
13377
13567
|
if (showOutlineRef.current) {
|
|
13378
13568
|
if (collectHeadingsTimerRef.current) clearTimeout(collectHeadingsTimerRef.current);
|
|
13379
13569
|
collectHeadingsTimerRef.current = setTimeout(() => {
|
|
@@ -13394,10 +13584,14 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13394
13584
|
pushDocument,
|
|
13395
13585
|
extractTrackedChanges,
|
|
13396
13586
|
refreshBodyHistoryAvailability,
|
|
13397
|
-
commentsRef
|
|
13587
|
+
commentsRef,
|
|
13588
|
+
experimentalSession
|
|
13398
13589
|
]);
|
|
13399
13590
|
const buildCurrentDocument = useCallback(() => {
|
|
13400
13591
|
if (!history.state) return null;
|
|
13592
|
+
const canonical = pagedEditorRef.current?.getEditor().getCanonicalDocument();
|
|
13593
|
+
if (canonical) return canonical;
|
|
13594
|
+
if (experimentalSession === "canonical") return null;
|
|
13401
13595
|
let doc_0 = cloneDocumentWithParagraphPropertySources(history.state);
|
|
13402
13596
|
const pmDoc = pagedEditorRef.current?.getDocument();
|
|
13403
13597
|
if (pmDoc) {
|
|
@@ -13422,8 +13616,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13422
13616
|
const referencedCommentIds = collectCommentIdsFromSources(doc_0.package.document.content, doc_0.package.headers, doc_0.package.footers, doc_0.package.footnotes, doc_0.package.endnotes);
|
|
13423
13617
|
doc_0.package.document.comments = pruneOrphanedComments(commentsRef.current, referencedCommentIds);
|
|
13424
13618
|
return doc_0;
|
|
13425
|
-
}, [
|
|
13619
|
+
}, [
|
|
13620
|
+
history.state,
|
|
13621
|
+
commentsRef,
|
|
13622
|
+
experimentalSession
|
|
13623
|
+
]);
|
|
13426
13624
|
const replaceComments = useCallback((nextComments) => {
|
|
13625
|
+
if (experimentalSession === "canonical") {
|
|
13626
|
+
refuseCanonicalModelEdit("Comment changes are unavailable in this session.");
|
|
13627
|
+
return;
|
|
13628
|
+
}
|
|
13427
13629
|
commentsDirtyRef.current = true;
|
|
13428
13630
|
setComments(nextComments);
|
|
13429
13631
|
const currentDocument = buildCurrentDocument();
|
|
@@ -13432,7 +13634,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13432
13634
|
}, [
|
|
13433
13635
|
buildCurrentDocument,
|
|
13434
13636
|
commentsDirtyRef,
|
|
13637
|
+
experimentalSession,
|
|
13435
13638
|
onChange,
|
|
13639
|
+
refuseCanonicalModelEdit,
|
|
13436
13640
|
setComments
|
|
13437
13641
|
]);
|
|
13438
13642
|
const updateComments = useCallback((updater) => {
|
|
@@ -13685,6 +13889,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13685
13889
|
roots: shortcutRoots
|
|
13686
13890
|
});
|
|
13687
13891
|
const handleApplyFootnoteProperties = useCallback((footnotePr, endnotePr) => {
|
|
13892
|
+
if (experimentalSession === "canonical") {
|
|
13893
|
+
const api = getCanonicalApi();
|
|
13894
|
+
api?.ensureView();
|
|
13895
|
+
const canonical_0 = api?.getCanonicalDocument();
|
|
13896
|
+
if (!canonical_0 || !api?.applyCanonicalOperations([createCanonicalSectionPropertiesOperation(canonical_0, {
|
|
13897
|
+
footnotePr,
|
|
13898
|
+
endnotePr
|
|
13899
|
+
})])) refuseCanonicalModelEdit("Section property changes could not be applied.");
|
|
13900
|
+
return;
|
|
13901
|
+
}
|
|
13688
13902
|
if (!history.state?.package) return;
|
|
13689
13903
|
const newDoc = {
|
|
13690
13904
|
...history.state.package.document,
|
|
@@ -13701,7 +13915,13 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13701
13915
|
document: newDoc
|
|
13702
13916
|
}
|
|
13703
13917
|
});
|
|
13704
|
-
}, [
|
|
13918
|
+
}, [
|
|
13919
|
+
history,
|
|
13920
|
+
pushDocument,
|
|
13921
|
+
experimentalSession,
|
|
13922
|
+
getCanonicalApi,
|
|
13923
|
+
refuseCanonicalModelEdit
|
|
13924
|
+
]);
|
|
13705
13925
|
const handleTableAction = useCallback((action_0) => {
|
|
13706
13926
|
const view_9 = getActiveEditorView();
|
|
13707
13927
|
if (!view_9) return;
|
|
@@ -13896,92 +14116,95 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13896
14116
|
const tr = view_10.state.tr.setSelection(TextSelection.create(view_10.state.doc, savedSelection.from, savedSelection.to));
|
|
13897
14117
|
view_10.dispatch(tr);
|
|
13898
14118
|
} catch {}
|
|
13899
|
-
const commandState = view_10.state;
|
|
13900
14119
|
if (action_1 === "bold") {
|
|
13901
|
-
|
|
14120
|
+
executeEditorCommand(view_10, toggleBold);
|
|
13902
14121
|
return;
|
|
13903
14122
|
}
|
|
13904
14123
|
if (action_1 === "italic") {
|
|
13905
|
-
|
|
14124
|
+
executeEditorCommand(view_10, toggleItalic);
|
|
13906
14125
|
return;
|
|
13907
14126
|
}
|
|
13908
14127
|
if (action_1 === "underline") {
|
|
13909
|
-
|
|
14128
|
+
executeEditorCommand(view_10, toggleUnderline);
|
|
13910
14129
|
return;
|
|
13911
14130
|
}
|
|
13912
14131
|
if (action_1 === "strikethrough") {
|
|
13913
|
-
|
|
14132
|
+
executeEditorCommand(view_10, toggleStrike);
|
|
13914
14133
|
return;
|
|
13915
14134
|
}
|
|
13916
14135
|
if (action_1 === "superscript") {
|
|
13917
|
-
|
|
14136
|
+
executeEditorCommand(view_10, toggleSuperscript);
|
|
13918
14137
|
return;
|
|
13919
14138
|
}
|
|
13920
14139
|
if (action_1 === "subscript") {
|
|
13921
|
-
|
|
14140
|
+
executeEditorCommand(view_10, toggleSubscript);
|
|
13922
14141
|
return;
|
|
13923
14142
|
}
|
|
13924
14143
|
if (action_1 === "bulletList") {
|
|
13925
|
-
|
|
14144
|
+
executeEditorCommand(view_10, toggleBulletList);
|
|
13926
14145
|
return;
|
|
13927
14146
|
}
|
|
13928
14147
|
if (action_1 === "numberedList") {
|
|
13929
|
-
|
|
14148
|
+
executeEditorCommand(view_10, toggleNumberedList);
|
|
13930
14149
|
return;
|
|
13931
14150
|
}
|
|
13932
14151
|
if (action_1 === "indent") {
|
|
13933
|
-
|
|
14152
|
+
executeFirstEditorCommand(view_10, [increaseListLevel, increaseIndent()]);
|
|
13934
14153
|
return;
|
|
13935
14154
|
}
|
|
13936
14155
|
if (action_1 === "outdent") {
|
|
13937
|
-
|
|
14156
|
+
executeFirstEditorCommand(view_10, [decreaseListLevel, decreaseIndent()]);
|
|
13938
14157
|
return;
|
|
13939
14158
|
}
|
|
13940
14159
|
if (action_1 === "clearFormatting") {
|
|
13941
|
-
|
|
14160
|
+
executeEditorCommand(view_10, clearFormatting);
|
|
13942
14161
|
return;
|
|
13943
14162
|
}
|
|
13944
14163
|
if (action_1 === "setRtl") {
|
|
13945
|
-
|
|
14164
|
+
executeEditorCommand(view_10, setRtl);
|
|
13946
14165
|
return;
|
|
13947
14166
|
}
|
|
13948
14167
|
if (action_1 === "setLtr") {
|
|
13949
|
-
|
|
14168
|
+
executeEditorCommand(view_10, setLtr);
|
|
14169
|
+
return;
|
|
14170
|
+
}
|
|
14171
|
+
if (action_1 === "insertPageBreak") {
|
|
14172
|
+
executeEditorCommand(view_10, insertPageBreak);
|
|
13950
14173
|
return;
|
|
13951
14174
|
}
|
|
13952
14175
|
if (typeof action_1 === "object") switch (action_1.type) {
|
|
13953
14176
|
case "alignment":
|
|
13954
|
-
setAlignment(action_1.value)
|
|
14177
|
+
executeEditorCommand(view_10, setAlignment(action_1.value));
|
|
13955
14178
|
break;
|
|
13956
14179
|
case "toggleDirection":
|
|
13957
|
-
|
|
14180
|
+
executeEditorCommand(view_10, toggleBidi);
|
|
13958
14181
|
break;
|
|
13959
14182
|
case "textColor": {
|
|
13960
14183
|
const colorVal_0 = action_1.value;
|
|
13961
|
-
if (typeof colorVal_0 === "string") setTextColor({ rgb: colorVal_0.replace("#", "") })
|
|
13962
|
-
else if (colorVal_0.auto)
|
|
14184
|
+
if (typeof colorVal_0 === "string") executeEditorCommand(view_10, setTextColor({ rgb: colorVal_0.replace("#", "") }));
|
|
14185
|
+
else if (colorVal_0.auto) executeEditorCommand(view_10, clearTextColor);
|
|
13963
14186
|
else {
|
|
13964
14187
|
const themeColor = typeof colorVal_0.themeColor === "string" ? colorVal_0.themeColor : void 0;
|
|
13965
|
-
setTextColor({
|
|
14188
|
+
executeEditorCommand(view_10, setTextColor({
|
|
13966
14189
|
...colorVal_0.rgb === void 0 ? {} : { rgb: colorVal_0.rgb },
|
|
13967
14190
|
...themeColor ? { themeColor } : {},
|
|
13968
14191
|
...colorVal_0.themeTint === void 0 ? {} : { themeTint: colorVal_0.themeTint },
|
|
13969
14192
|
...colorVal_0.themeShade === void 0 ? {} : { themeShade: colorVal_0.themeShade }
|
|
13970
|
-
})
|
|
14193
|
+
}));
|
|
13971
14194
|
}
|
|
13972
14195
|
break;
|
|
13973
14196
|
}
|
|
13974
14197
|
case "highlightColor":
|
|
13975
|
-
setHighlight((action_1.value ? mapHexToHighlightName(action_1.value) : "") || action_1.value)
|
|
14198
|
+
executeEditorCommand(view_10, setHighlight((action_1.value ? mapHexToHighlightName(action_1.value) : "") || action_1.value));
|
|
13976
14199
|
break;
|
|
13977
14200
|
case "fontSize":
|
|
13978
|
-
setFontSize(pointsToHalfPoints(action_1.value))
|
|
14201
|
+
executeEditorCommand(view_10, setFontSize(pointsToHalfPoints(action_1.value)));
|
|
13979
14202
|
break;
|
|
13980
14203
|
case "fontFamily":
|
|
13981
|
-
setFontFamily(action_1.value)
|
|
14204
|
+
executeEditorCommand(view_10, setFontFamily(action_1.value));
|
|
13982
14205
|
break;
|
|
13983
14206
|
case "lineSpacing":
|
|
13984
|
-
setLineSpacing(action_1.value)
|
|
14207
|
+
executeEditorCommand(view_10, setLineSpacing(action_1.value));
|
|
13985
14208
|
break;
|
|
13986
14209
|
case "applyStyle": {
|
|
13987
14210
|
const currentDoc_0 = historyStateRef.current;
|
|
@@ -13994,8 +14217,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
13994
14217
|
const styleName = styleResolver_0.getStyle(action_1.value)?.name;
|
|
13995
14218
|
if (styleName) styleAttrs.styleName = styleName;
|
|
13996
14219
|
styleAttrs.numbering = currentDoc_0?.package.numbering ? getCachedNumberingMap(currentDoc_0.package.numbering) : null;
|
|
13997
|
-
applyStyle(action_1.value, styleAttrs)
|
|
13998
|
-
} else applyStyle(action_1.value)
|
|
14220
|
+
executeEditorCommand(view_10, applyStyle(action_1.value, styleAttrs));
|
|
14221
|
+
} else executeEditorCommand(view_10, applyStyle(action_1.value));
|
|
13999
14222
|
break;
|
|
14000
14223
|
}
|
|
14001
14224
|
default: break;
|
|
@@ -14310,13 +14533,21 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14310
14533
|
case "acceptChange": {
|
|
14311
14534
|
const { from: from_4, to: to_4 } = view_13.state.selection;
|
|
14312
14535
|
const range_1 = findChangeAtPosition(view_13.state, from_4, to_4);
|
|
14313
|
-
|
|
14536
|
+
if (resolveCanonicalReviewRange({
|
|
14537
|
+
editor: pagedEditorRef.current?.getEditor(),
|
|
14538
|
+
...range_1,
|
|
14539
|
+
resolution: "accept"
|
|
14540
|
+
}) === null) acceptChange(range_1.from, range_1.to)(view_13.state, view_13.dispatch);
|
|
14314
14541
|
break;
|
|
14315
14542
|
}
|
|
14316
14543
|
case "rejectChange": {
|
|
14317
14544
|
const { from: from_3, to: to_3 } = view_13.state.selection;
|
|
14318
14545
|
const range_0 = findChangeAtPosition(view_13.state, from_3, to_3);
|
|
14319
|
-
|
|
14546
|
+
if (resolveCanonicalReviewRange({
|
|
14547
|
+
editor: pagedEditorRef.current?.getEditor(),
|
|
14548
|
+
...range_0,
|
|
14549
|
+
resolution: "reject"
|
|
14550
|
+
}) === null) rejectChange(range_0.from, range_0.to)(view_13.state, view_13.dispatch);
|
|
14320
14551
|
break;
|
|
14321
14552
|
}
|
|
14322
14553
|
case "restartNumbering":
|
|
@@ -14348,6 +14579,14 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14348
14579
|
t
|
|
14349
14580
|
]);
|
|
14350
14581
|
const handlePageSetupApply = useCallback((props) => {
|
|
14582
|
+
if (readOnly) return;
|
|
14583
|
+
if (experimentalSession === "canonical") {
|
|
14584
|
+
const api_0 = getCanonicalApi();
|
|
14585
|
+
api_0?.ensureView();
|
|
14586
|
+
const canonical_1 = api_0?.getCanonicalDocument();
|
|
14587
|
+
if (!canonical_1 || !api_0?.applyCanonicalOperations([createCanonicalSectionPropertiesOperation(canonical_1, props)])) refuseCanonicalModelEdit("Section property changes could not be applied.");
|
|
14588
|
+
return;
|
|
14589
|
+
}
|
|
14351
14590
|
if (!history.state || readOnly) return;
|
|
14352
14591
|
const newDoc_0 = {
|
|
14353
14592
|
...history.state,
|
|
@@ -14366,7 +14605,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14366
14605
|
}, [
|
|
14367
14606
|
history.state,
|
|
14368
14607
|
readOnly,
|
|
14369
|
-
handleDocumentChange
|
|
14608
|
+
handleDocumentChange,
|
|
14609
|
+
experimentalSession,
|
|
14610
|
+
getCanonicalApi,
|
|
14611
|
+
refuseCanonicalModelEdit
|
|
14370
14612
|
]);
|
|
14371
14613
|
const handleLeftMarginChange = useCallback((twips) => handlePageSetupApply({ marginLeft: twips }), [handlePageSetupApply]);
|
|
14372
14614
|
const handleRightMarginChange = useCallback((twips_0) => handlePageSetupApply({ marginRight: twips_0 }), [handlePageSetupApply]);
|
|
@@ -14423,6 +14665,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14423
14665
|
const repackFull = async () => {
|
|
14424
14666
|
const repackDocx = await loadRepackDocx();
|
|
14425
14667
|
const repack = () => repackDocx(repackSourceDoc);
|
|
14668
|
+
if (experimentalSession === "canonical") return repackWithCanonicalStoryRemovals({
|
|
14669
|
+
document: repackSourceDoc,
|
|
14670
|
+
repack
|
|
14671
|
+
});
|
|
14426
14672
|
return editorState ? repackWithEditorSectionRemovals({
|
|
14427
14673
|
state: editorState,
|
|
14428
14674
|
document: repackSourceDoc,
|
|
@@ -14444,8 +14690,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14444
14690
|
view_18.dispatch(clearTrackedChanges(view_18.state));
|
|
14445
14691
|
}
|
|
14446
14692
|
savedBuffer = buffer;
|
|
14447
|
-
} catch (
|
|
14448
|
-
onError?.(
|
|
14693
|
+
} catch (error_1) {
|
|
14694
|
+
onError?.(error_1 instanceof Error ? error_1 : /* @__PURE__ */ new Error("Failed to save document"));
|
|
14449
14695
|
return null;
|
|
14450
14696
|
}
|
|
14451
14697
|
if (tripwireResult && onSelectiveSaveTripwire) onSelectiveSaveTripwire(tripwireResult);
|
|
@@ -14479,8 +14725,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14479
14725
|
loadParsedDocument,
|
|
14480
14726
|
serializeCurrentDocx
|
|
14481
14727
|
]);
|
|
14482
|
-
const handleEditorError = useCallback((
|
|
14483
|
-
|
|
14728
|
+
const handleEditorError = useCallback((error_2) => {
|
|
14729
|
+
if (CanonicalSessionRefusalError.is(error_2)) toast(error_2.message);
|
|
14730
|
+
onError?.(error_2);
|
|
14484
14731
|
}, [onError]);
|
|
14485
14732
|
useImperativeHandle(ref, () => ({
|
|
14486
14733
|
getDocument: () => buildCurrentDocument(),
|
|
@@ -14679,21 +14926,25 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14679
14926
|
acceptAIEditOperation: (revisionId) => {
|
|
14680
14927
|
const view_24 = pagedEditorRef.current?.getView();
|
|
14681
14928
|
if (!view_24) return false;
|
|
14929
|
+
const editor_3 = pagedEditorRef.current?.getEditor();
|
|
14930
|
+
if (editor_3?.getCanonicalDocument()) return editor_3.resolveCanonicalRevisions(typeof revisionId === "number" ? [revisionId] : revisionId, "accept");
|
|
14682
14931
|
return acceptAIEditRevision(revisionId)(view_24.state, view_24.dispatch);
|
|
14683
14932
|
},
|
|
14684
14933
|
rejectAIEditOperation: (revisionId_0) => {
|
|
14685
14934
|
const view_25 = pagedEditorRef.current?.getView();
|
|
14686
14935
|
if (!view_25) return false;
|
|
14936
|
+
const editor_4 = pagedEditorRef.current?.getEditor();
|
|
14937
|
+
if (editor_4?.getCanonicalDocument()) return editor_4.resolveCanonicalRevisions(typeof revisionId_0 === "number" ? [revisionId_0] : revisionId_0, "reject");
|
|
14687
14938
|
return rejectAIEditRevision(revisionId_0)(view_25.state, view_25.dispatch);
|
|
14688
14939
|
},
|
|
14689
14940
|
undo: () => {
|
|
14690
|
-
if (getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
|
|
14941
|
+
if (experimentalSession !== "canonical" && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
|
|
14691
14942
|
const undone = pagedEditorRef.current?.undo() ?? false;
|
|
14692
14943
|
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
14693
14944
|
return undone;
|
|
14694
14945
|
},
|
|
14695
14946
|
redo: () => {
|
|
14696
|
-
if (getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.redo();
|
|
14947
|
+
if (experimentalSession !== "canonical" && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.redo();
|
|
14697
14948
|
const redone = pagedEditorRef.current?.redo() ?? false;
|
|
14698
14949
|
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
14699
14950
|
return redone;
|
|
@@ -14977,7 +15228,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14977
15228
|
commentsRef,
|
|
14978
15229
|
commentsDirtyRef,
|
|
14979
15230
|
getActiveEditorStory,
|
|
14980
|
-
refreshBodyHistoryAvailability
|
|
15231
|
+
refreshBodyHistoryAvailability,
|
|
15232
|
+
experimentalSession
|
|
14981
15233
|
]);
|
|
14982
15234
|
const getHfTargetElement = useCallback((pos_0) => {
|
|
14983
15235
|
const pagesContainer = containerRef.current?.querySelector(".paged-editor__pages");
|
|
@@ -14990,6 +15242,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14990
15242
|
label: t(DISPLAY_MODE_LABEL_KEYS[mode_0])
|
|
14991
15243
|
})), [t]);
|
|
14992
15244
|
const activeHistoryAvailability = (() => {
|
|
15245
|
+
if (experimentalSession === "canonical") return {
|
|
15246
|
+
canRedo: pagedEditorRef.current?.canRedo() ?? false,
|
|
15247
|
+
canUndo: pagedEditorRef.current?.canUndo() ?? false
|
|
15248
|
+
};
|
|
14993
15249
|
if (activeNoteStory) return {
|
|
14994
15250
|
canRedo: pagedEditorRef.current?.canRedo() ?? false,
|
|
14995
15251
|
canUndo: pagedEditorRef.current?.canUndo() ?? false
|
|
@@ -15045,14 +15301,22 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15045
15301
|
if (!view_49) return;
|
|
15046
15302
|
const { from: from_13, to: to_13 } = view_49.state.selection;
|
|
15047
15303
|
const range_7 = findChangeAtPosition(view_49.state, from_13, to_13);
|
|
15048
|
-
|
|
15304
|
+
if (resolveCanonicalReviewRange({
|
|
15305
|
+
editor: pagedEditorRef.current?.getEditor(),
|
|
15306
|
+
...range_7,
|
|
15307
|
+
resolution: "accept"
|
|
15308
|
+
}) === null) acceptChange(range_7.from, range_7.to)(view_49.state, view_49.dispatch);
|
|
15049
15309
|
}, []);
|
|
15050
15310
|
const handleRejectActiveChange = useCallback(() => {
|
|
15051
15311
|
const view_50 = pagedEditorRef.current?.getView();
|
|
15052
15312
|
if (!view_50) return;
|
|
15053
15313
|
const { from: from_14, to: to_14 } = view_50.state.selection;
|
|
15054
15314
|
const range_8 = findChangeAtPosition(view_50.state, from_14, to_14);
|
|
15055
|
-
|
|
15315
|
+
if (resolveCanonicalReviewRange({
|
|
15316
|
+
editor: pagedEditorRef.current?.getEditor(),
|
|
15317
|
+
...range_8,
|
|
15318
|
+
resolution: "reject"
|
|
15319
|
+
}) === null) rejectChange(range_8.from, range_8.to)(view_50.state, view_50.dispatch);
|
|
15056
15320
|
}, []);
|
|
15057
15321
|
const handlePreviousChange = useCallback(() => {
|
|
15058
15322
|
const view_51 = pagedEditorRef.current?.getView();
|
|
@@ -15251,27 +15515,33 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15251
15515
|
}, [setScrollPageInfo]);
|
|
15252
15516
|
const handleCommentClick = useCallback((id) => setActiveCommentId(id), [setActiveCommentId]);
|
|
15253
15517
|
const handleCommentResolve = useCallback((id_0) => {
|
|
15518
|
+
if (refuseCanonicalModelEdit("Comment changes are unavailable in this session.")) return;
|
|
15254
15519
|
updateComments((previous_0) => previous_0.map((comment_2) => comment_2.id === id_0 ? {
|
|
15255
15520
|
...comment_2,
|
|
15256
15521
|
done: true
|
|
15257
15522
|
} : comment_2));
|
|
15258
|
-
}, [updateComments]);
|
|
15523
|
+
}, [refuseCanonicalModelEdit, updateComments]);
|
|
15259
15524
|
const handleCommentDelete = useCallback((id_1) => {
|
|
15525
|
+
if (refuseCanonicalModelEdit("Comment changes are unavailable in this session.")) return;
|
|
15260
15526
|
updateComments((previous_1) => previous_1.filter((comment_3) => comment_3.id !== id_1 && comment_3.parentId !== id_1));
|
|
15261
15527
|
if (activeCommentId === id_1) setActiveCommentId(null);
|
|
15262
15528
|
}, [
|
|
15263
15529
|
activeCommentId,
|
|
15530
|
+
refuseCanonicalModelEdit,
|
|
15264
15531
|
setActiveCommentId,
|
|
15265
15532
|
updateComments
|
|
15266
15533
|
]);
|
|
15267
15534
|
const handleCommentReply = useCallback((id_2, text_6) => {
|
|
15535
|
+
if (refuseCanonicalModelEdit("Comment changes are unavailable in this session.")) return;
|
|
15268
15536
|
updateComments((previous_2) => [...previous_2, createComment(text_6, author, id_2)]);
|
|
15269
15537
|
}, [
|
|
15270
15538
|
author,
|
|
15271
15539
|
createComment,
|
|
15540
|
+
refuseCanonicalModelEdit,
|
|
15272
15541
|
updateComments
|
|
15273
15542
|
]);
|
|
15274
15543
|
const handleAddComment = useCallback((addText) => {
|
|
15544
|
+
if (refuseCanonicalModelEdit("Comment changes are unavailable in this session.")) return false;
|
|
15275
15545
|
const comment_4 = createComment(addText, author);
|
|
15276
15546
|
const view_54 = pagedEditorRef.current?.getView();
|
|
15277
15547
|
if (!view_54 || !commentSelectionRange) return false;
|
|
@@ -15298,6 +15568,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15298
15568
|
author,
|
|
15299
15569
|
commentSelectionRange,
|
|
15300
15570
|
createComment,
|
|
15571
|
+
refuseCanonicalModelEdit,
|
|
15301
15572
|
setActiveCommentId,
|
|
15302
15573
|
setAddCommentYPosition,
|
|
15303
15574
|
setCommentSelectionRange,
|
|
@@ -15307,10 +15578,12 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15307
15578
|
updateComments
|
|
15308
15579
|
]);
|
|
15309
15580
|
const handleTrackedChangeReply = useCallback((revisionId_2, text_7) => {
|
|
15581
|
+
if (refuseCanonicalModelEdit("Comment changes are unavailable in this session.")) return;
|
|
15310
15582
|
updateComments((previous_4) => [...previous_4, createComment(text_7, author, revisionId_2)]);
|
|
15311
15583
|
}, [
|
|
15312
15584
|
author,
|
|
15313
15585
|
createComment,
|
|
15586
|
+
refuseCanonicalModelEdit,
|
|
15314
15587
|
updateComments
|
|
15315
15588
|
]);
|
|
15316
15589
|
const handleCancelAddComment = useCallback(() => {
|
|
@@ -15335,7 +15608,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15335
15608
|
if (!view_56) return;
|
|
15336
15609
|
const revisionId_3 = resolveSidebarChangeRevisionId(from_17, to_17);
|
|
15337
15610
|
if (revisionId_3 === null) return;
|
|
15338
|
-
|
|
15611
|
+
const editor_5 = pagedEditorRef.current?.getEditor();
|
|
15612
|
+
if (editor_5?.getCanonicalDocument()) editor_5.resolveCanonicalRevisions([revisionId_3], "accept");
|
|
15613
|
+
else acceptAIEditRevision(revisionId_3)(view_56.state, view_56.dispatch);
|
|
15339
15614
|
extractTrackedChanges();
|
|
15340
15615
|
}, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
|
|
15341
15616
|
const handleSidebarRejectChange = useCallback((from_18, to_18) => {
|
|
@@ -15343,7 +15618,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15343
15618
|
if (!view_57) return;
|
|
15344
15619
|
const revisionId_4 = resolveSidebarChangeRevisionId(from_18, to_18);
|
|
15345
15620
|
if (revisionId_4 === null) return;
|
|
15346
|
-
|
|
15621
|
+
const editor_6 = pagedEditorRef.current?.getEditor();
|
|
15622
|
+
if (editor_6?.getCanonicalDocument()) editor_6.resolveCanonicalRevisions([revisionId_4], "reject");
|
|
15623
|
+
else rejectAIEditRevision(revisionId_4)(view_57.state, view_57.dispatch);
|
|
15347
15624
|
extractTrackedChanges();
|
|
15348
15625
|
}, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
|
|
15349
15626
|
const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
|
|
@@ -15662,7 +15939,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15662
15939
|
onError: handleEditorError,
|
|
15663
15940
|
children: /* @__PURE__ */ jsxs("div", {
|
|
15664
15941
|
ref: containerRef,
|
|
15665
|
-
className: `folio-root folio-editor${displayMode !== "all-markup" ? ` folio-root--${displayMode}` : ""}${
|
|
15942
|
+
className: `folio-root folio-editor${displayMode !== "all-markup" ? ` folio-root--${displayMode}` : ""}${canEditHeaderFooter ? "" : " folio-no-hf-edit"} ${className}`,
|
|
15666
15943
|
style: containerStyle,
|
|
15667
15944
|
"data-testid": "folio-editor",
|
|
15668
15945
|
"data-folio-format-painter": formatPainterMode !== "off" ? "armed" : void 0,
|
|
@@ -15832,9 +16109,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15832
16109
|
firstPageHeaderContentRId: activeFirstHeaderRId,
|
|
15833
16110
|
firstPageFooterContentRId: activeFirstFooterRId,
|
|
15834
16111
|
...history.state.package.styles ? { styles: history.state.package.styles } : {},
|
|
15835
|
-
onHeaderFooterDoubleClick:
|
|
15836
|
-
hfEditMode: hfEditPosition,
|
|
15837
|
-
activeHeaderFooterRId: activeHfRId,
|
|
16112
|
+
onHeaderFooterDoubleClick: handleHeaderFooterStoryOpen,
|
|
16113
|
+
hfEditMode: canEditHeaderFooter ? hfEditPosition : null,
|
|
16114
|
+
activeHeaderFooterRId: canEditHeaderFooter ? activeHfRId : null,
|
|
15838
16115
|
onBodyClick: handleBodyClick,
|
|
15839
16116
|
onActiveNoteStoryChange: handleActiveNoteStoryChange,
|
|
15840
16117
|
zoom,
|
|
@@ -15842,6 +16119,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15842
16119
|
showMarginGuides,
|
|
15843
16120
|
...marginGuideColor !== void 0 ? { marginGuideColor } : {},
|
|
15844
16121
|
readOnly,
|
|
16122
|
+
...experimentalSession === void 0 ? {} : { experimentalSession },
|
|
15845
16123
|
onDocumentChange: handleDocumentChange,
|
|
15846
16124
|
extensionManager,
|
|
15847
16125
|
suggestionModeActive: editingMode === "suggesting",
|
|
@@ -15950,7 +16228,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15950
16228
|
children: /* @__PURE__ */ jsx(SquarePenIcon, { size: 16 })
|
|
15951
16229
|
})
|
|
15952
16230
|
}),
|
|
15953
|
-
hfEditPosition && (() => {
|
|
16231
|
+
canEditHeaderFooter && hfEditPosition && (() => {
|
|
15954
16232
|
if (!(() => {
|
|
15955
16233
|
if (hfEditIsFirstPage) return (() => {
|
|
15956
16234
|
if (hfEditPosition === "header") return firstPageHeaderContent;
|