@stll/folio-react 0.33.0 → 0.34.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-CQJT9gei.js → CommentsSidebar-4XdScjMH.js} +1 -1
- package/dist/{TextContextMenu-BxnNvhJg.js → TextContextMenu-jOBgICwD.js} +110 -97
- package/dist/compat/eigenpal.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{renderAsync-C4XgGuNC.js → renderAsync-B1Y5l8tt.js} +478 -467
- package/package.json +2 -2
|
@@ -13,9 +13,9 @@ import { afterCanonicalCompositionSettles } from "@stll/folio-core/controller/ca
|
|
|
13
13
|
import { resolveCanonicalReviewRange } from "@stll/folio-core/controller/canonicalReview";
|
|
14
14
|
import { FOLIO_DOCX_SERIALIZATION_MODE, createFolioEditor } from "@stll/folio-core/controller/folioEditor";
|
|
15
15
|
import { CanonicalSessionRefusalError, collectRemoteSelections, createHiddenEditorManager, createHiddenEditorState } from "@stll/folio-core/controller/hiddenEditorManager";
|
|
16
|
-
import { setDocumentBodyComments } from "@stll/folio-core/docx/canonicalModel";
|
|
17
16
|
import { CanonicalSaveDiagnosticError, serializeCanonicalSave } from "@stll/folio-core/docx/canonicalSave";
|
|
18
17
|
import { cloneDocumentWithParagraphPropertySources } from "@stll/folio-core/docx/document-clone";
|
|
18
|
+
import { getCommentParentId, getCommentParentId as getCommentParentId$1, withHostCommentThreads } from "@stll/folio-core/docx/hostCommentThreads";
|
|
19
19
|
import { normalizeBaseDirection } from "@stll/folio-core/docx/normalizeBaseDirection";
|
|
20
20
|
import { getCachedNumberingMap } from "@stll/folio-core/docx/numberingParser";
|
|
21
21
|
import { DEFAULT_KEYBOARD_SHORTCUT_SCOPE, classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform } from "@stll/folio-core/managers/editorShortcuts";
|
|
@@ -25,11 +25,11 @@ import { computeScrollPageInfo, updateScrollPageTotal } from "@stll/folio-core/p
|
|
|
25
25
|
import { DEFAULT_PAGE_HEIGHT_PX, getMargins, getPageSize, twipsToPixels } from "@stll/folio-core/paged-layout/sectionGeometry";
|
|
26
26
|
import { NO_LIST_STATE, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, captureFormatMarks, clearFormatting, clearTextColor, continueNumbering, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, extractSelectionState, getDocumentBuiltInStyles, getSelectedText, getTableContext, increaseIndent, increaseListLevel, listStateLevel, mergeCells, removeTabStop, removeTableBorders, restartNumbering, sameListState, schema, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableProperties, setTextColor, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "@stll/folio-core/prosemirror";
|
|
27
27
|
import { expectImageAttrs, expectTableAttrs } from "@stll/folio-core/prosemirror/attrs";
|
|
28
|
-
import { acceptAIEditRevision, acceptChange, acceptSuggestion, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectChange, rejectSuggestion } from "@stll/folio-core/prosemirror/commands/comments";
|
|
28
|
+
import { acceptAIEditRevision, acceptChange, acceptSuggestion, changeResolutionLockViolation, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectChange, rejectSuggestion } from "@stll/folio-core/prosemirror/commands/comments";
|
|
29
29
|
import { blockSdtAttrsToSdtProperties, findBlockSdtMatch, findBlockSdtMatches, removeContentControlTr, setContentControlContentTr, setContentControlValueTr } from "@stll/folio-core/prosemirror/commands/contentControls";
|
|
30
30
|
import { setContentControlContentBlocksTr } from "@stll/folio-core/prosemirror/commands/contentControlsBlockFill";
|
|
31
31
|
import { insertPageBreak } from "@stll/folio-core/prosemirror/commands/pageBreak";
|
|
32
|
-
import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice } from "@stll/folio-core/prosemirror/commands/pastePlainText";
|
|
32
|
+
import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pastePlainTextSlice } from "@stll/folio-core/prosemirror/commands/pastePlainText";
|
|
33
33
|
import { proseDocToBlocks } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
|
|
34
34
|
import { executeEditorCommand, executeFirstEditorCommand } from "@stll/folio-core/prosemirror/executeEditorCommand";
|
|
35
35
|
import { ExtensionManager } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
|
|
@@ -46,7 +46,7 @@ import { createTemplateDirectivesPlugin, templateDirectivesKey } from "@stll/fol
|
|
|
46
46
|
import { createTemplatePreviewValuesPlugin, templatePreviewValuesKey } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
|
|
47
47
|
import { getTemplateSlashMenu, templateSlashMenuPlugin } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
|
|
48
48
|
import { getFolioParaIdFromBlockId } from "@stll/folio-core/types/block-id";
|
|
49
|
-
import { CANONICAL_GAP, canonicalRefusalMessage, usesCanonicalSession } from "@stll/folio-core/types/canonicalCapabilities";
|
|
49
|
+
import { CANONICAL_GAP, canonicalRefusalMessage, canonicalRefusalNotice, usesCanonicalSession } from "@stll/folio-core/types/canonicalCapabilities";
|
|
50
50
|
import { canonicalJson } from "@stll/folio-core/utils/canonicalJson";
|
|
51
51
|
import { resolveColor } from "@stll/folio-core/utils/colorResolver";
|
|
52
52
|
import { closestHtmlElement, htmlQueryAll, queryHtmlElement } from "@stll/folio-core/utils/domGuards";
|
|
@@ -632,7 +632,7 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
|
|
|
632
632
|
getTheme: () => themeRef.current,
|
|
633
633
|
getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
|
|
634
634
|
getExperimentalSession: () => sessionRef.current,
|
|
635
|
-
onSessionRefusal: (reason,
|
|
635
|
+
onSessionRefusal: (reason, ground, error) => refusalRef.current?.(reason, ground, error),
|
|
636
636
|
onTransaction: ({ rId, kind, view, docChanged, selectionChanged }) => {
|
|
637
637
|
onTransactionRef.current?.(rId, kind, view, docChanged, selectionChanged);
|
|
638
638
|
}
|
|
@@ -737,7 +737,7 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
737
737
|
getTheme: () => themeRef.current,
|
|
738
738
|
getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
|
|
739
739
|
getExperimentalSession: () => sessionRef.current,
|
|
740
|
-
onSessionRefusal: (reason,
|
|
740
|
+
onSessionRefusal: (reason, ground, error) => refusalRef.current?.(reason, ground, error),
|
|
741
741
|
onTransaction: (t3) => {
|
|
742
742
|
const { docChanged, selectionChanged, view } = t3;
|
|
743
743
|
if (docChanged) {
|
|
@@ -1358,7 +1358,7 @@ const HIDDEN_HOST_STYLES = {
|
|
|
1358
1358
|
* HiddenProseMirror - Off-screen ProseMirror editor for keyboard input
|
|
1359
1359
|
*/
|
|
1360
1360
|
const HiddenProseMirror = forwardRef((props, ref) => {
|
|
1361
|
-
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;
|
|
1361
|
+
const { document, documentIdentity, experimentalSession, suggestionModeActive = false, suggestionAuthor = "User", onSessionRefusal, styles, theme: _theme, widthPx = 612, readOnly = false, onTransaction, onCanonicalCompositionEnd, onSelectionChange, externalPlugins = EMPTY_EXTERNAL_PLUGINS, collaboration, extensionManager, onEditorViewReady, onEditorViewDestroy, onKeyDown, onCopy, onCut, onPaste, onReadOnlyEditAttempt, onRemoteSelectionsChange, precomputedInitialState } = props;
|
|
1362
1362
|
const hasCollaboration = collaboration !== void 0;
|
|
1363
1363
|
const [collaborationLoad, setCollaborationLoad] = useState(() => ({ status: hasCollaboration ? "loading" : "disabled" }));
|
|
1364
1364
|
if (hasCollaboration !== (collaborationLoad.status !== "disabled")) setCollaborationLoad({ status: hasCollaboration ? "loading" : "disabled" });
|
|
@@ -1379,6 +1379,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1379
1379
|
const collaborationRef = useRef(collaboration);
|
|
1380
1380
|
const collaborationModulesRef = useRef(collaborationModules);
|
|
1381
1381
|
const onTransactionRef = useRef(onTransaction);
|
|
1382
|
+
const onCanonicalCompositionEndRef = useRef(onCanonicalCompositionEnd);
|
|
1382
1383
|
const onSelectionChangeRef = useRef(onSelectionChange);
|
|
1383
1384
|
const onEditorViewReadyRef = useRef(onEditorViewReady);
|
|
1384
1385
|
const onEditorViewDestroyRef = useRef(onEditorViewDestroy);
|
|
@@ -1400,6 +1401,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1400
1401
|
externalPluginsRef.current = externalPlugins;
|
|
1401
1402
|
precomputedInitialStateRef.current = precomputedInitialState;
|
|
1402
1403
|
onTransactionRef.current = onTransaction;
|
|
1404
|
+
onCanonicalCompositionEndRef.current = onCanonicalCompositionEnd;
|
|
1403
1405
|
onSelectionChangeRef.current = onSelectionChange;
|
|
1404
1406
|
onEditorViewReadyRef.current = onEditorViewReady;
|
|
1405
1407
|
onEditorViewDestroyRef.current = onEditorViewDestroy;
|
|
@@ -1426,10 +1428,11 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1426
1428
|
getExperimentalSession: () => experimentalSessionRef.current,
|
|
1427
1429
|
getEditingMode: () => suggestionModeActiveRef.current ? "suggesting" : "editing",
|
|
1428
1430
|
getSuggestionAuthor: () => suggestionAuthorRef.current,
|
|
1429
|
-
onSessionRefusal: (reason,
|
|
1431
|
+
onSessionRefusal: (reason, ground, error) => onSessionRefusalRef.current?.(reason, ground, error),
|
|
1430
1432
|
getDocumentIdentity: () => documentIdentityRef.current,
|
|
1431
1433
|
getDocumentContext: () => documentRef.current,
|
|
1432
1434
|
onTransaction: (update) => onTransactionRef.current?.(update),
|
|
1435
|
+
onCanonicalCompositionEnd: () => onCanonicalCompositionEndRef.current?.(),
|
|
1433
1436
|
onSelectionChange: (state) => onSelectionChangeRef.current?.(state),
|
|
1434
1437
|
onKeyDown: (view, event) => onKeyDownRef.current?.(view, event) ?? false,
|
|
1435
1438
|
onCopy: () => onCopyRef.current?.(),
|
|
@@ -3235,7 +3238,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
|
|
|
3235
3238
|
* PagedEditor - Main paginated editing component.
|
|
3236
3239
|
*/
|
|
3237
3240
|
const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
3238
|
-
const { accessibleName, 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, showCommentHighlights = true, 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;
|
|
3241
|
+
const { accessibleName, 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, showCommentHighlights = true, altChunkMarkerText, 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;
|
|
3239
3242
|
const getScrollContainer = useCallback(() => {
|
|
3240
3243
|
if (scrollContainerRefProp && typeof scrollContainerRefProp === "object") return getEditorScrollRoot(scrollContainerRefProp.current);
|
|
3241
3244
|
return getEditorScrollRoot(containerRef.current);
|
|
@@ -3303,9 +3306,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3303
3306
|
onTotalPagesChange,
|
|
3304
3307
|
onError
|
|
3305
3308
|
]);
|
|
3306
|
-
const handleSessionRefusal = useCallback((message,
|
|
3309
|
+
const handleSessionRefusal = useCallback((message, ground, error) => {
|
|
3307
3310
|
onErrorRef.current?.(error ?? new CanonicalSessionRefusalError({
|
|
3308
|
-
|
|
3311
|
+
ground,
|
|
3309
3312
|
message
|
|
3310
3313
|
}));
|
|
3311
3314
|
}, []);
|
|
@@ -3514,6 +3517,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3514
3517
|
columns,
|
|
3515
3518
|
markupView,
|
|
3516
3519
|
showCommentHighlights,
|
|
3520
|
+
altChunkMarkerText,
|
|
3517
3521
|
contentWidth,
|
|
3518
3522
|
defaultTabStop,
|
|
3519
3523
|
mirrorMargins,
|
|
@@ -3536,6 +3540,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3536
3540
|
columns,
|
|
3537
3541
|
markupView,
|
|
3538
3542
|
showCommentHighlights,
|
|
3543
|
+
altChunkMarkerText,
|
|
3539
3544
|
contentWidth,
|
|
3540
3545
|
defaultTabStop,
|
|
3541
3546
|
mirrorMargins,
|
|
@@ -3617,7 +3622,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3617
3622
|
emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN,
|
|
3618
3623
|
hyphenationReadiness,
|
|
3619
3624
|
markupView,
|
|
3620
|
-
showCommentHighlights
|
|
3625
|
+
showCommentHighlights,
|
|
3626
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText }
|
|
3621
3627
|
}, state, options);
|
|
3622
3628
|
if (outcome.blocks) setBlocks(outcome.blocks);
|
|
3623
3629
|
if (outcome.measures !== void 0) setMeasures(outcome.measures);
|
|
@@ -3655,6 +3661,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3655
3661
|
styles,
|
|
3656
3662
|
markupView,
|
|
3657
3663
|
showCommentHighlights,
|
|
3664
|
+
altChunkMarkerText,
|
|
3658
3665
|
layoutInputSignature,
|
|
3659
3666
|
hyphenationReadiness
|
|
3660
3667
|
]);
|
|
@@ -6148,6 +6155,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6148
6155
|
precomputedInitialState: validPrecomputedInitialState,
|
|
6149
6156
|
readOnly,
|
|
6150
6157
|
onTransaction: handleTransaction,
|
|
6158
|
+
onCanonicalCompositionEnd: scheduleLayout,
|
|
6151
6159
|
onSelectionChange: handleSelectionChange,
|
|
6152
6160
|
onRemoteSelectionsChange: setRemoteSelections,
|
|
6153
6161
|
onEditorViewReady: handleEditorViewReady,
|
|
@@ -6349,9 +6357,6 @@ function createComment(text, authorName, parentId, id) {
|
|
|
6349
6357
|
...parentId !== void 0 && { parentId }
|
|
6350
6358
|
};
|
|
6351
6359
|
}
|
|
6352
|
-
function getCommentParentId(comment) {
|
|
6353
|
-
return comment.parentId;
|
|
6354
|
-
}
|
|
6355
6360
|
/**
|
|
6356
6361
|
* Threads the comments sidebar shows a card for: top-level comments not yet
|
|
6357
6362
|
* resolved. Tracked changes are painted inline and have no card, so a
|
|
@@ -6376,91 +6381,6 @@ function applyCommentMarkRange(view, range, commentId, options) {
|
|
|
6376
6381
|
view.dispatch(tr);
|
|
6377
6382
|
return true;
|
|
6378
6383
|
}
|
|
6379
|
-
/**
|
|
6380
|
-
* Walk arbitrary Folio content subtrees and collect every comment id that
|
|
6381
|
-
* is *referenced* by an inline anchor (`commentRangeStart`,
|
|
6382
|
-
* `commentRangeEnd`, or `commentReference`). Used at save time to detect
|
|
6383
|
-
* which comment threads still have something to anchor to, so that
|
|
6384
|
-
* comments whose underlying text has been edited away can be pruned
|
|
6385
|
-
* before serialization instead of being written out as phantom threads
|
|
6386
|
-
* that no Word reader can scroll to.
|
|
6387
|
-
*
|
|
6388
|
-
* Pass every part of the document that can carry anchors — comments can
|
|
6389
|
-
* live in headers, footers, footnotes, and endnotes as well as the
|
|
6390
|
-
* main body, and a save path that only checks the body would prune
|
|
6391
|
-
* legitimate header/footer/note comments.
|
|
6392
|
-
*
|
|
6393
|
-
* Uses `for (const key in obj)` instead of `Object.values(obj)` so the
|
|
6394
|
-
* recursive walk doesn't allocate a values array at every node; also
|
|
6395
|
-
* handles `Map` containers (e.g., `package.headers`) which `Object.values`
|
|
6396
|
-
* would silently skip.
|
|
6397
|
-
*/
|
|
6398
|
-
function collectCommentIdsFromSources(...sources) {
|
|
6399
|
-
const ids = /* @__PURE__ */ new Set();
|
|
6400
|
-
const visit = (node) => {
|
|
6401
|
-
if (node === null || node === void 0) return;
|
|
6402
|
-
if (Array.isArray(node)) {
|
|
6403
|
-
for (const item of node) visit(item);
|
|
6404
|
-
return;
|
|
6405
|
-
}
|
|
6406
|
-
if (node instanceof Map) {
|
|
6407
|
-
for (const value of node.values()) visit(value);
|
|
6408
|
-
return;
|
|
6409
|
-
}
|
|
6410
|
-
if (typeof node !== "object") return;
|
|
6411
|
-
const obj = node;
|
|
6412
|
-
const type = obj["type"];
|
|
6413
|
-
if ((type === "commentRangeStart" || type === "commentRangeEnd" || type === "commentReference") && typeof obj["id"] === "number") ids.add(obj["id"]);
|
|
6414
|
-
for (const key in obj) visit(obj[key]);
|
|
6415
|
-
};
|
|
6416
|
-
for (const source of sources) visit(source);
|
|
6417
|
-
return ids;
|
|
6418
|
-
}
|
|
6419
|
-
/**
|
|
6420
|
-
* Filter `comments` to drop entries whose reply chain has lost its root.
|
|
6421
|
-
*
|
|
6422
|
-
* Kept:
|
|
6423
|
-
* - every top-level comment (`parentId` is null/undefined), regardless of
|
|
6424
|
-
* whether its id appears in `referencedIds`,
|
|
6425
|
-
* - replies whose parent chain transitively reaches a kept top-level
|
|
6426
|
-
* comment.
|
|
6427
|
-
*
|
|
6428
|
-
* Dropped:
|
|
6429
|
-
* - replies whose explicit `parentId` does not reach a kept top-level
|
|
6430
|
-
* comment (a true broken-thread orphan).
|
|
6431
|
-
*
|
|
6432
|
-
* Why we don't prune unanchored top-level comments: pre-Word-2013
|
|
6433
|
-
* documents (and any document missing `commentsExtended.xml`) carry no
|
|
6434
|
-
* reply-thread metadata, so Word replies in those files arrive with
|
|
6435
|
-
* `parentId === undefined` and look indistinguishable from a true
|
|
6436
|
-
* top-level comment whose anchor has been edited away. Dropping
|
|
6437
|
-
* unanchored top-level entries would silently lose every reply in
|
|
6438
|
-
* those older files on the first save — a strictly worse failure mode
|
|
6439
|
-
* than re-emitting a comment whose anchor was actually deleted. The
|
|
6440
|
-
* complementary "overwrite stale `comments.xml`" fix in the save paths
|
|
6441
|
-
* already prevents the phantom-thread regression when the array does
|
|
6442
|
-
* end up empty.
|
|
6443
|
-
*/
|
|
6444
|
-
function pruneOrphanedComments(comments, _referencedIds) {
|
|
6445
|
-
const keptIds = /* @__PURE__ */ new Set();
|
|
6446
|
-
for (const comment of comments) {
|
|
6447
|
-
const parentId = getCommentParentId(comment);
|
|
6448
|
-
if (parentId === null || parentId === void 0) keptIds.add(comment.id);
|
|
6449
|
-
}
|
|
6450
|
-
let addedThisPass = true;
|
|
6451
|
-
while (addedThisPass) {
|
|
6452
|
-
addedThisPass = false;
|
|
6453
|
-
for (const comment of comments) {
|
|
6454
|
-
if (keptIds.has(comment.id)) continue;
|
|
6455
|
-
const parentId = getCommentParentId(comment);
|
|
6456
|
-
if (parentId !== null && parentId !== void 0 && keptIds.has(parentId)) {
|
|
6457
|
-
keptIds.add(comment.id);
|
|
6458
|
-
addedThisPass = true;
|
|
6459
|
-
}
|
|
6460
|
-
}
|
|
6461
|
-
}
|
|
6462
|
-
return comments.filter((comment) => keptIds.has(comment.id));
|
|
6463
|
-
}
|
|
6464
6384
|
function removePendingCommentMarkRange(view, range) {
|
|
6465
6385
|
const commentMark = view.state.schema.marks["comment"];
|
|
6466
6386
|
const safeRange = clampCommentMarkRange(view.state.doc.content.size, range);
|
|
@@ -9608,17 +9528,8 @@ function detectImageContext(state) {
|
|
|
9608
9528
|
function detectActiveTrackedChange(state) {
|
|
9609
9529
|
const { from } = state.selection;
|
|
9610
9530
|
const $pos = state.doc.resolve(from);
|
|
9611
|
-
const
|
|
9612
|
-
|
|
9613
|
-
let childOffset = 0;
|
|
9614
|
-
for (let index = 0; index < node.childCount; index += 1) {
|
|
9615
|
-
const child = node.child(index);
|
|
9616
|
-
const childStart = $pos.start() + childOffset;
|
|
9617
|
-
const childEnd = childStart + child.nodeSize;
|
|
9618
|
-
if (from < childStart || from > childEnd || !child.isText) {
|
|
9619
|
-
childOffset += child.nodeSize;
|
|
9620
|
-
continue;
|
|
9621
|
-
}
|
|
9531
|
+
for (const child of [$pos.nodeBefore, $pos.nodeAfter]) {
|
|
9532
|
+
if (!child?.isText) continue;
|
|
9622
9533
|
for (const mark of child.marks) {
|
|
9623
9534
|
if (mark.type.name !== "insertion" && mark.type.name !== "deletion") continue;
|
|
9624
9535
|
const range = findChangeAtPosition(state, from, from);
|
|
@@ -9627,10 +9538,10 @@ function detectActiveTrackedChange(state) {
|
|
|
9627
9538
|
author: mark.attrs["author"] || "Unknown",
|
|
9628
9539
|
date: mark.attrs["date"] || null,
|
|
9629
9540
|
from: range.from,
|
|
9630
|
-
to: range.to
|
|
9541
|
+
to: range.to,
|
|
9542
|
+
heldByLock: heldByLock(state, range)
|
|
9631
9543
|
};
|
|
9632
9544
|
}
|
|
9633
|
-
childOffset += child.nodeSize;
|
|
9634
9545
|
}
|
|
9635
9546
|
const paragraphChange = findParagraphBoundaryChangeAtPosition(state, from);
|
|
9636
9547
|
if (!paragraphChange) return null;
|
|
@@ -9639,9 +9550,21 @@ function detectActiveTrackedChange(state) {
|
|
|
9639
9550
|
author: paragraphChange.author || "Unknown",
|
|
9640
9551
|
date: paragraphChange.date || null,
|
|
9641
9552
|
from: paragraphChange.from,
|
|
9642
|
-
to: paragraphChange.to
|
|
9553
|
+
to: paragraphChange.to,
|
|
9554
|
+
heldByLock: heldByLock(state, paragraphChange)
|
|
9643
9555
|
};
|
|
9644
9556
|
}
|
|
9557
|
+
/** What the content-control locks say about resolving the changes in `range`. */
|
|
9558
|
+
const heldByLock = (state, range) => ({
|
|
9559
|
+
accept: changeResolutionLockViolation(state, {
|
|
9560
|
+
...range,
|
|
9561
|
+
mode: "accept"
|
|
9562
|
+
}) !== null,
|
|
9563
|
+
reject: changeResolutionLockViolation(state, {
|
|
9564
|
+
...range,
|
|
9565
|
+
mode: "reject"
|
|
9566
|
+
}) !== null
|
|
9567
|
+
});
|
|
9645
9568
|
// src/components/hooks/useContextMenu.ts
|
|
9646
9569
|
function useContextMenu(t0) {
|
|
9647
9570
|
const $ = c(7);
|
|
@@ -13870,7 +13793,7 @@ function useFolioComments(t0) {
|
|
|
13870
13793
|
if ($[38] !== listedComments || $[39] !== visibleCommentIds) {
|
|
13871
13794
|
visibleRootIds = /* @__PURE__ */ new Set();
|
|
13872
13795
|
for (const comment_1 of listedComments) {
|
|
13873
|
-
const parentId_0 = getCommentParentId(comment_1);
|
|
13796
|
+
const parentId_0 = getCommentParentId$1(comment_1);
|
|
13874
13797
|
if (parentId_0 === null || parentId_0 === void 0 || !visibleCommentIds.has(comment_1.id)) continue;
|
|
13875
13798
|
visibleRootIds.add(parentId_0);
|
|
13876
13799
|
}
|
|
@@ -13883,7 +13806,7 @@ function useFolioComments(t0) {
|
|
|
13883
13806
|
let t20;
|
|
13884
13807
|
if ($[45] !== visibleCommentIds || $[46] !== visibleRootIds) {
|
|
13885
13808
|
t20 = (comment_2) => {
|
|
13886
|
-
const parentId_1 = getCommentParentId(comment_2);
|
|
13809
|
+
const parentId_1 = getCommentParentId$1(comment_2);
|
|
13887
13810
|
if (parentId_1 !== null && parentId_1 !== void 0) return visibleCommentIds.has(comment_2.id);
|
|
13888
13811
|
return visibleCommentIds.has(comment_2.id) || visibleRootIds.has(comment_2.id);
|
|
13889
13812
|
};
|
|
@@ -14040,8 +13963,8 @@ function _temp(id_4) {
|
|
|
14040
13963
|
// src/components/DocxEditor.tsx
|
|
14041
13964
|
/** No headings to track while the outline is not shown. */
|
|
14042
13965
|
const NO_HEADINGS = [];
|
|
14043
|
-
const CommentsSidebar = lazy(() => import("./CommentsSidebar-
|
|
14044
|
-
const TextContextMenu = lazy(() => import("./TextContextMenu-
|
|
13966
|
+
const CommentsSidebar = lazy(() => import("./CommentsSidebar-4XdScjMH.js").then((m) => ({ default: m.CommentsSidebar })));
|
|
13967
|
+
const TextContextMenu = lazy(() => import("./TextContextMenu-jOBgICwD.js").then((m) => ({ default: m.TextContextMenu })));
|
|
14045
13968
|
const loadAttemptSelectiveSave = async () => {
|
|
14046
13969
|
const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
|
|
14047
13970
|
return attemptSelectiveSave;
|
|
@@ -14106,7 +14029,7 @@ function areImageContextsEqual(a, b) {
|
|
|
14106
14029
|
function areActiveTrackedChangesEqual(a, b) {
|
|
14107
14030
|
if (a === b) return true;
|
|
14108
14031
|
if (!a || !b) return false;
|
|
14109
|
-
return a.type === b.type && a.author === b.author && a.date === b.date && a.from === b.from && a.to === b.to;
|
|
14032
|
+
return a.type === b.type && a.author === b.author && a.date === b.date && a.from === b.from && a.to === b.to && a.heldByLock.accept === b.heldByLock.accept && a.heldByLock.reject === b.heldByLock.reject;
|
|
14110
14033
|
}
|
|
14111
14034
|
const assignRef = (ref, value) => {
|
|
14112
14035
|
ref.current = value;
|
|
@@ -14199,12 +14122,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14199
14122
|
readOnlyProp,
|
|
14200
14123
|
...reviewDisplayMode === void 0 ? {} : { reviewDisplayMode }
|
|
14201
14124
|
});
|
|
14202
|
-
|
|
14125
|
+
const syncCanonicalMode = useCallback(() => {
|
|
14203
14126
|
pagedEditorRef.current?.getEditor().setCanonicalMode(editingMode === "suggesting" ? {
|
|
14204
14127
|
type: "suggesting",
|
|
14205
14128
|
author
|
|
14206
14129
|
} : { type: "editing" });
|
|
14207
14130
|
}, [editingMode, author]);
|
|
14131
|
+
useEffect(() => {
|
|
14132
|
+
syncCanonicalMode();
|
|
14133
|
+
}, [syncCanonicalMode]);
|
|
14208
14134
|
const extractTrackedChangesTimerRef = useRef(null);
|
|
14209
14135
|
const extractTrackedChanges = useCallback(() => {
|
|
14210
14136
|
const view = pagedEditorRef.current?.getView();
|
|
@@ -14257,7 +14183,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14257
14183
|
const refuseCanonicalModelEdit = useCallback((gap, message) => {
|
|
14258
14184
|
if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return false;
|
|
14259
14185
|
const error = new CanonicalSessionRefusalError({
|
|
14260
|
-
gap,
|
|
14186
|
+
ground: { gap },
|
|
14261
14187
|
message: canonicalRefusalMessage(gap, message)
|
|
14262
14188
|
});
|
|
14263
14189
|
toast(error.message);
|
|
@@ -14364,21 +14290,34 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14364
14290
|
};
|
|
14365
14291
|
}, [onEditorViewReady, reportEditorViewReady]);
|
|
14366
14292
|
const [bodyViewEpoch, setBodyViewEpoch] = useState(0);
|
|
14367
|
-
const
|
|
14368
|
-
|
|
14293
|
+
const syncSuggestionMode = useCallback((view_2) => {
|
|
14294
|
+
const active = editingMode === "suggesting";
|
|
14295
|
+
const current = suggestionModeKey.getState(view_2.state);
|
|
14296
|
+
if (current?.active !== active || current.author !== author) setSuggestionMode(active, view_2.state, view_2.dispatch, author);
|
|
14297
|
+
}, [editingMode, author]);
|
|
14298
|
+
const handleBodyViewReady = useCallback((view_3) => {
|
|
14299
|
+
if (view_3) {
|
|
14300
|
+
syncSuggestionMode(view_3);
|
|
14301
|
+
syncCanonicalMode();
|
|
14302
|
+
}
|
|
14303
|
+
reportEditorViewReady(view_3);
|
|
14369
14304
|
setBodyViewEpoch((epoch) => epoch + 1);
|
|
14370
|
-
}, [
|
|
14305
|
+
}, [
|
|
14306
|
+
reportEditorViewReady,
|
|
14307
|
+
syncCanonicalMode,
|
|
14308
|
+
syncSuggestionMode
|
|
14309
|
+
]);
|
|
14371
14310
|
useEffect(() => {
|
|
14372
14311
|
const pagedEditor = pagedEditorRef.current;
|
|
14373
14312
|
if (!showOutline || bodyViewEpoch === 0 || !pagedEditor) return;
|
|
14374
14313
|
let collectedDoc = null;
|
|
14375
14314
|
let collected = [];
|
|
14376
14315
|
const refresh = (layout) => {
|
|
14377
|
-
const
|
|
14378
|
-
if (!
|
|
14379
|
-
if (
|
|
14380
|
-
collectedDoc =
|
|
14381
|
-
collected = collectHeadings(
|
|
14316
|
+
const view_4 = pagedEditor.getView();
|
|
14317
|
+
if (!view_4) return;
|
|
14318
|
+
if (view_4.state.doc !== collectedDoc) {
|
|
14319
|
+
collectedDoc = view_4.state.doc;
|
|
14320
|
+
collected = collectHeadings(view_4.state.doc, getDocumentBuiltInStyles(view_4.state));
|
|
14382
14321
|
}
|
|
14383
14322
|
setHeadingInfos((previous) => resolveOutlineHeadings({
|
|
14384
14323
|
collected,
|
|
@@ -14729,9 +14668,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14729
14668
|
});
|
|
14730
14669
|
}, [onFontsLoadedCallback]);
|
|
14731
14670
|
useEffect(() => {
|
|
14732
|
-
const
|
|
14733
|
-
if (
|
|
14734
|
-
}, [
|
|
14671
|
+
const view_5 = pagedEditorRef.current?.getView();
|
|
14672
|
+
if (view_5) syncSuggestionMode(view_5);
|
|
14673
|
+
}, [syncSuggestionMode]);
|
|
14735
14674
|
const handleDocumentChange = useCallback((newDocument) => {
|
|
14736
14675
|
const canonical = usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting);
|
|
14737
14676
|
const currentComments = commentsRef.current;
|
|
@@ -14778,16 +14717,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14778
14717
|
const flushBag = (bag) => {
|
|
14779
14718
|
if (!bag) return;
|
|
14780
14719
|
for (const [rId, hf] of bag) {
|
|
14781
|
-
const
|
|
14782
|
-
if (
|
|
14720
|
+
const view_6 = editor_0.getHfView(rId);
|
|
14721
|
+
if (view_6) hf.content = proseDocToBlocks(view_6.state.doc, hf.content);
|
|
14783
14722
|
}
|
|
14784
14723
|
};
|
|
14785
14724
|
flushBag(doc_0.package.headers);
|
|
14786
14725
|
flushBag(doc_0.package.footers);
|
|
14787
14726
|
}
|
|
14788
|
-
|
|
14789
|
-
setDocumentBodyComments(doc_0.package.document, pruneOrphanedComments(commentsRef.current, referencedCommentIds));
|
|
14790
|
-
return doc_0;
|
|
14727
|
+
return withHostCommentThreads(doc_0, commentsRef.current);
|
|
14791
14728
|
}, [commentsRef, experimentalSession]);
|
|
14792
14729
|
const applyCanonicalComment = useCallback((request) => {
|
|
14793
14730
|
return getCanonicalApi()?.applyCanonicalComment(request) ?? null;
|
|
@@ -14834,9 +14771,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14834
14771
|
return;
|
|
14835
14772
|
}
|
|
14836
14773
|
if (result?.status !== "refused" || result.retry !== "afterComposition") return;
|
|
14837
|
-
const
|
|
14838
|
-
if (!
|
|
14839
|
-
return afterCanonicalCompositionSettles(
|
|
14774
|
+
const view_7 = getCanonicalApi()?.getView();
|
|
14775
|
+
if (!view_7) return;
|
|
14776
|
+
return afterCanonicalCompositionSettles(view_7, () => setControlledCommentsRetry((attempt) => attempt + 1));
|
|
14840
14777
|
});
|
|
14841
14778
|
useEffect(() => synchronizeControlledComments({
|
|
14842
14779
|
commentsProp,
|
|
@@ -14937,17 +14874,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14937
14874
|
resetFindResultRef.current = resetFindResult;
|
|
14938
14875
|
}, [resetFindResult]);
|
|
14939
14876
|
const handleSelectionChange = useCallback((selectionState) => {
|
|
14940
|
-
const
|
|
14941
|
-
if (
|
|
14942
|
-
const { from, to } =
|
|
14877
|
+
const view_8 = getActiveEditorView();
|
|
14878
|
+
if (view_8) {
|
|
14879
|
+
const { from, to } = view_8.state.selection;
|
|
14943
14880
|
lastSelectionRef.current = {
|
|
14944
14881
|
from,
|
|
14945
14882
|
to
|
|
14946
14883
|
};
|
|
14947
14884
|
}
|
|
14948
14885
|
let pmTableCtx = null;
|
|
14949
|
-
if (
|
|
14950
|
-
pmTableCtx = getTableContext(
|
|
14886
|
+
if (view_8) {
|
|
14887
|
+
pmTableCtx = getTableContext(view_8.state);
|
|
14951
14888
|
if (!pmTableCtx.isInTable) pmTableCtx = null;
|
|
14952
14889
|
}
|
|
14953
14890
|
if (pmTableCtx?.cellBorderColor) {
|
|
@@ -14959,8 +14896,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14959
14896
|
color: { rgb }
|
|
14960
14897
|
};
|
|
14961
14898
|
}
|
|
14962
|
-
const pmImageCtx =
|
|
14963
|
-
const trackedChange =
|
|
14899
|
+
const pmImageCtx = view_8 ? detectImageContext(view_8.state) : null;
|
|
14900
|
+
const trackedChange = view_8 ? detectActiveTrackedChange(view_8.state) : null;
|
|
14964
14901
|
if (!selectionState) {
|
|
14965
14902
|
setFloatingCommentBtn(null);
|
|
14966
14903
|
setState((prev_1) => {
|
|
@@ -15023,10 +14960,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15023
14960
|
activeTrackedChange: activeTrackedChange_0
|
|
15024
14961
|
};
|
|
15025
14962
|
});
|
|
15026
|
-
if (
|
|
14963
|
+
if (view_8 && selectionState.hasSelection && !isAddingComment && !readOnly) {
|
|
15027
14964
|
const container = scrollContainerRef.current;
|
|
15028
14965
|
const parentEl = editorContentRef.current;
|
|
15029
|
-
const { from: selFrom } =
|
|
14966
|
+
const { from: selFrom } = view_8.state.selection;
|
|
15030
14967
|
const top = findSelectionYPosition(container, parentEl, selFrom);
|
|
15031
14968
|
if (top !== null && container && parentEl) {
|
|
15032
14969
|
const pagesEl = container.querySelector(".paged-editor__pages");
|
|
@@ -15034,7 +14971,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15034
14971
|
const parentRect = parentEl.getBoundingClientRect();
|
|
15035
14972
|
const rawLeft = pageEl ? pageEl.getBoundingClientRect().right - parentRect.left + 12 : parentRect.width / 2 + 408;
|
|
15036
14973
|
const left = Math.max(16, Math.min(rawLeft, parentRect.width - 16));
|
|
15037
|
-
const { from: from_0, to: to_0 } =
|
|
14974
|
+
const { from: from_0, to: to_0 } = view_8.state.selection;
|
|
15038
14975
|
if (from_0 !== to_0) setFloatingCommentBtn({
|
|
15039
14976
|
top,
|
|
15040
14977
|
left,
|
|
@@ -15197,99 +15134,99 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15197
15134
|
refuseCanonicalModelEdit
|
|
15198
15135
|
]);
|
|
15199
15136
|
const handleTableAction = useCallback((action_0) => {
|
|
15200
|
-
const
|
|
15201
|
-
if (!
|
|
15137
|
+
const view_9 = getActiveEditorView();
|
|
15138
|
+
if (!view_9) return;
|
|
15202
15139
|
switch (action_0) {
|
|
15203
15140
|
case "addRowAbove":
|
|
15204
|
-
addRowAbove(
|
|
15141
|
+
addRowAbove(view_9.state, view_9.dispatch);
|
|
15205
15142
|
break;
|
|
15206
15143
|
case "addRowBelow":
|
|
15207
|
-
addRowBelow(
|
|
15144
|
+
addRowBelow(view_9.state, view_9.dispatch);
|
|
15208
15145
|
break;
|
|
15209
15146
|
case "addColumnLeft":
|
|
15210
|
-
addColumnLeft(
|
|
15147
|
+
addColumnLeft(view_9.state, view_9.dispatch);
|
|
15211
15148
|
break;
|
|
15212
15149
|
case "addColumnRight":
|
|
15213
|
-
addColumnRight(
|
|
15150
|
+
addColumnRight(view_9.state, view_9.dispatch);
|
|
15214
15151
|
break;
|
|
15215
15152
|
case "deleteRow":
|
|
15216
|
-
deleteRow(
|
|
15153
|
+
deleteRow(view_9.state, view_9.dispatch);
|
|
15217
15154
|
break;
|
|
15218
15155
|
case "deleteColumn":
|
|
15219
|
-
deleteColumn(
|
|
15156
|
+
deleteColumn(view_9.state, view_9.dispatch);
|
|
15220
15157
|
break;
|
|
15221
15158
|
case "deleteTable":
|
|
15222
|
-
deleteTable(
|
|
15159
|
+
deleteTable(view_9.state, view_9.dispatch);
|
|
15223
15160
|
break;
|
|
15224
15161
|
case "selectTable":
|
|
15225
|
-
selectTable(
|
|
15162
|
+
selectTable(view_9.state, view_9.dispatch);
|
|
15226
15163
|
break;
|
|
15227
15164
|
case "selectRow":
|
|
15228
|
-
selectRow(
|
|
15165
|
+
selectRow(view_9.state, view_9.dispatch);
|
|
15229
15166
|
break;
|
|
15230
15167
|
case "selectColumn":
|
|
15231
|
-
selectColumn(
|
|
15168
|
+
selectColumn(view_9.state, view_9.dispatch);
|
|
15232
15169
|
break;
|
|
15233
15170
|
case "mergeCells":
|
|
15234
|
-
mergeCells(
|
|
15171
|
+
mergeCells(view_9.state, view_9.dispatch);
|
|
15235
15172
|
break;
|
|
15236
15173
|
case "splitCell":
|
|
15237
|
-
splitCell(
|
|
15174
|
+
splitCell(view_9.state, view_9.dispatch);
|
|
15238
15175
|
break;
|
|
15239
15176
|
case "borderAll":
|
|
15240
|
-
setAllTableBorders(
|
|
15177
|
+
setAllTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
|
|
15241
15178
|
break;
|
|
15242
15179
|
case "borderOutside":
|
|
15243
|
-
setOutsideTableBorders(
|
|
15180
|
+
setOutsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
|
|
15244
15181
|
break;
|
|
15245
15182
|
case "borderInside":
|
|
15246
|
-
setInsideTableBorders(
|
|
15183
|
+
setInsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
|
|
15247
15184
|
break;
|
|
15248
15185
|
case "borderNone":
|
|
15249
|
-
removeTableBorders(
|
|
15186
|
+
removeTableBorders(view_9.state, view_9.dispatch);
|
|
15250
15187
|
break;
|
|
15251
15188
|
case "borderTop":
|
|
15252
|
-
setCellBorder("top", borderSpecRef.current, true)(
|
|
15189
|
+
setCellBorder("top", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
|
|
15253
15190
|
break;
|
|
15254
15191
|
case "borderBottom":
|
|
15255
|
-
setCellBorder("bottom", borderSpecRef.current, true)(
|
|
15192
|
+
setCellBorder("bottom", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
|
|
15256
15193
|
break;
|
|
15257
15194
|
case "borderLeft":
|
|
15258
|
-
setCellBorder("left", borderSpecRef.current, true)(
|
|
15195
|
+
setCellBorder("left", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
|
|
15259
15196
|
break;
|
|
15260
15197
|
case "borderRight":
|
|
15261
|
-
setCellBorder("right", borderSpecRef.current, true)(
|
|
15198
|
+
setCellBorder("right", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
|
|
15262
15199
|
break;
|
|
15263
15200
|
default: if (typeof action_0 === "object") {
|
|
15264
|
-
if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(
|
|
15201
|
+
if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(view_9.state, view_9.dispatch);
|
|
15265
15202
|
else if (action_0.type === "borderColor") {
|
|
15266
15203
|
const rgb_0 = action_0.color.replace(/^#/u, "");
|
|
15267
15204
|
borderSpecRef.current = {
|
|
15268
15205
|
...borderSpecRef.current,
|
|
15269
15206
|
color: { rgb: rgb_0 }
|
|
15270
15207
|
};
|
|
15271
|
-
setTableBorderColor(action_0.color)(
|
|
15208
|
+
setTableBorderColor(action_0.color)(view_9.state, view_9.dispatch);
|
|
15272
15209
|
} else if (action_0.type === "borderWidth") {
|
|
15273
15210
|
borderSpecRef.current = {
|
|
15274
15211
|
...borderSpecRef.current,
|
|
15275
15212
|
size: action_0.size
|
|
15276
15213
|
};
|
|
15277
|
-
setTableBorderWidth(action_0.size)(
|
|
15214
|
+
setTableBorderWidth(action_0.size)(view_9.state, view_9.dispatch);
|
|
15278
15215
|
} else if (action_0.type === "cellBorder") setCellBorder(action_0.side, {
|
|
15279
15216
|
style: action_0.style,
|
|
15280
15217
|
size: action_0.size,
|
|
15281
15218
|
color: { rgb: action_0.color.replace(/^#/u, "") }
|
|
15282
|
-
})(
|
|
15283
|
-
else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(
|
|
15284
|
-
else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(
|
|
15285
|
-
else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(
|
|
15286
|
-
else if (action_0.type === "toggleNoWrap") toggleNoWrap()(
|
|
15287
|
-
else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(
|
|
15288
|
-
else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(
|
|
15289
|
-
else if (action_0.type === "distributeColumns") distributeColumns()(
|
|
15290
|
-
else if (action_0.type === "autoFitContents") autoFitContents()(
|
|
15219
|
+
})(view_9.state, view_9.dispatch);
|
|
15220
|
+
else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(view_9.state, view_9.dispatch);
|
|
15221
|
+
else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(view_9.state, view_9.dispatch);
|
|
15222
|
+
else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(view_9.state, view_9.dispatch);
|
|
15223
|
+
else if (action_0.type === "toggleNoWrap") toggleNoWrap()(view_9.state, view_9.dispatch);
|
|
15224
|
+
else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(view_9.state, view_9.dispatch);
|
|
15225
|
+
else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(view_9.state, view_9.dispatch);
|
|
15226
|
+
else if (action_0.type === "distributeColumns") distributeColumns()(view_9.state, view_9.dispatch);
|
|
15227
|
+
else if (action_0.type === "autoFitContents") autoFitContents()(view_9.state, view_9.dispatch);
|
|
15291
15228
|
else if (action_0.type === "openTableProperties") setTablePropsOpen(true);
|
|
15292
|
-
else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(
|
|
15229
|
+
else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(view_9.state, view_9.dispatch);
|
|
15293
15230
|
else {
|
|
15294
15231
|
let preset = getBuiltinTableStyle(action_0.styleId);
|
|
15295
15232
|
const currentDocForTable = historyStateRef.current;
|
|
@@ -15360,7 +15297,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15360
15297
|
if (preset.tableBorders) styleArg.tableBorders = preset.tableBorders;
|
|
15361
15298
|
if (preset.conditionals) styleArg.conditionals = preset.conditionals;
|
|
15362
15299
|
if (preset.look) styleArg.look = preset.look;
|
|
15363
|
-
applyTableStyle(styleArg)(
|
|
15300
|
+
applyTableStyle(styleArg)(view_9.state, view_9.dispatch);
|
|
15364
15301
|
}
|
|
15365
15302
|
}
|
|
15366
15303
|
} else tableSelection.handleAction(action_0);
|
|
@@ -15381,86 +15318,86 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15381
15318
|
});
|
|
15382
15319
|
}, [openContextMenu]);
|
|
15383
15320
|
const handleFormat = useCallback((action_1) => {
|
|
15384
|
-
const
|
|
15385
|
-
if (!
|
|
15386
|
-
|
|
15387
|
-
const isBodyEditor =
|
|
15388
|
-
const { from: from_1, to: to_1 } =
|
|
15321
|
+
const view_10 = getActiveEditorView();
|
|
15322
|
+
if (!view_10) return;
|
|
15323
|
+
view_10.focus();
|
|
15324
|
+
const isBodyEditor = view_10 === pagedEditorRef.current?.getView();
|
|
15325
|
+
const { from: from_1, to: to_1 } = view_10.state.selection;
|
|
15389
15326
|
const savedSelection = lastSelectionRef.current;
|
|
15390
15327
|
if (isBodyEditor && savedSelection && (from_1 !== savedSelection.from || to_1 !== savedSelection.to)) try {
|
|
15391
|
-
const tr =
|
|
15392
|
-
|
|
15328
|
+
const tr = view_10.state.tr.setSelection(TextSelection.create(view_10.state.doc, savedSelection.from, savedSelection.to));
|
|
15329
|
+
view_10.dispatch(tr);
|
|
15393
15330
|
} catch {}
|
|
15394
15331
|
if (action_1 === "bold") {
|
|
15395
|
-
executeEditorCommand(
|
|
15332
|
+
executeEditorCommand(view_10, toggleBold);
|
|
15396
15333
|
return;
|
|
15397
15334
|
}
|
|
15398
15335
|
if (action_1 === "italic") {
|
|
15399
|
-
executeEditorCommand(
|
|
15336
|
+
executeEditorCommand(view_10, toggleItalic);
|
|
15400
15337
|
return;
|
|
15401
15338
|
}
|
|
15402
15339
|
if (action_1 === "underline") {
|
|
15403
|
-
executeEditorCommand(
|
|
15340
|
+
executeEditorCommand(view_10, toggleUnderline);
|
|
15404
15341
|
return;
|
|
15405
15342
|
}
|
|
15406
15343
|
if (action_1 === "strikethrough") {
|
|
15407
|
-
executeEditorCommand(
|
|
15344
|
+
executeEditorCommand(view_10, toggleStrike);
|
|
15408
15345
|
return;
|
|
15409
15346
|
}
|
|
15410
15347
|
if (action_1 === "superscript") {
|
|
15411
|
-
executeEditorCommand(
|
|
15348
|
+
executeEditorCommand(view_10, toggleSuperscript);
|
|
15412
15349
|
return;
|
|
15413
15350
|
}
|
|
15414
15351
|
if (action_1 === "subscript") {
|
|
15415
|
-
executeEditorCommand(
|
|
15352
|
+
executeEditorCommand(view_10, toggleSubscript);
|
|
15416
15353
|
return;
|
|
15417
15354
|
}
|
|
15418
15355
|
if (action_1 === "bulletList") {
|
|
15419
|
-
executeEditorCommand(
|
|
15356
|
+
executeEditorCommand(view_10, toggleBulletList);
|
|
15420
15357
|
return;
|
|
15421
15358
|
}
|
|
15422
15359
|
if (action_1 === "numberedList") {
|
|
15423
|
-
executeEditorCommand(
|
|
15360
|
+
executeEditorCommand(view_10, toggleNumberedList);
|
|
15424
15361
|
return;
|
|
15425
15362
|
}
|
|
15426
15363
|
if (action_1 === "indent") {
|
|
15427
|
-
executeFirstEditorCommand(
|
|
15364
|
+
executeFirstEditorCommand(view_10, [increaseListLevel, increaseIndent()]);
|
|
15428
15365
|
return;
|
|
15429
15366
|
}
|
|
15430
15367
|
if (action_1 === "outdent") {
|
|
15431
|
-
executeFirstEditorCommand(
|
|
15368
|
+
executeFirstEditorCommand(view_10, [decreaseListLevel, decreaseIndent()]);
|
|
15432
15369
|
return;
|
|
15433
15370
|
}
|
|
15434
15371
|
if (action_1 === "clearFormatting") {
|
|
15435
|
-
executeEditorCommand(
|
|
15372
|
+
executeEditorCommand(view_10, clearFormatting);
|
|
15436
15373
|
return;
|
|
15437
15374
|
}
|
|
15438
15375
|
if (action_1 === "setRtl") {
|
|
15439
|
-
executeEditorCommand(
|
|
15376
|
+
executeEditorCommand(view_10, setRtl);
|
|
15440
15377
|
return;
|
|
15441
15378
|
}
|
|
15442
15379
|
if (action_1 === "setLtr") {
|
|
15443
|
-
executeEditorCommand(
|
|
15380
|
+
executeEditorCommand(view_10, setLtr);
|
|
15444
15381
|
return;
|
|
15445
15382
|
}
|
|
15446
15383
|
if (action_1 === "insertPageBreak") {
|
|
15447
|
-
executeEditorCommand(
|
|
15384
|
+
executeEditorCommand(view_10, insertPageBreak);
|
|
15448
15385
|
return;
|
|
15449
15386
|
}
|
|
15450
15387
|
if (typeof action_1 === "object") switch (action_1.type) {
|
|
15451
15388
|
case "alignment":
|
|
15452
|
-
executeEditorCommand(
|
|
15389
|
+
executeEditorCommand(view_10, setAlignment(action_1.value));
|
|
15453
15390
|
break;
|
|
15454
15391
|
case "toggleDirection":
|
|
15455
|
-
executeEditorCommand(
|
|
15392
|
+
executeEditorCommand(view_10, toggleBidi);
|
|
15456
15393
|
break;
|
|
15457
15394
|
case "textColor": {
|
|
15458
15395
|
const colorVal_0 = action_1.value;
|
|
15459
|
-
if (typeof colorVal_0 === "string") executeEditorCommand(
|
|
15460
|
-
else if (colorVal_0.auto) executeEditorCommand(
|
|
15396
|
+
if (typeof colorVal_0 === "string") executeEditorCommand(view_10, setTextColor({ rgb: colorVal_0.replace("#", "") }));
|
|
15397
|
+
else if (colorVal_0.auto) executeEditorCommand(view_10, clearTextColor);
|
|
15461
15398
|
else {
|
|
15462
15399
|
const themeColor = typeof colorVal_0.themeColor === "string" ? colorVal_0.themeColor : void 0;
|
|
15463
|
-
executeEditorCommand(
|
|
15400
|
+
executeEditorCommand(view_10, setTextColor({
|
|
15464
15401
|
...colorVal_0.rgb === void 0 ? {} : { rgb: colorVal_0.rgb },
|
|
15465
15402
|
...themeColor ? { themeColor } : {},
|
|
15466
15403
|
...colorVal_0.themeTint === void 0 ? {} : { themeTint: colorVal_0.themeTint },
|
|
@@ -15471,17 +15408,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15471
15408
|
}
|
|
15472
15409
|
case "highlightColor": {
|
|
15473
15410
|
const highlightName = action_1.value ? mapHexToHighlightName(action_1.value) : "";
|
|
15474
|
-
executeEditorCommand(
|
|
15411
|
+
executeEditorCommand(view_10, setHighlight(highlightName || action_1.value));
|
|
15475
15412
|
break;
|
|
15476
15413
|
}
|
|
15477
15414
|
case "fontSize":
|
|
15478
|
-
executeEditorCommand(
|
|
15415
|
+
executeEditorCommand(view_10, setFontSize(pointsToHalfPoints(action_1.value)));
|
|
15479
15416
|
break;
|
|
15480
15417
|
case "fontFamily":
|
|
15481
|
-
executeEditorCommand(
|
|
15418
|
+
executeEditorCommand(view_10, setFontFamily(action_1.value));
|
|
15482
15419
|
break;
|
|
15483
15420
|
case "lineSpacing":
|
|
15484
|
-
executeEditorCommand(
|
|
15421
|
+
executeEditorCommand(view_10, setLineSpacing(action_1.value));
|
|
15485
15422
|
break;
|
|
15486
15423
|
case "applyStyle": {
|
|
15487
15424
|
const currentDoc_0 = historyStateRef.current;
|
|
@@ -15494,21 +15431,21 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15494
15431
|
const styleName = styleResolver_0.getStyle(action_1.value)?.name;
|
|
15495
15432
|
if (styleName) styleAttrs.styleName = styleName;
|
|
15496
15433
|
styleAttrs.numbering = currentDoc_0?.package.numbering ? getCachedNumberingMap(currentDoc_0.package.numbering) : null;
|
|
15497
|
-
executeEditorCommand(
|
|
15498
|
-
} else executeEditorCommand(
|
|
15434
|
+
executeEditorCommand(view_10, applyStyle(action_1.value, styleAttrs));
|
|
15435
|
+
} else executeEditorCommand(view_10, applyStyle(action_1.value));
|
|
15499
15436
|
break;
|
|
15500
15437
|
}
|
|
15501
15438
|
}
|
|
15502
15439
|
}, [getActiveEditorView, getCachedStyleResolver]);
|
|
15503
15440
|
const captureFormatPainter = useCallback(() => {
|
|
15504
|
-
const
|
|
15505
|
-
capturedFormatMarksRef.current =
|
|
15441
|
+
const view_11 = getActiveEditorView();
|
|
15442
|
+
capturedFormatMarksRef.current = view_11 ? captureFormatMarks(view_11.state) : null;
|
|
15506
15443
|
}, [getActiveEditorView]);
|
|
15507
15444
|
const paintFormatToSelection = useCallback(() => {
|
|
15508
|
-
const
|
|
15509
|
-
if (!
|
|
15510
|
-
const applied = applyFormatMarks(capturedFormatMarksRef.current)(
|
|
15511
|
-
if (applied) requestAnimationFrame(() =>
|
|
15445
|
+
const view_12 = getActiveEditorView();
|
|
15446
|
+
if (!view_12) return false;
|
|
15447
|
+
const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_12.state, view_12.dispatch);
|
|
15448
|
+
if (applied) requestAnimationFrame(() => view_12.focus());
|
|
15512
15449
|
return applied;
|
|
15513
15450
|
}, [getActiveEditorView]);
|
|
15514
15451
|
const handleFormatPainter = useCallback((sticky) => {
|
|
@@ -15650,14 +15587,29 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15650
15587
|
label: t("tableBordersNone"),
|
|
15651
15588
|
dividerAfter: true
|
|
15652
15589
|
});
|
|
15653
|
-
if (contextMenu.cursorInTrackedChange)
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15590
|
+
if (contextMenu.cursorInTrackedChange) {
|
|
15591
|
+
const held = state.activeTrackedChange?.heldByLock ?? {
|
|
15592
|
+
accept: false,
|
|
15593
|
+
reject: false
|
|
15594
|
+
};
|
|
15595
|
+
const reason = t("trackedChanges.heldByLock");
|
|
15596
|
+
items.push({
|
|
15597
|
+
action: "acceptChange",
|
|
15598
|
+
label: t("acceptChange"),
|
|
15599
|
+
...held.accept && {
|
|
15600
|
+
disabled: true,
|
|
15601
|
+
disabledReason: reason
|
|
15602
|
+
}
|
|
15603
|
+
}, {
|
|
15604
|
+
action: "rejectChange",
|
|
15605
|
+
label: t("rejectChange"),
|
|
15606
|
+
dividerAfter: true,
|
|
15607
|
+
...held.reject && {
|
|
15608
|
+
disabled: true,
|
|
15609
|
+
disabledReason: reason
|
|
15610
|
+
}
|
|
15611
|
+
});
|
|
15612
|
+
}
|
|
15661
15613
|
if (contextMenu.listNumbering.type === "listItem") items.push({
|
|
15662
15614
|
action: "restartNumbering",
|
|
15663
15615
|
label: t("contextMenu.restartNumbering")
|
|
@@ -15683,19 +15635,20 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15683
15635
|
contextMenu.listNumbering,
|
|
15684
15636
|
customContextMenuItems,
|
|
15685
15637
|
readOnly,
|
|
15638
|
+
state.activeTrackedChange?.heldByLock,
|
|
15686
15639
|
t
|
|
15687
15640
|
]);
|
|
15688
15641
|
const { from: contextSelectionFrom, to: contextSelectionTo } = contextMenu.selectionRange;
|
|
15689
15642
|
const handleContextMenuAction = useCallback(async (action_2) => {
|
|
15690
|
-
const
|
|
15691
|
-
if (!
|
|
15643
|
+
const view_13 = getActiveEditorView();
|
|
15644
|
+
if (!view_13) return;
|
|
15692
15645
|
focusActiveEditor();
|
|
15693
15646
|
if (readOnly && action_2 !== "copy" && action_2 !== "selectAll") return;
|
|
15694
15647
|
if (action_2.startsWith("custom:")) {
|
|
15695
15648
|
const { from: from_2, to: to_2 } = contextSelectionFrom !== contextSelectionTo ? {
|
|
15696
15649
|
from: contextSelectionFrom,
|
|
15697
15650
|
to: contextSelectionTo
|
|
15698
|
-
} :
|
|
15651
|
+
} : view_13.state.selection;
|
|
15699
15652
|
onCustomContextAction?.(action_2.slice(7), {
|
|
15700
15653
|
from: from_2,
|
|
15701
15654
|
to: to_2
|
|
@@ -15705,16 +15658,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15705
15658
|
switch (action_2) {
|
|
15706
15659
|
case "cut": {
|
|
15707
15660
|
if (readOnly) return;
|
|
15708
|
-
const { from: from_7, to: to_7 } =
|
|
15709
|
-
const text_2 =
|
|
15661
|
+
const { from: from_7, to: to_7 } = view_13.state.selection;
|
|
15662
|
+
const text_2 = view_13.state.doc.textBetween(from_7, to_7, "\n");
|
|
15710
15663
|
navigator.clipboard.writeText(text_2).catch(() => void 0);
|
|
15711
|
-
if (!deleteSelectionAsSuggestion(
|
|
15664
|
+
if (!deleteSelectionAsSuggestion(view_13.state, view_13.dispatch)) view_13.dispatch(view_13.state.tr.deleteSelection());
|
|
15712
15665
|
onCut?.();
|
|
15713
15666
|
break;
|
|
15714
15667
|
}
|
|
15715
15668
|
case "copy": {
|
|
15716
|
-
const { from: cf, to: ct } =
|
|
15717
|
-
const copied =
|
|
15669
|
+
const { from: cf, to: ct } = view_13.state.selection;
|
|
15670
|
+
const copied = view_13.state.doc.textBetween(cf, ct, "\n");
|
|
15718
15671
|
navigator.clipboard.writeText(copied).catch(() => void 0);
|
|
15719
15672
|
onCopy?.();
|
|
15720
15673
|
break;
|
|
@@ -15737,12 +15690,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15737
15690
|
bubbles: true,
|
|
15738
15691
|
cancelable: true
|
|
15739
15692
|
});
|
|
15740
|
-
|
|
15693
|
+
view_13.dom.dispatchEvent(pasteEvent);
|
|
15741
15694
|
} catch {
|
|
15742
15695
|
try {
|
|
15743
15696
|
const text_0 = await navigator.clipboard.readText();
|
|
15744
15697
|
if (text_0) {
|
|
15745
|
-
|
|
15698
|
+
view_13.dispatch(view_13.state.tr.insertText(text_0));
|
|
15746
15699
|
onPaste?.();
|
|
15747
15700
|
}
|
|
15748
15701
|
} catch {}
|
|
@@ -15751,9 +15704,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15751
15704
|
case "pasteAsPlainText":
|
|
15752
15705
|
try {
|
|
15753
15706
|
const text = await navigator.clipboard.readText();
|
|
15754
|
-
if (text && !
|
|
15755
|
-
|
|
15756
|
-
view_12.dispatch(view_12.state.tr.replaceSelection(slice).scrollIntoView());
|
|
15707
|
+
if (text && !view_13.isDestroyed) {
|
|
15708
|
+
pastePlainTextSlice(view_13, buildPlainTextSlice(text, view_13.state.schema));
|
|
15757
15709
|
onPaste?.();
|
|
15758
15710
|
}
|
|
15759
15711
|
} catch {
|
|
@@ -15761,42 +15713,42 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15761
15713
|
}
|
|
15762
15714
|
break;
|
|
15763
15715
|
case "delete": {
|
|
15764
|
-
const { from: from_6, to: to_6 } =
|
|
15765
|
-
if (from_6 !== to_6)
|
|
15716
|
+
const { from: from_6, to: to_6 } = view_13.state.selection;
|
|
15717
|
+
if (from_6 !== to_6) view_13.dispatch(view_13.state.tr.deleteRange(from_6, to_6));
|
|
15766
15718
|
break;
|
|
15767
15719
|
}
|
|
15768
15720
|
case "selectAll":
|
|
15769
|
-
|
|
15721
|
+
view_13.dispatch(view_13.state.tr.setSelection(TextSelection.create(view_13.state.doc, 0, view_13.state.doc.content.size)));
|
|
15770
15722
|
break;
|
|
15771
15723
|
case "addRowAbove":
|
|
15772
|
-
addRowAbove(
|
|
15724
|
+
addRowAbove(view_13.state, view_13.dispatch);
|
|
15773
15725
|
break;
|
|
15774
15726
|
case "addRowBelow":
|
|
15775
|
-
addRowBelow(
|
|
15727
|
+
addRowBelow(view_13.state, view_13.dispatch);
|
|
15776
15728
|
break;
|
|
15777
15729
|
case "deleteRow":
|
|
15778
|
-
deleteRow(
|
|
15730
|
+
deleteRow(view_13.state, view_13.dispatch);
|
|
15779
15731
|
break;
|
|
15780
15732
|
case "addColumnLeft":
|
|
15781
|
-
addColumnLeft(
|
|
15733
|
+
addColumnLeft(view_13.state, view_13.dispatch);
|
|
15782
15734
|
break;
|
|
15783
15735
|
case "addColumnRight":
|
|
15784
|
-
addColumnRight(
|
|
15736
|
+
addColumnRight(view_13.state, view_13.dispatch);
|
|
15785
15737
|
break;
|
|
15786
15738
|
case "deleteColumn":
|
|
15787
|
-
deleteColumn(
|
|
15739
|
+
deleteColumn(view_13.state, view_13.dispatch);
|
|
15788
15740
|
break;
|
|
15789
15741
|
case "tableBordersAll":
|
|
15790
|
-
setTableBorderPreset("all")(
|
|
15742
|
+
setTableBorderPreset("all")(view_13.state, view_13.dispatch);
|
|
15791
15743
|
break;
|
|
15792
15744
|
case "tableBordersNone":
|
|
15793
|
-
setTableBorderPreset("none")(
|
|
15745
|
+
setTableBorderPreset("none")(view_13.state, view_13.dispatch);
|
|
15794
15746
|
break;
|
|
15795
15747
|
case "addComment": {
|
|
15796
15748
|
const { from: from_5, to: to_5 } = contextSelectionFrom !== contextSelectionTo ? {
|
|
15797
15749
|
from: contextSelectionFrom,
|
|
15798
15750
|
to: contextSelectionTo
|
|
15799
|
-
} :
|
|
15751
|
+
} : view_13.state.selection;
|
|
15800
15752
|
if (from_5 === to_5) break;
|
|
15801
15753
|
const commentY = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, from_5) ?? getFallbackCommentYPosition(scrollContainerRef.current);
|
|
15802
15754
|
setCommentSelectionRange({
|
|
@@ -15804,7 +15756,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15804
15756
|
to: to_5
|
|
15805
15757
|
});
|
|
15806
15758
|
if (commentDraftMode === "prosemirror") {
|
|
15807
|
-
if (!applyCommentMarkRange(
|
|
15759
|
+
if (!applyCommentMarkRange(view_13, {
|
|
15808
15760
|
from: from_5,
|
|
15809
15761
|
to: to_5
|
|
15810
15762
|
}, -1, { selectEnd: true })) break;
|
|
@@ -15816,30 +15768,30 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15816
15768
|
break;
|
|
15817
15769
|
}
|
|
15818
15770
|
case "acceptChange": {
|
|
15819
|
-
const { from: from_4, to: to_4 } =
|
|
15820
|
-
const range_0 = findChangeAtPosition(
|
|
15771
|
+
const { from: from_4, to: to_4 } = view_13.state.selection;
|
|
15772
|
+
const range_0 = findChangeAtPosition(view_13.state, from_4, to_4);
|
|
15821
15773
|
if (resolveCanonicalReviewRange({
|
|
15822
15774
|
editor: pagedEditorRef.current?.getEditor(),
|
|
15823
15775
|
...range_0,
|
|
15824
15776
|
resolution: "accept"
|
|
15825
|
-
}) === null) acceptChange(range_0.from, range_0.to)(
|
|
15777
|
+
}) === null) acceptChange(range_0.from, range_0.to)(view_13.state, view_13.dispatch);
|
|
15826
15778
|
break;
|
|
15827
15779
|
}
|
|
15828
15780
|
case "rejectChange": {
|
|
15829
|
-
const { from: from_3, to: to_3 } =
|
|
15830
|
-
const range = findChangeAtPosition(
|
|
15781
|
+
const { from: from_3, to: to_3 } = view_13.state.selection;
|
|
15782
|
+
const range = findChangeAtPosition(view_13.state, from_3, to_3);
|
|
15831
15783
|
if (resolveCanonicalReviewRange({
|
|
15832
15784
|
editor: pagedEditorRef.current?.getEditor(),
|
|
15833
15785
|
...range,
|
|
15834
15786
|
resolution: "reject"
|
|
15835
|
-
}) === null) rejectChange(range.from, range.to)(
|
|
15787
|
+
}) === null) rejectChange(range.from, range.to)(view_13.state, view_13.dispatch);
|
|
15836
15788
|
break;
|
|
15837
15789
|
}
|
|
15838
15790
|
case "restartNumbering":
|
|
15839
|
-
restartNumbering(
|
|
15791
|
+
restartNumbering(view_13.state, view_13.dispatch);
|
|
15840
15792
|
break;
|
|
15841
15793
|
case "continueNumbering":
|
|
15842
|
-
continueNumbering(
|
|
15794
|
+
continueNumbering(view_13.state, view_13.dispatch);
|
|
15843
15795
|
break;
|
|
15844
15796
|
case "setNumberingValue": setNumberingValueDialogOpen(true);
|
|
15845
15797
|
}
|
|
@@ -15896,25 +15848,25 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15896
15848
|
const handleTopMarginChange = useCallback((twips_1) => handlePageSetupApply({ marginTop: twips_1 }), [handlePageSetupApply]);
|
|
15897
15849
|
const handleBottomMarginChange = useCallback((twips_2) => handlePageSetupApply({ marginBottom: twips_2 }), [handlePageSetupApply]);
|
|
15898
15850
|
const handleIndentLeftChange = useCallback((twips_3) => {
|
|
15899
|
-
const view_13 = getActiveEditorView();
|
|
15900
|
-
if (!view_13) return;
|
|
15901
|
-
setIndentLeft(twips_3)(view_13.state, view_13.dispatch);
|
|
15902
|
-
}, [getActiveEditorView]);
|
|
15903
|
-
const handleIndentRightChange = useCallback((twips_4) => {
|
|
15904
15851
|
const view_14 = getActiveEditorView();
|
|
15905
15852
|
if (!view_14) return;
|
|
15906
|
-
|
|
15853
|
+
setIndentLeft(twips_3)(view_14.state, view_14.dispatch);
|
|
15907
15854
|
}, [getActiveEditorView]);
|
|
15908
|
-
const
|
|
15855
|
+
const handleIndentRightChange = useCallback((twips_4) => {
|
|
15909
15856
|
const view_15 = getActiveEditorView();
|
|
15910
15857
|
if (!view_15) return;
|
|
15911
|
-
|
|
15912
|
-
else setIndentFirstLine(twips_5, false)(view_15.state, view_15.dispatch);
|
|
15858
|
+
setIndentRight(twips_4)(view_15.state, view_15.dispatch);
|
|
15913
15859
|
}, [getActiveEditorView]);
|
|
15914
|
-
const
|
|
15860
|
+
const handleFirstLineIndentChange = useCallback((twips_5) => {
|
|
15915
15861
|
const view_16 = getActiveEditorView();
|
|
15916
15862
|
if (!view_16) return;
|
|
15917
|
-
|
|
15863
|
+
if (twips_5 < 0) setIndentFirstLine(-twips_5, true)(view_16.state, view_16.dispatch);
|
|
15864
|
+
else setIndentFirstLine(twips_5, false)(view_16.state, view_16.dispatch);
|
|
15865
|
+
}, [getActiveEditorView]);
|
|
15866
|
+
const handleTabStopRemove = useCallback((positionTwips) => {
|
|
15867
|
+
const view_17 = getActiveEditorView();
|
|
15868
|
+
if (!view_17) return;
|
|
15869
|
+
removeTabStop(positionTwips)(view_17.state, view_17.dispatch);
|
|
15918
15870
|
}, [getActiveEditorView]);
|
|
15919
15871
|
const serializeCurrentDocx = useCallback(async (options) => {
|
|
15920
15872
|
let tripwireResult = null;
|
|
@@ -15923,8 +15875,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15923
15875
|
const editor_2 = pagedEditorRef.current?.getEditor();
|
|
15924
15876
|
const snapshot_0 = editor_2?.captureCanonicalSave();
|
|
15925
15877
|
if (snapshot_0 && editor_2) {
|
|
15926
|
-
const
|
|
15927
|
-
const editorState =
|
|
15878
|
+
const view_18 = editor_2.getView();
|
|
15879
|
+
const editorState = view_18?.state;
|
|
15928
15880
|
const result_2 = await serializeCanonicalSave({
|
|
15929
15881
|
snapshot: snapshot_0,
|
|
15930
15882
|
options,
|
|
@@ -15936,15 +15888,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15936
15888
|
message: `Canonical save used a fidelity fallback: ${diagnostic.type} (${diagnostic.part}).`
|
|
15937
15889
|
}));
|
|
15938
15890
|
tripwireResult = result_2.tripwireResult;
|
|
15939
|
-
if (
|
|
15891
|
+
if (view_18 && pagedEditorRef.current?.getEditor() === editor_2 && editor_2.getView() === view_18 && view_18.state.doc === editorState?.doc && editor_2.isCanonicalSaveCurrent(snapshot_0.version)) view_18.dispatch(clearTrackedChanges(view_18.state));
|
|
15940
15892
|
savedBuffer = result_2.buffer;
|
|
15941
15893
|
} else {
|
|
15942
15894
|
if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.save)) return null;
|
|
15943
|
-
const
|
|
15944
|
-
const editorState_0 =
|
|
15895
|
+
const view_19 = pagedEditorRef.current?.getView();
|
|
15896
|
+
const editorState_0 = view_19?.state;
|
|
15945
15897
|
const baselineBuffer = originalBufferRef.current;
|
|
15946
|
-
const
|
|
15947
|
-
const doc_1 =
|
|
15898
|
+
const current_0 = buildCurrentDocument();
|
|
15899
|
+
const doc_1 = current_0 ? withoutUnreferencedNotes(current_0) : null;
|
|
15948
15900
|
if (!doc_1) return null;
|
|
15949
15901
|
const { resolveSelectiveSaveFlags } = await import("@stll/folio-core/docx/selectiveSaveFlags");
|
|
15950
15902
|
const flags = resolveSelectiveSaveFlags(featureFlags);
|
|
@@ -15982,9 +15934,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15982
15934
|
const { compareSelectiveVsFull } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
|
|
15983
15935
|
tripwireResult = await compareSelectiveVsFull(selectiveBuffer, fullBuffer);
|
|
15984
15936
|
} catch {}
|
|
15985
|
-
if (
|
|
15937
|
+
if (view_19 && pagedEditorRef.current?.getView() === view_19 && view_19.state.doc === editorState_0?.doc) {
|
|
15986
15938
|
originalBufferRef.current = buffer;
|
|
15987
|
-
|
|
15939
|
+
view_19.dispatch(clearTrackedChanges(view_19.state));
|
|
15988
15940
|
}
|
|
15989
15941
|
savedBuffer = buffer;
|
|
15990
15942
|
}
|
|
@@ -16025,9 +15977,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16025
15977
|
serializeCurrentDocx
|
|
16026
15978
|
]);
|
|
16027
15979
|
const handleEditorError = useCallback((error_1) => {
|
|
16028
|
-
if (CanonicalSessionRefusalError.is(error_1)) toast(error_1.message);
|
|
15980
|
+
if (CanonicalSessionRefusalError.is(error_1)) toast(canonicalRefusalNotice(error_1.ground, error_1.message, t));
|
|
16029
15981
|
onError?.(error_1);
|
|
16030
|
-
}, [onError]);
|
|
15982
|
+
}, [onError, t]);
|
|
16031
15983
|
useImperativeHandle(ref, () => ({
|
|
16032
15984
|
getReadOnlyReason: () => readOnlyReason,
|
|
16033
15985
|
getDocument: () => buildCurrentDocument(),
|
|
@@ -16040,9 +15992,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16040
15992
|
getFindResult,
|
|
16041
15993
|
clearFind: resetFindResult,
|
|
16042
15994
|
hasPendingChanges: () => {
|
|
16043
|
-
const
|
|
16044
|
-
if (!
|
|
16045
|
-
return getCommentsDirty() || getChangedParagraphIds(
|
|
15995
|
+
const view_20 = pagedEditorRef.current?.getView();
|
|
15996
|
+
if (!view_20) return false;
|
|
15997
|
+
return getCommentsDirty() || getChangedParagraphIds(view_20.state).size > 0 || hasStructuralChanges(view_20.state) || hasUntrackedChanges(view_20.state);
|
|
16046
15998
|
},
|
|
16047
15999
|
getEditorRef: () => pagedEditorRef.current,
|
|
16048
16000
|
getEditor: () => pagedEditorRef.current?.getEditor() ?? null,
|
|
@@ -16087,13 +16039,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16087
16039
|
pagedEditorRef.current?.ensureView(options_3);
|
|
16088
16040
|
},
|
|
16089
16041
|
createAIEditSnapshot: () => {
|
|
16090
|
-
const
|
|
16091
|
-
return
|
|
16042
|
+
const view_21 = pagedEditorRef.current?.getView();
|
|
16043
|
+
return view_21 ? createFolioAIEditSnapshot(view_21.state.doc) : null;
|
|
16092
16044
|
},
|
|
16093
16045
|
applyDocumentOperations: ({ undefinedReferences, snapshot: snapshot_1, batch, author: operationAuthor = author }) => {
|
|
16094
16046
|
assertSupportedFolioDocumentOperationVersion(batch.version);
|
|
16095
|
-
const
|
|
16096
|
-
if (!
|
|
16047
|
+
const view_22 = pagedEditorRef.current?.getView();
|
|
16048
|
+
if (!view_22) {
|
|
16097
16049
|
let status = "committed";
|
|
16098
16050
|
if (batch.dryRun === true) status = "previewed";
|
|
16099
16051
|
else if (batch.atomic === true) status = "rejected";
|
|
@@ -16111,25 +16063,36 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16111
16063
|
undoHandle: null
|
|
16112
16064
|
};
|
|
16113
16065
|
}
|
|
16066
|
+
const activeBeforeCanonical = new Set(getSuggestions(view_22.state).map((s_0) => s_0.suggestionId));
|
|
16114
16067
|
const canonical_1 = getCanonicalApi()?.applyCanonicalDocumentOperations({
|
|
16115
16068
|
undefinedReferences,
|
|
16116
16069
|
snapshot: snapshot_1,
|
|
16117
16070
|
batch,
|
|
16118
16071
|
author: operationAuthor
|
|
16119
16072
|
});
|
|
16120
|
-
if (canonical_1)
|
|
16073
|
+
if (canonical_1) {
|
|
16074
|
+
if (batch.mode === "suggested" && canonical_1.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
|
|
16075
|
+
snapshot: snapshot_1,
|
|
16076
|
+
story: { type: "main" },
|
|
16077
|
+
operations: batch.operations,
|
|
16078
|
+
applied: canonical_1.applied,
|
|
16079
|
+
author: operationAuthor,
|
|
16080
|
+
activeSuggestionIds: activeBeforeCanonical
|
|
16081
|
+
});
|
|
16082
|
+
return canonical_1;
|
|
16083
|
+
}
|
|
16121
16084
|
const existingUndoEntry = documentOperationUndoEntriesRef.current.at(-1);
|
|
16122
|
-
if (existingUndoEntry && (!
|
|
16085
|
+
if (existingUndoEntry && (!view_22.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentsRef.current) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
|
|
16123
16086
|
const commentsBefore = commentsRef.current;
|
|
16124
16087
|
const createdComments = [];
|
|
16125
16088
|
const operationView = {
|
|
16126
|
-
state:
|
|
16089
|
+
state: view_22.state,
|
|
16127
16090
|
dispatch: (transaction) => {
|
|
16128
|
-
|
|
16129
|
-
operationView.state =
|
|
16091
|
+
view_22.dispatch(closeHistory(transaction));
|
|
16092
|
+
operationView.state = view_22.state;
|
|
16130
16093
|
}
|
|
16131
16094
|
};
|
|
16132
|
-
const activeSuggestionIds = new Set(getSuggestions(
|
|
16095
|
+
const activeSuggestionIds = new Set(getSuggestions(view_22.state).map((s_1) => s_1.suggestionId));
|
|
16133
16096
|
const result_3 = applyFolioDocumentOperations({
|
|
16134
16097
|
undefinedReferences,
|
|
16135
16098
|
view: operationView,
|
|
@@ -16159,7 +16122,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16159
16122
|
if (batchComments.length > 0) replaceComments(commentsAfter);
|
|
16160
16123
|
if (result_3.undoHandle !== null) documentOperationUndoEntriesRef.current.push({
|
|
16161
16124
|
undoHandle: result_3.undoHandle,
|
|
16162
|
-
afterState:
|
|
16125
|
+
afterState: view_22.state,
|
|
16163
16126
|
commentsBefore,
|
|
16164
16127
|
commentsAfterJson: canonicalJson(commentsAfter)
|
|
16165
16128
|
});
|
|
@@ -16181,18 +16144,18 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16181
16144
|
reason: "notLatest"
|
|
16182
16145
|
};
|
|
16183
16146
|
const entry_3 = entries_0.at(-1);
|
|
16184
|
-
const
|
|
16185
|
-
if (!entry_3 || !
|
|
16147
|
+
const view_23 = pagedEditorRef.current?.getView();
|
|
16148
|
+
if (!entry_3 || !view_23) return {
|
|
16186
16149
|
status: "rejected",
|
|
16187
16150
|
undoHandle,
|
|
16188
16151
|
reason: "unknownHandle"
|
|
16189
16152
|
};
|
|
16190
|
-
if (!
|
|
16153
|
+
if (!view_23.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentsRef.current) !== entry_3.commentsAfterJson) return {
|
|
16191
16154
|
status: "rejected",
|
|
16192
16155
|
undoHandle,
|
|
16193
16156
|
reason: "documentChanged"
|
|
16194
16157
|
};
|
|
16195
|
-
if (!undo(
|
|
16158
|
+
if (!undo(view_23.state, view_23.dispatch)) return {
|
|
16196
16159
|
status: "rejected",
|
|
16197
16160
|
undoHandle,
|
|
16198
16161
|
reason: "documentChanged"
|
|
@@ -16206,14 +16169,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16206
16169
|
};
|
|
16207
16170
|
},
|
|
16208
16171
|
applyAIEditOperations: ({ undefinedReferences: undefinedReferences_0, snapshot: snapshot_2, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
|
|
16209
|
-
const
|
|
16210
|
-
if (!
|
|
16172
|
+
const view_24 = pagedEditorRef.current?.getView();
|
|
16173
|
+
if (!view_24) return {
|
|
16211
16174
|
applied: [],
|
|
16212
16175
|
skipped: operations.map((operation_0) => ({
|
|
16213
16176
|
id: operation_0.id,
|
|
16214
16177
|
reason: "unsupportedBlock"
|
|
16215
16178
|
}))
|
|
16216
16179
|
};
|
|
16180
|
+
const activeSuggestionIds_0 = new Set(getSuggestions(view_24.state).map((s_2) => s_2.suggestionId));
|
|
16217
16181
|
const canonical_3 = getCanonicalApi()?.applyCanonicalDocumentOperations({
|
|
16218
16182
|
undefinedReferences: undefinedReferences_0,
|
|
16219
16183
|
snapshot: snapshot_2,
|
|
@@ -16224,12 +16188,21 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16224
16188
|
},
|
|
16225
16189
|
author: operationAuthor_0
|
|
16226
16190
|
});
|
|
16227
|
-
if (canonical_3)
|
|
16191
|
+
if (canonical_3) {
|
|
16192
|
+
if (mode === "suggested" && canonical_3.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
|
|
16193
|
+
snapshot: snapshot_2,
|
|
16194
|
+
story: { type: "main" },
|
|
16195
|
+
operations,
|
|
16196
|
+
applied: canonical_3.applied,
|
|
16197
|
+
author: operationAuthor_0,
|
|
16198
|
+
activeSuggestionIds: activeSuggestionIds_0
|
|
16199
|
+
});
|
|
16200
|
+
return canonical_3;
|
|
16201
|
+
}
|
|
16228
16202
|
const createdComments_0 = [];
|
|
16229
|
-
const activeSuggestionIds_0 = new Set(getSuggestions(view_23.state).map((s_1) => s_1.suggestionId));
|
|
16230
16203
|
const { applied: applied_0, skipped: skipped_0 } = applyFolioDocumentOperations({
|
|
16231
16204
|
undefinedReferences: undefinedReferences_0,
|
|
16232
|
-
view:
|
|
16205
|
+
view: view_24,
|
|
16233
16206
|
snapshot: snapshot_2,
|
|
16234
16207
|
batch: {
|
|
16235
16208
|
version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
|
|
@@ -16259,18 +16232,18 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16259
16232
|
};
|
|
16260
16233
|
},
|
|
16261
16234
|
acceptAIEditOperation: (revisionId) => {
|
|
16262
|
-
const
|
|
16263
|
-
if (!
|
|
16235
|
+
const view_25 = pagedEditorRef.current?.getView();
|
|
16236
|
+
if (!view_25) return false;
|
|
16264
16237
|
const editor_5 = pagedEditorRef.current?.getEditor();
|
|
16265
16238
|
if (editor_5?.getCanonicalDocument()) return editor_5.resolveCanonicalRevisions(typeof revisionId === "number" ? [revisionId] : revisionId, "accept");
|
|
16266
|
-
return acceptAIEditRevision(revisionId)(
|
|
16239
|
+
return acceptAIEditRevision(revisionId)(view_25.state, view_25.dispatch);
|
|
16267
16240
|
},
|
|
16268
16241
|
rejectAIEditOperation: (revisionId_0) => {
|
|
16269
|
-
const
|
|
16270
|
-
if (!
|
|
16242
|
+
const view_26 = pagedEditorRef.current?.getView();
|
|
16243
|
+
if (!view_26) return false;
|
|
16271
16244
|
const editor_6 = pagedEditorRef.current?.getEditor();
|
|
16272
16245
|
if (editor_6?.getCanonicalDocument()) return editor_6.resolveCanonicalRevisions(typeof revisionId_0 === "number" ? [revisionId_0] : revisionId_0, "reject");
|
|
16273
|
-
return rejectAIEditRevision(revisionId_0)(
|
|
16246
|
+
return rejectAIEditRevision(revisionId_0)(view_26.state, view_26.dispatch);
|
|
16274
16247
|
},
|
|
16275
16248
|
undo: () => {
|
|
16276
16249
|
if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
|
|
@@ -16285,44 +16258,44 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16285
16258
|
return redone;
|
|
16286
16259
|
},
|
|
16287
16260
|
scrollToAIEditOperation: (revisionId_1) => {
|
|
16288
|
-
const
|
|
16289
|
-
if (!
|
|
16290
|
-
const range_1 = findAIEditRevisionRange(
|
|
16261
|
+
const view_27 = pagedEditorRef.current?.getView();
|
|
16262
|
+
if (!view_27) return false;
|
|
16263
|
+
const range_1 = findAIEditRevisionRange(view_27.state, revisionId_1);
|
|
16291
16264
|
if (!range_1) return false;
|
|
16292
|
-
const { from: from_8, to: to_8 } = clampRangeToDocSize(
|
|
16293
|
-
const $from =
|
|
16294
|
-
const $to =
|
|
16295
|
-
|
|
16265
|
+
const { from: from_8, to: to_8 } = clampRangeToDocSize(view_27.state.doc.content.size, range_1);
|
|
16266
|
+
const $from = view_27.state.doc.resolve(from_8);
|
|
16267
|
+
const $to = view_27.state.doc.resolve(to_8);
|
|
16268
|
+
view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from, $to)));
|
|
16296
16269
|
requestAnimationFrame(() => {
|
|
16297
16270
|
pagedEditorRef.current?.scrollToPosition(from_8);
|
|
16298
16271
|
});
|
|
16299
16272
|
return true;
|
|
16300
16273
|
},
|
|
16301
16274
|
scrollToBlock: (blockId, snapshot_3) => {
|
|
16302
|
-
const
|
|
16303
|
-
if (!
|
|
16275
|
+
const view_28 = pagedEditorRef.current?.getView();
|
|
16276
|
+
if (!view_28) return false;
|
|
16304
16277
|
const range_2 = resolveFolioAIBlockRange({
|
|
16305
16278
|
blockId,
|
|
16306
|
-
doc:
|
|
16279
|
+
doc: view_28.state.doc,
|
|
16307
16280
|
snapshot: snapshot_3
|
|
16308
16281
|
});
|
|
16309
16282
|
if (range_2 === null) return false;
|
|
16310
16283
|
const { from: from_9, to: to_9 } = range_2;
|
|
16311
|
-
const $from_0 =
|
|
16312
|
-
const $to_0 =
|
|
16313
|
-
|
|
16284
|
+
const $from_0 = view_28.state.doc.resolve(from_9);
|
|
16285
|
+
const $to_0 = view_28.state.doc.resolve(to_9);
|
|
16286
|
+
view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
|
|
16314
16287
|
requestAnimationFrame(() => {
|
|
16315
16288
|
pagedEditorRef.current?.scrollToPosition(from_9);
|
|
16316
16289
|
});
|
|
16317
16290
|
return true;
|
|
16318
16291
|
},
|
|
16319
16292
|
highlightPassage: ({ blockId: blockId_0, text: text_5, snapshot: snapshot_4 }) => {
|
|
16320
|
-
const
|
|
16321
|
-
if (!
|
|
16293
|
+
const view_29 = pagedEditorRef.current?.getView();
|
|
16294
|
+
if (!view_29) return "none";
|
|
16322
16295
|
const passageRange = resolvePassageRange({
|
|
16323
16296
|
blockId: blockId_0,
|
|
16324
16297
|
text: text_5,
|
|
16325
|
-
doc:
|
|
16298
|
+
doc: view_29.state.doc,
|
|
16326
16299
|
snapshot: snapshot_4
|
|
16327
16300
|
});
|
|
16328
16301
|
if (passageRange !== null) {
|
|
@@ -16335,16 +16308,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16335
16308
|
pagedEditorRef.current?.setPassageHighlight(null);
|
|
16336
16309
|
const blockRange = resolveFolioAIBlockRange({
|
|
16337
16310
|
blockId: blockId_0,
|
|
16338
|
-
doc:
|
|
16311
|
+
doc: view_29.state.doc,
|
|
16339
16312
|
snapshot: snapshot_4
|
|
16340
16313
|
});
|
|
16341
16314
|
if (blockRange === null) return "none";
|
|
16342
16315
|
const paraId_0 = getFolioParaIdFromBlockId(blockId_0);
|
|
16343
16316
|
if (paraId_0 !== null && pagedEditorRef.current?.scrollToParaId(paraId_0, { highlight: {} })) return "block";
|
|
16344
16317
|
const { from: from_10, to: to_10 } = blockRange;
|
|
16345
|
-
const $from_1 =
|
|
16346
|
-
const $to_1 =
|
|
16347
|
-
|
|
16318
|
+
const $from_1 = view_29.state.doc.resolve(from_10);
|
|
16319
|
+
const $to_1 = view_29.state.doc.resolve(to_10);
|
|
16320
|
+
view_29.dispatch(view_29.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
|
|
16348
16321
|
requestAnimationFrame(() => {
|
|
16349
16322
|
pagedEditorRef.current?.scrollToPosition(from_10);
|
|
16350
16323
|
});
|
|
@@ -16354,52 +16327,52 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16354
16327
|
pagedEditorRef.current?.setPassageHighlight(null);
|
|
16355
16328
|
},
|
|
16356
16329
|
showInDocument: (target_1, snapshot_5) => {
|
|
16357
|
-
const
|
|
16358
|
-
if (!
|
|
16330
|
+
const view_30 = pagedEditorRef.current?.getView();
|
|
16331
|
+
if (!view_30) return false;
|
|
16359
16332
|
const range_3 = target_1.type === "textRange" ? resolveFolioAITextRange({
|
|
16360
16333
|
range: target_1,
|
|
16361
|
-
doc:
|
|
16334
|
+
doc: view_30.state.doc,
|
|
16362
16335
|
snapshot: snapshot_5
|
|
16363
16336
|
}) : resolveFolioAIBlockRange({
|
|
16364
16337
|
blockId: target_1.blockId,
|
|
16365
|
-
doc:
|
|
16338
|
+
doc: view_30.state.doc,
|
|
16366
16339
|
snapshot: snapshot_5
|
|
16367
16340
|
});
|
|
16368
16341
|
if (range_3 === null) return false;
|
|
16369
16342
|
const { from: from_11, to: to_11 } = range_3;
|
|
16370
|
-
const $from_2 =
|
|
16371
|
-
const $to_2 =
|
|
16372
|
-
|
|
16343
|
+
const $from_2 = view_30.state.doc.resolve(from_11);
|
|
16344
|
+
const $to_2 = view_30.state.doc.resolve(to_11);
|
|
16345
|
+
view_30.dispatch(view_30.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
|
|
16373
16346
|
requestAnimationFrame(() => {
|
|
16374
16347
|
pagedEditorRef.current?.scrollToPosition(from_11);
|
|
16375
16348
|
});
|
|
16376
16349
|
return true;
|
|
16377
16350
|
},
|
|
16378
16351
|
getSuggestions: () => {
|
|
16379
|
-
const
|
|
16380
|
-
return
|
|
16352
|
+
const view_31 = pagedEditorRef.current?.getView();
|
|
16353
|
+
return view_31 ? getSuggestions(view_31.state) : [];
|
|
16381
16354
|
},
|
|
16382
16355
|
exportPendingSuggestions: () => {
|
|
16383
|
-
const
|
|
16384
|
-
const activeIds = new Set(
|
|
16356
|
+
const view_32 = pagedEditorRef.current?.getView();
|
|
16357
|
+
const activeIds = new Set(view_32 ? getSuggestions(view_32.state).map((s_3) => s_3.suggestionId) : []);
|
|
16385
16358
|
return pendingSuggestionRegistryRef.current.exportPendingSuggestions({
|
|
16386
16359
|
activeSuggestionIds: activeIds,
|
|
16387
|
-
snapshotForStory: (story_0, commentIds) => story_0.type === "main" &&
|
|
16360
|
+
snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_32 ? createPendingSuggestionSourceSnapshot(view_32.state, commentIds) : null
|
|
16388
16361
|
});
|
|
16389
16362
|
},
|
|
16390
16363
|
loadPendingSuggestions: (records) => pendingSuggestionRegistryRef.current.loadPendingSuggestions({
|
|
16391
16364
|
records,
|
|
16392
16365
|
snapshotForStory: (story_1) => {
|
|
16393
|
-
const
|
|
16394
|
-
return story_1.type === "main" &&
|
|
16366
|
+
const view_33 = pagedEditorRef.current?.getView();
|
|
16367
|
+
return story_1.type === "main" && view_33 ? createFolioAIEditSnapshot(view_33.state.doc) : null;
|
|
16395
16368
|
},
|
|
16396
16369
|
sourceSnapshotForStory: (story_2, commentIds_0) => {
|
|
16397
|
-
const
|
|
16398
|
-
return story_2.type === "main" &&
|
|
16370
|
+
const view_34 = pagedEditorRef.current?.getView();
|
|
16371
|
+
return story_2.type === "main" && view_34 ? createPendingSuggestionSourceSnapshot(view_34.state, commentIds_0) : null;
|
|
16399
16372
|
},
|
|
16400
16373
|
apply: (record, snapshot_6) => {
|
|
16401
|
-
const
|
|
16402
|
-
if (!
|
|
16374
|
+
const view_35 = pagedEditorRef.current?.getView();
|
|
16375
|
+
if (!view_35) return {
|
|
16403
16376
|
applied: [],
|
|
16404
16377
|
skipped: []
|
|
16405
16378
|
};
|
|
@@ -16417,7 +16390,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16417
16390
|
const createdComments_1 = [];
|
|
16418
16391
|
const result_4 = applyFolioDocumentOperations({
|
|
16419
16392
|
undefinedReferences: "refuse",
|
|
16420
|
-
view:
|
|
16393
|
+
view: view_35,
|
|
16421
16394
|
snapshot: snapshot_6,
|
|
16422
16395
|
batch: {
|
|
16423
16396
|
version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
|
|
@@ -16439,75 +16412,78 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16439
16412
|
};
|
|
16440
16413
|
},
|
|
16441
16414
|
activeSuggestionIds: () => {
|
|
16442
|
-
const
|
|
16443
|
-
return new Set(
|
|
16415
|
+
const view_36 = pagedEditorRef.current?.getView();
|
|
16416
|
+
return new Set(view_36 ? getSuggestions(view_36.state).map((s_4) => s_4.suggestionId) : []);
|
|
16444
16417
|
}
|
|
16445
16418
|
}),
|
|
16446
16419
|
acceptSuggestion: (suggestionId, options_4) => {
|
|
16447
|
-
const
|
|
16448
|
-
if (!
|
|
16420
|
+
const view_37 = pagedEditorRef.current?.getView();
|
|
16421
|
+
if (!view_37) return {
|
|
16449
16422
|
accepted: false,
|
|
16450
16423
|
appliedAs: null
|
|
16451
16424
|
};
|
|
16452
|
-
const appliedAs = getSuggestions(
|
|
16453
|
-
const
|
|
16425
|
+
const appliedAs = getSuggestions(view_37.state).find((s_5) => s_5.suggestionId === suggestionId)?.appliedAs ?? null;
|
|
16426
|
+
const editor_7 = pagedEditorRef.current?.getEditor();
|
|
16427
|
+
const accepted = editor_7?.getCanonicalDocument() ? editor_7.resolveCanonicalSuggestion(suggestionId, "accept", options_4?.author ?? author) : acceptSuggestion(suggestionId, { author: options_4?.author ?? author })(view_37.state, view_37.dispatch);
|
|
16454
16428
|
return {
|
|
16455
16429
|
accepted,
|
|
16456
16430
|
appliedAs: accepted ? appliedAs : null
|
|
16457
16431
|
};
|
|
16458
16432
|
},
|
|
16459
16433
|
rejectSuggestion: (suggestionId_0) => {
|
|
16460
|
-
const view_37 = pagedEditorRef.current?.getView();
|
|
16461
|
-
if (!view_37) return false;
|
|
16462
|
-
return rejectSuggestion(suggestionId_0)(view_37.state, view_37.dispatch);
|
|
16463
|
-
},
|
|
16464
|
-
scrollToSuggestion: (suggestionId_1) => {
|
|
16465
16434
|
const view_38 = pagedEditorRef.current?.getView();
|
|
16466
16435
|
if (!view_38) return false;
|
|
16467
|
-
const
|
|
16436
|
+
const editor_8 = pagedEditorRef.current?.getEditor();
|
|
16437
|
+
if (editor_8?.getCanonicalDocument()) return editor_8.resolveCanonicalSuggestion(suggestionId_0, "reject", author);
|
|
16438
|
+
return rejectSuggestion(suggestionId_0)(view_38.state, view_38.dispatch);
|
|
16439
|
+
},
|
|
16440
|
+
scrollToSuggestion: (suggestionId_1) => {
|
|
16441
|
+
const view_39 = pagedEditorRef.current?.getView();
|
|
16442
|
+
if (!view_39) return false;
|
|
16443
|
+
const range_4 = findSuggestionRange(view_39.state, suggestionId_1);
|
|
16468
16444
|
if (!range_4) return false;
|
|
16469
|
-
const { from: from_12, to: to_12 } = clampRangeToDocSize(
|
|
16470
|
-
const $from_3 =
|
|
16471
|
-
const $to_3 =
|
|
16472
|
-
|
|
16445
|
+
const { from: from_12, to: to_12 } = clampRangeToDocSize(view_39.state.doc.content.size, range_4);
|
|
16446
|
+
const $from_3 = view_39.state.doc.resolve(from_12);
|
|
16447
|
+
const $to_3 = view_39.state.doc.resolve(to_12);
|
|
16448
|
+
view_39.dispatch(view_39.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
|
|
16473
16449
|
requestAnimationFrame(() => {
|
|
16474
16450
|
pagedEditorRef.current?.scrollToPosition(from_12);
|
|
16475
16451
|
});
|
|
16476
16452
|
return true;
|
|
16477
16453
|
},
|
|
16478
16454
|
getTrackedChanges: () => {
|
|
16479
|
-
const
|
|
16480
|
-
return
|
|
16455
|
+
const view_40 = pagedEditorRef.current?.getView();
|
|
16456
|
+
return view_40 ? getTrackedChangesFromDoc(view_40.state.doc) : [];
|
|
16481
16457
|
},
|
|
16482
16458
|
getCommentAnchors: () => {
|
|
16483
|
-
const
|
|
16484
|
-
return
|
|
16459
|
+
const view_41 = pagedEditorRef.current?.getView();
|
|
16460
|
+
return view_41 ? getCommentAnchorsFromDoc(view_41.state.doc) : [];
|
|
16485
16461
|
},
|
|
16486
16462
|
getSelectionText: () => {
|
|
16487
|
-
const
|
|
16488
|
-
return
|
|
16463
|
+
const view_42 = pagedEditorRef.current?.getView();
|
|
16464
|
+
return view_42 ? getSelectedText(view_42.state) : "";
|
|
16489
16465
|
},
|
|
16490
16466
|
getPageText: (page_0) => {
|
|
16491
|
-
const
|
|
16492
|
-
if (!
|
|
16467
|
+
const view_43 = pagedEditorRef.current?.getView();
|
|
16468
|
+
if (!view_43) return null;
|
|
16493
16469
|
const layout_0 = pagedEditorRef.current?.getEditor()?.getLayout() ?? null;
|
|
16494
16470
|
return getPageTextFromLayout({
|
|
16495
16471
|
layout: layout_0,
|
|
16496
|
-
doc:
|
|
16472
|
+
doc: view_43.state.doc,
|
|
16497
16473
|
page: page_0,
|
|
16498
|
-
projection: projectMarkupView(
|
|
16474
|
+
projection: projectMarkupView(view_43.state, displayMode)
|
|
16499
16475
|
});
|
|
16500
16476
|
},
|
|
16501
16477
|
getTargetPage: (target_2, snapshot_7) => {
|
|
16502
|
-
const
|
|
16503
|
-
if (!
|
|
16478
|
+
const view_44 = pagedEditorRef.current?.getView();
|
|
16479
|
+
if (!view_44) return null;
|
|
16504
16480
|
const range_5 = target_2.type === "textRange" ? resolveFolioAITextRange({
|
|
16505
16481
|
range: target_2,
|
|
16506
|
-
doc:
|
|
16482
|
+
doc: view_44.state.doc,
|
|
16507
16483
|
snapshot: snapshot_7
|
|
16508
16484
|
}) : resolveFolioAIBlockRange({
|
|
16509
16485
|
blockId: target_2.blockId,
|
|
16510
|
-
doc:
|
|
16486
|
+
doc: view_44.state.doc,
|
|
16511
16487
|
snapshot: snapshot_7
|
|
16512
16488
|
});
|
|
16513
16489
|
if (range_5 === null) return null;
|
|
@@ -16518,49 +16494,49 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16518
16494
|
getScrollRoot: () => pagedEditorRef.current?.getScrollRoot() ?? null,
|
|
16519
16495
|
onLayoutChange: (listener) => pagedEditorRef.current?.onLayoutChange(listener) ?? (() => {}),
|
|
16520
16496
|
getContentControls: (filter = {}) => {
|
|
16521
|
-
const
|
|
16522
|
-
if (!
|
|
16523
|
-
return findBlockSdtMatches(
|
|
16497
|
+
const view_45 = pagedEditorRef.current?.getView();
|
|
16498
|
+
if (!view_45) return [];
|
|
16499
|
+
return findBlockSdtMatches(view_45.state.doc, filter).map((match_0) => ({
|
|
16524
16500
|
properties: blockSdtAttrsToSdtProperties(match_0.node),
|
|
16525
16501
|
path: match_0.path,
|
|
16526
16502
|
pmPos: match_0.pos
|
|
16527
16503
|
}));
|
|
16528
16504
|
},
|
|
16529
16505
|
scrollToContentControl: (filter_0) => {
|
|
16530
|
-
const
|
|
16531
|
-
if (!
|
|
16532
|
-
const match_1 = findBlockSdtMatch(
|
|
16506
|
+
const view_46 = pagedEditorRef.current?.getView();
|
|
16507
|
+
if (!view_46) return false;
|
|
16508
|
+
const match_1 = findBlockSdtMatch(view_46.state.doc, filter_0);
|
|
16533
16509
|
if (!match_1) return false;
|
|
16534
16510
|
const inside = match_1.pos + 1;
|
|
16535
|
-
const $pos =
|
|
16536
|
-
|
|
16511
|
+
const $pos = view_46.state.doc.resolve(inside);
|
|
16512
|
+
view_46.dispatch(view_46.state.tr.setSelection(TextSelection.near($pos)));
|
|
16537
16513
|
requestAnimationFrame(() => {
|
|
16538
16514
|
pagedEditorRef.current?.scrollToPosition(inside);
|
|
16539
16515
|
});
|
|
16540
16516
|
return true;
|
|
16541
16517
|
},
|
|
16542
16518
|
setContentControlContent: (filter_1, input, options_5 = {}) => {
|
|
16543
|
-
const
|
|
16544
|
-
if (!
|
|
16545
|
-
const tr_0 = typeof input === "string" ? setContentControlContentTr(
|
|
16519
|
+
const view_47 = pagedEditorRef.current?.getView();
|
|
16520
|
+
if (!view_47) return false;
|
|
16521
|
+
const tr_0 = typeof input === "string" ? setContentControlContentTr(view_47.state, filter_1, input, options_5) : setContentControlContentBlocksTr(view_47.state, filter_1, input, options_5);
|
|
16546
16522
|
if (!tr_0) return false;
|
|
16547
|
-
|
|
16523
|
+
view_47.dispatch(tr_0);
|
|
16548
16524
|
return true;
|
|
16549
16525
|
},
|
|
16550
16526
|
setContentControlValue: (filter_2, input_0, options_6 = {}) => {
|
|
16551
|
-
const
|
|
16552
|
-
if (!
|
|
16553
|
-
const tr_1 = setContentControlValueTr(
|
|
16527
|
+
const view_48 = pagedEditorRef.current?.getView();
|
|
16528
|
+
if (!view_48) return false;
|
|
16529
|
+
const tr_1 = setContentControlValueTr(view_48.state, filter_2, input_0, options_6);
|
|
16554
16530
|
if (!tr_1) return false;
|
|
16555
|
-
|
|
16531
|
+
view_48.dispatch(tr_1);
|
|
16556
16532
|
return true;
|
|
16557
16533
|
},
|
|
16558
16534
|
removeContentControl: (filter_3, options_7 = {}) => {
|
|
16559
|
-
const
|
|
16560
|
-
if (!
|
|
16561
|
-
const tr_2 = removeContentControlTr(
|
|
16535
|
+
const view_49 = pagedEditorRef.current?.getView();
|
|
16536
|
+
if (!view_49) return false;
|
|
16537
|
+
const tr_2 = removeContentControlTr(view_49.state, filter_3, options_7);
|
|
16562
16538
|
if (!tr_2) return false;
|
|
16563
|
-
|
|
16539
|
+
view_49.dispatch(tr_2);
|
|
16564
16540
|
return true;
|
|
16565
16541
|
}
|
|
16566
16542
|
}), [
|
|
@@ -16653,47 +16629,47 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16653
16629
|
if (isDisplayMode(value)) setDisplayMode(value);
|
|
16654
16630
|
}, [setDisplayMode]);
|
|
16655
16631
|
const handleAcceptActiveChange = useCallback(() => {
|
|
16656
|
-
const
|
|
16657
|
-
if (!
|
|
16658
|
-
const { from: from_13, to: to_13 } =
|
|
16659
|
-
const range_6 = findChangeAtPosition(
|
|
16632
|
+
const view_50 = pagedEditorRef.current?.getView();
|
|
16633
|
+
if (!view_50) return;
|
|
16634
|
+
const { from: from_13, to: to_13 } = view_50.state.selection;
|
|
16635
|
+
const range_6 = findChangeAtPosition(view_50.state, from_13, to_13);
|
|
16660
16636
|
if (resolveCanonicalReviewRange({
|
|
16661
16637
|
editor: pagedEditorRef.current?.getEditor(),
|
|
16662
16638
|
...range_6,
|
|
16663
16639
|
resolution: "accept"
|
|
16664
|
-
}) === null) acceptChange(range_6.from, range_6.to)(
|
|
16640
|
+
}) === null) acceptChange(range_6.from, range_6.to)(view_50.state, view_50.dispatch);
|
|
16665
16641
|
}, []);
|
|
16666
16642
|
const handleRejectActiveChange = useCallback(() => {
|
|
16667
|
-
const
|
|
16668
|
-
if (!
|
|
16669
|
-
const { from: from_14, to: to_14 } =
|
|
16670
|
-
const range_7 = findChangeAtPosition(
|
|
16643
|
+
const view_51 = pagedEditorRef.current?.getView();
|
|
16644
|
+
if (!view_51) return;
|
|
16645
|
+
const { from: from_14, to: to_14 } = view_51.state.selection;
|
|
16646
|
+
const range_7 = findChangeAtPosition(view_51.state, from_14, to_14);
|
|
16671
16647
|
if (resolveCanonicalReviewRange({
|
|
16672
16648
|
editor: pagedEditorRef.current?.getEditor(),
|
|
16673
16649
|
...range_7,
|
|
16674
16650
|
resolution: "reject"
|
|
16675
|
-
}) === null) rejectChange(range_7.from, range_7.to)(
|
|
16651
|
+
}) === null) rejectChange(range_7.from, range_7.to)(view_51.state, view_51.dispatch);
|
|
16676
16652
|
}, []);
|
|
16677
16653
|
const handlePreviousChange = useCallback(() => {
|
|
16678
|
-
const
|
|
16679
|
-
if (!
|
|
16680
|
-
const { from: from_15 } =
|
|
16681
|
-
const change = findPreviousChange(
|
|
16654
|
+
const view_52 = pagedEditorRef.current?.getView();
|
|
16655
|
+
if (!view_52) return;
|
|
16656
|
+
const { from: from_15 } = view_52.state.selection;
|
|
16657
|
+
const change = findPreviousChange(view_52.state, from_15);
|
|
16682
16658
|
if (!change) return;
|
|
16683
|
-
|
|
16684
|
-
|
|
16659
|
+
view_52.dispatch(view_52.state.tr.setSelection(TextSelection.create(view_52.state.doc, change.from, change.to)));
|
|
16660
|
+
view_52.focus();
|
|
16685
16661
|
requestAnimationFrame(() => {
|
|
16686
16662
|
pagedEditorRef.current?.scrollToPosition(change.from);
|
|
16687
16663
|
});
|
|
16688
16664
|
}, []);
|
|
16689
16665
|
const handleNextChange = useCallback(() => {
|
|
16690
|
-
const
|
|
16691
|
-
if (!
|
|
16692
|
-
const { to: to_15 } =
|
|
16693
|
-
const change_0 = findNextChange(
|
|
16666
|
+
const view_53 = pagedEditorRef.current?.getView();
|
|
16667
|
+
if (!view_53) return;
|
|
16668
|
+
const { to: to_15 } = view_53.state.selection;
|
|
16669
|
+
const change_0 = findNextChange(view_53.state, to_15);
|
|
16694
16670
|
if (!change_0) return;
|
|
16695
|
-
|
|
16696
|
-
|
|
16671
|
+
view_53.dispatch(view_53.state.tr.setSelection(TextSelection.create(view_53.state.doc, change_0.from, change_0.to)));
|
|
16672
|
+
view_53.focus();
|
|
16697
16673
|
requestAnimationFrame(() => {
|
|
16698
16674
|
pagedEditorRef.current?.scrollToPosition(change_0.from);
|
|
16699
16675
|
});
|
|
@@ -16805,15 +16781,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16805
16781
|
}),
|
|
16806
16782
|
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
16807
16783
|
onClick: handleAcceptActiveChange,
|
|
16808
|
-
disabled: readOnly || !state.activeTrackedChange,
|
|
16809
|
-
title: t("acceptChange"),
|
|
16784
|
+
disabled: readOnly || !state.activeTrackedChange || state.activeTrackedChange.heldByLock.accept,
|
|
16785
|
+
title: state.activeTrackedChange?.heldByLock.accept ? t("trackedChanges.heldByLock") : t("acceptChange"),
|
|
16810
16786
|
ariaLabel: t("acceptChange"),
|
|
16811
16787
|
children: /* @__PURE__ */ jsx(CheckIcon, { size: 16 })
|
|
16812
16788
|
}),
|
|
16813
16789
|
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
16814
16790
|
onClick: handleRejectActiveChange,
|
|
16815
|
-
disabled: readOnly || !state.activeTrackedChange,
|
|
16816
|
-
title: t("rejectChange"),
|
|
16791
|
+
disabled: readOnly || !state.activeTrackedChange || state.activeTrackedChange.heldByLock.reject,
|
|
16792
|
+
title: state.activeTrackedChange?.heldByLock.reject ? t("trackedChanges.heldByLock") : t("rejectChange"),
|
|
16817
16793
|
ariaLabel: t("rejectChange"),
|
|
16818
16794
|
children: /* @__PURE__ */ jsx(XIcon, { size: 16 })
|
|
16819
16795
|
}),
|
|
@@ -16863,8 +16839,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16863
16839
|
requestAnimationFrame(syncCommentHighlightStyles);
|
|
16864
16840
|
}, [onScrollTopChange, syncCommentHighlightStyles]);
|
|
16865
16841
|
const handlePagedSelectionChange = useCallback((_from, _to) => {
|
|
16866
|
-
const
|
|
16867
|
-
handleSelectionChange(
|
|
16842
|
+
const view_54 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
|
|
16843
|
+
handleSelectionChange(view_54 ? extractSelectionState(view_54.state) : null);
|
|
16868
16844
|
}, [getActiveEditorView, handleSelectionChange]);
|
|
16869
16845
|
const handleTotalPagesChange = useCallback((totalPages) => {
|
|
16870
16846
|
setScrollPageInfo((previous_0) => updateScrollPageTotal(previous_0, totalPages));
|
|
@@ -16876,11 +16852,20 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16876
16852
|
id: id_1,
|
|
16877
16853
|
status: "resolved"
|
|
16878
16854
|
}) !== null) return;
|
|
16855
|
+
if (readOnly) {
|
|
16856
|
+
notifyReadonlyEditAttempt();
|
|
16857
|
+
return;
|
|
16858
|
+
}
|
|
16879
16859
|
updateComments((previous_1) => previous_1.map((comment_2) => comment_2.id === id_1 ? {
|
|
16880
16860
|
...comment_2,
|
|
16881
16861
|
done: true
|
|
16882
16862
|
} : comment_2));
|
|
16883
|
-
}, [
|
|
16863
|
+
}, [
|
|
16864
|
+
applyCanonicalComment,
|
|
16865
|
+
notifyReadonlyEditAttempt,
|
|
16866
|
+
readOnly,
|
|
16867
|
+
updateComments
|
|
16868
|
+
]);
|
|
16884
16869
|
const handleCommentDelete = useCallback((id_2) => {
|
|
16885
16870
|
const result_5 = applyCanonicalComment({
|
|
16886
16871
|
type: "delete",
|
|
@@ -16890,11 +16875,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16890
16875
|
if (result_5.status === "applied" && activeCommentId === id_2) setActiveCommentId(null);
|
|
16891
16876
|
return;
|
|
16892
16877
|
}
|
|
16878
|
+
if (readOnly) {
|
|
16879
|
+
notifyReadonlyEditAttempt();
|
|
16880
|
+
return;
|
|
16881
|
+
}
|
|
16893
16882
|
updateComments((previous_2) => previous_2.filter((comment_3) => comment_3.id !== id_2 && comment_3.parentId !== id_2));
|
|
16894
16883
|
if (activeCommentId === id_2) setActiveCommentId(null);
|
|
16895
16884
|
}, [
|
|
16896
16885
|
activeCommentId,
|
|
16897
16886
|
applyCanonicalComment,
|
|
16887
|
+
notifyReadonlyEditAttempt,
|
|
16888
|
+
readOnly,
|
|
16898
16889
|
setActiveCommentId,
|
|
16899
16890
|
updateComments
|
|
16900
16891
|
]);
|
|
@@ -16908,16 +16899,22 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16908
16899
|
parentId: id_3
|
|
16909
16900
|
}
|
|
16910
16901
|
}) !== null) return;
|
|
16902
|
+
if (readOnly) {
|
|
16903
|
+
notifyReadonlyEditAttempt();
|
|
16904
|
+
return;
|
|
16905
|
+
}
|
|
16911
16906
|
updateComments((previous_3) => [...previous_3, createComment(text_6, author, id_3)]);
|
|
16912
16907
|
}, [
|
|
16913
16908
|
applyCanonicalComment,
|
|
16914
16909
|
author,
|
|
16915
16910
|
createComment,
|
|
16911
|
+
notifyReadonlyEditAttempt,
|
|
16912
|
+
readOnly,
|
|
16916
16913
|
updateComments
|
|
16917
16914
|
]);
|
|
16918
16915
|
const handleAddComment = useCallback((addText) => {
|
|
16919
|
-
const
|
|
16920
|
-
if (!
|
|
16916
|
+
const view_55 = pagedEditorRef.current?.getView();
|
|
16917
|
+
if (!view_55 || !commentSelectionRange) return false;
|
|
16921
16918
|
const result_6 = applyCanonicalComment({
|
|
16922
16919
|
type: "create",
|
|
16923
16920
|
text: addText,
|
|
@@ -16930,9 +16927,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16930
16927
|
});
|
|
16931
16928
|
if (result_6 !== null) {
|
|
16932
16929
|
if (result_6?.status !== "applied") return false;
|
|
16933
|
-
setVisibleCommentAuthors((
|
|
16934
|
-
if (
|
|
16935
|
-
const next_1 = new Set(
|
|
16930
|
+
setVisibleCommentAuthors((current_1) => {
|
|
16931
|
+
if (current_1 === null) return null;
|
|
16932
|
+
const next_1 = new Set(current_1);
|
|
16936
16933
|
const created = result_6.comments.find(({ id: id_4 }) => id_4 === result_6.commentId);
|
|
16937
16934
|
if (created) next_1.add(getCommentAuthorKey(created.author));
|
|
16938
16935
|
return next_1;
|
|
@@ -16943,12 +16940,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16943
16940
|
setAddCommentYPosition(null);
|
|
16944
16941
|
return true;
|
|
16945
16942
|
}
|
|
16943
|
+
if (readOnly) {
|
|
16944
|
+
notifyReadonlyEditAttempt();
|
|
16945
|
+
return false;
|
|
16946
|
+
}
|
|
16946
16947
|
const comment_4 = createComment(addText, author);
|
|
16947
|
-
if (!applyCommentMarkRange(
|
|
16948
|
+
if (!applyCommentMarkRange(view_55, commentSelectionRange, comment_4.id, { replacePending: true })) return false;
|
|
16948
16949
|
const commentAuthor_2 = getCommentAuthorKey(comment_4.author);
|
|
16949
|
-
setVisibleCommentAuthors((
|
|
16950
|
-
if (
|
|
16951
|
-
const next_2 = new Set(
|
|
16950
|
+
setVisibleCommentAuthors((current_2) => {
|
|
16951
|
+
if (current_2 === null) return null;
|
|
16952
|
+
const next_2 = new Set(current_2);
|
|
16952
16953
|
next_2.add(commentAuthor_2);
|
|
16953
16954
|
return next_2;
|
|
16954
16955
|
});
|
|
@@ -16968,6 +16969,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16968
16969
|
applyCanonicalComment,
|
|
16969
16970
|
commentSelectionRange,
|
|
16970
16971
|
createComment,
|
|
16972
|
+
notifyReadonlyEditAttempt,
|
|
16973
|
+
readOnly,
|
|
16971
16974
|
setActiveCommentId,
|
|
16972
16975
|
setAddCommentYPosition,
|
|
16973
16976
|
setCommentSelectionRange,
|
|
@@ -16987,16 +16990,22 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16987
16990
|
revisionId: revisionId_2
|
|
16988
16991
|
}
|
|
16989
16992
|
}) !== null) return;
|
|
16993
|
+
if (readOnly) {
|
|
16994
|
+
notifyReadonlyEditAttempt();
|
|
16995
|
+
return;
|
|
16996
|
+
}
|
|
16990
16997
|
updateComments((previous_5) => [...previous_5, createComment(text_7, author, revisionId_2)]);
|
|
16991
16998
|
}, [
|
|
16992
16999
|
applyCanonicalComment,
|
|
16993
17000
|
author,
|
|
16994
17001
|
createComment,
|
|
17002
|
+
notifyReadonlyEditAttempt,
|
|
17003
|
+
readOnly,
|
|
16995
17004
|
updateComments
|
|
16996
17005
|
]);
|
|
16997
17006
|
const handleCancelAddComment = useCallback(() => {
|
|
16998
|
-
const
|
|
16999
|
-
if (
|
|
17007
|
+
const view_56 = pagedEditorRef.current?.getView();
|
|
17008
|
+
if (view_56 && commentSelectionRange && commentDraftMode === "prosemirror") removePendingCommentMarkRange(view_56, commentSelectionRange);
|
|
17000
17009
|
setIsAddingComment(false);
|
|
17001
17010
|
setCommentSelectionRange(null);
|
|
17002
17011
|
setAddCommentYPosition(null);
|
|
@@ -17013,23 +17022,23 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17013
17022
|
})?.revisionId ?? null;
|
|
17014
17023
|
}, []);
|
|
17015
17024
|
const handleSidebarAcceptChange = useCallback((from_17, to_17) => {
|
|
17016
|
-
const
|
|
17017
|
-
if (!
|
|
17025
|
+
const view_57 = pagedEditorRef.current?.getView();
|
|
17026
|
+
if (!view_57) return;
|
|
17018
17027
|
const revisionId_3 = resolveSidebarChangeRevisionId(from_17, to_17);
|
|
17019
17028
|
if (revisionId_3 === null) return;
|
|
17020
|
-
const
|
|
17021
|
-
if (
|
|
17022
|
-
else acceptAIEditRevision(revisionId_3)(
|
|
17029
|
+
const editor_9 = pagedEditorRef.current?.getEditor();
|
|
17030
|
+
if (editor_9?.getCanonicalDocument()) editor_9.resolveCanonicalRevisions([revisionId_3], "accept");
|
|
17031
|
+
else acceptAIEditRevision(revisionId_3)(view_57.state, view_57.dispatch);
|
|
17023
17032
|
extractTrackedChanges();
|
|
17024
17033
|
}, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
|
|
17025
17034
|
const handleSidebarRejectChange = useCallback((from_18, to_18) => {
|
|
17026
|
-
const
|
|
17027
|
-
if (!
|
|
17035
|
+
const view_58 = pagedEditorRef.current?.getView();
|
|
17036
|
+
if (!view_58) return;
|
|
17028
17037
|
const revisionId_4 = resolveSidebarChangeRevisionId(from_18, to_18);
|
|
17029
17038
|
if (revisionId_4 === null) return;
|
|
17030
|
-
const
|
|
17031
|
-
if (
|
|
17032
|
-
else rejectAIEditRevision(revisionId_4)(
|
|
17039
|
+
const editor_10 = pagedEditorRef.current?.getEditor();
|
|
17040
|
+
if (editor_10?.getCanonicalDocument()) editor_10.resolveCanonicalRevisions([revisionId_4], "reject");
|
|
17041
|
+
else rejectAIEditRevision(revisionId_4)(view_58.state, view_58.dispatch);
|
|
17033
17042
|
extractTrackedChanges();
|
|
17034
17043
|
}, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
|
|
17035
17044
|
const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
|
|
@@ -17179,8 +17188,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17179
17188
|
}, [readOnly]);
|
|
17180
17189
|
const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
|
|
17181
17190
|
const applyTableProperties = useCallback((props_0) => {
|
|
17182
|
-
const
|
|
17183
|
-
if (
|
|
17191
|
+
const view_59 = getActiveEditorView();
|
|
17192
|
+
if (view_59) setTableProperties(props_0)(view_59.state, view_59.dispatch);
|
|
17184
17193
|
}, [getActiveEditorView]);
|
|
17185
17194
|
const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
|
|
17186
17195
|
const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
|
|
@@ -17188,8 +17197,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17188
17197
|
const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
|
|
17189
17198
|
const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
|
|
17190
17199
|
const insertSymbol = useCallback((symbol) => {
|
|
17191
|
-
const
|
|
17192
|
-
if (
|
|
17200
|
+
const view_60 = getActiveEditorView();
|
|
17201
|
+
if (view_60) view_60.dispatch(view_60.state.tr.insertText(symbol).scrollIntoView());
|
|
17193
17202
|
}, [getActiveEditorView]);
|
|
17194
17203
|
const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
|
|
17195
17204
|
const { close: closeFindDialog } = findReplace;
|
|
@@ -17280,8 +17289,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17280
17289
|
]);
|
|
17281
17290
|
const closeNumberingValueDialog = useCallback(() => setNumberingValueDialogOpen(false), []);
|
|
17282
17291
|
const applyNumberingValue = useCallback((value_0) => {
|
|
17283
|
-
const
|
|
17284
|
-
if (
|
|
17292
|
+
const view_61 = getActiveEditorView();
|
|
17293
|
+
if (view_61) setNumberingValue(value_0)(view_61.state, view_61.dispatch);
|
|
17285
17294
|
}, [getActiveEditorView]);
|
|
17286
17295
|
const numberingValueDialog = useMemo(() => ({
|
|
17287
17296
|
isOpen: numberingValueDialogOpen,
|
|
@@ -17524,6 +17533,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17524
17533
|
documentIdentity: loadedDocumentIdentity,
|
|
17525
17534
|
markupView: displayMode,
|
|
17526
17535
|
showCommentHighlights,
|
|
17536
|
+
altChunkMarkerText: t("contentNotDisplayed"),
|
|
17527
17537
|
...fonts !== void 0 ? { fonts } : {},
|
|
17528
17538
|
theme: history.state.package.theme || theme || null,
|
|
17529
17539
|
sectionProperties: effectiveSectionProperties ?? null,
|
|
@@ -17580,11 +17590,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17580
17590
|
delayMs: 300,
|
|
17581
17591
|
children: /* @__PURE__ */ jsx("button", {
|
|
17582
17592
|
type: "button",
|
|
17593
|
+
"aria-label": "Add comment",
|
|
17583
17594
|
onMouseDown: (e_1) => {
|
|
17584
17595
|
e_1.preventDefault();
|
|
17585
17596
|
e_1.stopPropagation();
|
|
17586
|
-
const
|
|
17587
|
-
if (!
|
|
17597
|
+
const view_62 = pagedEditorRef.current?.getView();
|
|
17598
|
+
if (!view_62) {
|
|
17588
17599
|
setFloatingCommentBtn(null);
|
|
17589
17600
|
return;
|
|
17590
17601
|
}
|
|
@@ -17592,9 +17603,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17592
17603
|
from: floatingCommentBtn.from,
|
|
17593
17604
|
to: floatingCommentBtn.to
|
|
17594
17605
|
};
|
|
17595
|
-
const currentSelection =
|
|
17606
|
+
const currentSelection = view_62.state.selection;
|
|
17596
17607
|
const safeRange = resolveCommentCreationRange({
|
|
17597
|
-
docSize:
|
|
17608
|
+
docSize: view_62.state.doc.content.size,
|
|
17598
17609
|
capturedRange,
|
|
17599
17610
|
currentRange: {
|
|
17600
17611
|
from: currentSelection.from,
|
|
@@ -17609,7 +17620,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17609
17620
|
}
|
|
17610
17621
|
setCommentSelectionRange(safeRange);
|
|
17611
17622
|
if (commentDraftMode === "prosemirror") {
|
|
17612
|
-
if (!applyCommentMarkRange(
|
|
17623
|
+
if (!applyCommentMarkRange(view_62, safeRange, -1, { selectEnd: true })) {
|
|
17613
17624
|
setCommentSelectionRange(null);
|
|
17614
17625
|
setFloatingCommentBtn(null);
|
|
17615
17626
|
return;
|