@stll/folio-react 0.33.1 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CommentsSidebar-CUCUQpXb.js → CommentsSidebar-myF8qhju.js} +1 -1
- package/dist/{TextContextMenu-BxnNvhJg.js → TextContextMenu-jOBgICwD.js} +110 -97
- package/dist/compat/eigenpal.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{renderAsync-Bvosattm.js → renderAsync-k1iPk-aX.js} +1206 -1199
- 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,12 @@ 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
32
|
import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pastePlainTextSlice } from "@stll/folio-core/prosemirror/commands/pastePlainText";
|
|
33
|
+
import { clearPendingComment, commentIdsNamedIn, commentRecordsOf, commentThreadIds, commitCommentThread, deleteCommentThread, editCommentRecords, markPendingComment, recordingCommentsView, subscribeCommentRecords, syncCommentRecords } from "@stll/folio-core/prosemirror/commentRecords";
|
|
33
34
|
import { proseDocToBlocks } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
|
|
34
35
|
import { executeEditorCommand, executeFirstEditorCommand } from "@stll/folio-core/prosemirror/executeEditorCommand";
|
|
35
36
|
import { ExtensionManager } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
|
|
@@ -46,7 +47,7 @@ import { createTemplateDirectivesPlugin, templateDirectivesKey } from "@stll/fol
|
|
|
46
47
|
import { createTemplatePreviewValuesPlugin, templatePreviewValuesKey } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
|
|
47
48
|
import { getTemplateSlashMenu, templateSlashMenuPlugin } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
|
|
48
49
|
import { getFolioParaIdFromBlockId } from "@stll/folio-core/types/block-id";
|
|
49
|
-
import { CANONICAL_GAP, canonicalRefusalMessage, usesCanonicalSession } from "@stll/folio-core/types/canonicalCapabilities";
|
|
50
|
+
import { CANONICAL_GAP, canonicalRefusalMessage, canonicalRefusalNotice, usesCanonicalSession } from "@stll/folio-core/types/canonicalCapabilities";
|
|
50
51
|
import { canonicalJson } from "@stll/folio-core/utils/canonicalJson";
|
|
51
52
|
import { resolveColor } from "@stll/folio-core/utils/colorResolver";
|
|
52
53
|
import { closestHtmlElement, htmlQueryAll, queryHtmlElement } from "@stll/folio-core/utils/domGuards";
|
|
@@ -54,6 +55,7 @@ import { onFontsLoaded } from "@stll/folio-core/utils/fontLoader";
|
|
|
54
55
|
import { collectHeadings } from "@stll/folio-core/utils/headingCollector";
|
|
55
56
|
import { DEFAULT_OUTLINE_DEPTH, filterHeadingsByDepth } from "@stll/folio-core/utils/outlineDepth";
|
|
56
57
|
import { resolveOutlineHeadings } from "@stll/folio-core/utils/outlineHeadings";
|
|
58
|
+
import { PAINTED_START_SELECTOR, hasPaintedStart, paintedStartSelector, readPaintedEnd, readPaintedStart, readPaintedTableStart } from "@stll/folio-core/utils/paintedPositions";
|
|
57
59
|
import { readBlobText } from "@stll/folio-core/utils/textEncoding";
|
|
58
60
|
import { formatPx, pixelsToTwips, pointsToHalfPoints, twipsToPixels as twipsToPixels$1 } from "@stll/folio-core/utils/units";
|
|
59
61
|
import { HistoryManager, classifyHistoryShortcut } from "@stll/folio-core/managers/HistoryManager";
|
|
@@ -61,7 +63,7 @@ import { TableSelectionManager } from "@stll/folio-core/managers/TableSelectionM
|
|
|
61
63
|
import { ZOOM_MAX, ZOOM_MIN, ZOOM_STEP } from "@stll/folio-core/utils/zoom";
|
|
62
64
|
import { createPortal } from "react-dom";
|
|
63
65
|
import { panic } from "better-result";
|
|
64
|
-
import { NodeSelection,
|
|
66
|
+
import { NodeSelection, TextSelection as TextSelection$1 } from "prosemirror-state";
|
|
65
67
|
import { CellSelection } from "prosemirror-tables";
|
|
66
68
|
import { createFolioAIEditSnapshot as createFolioAIEditSnapshot$1 } from "@stll/folio-core/ai-edits/snapshot";
|
|
67
69
|
import { createFolioEditorEmitter } from "@stll/folio-core/controller/folioEditorEvents";
|
|
@@ -79,7 +81,7 @@ import { templatePreviewDirtyRange } from "@stll/folio-core/layout-bridge/conver
|
|
|
79
81
|
import { clickToPositionDom, getCaretPositionFromDom, getSelectionRectsFromDom } from "@stll/folio-core/layout-bridge/dom/clickToPositionDom";
|
|
80
82
|
import { findBodyPmAnchor, findBodyPmAnchors, findBodyPmSpans } from "@stll/folio-core/layout-bridge/dom/findBodyPmSpans";
|
|
81
83
|
import { clickToPositionInHfSlot, findHfSlotForTarget, findHfSlotKindForTarget } from "@stll/folio-core/layout-bridge/dom/findHfPmSpans";
|
|
82
|
-
import { resetImeCaretAnchor, syncImeCaretAnchor } from "@stll/folio-core/layout-bridge/dom/imeCaretAnchor";
|
|
84
|
+
import { HIDDEN_EDITOR_WRAPPER_CLASS, resetImeCaretAnchor, syncImeCaretAnchor } from "@stll/folio-core/layout-bridge/dom/imeCaretAnchor";
|
|
83
85
|
import { findNoteStoryForTarget } from "@stll/folio-core/layout-bridge/dom/noteStoryDom";
|
|
84
86
|
import { measurePaintedSpanRange } from "@stll/folio-core/layout-bridge/dom/textStreamDom";
|
|
85
87
|
import { clickToPosition } from "@stll/folio-core/layout-bridge/engine/clickToPosition";
|
|
@@ -96,10 +98,11 @@ import { collectRunFontsAtPmPositions, measureDirectiveGutter, projectRangesToRe
|
|
|
96
98
|
import { isReadOnlyEditKey } from "@stll/folio-core/paged-layout/readOnlyEditAttempt";
|
|
97
99
|
import { getPageScrollTarget } from "@stll/folio-core/paged-layout/scrollNavigation";
|
|
98
100
|
import { PAGES_CONTAINER_CLASS, scrollPagesToPmPosition } from "@stll/folio-core/paged-layout/scrollToPmPosition";
|
|
101
|
+
import { FOLIO_INPUT_HIDDEN_ATTRIBUTE } from "@stll/folio-core/paged-layout/selectionViewportRect";
|
|
99
102
|
import { resizeColumnPair } from "@stll/folio-core/paged-layout/tableColumnResize";
|
|
100
103
|
import { tableInsertButtonOffset } from "@stll/folio-core/paged-layout/tableInsertButtonGeometry";
|
|
101
104
|
import { commitImageFloatMove, commitImageInlineMove, commitImageResize, isFloatingImage } from "@stll/folio-core/prosemirror/imageCommit";
|
|
102
|
-
import { MIN_ROW_HEIGHT_TWIPS, clampRowResizeDelta,
|
|
105
|
+
import { MIN_ROW_HEIGHT_TWIPS, clampRowResizeDelta, columnResizeCommand, rightEdgeResizeCommand, rowResizeCommand } from "@stll/folio-core/prosemirror/tableResize";
|
|
103
106
|
import { dispatchEditorTextInput } from "@stll/folio-core/prosemirror/textInput";
|
|
104
107
|
import { findStartPosForParaId } from "@stll/folio-core/prosemirror/utils/findParagraphByParaId";
|
|
105
108
|
import { resolveHeaderFooterSelectionGeometry } from "@stll/folio-core/render-dom/HeaderFooterSelectionOverlay";
|
|
@@ -136,6 +139,81 @@ import { onDocumentPointerDown } from "@stll/folio-core/utils/documentPointerDow
|
|
|
136
139
|
import { COMMENT_ANCHOR_SELECTOR, commentAnchorIds } from "@stll/folio-core/render-dom/commentAnchorAttributes";
|
|
137
140
|
import { isValidHexId } from "@stll/folio-core/utils/hexId";
|
|
138
141
|
import { createRoot } from "react-dom/client";
|
|
142
|
+
// src/hooks/keepEqual.ts
|
|
143
|
+
/**
|
|
144
|
+
* State the editor host writes while the user types: caret and selection
|
|
145
|
+
* geometry, overlay rectangles, toolbar formatting. Most writes carry a value
|
|
146
|
+
* equal to the one already held (another empty rectangle list, the same
|
|
147
|
+
* caret), and every React commit with the editor focused reads the editor's
|
|
148
|
+
* whole DOM to save the selection. A write that changes nothing must not
|
|
149
|
+
* commit, so these states keep the value they hold when the next one is
|
|
150
|
+
* equal to it.
|
|
151
|
+
*/
|
|
152
|
+
const isPlainObject = (value) => {
|
|
153
|
+
const prototype = Object.getPrototypeOf(value);
|
|
154
|
+
return prototype === Object.prototype || prototype === null;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Whether two values hold the same data: primitives by `Object.is`, arrays,
|
|
158
|
+
* maps, sets and plain objects by their contents. Other objects (DOM nodes,
|
|
159
|
+
* class instances, functions) only when they are the same object.
|
|
160
|
+
*/
|
|
161
|
+
const structurallyEqual = (left, right) => {
|
|
162
|
+
if (Object.is(left, right)) return true;
|
|
163
|
+
if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
|
|
164
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
165
|
+
if (!Array.isArray(left) || !Array.isArray(right)) return false;
|
|
166
|
+
return left.length === right.length && left.every((item, index) => structurallyEqual(item, right[index]));
|
|
167
|
+
}
|
|
168
|
+
if (left instanceof Map || right instanceof Map) {
|
|
169
|
+
if (!(left instanceof Map) || !(right instanceof Map)) return false;
|
|
170
|
+
if (left.size !== right.size) return false;
|
|
171
|
+
for (const [key, value] of left) if (!right.has(key) || !structurallyEqual(value, right.get(key))) return false;
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
if (left instanceof Set || right instanceof Set) {
|
|
175
|
+
if (!(left instanceof Set) || !(right instanceof Set)) return false;
|
|
176
|
+
if (left.size !== right.size) return false;
|
|
177
|
+
for (const value of left) if (!right.has(value)) return false;
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
if (!isPlainObject(left) || !isPlainObject(right)) return false;
|
|
181
|
+
const leftKeys = Object.keys(left);
|
|
182
|
+
const rightKeys = Object.keys(right);
|
|
183
|
+
return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.hasOwn(right, key) && structurallyEqual(Reflect.get(left, key), Reflect.get(right, key)));
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* The next value of a state that keeps its current value when the next one
|
|
187
|
+
* is equal to it,
|
|
188
|
+
* so an unchanged write never re-renders or commits.
|
|
189
|
+
*/
|
|
190
|
+
function keepEqual(previous, next) {
|
|
191
|
+
const resolved = typeof next === "function" ? next(previous) : next;
|
|
192
|
+
return structurallyEqual(previous, resolved) ? previous : resolved;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* `useState` for state the editor host writes while the user types: the
|
|
196
|
+
* setter keeps the current value when the next one is equal to it. The
|
|
197
|
+
* update runs through React's own state queue, which drops an unchanged
|
|
198
|
+
* value before it schedules a render.
|
|
199
|
+
*/
|
|
200
|
+
function useEqualState(initial) {
|
|
201
|
+
const $ = c(3);
|
|
202
|
+
const [value, setValue] = useState(initial);
|
|
203
|
+
let t0;
|
|
204
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
205
|
+
t0 = (next) => setValue((previous) => keepEqual(previous, next));
|
|
206
|
+
$[0] = t0;
|
|
207
|
+
} else t0 = $[0];
|
|
208
|
+
const setIfChanged = t0;
|
|
209
|
+
let t1;
|
|
210
|
+
if ($[1] !== value) {
|
|
211
|
+
t1 = [value, setIfChanged];
|
|
212
|
+
$[1] = value;
|
|
213
|
+
$[2] = t1;
|
|
214
|
+
} else t1 = $[2];
|
|
215
|
+
return t1;
|
|
216
|
+
}
|
|
139
217
|
// src/hooks/useHistory.ts
|
|
140
218
|
/**
|
|
141
219
|
* History hook for undo/redo functionality
|
|
@@ -242,7 +320,7 @@ function useDocumentHistory(document, t0) {
|
|
|
242
320
|
$[1] = t1;
|
|
243
321
|
} else t1 = $[1];
|
|
244
322
|
const options = t1;
|
|
245
|
-
const isEqual = _temp$
|
|
323
|
+
const isEqual = _temp$16;
|
|
246
324
|
let t2;
|
|
247
325
|
if ($[2] !== options) {
|
|
248
326
|
t2 = {
|
|
@@ -254,7 +332,7 @@ function useDocumentHistory(document, t0) {
|
|
|
254
332
|
} else t2 = $[3];
|
|
255
333
|
return useHistory(document, t2);
|
|
256
334
|
}
|
|
257
|
-
function _temp$
|
|
335
|
+
function _temp$16(a, b) {
|
|
258
336
|
if (a === b) return true;
|
|
259
337
|
const aPackage = a?.package;
|
|
260
338
|
const bPackage = b?.package;
|
|
@@ -604,7 +682,7 @@ const HOST_STYLES = {
|
|
|
604
682
|
zIndex: -1,
|
|
605
683
|
pointerEvents: "none"
|
|
606
684
|
};
|
|
607
|
-
const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, readOnly, styles, theme, onTransaction, experimentalSession, getCanonicalApi, onSessionRefusal }, ref) {
|
|
685
|
+
const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, readOnly, styles, theme, onTransaction, experimentalSession, getCanonicalApi, readCanonicalDocument, onSessionRefusal }, ref) {
|
|
608
686
|
const hostRef = useRef(null);
|
|
609
687
|
const documentRef = useRef(document);
|
|
610
688
|
const readOnlyRef = useRef(readOnly);
|
|
@@ -612,6 +690,7 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
|
|
|
612
690
|
const themeRef = useRef(theme);
|
|
613
691
|
const onTransactionRef = useRef(onTransaction);
|
|
614
692
|
const canonicalApiRef = useRef(getCanonicalApi);
|
|
693
|
+
const readCanonicalDocumentRef = useRef(readCanonicalDocument);
|
|
615
694
|
const sessionRef = useRef(experimentalSession);
|
|
616
695
|
const refusalRef = useRef(onSessionRefusal);
|
|
617
696
|
const managerRef = useRef(null);
|
|
@@ -622,6 +701,7 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
|
|
|
622
701
|
themeRef.current = theme;
|
|
623
702
|
onTransactionRef.current = onTransaction;
|
|
624
703
|
canonicalApiRef.current = getCanonicalApi;
|
|
704
|
+
readCanonicalDocumentRef.current = readCanonicalDocument;
|
|
625
705
|
sessionRef.current = experimentalSession;
|
|
626
706
|
refusalRef.current = onSessionRefusal;
|
|
627
707
|
managerRef.current ??= createHeaderFooterEditorManager({
|
|
@@ -631,8 +711,9 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
|
|
|
631
711
|
getStyles: () => stylesRef.current,
|
|
632
712
|
getTheme: () => themeRef.current,
|
|
633
713
|
getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
|
|
714
|
+
readCanonicalDocument: () => readCanonicalDocumentRef.current(),
|
|
634
715
|
getExperimentalSession: () => sessionRef.current,
|
|
635
|
-
onSessionRefusal: (reason,
|
|
716
|
+
onSessionRefusal: (reason, ground, error) => refusalRef.current?.(reason, ground, error),
|
|
636
717
|
onTransaction: ({ rId, kind, view, docChanged, selectionChanged }) => {
|
|
637
718
|
onTransactionRef.current?.(rId, kind, view, docChanged, selectionChanged);
|
|
638
719
|
}
|
|
@@ -645,6 +726,7 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
|
|
|
645
726
|
theme,
|
|
646
727
|
onTransaction,
|
|
647
728
|
getCanonicalApi,
|
|
729
|
+
readCanonicalDocument,
|
|
648
730
|
experimentalSession,
|
|
649
731
|
onSessionRefusal
|
|
650
732
|
]);
|
|
@@ -697,14 +779,15 @@ const hostStyle = {
|
|
|
697
779
|
};
|
|
698
780
|
const EMPTY_PLUGINS$1 = [];
|
|
699
781
|
const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
700
|
-
const $ = c(
|
|
701
|
-
const { document, experimentalSession, getCanonicalApi, onSessionRefusal, onActiveChange, onDocumentChange, onStoryChange, plugins, styles, suggestionAuthor, suggestionModeActive, theme } = t0;
|
|
782
|
+
const $ = c(45);
|
|
783
|
+
const { document, experimentalSession, getCanonicalApi, readCanonicalDocument, onSessionRefusal, onActiveChange, onDocumentChange, onStoryChange, plugins, styles, suggestionAuthor, suggestionModeActive, theme } = t0;
|
|
702
784
|
const t = useTranslations("folio");
|
|
703
785
|
const resolvedPlugins = plugins ?? EMPTY_PLUGINS$1;
|
|
704
786
|
const isSuggestionModeActive = suggestionModeActive ?? false;
|
|
705
787
|
const hostRef = useRef(null);
|
|
706
788
|
const documentRef = useRef(document);
|
|
707
789
|
const canonicalApiRef = useRef(getCanonicalApi);
|
|
790
|
+
const readCanonicalDocumentRef = useRef(readCanonicalDocument);
|
|
708
791
|
const sessionRef = useRef(experimentalSession);
|
|
709
792
|
const refusalRef = useRef(onSessionRefusal);
|
|
710
793
|
const stylesRef = useRef(styles);
|
|
@@ -717,10 +800,11 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
717
800
|
const managerRef = useRef(null);
|
|
718
801
|
let t1;
|
|
719
802
|
let t2;
|
|
720
|
-
if ($[0] !== active || $[1] !== document || $[2] !== experimentalSession || $[3] !== getCanonicalApi || $[4] !== onActiveChange || $[5] !== onDocumentChange || $[6] !== onSessionRefusal || $[7] !== onStoryChange || $[8] !==
|
|
803
|
+
if ($[0] !== active || $[1] !== document || $[2] !== experimentalSession || $[3] !== getCanonicalApi || $[4] !== onActiveChange || $[5] !== onDocumentChange || $[6] !== onSessionRefusal || $[7] !== onStoryChange || $[8] !== readCanonicalDocument || $[9] !== resolvedPlugins || $[10] !== styles || $[11] !== theme) {
|
|
721
804
|
t1 = () => {
|
|
722
805
|
documentRef.current = document;
|
|
723
806
|
canonicalApiRef.current = getCanonicalApi;
|
|
807
|
+
readCanonicalDocumentRef.current = readCanonicalDocument;
|
|
724
808
|
sessionRef.current = experimentalSession;
|
|
725
809
|
refusalRef.current = onSessionRefusal;
|
|
726
810
|
stylesRef.current = styles;
|
|
@@ -736,20 +820,22 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
736
820
|
getStyles: () => stylesRef.current,
|
|
737
821
|
getTheme: () => themeRef.current,
|
|
738
822
|
getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
|
|
823
|
+
readCanonicalDocument: () => readCanonicalDocumentRef.current(),
|
|
739
824
|
getExperimentalSession: () => sessionRef.current,
|
|
740
|
-
onSessionRefusal: (reason,
|
|
825
|
+
onSessionRefusal: (reason, ground, error) => refusalRef.current?.(reason, ground, error),
|
|
741
826
|
onTransaction: (t3) => {
|
|
742
827
|
const { docChanged, selectionChanged, view } = t3;
|
|
743
828
|
if (docChanged) {
|
|
744
|
-
const
|
|
745
|
-
|
|
829
|
+
const manager = managerRef.current;
|
|
830
|
+
const current = readCanonicalDocumentRef.current() ?? documentRef.current;
|
|
831
|
+
if (current) onDocumentChangeRef.current(manager ? manager.snapshotDocument(current) : canonicalApiRef.current?.()?.getCanonicalDocument() ?? current);
|
|
746
832
|
}
|
|
747
833
|
onStoryChangeRef.current(view, docChanged, selectionChanged);
|
|
748
834
|
}
|
|
749
835
|
});
|
|
750
|
-
const
|
|
751
|
-
|
|
752
|
-
if (active && !
|
|
836
|
+
const manager_0 = managerRef.current;
|
|
837
|
+
manager_0.sync();
|
|
838
|
+
if (active && !manager_0?.getActive()) {
|
|
753
839
|
setActive(null);
|
|
754
840
|
onActiveChangeRef.current(null);
|
|
755
841
|
}
|
|
@@ -759,6 +845,7 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
759
845
|
document,
|
|
760
846
|
experimentalSession,
|
|
761
847
|
getCanonicalApi,
|
|
848
|
+
readCanonicalDocument,
|
|
762
849
|
onActiveChange,
|
|
763
850
|
onDocumentChange,
|
|
764
851
|
onSessionRefusal,
|
|
@@ -775,63 +862,64 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
775
862
|
$[5] = onDocumentChange;
|
|
776
863
|
$[6] = onSessionRefusal;
|
|
777
864
|
$[7] = onStoryChange;
|
|
778
|
-
$[8] =
|
|
779
|
-
$[9] =
|
|
780
|
-
$[10] =
|
|
781
|
-
$[11] =
|
|
782
|
-
$[12] =
|
|
865
|
+
$[8] = readCanonicalDocument;
|
|
866
|
+
$[9] = resolvedPlugins;
|
|
867
|
+
$[10] = styles;
|
|
868
|
+
$[11] = theme;
|
|
869
|
+
$[12] = t1;
|
|
870
|
+
$[13] = t2;
|
|
783
871
|
} else {
|
|
784
|
-
t1 = $[
|
|
785
|
-
t2 = $[
|
|
872
|
+
t1 = $[12];
|
|
873
|
+
t2 = $[13];
|
|
786
874
|
}
|
|
787
875
|
useEffect(t1, t2);
|
|
788
876
|
let t3;
|
|
789
877
|
let t4;
|
|
790
|
-
if ($[
|
|
878
|
+
if ($[14] !== isSuggestionModeActive || $[15] !== suggestionAuthor) {
|
|
791
879
|
t3 = () => {
|
|
792
|
-
const
|
|
793
|
-
if (!
|
|
794
|
-
for (const story of
|
|
795
|
-
const view_0 =
|
|
880
|
+
const manager_1 = managerRef.current;
|
|
881
|
+
if (!manager_1) return;
|
|
882
|
+
for (const story of manager_1.listStories()) {
|
|
883
|
+
const view_0 = manager_1.getView(story);
|
|
796
884
|
if (view_0) setSuggestionMode(isSuggestionModeActive, view_0.state, view_0.dispatch, suggestionAuthor);
|
|
797
885
|
}
|
|
798
886
|
};
|
|
799
887
|
t4 = [isSuggestionModeActive, suggestionAuthor];
|
|
800
|
-
$[
|
|
801
|
-
$[
|
|
802
|
-
$[
|
|
803
|
-
$[
|
|
888
|
+
$[14] = isSuggestionModeActive;
|
|
889
|
+
$[15] = suggestionAuthor;
|
|
890
|
+
$[16] = t3;
|
|
891
|
+
$[17] = t4;
|
|
804
892
|
} else {
|
|
805
|
-
t3 = $[
|
|
806
|
-
t4 = $[
|
|
893
|
+
t3 = $[16];
|
|
894
|
+
t4 = $[17];
|
|
807
895
|
}
|
|
808
896
|
useEffect(t3, t4);
|
|
809
897
|
let t5;
|
|
810
898
|
let t6;
|
|
811
|
-
if ($[
|
|
899
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
812
900
|
t5 = () => () => {
|
|
813
901
|
managerRef.current?.destroy();
|
|
814
902
|
};
|
|
815
903
|
t6 = [];
|
|
816
|
-
$[
|
|
817
|
-
$[
|
|
904
|
+
$[18] = t5;
|
|
905
|
+
$[19] = t6;
|
|
818
906
|
} else {
|
|
819
|
-
t5 = $[
|
|
820
|
-
t6 = $[
|
|
907
|
+
t5 = $[18];
|
|
908
|
+
t6 = $[19];
|
|
821
909
|
}
|
|
822
910
|
useEffect(t5, t6);
|
|
823
911
|
let t7;
|
|
824
|
-
if ($[
|
|
912
|
+
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
|
825
913
|
t7 = () => {
|
|
826
914
|
managerRef.current?.activate(null);
|
|
827
915
|
setActive(null);
|
|
828
916
|
onActiveChangeRef.current(null);
|
|
829
917
|
};
|
|
830
|
-
$[
|
|
831
|
-
} else t7 = $[
|
|
918
|
+
$[20] = t7;
|
|
919
|
+
} else t7 = $[20];
|
|
832
920
|
const closeEditor = t7;
|
|
833
921
|
let t8;
|
|
834
|
-
if ($[
|
|
922
|
+
if ($[21] !== isSuggestionModeActive || $[22] !== suggestionAuthor) {
|
|
835
923
|
t8 = () => ({
|
|
836
924
|
close: closeEditor,
|
|
837
925
|
getActiveView: () => {
|
|
@@ -848,63 +936,63 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
848
936
|
},
|
|
849
937
|
snapshotDocument: (current_0) => managerRef.current?.snapshotDocument(current_0) ?? current_0
|
|
850
938
|
});
|
|
851
|
-
$[
|
|
852
|
-
$[
|
|
853
|
-
$[
|
|
854
|
-
} else t8 = $[
|
|
939
|
+
$[21] = isSuggestionModeActive;
|
|
940
|
+
$[22] = suggestionAuthor;
|
|
941
|
+
$[23] = t8;
|
|
942
|
+
} else t8 = $[23];
|
|
855
943
|
useImperativeHandle(ref, t8);
|
|
856
944
|
let t9;
|
|
857
|
-
if ($[
|
|
945
|
+
if ($[24] !== active || $[25] !== t) {
|
|
858
946
|
t9 = active ? t(active.kind === "footnote" ? "dialogs.footnoteProperties.footnotes" : "dialogs.footnoteProperties.endnotes") : "";
|
|
859
|
-
$[
|
|
860
|
-
$[
|
|
861
|
-
$[
|
|
862
|
-
} else t9 = $[
|
|
947
|
+
$[24] = active;
|
|
948
|
+
$[25] = t;
|
|
949
|
+
$[26] = t9;
|
|
950
|
+
} else t9 = $[26];
|
|
863
951
|
const title = t9;
|
|
864
952
|
const t10 = active ? "block" : "none";
|
|
865
953
|
let t11;
|
|
866
|
-
if ($[
|
|
954
|
+
if ($[27] !== t10) {
|
|
867
955
|
t11 = {
|
|
868
956
|
...panelStyle,
|
|
869
957
|
display: t10
|
|
870
958
|
};
|
|
871
|
-
$[
|
|
872
|
-
$[
|
|
873
|
-
} else t11 = $[
|
|
959
|
+
$[27] = t10;
|
|
960
|
+
$[28] = t11;
|
|
961
|
+
} else t11 = $[28];
|
|
874
962
|
let t12;
|
|
875
|
-
if ($[
|
|
963
|
+
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
876
964
|
t12 = (event) => {
|
|
877
965
|
if (event.key !== "Escape") return;
|
|
878
966
|
event.preventDefault();
|
|
879
967
|
event.stopPropagation();
|
|
880
968
|
closeEditor();
|
|
881
969
|
};
|
|
882
|
-
$[
|
|
883
|
-
} else t12 = $[
|
|
970
|
+
$[29] = t12;
|
|
971
|
+
} else t12 = $[29];
|
|
884
972
|
let t13;
|
|
885
|
-
if ($[
|
|
973
|
+
if ($[30] !== title) {
|
|
886
974
|
t13 = /* @__PURE__ */ jsx("span", { children: title });
|
|
887
|
-
$[
|
|
888
|
-
$[
|
|
889
|
-
} else t13 = $[
|
|
975
|
+
$[30] = title;
|
|
976
|
+
$[31] = t13;
|
|
977
|
+
} else t13 = $[31];
|
|
890
978
|
let t14;
|
|
891
|
-
if ($[
|
|
979
|
+
if ($[32] !== t) {
|
|
892
980
|
t14 = t("common.closeDialog");
|
|
893
|
-
$[
|
|
894
|
-
$[
|
|
895
|
-
} else t14 = $[
|
|
981
|
+
$[32] = t;
|
|
982
|
+
$[33] = t14;
|
|
983
|
+
} else t14 = $[33];
|
|
896
984
|
let t15;
|
|
897
|
-
if ($[
|
|
985
|
+
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
|
|
898
986
|
t15 = {
|
|
899
987
|
border: 0,
|
|
900
988
|
background: "transparent",
|
|
901
989
|
color: "inherit",
|
|
902
990
|
cursor: "pointer"
|
|
903
991
|
};
|
|
904
|
-
$[
|
|
905
|
-
} else t15 = $[
|
|
992
|
+
$[34] = t15;
|
|
993
|
+
} else t15 = $[34];
|
|
906
994
|
let t16;
|
|
907
|
-
if ($[
|
|
995
|
+
if ($[35] !== t14) {
|
|
908
996
|
t16 = /* @__PURE__ */ jsx("button", {
|
|
909
997
|
type: "button",
|
|
910
998
|
"aria-label": t14,
|
|
@@ -912,40 +1000,40 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
912
1000
|
style: t15,
|
|
913
1001
|
children: "×"
|
|
914
1002
|
});
|
|
915
|
-
$[
|
|
916
|
-
$[
|
|
917
|
-
} else t16 = $[
|
|
1003
|
+
$[35] = t14;
|
|
1004
|
+
$[36] = t16;
|
|
1005
|
+
} else t16 = $[36];
|
|
918
1006
|
let t17;
|
|
919
|
-
if ($[
|
|
1007
|
+
if ($[37] !== t13 || $[38] !== t16) {
|
|
920
1008
|
t17 = /* @__PURE__ */ jsxs("div", {
|
|
921
1009
|
style: headerStyle,
|
|
922
1010
|
children: [t13, t16]
|
|
923
1011
|
});
|
|
924
|
-
$[
|
|
925
|
-
$[
|
|
926
|
-
$[
|
|
927
|
-
} else t17 = $[
|
|
1012
|
+
$[37] = t13;
|
|
1013
|
+
$[38] = t16;
|
|
1014
|
+
$[39] = t17;
|
|
1015
|
+
} else t17 = $[39];
|
|
928
1016
|
let t18;
|
|
929
|
-
if ($[
|
|
1017
|
+
if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
|
|
930
1018
|
t18 = /* @__PURE__ */ jsx("div", {
|
|
931
1019
|
ref: hostRef,
|
|
932
1020
|
style: hostStyle
|
|
933
1021
|
});
|
|
934
|
-
$[
|
|
935
|
-
} else t18 = $[
|
|
1022
|
+
$[40] = t18;
|
|
1023
|
+
} else t18 = $[40];
|
|
936
1024
|
let t19;
|
|
937
|
-
if ($[
|
|
1025
|
+
if ($[41] !== t11 || $[42] !== t17 || $[43] !== title) {
|
|
938
1026
|
t19 = /* @__PURE__ */ jsxs("aside", {
|
|
939
1027
|
style: t11,
|
|
940
1028
|
"aria-label": title,
|
|
941
1029
|
onKeyDown: t12,
|
|
942
1030
|
children: [t17, t18]
|
|
943
1031
|
});
|
|
944
|
-
$[
|
|
945
|
-
$[
|
|
946
|
-
$[
|
|
947
|
-
$[
|
|
948
|
-
} else t19 = $[
|
|
1032
|
+
$[41] = t11;
|
|
1033
|
+
$[42] = t17;
|
|
1034
|
+
$[43] = title;
|
|
1035
|
+
$[44] = t19;
|
|
1036
|
+
} else t19 = $[44];
|
|
949
1037
|
return t19;
|
|
950
1038
|
});
|
|
951
1039
|
NoteStoryEditor.displayName = "NoteStoryEditor";
|
|
@@ -1012,7 +1100,7 @@ const AISuggestionRectsOverlay = (t0) => {
|
|
|
1012
1100
|
if (groups.length === 0) return null;
|
|
1013
1101
|
let t1;
|
|
1014
1102
|
if ($[0] !== groups) {
|
|
1015
|
-
t1 = groups.map(_temp$
|
|
1103
|
+
t1 = groups.map(_temp$15);
|
|
1016
1104
|
$[0] = groups;
|
|
1017
1105
|
$[1] = t1;
|
|
1018
1106
|
} else t1 = $[1];
|
|
@@ -1028,7 +1116,7 @@ const AISuggestionRectsOverlay = (t0) => {
|
|
|
1028
1116
|
} else t2 = $[3];
|
|
1029
1117
|
return t2;
|
|
1030
1118
|
};
|
|
1031
|
-
function _temp$
|
|
1119
|
+
function _temp$15(t0) {
|
|
1032
1120
|
const { suggestion, rects, focused, font } = t0;
|
|
1033
1121
|
const replacementAnchor = rects.at(-1);
|
|
1034
1122
|
const showReplacement = focused && suggestion.suggestedText.length > 0 && replacementAnchor !== void 0;
|
|
@@ -1428,7 +1516,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1428
1516
|
getExperimentalSession: () => experimentalSessionRef.current,
|
|
1429
1517
|
getEditingMode: () => suggestionModeActiveRef.current ? "suggesting" : "editing",
|
|
1430
1518
|
getSuggestionAuthor: () => suggestionAuthorRef.current,
|
|
1431
|
-
onSessionRefusal: (reason,
|
|
1519
|
+
onSessionRefusal: (reason, ground, error) => onSessionRefusalRef.current?.(reason, ground, error),
|
|
1432
1520
|
getDocumentIdentity: () => documentIdentityRef.current,
|
|
1433
1521
|
getDocumentContext: () => documentRef.current,
|
|
1434
1522
|
onTransaction: (update) => onTransactionRef.current?.(update),
|
|
@@ -1492,7 +1580,8 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1492
1580
|
useImperativeHandle(ref, () => ({
|
|
1493
1581
|
...managerRef.current.api,
|
|
1494
1582
|
getHostElement: () => hostRef.current,
|
|
1495
|
-
isCanonicalComposing: () => managerRef.current?.isCanonicalComposing() ?? false
|
|
1583
|
+
isCanonicalComposing: () => managerRef.current?.isCanonicalComposing() ?? false,
|
|
1584
|
+
readCanonicalDocument: () => managerRef.current?.readCanonicalDocument() ?? null
|
|
1496
1585
|
}), []);
|
|
1497
1586
|
if (hasCollaboration && collaborationModulesError) {
|
|
1498
1587
|
let detail = "unknown error";
|
|
@@ -1501,7 +1590,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1501
1590
|
panic(`Failed to load collaboration editor modules. Reload the document to retry. Cause: ${detail}`);
|
|
1502
1591
|
}
|
|
1503
1592
|
return /* @__PURE__ */ jsx("div", {
|
|
1504
|
-
className:
|
|
1593
|
+
className: HIDDEN_EDITOR_WRAPPER_CLASS,
|
|
1505
1594
|
style: HIDDEN_WRAPPER_STYLES,
|
|
1506
1595
|
children: /* @__PURE__ */ jsx("div", {
|
|
1507
1596
|
ref: hostRef,
|
|
@@ -2115,7 +2204,7 @@ const PassageHighlightOverlay = (t0) => {
|
|
|
2115
2204
|
if (rects.length === 0) return null;
|
|
2116
2205
|
let t1;
|
|
2117
2206
|
if ($[0] !== rects) {
|
|
2118
|
-
t1 = rects.map(_temp$
|
|
2207
|
+
t1 = rects.map(_temp$14);
|
|
2119
2208
|
$[0] = rects;
|
|
2120
2209
|
$[1] = t1;
|
|
2121
2210
|
} else t1 = $[1];
|
|
@@ -2131,7 +2220,7 @@ const PassageHighlightOverlay = (t0) => {
|
|
|
2131
2220
|
} else t2 = $[3];
|
|
2132
2221
|
return t2;
|
|
2133
2222
|
};
|
|
2134
|
-
function _temp$
|
|
2223
|
+
function _temp$14(rect, idx) {
|
|
2135
2224
|
return /* @__PURE__ */ jsx("span", {
|
|
2136
2225
|
className: "folio-passage-highlight",
|
|
2137
2226
|
style: {
|
|
@@ -2262,10 +2351,11 @@ const SelectionRectangle = (t0) => {
|
|
|
2262
2351
|
* Renders selection highlights and caret cursor over the paginated document.
|
|
2263
2352
|
* Should be positioned as a child of the pages container with relative positioning.
|
|
2264
2353
|
*/
|
|
2265
|
-
const SelectionOverlay = ({ selectionRects, caretPosition, isFocused, caretColor = DEFAULT_CARET_COLOR, selectionColor = DEFAULT_SELECTION_COLOR, caretWidth = DEFAULT_CARET_WIDTH, blinkInterval = DEFAULT_BLINK_INTERVAL, markCaretRect = false }) => {
|
|
2354
|
+
const SelectionOverlay = ({ selectionRects, caretPosition, isFocused, caretColor = DEFAULT_CARET_COLOR, selectionColor = DEFAULT_SELECTION_COLOR, caretWidth = DEFAULT_CARET_WIDTH, blinkInterval = DEFAULT_BLINK_INTERVAL, markCaretRect = false, overlayRef }) => {
|
|
2266
2355
|
const hasRangeSelection = selectionRects.length > 0;
|
|
2267
2356
|
const hasCollapsedSelection = caretPosition !== null && !hasRangeSelection;
|
|
2268
2357
|
return /* @__PURE__ */ jsxs("div", {
|
|
2358
|
+
ref: overlayRef,
|
|
2269
2359
|
style: overlayStyles$1,
|
|
2270
2360
|
"data-testid": "selection-overlay",
|
|
2271
2361
|
children: [hasRangeSelection && selectionRects.map((rect, index) => /* @__PURE__ */ jsx(SelectionRectangle, {
|
|
@@ -2638,6 +2728,20 @@ const DOCUMENT_CHANGE_NOTIFY_DELAY = 250;
|
|
|
2638
2728
|
/** Keep the visual caret hidden briefly while typed content relayouts. */
|
|
2639
2729
|
const SELECTION_REVEAL_AFTER_INPUT_DELAY = 120;
|
|
2640
2730
|
/**
|
|
2731
|
+
* Hide the selection overlay while typed content lays out again. It is a DOM
|
|
2732
|
+
* write, not a state change: a keystroke must not render the editor, since
|
|
2733
|
+
* every commit with the editor focused reads its whole DOM.
|
|
2734
|
+
*/
|
|
2735
|
+
const hideSelectionOverlay = (overlay) => {
|
|
2736
|
+
overlay?.setAttribute(FOLIO_INPUT_HIDDEN_ATTRIBUTE, "");
|
|
2737
|
+
overlay?.style.setProperty("visibility", "hidden");
|
|
2738
|
+
};
|
|
2739
|
+
const showSelectionOverlay = (overlay) => {
|
|
2740
|
+
if (!overlay?.hasAttribute(FOLIO_INPUT_HIDDEN_ATTRIBUTE)) return;
|
|
2741
|
+
overlay.removeAttribute(FOLIO_INPUT_HIDDEN_ATTRIBUTE);
|
|
2742
|
+
overlay.style.removeProperty("visibility");
|
|
2743
|
+
};
|
|
2744
|
+
/**
|
|
2641
2745
|
* Readability floor for the autocomplete ghost width: with the caret at the
|
|
2642
2746
|
* right content boundary, an unfloored width plus `overflow-wrap: anywhere`
|
|
2643
2747
|
* would wrap the suggestion into a one-character-wide vertical column. Near
|
|
@@ -2766,7 +2870,7 @@ const createPagedRuntime = (emitter) => {
|
|
|
2766
2870
|
};
|
|
2767
2871
|
};
|
|
2768
2872
|
function HfCaretOverlay(t0) {
|
|
2769
|
-
const $ = c(
|
|
2873
|
+
const $ = c(23);
|
|
2770
2874
|
const { selection, getSurface, zoom } = t0;
|
|
2771
2875
|
let t1;
|
|
2772
2876
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -2776,18 +2880,18 @@ function HfCaretOverlay(t0) {
|
|
|
2776
2880
|
};
|
|
2777
2881
|
$[0] = t1;
|
|
2778
2882
|
} else t1 = $[0];
|
|
2779
|
-
const [caretProjection, setCaretProjection] =
|
|
2883
|
+
const [caretProjection, setCaretProjection] = useEqualState(t1);
|
|
2780
2884
|
const { caret, pagesContainer: portalTarget } = caretProjection;
|
|
2781
2885
|
let t2;
|
|
2782
2886
|
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2783
2887
|
t2 = [];
|
|
2784
2888
|
$[1] = t2;
|
|
2785
2889
|
} else t2 = $[1];
|
|
2786
|
-
const [rangeRects, setRangeRects] =
|
|
2890
|
+
const [rangeRects, setRangeRects] = useEqualState(t2);
|
|
2787
2891
|
const { rId, kind, from, to, pageNumber } = selection;
|
|
2788
2892
|
let t3;
|
|
2789
2893
|
let t4;
|
|
2790
|
-
if ($[2] !== from || $[3] !== getSurface || $[4] !== kind || $[5] !== pageNumber || $[6] !== rId || $[7] !==
|
|
2894
|
+
if ($[2] !== from || $[3] !== getSurface || $[4] !== kind || $[5] !== pageNumber || $[6] !== rId || $[7] !== setCaretProjection || $[8] !== setRangeRects || $[9] !== to || $[10] !== zoom) {
|
|
2791
2895
|
t3 = () => {
|
|
2792
2896
|
const { pagesContainer, hiddenHost } = getSurface(rId);
|
|
2793
2897
|
if (!pagesContainer) return;
|
|
@@ -2854,31 +2958,35 @@ function HfCaretOverlay(t0) {
|
|
|
2854
2958
|
to,
|
|
2855
2959
|
pageNumber,
|
|
2856
2960
|
getSurface,
|
|
2857
|
-
zoom
|
|
2961
|
+
zoom,
|
|
2962
|
+
setCaretProjection,
|
|
2963
|
+
setRangeRects
|
|
2858
2964
|
];
|
|
2859
2965
|
$[2] = from;
|
|
2860
2966
|
$[3] = getSurface;
|
|
2861
2967
|
$[4] = kind;
|
|
2862
2968
|
$[5] = pageNumber;
|
|
2863
2969
|
$[6] = rId;
|
|
2864
|
-
$[7] =
|
|
2865
|
-
$[8] =
|
|
2866
|
-
$[9] =
|
|
2867
|
-
$[10] =
|
|
2970
|
+
$[7] = setCaretProjection;
|
|
2971
|
+
$[8] = setRangeRects;
|
|
2972
|
+
$[9] = to;
|
|
2973
|
+
$[10] = zoom;
|
|
2974
|
+
$[11] = t3;
|
|
2975
|
+
$[12] = t4;
|
|
2868
2976
|
} else {
|
|
2869
|
-
t3 = $[
|
|
2870
|
-
t4 = $[
|
|
2977
|
+
t3 = $[11];
|
|
2978
|
+
t4 = $[12];
|
|
2871
2979
|
}
|
|
2872
2980
|
useEffect(t3, t4);
|
|
2873
2981
|
if (!portalTarget) return null;
|
|
2874
2982
|
let t5;
|
|
2875
|
-
if ($[
|
|
2876
|
-
t5 = rangeRects.map(_temp$
|
|
2877
|
-
$[
|
|
2878
|
-
$[
|
|
2879
|
-
} else t5 = $[
|
|
2983
|
+
if ($[13] !== rangeRects) {
|
|
2984
|
+
t5 = rangeRects.map(_temp$13);
|
|
2985
|
+
$[13] = rangeRects;
|
|
2986
|
+
$[14] = t5;
|
|
2987
|
+
} else t5 = $[14];
|
|
2880
2988
|
let t6;
|
|
2881
|
-
if ($[
|
|
2989
|
+
if ($[15] !== caret) {
|
|
2882
2990
|
t6 = caret && /* @__PURE__ */ jsx("div", {
|
|
2883
2991
|
"data-testid": "hf-caret",
|
|
2884
2992
|
style: {
|
|
@@ -2893,26 +3001,26 @@ function HfCaretOverlay(t0) {
|
|
|
2893
3001
|
animation: "folio-caret-blink 1060ms steps(1, end) infinite"
|
|
2894
3002
|
}
|
|
2895
3003
|
});
|
|
2896
|
-
$[
|
|
2897
|
-
$[
|
|
2898
|
-
} else t6 = $[
|
|
3004
|
+
$[15] = caret;
|
|
3005
|
+
$[16] = t6;
|
|
3006
|
+
} else t6 = $[16];
|
|
2899
3007
|
let t7;
|
|
2900
|
-
if ($[
|
|
3008
|
+
if ($[17] !== t5 || $[18] !== t6) {
|
|
2901
3009
|
t7 = /* @__PURE__ */ jsxs(Fragment, { children: [t5, t6] });
|
|
2902
|
-
$[
|
|
2903
|
-
$[
|
|
2904
|
-
$[
|
|
2905
|
-
} else t7 = $[
|
|
3010
|
+
$[17] = t5;
|
|
3011
|
+
$[18] = t6;
|
|
3012
|
+
$[19] = t7;
|
|
3013
|
+
} else t7 = $[19];
|
|
2906
3014
|
let t8;
|
|
2907
|
-
if ($[
|
|
3015
|
+
if ($[20] !== portalTarget || $[21] !== t7) {
|
|
2908
3016
|
t8 = createPortal(t7, portalTarget);
|
|
2909
|
-
$[
|
|
2910
|
-
$[
|
|
2911
|
-
$[
|
|
2912
|
-
} else t8 = $[
|
|
3017
|
+
$[20] = portalTarget;
|
|
3018
|
+
$[21] = t7;
|
|
3019
|
+
$[22] = t8;
|
|
3020
|
+
} else t8 = $[22];
|
|
2913
3021
|
return t8;
|
|
2914
3022
|
}
|
|
2915
|
-
function _temp$
|
|
3023
|
+
function _temp$13(r, i) {
|
|
2916
3024
|
return /* @__PURE__ */ jsx("div", {
|
|
2917
3025
|
"data-testid": "hf-selection-rect",
|
|
2918
3026
|
style: {
|
|
@@ -2997,12 +3105,12 @@ function describeInvalidHighlightMarks(doc) {
|
|
|
2997
3105
|
return invalidHighlights.join("; ");
|
|
2998
3106
|
}
|
|
2999
3107
|
const RemoteSelectionOverlay = (t0) => {
|
|
3000
|
-
const $ = c(
|
|
3108
|
+
const $ = c(22);
|
|
3001
3109
|
const { blocks, layout, measures, getPagesContainer, remoteSelection, zoom } = t0;
|
|
3002
|
-
const [geometry, setGeometry] =
|
|
3110
|
+
const [geometry, setGeometry] = useEqualState(null);
|
|
3003
3111
|
let t1;
|
|
3004
3112
|
let t2;
|
|
3005
|
-
if ($[0] !== blocks || $[1] !== getPagesContainer || $[2] !== layout || $[3] !== measures || $[4] !== remoteSelection.anchor || $[5] !== remoteSelection.head || $[6] !== zoom) {
|
|
3113
|
+
if ($[0] !== blocks || $[1] !== getPagesContainer || $[2] !== layout || $[3] !== measures || $[4] !== remoteSelection.anchor || $[5] !== remoteSelection.head || $[6] !== setGeometry || $[7] !== zoom) {
|
|
3006
3114
|
t1 = () => {
|
|
3007
3115
|
let cancelled = false;
|
|
3008
3116
|
loadSelectionGeometry().then((t3) => {
|
|
@@ -3047,7 +3155,8 @@ const RemoteSelectionOverlay = (t0) => {
|
|
|
3047
3155
|
getPagesContainer,
|
|
3048
3156
|
remoteSelection.anchor,
|
|
3049
3157
|
remoteSelection.head,
|
|
3050
|
-
zoom
|
|
3158
|
+
zoom,
|
|
3159
|
+
setGeometry
|
|
3051
3160
|
];
|
|
3052
3161
|
$[0] = blocks;
|
|
3053
3162
|
$[1] = getPagesContainer;
|
|
@@ -3055,19 +3164,20 @@ const RemoteSelectionOverlay = (t0) => {
|
|
|
3055
3164
|
$[3] = measures;
|
|
3056
3165
|
$[4] = remoteSelection.anchor;
|
|
3057
3166
|
$[5] = remoteSelection.head;
|
|
3058
|
-
$[6] =
|
|
3059
|
-
$[7] =
|
|
3060
|
-
$[8] =
|
|
3167
|
+
$[6] = setGeometry;
|
|
3168
|
+
$[7] = zoom;
|
|
3169
|
+
$[8] = t1;
|
|
3170
|
+
$[9] = t2;
|
|
3061
3171
|
} else {
|
|
3062
|
-
t1 = $[
|
|
3063
|
-
t2 = $[
|
|
3172
|
+
t1 = $[8];
|
|
3173
|
+
t2 = $[9];
|
|
3064
3174
|
}
|
|
3065
3175
|
useEffect(t1, t2);
|
|
3066
3176
|
if (!geometry) return null;
|
|
3067
3177
|
const { caretPosition: caretPosition_0, selectionRects } = geometry;
|
|
3068
3178
|
const t3 = `color-mix(in srgb, ${remoteSelection.color} 24%, transparent)`;
|
|
3069
3179
|
let t4;
|
|
3070
|
-
if ($[
|
|
3180
|
+
if ($[10] !== caretPosition_0 || $[11] !== remoteSelection.color || $[12] !== selectionRects || $[13] !== t3) {
|
|
3071
3181
|
t4 = /* @__PURE__ */ jsx(SelectionOverlay, {
|
|
3072
3182
|
blinkInterval: 0,
|
|
3073
3183
|
caretColor: remoteSelection.color,
|
|
@@ -3077,14 +3187,14 @@ const RemoteSelectionOverlay = (t0) => {
|
|
|
3077
3187
|
selectionColor: t3,
|
|
3078
3188
|
selectionRects
|
|
3079
3189
|
});
|
|
3080
|
-
$[
|
|
3081
|
-
$[
|
|
3082
|
-
$[
|
|
3083
|
-
$[
|
|
3084
|
-
$[
|
|
3085
|
-
} else t4 = $[
|
|
3190
|
+
$[10] = caretPosition_0;
|
|
3191
|
+
$[11] = remoteSelection.color;
|
|
3192
|
+
$[12] = selectionRects;
|
|
3193
|
+
$[13] = t3;
|
|
3194
|
+
$[14] = t4;
|
|
3195
|
+
} else t4 = $[14];
|
|
3086
3196
|
let t5;
|
|
3087
|
-
if ($[
|
|
3197
|
+
if ($[15] !== caretPosition_0 || $[16] !== remoteSelection.color || $[17] !== remoteSelection.name) {
|
|
3088
3198
|
t5 = caretPosition_0 && /* @__PURE__ */ jsx("div", {
|
|
3089
3199
|
className: "pointer-events-none absolute z-20 rounded-sm px-1 py-0.5 text-[10px] leading-none shadow-sm",
|
|
3090
3200
|
style: {
|
|
@@ -3095,18 +3205,18 @@ const RemoteSelectionOverlay = (t0) => {
|
|
|
3095
3205
|
},
|
|
3096
3206
|
children: remoteSelection.name
|
|
3097
3207
|
});
|
|
3098
|
-
$[
|
|
3099
|
-
$[
|
|
3100
|
-
$[
|
|
3101
|
-
$[
|
|
3102
|
-
} else t5 = $[
|
|
3208
|
+
$[15] = caretPosition_0;
|
|
3209
|
+
$[16] = remoteSelection.color;
|
|
3210
|
+
$[17] = remoteSelection.name;
|
|
3211
|
+
$[18] = t5;
|
|
3212
|
+
} else t5 = $[18];
|
|
3103
3213
|
let t6;
|
|
3104
|
-
if ($[
|
|
3214
|
+
if ($[19] !== t4 || $[20] !== t5) {
|
|
3105
3215
|
t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t4, t5] });
|
|
3106
|
-
$[
|
|
3107
|
-
$[
|
|
3108
|
-
$[
|
|
3109
|
-
} else t6 = $[
|
|
3216
|
+
$[19] = t4;
|
|
3217
|
+
$[20] = t5;
|
|
3218
|
+
$[21] = t6;
|
|
3219
|
+
} else t6 = $[21];
|
|
3110
3220
|
return t6;
|
|
3111
3221
|
};
|
|
3112
3222
|
const pagesContainerStyles = {
|
|
@@ -3306,9 +3416,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3306
3416
|
onTotalPagesChange,
|
|
3307
3417
|
onError
|
|
3308
3418
|
]);
|
|
3309
|
-
const handleSessionRefusal = useCallback((message,
|
|
3419
|
+
const handleSessionRefusal = useCallback((message, ground, error) => {
|
|
3310
3420
|
onErrorRef.current?.(error ?? new CanonicalSessionRefusalError({
|
|
3311
|
-
|
|
3421
|
+
ground,
|
|
3312
3422
|
message
|
|
3313
3423
|
}));
|
|
3314
3424
|
}, []);
|
|
@@ -3327,9 +3437,13 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3327
3437
|
const queuedInputBeforeHiddenEditorRef = useRef([]);
|
|
3328
3438
|
const pendingInitialFontReadyLayoutRef = useRef(false);
|
|
3329
3439
|
const [isFocused, setIsFocused] = useState(false);
|
|
3330
|
-
const [selectionRects, setSelectionRects] =
|
|
3331
|
-
const [caretPosition,
|
|
3332
|
-
|
|
3440
|
+
const [selectionRects, setSelectionRects] = useEqualState([]);
|
|
3441
|
+
const [caretPosition, setCaretPositionState] = useEqualState(null);
|
|
3442
|
+
/** The selection overlay, hidden without a render while typing. */
|
|
3443
|
+
const selectionOverlayRef = useRef(null);
|
|
3444
|
+
/** The caret the overlay last painted. */
|
|
3445
|
+
const committedCaretRef = useRef(null);
|
|
3446
|
+
const [anonymizationRectGroups, setAnonymizationRectGroups] = useEqualState([]);
|
|
3333
3447
|
const anonymizationMatchesRef = useRef([]);
|
|
3334
3448
|
const [anonymizationOverlayRequestGate] = useState(createLatestRequestGate);
|
|
3335
3449
|
const autocompleteSuggestionRef = useRef({
|
|
@@ -3339,16 +3453,16 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3339
3453
|
requestId: null
|
|
3340
3454
|
});
|
|
3341
3455
|
const [autocompleteOverlayRequestGate] = useState(createLatestRequestGate);
|
|
3342
|
-
const [autocompleteCaret, setAutocompleteCaret] =
|
|
3343
|
-
const [autocompleteText, setAutocompleteText] =
|
|
3456
|
+
const [autocompleteCaret, setAutocompleteCaret] = useEqualState(null);
|
|
3457
|
+
const [autocompleteText, setAutocompleteText] = useEqualState("");
|
|
3344
3458
|
const [autocompleteIsStreaming, setAutocompleteIsStreaming] = useState(false);
|
|
3345
|
-
const [directiveProjection, setDirectiveProjection] =
|
|
3459
|
+
const [directiveProjection, setDirectiveProjection] = useEqualState({
|
|
3346
3460
|
groups: [],
|
|
3347
3461
|
ranges: []
|
|
3348
3462
|
});
|
|
3349
3463
|
const directiveRectGroups = directiveProjection.groups;
|
|
3350
|
-
const [directiveGutter, setDirectiveGutter] =
|
|
3351
|
-
const [directiveCaretPos, setDirectiveCaretPos] =
|
|
3464
|
+
const [directiveGutter, setDirectiveGutter] = useEqualState(null);
|
|
3465
|
+
const [directiveCaretPos, setDirectiveCaretPos] = useEqualState(null);
|
|
3352
3466
|
const directivesRef = useRef([]);
|
|
3353
3467
|
const [directivesOverlayRequestGate] = useState(createLatestRequestGate);
|
|
3354
3468
|
const templatePreviewRef = useRef({
|
|
@@ -3356,18 +3470,32 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3356
3470
|
hidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN,
|
|
3357
3471
|
mode: "plain"
|
|
3358
3472
|
});
|
|
3359
|
-
const [aiSuggestionRectGroups, setAiSuggestionRectGroups] =
|
|
3473
|
+
const [aiSuggestionRectGroups, setAiSuggestionRectGroups] = useEqualState([]);
|
|
3360
3474
|
const aiSuggestionsRef = useRef({
|
|
3361
3475
|
suggestions: EMPTY_AI_SUGGESTIONS,
|
|
3362
3476
|
focusedId: null
|
|
3363
3477
|
});
|
|
3364
3478
|
const [aiSuggestionsOverlayRequestGate] = useState(createLatestRequestGate);
|
|
3365
3479
|
const passageHighlightRangeRef = useRef(null);
|
|
3366
|
-
const [passageHighlightRects, setPassageHighlightRects] =
|
|
3480
|
+
const [passageHighlightRects, setPassageHighlightRects] = useEqualState([]);
|
|
3367
3481
|
const [passageHighlightOverlayRequestGate] = useState(createLatestRequestGate);
|
|
3368
|
-
const [remoteSelections, setRemoteSelections] =
|
|
3482
|
+
const [remoteSelections, setRemoteSelections] = useEqualState([]);
|
|
3369
3483
|
const suppressSelectionOverlayRef = useRef(false);
|
|
3370
3484
|
const revealSelectionOverlayTimerRef = useRef(null);
|
|
3485
|
+
/**
|
|
3486
|
+
* Write the caret. While typed content lays out again the overlay is
|
|
3487
|
+
* hidden instead of cleared, so a keystroke renders nothing for it; the
|
|
3488
|
+
* first caret written after that shows the overlay again, once the caret
|
|
3489
|
+
* it holds is the one painted.
|
|
3490
|
+
*/
|
|
3491
|
+
const setCaretPosition = useCallback((next) => {
|
|
3492
|
+
setCaretPositionState(next);
|
|
3493
|
+
if (!suppressSelectionOverlayRef.current && structurallyEqual(committedCaretRef.current, next)) showSelectionOverlay(selectionOverlayRef.current);
|
|
3494
|
+
}, [setCaretPositionState]);
|
|
3495
|
+
useLayoutEffect(() => {
|
|
3496
|
+
committedCaretRef.current = caretPosition;
|
|
3497
|
+
if (!suppressSelectionOverlayRef.current) showSelectionOverlay(selectionOverlayRef.current);
|
|
3498
|
+
}, [caretPosition]);
|
|
3371
3499
|
const [selectionOverlayRequestGate] = useState(createLatestRequestGate);
|
|
3372
3500
|
const validPrecomputedInitialState = useMemo(() => {
|
|
3373
3501
|
if (shouldCreateHiddenEditorView || collaboration !== void 0 || !document) return null;
|
|
@@ -3390,7 +3518,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3390
3518
|
useLayoutEffect(() => {
|
|
3391
3519
|
precomputedInitialStateRef.current = validPrecomputedInitialState;
|
|
3392
3520
|
}, [validPrecomputedInitialState]);
|
|
3393
|
-
const [selectedImageInfo, setSelectedImageInfo] =
|
|
3521
|
+
const [selectedImageInfo, setSelectedImageInfo] = useEqualState(null);
|
|
3394
3522
|
const isImageInteractingRef = useRef(false);
|
|
3395
3523
|
/** Build ImageSelectionInfo from a DOM element with data-pm-start */
|
|
3396
3524
|
const buildImageSelectionInfo = useCallback((el, pmPos) => {
|
|
@@ -3494,7 +3622,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3494
3622
|
const cellDragOverflowXRef = useRef(null);
|
|
3495
3623
|
const cellDragContentEndRef = useRef(null);
|
|
3496
3624
|
const CELL_SELECT_OVERFLOW_PX = 5;
|
|
3497
|
-
const [tableInsertButton, setTableInsertButton] =
|
|
3625
|
+
const [tableInsertButton, setTableInsertButton] = useEqualState(null);
|
|
3498
3626
|
const tableInsertHideTimerRef = useRef(null);
|
|
3499
3627
|
const clearTableInsertTimer = useCallback(() => {
|
|
3500
3628
|
if (tableInsertHideTimerRef.current) {
|
|
@@ -3763,8 +3891,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3763
3891
|
const body = hiddenPMRef.current?.getState()?.doc;
|
|
3764
3892
|
if (newDoc && body && !usesCanonicalSession(experimentalSession, CANONICAL_GAP.save)) newDoc = noteFollower.reconcile(newDoc, body);
|
|
3765
3893
|
if (newDoc) {
|
|
3766
|
-
onDocumentChangeRef.current?.(
|
|
3767
|
-
folioEmitterRef.current.emit("docChange",
|
|
3894
|
+
onDocumentChangeRef.current?.(newDoc);
|
|
3895
|
+
folioEmitterRef.current.emit("docChange", newDoc);
|
|
3768
3896
|
}
|
|
3769
3897
|
};
|
|
3770
3898
|
flush();
|
|
@@ -3773,6 +3901,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3773
3901
|
noteFollower,
|
|
3774
3902
|
getActiveEditorStory
|
|
3775
3903
|
]);
|
|
3904
|
+
const readCanonicalDocument = useCallback(() => hiddenPMRef.current?.readCanonicalDocument() ?? null, []);
|
|
3776
3905
|
const scheduleDocumentChangeNotification = useCallback(() => {
|
|
3777
3906
|
if (documentChangeNotifyTimerRef.current !== null) window.clearTimeout(documentChangeNotifyTimerRef.current);
|
|
3778
3907
|
documentChangeNotifyTimerRef.current = window.setTimeout(() => {
|
|
@@ -3850,13 +3979,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3850
3979
|
});
|
|
3851
3980
|
}
|
|
3852
3981
|
if (suppressSelectionOverlayRef.current) {
|
|
3853
|
-
setCaretPosition(null);
|
|
3854
3982
|
setSelectionRects([]);
|
|
3855
|
-
syncImeCaretAnchor({
|
|
3856
|
-
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3857
|
-
editorView: hiddenPMRef.current?.getView(),
|
|
3858
|
-
visibleCaret: null
|
|
3859
|
-
});
|
|
3860
3983
|
return;
|
|
3861
3984
|
}
|
|
3862
3985
|
if (pagesContainerRef.current) {
|
|
@@ -3870,9 +3993,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3870
3993
|
});
|
|
3871
3994
|
const allCells = htmlQueryAll(pagesContainerRef.current, ".layout-table-cell");
|
|
3872
3995
|
for (const cellEl of allCells) {
|
|
3873
|
-
const
|
|
3874
|
-
if (
|
|
3875
|
-
const pmPos_1 = Number(pmStartAttr);
|
|
3996
|
+
const pmPos_1 = readPaintedStart(cellEl);
|
|
3997
|
+
if (pmPos_1 !== void 0) {
|
|
3876
3998
|
for (const [start, end] of selectedRanges) if (pmPos_1 >= start && pmPos_1 < end) {
|
|
3877
3999
|
cellEl.classList.add("layout-table-cell-selected");
|
|
3878
4000
|
break;
|
|
@@ -4005,7 +4127,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4005
4127
|
getCaretFromDom,
|
|
4006
4128
|
selectionOverlayRequestGate,
|
|
4007
4129
|
zoom,
|
|
4008
|
-
markupView
|
|
4130
|
+
markupView,
|
|
4131
|
+
setSelectionRects,
|
|
4132
|
+
setCaretPosition,
|
|
4133
|
+
setDirectiveCaretPos
|
|
4009
4134
|
]);
|
|
4010
4135
|
useLayoutEffect(() => {
|
|
4011
4136
|
runtime.commitSelectionUpdate(updateSelectionOverlay);
|
|
@@ -4107,7 +4232,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4107
4232
|
layout,
|
|
4108
4233
|
blocks,
|
|
4109
4234
|
measures,
|
|
4110
|
-
zoom
|
|
4235
|
+
zoom,
|
|
4236
|
+
setAnonymizationRectGroups
|
|
4111
4237
|
]);
|
|
4112
4238
|
const updateAutocompleteOverlay = useCallback(() => {
|
|
4113
4239
|
const requestIsLatest = autocompleteOverlayRequestGate.begin();
|
|
@@ -4157,7 +4283,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4157
4283
|
layout,
|
|
4158
4284
|
blocks,
|
|
4159
4285
|
measures,
|
|
4160
|
-
zoom
|
|
4286
|
+
zoom,
|
|
4287
|
+
setAutocompleteText,
|
|
4288
|
+
setAutocompleteCaret
|
|
4161
4289
|
]);
|
|
4162
4290
|
const updateDirectivesOverlay = useCallback(() => {
|
|
4163
4291
|
const isCurrentRequest_2 = directivesOverlayRequestGate.begin();
|
|
@@ -4191,7 +4319,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4191
4319
|
layout,
|
|
4192
4320
|
blocks,
|
|
4193
4321
|
measures,
|
|
4194
|
-
zoom
|
|
4322
|
+
zoom,
|
|
4323
|
+
setDirectiveProjection,
|
|
4324
|
+
setDirectiveGutter
|
|
4195
4325
|
]);
|
|
4196
4326
|
const updateAISuggestionsOverlay = useCallback(() => {
|
|
4197
4327
|
const isCurrentRequest_3 = aiSuggestionsOverlayRequestGate.begin();
|
|
@@ -4229,7 +4359,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4229
4359
|
layout,
|
|
4230
4360
|
blocks,
|
|
4231
4361
|
measures,
|
|
4232
|
-
zoom
|
|
4362
|
+
zoom,
|
|
4363
|
+
setAiSuggestionRectGroups
|
|
4233
4364
|
]);
|
|
4234
4365
|
const updatePassageHighlightOverlay = useCallback(() => {
|
|
4235
4366
|
const isCurrentRequest_4 = passageHighlightOverlayRequestGate.begin();
|
|
@@ -4255,7 +4386,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4255
4386
|
layout,
|
|
4256
4387
|
blocks,
|
|
4257
4388
|
measures,
|
|
4258
|
-
zoom
|
|
4389
|
+
zoom,
|
|
4390
|
+
setPassageHighlightRects
|
|
4259
4391
|
]);
|
|
4260
4392
|
const setPassageHighlightImpl = useCallback((range_3) => {
|
|
4261
4393
|
passageHighlightRangeRef.current = range_3;
|
|
@@ -4265,11 +4397,15 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4265
4397
|
return;
|
|
4266
4398
|
}
|
|
4267
4399
|
updatePassageHighlightOverlay();
|
|
4268
|
-
}, [
|
|
4400
|
+
}, [
|
|
4401
|
+
passageHighlightOverlayRequestGate,
|
|
4402
|
+
updatePassageHighlightOverlay,
|
|
4403
|
+
setPassageHighlightRects
|
|
4404
|
+
]);
|
|
4269
4405
|
const hideSelectionOverlayDuringInput = useCallback((state_4) => {
|
|
4270
4406
|
selectionOverlayRequestGate.invalidate();
|
|
4271
4407
|
suppressSelectionOverlayRef.current = true;
|
|
4272
|
-
|
|
4408
|
+
hideSelectionOverlay(selectionOverlayRef.current);
|
|
4273
4409
|
setSelectionRects([]);
|
|
4274
4410
|
if (revealSelectionOverlayTimerRef.current !== null) window.clearTimeout(revealSelectionOverlayTimerRef.current);
|
|
4275
4411
|
revealSelectionOverlayTimerRef.current = window.setTimeout(() => {
|
|
@@ -4277,7 +4413,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4277
4413
|
suppressSelectionOverlayRef.current = false;
|
|
4278
4414
|
updateSelectionOverlay(hiddenPMRef.current?.getState() ?? state_4);
|
|
4279
4415
|
}, SELECTION_REVEAL_AFTER_INPUT_DELAY);
|
|
4280
|
-
}, [
|
|
4416
|
+
}, [
|
|
4417
|
+
selectionOverlayRequestGate,
|
|
4418
|
+
updateSelectionOverlay,
|
|
4419
|
+
setSelectionRects
|
|
4420
|
+
]);
|
|
4281
4421
|
useEffect(() => () => {
|
|
4282
4422
|
selectionOverlayRequestGate.invalidate();
|
|
4283
4423
|
anonymizationOverlayRequestGate.invalidate();
|
|
@@ -4357,6 +4497,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4357
4497
|
scheduleLayout,
|
|
4358
4498
|
scheduleDocumentChangeNotification,
|
|
4359
4499
|
hideSelectionOverlayDuringInput,
|
|
4500
|
+
setPassageHighlightRects,
|
|
4360
4501
|
updateSelectionOverlay,
|
|
4361
4502
|
updateAnonymizationOverlay,
|
|
4362
4503
|
updateAutocompleteOverlay,
|
|
@@ -4381,7 +4522,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4381
4522
|
* state; the HF blocks are pulled from the HF PM via
|
|
4382
4523
|
* `renderHfFromContentOrPm` on the next layout tick.
|
|
4383
4524
|
*/
|
|
4384
|
-
const [hfCaretSelection, setHfCaretSelection] =
|
|
4525
|
+
const [hfCaretSelection, setHfCaretSelection] = useEqualState(null);
|
|
4385
4526
|
const [previousHfEditMode, setPreviousHfEditMode] = useState(hfEditMode);
|
|
4386
4527
|
if (previousHfEditMode !== hfEditMode) {
|
|
4387
4528
|
setPreviousHfEditMode(hfEditMode);
|
|
@@ -4414,7 +4555,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4414
4555
|
scheduleLayout,
|
|
4415
4556
|
ensureHiddenEditorView,
|
|
4416
4557
|
experimentalSession,
|
|
4417
|
-
scheduleDocumentChangeNotification
|
|
4558
|
+
scheduleDocumentChangeNotification,
|
|
4559
|
+
setHfCaretSelection
|
|
4418
4560
|
]);
|
|
4419
4561
|
const handleNoteStoryTransaction = useCallback((view_4, docChanged_1, selectionChanged_0) => {
|
|
4420
4562
|
if (docChanged_1) scheduleLayout();
|
|
@@ -4428,9 +4570,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4428
4570
|
}
|
|
4429
4571
|
}, [scheduleLayout]);
|
|
4430
4572
|
const handleNoteDocumentChange = useCallback((updated) => {
|
|
4431
|
-
onDocumentChangeRef.current?.(
|
|
4432
|
-
folioEmitterRef.current.emit("docChange",
|
|
4433
|
-
}, [
|
|
4573
|
+
onDocumentChangeRef.current?.(updated);
|
|
4574
|
+
folioEmitterRef.current.emit("docChange", updated);
|
|
4575
|
+
}, []);
|
|
4434
4576
|
const dragSurfaceModeRef = useRef(hfEditMode);
|
|
4435
4577
|
useEffect(() => {
|
|
4436
4578
|
if (dragSurfaceModeRef.current === hfEditMode) return;
|
|
@@ -4468,7 +4610,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4468
4610
|
}, [
|
|
4469
4611
|
updateSelectionOverlay,
|
|
4470
4612
|
buildImageSelectionInfo,
|
|
4471
|
-
syncCoordinator
|
|
4613
|
+
syncCoordinator,
|
|
4614
|
+
setSelectionRects,
|
|
4615
|
+
setCaretPosition,
|
|
4616
|
+
setSelectedImageInfo
|
|
4472
4617
|
]);
|
|
4473
4618
|
/**
|
|
4474
4619
|
* Get PM position from mouse coordinates using DOM-based detection.
|
|
@@ -4547,7 +4692,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4547
4692
|
"layout-image",
|
|
4548
4693
|
"layout-page-floating-image"
|
|
4549
4694
|
];
|
|
4550
|
-
const isImageContainer = (el_1) =>
|
|
4695
|
+
const isImageContainer = (el_1) => hasPaintedStart(el_1) && IMAGE_CONTAINER_CLASSES.some((c) => el_1.classList.contains(c));
|
|
4551
4696
|
if (target.tagName === "IMG" && target.classList.contains("layout-run-image")) return target;
|
|
4552
4697
|
if (target.tagName === "IMG" && target.parentElement && isImageContainer(target.parentElement)) return target.parentElement;
|
|
4553
4698
|
if (isImageContainer(target)) return target;
|
|
@@ -4750,7 +4895,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4750
4895
|
target_1.classList.add("dragging");
|
|
4751
4896
|
const colIndex = Number.parseInt(target_1.dataset["columnIndex"] ?? "0", 10);
|
|
4752
4897
|
resizeColumnIndexRef.current = colIndex;
|
|
4753
|
-
resizeTablePmStartRef.current =
|
|
4898
|
+
resizeTablePmStartRef.current = readPaintedTableStart(target_1) ?? 0;
|
|
4754
4899
|
const view_10 = resizeViewForRead;
|
|
4755
4900
|
if (view_10) {
|
|
4756
4901
|
const $pos_1 = view_10.state.doc.resolve(resizeTablePmStartRef.current + 1);
|
|
@@ -4783,7 +4928,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4783
4928
|
target_1.classList.add("dragging");
|
|
4784
4929
|
const rowIndex = Number.parseInt(target_1.dataset["rowIndex"] ?? "0", 10);
|
|
4785
4930
|
resizeRowIndexRef.current = rowIndex;
|
|
4786
|
-
resizeRowTablePmStartRef.current =
|
|
4931
|
+
resizeRowTablePmStartRef.current = readPaintedTableStart(target_1) ?? 0;
|
|
4787
4932
|
const view_11 = resizeViewForRead;
|
|
4788
4933
|
if (view_11) {
|
|
4789
4934
|
const $pos_2 = view_11.state.doc.resolve(resizeRowTablePmStartRef.current + 1);
|
|
@@ -4818,7 +4963,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4818
4963
|
target_1.classList.add("dragging");
|
|
4819
4964
|
const colIndex_0 = Number.parseInt(target_1.dataset["columnIndex"] ?? "0", 10);
|
|
4820
4965
|
resizeRightEdgeColIndexRef.current = colIndex_0;
|
|
4821
|
-
resizeRightEdgePmStartRef.current =
|
|
4966
|
+
resizeRightEdgePmStartRef.current = readPaintedTableStart(target_1) ?? 0;
|
|
4822
4967
|
const view_12 = resizeViewForRead;
|
|
4823
4968
|
if (view_12) {
|
|
4824
4969
|
const $pos_3 = view_12.state.doc.resolve(resizeRightEdgePmStartRef.current + 1);
|
|
@@ -4837,9 +4982,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4837
4982
|
if (!readOnly && imageEl) {
|
|
4838
4983
|
e.preventDefault();
|
|
4839
4984
|
e.stopPropagation();
|
|
4840
|
-
const pmStart = imageEl
|
|
4985
|
+
const pmStart = readPaintedStart(imageEl);
|
|
4841
4986
|
if (pmStart !== void 0) {
|
|
4842
|
-
const pos_1 =
|
|
4987
|
+
const pos_1 = pmStart;
|
|
4843
4988
|
const hfSlot = hfEditMode ? findHfSlotForTarget(imageEl) : null;
|
|
4844
4989
|
const hfView_0 = hfSlot ? hfPMsRef.current?.getView(hfSlot.rId) : null;
|
|
4845
4990
|
if (hfView_0) {
|
|
@@ -4877,7 +5022,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4877
5022
|
queueHiddenEditorSelection,
|
|
4878
5023
|
buildImageSelectionInfo,
|
|
4879
5024
|
findImageElement,
|
|
4880
|
-
findCellPosInDoc
|
|
5025
|
+
findCellPosInDoc,
|
|
5026
|
+
setSelectionRects,
|
|
5027
|
+
setCaretPosition,
|
|
5028
|
+
setSelectedImageInfo,
|
|
5029
|
+
setTableInsertButton
|
|
4881
5030
|
]);
|
|
4882
5031
|
const { updateMousePosition: updateDragScroll, stopAutoScroll: stopDragAutoScroll } = useDragAutoScroll({
|
|
4883
5032
|
pagesContainerRef,
|
|
@@ -5018,25 +5167,29 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5018
5167
|
* Handle mouseup - end drag selection.
|
|
5019
5168
|
*/
|
|
5020
5169
|
const handleMouseUp = useCallback(() => {
|
|
5170
|
+
const runTableResize = (command) => {
|
|
5171
|
+
const surface = resizingHfSurfaceRef.current;
|
|
5172
|
+
resizingHfSurfaceRef.current = null;
|
|
5173
|
+
if (surface) {
|
|
5174
|
+
const view_13 = hfPMsRef.current?.getView(surface.rId);
|
|
5175
|
+
if (view_13) command(view_13.state, (tr) => view_13.dispatch(tr), view_13);
|
|
5176
|
+
return;
|
|
5177
|
+
}
|
|
5178
|
+
hiddenPMRef.current?.executeCommand(command);
|
|
5179
|
+
};
|
|
5021
5180
|
if (isResizingColumnRef.current) {
|
|
5022
5181
|
isResizingColumnRef.current = false;
|
|
5023
5182
|
if (resizeHandleRef.current) {
|
|
5024
5183
|
resizeHandleRef.current.classList.remove("dragging");
|
|
5025
5184
|
resizeHandleRef.current = null;
|
|
5026
5185
|
}
|
|
5027
|
-
const
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
pmStart: pmStart_0,
|
|
5035
|
-
colIdx,
|
|
5036
|
-
newLeft,
|
|
5037
|
-
newRight
|
|
5038
|
-
});
|
|
5039
|
-
}
|
|
5186
|
+
const { left: newLeft, right: newRight } = resizeOrigWidthsRef.current;
|
|
5187
|
+
runTableResize(columnResizeCommand({
|
|
5188
|
+
pmStart: resizeTablePmStartRef.current,
|
|
5189
|
+
colIdx: resizeColumnIndexRef.current,
|
|
5190
|
+
newLeft,
|
|
5191
|
+
newRight
|
|
5192
|
+
}));
|
|
5040
5193
|
return;
|
|
5041
5194
|
}
|
|
5042
5195
|
if (isResizingRowRef.current) {
|
|
@@ -5045,18 +5198,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5045
5198
|
resizeRowHandleRef.current.classList.remove("dragging");
|
|
5046
5199
|
resizeRowHandleRef.current = null;
|
|
5047
5200
|
}
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
const newHeight = resizeRowOrigHeightRef.current;
|
|
5054
|
-
commitRowResize(view_14, {
|
|
5055
|
-
pmStart: pmStart_1,
|
|
5056
|
-
rowIdx,
|
|
5057
|
-
newHeight
|
|
5058
|
-
});
|
|
5059
|
-
}
|
|
5201
|
+
runTableResize(rowResizeCommand({
|
|
5202
|
+
pmStart: resizeRowTablePmStartRef.current,
|
|
5203
|
+
rowIdx: resizeRowIndexRef.current,
|
|
5204
|
+
newHeight: resizeRowOrigHeightRef.current
|
|
5205
|
+
}));
|
|
5060
5206
|
return;
|
|
5061
5207
|
}
|
|
5062
5208
|
if (isResizingRightEdgeRef.current) {
|
|
@@ -5065,18 +5211,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5065
5211
|
resizeRightEdgeHandleRef.current.classList.remove("dragging");
|
|
5066
5212
|
resizeRightEdgeHandleRef.current = null;
|
|
5067
5213
|
}
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
const newWidth_0 = resizeRightEdgeOrigWidthRef.current;
|
|
5074
|
-
commitRightEdgeResize(view_15, {
|
|
5075
|
-
pmStart: pmStart_2,
|
|
5076
|
-
colIdx: colIdx_0,
|
|
5077
|
-
newWidth: newWidth_0
|
|
5078
|
-
});
|
|
5079
|
-
}
|
|
5214
|
+
runTableResize(rightEdgeResizeCommand({
|
|
5215
|
+
pmStart: resizeRightEdgePmStartRef.current,
|
|
5216
|
+
colIdx: resizeRightEdgeColIndexRef.current,
|
|
5217
|
+
newWidth: resizeRightEdgeOrigWidthRef.current
|
|
5218
|
+
}));
|
|
5080
5219
|
return;
|
|
5081
5220
|
}
|
|
5082
5221
|
isDraggingRef.current = false;
|
|
@@ -5162,7 +5301,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5162
5301
|
if (!viewportEl) return;
|
|
5163
5302
|
const viewportRect = viewportEl.getBoundingClientRect();
|
|
5164
5303
|
/** Extract PM position from a cell element */
|
|
5165
|
-
const getCellPmPos = (el_2) => el_2 ?
|
|
5304
|
+
const getCellPmPos = (el_2) => el_2 ? readPaintedStart(el_2) || 0 : 0;
|
|
5166
5305
|
if (nearLeftEdge) for (const row of rows) {
|
|
5167
5306
|
const rowRect = row.getBoundingClientRect();
|
|
5168
5307
|
if (mouseY >= rowRect.top && mouseY <= rowRect.bottom) {
|
|
@@ -5205,7 +5344,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5205
5344
|
}, [
|
|
5206
5345
|
readOnly,
|
|
5207
5346
|
clearTableInsertTimer,
|
|
5208
|
-
zoom
|
|
5347
|
+
zoom,
|
|
5348
|
+
setTableInsertButton
|
|
5209
5349
|
]);
|
|
5210
5350
|
/**
|
|
5211
5351
|
* Handle table insert button click — set selection to target cell, then insert.
|
|
@@ -5214,16 +5354,16 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5214
5354
|
e_2.preventDefault();
|
|
5215
5355
|
e_2.stopPropagation();
|
|
5216
5356
|
if (!tableInsertButton || !hiddenPMRef.current) return;
|
|
5217
|
-
const
|
|
5218
|
-
if (!
|
|
5357
|
+
const view_14 = hiddenPMRef.current.getView();
|
|
5358
|
+
if (!view_14) return;
|
|
5219
5359
|
const { type, cellPmPos } = tableInsertButton;
|
|
5220
|
-
const
|
|
5221
|
-
|
|
5222
|
-
if (type === "row") addRowBelow(
|
|
5223
|
-
else addColumnRight(
|
|
5360
|
+
const tr_0 = view_14.state.tr.setSelection(TextSelection$1.create(view_14.state.doc, cellPmPos + 1));
|
|
5361
|
+
view_14.dispatch(tr_0);
|
|
5362
|
+
if (type === "row") addRowBelow(view_14.state, view_14.dispatch);
|
|
5363
|
+
else addColumnRight(view_14.state, view_14.dispatch);
|
|
5224
5364
|
setTableInsertButton(null);
|
|
5225
5365
|
hiddenPMRef.current.focus();
|
|
5226
|
-
}, [tableInsertButton]);
|
|
5366
|
+
}, [tableInsertButton, setTableInsertButton]);
|
|
5227
5367
|
/**
|
|
5228
5368
|
* Handle click on pages container (for double-click word selection).
|
|
5229
5369
|
*/
|
|
@@ -5247,10 +5387,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5247
5387
|
if (href.startsWith("#")) {
|
|
5248
5388
|
const bookmarkName = href.slice(1);
|
|
5249
5389
|
if (bookmarkName && hiddenPMRef.current) {
|
|
5250
|
-
const
|
|
5251
|
-
if (
|
|
5390
|
+
const view_15 = hiddenPMRef.current.getView();
|
|
5391
|
+
if (view_15) {
|
|
5252
5392
|
const targetPos = { value: null };
|
|
5253
|
-
|
|
5393
|
+
view_15.state.doc.descendants((node_5, pos_2) => {
|
|
5254
5394
|
if (targetPos.value !== null) return false;
|
|
5255
5395
|
if (node_5.type.name === "paragraph") {
|
|
5256
5396
|
if (node_5.attrs["bookmarks"]?.some((b) => b.name === bookmarkName)) {
|
|
@@ -5339,9 +5479,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5339
5479
|
if (e_3.detail === 2 && hiddenPMRef.current) {
|
|
5340
5480
|
const pmPos_12 = getPositionFromMouse(e_3.clientX, e_3.clientY);
|
|
5341
5481
|
if (pmPos_12 !== null) {
|
|
5342
|
-
const
|
|
5343
|
-
if (
|
|
5344
|
-
const { doc: doc_0 } =
|
|
5482
|
+
const view_16 = hiddenPMRef.current.getView();
|
|
5483
|
+
if (view_16) {
|
|
5484
|
+
const { doc: doc_0 } = view_16.state;
|
|
5345
5485
|
const $pos_6 = doc_0.resolve(pmPos_12);
|
|
5346
5486
|
const parent_0 = $pos_6.parent;
|
|
5347
5487
|
if (parent_0.isTextblock) {
|
|
@@ -5367,9 +5507,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5367
5507
|
if (e_3.detail === 3 && hiddenPMRef.current) {
|
|
5368
5508
|
const pmPos_13 = getPositionFromMouse(e_3.clientX, e_3.clientY);
|
|
5369
5509
|
if (pmPos_13 !== null) {
|
|
5370
|
-
const
|
|
5371
|
-
if (
|
|
5372
|
-
const { doc: doc_1 } =
|
|
5510
|
+
const view_17 = hiddenPMRef.current.getView();
|
|
5511
|
+
if (view_17) {
|
|
5512
|
+
const { doc: doc_1 } = view_17.state;
|
|
5373
5513
|
const $pos_7 = doc_1.resolve(pmPos_13);
|
|
5374
5514
|
const paragraphStart = $pos_7.start($pos_7.depth);
|
|
5375
5515
|
const paragraphEnd = $pos_7.end($pos_7.depth);
|
|
@@ -5416,9 +5556,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5416
5556
|
}
|
|
5417
5557
|
}
|
|
5418
5558
|
}
|
|
5419
|
-
const
|
|
5420
|
-
if (!
|
|
5421
|
-
const { from: from_5, to: to_5 } =
|
|
5559
|
+
const view_18 = hiddenPMRef.current?.getView();
|
|
5560
|
+
if (!view_18) return;
|
|
5561
|
+
const { from: from_5, to: to_5 } = view_18.state.selection;
|
|
5422
5562
|
const pmPos_15 = getPositionFromMouse(e_4.clientX, e_4.clientY);
|
|
5423
5563
|
if (pmPos_15 !== null && (from_5 === to_5 || pmPos_15 < from_5 || pmPos_15 > to_5)) {
|
|
5424
5564
|
hiddenPMRef.current?.setSelection(pmPos_15);
|
|
@@ -5458,10 +5598,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5458
5598
|
/**
|
|
5459
5599
|
* Handle image resize from the overlay.
|
|
5460
5600
|
*/
|
|
5461
|
-
const handleImageResize = useCallback((pmPos_16,
|
|
5462
|
-
const
|
|
5463
|
-
if (!
|
|
5464
|
-
const committed = commitImageResize(
|
|
5601
|
+
const handleImageResize = useCallback((pmPos_16, newWidth_0, newHeight) => {
|
|
5602
|
+
const view_19 = hiddenPMRef.current?.getView();
|
|
5603
|
+
if (!view_19) return;
|
|
5604
|
+
const committed = commitImageResize(view_19, pmPos_16, newWidth_0, newHeight);
|
|
5465
5605
|
if (committed !== null) hiddenPMRef.current?.setNodeSelection(committed);
|
|
5466
5606
|
}, []);
|
|
5467
5607
|
/**
|
|
@@ -5481,10 +5621,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5481
5621
|
* to the drop position determined by mouse coordinates.
|
|
5482
5622
|
*/
|
|
5483
5623
|
const handleImageDragMove = useCallback((pmPos_17, clientX_1, clientY_1) => {
|
|
5484
|
-
const
|
|
5485
|
-
if (!
|
|
5624
|
+
const view_20 = hiddenPMRef.current?.getView();
|
|
5625
|
+
if (!view_20) return;
|
|
5486
5626
|
try {
|
|
5487
|
-
const node_8 =
|
|
5627
|
+
const node_8 = view_20.state.doc.nodeAt(pmPos_17);
|
|
5488
5628
|
if (!node_8 || node_8.type.name !== "image") return;
|
|
5489
5629
|
let committed_0 = null;
|
|
5490
5630
|
if (isFloatingImage(node_8)) {
|
|
@@ -5509,11 +5649,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5509
5649
|
const PIXELS_TO_EMU = 9525;
|
|
5510
5650
|
const hOffsetEmu = Math.round(dropX * PIXELS_TO_EMU);
|
|
5511
5651
|
const vOffsetEmu = Math.round(dropY * PIXELS_TO_EMU);
|
|
5512
|
-
committed_0 = commitImageFloatMove(
|
|
5652
|
+
committed_0 = commitImageFloatMove(view_20, pmPos_17, hOffsetEmu, vOffsetEmu);
|
|
5513
5653
|
} else {
|
|
5514
5654
|
const dropPos = getPositionFromMouse(clientX_1, clientY_1);
|
|
5515
5655
|
if (dropPos === null) return;
|
|
5516
|
-
committed_0 = commitImageInlineMove(
|
|
5656
|
+
committed_0 = commitImageInlineMove(view_20, pmPos_17, dropPos);
|
|
5517
5657
|
}
|
|
5518
5658
|
if (committed_0 !== null) hiddenPMRef.current?.setNodeSelection(committed_0);
|
|
5519
5659
|
} catch {}
|
|
@@ -5536,8 +5676,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5536
5676
|
}
|
|
5537
5677
|
if (readOnly) {
|
|
5538
5678
|
if ((e_7.metaKey || e_7.ctrlKey) && e_7.key.toLowerCase() === "a" || e_7.shiftKey && /^(?:Arrow(?:Left|Right|Up|Down)|Home|End|PageUp|PageDown)$/u.test(e_7.key)) {
|
|
5539
|
-
const
|
|
5540
|
-
if (
|
|
5679
|
+
const view_21 = hiddenPMRef.current?.getView();
|
|
5680
|
+
if (view_21?.someProp("handleKeyDown", (handler) => handler(view_21, e_7.nativeEvent)) ?? false) {
|
|
5541
5681
|
e_7.preventDefault();
|
|
5542
5682
|
return;
|
|
5543
5683
|
}
|
|
@@ -5549,11 +5689,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5549
5689
|
return;
|
|
5550
5690
|
}
|
|
5551
5691
|
if (e_7.target instanceof HTMLElement && e_7.target.closest("[data-hf-r-id], [data-note-kind][data-note-id]")) return;
|
|
5552
|
-
let
|
|
5553
|
-
if (!
|
|
5692
|
+
let view_22 = hiddenPMRef.current?.getView();
|
|
5693
|
+
if (!view_22) {
|
|
5554
5694
|
ensureHiddenEditorView({ sync: true });
|
|
5555
|
-
|
|
5556
|
-
if (
|
|
5695
|
+
view_22 = hiddenPMRef.current?.getView();
|
|
5696
|
+
if (view_22) {
|
|
5557
5697
|
if (isPlainTextInputEvent(e_7)) {
|
|
5558
5698
|
e_7.preventDefault();
|
|
5559
5699
|
queueHiddenEditorTextInput(e_7.key);
|
|
@@ -5576,7 +5716,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5576
5716
|
}
|
|
5577
5717
|
return;
|
|
5578
5718
|
}
|
|
5579
|
-
if (pendingHiddenEditorSelectionRef.current || queuedInputBeforeHiddenEditorRef.current.length > 0) applyPendingHiddenEditorInput(
|
|
5719
|
+
if (pendingHiddenEditorSelectionRef.current || queuedInputBeforeHiddenEditorRef.current.length > 0) applyPendingHiddenEditorInput(view_22);
|
|
5580
5720
|
if (!hiddenPMRef.current?.isFocused()) focusHiddenEditor();
|
|
5581
5721
|
if (["PageUp", "PageDown"].includes(e_7.key) && !e_7.metaKey && !e_7.ctrlKey) {}
|
|
5582
5722
|
if (e_7.key === "Home" && (e_7.metaKey || e_7.ctrlKey)) {
|
|
@@ -5660,20 +5800,20 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5660
5800
|
/**
|
|
5661
5801
|
* Run initial layout when document or view changes.
|
|
5662
5802
|
*/
|
|
5663
|
-
const handleEditorViewReady = useCallback((
|
|
5664
|
-
onEditorViewReadyRef.current?.(
|
|
5665
|
-
anonymizationMatchesRef.current = anonymizationDecorationsKey.getState(
|
|
5666
|
-
const initialSuggestion = autocompleteSuggestionKey.getState(
|
|
5803
|
+
const handleEditorViewReady = useCallback((view_23) => {
|
|
5804
|
+
onEditorViewReadyRef.current?.(view_23);
|
|
5805
|
+
anonymizationMatchesRef.current = anonymizationDecorationsKey.getState(view_23.state)?.matches ?? [];
|
|
5806
|
+
const initialSuggestion = autocompleteSuggestionKey.getState(view_23.state)?.suggestion;
|
|
5667
5807
|
if (initialSuggestion !== void 0) autocompleteSuggestionRef.current = initialSuggestion;
|
|
5668
5808
|
updateAutocompleteOverlay();
|
|
5669
|
-
directivesRef.current = templateDirectivesKey.getState(
|
|
5670
|
-
const previewState = templatePreviewValuesKey.getState(
|
|
5809
|
+
directivesRef.current = templateDirectivesKey.getState(view_23.state)?.ranges ?? [];
|
|
5810
|
+
const previewState = templatePreviewValuesKey.getState(view_23.state);
|
|
5671
5811
|
templatePreviewRef.current = {
|
|
5672
5812
|
entries: previewState?.entries ?? EMPTY_TEMPLATE_PREVIEW_ENTRIES,
|
|
5673
5813
|
hidden: previewState?.hidden ?? EMPTY_TEMPLATE_PREVIEW_HIDDEN,
|
|
5674
5814
|
mode: previewState?.preview?.mode ?? "plain"
|
|
5675
5815
|
};
|
|
5676
|
-
const aiState = aiSuggestionDecorationsKey.getState(
|
|
5816
|
+
const aiState = aiSuggestionDecorationsKey.getState(view_23.state);
|
|
5677
5817
|
aiSuggestionsRef.current = {
|
|
5678
5818
|
suggestions: aiState?.suggestions ?? EMPTY_AI_SUGGESTIONS,
|
|
5679
5819
|
focusedId: aiState?.focusedId ?? null
|
|
@@ -5681,17 +5821,17 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5681
5821
|
const focusReadyView = () => {
|
|
5682
5822
|
if (readOnly || !shouldFocusHiddenEditorOnReadyRef.current) return;
|
|
5683
5823
|
requestAnimationFrame(() => {
|
|
5684
|
-
if (hiddenPMRef.current?.getView() !==
|
|
5685
|
-
applyPendingHiddenEditorInput(
|
|
5686
|
-
|
|
5824
|
+
if (hiddenPMRef.current?.getView() !== view_23) return;
|
|
5825
|
+
applyPendingHiddenEditorInput(view_23);
|
|
5826
|
+
view_23.focus();
|
|
5687
5827
|
refreshBodyImeCaretAnchor();
|
|
5688
5828
|
setIsFocused(true);
|
|
5689
5829
|
});
|
|
5690
5830
|
};
|
|
5691
|
-
if (layoutSessionRef.current.lastPmDoc?.eq(
|
|
5831
|
+
if (layoutSessionRef.current.lastPmDoc?.eq(view_23.state.doc) && layoutSessionRef.current.lastMeasureInputs?.markupView === markupView && layoutSessionRef.current.lastMeasureInputs?.showCommentHighlights === (showCommentHighlights && markupView !== "no-markup" && markupView !== "original")) {
|
|
5692
5832
|
const lastPreview = layoutSessionRef.current.lastTemplatePreview;
|
|
5693
|
-
if (templatePreviewRef.current.mode !== lastPreview.mode || templatePreviewDirtyRange(lastPreview, templatePreviewRef.current) !== null) runLayoutPipeline$1(
|
|
5694
|
-
updateSelectionOverlay(
|
|
5833
|
+
if (templatePreviewRef.current.mode !== lastPreview.mode || templatePreviewDirtyRange(lastPreview, templatePreviewRef.current) !== null) runLayoutPipeline$1(view_23.state, { reason: "manual" });
|
|
5834
|
+
updateSelectionOverlay(view_23.state);
|
|
5695
5835
|
updateAnonymizationOverlay();
|
|
5696
5836
|
updateDirectivesOverlay();
|
|
5697
5837
|
updateAISuggestionsOverlay();
|
|
@@ -5710,13 +5850,13 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5710
5850
|
const runAfterFontWait_0 = () => {
|
|
5711
5851
|
pendingInitialFontReadyLayoutRef.current = false;
|
|
5712
5852
|
const currentView_0 = hiddenPMRef.current?.getView();
|
|
5713
|
-
if (currentView_0 !==
|
|
5853
|
+
if (currentView_0 !== view_23) return;
|
|
5714
5854
|
recordLayoutPhase("initial", "initial-fonts", performance.now() - fontWaitStartedAt_0);
|
|
5715
5855
|
resetCanvasContext();
|
|
5716
5856
|
clearAllCaches();
|
|
5717
5857
|
runInitialLayout(currentView_0);
|
|
5718
5858
|
};
|
|
5719
|
-
waitForInitialLayoutFonts(document,
|
|
5859
|
+
waitForInitialLayoutFonts(document, view_23.state.doc).then(runAfterFontWait_0, runAfterFontWait_0);
|
|
5720
5860
|
focusReadyView();
|
|
5721
5861
|
}, [
|
|
5722
5862
|
applyPendingHiddenEditorInput,
|
|
@@ -5775,11 +5915,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5775
5915
|
measuredFontSet: () => layoutSessionRef.current.lastMeasureInputs?.fontSet ?? null,
|
|
5776
5916
|
relayout: () => {
|
|
5777
5917
|
if (pendingInitialFontReadyLayoutRef.current) return;
|
|
5778
|
-
const
|
|
5779
|
-
const state_7 =
|
|
5918
|
+
const view_24 = hiddenPMRef.current?.getView();
|
|
5919
|
+
const state_7 = view_24?.state ?? layoutSessionRef.current.lastEditorState;
|
|
5780
5920
|
if (!state_7) return;
|
|
5781
5921
|
runLayoutPipelineRef.current(state_7, { reason: "font-ready" });
|
|
5782
|
-
if (
|
|
5922
|
+
if (view_24) runtime.updateSelection(view_24.state);
|
|
5783
5923
|
}
|
|
5784
5924
|
}), [runtime]);
|
|
5785
5925
|
const embeddedFontBuffer = document?.originalBuffer ?? null;
|
|
@@ -5795,12 +5935,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5795
5935
|
registered = faces;
|
|
5796
5936
|
if (faces.length === 0 && familyMap.size === 0) return;
|
|
5797
5937
|
layoutSessionRef.current.embeddedFontFamilyMap = new Map(familyMap);
|
|
5798
|
-
const
|
|
5799
|
-
if (!
|
|
5938
|
+
const view_25 = hiddenPMRef.current?.getView();
|
|
5939
|
+
if (!view_25) return;
|
|
5800
5940
|
resetCanvasContext();
|
|
5801
5941
|
clearAllCaches();
|
|
5802
|
-
runLayoutPipelineRef.current(
|
|
5803
|
-
runtime.updateSelection(
|
|
5942
|
+
runLayoutPipelineRef.current(view_25.state, { reason: "font-ready" });
|
|
5943
|
+
runtime.updateSelection(view_25.state);
|
|
5804
5944
|
});
|
|
5805
5945
|
return () => {
|
|
5806
5946
|
cancelled_1 = true;
|
|
@@ -5813,12 +5953,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5813
5953
|
const lifecycle = new FontFaceLifecycle(removeFontFaces);
|
|
5814
5954
|
hostFontLifecycleRef.current = lifecycle;
|
|
5815
5955
|
const remeasureForFontChange = () => {
|
|
5816
|
-
const
|
|
5817
|
-
if (!
|
|
5956
|
+
const view_26 = hiddenPMRef.current?.getView();
|
|
5957
|
+
if (!view_26) return;
|
|
5818
5958
|
resetCanvasContext();
|
|
5819
5959
|
clearAllCaches();
|
|
5820
|
-
runLayoutPipelineRef.current(
|
|
5821
|
-
runtime.updateSelection(
|
|
5960
|
+
runLayoutPipelineRef.current(view_26.state, { reason: "font-ready" });
|
|
5961
|
+
runtime.updateSelection(view_26.state);
|
|
5822
5962
|
};
|
|
5823
5963
|
const unsubscribe = lifecycle.subscribe(remeasureForFontChange);
|
|
5824
5964
|
return () => {
|
|
@@ -5917,15 +6057,15 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5917
6057
|
setIsFocused(true);
|
|
5918
6058
|
},
|
|
5919
6059
|
blur() {
|
|
5920
|
-
const
|
|
5921
|
-
if (
|
|
6060
|
+
const view_27 = getActiveEditorStory().view;
|
|
6061
|
+
if (view_27?.hasFocus() && view_27.dom instanceof HTMLElement) view_27.dom.blur();
|
|
5922
6062
|
setIsFocused(false);
|
|
5923
6063
|
},
|
|
5924
6064
|
isFocused() {
|
|
5925
6065
|
return getActiveEditorStory().view?.hasFocus() ?? false;
|
|
5926
6066
|
},
|
|
5927
|
-
dispatch(
|
|
5928
|
-
folioEditor.dispatch(
|
|
6067
|
+
dispatch(tr_1) {
|
|
6068
|
+
folioEditor.dispatch(tr_1);
|
|
5929
6069
|
},
|
|
5930
6070
|
undo() {
|
|
5931
6071
|
const target_5 = getActiveEditorStory();
|
|
@@ -5985,12 +6125,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5985
6125
|
let bestNumber = null;
|
|
5986
6126
|
let bestStart = Number.NEGATIVE_INFINITY;
|
|
5987
6127
|
for (const shell_0 of shells) {
|
|
5988
|
-
const anchors = shell_0.querySelectorAll(
|
|
6128
|
+
const anchors = shell_0.querySelectorAll(PAINTED_START_SELECTOR);
|
|
5989
6129
|
if (anchors.length === 0) continue;
|
|
5990
6130
|
let pageStart = Number.POSITIVE_INFINITY;
|
|
5991
6131
|
let pageEnd = Number.NEGATIVE_INFINITY;
|
|
5992
6132
|
for (const el_3 of anchors) {
|
|
5993
|
-
const pm =
|
|
6133
|
+
const pm = readPaintedStart(el_3) ?? NaN;
|
|
5994
6134
|
if (!Number.isFinite(pm)) continue;
|
|
5995
6135
|
if (pm < pageStart) pageStart = pm;
|
|
5996
6136
|
if (pm > pageEnd) pageEnd = pm;
|
|
@@ -6123,6 +6263,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6123
6263
|
readOnly,
|
|
6124
6264
|
onTransaction: handleHfPmTransaction,
|
|
6125
6265
|
getCanonicalApi,
|
|
6266
|
+
readCanonicalDocument,
|
|
6126
6267
|
onSessionRefusal: handleSessionRefusal,
|
|
6127
6268
|
...!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? {} : { experimentalSession },
|
|
6128
6269
|
...styles !== void 0 ? { styles } : {},
|
|
@@ -6133,6 +6274,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6133
6274
|
document,
|
|
6134
6275
|
onActiveChange: handleActiveNoteStoryChange,
|
|
6135
6276
|
getCanonicalApi,
|
|
6277
|
+
readCanonicalDocument,
|
|
6136
6278
|
onSessionRefusal: handleSessionRefusal,
|
|
6137
6279
|
...!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? {} : { experimentalSession },
|
|
6138
6280
|
onDocumentChange: handleNoteDocumentChange,
|
|
@@ -6211,7 +6353,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6211
6353
|
caretPosition: hfEditMode || noteStoryActive ? null : caretPosition,
|
|
6212
6354
|
isFocused,
|
|
6213
6355
|
pageGap,
|
|
6214
|
-
markCaretRect: true
|
|
6356
|
+
markCaretRect: true,
|
|
6357
|
+
overlayRef: selectionOverlayRef
|
|
6215
6358
|
}),
|
|
6216
6359
|
hfCaretSelection && /* @__PURE__ */ jsx(HfCaretOverlay, {
|
|
6217
6360
|
selection: hfCaretSelection,
|
|
@@ -6301,6 +6444,7 @@ function resolveCommentCreationRange({ docSize, capturedRange, currentRange, sav
|
|
|
6301
6444
|
})();
|
|
6302
6445
|
return range ? clampCommentMarkRange(docSize, range) : null;
|
|
6303
6446
|
}
|
|
6447
|
+
// src/components/commentsHelpers.ts
|
|
6304
6448
|
/** Stable empty anchor positions Map used as the initial state. */
|
|
6305
6449
|
const EMPTY_ANCHOR_POSITIONS = /* @__PURE__ */ new Map();
|
|
6306
6450
|
function getCommentAuthorKey(author) {
|
|
@@ -6318,8 +6462,8 @@ function findSelectionYPosition(scrollContainer, parentEl, pmPos) {
|
|
|
6318
6462
|
const pagesEl = scrollContainer.querySelector(".paged-editor__pages");
|
|
6319
6463
|
if (!pagesEl) return null;
|
|
6320
6464
|
for (const el of findBodyPmAnchors(pagesEl)) {
|
|
6321
|
-
const pmStart =
|
|
6322
|
-
const pmEnd =
|
|
6465
|
+
const pmStart = readPaintedStart(el) ?? NaN;
|
|
6466
|
+
const pmEnd = readPaintedEnd(el) ?? NaN;
|
|
6323
6467
|
if (pmPos >= pmStart && pmPos <= pmEnd) return el.getBoundingClientRect().top - scrollContainer.getBoundingClientRect().top + scrollContainer.scrollTop;
|
|
6324
6468
|
}
|
|
6325
6469
|
return null;
|
|
@@ -6357,9 +6501,6 @@ function createComment(text, authorName, parentId, id) {
|
|
|
6357
6501
|
...parentId !== void 0 && { parentId }
|
|
6358
6502
|
};
|
|
6359
6503
|
}
|
|
6360
|
-
function getCommentParentId(comment) {
|
|
6361
|
-
return comment.parentId;
|
|
6362
|
-
}
|
|
6363
6504
|
/**
|
|
6364
6505
|
* Threads the comments sidebar shows a card for: top-level comments not yet
|
|
6365
6506
|
* resolved. Tracked changes are painted inline and have no card, so a
|
|
@@ -6373,108 +6514,6 @@ function countOpenCommentThreads(comments) {
|
|
|
6373
6514
|
}
|
|
6374
6515
|
return count;
|
|
6375
6516
|
}
|
|
6376
|
-
function applyCommentMarkRange(view, range, commentId, options) {
|
|
6377
|
-
const commentMark = view.state.schema.marks["comment"];
|
|
6378
|
-
const safeRange = clampCommentMarkRange(view.state.doc.content.size, range);
|
|
6379
|
-
if (!commentMark || !safeRange) return false;
|
|
6380
|
-
let tr = view.state.tr;
|
|
6381
|
-
if (options?.replacePending) tr = tr.removeMark(safeRange.from, safeRange.to, commentMark.create({ commentId: -1 }));
|
|
6382
|
-
tr = tr.addMark(safeRange.from, safeRange.to, commentMark.create({ commentId }));
|
|
6383
|
-
if (options?.selectEnd) tr = tr.setSelection(Selection.near(tr.doc.resolve(safeRange.to), -1));
|
|
6384
|
-
view.dispatch(tr);
|
|
6385
|
-
return true;
|
|
6386
|
-
}
|
|
6387
|
-
/**
|
|
6388
|
-
* Walk arbitrary Folio content subtrees and collect every comment id that
|
|
6389
|
-
* is *referenced* by an inline anchor (`commentRangeStart`,
|
|
6390
|
-
* `commentRangeEnd`, or `commentReference`). Used at save time to detect
|
|
6391
|
-
* which comment threads still have something to anchor to, so that
|
|
6392
|
-
* comments whose underlying text has been edited away can be pruned
|
|
6393
|
-
* before serialization instead of being written out as phantom threads
|
|
6394
|
-
* that no Word reader can scroll to.
|
|
6395
|
-
*
|
|
6396
|
-
* Pass every part of the document that can carry anchors — comments can
|
|
6397
|
-
* live in headers, footers, footnotes, and endnotes as well as the
|
|
6398
|
-
* main body, and a save path that only checks the body would prune
|
|
6399
|
-
* legitimate header/footer/note comments.
|
|
6400
|
-
*
|
|
6401
|
-
* Uses `for (const key in obj)` instead of `Object.values(obj)` so the
|
|
6402
|
-
* recursive walk doesn't allocate a values array at every node; also
|
|
6403
|
-
* handles `Map` containers (e.g., `package.headers`) which `Object.values`
|
|
6404
|
-
* would silently skip.
|
|
6405
|
-
*/
|
|
6406
|
-
function collectCommentIdsFromSources(...sources) {
|
|
6407
|
-
const ids = /* @__PURE__ */ new Set();
|
|
6408
|
-
const visit = (node) => {
|
|
6409
|
-
if (node === null || node === void 0) return;
|
|
6410
|
-
if (Array.isArray(node)) {
|
|
6411
|
-
for (const item of node) visit(item);
|
|
6412
|
-
return;
|
|
6413
|
-
}
|
|
6414
|
-
if (node instanceof Map) {
|
|
6415
|
-
for (const value of node.values()) visit(value);
|
|
6416
|
-
return;
|
|
6417
|
-
}
|
|
6418
|
-
if (typeof node !== "object") return;
|
|
6419
|
-
const obj = node;
|
|
6420
|
-
const type = obj["type"];
|
|
6421
|
-
if ((type === "commentRangeStart" || type === "commentRangeEnd" || type === "commentReference") && typeof obj["id"] === "number") ids.add(obj["id"]);
|
|
6422
|
-
for (const key in obj) visit(obj[key]);
|
|
6423
|
-
};
|
|
6424
|
-
for (const source of sources) visit(source);
|
|
6425
|
-
return ids;
|
|
6426
|
-
}
|
|
6427
|
-
/**
|
|
6428
|
-
* Filter `comments` to drop entries whose reply chain has lost its root.
|
|
6429
|
-
*
|
|
6430
|
-
* Kept:
|
|
6431
|
-
* - every top-level comment (`parentId` is null/undefined), regardless of
|
|
6432
|
-
* whether its id appears in `referencedIds`,
|
|
6433
|
-
* - replies whose parent chain transitively reaches a kept top-level
|
|
6434
|
-
* comment.
|
|
6435
|
-
*
|
|
6436
|
-
* Dropped:
|
|
6437
|
-
* - replies whose explicit `parentId` does not reach a kept top-level
|
|
6438
|
-
* comment (a true broken-thread orphan).
|
|
6439
|
-
*
|
|
6440
|
-
* Why we don't prune unanchored top-level comments: pre-Word-2013
|
|
6441
|
-
* documents (and any document missing `commentsExtended.xml`) carry no
|
|
6442
|
-
* reply-thread metadata, so Word replies in those files arrive with
|
|
6443
|
-
* `parentId === undefined` and look indistinguishable from a true
|
|
6444
|
-
* top-level comment whose anchor has been edited away. Dropping
|
|
6445
|
-
* unanchored top-level entries would silently lose every reply in
|
|
6446
|
-
* those older files on the first save — a strictly worse failure mode
|
|
6447
|
-
* than re-emitting a comment whose anchor was actually deleted. The
|
|
6448
|
-
* complementary "overwrite stale `comments.xml`" fix in the save paths
|
|
6449
|
-
* already prevents the phantom-thread regression when the array does
|
|
6450
|
-
* end up empty.
|
|
6451
|
-
*/
|
|
6452
|
-
function pruneOrphanedComments(comments, _referencedIds) {
|
|
6453
|
-
const keptIds = /* @__PURE__ */ new Set();
|
|
6454
|
-
for (const comment of comments) {
|
|
6455
|
-
const parentId = getCommentParentId(comment);
|
|
6456
|
-
if (parentId === null || parentId === void 0) keptIds.add(comment.id);
|
|
6457
|
-
}
|
|
6458
|
-
let addedThisPass = true;
|
|
6459
|
-
while (addedThisPass) {
|
|
6460
|
-
addedThisPass = false;
|
|
6461
|
-
for (const comment of comments) {
|
|
6462
|
-
if (keptIds.has(comment.id)) continue;
|
|
6463
|
-
const parentId = getCommentParentId(comment);
|
|
6464
|
-
if (parentId !== null && parentId !== void 0 && keptIds.has(parentId)) {
|
|
6465
|
-
keptIds.add(comment.id);
|
|
6466
|
-
addedThisPass = true;
|
|
6467
|
-
}
|
|
6468
|
-
}
|
|
6469
|
-
}
|
|
6470
|
-
return comments.filter((comment) => keptIds.has(comment.id));
|
|
6471
|
-
}
|
|
6472
|
-
function removePendingCommentMarkRange(view, range) {
|
|
6473
|
-
const commentMark = view.state.schema.marks["comment"];
|
|
6474
|
-
const safeRange = clampCommentMarkRange(view.state.doc.content.size, range);
|
|
6475
|
-
if (!commentMark || !safeRange) return;
|
|
6476
|
-
view.dispatch(view.state.tr.removeMark(safeRange.from, safeRange.to, commentMark.create({ commentId: -1 })));
|
|
6477
|
-
}
|
|
6478
6517
|
// src/components/ContentControlWidgetsOverlay.tsx
|
|
6479
6518
|
/** Thin React renderer for the shared content-control widget controller. */
|
|
6480
6519
|
function ContentControlWidgetsOverlay(t0) {
|
|
@@ -6605,7 +6644,7 @@ function ContentControlWidgetsOverlay(t0) {
|
|
|
6605
6644
|
"aria-label": t11,
|
|
6606
6645
|
style,
|
|
6607
6646
|
className: "bg-popover text-popover-foreground min-w-[10rem] rounded-md border p-1 shadow-md",
|
|
6608
|
-
onPointerDown: _temp$
|
|
6647
|
+
onPointerDown: _temp$12,
|
|
6609
6648
|
children: [t12, t13]
|
|
6610
6649
|
})
|
|
6611
6650
|
}), document.body);
|
|
@@ -6617,7 +6656,7 @@ function ContentControlWidgetsOverlay(t0) {
|
|
|
6617
6656
|
} else t14 = $[31];
|
|
6618
6657
|
return t14;
|
|
6619
6658
|
}
|
|
6620
|
-
function _temp$
|
|
6659
|
+
function _temp$12(event) {
|
|
6621
6660
|
return event.stopPropagation();
|
|
6622
6661
|
}
|
|
6623
6662
|
function ContentControlDropdownItem(t0) {
|
|
@@ -6729,7 +6768,7 @@ function useFindReplace$1(hookOptions) {
|
|
|
6729
6768
|
let t6;
|
|
6730
6769
|
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
6731
6770
|
t6 = () => {
|
|
6732
|
-
setState(_temp$
|
|
6771
|
+
setState(_temp$11);
|
|
6733
6772
|
};
|
|
6734
6773
|
$[8] = t6;
|
|
6735
6774
|
} else t6 = $[8];
|
|
@@ -6737,7 +6776,7 @@ function useFindReplace$1(hookOptions) {
|
|
|
6737
6776
|
let t7;
|
|
6738
6777
|
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
6739
6778
|
t7 = () => {
|
|
6740
|
-
setState(_temp2$
|
|
6779
|
+
setState(_temp2$5);
|
|
6741
6780
|
};
|
|
6742
6781
|
$[9] = t7;
|
|
6743
6782
|
} else t7 = $[9];
|
|
@@ -6887,13 +6926,13 @@ function useFindReplace$1(hookOptions) {
|
|
|
6887
6926
|
} else t17 = $[27];
|
|
6888
6927
|
return t17;
|
|
6889
6928
|
}
|
|
6890
|
-
function _temp2$
|
|
6929
|
+
function _temp2$5(prev_2) {
|
|
6891
6930
|
return {
|
|
6892
6931
|
...prev_2,
|
|
6893
6932
|
...prev_2.dialog.status === "closed" ? openDialogState(prev_2.lastMode) : closedDialogState(prev_2.lastMode)
|
|
6894
6933
|
};
|
|
6895
6934
|
}
|
|
6896
|
-
function _temp$
|
|
6935
|
+
function _temp$11(prev_1) {
|
|
6897
6936
|
return {
|
|
6898
6937
|
...prev_1,
|
|
6899
6938
|
...closedDialogState(prev_1.lastMode)
|
|
@@ -7056,7 +7095,7 @@ const DocumentOutline = (t0) => {
|
|
|
7056
7095
|
const controlMinimumStyle = t4;
|
|
7057
7096
|
let t5;
|
|
7058
7097
|
if ($[4] !== headings) {
|
|
7059
|
-
t5 = headings.map(_temp$
|
|
7098
|
+
t5 = headings.map(_temp$10);
|
|
7060
7099
|
$[4] = headings;
|
|
7061
7100
|
$[5] = t5;
|
|
7062
7101
|
} else t5 = $[5];
|
|
@@ -7368,7 +7407,7 @@ const DocumentOutline = (t0) => {
|
|
|
7368
7407
|
} else t30 = $[92];
|
|
7369
7408
|
return t30;
|
|
7370
7409
|
};
|
|
7371
|
-
function _temp$
|
|
7410
|
+
function _temp$10(heading) {
|
|
7372
7411
|
const item = {
|
|
7373
7412
|
id: heading.id,
|
|
7374
7413
|
label: heading.text,
|
|
@@ -7765,7 +7804,7 @@ function NotificationContainer(t0) {
|
|
|
7765
7804
|
if ($[0] !== notifications || $[1] !== onDismiss) {
|
|
7766
7805
|
t3 = Symbol.for("react.early_return_sentinel");
|
|
7767
7806
|
bb0: {
|
|
7768
|
-
const visibleNotifications = notifications.filter(_temp$
|
|
7807
|
+
const visibleNotifications = notifications.filter(_temp$9);
|
|
7769
7808
|
if (visibleNotifications.length === 0) {
|
|
7770
7809
|
t3 = null;
|
|
7771
7810
|
break bb0;
|
|
@@ -7805,7 +7844,7 @@ function NotificationContainer(t0) {
|
|
|
7805
7844
|
} else t4 = $[9];
|
|
7806
7845
|
return t4;
|
|
7807
7846
|
}
|
|
7808
|
-
function _temp$
|
|
7847
|
+
function _temp$9(n) {
|
|
7809
7848
|
return !n.dismissed;
|
|
7810
7849
|
}
|
|
7811
7850
|
const SEVERITY_STYLES = {
|
|
@@ -8245,7 +8284,7 @@ function AlignmentButtons({ value = "left", onChange, disabled = false }) {
|
|
|
8245
8284
|
function AlignmentOption(t0) {
|
|
8246
8285
|
const $ = c(16);
|
|
8247
8286
|
const { PopoverClose, option, selected, onChange } = t0;
|
|
8248
|
-
const handleMouseDown = _temp$
|
|
8287
|
+
const handleMouseDown = _temp$8;
|
|
8249
8288
|
let t1;
|
|
8250
8289
|
if ($[0] !== onChange || $[1] !== option.value) {
|
|
8251
8290
|
t1 = () => onChange?.(option.value);
|
|
@@ -8299,7 +8338,7 @@ function AlignmentOption(t0) {
|
|
|
8299
8338
|
} else t8 = $[15];
|
|
8300
8339
|
return t8;
|
|
8301
8340
|
}
|
|
8302
|
-
function _temp$
|
|
8341
|
+
function _temp$8(event) {
|
|
8303
8342
|
return event.preventDefault();
|
|
8304
8343
|
}
|
|
8305
8344
|
// src/components/ui/FontPicker.tsx
|
|
@@ -9513,14 +9552,14 @@ const useActiveHeading = (container, headings) => {
|
|
|
9513
9552
|
const threshold = container.scrollTop + container.clientHeight / 2;
|
|
9514
9553
|
const offsets = [];
|
|
9515
9554
|
for (const el of anchors) {
|
|
9516
|
-
const pm =
|
|
9555
|
+
const pm = readPaintedStart(el) ?? NaN;
|
|
9517
9556
|
if (!Number.isFinite(pm)) continue;
|
|
9518
9557
|
offsets.push({
|
|
9519
9558
|
pm,
|
|
9520
9559
|
top: el.getBoundingClientRect().top - containerTop + container.scrollTop
|
|
9521
9560
|
});
|
|
9522
9561
|
}
|
|
9523
|
-
offsets.sort(_temp$
|
|
9562
|
+
offsets.sort(_temp$7);
|
|
9524
9563
|
let next = null;
|
|
9525
9564
|
for (const heading of headings) {
|
|
9526
9565
|
const candidate = offsets.find((offset) => offset.pm >= heading.pmPos);
|
|
@@ -9570,7 +9609,7 @@ const useActiveHeading = (container, headings) => {
|
|
|
9570
9609
|
} else t3 = $[6];
|
|
9571
9610
|
return t3;
|
|
9572
9611
|
};
|
|
9573
|
-
function _temp$
|
|
9612
|
+
function _temp$7(a, b) {
|
|
9574
9613
|
return a.pm - b.pm;
|
|
9575
9614
|
}
|
|
9576
9615
|
// src/components/selectionDetection.ts
|
|
@@ -9616,17 +9655,8 @@ function detectImageContext(state) {
|
|
|
9616
9655
|
function detectActiveTrackedChange(state) {
|
|
9617
9656
|
const { from } = state.selection;
|
|
9618
9657
|
const $pos = state.doc.resolve(from);
|
|
9619
|
-
const
|
|
9620
|
-
|
|
9621
|
-
let childOffset = 0;
|
|
9622
|
-
for (let index = 0; index < node.childCount; index += 1) {
|
|
9623
|
-
const child = node.child(index);
|
|
9624
|
-
const childStart = $pos.start() + childOffset;
|
|
9625
|
-
const childEnd = childStart + child.nodeSize;
|
|
9626
|
-
if (from < childStart || from > childEnd || !child.isText) {
|
|
9627
|
-
childOffset += child.nodeSize;
|
|
9628
|
-
continue;
|
|
9629
|
-
}
|
|
9658
|
+
for (const child of [$pos.nodeBefore, $pos.nodeAfter]) {
|
|
9659
|
+
if (!child?.isText) continue;
|
|
9630
9660
|
for (const mark of child.marks) {
|
|
9631
9661
|
if (mark.type.name !== "insertion" && mark.type.name !== "deletion") continue;
|
|
9632
9662
|
const range = findChangeAtPosition(state, from, from);
|
|
@@ -9635,10 +9665,10 @@ function detectActiveTrackedChange(state) {
|
|
|
9635
9665
|
author: mark.attrs["author"] || "Unknown",
|
|
9636
9666
|
date: mark.attrs["date"] || null,
|
|
9637
9667
|
from: range.from,
|
|
9638
|
-
to: range.to
|
|
9668
|
+
to: range.to,
|
|
9669
|
+
heldByLock: heldByLock(state, range)
|
|
9639
9670
|
};
|
|
9640
9671
|
}
|
|
9641
|
-
childOffset += child.nodeSize;
|
|
9642
9672
|
}
|
|
9643
9673
|
const paragraphChange = findParagraphBoundaryChangeAtPosition(state, from);
|
|
9644
9674
|
if (!paragraphChange) return null;
|
|
@@ -9647,9 +9677,21 @@ function detectActiveTrackedChange(state) {
|
|
|
9647
9677
|
author: paragraphChange.author || "Unknown",
|
|
9648
9678
|
date: paragraphChange.date || null,
|
|
9649
9679
|
from: paragraphChange.from,
|
|
9650
|
-
to: paragraphChange.to
|
|
9680
|
+
to: paragraphChange.to,
|
|
9681
|
+
heldByLock: heldByLock(state, paragraphChange)
|
|
9651
9682
|
};
|
|
9652
9683
|
}
|
|
9684
|
+
/** What the content-control locks say about resolving the changes in `range`. */
|
|
9685
|
+
const heldByLock = (state, range) => ({
|
|
9686
|
+
accept: changeResolutionLockViolation(state, {
|
|
9687
|
+
...range,
|
|
9688
|
+
mode: "accept"
|
|
9689
|
+
}) !== null,
|
|
9690
|
+
reject: changeResolutionLockViolation(state, {
|
|
9691
|
+
...range,
|
|
9692
|
+
mode: "reject"
|
|
9693
|
+
}) !== null
|
|
9694
|
+
});
|
|
9653
9695
|
// src/components/hooks/useContextMenu.ts
|
|
9654
9696
|
function useContextMenu(t0) {
|
|
9655
9697
|
const $ = c(7);
|
|
@@ -10765,8 +10807,8 @@ const useHyperlinkHandlers = (t0) => {
|
|
|
10765
10807
|
$[0] = t1;
|
|
10766
10808
|
} else t1 = $[0];
|
|
10767
10809
|
const handleHyperlinkClick = t1;
|
|
10768
|
-
const handleHyperlinkPopupNavigate = _temp$
|
|
10769
|
-
const handleHyperlinkPopupCopy = _temp2$
|
|
10810
|
+
const handleHyperlinkPopupNavigate = _temp$6;
|
|
10811
|
+
const handleHyperlinkPopupCopy = _temp2$4;
|
|
10770
10812
|
let t2;
|
|
10771
10813
|
if ($[1] !== focusActiveEditor || $[2] !== getActiveEditorView) {
|
|
10772
10814
|
t2 = (displayText, href_1) => {
|
|
@@ -10827,14 +10869,14 @@ const useHyperlinkHandlers = (t0) => {
|
|
|
10827
10869
|
} else t5 = $[12];
|
|
10828
10870
|
return t5;
|
|
10829
10871
|
};
|
|
10830
|
-
function _temp$
|
|
10872
|
+
function _temp$6(href) {
|
|
10831
10873
|
const safeHref = sanitizeExternalUrl(href);
|
|
10832
10874
|
if (safeHref) {
|
|
10833
10875
|
const anchor = anchorTargetAttrs(void 0);
|
|
10834
10876
|
window.open(safeHref, anchor.target, windowFeaturesFor(anchor));
|
|
10835
10877
|
}
|
|
10836
10878
|
}
|
|
10837
|
-
function _temp2$
|
|
10879
|
+
function _temp2$4(href_0) {
|
|
10838
10880
|
navigator.clipboard.writeText(href_0);
|
|
10839
10881
|
}
|
|
10840
10882
|
// src/components/hooks/useImageHandlers.ts
|
|
@@ -10850,7 +10892,7 @@ const useImageHandlers = (t0) => {
|
|
|
10850
10892
|
if (!file) return;
|
|
10851
10893
|
const view = getActiveEditorView();
|
|
10852
10894
|
if (!view) return;
|
|
10853
|
-
insertImageFromFile(view, file, focusActiveEditor).catch(_temp$
|
|
10895
|
+
insertImageFromFile(view, file, focusActiveEditor).catch(_temp$5);
|
|
10854
10896
|
e.target.value = "";
|
|
10855
10897
|
};
|
|
10856
10898
|
$[0] = focusActiveEditor;
|
|
@@ -10943,7 +10985,7 @@ const useImageHandlers = (t0) => {
|
|
|
10943
10985
|
} else t7 = $[27];
|
|
10944
10986
|
return t7;
|
|
10945
10987
|
};
|
|
10946
|
-
function _temp$
|
|
10988
|
+
function _temp$5() {}
|
|
10947
10989
|
// src/components/hooks/useKeyboardShortcuts.ts
|
|
10948
10990
|
/**
|
|
10949
10991
|
* Page-level keyboard shortcuts:
|
|
@@ -11023,7 +11065,7 @@ function useKeyboardShortcuts(t0) {
|
|
|
11023
11065
|
const handleKeyDown = (e_0) => {
|
|
11024
11066
|
if (!isKeydownInShortcutScope(e_0, {
|
|
11025
11067
|
scope,
|
|
11026
|
-
roots: callbacksRef.current.roots.map(_temp$
|
|
11068
|
+
roots: callbacksRef.current.roots.map(_temp$4)
|
|
11027
11069
|
})) return;
|
|
11028
11070
|
const editorDom = pagedEditorRef.current?.getView()?.dom;
|
|
11029
11071
|
switch (classifyEditorKeydown(e_0, {
|
|
@@ -11061,7 +11103,7 @@ function useKeyboardShortcuts(t0) {
|
|
|
11061
11103
|
}
|
|
11062
11104
|
useEffect(t3, t4);
|
|
11063
11105
|
}
|
|
11064
|
-
function _temp$
|
|
11106
|
+
function _temp$4(root) {
|
|
11065
11107
|
return root.current;
|
|
11066
11108
|
}
|
|
11067
11109
|
// src/components/hooks/usePanelLayout.ts
|
|
@@ -11177,7 +11219,7 @@ function useZoomAndPageInfo(t0) {
|
|
|
11177
11219
|
t2 = () => {
|
|
11178
11220
|
if (scrollFadeTimerRef.current) clearTimeout(scrollFadeTimerRef.current);
|
|
11179
11221
|
scrollFadeTimerRef.current = setTimeout(() => {
|
|
11180
|
-
setScrollPageInfo(_temp$
|
|
11222
|
+
setScrollPageInfo(_temp$3);
|
|
11181
11223
|
}, PAGE_INFO_FADE_MS);
|
|
11182
11224
|
};
|
|
11183
11225
|
$[1] = t2;
|
|
@@ -11189,7 +11231,7 @@ function useZoomAndPageInfo(t0) {
|
|
|
11189
11231
|
const layout = pagedEditorRef.current?.getLayout();
|
|
11190
11232
|
if (!layout) return;
|
|
11191
11233
|
const info = computeScrollPageInfo({
|
|
11192
|
-
pageHeights: layout.pages.map(_temp2$
|
|
11234
|
+
pageHeights: layout.pages.map(_temp2$3),
|
|
11193
11235
|
scrollTop: scrollContainer.scrollTop,
|
|
11194
11236
|
clientHeight: scrollContainer.clientHeight,
|
|
11195
11237
|
zoom: zoomRef.current,
|
|
@@ -11374,10 +11416,10 @@ function useZoomAndPageInfo(t0) {
|
|
|
11374
11416
|
} else t13 = $[28];
|
|
11375
11417
|
return t13;
|
|
11376
11418
|
}
|
|
11377
|
-
function _temp2$
|
|
11419
|
+
function _temp2$3(page) {
|
|
11378
11420
|
return page.size.h;
|
|
11379
11421
|
}
|
|
11380
|
-
function _temp$
|
|
11422
|
+
function _temp$3(prev) {
|
|
11381
11423
|
return {
|
|
11382
11424
|
...prev,
|
|
11383
11425
|
visible: false
|
|
@@ -11427,15 +11469,26 @@ const labelStyle = {
|
|
|
11427
11469
|
fontWeight: 500,
|
|
11428
11470
|
letterSpacing: .3
|
|
11429
11471
|
};
|
|
11430
|
-
const InlineHeaderFooterEditor = forwardRef(function InlineHeaderFooterEditor({ position,
|
|
11472
|
+
const InlineHeaderFooterEditor = forwardRef(function InlineHeaderFooterEditor({ position, targetSelector, parentElement, getActiveView, onClose, onRemove }, ref) {
|
|
11431
11473
|
const t = useTranslations("folio");
|
|
11432
11474
|
const [showOptions, setShowOptions] = useState(false);
|
|
11433
11475
|
const optionsRef = useRef(null);
|
|
11434
|
-
const [overlayPos, setOverlayPos] =
|
|
11476
|
+
const [overlayPos, setOverlayPos] = useEqualState(null);
|
|
11435
11477
|
useEffect(() => {
|
|
11478
|
+
let observed = null;
|
|
11479
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
11480
|
+
computePosition();
|
|
11481
|
+
});
|
|
11436
11482
|
const computePosition = () => {
|
|
11483
|
+
const target = parentElement.querySelector(targetSelector);
|
|
11484
|
+
if (target !== observed) {
|
|
11485
|
+
if (observed !== null) resizeObserver.unobserve(observed);
|
|
11486
|
+
if (target !== null) resizeObserver.observe(target);
|
|
11487
|
+
observed = target;
|
|
11488
|
+
}
|
|
11489
|
+
if (target === null) return;
|
|
11437
11490
|
const parentRect = parentElement.getBoundingClientRect();
|
|
11438
|
-
const targetRect =
|
|
11491
|
+
const targetRect = target.getBoundingClientRect();
|
|
11439
11492
|
setOverlayPos({
|
|
11440
11493
|
top: targetRect.top - parentRect.top + parentElement.scrollTop,
|
|
11441
11494
|
left: targetRect.left - parentRect.left + parentElement.scrollLeft,
|
|
@@ -11444,17 +11497,21 @@ const InlineHeaderFooterEditor = forwardRef(function InlineHeaderFooterEditor({
|
|
|
11444
11497
|
});
|
|
11445
11498
|
};
|
|
11446
11499
|
computePosition();
|
|
11447
|
-
|
|
11448
|
-
resizeObserver.observe(targetElement);
|
|
11500
|
+
parentElement.addEventListener(PAINTER_PAINTED_EVENT, computePosition);
|
|
11449
11501
|
const scrollParent = parentElement.closest("[style*=\"overflow\"]") || parentElement;
|
|
11450
11502
|
scrollParent.addEventListener("scroll", computePosition);
|
|
11451
11503
|
window.addEventListener("resize", computePosition);
|
|
11452
11504
|
return () => {
|
|
11453
11505
|
resizeObserver.disconnect();
|
|
11506
|
+
parentElement.removeEventListener(PAINTER_PAINTED_EVENT, computePosition);
|
|
11454
11507
|
scrollParent.removeEventListener("scroll", computePosition);
|
|
11455
11508
|
window.removeEventListener("resize", computePosition);
|
|
11456
11509
|
};
|
|
11457
|
-
}, [
|
|
11510
|
+
}, [
|
|
11511
|
+
parentElement,
|
|
11512
|
+
targetSelector,
|
|
11513
|
+
setOverlayPos
|
|
11514
|
+
]);
|
|
11458
11515
|
const getActiveViewRef = useRef(getActiveView);
|
|
11459
11516
|
useLayoutEffect(() => {
|
|
11460
11517
|
getActiveViewRef.current = getActiveView;
|
|
@@ -11592,7 +11649,7 @@ function OptionsMenu(t0) {
|
|
|
11592
11649
|
if ($[3] !== setShowOptions) {
|
|
11593
11650
|
t3 = (e) => {
|
|
11594
11651
|
e.stopPropagation();
|
|
11595
|
-
setShowOptions(_temp$
|
|
11652
|
+
setShowOptions(_temp$2);
|
|
11596
11653
|
};
|
|
11597
11654
|
$[3] = setShowOptions;
|
|
11598
11655
|
$[4] = t3;
|
|
@@ -11609,7 +11666,7 @@ function OptionsMenu(t0) {
|
|
|
11609
11666
|
type: "button",
|
|
11610
11667
|
className: "hf-options-button",
|
|
11611
11668
|
onClick: t3,
|
|
11612
|
-
onMouseDown: _temp2$
|
|
11669
|
+
onMouseDown: _temp2$2,
|
|
11613
11670
|
children: [t4, " ▾"]
|
|
11614
11671
|
});
|
|
11615
11672
|
$[7] = t3;
|
|
@@ -11683,10 +11740,10 @@ function OptionsMenu(t0) {
|
|
|
11683
11740
|
} else t7 = $[21];
|
|
11684
11741
|
return t7;
|
|
11685
11742
|
}
|
|
11686
|
-
function _temp2$
|
|
11743
|
+
function _temp2$2(e_0) {
|
|
11687
11744
|
return e_0.stopPropagation();
|
|
11688
11745
|
}
|
|
11689
|
-
function _temp$
|
|
11746
|
+
function _temp$2(prev) {
|
|
11690
11747
|
return !prev;
|
|
11691
11748
|
}
|
|
11692
11749
|
// src/components/toolbarUtils.ts
|
|
@@ -11823,7 +11880,7 @@ function PanelToggles(t0) {
|
|
|
11823
11880
|
className: t5,
|
|
11824
11881
|
"data-testid": "toolbar-comments-toggle",
|
|
11825
11882
|
onClick: onToggleComments,
|
|
11826
|
-
onMouseDown: _temp2$
|
|
11883
|
+
onMouseDown: _temp2$1,
|
|
11827
11884
|
title: commentsLabel,
|
|
11828
11885
|
type: "button",
|
|
11829
11886
|
children: [
|
|
@@ -11844,7 +11901,7 @@ function PanelToggles(t0) {
|
|
|
11844
11901
|
if ($[24] !== t3 || $[25] !== t9) {
|
|
11845
11902
|
t10 = /* @__PURE__ */ jsxs("div", {
|
|
11846
11903
|
className: "flex shrink-0 items-center gap-0.5",
|
|
11847
|
-
onMouseUp: _temp$
|
|
11904
|
+
onMouseUp: _temp$1,
|
|
11848
11905
|
children: [t3, t9]
|
|
11849
11906
|
});
|
|
11850
11907
|
$[24] = t3;
|
|
@@ -11853,10 +11910,10 @@ function PanelToggles(t0) {
|
|
|
11853
11910
|
} else t10 = $[26];
|
|
11854
11911
|
return t10;
|
|
11855
11912
|
}
|
|
11856
|
-
function _temp2$
|
|
11913
|
+
function _temp2$1(event_0) {
|
|
11857
11914
|
return event_0.preventDefault();
|
|
11858
11915
|
}
|
|
11859
|
-
function _temp$
|
|
11916
|
+
function _temp$1(event) {
|
|
11860
11917
|
return event.stopPropagation();
|
|
11861
11918
|
}
|
|
11862
11919
|
// src/components/selectionFormattingBuilder.ts
|
|
@@ -12649,7 +12706,7 @@ function HyperlinkPopupContent(t0) {
|
|
|
12649
12706
|
if (mode === "edit") {
|
|
12650
12707
|
let t11;
|
|
12651
12708
|
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
12652
|
-
t11 = containedHandler(_temp
|
|
12709
|
+
t11 = containedHandler(_temp);
|
|
12653
12710
|
$[22] = t11;
|
|
12654
12711
|
} else t11 = $[22];
|
|
12655
12712
|
let t12;
|
|
@@ -12781,7 +12838,7 @@ function HyperlinkPopupContent(t0) {
|
|
|
12781
12838
|
}
|
|
12782
12839
|
let t11;
|
|
12783
12840
|
if ($[54] === Symbol.for("react.memo_cache_sentinel")) {
|
|
12784
|
-
t11 = containedHandler(_temp2
|
|
12841
|
+
t11 = containedHandler(_temp2);
|
|
12785
12842
|
$[54] = t11;
|
|
12786
12843
|
} else t11 = $[54];
|
|
12787
12844
|
let t12;
|
|
@@ -12915,10 +12972,10 @@ function HyperlinkPopupContent(t0) {
|
|
|
12915
12972
|
} else t24 = $[86];
|
|
12916
12973
|
return t24;
|
|
12917
12974
|
}
|
|
12918
|
-
function _temp2
|
|
12975
|
+
function _temp2(e_4) {
|
|
12919
12976
|
return e_4.stopPropagation();
|
|
12920
12977
|
}
|
|
12921
|
-
function _temp
|
|
12978
|
+
function _temp(e_1) {
|
|
12922
12979
|
return e_1.stopPropagation();
|
|
12923
12980
|
}
|
|
12924
12981
|
// src/components/ui/table-styles.ts
|
|
@@ -13667,137 +13724,112 @@ function sanitizeControlledComments(comments) {
|
|
|
13667
13724
|
}
|
|
13668
13725
|
return sanitized;
|
|
13669
13726
|
}
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13727
|
+
/** The records as the list the hook hands out, copied once per change. */
|
|
13728
|
+
const listOf = (records) => [...records];
|
|
13729
|
+
function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorContentRef, commentsProp, onCommentsChange, committedComments, bodyView = null }) {
|
|
13673
13730
|
const [showCommentsSidebar, setShowCommentsSidebar] = useState(false);
|
|
13674
13731
|
const [visibleCommentAuthors, setVisibleCommentAuthors] = useState(null);
|
|
13675
13732
|
const [activeCommentId, setActiveCommentId] = useState(null);
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
t1 = [];
|
|
13679
|
-
$[0] = t1;
|
|
13680
|
-
} else t1 = $[0];
|
|
13681
|
-
const [internalComments, setInternalComments] = useState(t1);
|
|
13682
|
-
let t2;
|
|
13683
|
-
if ($[1] !== commentsProp) {
|
|
13684
|
-
t2 = commentsProp !== void 0 ? sanitizeControlledComments(commentsProp) : void 0;
|
|
13685
|
-
$[1] = commentsProp;
|
|
13686
|
-
$[2] = t2;
|
|
13687
|
-
} else t2 = $[2];
|
|
13688
|
-
const sanitizedCommentsProp = t2;
|
|
13733
|
+
const [internalComments, setInternalComments] = useState([]);
|
|
13734
|
+
const sanitizedCommentsProp = useMemo(() => commentsProp !== void 0 ? sanitizeControlledComments(commentsProp) : void 0, [commentsProp]);
|
|
13689
13735
|
const commentsMode = sanitizedCommentsProp === void 0 ? "uncontrolled" : "controlled";
|
|
13736
|
+
const commentsModeRef = useRef(commentsMode);
|
|
13737
|
+
useLayoutEffect(() => {
|
|
13738
|
+
commentsModeRef.current = commentsMode;
|
|
13739
|
+
}, [commentsMode]);
|
|
13690
13740
|
const isControlledComments = commentsMode === "controlled";
|
|
13691
|
-
const
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
};
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
$[5] = t3;
|
|
13701
|
-
} else t3 = $[5];
|
|
13702
|
-
let t4;
|
|
13703
|
-
if ($[6] !== comments || $[7] !== doc) {
|
|
13704
|
-
t4 = [comments, doc];
|
|
13705
|
-
$[6] = comments;
|
|
13706
|
-
$[7] = doc;
|
|
13707
|
-
$[8] = t4;
|
|
13708
|
-
} else t4 = $[8];
|
|
13709
|
-
useLayoutEffect(t3, t4);
|
|
13741
|
+
const subscribeRecords = useCallback((notify) => bodyView ? subscribeCommentRecords(bodyView, notify) : () => void 0, [bodyView]);
|
|
13742
|
+
const readRecords = useCallback(() => bodyView ? commentRecordsOf(bodyView.state) : null, [bodyView]);
|
|
13743
|
+
const recordsSnapshot = useSyncExternalStore(subscribeRecords, readRecords, readRecords);
|
|
13744
|
+
const records = useMemo(() => recordsSnapshot === null ? null : listOf(recordsSnapshot), [recordsSnapshot]);
|
|
13745
|
+
const comments = sanitizedCommentsProp ?? records ?? internalComments;
|
|
13746
|
+
useLayoutEffect(() => {
|
|
13747
|
+
for (const { id } of doc?.package.document.comments ?? []) seedCommentIdAbove(id);
|
|
13748
|
+
for (const { id: id_0 } of comments) seedCommentIdAbove(id_0);
|
|
13749
|
+
}, [comments, doc]);
|
|
13710
13750
|
const commentsDirtyRef = useRef(false);
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
} else t5 = $[9];
|
|
13716
|
-
const getCommentsDirty = t5;
|
|
13717
|
-
let t6;
|
|
13718
|
-
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
13719
|
-
t6 = (dirty) => {
|
|
13720
|
-
commentsDirtyRef.current = dirty;
|
|
13721
|
-
};
|
|
13722
|
-
$[10] = t6;
|
|
13723
|
-
} else t6 = $[10];
|
|
13724
|
-
const setCommentsDirty = t6;
|
|
13751
|
+
const getCommentsDirty = useCallback(() => commentsDirtyRef.current, []);
|
|
13752
|
+
const setCommentsDirty = useCallback((dirty) => {
|
|
13753
|
+
commentsDirtyRef.current = dirty;
|
|
13754
|
+
}, []);
|
|
13725
13755
|
const commentsRef = useRef(comments);
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
t7 = () => {
|
|
13730
|
-
commentsRef.current = comments;
|
|
13731
|
-
};
|
|
13732
|
-
t8 = [comments];
|
|
13733
|
-
$[11] = comments;
|
|
13734
|
-
$[12] = t7;
|
|
13735
|
-
$[13] = t8;
|
|
13736
|
-
} else {
|
|
13737
|
-
t7 = $[12];
|
|
13738
|
-
t8 = $[13];
|
|
13739
|
-
}
|
|
13740
|
-
useLayoutEffect(t7, t8);
|
|
13756
|
+
useLayoutEffect(() => {
|
|
13757
|
+
commentsRef.current = comments;
|
|
13758
|
+
}, [comments]);
|
|
13741
13759
|
const readonlyCommentsRef = commentsRef;
|
|
13742
13760
|
const onCommentsChangeRef = useRef(onCommentsChange);
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13761
|
+
useLayoutEffect(() => {
|
|
13762
|
+
onCommentsChangeRef.current = onCommentsChange;
|
|
13763
|
+
}, [onCommentsChange]);
|
|
13764
|
+
const bodyViewRef = useRef(bodyView);
|
|
13765
|
+
useLayoutEffect(() => {
|
|
13766
|
+
bodyViewRef.current = bodyView;
|
|
13767
|
+
}, [bodyView]);
|
|
13768
|
+
useLayoutEffect(() => {
|
|
13769
|
+
if (!bodyView) return;
|
|
13770
|
+
return subscribeCommentRecords(bodyView, (next, origin) => {
|
|
13771
|
+
if (next === null) return;
|
|
13772
|
+
const list = listOf(next);
|
|
13773
|
+
for (const { id: id_1 } of list) seedCommentIdAbove(id_1);
|
|
13774
|
+
if (commentsModeRef.current === "uncontrolled") commentsRef.current = list;
|
|
13775
|
+
if (origin === "sync") return;
|
|
13776
|
+
commentsDirtyRef.current = true;
|
|
13777
|
+
onCommentsChangeRef.current?.(list);
|
|
13778
|
+
});
|
|
13779
|
+
}, [bodyView]);
|
|
13780
|
+
const comparedRef = useRef(null);
|
|
13781
|
+
useLayoutEffect(() => {
|
|
13782
|
+
if (!bodyView || sanitizedCommentsProp === void 0 || records === null) {
|
|
13783
|
+
comparedRef.current = null;
|
|
13784
|
+
return;
|
|
13785
|
+
}
|
|
13786
|
+
const compared = comparedRef.current;
|
|
13787
|
+
if (compared?.prop === sanitizedCommentsProp && compared.records === records) return;
|
|
13788
|
+
comparedRef.current = {
|
|
13789
|
+
prop: sanitizedCommentsProp,
|
|
13790
|
+
records
|
|
13764
13791
|
};
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13792
|
+
if (JSON.stringify(records) === JSON.stringify(sanitizedCommentsProp)) return;
|
|
13793
|
+
const transaction = syncCommentRecords(bodyView.state, sanitizedCommentsProp);
|
|
13794
|
+
if (transaction) bodyView.dispatch(transaction);
|
|
13795
|
+
});
|
|
13796
|
+
const createComment$1 = useCallback((text, author, parentId) => {
|
|
13797
|
+
for (const { id: id_2 } of doc?.package.document.comments ?? []) seedCommentIdAbove(id_2);
|
|
13798
|
+
for (const { id: id_3 } of commentsRef.current) seedCommentIdAbove(id_3);
|
|
13799
|
+
return createComment(text, author, parentId);
|
|
13800
|
+
}, [doc]);
|
|
13801
|
+
const setComments = useCallback((next_0) => {
|
|
13802
|
+
const resolved = typeof next_0 === "function" ? next_0(commentsRef.current) : next_0;
|
|
13803
|
+
if (resolved === commentsRef.current) return;
|
|
13804
|
+
const view = bodyViewRef.current;
|
|
13805
|
+
if (view && commentRecordsOf(view.state) !== null) {
|
|
13806
|
+
const transaction_0 = editCommentRecords(view.state, resolved);
|
|
13807
|
+
if (transaction_0) view.dispatch(transaction_0);
|
|
13808
|
+
return;
|
|
13809
|
+
}
|
|
13810
|
+
switch (commentsMode) {
|
|
13811
|
+
case "controlled": break;
|
|
13812
|
+
case "uncontrolled":
|
|
13813
|
+
for (const { id: id_4 } of resolved) seedCommentIdAbove(id_4);
|
|
13814
|
+
commentsRef.current = resolved;
|
|
13815
|
+
setInternalComments(resolved);
|
|
13816
|
+
break;
|
|
13817
|
+
default: return commentsMode;
|
|
13818
|
+
}
|
|
13819
|
+
onCommentsChangeRef.current?.(resolved);
|
|
13820
|
+
}, [commentsMode]);
|
|
13789
13821
|
const [isAddingComment, setIsAddingComment] = useState(false);
|
|
13790
|
-
const [commentSelectionRange, setCommentSelectionRange] =
|
|
13822
|
+
const [commentSelectionRange, setCommentSelectionRange] = useEqualState(null);
|
|
13791
13823
|
const [addCommentYPosition, setAddCommentYPosition] = useState(null);
|
|
13792
|
-
const [floatingCommentBtn, setFloatingCommentBtn] =
|
|
13824
|
+
const [floatingCommentBtn, setFloatingCommentBtn] = useEqualState(null);
|
|
13793
13825
|
const [commentsLoaded, setCommentsLoaded] = useState(false);
|
|
13794
13826
|
const [loadedCommentsNotification, setLoadedCommentsNotification] = useState(null);
|
|
13795
|
-
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13827
|
+
const resetLoadedComments = useCallback(() => setCommentsLoaded(false), []);
|
|
13828
|
+
/** Forget the list for a document about to load; its state brings its own. */
|
|
13829
|
+
const resetComments = useCallback(() => {
|
|
13830
|
+
commentsRef.current = [];
|
|
13831
|
+
setInternalComments([]);
|
|
13832
|
+
}, []);
|
|
13801
13833
|
const bodyComments = committedComments ?? doc?.package.document.comments;
|
|
13802
13834
|
if (!commentsLoaded && !(committedComments == null && isControlledComments) && bodyComments && bodyComments.length > 0) {
|
|
13803
13835
|
setCommentsLoaded(true);
|
|
@@ -13810,37 +13842,17 @@ function useFolioComments(t0) {
|
|
|
13810
13842
|
setActiveCommentId(null);
|
|
13811
13843
|
if (autoOpenReviewSidebar && countOpenCommentThreads(bodyComments) > 0) setShowCommentsSidebar(true);
|
|
13812
13844
|
}
|
|
13813
|
-
|
|
13814
|
-
if ($[22] !== onCommentsChange) {
|
|
13815
|
-
t14 = (loaded) => onCommentsChange?.(loaded);
|
|
13816
|
-
$[22] = onCommentsChange;
|
|
13817
|
-
$[23] = t14;
|
|
13818
|
-
} else t14 = $[23];
|
|
13819
|
-
const notifyLoadedComments = useEffectEvent(t14);
|
|
13845
|
+
const notifyLoadedComments = useEffectEvent((loaded) => onCommentsChange?.(loaded));
|
|
13820
13846
|
const lastLoadedNotificationRef = useRef(null);
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
|
|
13826
|
-
notifyLoadedComments(loadedCommentsNotification.comments);
|
|
13827
|
-
};
|
|
13828
|
-
$[24] = loadedCommentsNotification;
|
|
13829
|
-
$[25] = notifyLoadedComments;
|
|
13830
|
-
$[26] = t15;
|
|
13831
|
-
} else t15 = $[26];
|
|
13832
|
-
let t16;
|
|
13833
|
-
if ($[27] !== loadedCommentsNotification) {
|
|
13834
|
-
t16 = [loadedCommentsNotification];
|
|
13835
|
-
$[27] = loadedCommentsNotification;
|
|
13836
|
-
$[28] = t16;
|
|
13837
|
-
} else t16 = $[28];
|
|
13838
|
-
useEffect(t15, t16);
|
|
13847
|
+
useEffect(() => {
|
|
13848
|
+
if (loadedCommentsNotification === null || lastLoadedNotificationRef.current === loadedCommentsNotification) return;
|
|
13849
|
+
lastLoadedNotificationRef.current = loadedCommentsNotification;
|
|
13850
|
+
notifyLoadedComments(loadedCommentsNotification.comments);
|
|
13851
|
+
}, [loadedCommentsNotification]);
|
|
13839
13852
|
const listedComments = committedComments ?? comments;
|
|
13840
|
-
|
|
13841
|
-
if ($[29] !== listedComments) {
|
|
13853
|
+
const commentAuthors = useMemo(() => {
|
|
13842
13854
|
const seen = /* @__PURE__ */ new Set();
|
|
13843
|
-
authors = [];
|
|
13855
|
+
const authors = [];
|
|
13844
13856
|
for (const comment of listedComments) {
|
|
13845
13857
|
const commentAuthor = getCommentAuthorKey(comment.author);
|
|
13846
13858
|
if (!seen.has(commentAuthor)) {
|
|
@@ -13848,208 +13860,112 @@ function useFolioComments(t0) {
|
|
|
13848
13860
|
authors.push(commentAuthor);
|
|
13849
13861
|
}
|
|
13850
13862
|
}
|
|
13851
|
-
|
|
13852
|
-
|
|
13853
|
-
|
|
13854
|
-
const
|
|
13855
|
-
|
|
13856
|
-
if ($[31] !== commentAuthors || $[32] !== visibleCommentAuthors) {
|
|
13857
|
-
t17 = visibleCommentAuthors ?? new Set(commentAuthors);
|
|
13858
|
-
$[31] = commentAuthors;
|
|
13859
|
-
$[32] = visibleCommentAuthors;
|
|
13860
|
-
$[33] = t17;
|
|
13861
|
-
} else t17 = $[33];
|
|
13862
|
-
const visibleCommentAuthorSet = t17;
|
|
13863
|
-
let t18;
|
|
13864
|
-
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
|
|
13865
|
-
t18 = [-1];
|
|
13866
|
-
$[34] = t18;
|
|
13867
|
-
} else t18 = $[34];
|
|
13868
|
-
let ids;
|
|
13869
|
-
if ($[35] !== listedComments || $[36] !== visibleCommentAuthorSet) {
|
|
13870
|
-
ids = new Set(t18);
|
|
13863
|
+
return authors;
|
|
13864
|
+
}, [listedComments]);
|
|
13865
|
+
const visibleCommentAuthorSet = useMemo(() => visibleCommentAuthors ?? new Set(commentAuthors), [visibleCommentAuthors, commentAuthors]);
|
|
13866
|
+
const visibleCommentIds = useMemo(() => {
|
|
13867
|
+
const ids = /* @__PURE__ */ new Set([-1]);
|
|
13871
13868
|
for (const comment_0 of listedComments) if (visibleCommentAuthorSet.has(getCommentAuthorKey(comment_0.author))) ids.add(comment_0.id);
|
|
13872
|
-
|
|
13873
|
-
|
|
13874
|
-
|
|
13875
|
-
|
|
13876
|
-
const visibleCommentIds = ids;
|
|
13877
|
-
let visibleRootIds;
|
|
13878
|
-
if ($[38] !== listedComments || $[39] !== visibleCommentIds) {
|
|
13879
|
-
visibleRootIds = /* @__PURE__ */ new Set();
|
|
13869
|
+
return ids;
|
|
13870
|
+
}, [listedComments, visibleCommentAuthorSet]);
|
|
13871
|
+
const visibleComments = useMemo(() => {
|
|
13872
|
+
const visibleRootIds = /* @__PURE__ */ new Set();
|
|
13880
13873
|
for (const comment_1 of listedComments) {
|
|
13881
|
-
const parentId_0 = getCommentParentId(comment_1);
|
|
13874
|
+
const parentId_0 = getCommentParentId$1(comment_1);
|
|
13882
13875
|
if (parentId_0 === null || parentId_0 === void 0 || !visibleCommentIds.has(comment_1.id)) continue;
|
|
13883
13876
|
visibleRootIds.add(parentId_0);
|
|
13884
13877
|
}
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
13891
|
-
let t20;
|
|
13892
|
-
if ($[45] !== visibleCommentIds || $[46] !== visibleRootIds) {
|
|
13893
|
-
t20 = (comment_2) => {
|
|
13894
|
-
const parentId_1 = getCommentParentId(comment_2);
|
|
13895
|
-
if (parentId_1 !== null && parentId_1 !== void 0) return visibleCommentIds.has(comment_2.id);
|
|
13896
|
-
return visibleCommentIds.has(comment_2.id) || visibleRootIds.has(comment_2.id);
|
|
13897
|
-
};
|
|
13898
|
-
$[45] = visibleCommentIds;
|
|
13899
|
-
$[46] = visibleRootIds;
|
|
13900
|
-
$[47] = t20;
|
|
13901
|
-
} else t20 = $[47];
|
|
13902
|
-
t19 = listedComments.filter(t20);
|
|
13903
|
-
$[41] = listedComments;
|
|
13904
|
-
$[42] = visibleCommentIds;
|
|
13905
|
-
$[43] = visibleRootIds;
|
|
13906
|
-
$[44] = t19;
|
|
13907
|
-
} else t19 = $[44];
|
|
13908
|
-
const visibleComments = t19;
|
|
13878
|
+
return listedComments.filter((comment_2) => {
|
|
13879
|
+
const parentId_1 = getCommentParentId$1(comment_2);
|
|
13880
|
+
if (parentId_1 !== null && parentId_1 !== void 0) return visibleCommentIds.has(comment_2.id);
|
|
13881
|
+
return visibleCommentIds.has(comment_2.id) || visibleRootIds.has(comment_2.id);
|
|
13882
|
+
});
|
|
13883
|
+
}, [listedComments, visibleCommentIds]);
|
|
13909
13884
|
const activeCommentVisible = activeCommentId !== null && visibleCommentIds.has(activeCommentId);
|
|
13910
13885
|
if (activeCommentId !== null && !activeCommentVisible) setActiveCommentId(null);
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
13914
|
-
|
|
13915
|
-
|
|
13916
|
-
const
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
node.style.backgroundColor = "transparent";
|
|
13921
|
-
node.style.borderBottom = "2px solid transparent";
|
|
13922
|
-
node.style.boxShadow = "none";
|
|
13923
|
-
delete node.dataset["activeComment"];
|
|
13924
|
-
continue;
|
|
13925
|
-
}
|
|
13926
|
-
if (activeCommentId !== null && commentIds.includes(activeCommentId)) {
|
|
13927
|
-
node.style.backgroundColor = "var(--doc-comment-active-bg, rgba(255, 212, 0, 0.22))";
|
|
13928
|
-
node.style.borderBottom = "1px solid var(--doc-comment-active-border, rgba(180, 130, 0, 0.62))";
|
|
13929
|
-
node.style.boxShadow = "none";
|
|
13930
|
-
node.dataset.activeComment = "true";
|
|
13931
|
-
continue;
|
|
13932
|
-
}
|
|
13933
|
-
node.style.backgroundColor = "var(--doc-comment-bg, rgba(255, 212, 0, 0.08))";
|
|
13934
|
-
node.style.borderBottom = "1px solid var(--doc-comment-border, rgba(180, 130, 0, 0.24))";
|
|
13886
|
+
const syncCommentHighlightStyles = useCallback(() => {
|
|
13887
|
+
const root = editorContentRef.current;
|
|
13888
|
+
if (!root) return;
|
|
13889
|
+
const nodes = root.querySelectorAll(`.layout-run-text${COMMENT_ANCHOR_SELECTOR}`);
|
|
13890
|
+
for (const node of nodes) {
|
|
13891
|
+
const commentIds = commentAnchorIds(node).map((id_5) => Number.parseInt(id_5, 10));
|
|
13892
|
+
if (!commentIds.some((commentId) => commentId === -1 || visibleCommentIds.has(commentId))) {
|
|
13893
|
+
node.style.backgroundColor = "transparent";
|
|
13894
|
+
node.style.borderBottom = "2px solid transparent";
|
|
13935
13895
|
node.style.boxShadow = "none";
|
|
13936
13896
|
delete node.dataset["activeComment"];
|
|
13897
|
+
continue;
|
|
13937
13898
|
}
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
13945
|
-
|
|
13946
|
-
|
|
13947
|
-
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
|
|
13954
|
-
|
|
13955
|
-
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
13960
|
-
$[57] = syncCommentHighlightStyles;
|
|
13961
|
-
$[58] = t22;
|
|
13962
|
-
} else t22 = $[58];
|
|
13963
|
-
useLayoutEffect(t21, t22);
|
|
13964
|
-
const scheduleHighlightCommit = useEffectEvent(_temp3);
|
|
13965
|
-
let t23;
|
|
13966
|
-
if ($[59] !== comments || $[60] !== scheduleHighlightCommit || $[61] !== syncCommentHighlightStyles) {
|
|
13967
|
-
t23 = () => scheduleHighlightCommit(comments, syncCommentHighlightStyles);
|
|
13968
|
-
$[59] = comments;
|
|
13969
|
-
$[60] = scheduleHighlightCommit;
|
|
13970
|
-
$[61] = syncCommentHighlightStyles;
|
|
13971
|
-
$[62] = t23;
|
|
13972
|
-
} else t23 = $[62];
|
|
13973
|
-
let t24;
|
|
13974
|
-
if ($[63] !== comments || $[64] !== syncCommentHighlightStyles) {
|
|
13975
|
-
t24 = [comments, syncCommentHighlightStyles];
|
|
13976
|
-
$[63] = comments;
|
|
13977
|
-
$[64] = syncCommentHighlightStyles;
|
|
13978
|
-
$[65] = t24;
|
|
13979
|
-
} else t24 = $[65];
|
|
13980
|
-
useEffect(t23, t24);
|
|
13981
|
-
let t25;
|
|
13982
|
-
if ($[66] !== activeCommentId || $[67] !== addCommentYPosition || $[68] !== commentAuthors || $[69] !== commentSelectionRange || $[70] !== comments || $[71] !== createComment$1 || $[72] !== floatingCommentBtn || $[73] !== isAddingComment || $[74] !== isControlledComments || $[75] !== setComments || $[76] !== showCommentsSidebar || $[77] !== syncCommentHighlightStyles || $[78] !== visibleCommentAuthorSet || $[79] !== visibleComments) {
|
|
13983
|
-
t25 = {
|
|
13984
|
-
comments,
|
|
13985
|
-
setComments,
|
|
13986
|
-
createComment: createComment$1,
|
|
13987
|
-
isControlledComments,
|
|
13988
|
-
commentsRef: readonlyCommentsRef,
|
|
13989
|
-
getCommentsDirty,
|
|
13990
|
-
setCommentsDirty,
|
|
13991
|
-
resetLoadedComments,
|
|
13992
|
-
showCommentsSidebar,
|
|
13993
|
-
setShowCommentsSidebar,
|
|
13994
|
-
setVisibleCommentAuthors,
|
|
13995
|
-
activeCommentId,
|
|
13996
|
-
setActiveCommentId,
|
|
13997
|
-
isAddingComment,
|
|
13998
|
-
setIsAddingComment,
|
|
13999
|
-
commentSelectionRange,
|
|
14000
|
-
setCommentSelectionRange,
|
|
14001
|
-
addCommentYPosition,
|
|
14002
|
-
setAddCommentYPosition,
|
|
14003
|
-
floatingCommentBtn,
|
|
14004
|
-
setFloatingCommentBtn,
|
|
14005
|
-
commentAuthors,
|
|
14006
|
-
visibleCommentAuthorSet,
|
|
14007
|
-
visibleComments,
|
|
14008
|
-
syncCommentHighlightStyles
|
|
14009
|
-
};
|
|
14010
|
-
$[66] = activeCommentId;
|
|
14011
|
-
$[67] = addCommentYPosition;
|
|
14012
|
-
$[68] = commentAuthors;
|
|
14013
|
-
$[69] = commentSelectionRange;
|
|
14014
|
-
$[70] = comments;
|
|
14015
|
-
$[71] = createComment$1;
|
|
14016
|
-
$[72] = floatingCommentBtn;
|
|
14017
|
-
$[73] = isAddingComment;
|
|
14018
|
-
$[74] = isControlledComments;
|
|
14019
|
-
$[75] = setComments;
|
|
14020
|
-
$[76] = showCommentsSidebar;
|
|
14021
|
-
$[77] = syncCommentHighlightStyles;
|
|
14022
|
-
$[78] = visibleCommentAuthorSet;
|
|
14023
|
-
$[79] = visibleComments;
|
|
14024
|
-
$[80] = t25;
|
|
14025
|
-
} else t25 = $[80];
|
|
14026
|
-
return t25;
|
|
14027
|
-
}
|
|
14028
|
-
function _temp3(_comments, sync_0) {
|
|
14029
|
-
sync_0();
|
|
14030
|
-
let secondFrame = null;
|
|
14031
|
-
const firstFrame = requestAnimationFrame(() => {
|
|
13899
|
+
if (activeCommentId !== null && commentIds.includes(activeCommentId)) {
|
|
13900
|
+
node.style.backgroundColor = "var(--doc-comment-active-bg, rgba(255, 212, 0, 0.22))";
|
|
13901
|
+
node.style.borderBottom = "1px solid var(--doc-comment-active-border, rgba(180, 130, 0, 0.62))";
|
|
13902
|
+
node.style.boxShadow = "none";
|
|
13903
|
+
node.dataset["activeComment"] = "true";
|
|
13904
|
+
continue;
|
|
13905
|
+
}
|
|
13906
|
+
node.style.backgroundColor = "var(--doc-comment-bg, rgba(255, 212, 0, 0.08))";
|
|
13907
|
+
node.style.borderBottom = "1px solid var(--doc-comment-border, rgba(180, 130, 0, 0.24))";
|
|
13908
|
+
node.style.boxShadow = "none";
|
|
13909
|
+
delete node.dataset["activeComment"];
|
|
13910
|
+
}
|
|
13911
|
+
}, [
|
|
13912
|
+
visibleCommentIds,
|
|
13913
|
+
activeCommentId,
|
|
13914
|
+
editorContentRef
|
|
13915
|
+
]);
|
|
13916
|
+
const highlightLayoutCommit = useEffectEvent((_positions, sync) => sync());
|
|
13917
|
+
useLayoutEffect(() => {
|
|
13918
|
+
highlightLayoutCommit(anchorPositions, syncCommentHighlightStyles);
|
|
13919
|
+
}, [syncCommentHighlightStyles, anchorPositions]);
|
|
13920
|
+
const scheduleHighlightCommit = useEffectEvent((_comments, sync_0) => {
|
|
14032
13921
|
sync_0();
|
|
14033
|
-
secondFrame =
|
|
13922
|
+
let secondFrame = null;
|
|
13923
|
+
const firstFrame = requestAnimationFrame(() => {
|
|
13924
|
+
sync_0();
|
|
13925
|
+
secondFrame = requestAnimationFrame(sync_0);
|
|
13926
|
+
});
|
|
13927
|
+
const timeout = setTimeout(sync_0, 120);
|
|
13928
|
+
return () => {
|
|
13929
|
+
cancelAnimationFrame(firstFrame);
|
|
13930
|
+
if (secondFrame !== null) cancelAnimationFrame(secondFrame);
|
|
13931
|
+
clearTimeout(timeout);
|
|
13932
|
+
};
|
|
14034
13933
|
});
|
|
14035
|
-
|
|
14036
|
-
return
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
13934
|
+
useEffect(() => scheduleHighlightCommit(comments, syncCommentHighlightStyles), [comments, syncCommentHighlightStyles]);
|
|
13935
|
+
return {
|
|
13936
|
+
comments,
|
|
13937
|
+
setComments,
|
|
13938
|
+
createComment: createComment$1,
|
|
13939
|
+
isControlledComments,
|
|
13940
|
+
commentsRef: readonlyCommentsRef,
|
|
13941
|
+
getCommentsDirty,
|
|
13942
|
+
setCommentsDirty,
|
|
13943
|
+
resetLoadedComments,
|
|
13944
|
+
resetComments,
|
|
13945
|
+
showCommentsSidebar,
|
|
13946
|
+
setShowCommentsSidebar,
|
|
13947
|
+
setVisibleCommentAuthors,
|
|
13948
|
+
activeCommentId,
|
|
13949
|
+
setActiveCommentId,
|
|
13950
|
+
isAddingComment,
|
|
13951
|
+
setIsAddingComment,
|
|
13952
|
+
commentSelectionRange,
|
|
13953
|
+
setCommentSelectionRange,
|
|
13954
|
+
addCommentYPosition,
|
|
13955
|
+
setAddCommentYPosition,
|
|
13956
|
+
floatingCommentBtn,
|
|
13957
|
+
setFloatingCommentBtn,
|
|
13958
|
+
commentAuthors,
|
|
13959
|
+
visibleCommentAuthorSet,
|
|
13960
|
+
visibleComments,
|
|
13961
|
+
syncCommentHighlightStyles
|
|
14040
13962
|
};
|
|
14041
13963
|
}
|
|
14042
|
-
function _temp2(_positions, sync) {
|
|
14043
|
-
return sync();
|
|
14044
|
-
}
|
|
14045
|
-
function _temp(id_4) {
|
|
14046
|
-
return Number.parseInt(id_4, 10);
|
|
14047
|
-
}
|
|
14048
13964
|
// src/components/DocxEditor.tsx
|
|
14049
13965
|
/** No headings to track while the outline is not shown. */
|
|
14050
13966
|
const NO_HEADINGS = [];
|
|
14051
|
-
const CommentsSidebar = lazy(() => import("./CommentsSidebar-
|
|
14052
|
-
const TextContextMenu = lazy(() => import("./TextContextMenu-
|
|
13967
|
+
const CommentsSidebar = lazy(() => import("./CommentsSidebar-myF8qhju.js").then((m) => ({ default: m.CommentsSidebar })));
|
|
13968
|
+
const TextContextMenu = lazy(() => import("./TextContextMenu-jOBgICwD.js").then((m) => ({ default: m.TextContextMenu })));
|
|
14053
13969
|
const loadAttemptSelectiveSave = async () => {
|
|
14054
13970
|
const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
|
|
14055
13971
|
return attemptSelectiveSave;
|
|
@@ -14067,15 +13983,6 @@ const DISPLAY_MODE_LABEL_KEYS = {
|
|
|
14067
13983
|
};
|
|
14068
13984
|
const preventMouseDownDefault = (event) => event.preventDefault();
|
|
14069
13985
|
let documentOperationUndoHandleCursor = Date.now();
|
|
14070
|
-
/**
|
|
14071
|
-
* The comments a batch's applied operations own. A run whose result the
|
|
14072
|
-
* save-time check refused allocated comments nothing in the document names;
|
|
14073
|
-
* they stay out of the comment list.
|
|
14074
|
-
*/
|
|
14075
|
-
const appliedOperationComments = (created, applied) => {
|
|
14076
|
-
const appliedIds = new Set(applied.map(({ commentId }) => commentId));
|
|
14077
|
-
return created.filter((comment) => appliedIds.has(comment.id));
|
|
14078
|
-
};
|
|
14079
13986
|
function isDisplayMode(value) {
|
|
14080
13987
|
return typeof value === "string" && DISPLAY_MODES.some((mode) => mode === value);
|
|
14081
13988
|
}
|
|
@@ -14102,7 +14009,7 @@ const EMPTY_SELECTION_FORMATTING = {};
|
|
|
14102
14009
|
function areTableContextsEqual(a, b) {
|
|
14103
14010
|
if (a === b) return true;
|
|
14104
14011
|
if (!a || !b) return false;
|
|
14105
|
-
return a.isInTable === b.isInTable && a.table === b.table && a.tablePos === b.tablePos && a.rowIndex === b.rowIndex && a.columnIndex === b.columnIndex && a.rowCount === b.rowCount && a.columnCount === b.columnCount && a.hasMultiCellSelection === b.hasMultiCellSelection && a.canSplitCell === b.canSplitCell && a.cellBorderColor === b.cellBorderColor && a.cellBackgroundColor === b.cellBackgroundColor;
|
|
14012
|
+
return a.isInTable === b.isInTable && a.table?.attrs === b.table?.attrs && a.tablePos === b.tablePos && a.rowIndex === b.rowIndex && a.columnIndex === b.columnIndex && a.rowCount === b.rowCount && a.columnCount === b.columnCount && a.hasMultiCellSelection === b.hasMultiCellSelection && a.canSplitCell === b.canSplitCell && a.cellBorderColor === b.cellBorderColor && a.cellBackgroundColor === b.cellBackgroundColor;
|
|
14106
14013
|
}
|
|
14107
14014
|
/** Structural equality for the image context surfaced to the toolbar. */
|
|
14108
14015
|
function areImageContextsEqual(a, b) {
|
|
@@ -14114,7 +14021,7 @@ function areImageContextsEqual(a, b) {
|
|
|
14114
14021
|
function areActiveTrackedChangesEqual(a, b) {
|
|
14115
14022
|
if (a === b) return true;
|
|
14116
14023
|
if (!a || !b) return false;
|
|
14117
|
-
return a.type === b.type && a.author === b.author && a.date === b.date && a.
|
|
14024
|
+
return a.type === b.type && a.author === b.author && a.date === b.date && a.heldByLock.accept === b.heldByLock.accept && a.heldByLock.reject === b.heldByLock.reject;
|
|
14118
14025
|
}
|
|
14119
14026
|
const assignRef = (ref, value) => {
|
|
14120
14027
|
ref.current = value;
|
|
@@ -14193,26 +14100,29 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14193
14100
|
const [rulerVisible, setRulerVisible] = useState(showRulerProp);
|
|
14194
14101
|
const toggleRuler = useCallback(() => setRulerVisible((visible) => !visible), []);
|
|
14195
14102
|
const [showOutline, setShowOutline] = useState(showOutlineProp);
|
|
14196
|
-
const [outlineHeadings, setHeadingInfos] =
|
|
14197
|
-
const [, setTrackedChangeEntries] =
|
|
14103
|
+
const [outlineHeadings, setHeadingInfos] = useEqualState([]);
|
|
14104
|
+
const [, setTrackedChangeEntries] = useEqualState([]);
|
|
14198
14105
|
const trackedChangesRef = useRef([]);
|
|
14199
14106
|
const setTrackedChanges = useCallback((entries) => {
|
|
14200
14107
|
trackedChangesRef.current = entries;
|
|
14201
14108
|
setTrackedChangeEntries(entries);
|
|
14202
|
-
}, []);
|
|
14203
|
-
const [anchorPositions, setAnchorPositions] =
|
|
14109
|
+
}, [setTrackedChangeEntries]);
|
|
14110
|
+
const [anchorPositions, setAnchorPositions] = useEqualState(EMPTY_ANCHOR_POSITIONS);
|
|
14204
14111
|
const { editingMode, readOnly, readOnlyReason, trackChangesOn, toggleTrackChanges, displayMode, setDisplayMode } = useEditorMode({
|
|
14205
14112
|
modeProp,
|
|
14206
14113
|
onModeChange,
|
|
14207
14114
|
readOnlyProp,
|
|
14208
14115
|
...reviewDisplayMode === void 0 ? {} : { reviewDisplayMode }
|
|
14209
14116
|
});
|
|
14210
|
-
|
|
14117
|
+
const syncCanonicalMode = useCallback(() => {
|
|
14211
14118
|
pagedEditorRef.current?.getEditor().setCanonicalMode(editingMode === "suggesting" ? {
|
|
14212
14119
|
type: "suggesting",
|
|
14213
14120
|
author
|
|
14214
14121
|
} : { type: "editing" });
|
|
14215
14122
|
}, [editingMode, author]);
|
|
14123
|
+
useEffect(() => {
|
|
14124
|
+
syncCanonicalMode();
|
|
14125
|
+
}, [syncCanonicalMode]);
|
|
14216
14126
|
const extractTrackedChangesTimerRef = useRef(null);
|
|
14217
14127
|
const extractTrackedChanges = useCallback(() => {
|
|
14218
14128
|
const view = pagedEditorRef.current?.getView();
|
|
@@ -14265,7 +14175,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14265
14175
|
const refuseCanonicalModelEdit = useCallback((gap, message) => {
|
|
14266
14176
|
if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return false;
|
|
14267
14177
|
const error = new CanonicalSessionRefusalError({
|
|
14268
|
-
gap,
|
|
14178
|
+
ground: { gap },
|
|
14269
14179
|
message: canonicalRefusalMessage(gap, message)
|
|
14270
14180
|
});
|
|
14271
14181
|
toast(error.message);
|
|
@@ -14372,21 +14282,36 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14372
14282
|
};
|
|
14373
14283
|
}, [onEditorViewReady, reportEditorViewReady]);
|
|
14374
14284
|
const [bodyViewEpoch, setBodyViewEpoch] = useState(0);
|
|
14375
|
-
const
|
|
14376
|
-
|
|
14285
|
+
const [bodyEditorView, setBodyEditorView] = useState(null);
|
|
14286
|
+
const syncSuggestionMode = useCallback((view_2) => {
|
|
14287
|
+
const active = editingMode === "suggesting";
|
|
14288
|
+
const current = suggestionModeKey.getState(view_2.state);
|
|
14289
|
+
if (current?.active !== active || current.author !== author) setSuggestionMode(active, view_2.state, view_2.dispatch, author);
|
|
14290
|
+
}, [editingMode, author]);
|
|
14291
|
+
const handleBodyViewReady = useCallback((view_3) => {
|
|
14292
|
+
if (view_3) {
|
|
14293
|
+
syncSuggestionMode(view_3);
|
|
14294
|
+
syncCanonicalMode();
|
|
14295
|
+
}
|
|
14296
|
+
reportEditorViewReady(view_3);
|
|
14297
|
+
setBodyEditorView(view_3);
|
|
14377
14298
|
setBodyViewEpoch((epoch) => epoch + 1);
|
|
14378
|
-
}, [
|
|
14299
|
+
}, [
|
|
14300
|
+
reportEditorViewReady,
|
|
14301
|
+
syncCanonicalMode,
|
|
14302
|
+
syncSuggestionMode
|
|
14303
|
+
]);
|
|
14379
14304
|
useEffect(() => {
|
|
14380
14305
|
const pagedEditor = pagedEditorRef.current;
|
|
14381
14306
|
if (!showOutline || bodyViewEpoch === 0 || !pagedEditor) return;
|
|
14382
14307
|
let collectedDoc = null;
|
|
14383
14308
|
let collected = [];
|
|
14384
14309
|
const refresh = (layout) => {
|
|
14385
|
-
const
|
|
14386
|
-
if (!
|
|
14387
|
-
if (
|
|
14388
|
-
collectedDoc =
|
|
14389
|
-
collected = collectHeadings(
|
|
14310
|
+
const view_4 = pagedEditor.getView();
|
|
14311
|
+
if (!view_4) return;
|
|
14312
|
+
if (view_4.state.doc !== collectedDoc) {
|
|
14313
|
+
collectedDoc = view_4.state.doc;
|
|
14314
|
+
collected = collectHeadings(view_4.state.doc, getDocumentBuiltInStyles(view_4.state));
|
|
14390
14315
|
}
|
|
14391
14316
|
setHeadingInfos((previous) => resolveOutlineHeadings({
|
|
14392
14317
|
collected,
|
|
@@ -14396,7 +14321,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14396
14321
|
};
|
|
14397
14322
|
refresh(pagedEditor.getLayout());
|
|
14398
14323
|
return pagedEditor.getEditor().on("layoutComplete", refresh);
|
|
14399
|
-
}, [
|
|
14324
|
+
}, [
|
|
14325
|
+
showOutline,
|
|
14326
|
+
bodyViewEpoch,
|
|
14327
|
+
setHeadingInfos
|
|
14328
|
+
]);
|
|
14400
14329
|
const [editorController, setEditorController] = useState(null);
|
|
14401
14330
|
const attachPagedEditor = useCallback((editor) => {
|
|
14402
14331
|
assignRef(pagedEditorRef, editor);
|
|
@@ -14474,14 +14403,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14474
14403
|
const canonicalCommentsSerialized = useMemo(() => canonicalComments === null ? null : JSON.stringify(canonicalComments), [canonicalComments]);
|
|
14475
14404
|
const canonicalCommentsSnapshotRef = useRef(canonicalCommentsSerialized);
|
|
14476
14405
|
const lastControlledCommentsRef = useRef(void 0);
|
|
14477
|
-
const { comments: legacyComments, createComment, setComments, commentsRef, getCommentsDirty, setCommentsDirty, resetLoadedComments, showCommentsSidebar, setShowCommentsSidebar, setVisibleCommentAuthors, activeCommentId, setActiveCommentId, isAddingComment, setIsAddingComment, commentSelectionRange, setCommentSelectionRange, addCommentYPosition, setAddCommentYPosition, floatingCommentBtn, setFloatingCommentBtn, commentAuthors, visibleCommentAuthorSet, visibleComments, syncCommentHighlightStyles } = useFolioComments({
|
|
14406
|
+
const { comments: legacyComments, createComment, setComments, commentsRef, getCommentsDirty, setCommentsDirty, resetLoadedComments, resetComments, showCommentsSidebar, setShowCommentsSidebar, setVisibleCommentAuthors, activeCommentId, setActiveCommentId, isAddingComment, setIsAddingComment, commentSelectionRange, setCommentSelectionRange, addCommentYPosition, setAddCommentYPosition, floatingCommentBtn, setFloatingCommentBtn, commentAuthors, visibleCommentAuthorSet, visibleComments, syncCommentHighlightStyles } = useFolioComments({
|
|
14478
14407
|
doc: canonicalComments === null ? history.state : null,
|
|
14479
14408
|
autoOpenReviewSidebar,
|
|
14480
14409
|
anchorPositions,
|
|
14481
14410
|
editorContentRef,
|
|
14482
14411
|
commentsProp,
|
|
14483
14412
|
onCommentsChange,
|
|
14484
|
-
committedComments: canonicalComments
|
|
14413
|
+
committedComments: canonicalComments,
|
|
14414
|
+
bodyView: bodyEditorView
|
|
14485
14415
|
});
|
|
14486
14416
|
const comments = canonicalComments ?? legacyComments;
|
|
14487
14417
|
const commentDraftMode = usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "prosemirror";
|
|
@@ -14511,7 +14441,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14511
14441
|
onZoomChange: setZoomWithViewportAnchor,
|
|
14512
14442
|
keyboardShortcuts: "none"
|
|
14513
14443
|
});
|
|
14514
|
-
const [bodyHistoryAvailability, setBodyHistoryAvailability] =
|
|
14444
|
+
const [bodyHistoryAvailability, setBodyHistoryAvailability] = useEqualState({
|
|
14515
14445
|
canRedo: false,
|
|
14516
14446
|
canUndo: false
|
|
14517
14447
|
});
|
|
@@ -14529,7 +14459,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14529
14459
|
canUndo,
|
|
14530
14460
|
canRedo
|
|
14531
14461
|
});
|
|
14532
|
-
}, []);
|
|
14462
|
+
}, [setBodyHistoryAvailability]);
|
|
14533
14463
|
const { hfEditPosition, setHfEditPosition, hfEditIsFirstPage, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, activeHeaderRId, activeFooterRId, activeFirstHeaderRId, activeFirstFooterRId, effectiveSectionProperties, handleHeaderFooterDoubleClick, handleBodyClick, handleRemoveHeaderFooter } = useHeaderFooterEditor({
|
|
14534
14464
|
history,
|
|
14535
14465
|
pushDocument,
|
|
@@ -14654,7 +14584,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14654
14584
|
});
|
|
14655
14585
|
setCommentsDirty(false);
|
|
14656
14586
|
resetLoadedComments();
|
|
14657
|
-
|
|
14587
|
+
resetComments();
|
|
14658
14588
|
setTrackedChanges([]);
|
|
14659
14589
|
setVisibleCommentAuthors(null);
|
|
14660
14590
|
setActiveCommentId(null);
|
|
@@ -14674,16 +14604,18 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14674
14604
|
}, [
|
|
14675
14605
|
setCommentsDirty,
|
|
14676
14606
|
resetLoadedComments,
|
|
14607
|
+
resetComments,
|
|
14677
14608
|
setActiveCommentId,
|
|
14678
14609
|
setAddCommentYPosition,
|
|
14679
14610
|
setCommentSelectionRange,
|
|
14680
|
-
setComments,
|
|
14681
14611
|
setTrackedChanges,
|
|
14682
14612
|
setFloatingCommentBtn,
|
|
14683
14613
|
setHfEditPosition,
|
|
14684
14614
|
setIsAddingComment,
|
|
14685
14615
|
setShowCommentsSidebar,
|
|
14686
|
-
setVisibleCommentAuthors
|
|
14616
|
+
setVisibleCommentAuthors,
|
|
14617
|
+
setHeadingInfos,
|
|
14618
|
+
setAnchorPositions
|
|
14687
14619
|
]),
|
|
14688
14620
|
setDocumentLoadState: useCallback((documentLoad) => {
|
|
14689
14621
|
setState((prev_0) => ({
|
|
@@ -14737,9 +14669,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14737
14669
|
});
|
|
14738
14670
|
}, [onFontsLoadedCallback]);
|
|
14739
14671
|
useEffect(() => {
|
|
14740
|
-
const
|
|
14741
|
-
if (
|
|
14742
|
-
}, [
|
|
14672
|
+
const view_5 = pagedEditorRef.current?.getView();
|
|
14673
|
+
if (view_5) syncSuggestionMode(view_5);
|
|
14674
|
+
}, [syncSuggestionMode]);
|
|
14743
14675
|
const handleDocumentChange = useCallback((newDocument) => {
|
|
14744
14676
|
const canonical = usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting);
|
|
14745
14677
|
const currentComments = commentsRef.current;
|
|
@@ -14786,16 +14718,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14786
14718
|
const flushBag = (bag) => {
|
|
14787
14719
|
if (!bag) return;
|
|
14788
14720
|
for (const [rId, hf] of bag) {
|
|
14789
|
-
const
|
|
14790
|
-
if (
|
|
14721
|
+
const view_6 = editor_0.getHfView(rId);
|
|
14722
|
+
if (view_6) hf.content = proseDocToBlocks(view_6.state.doc, hf.content);
|
|
14791
14723
|
}
|
|
14792
14724
|
};
|
|
14793
14725
|
flushBag(doc_0.package.headers);
|
|
14794
14726
|
flushBag(doc_0.package.footers);
|
|
14795
14727
|
}
|
|
14796
|
-
const
|
|
14797
|
-
|
|
14798
|
-
return doc_0;
|
|
14728
|
+
const editorDoc = pagedEditorRef.current?.getView()?.state.doc;
|
|
14729
|
+
return withHostCommentThreads(doc_0, commentsRef.current, { anchoredInEditor: editorDoc ? commentIdsNamedIn(editorDoc) : null });
|
|
14799
14730
|
}, [commentsRef, experimentalSession]);
|
|
14800
14731
|
const applyCanonicalComment = useCallback((request) => {
|
|
14801
14732
|
return getCanonicalApi()?.applyCanonicalComment(request) ?? null;
|
|
@@ -14842,9 +14773,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14842
14773
|
return;
|
|
14843
14774
|
}
|
|
14844
14775
|
if (result?.status !== "refused" || result.retry !== "afterComposition") return;
|
|
14845
|
-
const
|
|
14846
|
-
if (!
|
|
14847
|
-
return afterCanonicalCompositionSettles(
|
|
14776
|
+
const view_7 = getCanonicalApi()?.getView();
|
|
14777
|
+
if (!view_7) return;
|
|
14778
|
+
return afterCanonicalCompositionSettles(view_7, () => setControlledCommentsRetry((attempt) => attempt + 1));
|
|
14848
14779
|
});
|
|
14849
14780
|
useEffect(() => synchronizeControlledComments({
|
|
14850
14781
|
commentsProp,
|
|
@@ -14945,17 +14876,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14945
14876
|
resetFindResultRef.current = resetFindResult;
|
|
14946
14877
|
}, [resetFindResult]);
|
|
14947
14878
|
const handleSelectionChange = useCallback((selectionState) => {
|
|
14948
|
-
const
|
|
14949
|
-
if (
|
|
14950
|
-
const { from, to } =
|
|
14879
|
+
const view_8 = getActiveEditorView();
|
|
14880
|
+
if (view_8) {
|
|
14881
|
+
const { from, to } = view_8.state.selection;
|
|
14951
14882
|
lastSelectionRef.current = {
|
|
14952
14883
|
from,
|
|
14953
14884
|
to
|
|
14954
14885
|
};
|
|
14955
14886
|
}
|
|
14956
14887
|
let pmTableCtx = null;
|
|
14957
|
-
if (
|
|
14958
|
-
pmTableCtx = getTableContext(
|
|
14888
|
+
if (view_8) {
|
|
14889
|
+
pmTableCtx = getTableContext(view_8.state);
|
|
14959
14890
|
if (!pmTableCtx.isInTable) pmTableCtx = null;
|
|
14960
14891
|
}
|
|
14961
14892
|
if (pmTableCtx?.cellBorderColor) {
|
|
@@ -14967,8 +14898,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14967
14898
|
color: { rgb }
|
|
14968
14899
|
};
|
|
14969
14900
|
}
|
|
14970
|
-
const pmImageCtx =
|
|
14971
|
-
const
|
|
14901
|
+
const pmImageCtx = view_8 ? detectImageContext(view_8.state) : null;
|
|
14902
|
+
const detectedChange = view_8 ? detectActiveTrackedChange(view_8.state) : null;
|
|
14903
|
+
const trackedChange = detectedChange === null ? null : {
|
|
14904
|
+
type: detectedChange.type,
|
|
14905
|
+
author: detectedChange.author,
|
|
14906
|
+
date: detectedChange.date,
|
|
14907
|
+
heldByLock: detectedChange.heldByLock
|
|
14908
|
+
};
|
|
14972
14909
|
if (!selectionState) {
|
|
14973
14910
|
setFloatingCommentBtn(null);
|
|
14974
14911
|
setState((prev_1) => {
|
|
@@ -15031,10 +14968,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15031
14968
|
activeTrackedChange: activeTrackedChange_0
|
|
15032
14969
|
};
|
|
15033
14970
|
});
|
|
15034
|
-
if (
|
|
14971
|
+
if (view_8 && selectionState.hasSelection && !isAddingComment && !readOnly) {
|
|
15035
14972
|
const container = scrollContainerRef.current;
|
|
15036
14973
|
const parentEl = editorContentRef.current;
|
|
15037
|
-
const { from: selFrom } =
|
|
14974
|
+
const { from: selFrom } = view_8.state.selection;
|
|
15038
14975
|
const top = findSelectionYPosition(container, parentEl, selFrom);
|
|
15039
14976
|
if (top !== null && container && parentEl) {
|
|
15040
14977
|
const pagesEl = container.querySelector(".paged-editor__pages");
|
|
@@ -15042,7 +14979,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15042
14979
|
const parentRect = parentEl.getBoundingClientRect();
|
|
15043
14980
|
const rawLeft = pageEl ? pageEl.getBoundingClientRect().right - parentRect.left + 12 : parentRect.width / 2 + 408;
|
|
15044
14981
|
const left = Math.max(16, Math.min(rawLeft, parentRect.width - 16));
|
|
15045
|
-
const { from: from_0, to: to_0 } =
|
|
14982
|
+
const { from: from_0, to: to_0 } = view_8.state.selection;
|
|
15046
14983
|
if (from_0 !== to_0) setFloatingCommentBtn({
|
|
15047
14984
|
top,
|
|
15048
14985
|
left,
|
|
@@ -15205,99 +15142,99 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15205
15142
|
refuseCanonicalModelEdit
|
|
15206
15143
|
]);
|
|
15207
15144
|
const handleTableAction = useCallback((action_0) => {
|
|
15208
|
-
const
|
|
15209
|
-
if (!
|
|
15145
|
+
const view_9 = getActiveEditorView();
|
|
15146
|
+
if (!view_9) return;
|
|
15210
15147
|
switch (action_0) {
|
|
15211
15148
|
case "addRowAbove":
|
|
15212
|
-
addRowAbove(
|
|
15149
|
+
addRowAbove(view_9.state, view_9.dispatch);
|
|
15213
15150
|
break;
|
|
15214
15151
|
case "addRowBelow":
|
|
15215
|
-
addRowBelow(
|
|
15152
|
+
addRowBelow(view_9.state, view_9.dispatch);
|
|
15216
15153
|
break;
|
|
15217
15154
|
case "addColumnLeft":
|
|
15218
|
-
addColumnLeft(
|
|
15155
|
+
addColumnLeft(view_9.state, view_9.dispatch);
|
|
15219
15156
|
break;
|
|
15220
15157
|
case "addColumnRight":
|
|
15221
|
-
addColumnRight(
|
|
15158
|
+
addColumnRight(view_9.state, view_9.dispatch);
|
|
15222
15159
|
break;
|
|
15223
15160
|
case "deleteRow":
|
|
15224
|
-
deleteRow(
|
|
15161
|
+
deleteRow(view_9.state, view_9.dispatch);
|
|
15225
15162
|
break;
|
|
15226
15163
|
case "deleteColumn":
|
|
15227
|
-
deleteColumn(
|
|
15164
|
+
deleteColumn(view_9.state, view_9.dispatch);
|
|
15228
15165
|
break;
|
|
15229
15166
|
case "deleteTable":
|
|
15230
|
-
deleteTable(
|
|
15167
|
+
deleteTable(view_9.state, view_9.dispatch);
|
|
15231
15168
|
break;
|
|
15232
15169
|
case "selectTable":
|
|
15233
|
-
selectTable(
|
|
15170
|
+
selectTable(view_9.state, view_9.dispatch);
|
|
15234
15171
|
break;
|
|
15235
15172
|
case "selectRow":
|
|
15236
|
-
selectRow(
|
|
15173
|
+
selectRow(view_9.state, view_9.dispatch);
|
|
15237
15174
|
break;
|
|
15238
15175
|
case "selectColumn":
|
|
15239
|
-
selectColumn(
|
|
15176
|
+
selectColumn(view_9.state, view_9.dispatch);
|
|
15240
15177
|
break;
|
|
15241
15178
|
case "mergeCells":
|
|
15242
|
-
mergeCells(
|
|
15179
|
+
mergeCells(view_9.state, view_9.dispatch);
|
|
15243
15180
|
break;
|
|
15244
15181
|
case "splitCell":
|
|
15245
|
-
splitCell(
|
|
15182
|
+
splitCell(view_9.state, view_9.dispatch);
|
|
15246
15183
|
break;
|
|
15247
15184
|
case "borderAll":
|
|
15248
|
-
setAllTableBorders(
|
|
15185
|
+
setAllTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
|
|
15249
15186
|
break;
|
|
15250
15187
|
case "borderOutside":
|
|
15251
|
-
setOutsideTableBorders(
|
|
15188
|
+
setOutsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
|
|
15252
15189
|
break;
|
|
15253
15190
|
case "borderInside":
|
|
15254
|
-
setInsideTableBorders(
|
|
15191
|
+
setInsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
|
|
15255
15192
|
break;
|
|
15256
15193
|
case "borderNone":
|
|
15257
|
-
removeTableBorders(
|
|
15194
|
+
removeTableBorders(view_9.state, view_9.dispatch);
|
|
15258
15195
|
break;
|
|
15259
15196
|
case "borderTop":
|
|
15260
|
-
setCellBorder("top", borderSpecRef.current, true)(
|
|
15197
|
+
setCellBorder("top", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
|
|
15261
15198
|
break;
|
|
15262
15199
|
case "borderBottom":
|
|
15263
|
-
setCellBorder("bottom", borderSpecRef.current, true)(
|
|
15200
|
+
setCellBorder("bottom", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
|
|
15264
15201
|
break;
|
|
15265
15202
|
case "borderLeft":
|
|
15266
|
-
setCellBorder("left", borderSpecRef.current, true)(
|
|
15203
|
+
setCellBorder("left", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
|
|
15267
15204
|
break;
|
|
15268
15205
|
case "borderRight":
|
|
15269
|
-
setCellBorder("right", borderSpecRef.current, true)(
|
|
15206
|
+
setCellBorder("right", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
|
|
15270
15207
|
break;
|
|
15271
15208
|
default: if (typeof action_0 === "object") {
|
|
15272
|
-
if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(
|
|
15209
|
+
if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(view_9.state, view_9.dispatch);
|
|
15273
15210
|
else if (action_0.type === "borderColor") {
|
|
15274
15211
|
const rgb_0 = action_0.color.replace(/^#/u, "");
|
|
15275
15212
|
borderSpecRef.current = {
|
|
15276
15213
|
...borderSpecRef.current,
|
|
15277
15214
|
color: { rgb: rgb_0 }
|
|
15278
15215
|
};
|
|
15279
|
-
setTableBorderColor(action_0.color)(
|
|
15216
|
+
setTableBorderColor(action_0.color)(view_9.state, view_9.dispatch);
|
|
15280
15217
|
} else if (action_0.type === "borderWidth") {
|
|
15281
15218
|
borderSpecRef.current = {
|
|
15282
15219
|
...borderSpecRef.current,
|
|
15283
15220
|
size: action_0.size
|
|
15284
15221
|
};
|
|
15285
|
-
setTableBorderWidth(action_0.size)(
|
|
15222
|
+
setTableBorderWidth(action_0.size)(view_9.state, view_9.dispatch);
|
|
15286
15223
|
} else if (action_0.type === "cellBorder") setCellBorder(action_0.side, {
|
|
15287
15224
|
style: action_0.style,
|
|
15288
15225
|
size: action_0.size,
|
|
15289
15226
|
color: { rgb: action_0.color.replace(/^#/u, "") }
|
|
15290
|
-
})(
|
|
15291
|
-
else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(
|
|
15292
|
-
else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(
|
|
15293
|
-
else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(
|
|
15294
|
-
else if (action_0.type === "toggleNoWrap") toggleNoWrap()(
|
|
15295
|
-
else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(
|
|
15296
|
-
else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(
|
|
15297
|
-
else if (action_0.type === "distributeColumns") distributeColumns()(
|
|
15298
|
-
else if (action_0.type === "autoFitContents") autoFitContents()(
|
|
15227
|
+
})(view_9.state, view_9.dispatch);
|
|
15228
|
+
else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(view_9.state, view_9.dispatch);
|
|
15229
|
+
else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(view_9.state, view_9.dispatch);
|
|
15230
|
+
else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(view_9.state, view_9.dispatch);
|
|
15231
|
+
else if (action_0.type === "toggleNoWrap") toggleNoWrap()(view_9.state, view_9.dispatch);
|
|
15232
|
+
else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(view_9.state, view_9.dispatch);
|
|
15233
|
+
else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(view_9.state, view_9.dispatch);
|
|
15234
|
+
else if (action_0.type === "distributeColumns") distributeColumns()(view_9.state, view_9.dispatch);
|
|
15235
|
+
else if (action_0.type === "autoFitContents") autoFitContents()(view_9.state, view_9.dispatch);
|
|
15299
15236
|
else if (action_0.type === "openTableProperties") setTablePropsOpen(true);
|
|
15300
|
-
else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(
|
|
15237
|
+
else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(view_9.state, view_9.dispatch);
|
|
15301
15238
|
else {
|
|
15302
15239
|
let preset = getBuiltinTableStyle(action_0.styleId);
|
|
15303
15240
|
const currentDocForTable = historyStateRef.current;
|
|
@@ -15368,7 +15305,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15368
15305
|
if (preset.tableBorders) styleArg.tableBorders = preset.tableBorders;
|
|
15369
15306
|
if (preset.conditionals) styleArg.conditionals = preset.conditionals;
|
|
15370
15307
|
if (preset.look) styleArg.look = preset.look;
|
|
15371
|
-
applyTableStyle(styleArg)(
|
|
15308
|
+
applyTableStyle(styleArg)(view_9.state, view_9.dispatch);
|
|
15372
15309
|
}
|
|
15373
15310
|
}
|
|
15374
15311
|
} else tableSelection.handleAction(action_0);
|
|
@@ -15389,86 +15326,86 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15389
15326
|
});
|
|
15390
15327
|
}, [openContextMenu]);
|
|
15391
15328
|
const handleFormat = useCallback((action_1) => {
|
|
15392
|
-
const
|
|
15393
|
-
if (!
|
|
15394
|
-
|
|
15395
|
-
const isBodyEditor =
|
|
15396
|
-
const { from: from_1, to: to_1 } =
|
|
15329
|
+
const view_10 = getActiveEditorView();
|
|
15330
|
+
if (!view_10) return;
|
|
15331
|
+
view_10.focus();
|
|
15332
|
+
const isBodyEditor = view_10 === pagedEditorRef.current?.getView();
|
|
15333
|
+
const { from: from_1, to: to_1 } = view_10.state.selection;
|
|
15397
15334
|
const savedSelection = lastSelectionRef.current;
|
|
15398
15335
|
if (isBodyEditor && savedSelection && (from_1 !== savedSelection.from || to_1 !== savedSelection.to)) try {
|
|
15399
|
-
const tr =
|
|
15400
|
-
|
|
15336
|
+
const tr = view_10.state.tr.setSelection(TextSelection.create(view_10.state.doc, savedSelection.from, savedSelection.to));
|
|
15337
|
+
view_10.dispatch(tr);
|
|
15401
15338
|
} catch {}
|
|
15402
15339
|
if (action_1 === "bold") {
|
|
15403
|
-
executeEditorCommand(
|
|
15340
|
+
executeEditorCommand(view_10, toggleBold);
|
|
15404
15341
|
return;
|
|
15405
15342
|
}
|
|
15406
15343
|
if (action_1 === "italic") {
|
|
15407
|
-
executeEditorCommand(
|
|
15344
|
+
executeEditorCommand(view_10, toggleItalic);
|
|
15408
15345
|
return;
|
|
15409
15346
|
}
|
|
15410
15347
|
if (action_1 === "underline") {
|
|
15411
|
-
executeEditorCommand(
|
|
15348
|
+
executeEditorCommand(view_10, toggleUnderline);
|
|
15412
15349
|
return;
|
|
15413
15350
|
}
|
|
15414
15351
|
if (action_1 === "strikethrough") {
|
|
15415
|
-
executeEditorCommand(
|
|
15352
|
+
executeEditorCommand(view_10, toggleStrike);
|
|
15416
15353
|
return;
|
|
15417
15354
|
}
|
|
15418
15355
|
if (action_1 === "superscript") {
|
|
15419
|
-
executeEditorCommand(
|
|
15356
|
+
executeEditorCommand(view_10, toggleSuperscript);
|
|
15420
15357
|
return;
|
|
15421
15358
|
}
|
|
15422
15359
|
if (action_1 === "subscript") {
|
|
15423
|
-
executeEditorCommand(
|
|
15360
|
+
executeEditorCommand(view_10, toggleSubscript);
|
|
15424
15361
|
return;
|
|
15425
15362
|
}
|
|
15426
15363
|
if (action_1 === "bulletList") {
|
|
15427
|
-
executeEditorCommand(
|
|
15364
|
+
executeEditorCommand(view_10, toggleBulletList);
|
|
15428
15365
|
return;
|
|
15429
15366
|
}
|
|
15430
15367
|
if (action_1 === "numberedList") {
|
|
15431
|
-
executeEditorCommand(
|
|
15368
|
+
executeEditorCommand(view_10, toggleNumberedList);
|
|
15432
15369
|
return;
|
|
15433
15370
|
}
|
|
15434
15371
|
if (action_1 === "indent") {
|
|
15435
|
-
executeFirstEditorCommand(
|
|
15372
|
+
executeFirstEditorCommand(view_10, [increaseListLevel, increaseIndent()]);
|
|
15436
15373
|
return;
|
|
15437
15374
|
}
|
|
15438
15375
|
if (action_1 === "outdent") {
|
|
15439
|
-
executeFirstEditorCommand(
|
|
15376
|
+
executeFirstEditorCommand(view_10, [decreaseListLevel, decreaseIndent()]);
|
|
15440
15377
|
return;
|
|
15441
15378
|
}
|
|
15442
15379
|
if (action_1 === "clearFormatting") {
|
|
15443
|
-
executeEditorCommand(
|
|
15380
|
+
executeEditorCommand(view_10, clearFormatting);
|
|
15444
15381
|
return;
|
|
15445
15382
|
}
|
|
15446
15383
|
if (action_1 === "setRtl") {
|
|
15447
|
-
executeEditorCommand(
|
|
15384
|
+
executeEditorCommand(view_10, setRtl);
|
|
15448
15385
|
return;
|
|
15449
15386
|
}
|
|
15450
15387
|
if (action_1 === "setLtr") {
|
|
15451
|
-
executeEditorCommand(
|
|
15388
|
+
executeEditorCommand(view_10, setLtr);
|
|
15452
15389
|
return;
|
|
15453
15390
|
}
|
|
15454
15391
|
if (action_1 === "insertPageBreak") {
|
|
15455
|
-
executeEditorCommand(
|
|
15392
|
+
executeEditorCommand(view_10, insertPageBreak);
|
|
15456
15393
|
return;
|
|
15457
15394
|
}
|
|
15458
15395
|
if (typeof action_1 === "object") switch (action_1.type) {
|
|
15459
15396
|
case "alignment":
|
|
15460
|
-
executeEditorCommand(
|
|
15397
|
+
executeEditorCommand(view_10, setAlignment(action_1.value));
|
|
15461
15398
|
break;
|
|
15462
15399
|
case "toggleDirection":
|
|
15463
|
-
executeEditorCommand(
|
|
15400
|
+
executeEditorCommand(view_10, toggleBidi);
|
|
15464
15401
|
break;
|
|
15465
15402
|
case "textColor": {
|
|
15466
15403
|
const colorVal_0 = action_1.value;
|
|
15467
|
-
if (typeof colorVal_0 === "string") executeEditorCommand(
|
|
15468
|
-
else if (colorVal_0.auto) executeEditorCommand(
|
|
15404
|
+
if (typeof colorVal_0 === "string") executeEditorCommand(view_10, setTextColor({ rgb: colorVal_0.replace("#", "") }));
|
|
15405
|
+
else if (colorVal_0.auto) executeEditorCommand(view_10, clearTextColor);
|
|
15469
15406
|
else {
|
|
15470
15407
|
const themeColor = typeof colorVal_0.themeColor === "string" ? colorVal_0.themeColor : void 0;
|
|
15471
|
-
executeEditorCommand(
|
|
15408
|
+
executeEditorCommand(view_10, setTextColor({
|
|
15472
15409
|
...colorVal_0.rgb === void 0 ? {} : { rgb: colorVal_0.rgb },
|
|
15473
15410
|
...themeColor ? { themeColor } : {},
|
|
15474
15411
|
...colorVal_0.themeTint === void 0 ? {} : { themeTint: colorVal_0.themeTint },
|
|
@@ -15479,17 +15416,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15479
15416
|
}
|
|
15480
15417
|
case "highlightColor": {
|
|
15481
15418
|
const highlightName = action_1.value ? mapHexToHighlightName(action_1.value) : "";
|
|
15482
|
-
executeEditorCommand(
|
|
15419
|
+
executeEditorCommand(view_10, setHighlight(highlightName || action_1.value));
|
|
15483
15420
|
break;
|
|
15484
15421
|
}
|
|
15485
15422
|
case "fontSize":
|
|
15486
|
-
executeEditorCommand(
|
|
15423
|
+
executeEditorCommand(view_10, setFontSize(pointsToHalfPoints(action_1.value)));
|
|
15487
15424
|
break;
|
|
15488
15425
|
case "fontFamily":
|
|
15489
|
-
executeEditorCommand(
|
|
15426
|
+
executeEditorCommand(view_10, setFontFamily(action_1.value));
|
|
15490
15427
|
break;
|
|
15491
15428
|
case "lineSpacing":
|
|
15492
|
-
executeEditorCommand(
|
|
15429
|
+
executeEditorCommand(view_10, setLineSpacing(action_1.value));
|
|
15493
15430
|
break;
|
|
15494
15431
|
case "applyStyle": {
|
|
15495
15432
|
const currentDoc_0 = historyStateRef.current;
|
|
@@ -15502,21 +15439,21 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15502
15439
|
const styleName = styleResolver_0.getStyle(action_1.value)?.name;
|
|
15503
15440
|
if (styleName) styleAttrs.styleName = styleName;
|
|
15504
15441
|
styleAttrs.numbering = currentDoc_0?.package.numbering ? getCachedNumberingMap(currentDoc_0.package.numbering) : null;
|
|
15505
|
-
executeEditorCommand(
|
|
15506
|
-
} else executeEditorCommand(
|
|
15442
|
+
executeEditorCommand(view_10, applyStyle(action_1.value, styleAttrs));
|
|
15443
|
+
} else executeEditorCommand(view_10, applyStyle(action_1.value));
|
|
15507
15444
|
break;
|
|
15508
15445
|
}
|
|
15509
15446
|
}
|
|
15510
15447
|
}, [getActiveEditorView, getCachedStyleResolver]);
|
|
15511
15448
|
const captureFormatPainter = useCallback(() => {
|
|
15512
|
-
const
|
|
15513
|
-
capturedFormatMarksRef.current =
|
|
15449
|
+
const view_11 = getActiveEditorView();
|
|
15450
|
+
capturedFormatMarksRef.current = view_11 ? captureFormatMarks(view_11.state) : null;
|
|
15514
15451
|
}, [getActiveEditorView]);
|
|
15515
15452
|
const paintFormatToSelection = useCallback(() => {
|
|
15516
|
-
const
|
|
15517
|
-
if (!
|
|
15518
|
-
const applied = applyFormatMarks(capturedFormatMarksRef.current)(
|
|
15519
|
-
if (applied) requestAnimationFrame(() =>
|
|
15453
|
+
const view_12 = getActiveEditorView();
|
|
15454
|
+
if (!view_12) return false;
|
|
15455
|
+
const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_12.state, view_12.dispatch);
|
|
15456
|
+
if (applied) requestAnimationFrame(() => view_12.focus());
|
|
15520
15457
|
return applied;
|
|
15521
15458
|
}, [getActiveEditorView]);
|
|
15522
15459
|
const handleFormatPainter = useCallback((sticky) => {
|
|
@@ -15658,14 +15595,29 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15658
15595
|
label: t("tableBordersNone"),
|
|
15659
15596
|
dividerAfter: true
|
|
15660
15597
|
});
|
|
15661
|
-
if (contextMenu.cursorInTrackedChange)
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15598
|
+
if (contextMenu.cursorInTrackedChange) {
|
|
15599
|
+
const held = state.activeTrackedChange?.heldByLock ?? {
|
|
15600
|
+
accept: false,
|
|
15601
|
+
reject: false
|
|
15602
|
+
};
|
|
15603
|
+
const reason = t("trackedChanges.heldByLock");
|
|
15604
|
+
items.push({
|
|
15605
|
+
action: "acceptChange",
|
|
15606
|
+
label: t("acceptChange"),
|
|
15607
|
+
...held.accept && {
|
|
15608
|
+
disabled: true,
|
|
15609
|
+
disabledReason: reason
|
|
15610
|
+
}
|
|
15611
|
+
}, {
|
|
15612
|
+
action: "rejectChange",
|
|
15613
|
+
label: t("rejectChange"),
|
|
15614
|
+
dividerAfter: true,
|
|
15615
|
+
...held.reject && {
|
|
15616
|
+
disabled: true,
|
|
15617
|
+
disabledReason: reason
|
|
15618
|
+
}
|
|
15619
|
+
});
|
|
15620
|
+
}
|
|
15669
15621
|
if (contextMenu.listNumbering.type === "listItem") items.push({
|
|
15670
15622
|
action: "restartNumbering",
|
|
15671
15623
|
label: t("contextMenu.restartNumbering")
|
|
@@ -15691,19 +15643,20 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15691
15643
|
contextMenu.listNumbering,
|
|
15692
15644
|
customContextMenuItems,
|
|
15693
15645
|
readOnly,
|
|
15646
|
+
state.activeTrackedChange?.heldByLock,
|
|
15694
15647
|
t
|
|
15695
15648
|
]);
|
|
15696
15649
|
const { from: contextSelectionFrom, to: contextSelectionTo } = contextMenu.selectionRange;
|
|
15697
15650
|
const handleContextMenuAction = useCallback(async (action_2) => {
|
|
15698
|
-
const
|
|
15699
|
-
if (!
|
|
15651
|
+
const view_13 = getActiveEditorView();
|
|
15652
|
+
if (!view_13) return;
|
|
15700
15653
|
focusActiveEditor();
|
|
15701
15654
|
if (readOnly && action_2 !== "copy" && action_2 !== "selectAll") return;
|
|
15702
15655
|
if (action_2.startsWith("custom:")) {
|
|
15703
15656
|
const { from: from_2, to: to_2 } = contextSelectionFrom !== contextSelectionTo ? {
|
|
15704
15657
|
from: contextSelectionFrom,
|
|
15705
15658
|
to: contextSelectionTo
|
|
15706
|
-
} :
|
|
15659
|
+
} : view_13.state.selection;
|
|
15707
15660
|
onCustomContextAction?.(action_2.slice(7), {
|
|
15708
15661
|
from: from_2,
|
|
15709
15662
|
to: to_2
|
|
@@ -15713,16 +15666,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15713
15666
|
switch (action_2) {
|
|
15714
15667
|
case "cut": {
|
|
15715
15668
|
if (readOnly) return;
|
|
15716
|
-
const { from: from_7, to: to_7 } =
|
|
15717
|
-
const text_2 =
|
|
15669
|
+
const { from: from_7, to: to_7 } = view_13.state.selection;
|
|
15670
|
+
const text_2 = view_13.state.doc.textBetween(from_7, to_7, "\n");
|
|
15718
15671
|
navigator.clipboard.writeText(text_2).catch(() => void 0);
|
|
15719
|
-
if (!deleteSelectionAsSuggestion(
|
|
15672
|
+
if (!deleteSelectionAsSuggestion(view_13.state, view_13.dispatch)) view_13.dispatch(view_13.state.tr.deleteSelection());
|
|
15720
15673
|
onCut?.();
|
|
15721
15674
|
break;
|
|
15722
15675
|
}
|
|
15723
15676
|
case "copy": {
|
|
15724
|
-
const { from: cf, to: ct } =
|
|
15725
|
-
const copied =
|
|
15677
|
+
const { from: cf, to: ct } = view_13.state.selection;
|
|
15678
|
+
const copied = view_13.state.doc.textBetween(cf, ct, "\n");
|
|
15726
15679
|
navigator.clipboard.writeText(copied).catch(() => void 0);
|
|
15727
15680
|
onCopy?.();
|
|
15728
15681
|
break;
|
|
@@ -15745,12 +15698,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15745
15698
|
bubbles: true,
|
|
15746
15699
|
cancelable: true
|
|
15747
15700
|
});
|
|
15748
|
-
|
|
15701
|
+
view_13.dom.dispatchEvent(pasteEvent);
|
|
15749
15702
|
} catch {
|
|
15750
15703
|
try {
|
|
15751
15704
|
const text_0 = await navigator.clipboard.readText();
|
|
15752
15705
|
if (text_0) {
|
|
15753
|
-
|
|
15706
|
+
view_13.dispatch(view_13.state.tr.insertText(text_0));
|
|
15754
15707
|
onPaste?.();
|
|
15755
15708
|
}
|
|
15756
15709
|
} catch {}
|
|
@@ -15759,8 +15712,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15759
15712
|
case "pasteAsPlainText":
|
|
15760
15713
|
try {
|
|
15761
15714
|
const text = await navigator.clipboard.readText();
|
|
15762
|
-
if (text && !
|
|
15763
|
-
pastePlainTextSlice(
|
|
15715
|
+
if (text && !view_13.isDestroyed) {
|
|
15716
|
+
pastePlainTextSlice(view_13, buildPlainTextSlice(text, view_13.state.schema));
|
|
15764
15717
|
onPaste?.();
|
|
15765
15718
|
}
|
|
15766
15719
|
} catch {
|
|
@@ -15768,42 +15721,42 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15768
15721
|
}
|
|
15769
15722
|
break;
|
|
15770
15723
|
case "delete": {
|
|
15771
|
-
const { from: from_6, to: to_6 } =
|
|
15772
|
-
if (from_6 !== to_6)
|
|
15724
|
+
const { from: from_6, to: to_6 } = view_13.state.selection;
|
|
15725
|
+
if (from_6 !== to_6) view_13.dispatch(view_13.state.tr.deleteRange(from_6, to_6));
|
|
15773
15726
|
break;
|
|
15774
15727
|
}
|
|
15775
15728
|
case "selectAll":
|
|
15776
|
-
|
|
15729
|
+
view_13.dispatch(view_13.state.tr.setSelection(TextSelection.create(view_13.state.doc, 0, view_13.state.doc.content.size)));
|
|
15777
15730
|
break;
|
|
15778
15731
|
case "addRowAbove":
|
|
15779
|
-
addRowAbove(
|
|
15732
|
+
addRowAbove(view_13.state, view_13.dispatch);
|
|
15780
15733
|
break;
|
|
15781
15734
|
case "addRowBelow":
|
|
15782
|
-
addRowBelow(
|
|
15735
|
+
addRowBelow(view_13.state, view_13.dispatch);
|
|
15783
15736
|
break;
|
|
15784
15737
|
case "deleteRow":
|
|
15785
|
-
deleteRow(
|
|
15738
|
+
deleteRow(view_13.state, view_13.dispatch);
|
|
15786
15739
|
break;
|
|
15787
15740
|
case "addColumnLeft":
|
|
15788
|
-
addColumnLeft(
|
|
15741
|
+
addColumnLeft(view_13.state, view_13.dispatch);
|
|
15789
15742
|
break;
|
|
15790
15743
|
case "addColumnRight":
|
|
15791
|
-
addColumnRight(
|
|
15744
|
+
addColumnRight(view_13.state, view_13.dispatch);
|
|
15792
15745
|
break;
|
|
15793
15746
|
case "deleteColumn":
|
|
15794
|
-
deleteColumn(
|
|
15747
|
+
deleteColumn(view_13.state, view_13.dispatch);
|
|
15795
15748
|
break;
|
|
15796
15749
|
case "tableBordersAll":
|
|
15797
|
-
setTableBorderPreset("all")(
|
|
15750
|
+
setTableBorderPreset("all")(view_13.state, view_13.dispatch);
|
|
15798
15751
|
break;
|
|
15799
15752
|
case "tableBordersNone":
|
|
15800
|
-
setTableBorderPreset("none")(
|
|
15753
|
+
setTableBorderPreset("none")(view_13.state, view_13.dispatch);
|
|
15801
15754
|
break;
|
|
15802
15755
|
case "addComment": {
|
|
15803
15756
|
const { from: from_5, to: to_5 } = contextSelectionFrom !== contextSelectionTo ? {
|
|
15804
15757
|
from: contextSelectionFrom,
|
|
15805
15758
|
to: contextSelectionTo
|
|
15806
|
-
} :
|
|
15759
|
+
} : view_13.state.selection;
|
|
15807
15760
|
if (from_5 === to_5) break;
|
|
15808
15761
|
const commentY = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, from_5) ?? getFallbackCommentYPosition(scrollContainerRef.current);
|
|
15809
15762
|
setCommentSelectionRange({
|
|
@@ -15811,10 +15764,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15811
15764
|
to: to_5
|
|
15812
15765
|
});
|
|
15813
15766
|
if (commentDraftMode === "prosemirror") {
|
|
15814
|
-
if (!
|
|
15767
|
+
if (!markPendingComment(view_13, {
|
|
15815
15768
|
from: from_5,
|
|
15816
15769
|
to: to_5
|
|
15817
|
-
},
|
|
15770
|
+
}, { selectEnd: true })) break;
|
|
15818
15771
|
}
|
|
15819
15772
|
setAddCommentYPosition(commentY);
|
|
15820
15773
|
setShowCommentsSidebar(true);
|
|
@@ -15823,30 +15776,30 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15823
15776
|
break;
|
|
15824
15777
|
}
|
|
15825
15778
|
case "acceptChange": {
|
|
15826
|
-
const { from: from_4, to: to_4 } =
|
|
15827
|
-
const range_0 = findChangeAtPosition(
|
|
15779
|
+
const { from: from_4, to: to_4 } = view_13.state.selection;
|
|
15780
|
+
const range_0 = findChangeAtPosition(view_13.state, from_4, to_4);
|
|
15828
15781
|
if (resolveCanonicalReviewRange({
|
|
15829
15782
|
editor: pagedEditorRef.current?.getEditor(),
|
|
15830
15783
|
...range_0,
|
|
15831
15784
|
resolution: "accept"
|
|
15832
|
-
}) === null) acceptChange(range_0.from, range_0.to)(
|
|
15785
|
+
}) === null) acceptChange(range_0.from, range_0.to)(view_13.state, view_13.dispatch);
|
|
15833
15786
|
break;
|
|
15834
15787
|
}
|
|
15835
15788
|
case "rejectChange": {
|
|
15836
|
-
const { from: from_3, to: to_3 } =
|
|
15837
|
-
const range = findChangeAtPosition(
|
|
15789
|
+
const { from: from_3, to: to_3 } = view_13.state.selection;
|
|
15790
|
+
const range = findChangeAtPosition(view_13.state, from_3, to_3);
|
|
15838
15791
|
if (resolveCanonicalReviewRange({
|
|
15839
15792
|
editor: pagedEditorRef.current?.getEditor(),
|
|
15840
15793
|
...range,
|
|
15841
15794
|
resolution: "reject"
|
|
15842
|
-
}) === null) rejectChange(range.from, range.to)(
|
|
15795
|
+
}) === null) rejectChange(range.from, range.to)(view_13.state, view_13.dispatch);
|
|
15843
15796
|
break;
|
|
15844
15797
|
}
|
|
15845
15798
|
case "restartNumbering":
|
|
15846
|
-
restartNumbering(
|
|
15799
|
+
restartNumbering(view_13.state, view_13.dispatch);
|
|
15847
15800
|
break;
|
|
15848
15801
|
case "continueNumbering":
|
|
15849
|
-
continueNumbering(
|
|
15802
|
+
continueNumbering(view_13.state, view_13.dispatch);
|
|
15850
15803
|
break;
|
|
15851
15804
|
case "setNumberingValue": setNumberingValueDialogOpen(true);
|
|
15852
15805
|
}
|
|
@@ -15903,25 +15856,25 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15903
15856
|
const handleTopMarginChange = useCallback((twips_1) => handlePageSetupApply({ marginTop: twips_1 }), [handlePageSetupApply]);
|
|
15904
15857
|
const handleBottomMarginChange = useCallback((twips_2) => handlePageSetupApply({ marginBottom: twips_2 }), [handlePageSetupApply]);
|
|
15905
15858
|
const handleIndentLeftChange = useCallback((twips_3) => {
|
|
15906
|
-
const view_13 = getActiveEditorView();
|
|
15907
|
-
if (!view_13) return;
|
|
15908
|
-
setIndentLeft(twips_3)(view_13.state, view_13.dispatch);
|
|
15909
|
-
}, [getActiveEditorView]);
|
|
15910
|
-
const handleIndentRightChange = useCallback((twips_4) => {
|
|
15911
15859
|
const view_14 = getActiveEditorView();
|
|
15912
15860
|
if (!view_14) return;
|
|
15913
|
-
|
|
15861
|
+
setIndentLeft(twips_3)(view_14.state, view_14.dispatch);
|
|
15914
15862
|
}, [getActiveEditorView]);
|
|
15915
|
-
const
|
|
15863
|
+
const handleIndentRightChange = useCallback((twips_4) => {
|
|
15916
15864
|
const view_15 = getActiveEditorView();
|
|
15917
15865
|
if (!view_15) return;
|
|
15918
|
-
|
|
15919
|
-
else setIndentFirstLine(twips_5, false)(view_15.state, view_15.dispatch);
|
|
15866
|
+
setIndentRight(twips_4)(view_15.state, view_15.dispatch);
|
|
15920
15867
|
}, [getActiveEditorView]);
|
|
15921
|
-
const
|
|
15868
|
+
const handleFirstLineIndentChange = useCallback((twips_5) => {
|
|
15922
15869
|
const view_16 = getActiveEditorView();
|
|
15923
15870
|
if (!view_16) return;
|
|
15924
|
-
|
|
15871
|
+
if (twips_5 < 0) setIndentFirstLine(-twips_5, true)(view_16.state, view_16.dispatch);
|
|
15872
|
+
else setIndentFirstLine(twips_5, false)(view_16.state, view_16.dispatch);
|
|
15873
|
+
}, [getActiveEditorView]);
|
|
15874
|
+
const handleTabStopRemove = useCallback((positionTwips) => {
|
|
15875
|
+
const view_17 = getActiveEditorView();
|
|
15876
|
+
if (!view_17) return;
|
|
15877
|
+
removeTabStop(positionTwips)(view_17.state, view_17.dispatch);
|
|
15925
15878
|
}, [getActiveEditorView]);
|
|
15926
15879
|
const serializeCurrentDocx = useCallback(async (options) => {
|
|
15927
15880
|
let tripwireResult = null;
|
|
@@ -15930,8 +15883,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15930
15883
|
const editor_2 = pagedEditorRef.current?.getEditor();
|
|
15931
15884
|
const snapshot_0 = editor_2?.captureCanonicalSave();
|
|
15932
15885
|
if (snapshot_0 && editor_2) {
|
|
15933
|
-
const
|
|
15934
|
-
const editorState =
|
|
15886
|
+
const view_18 = editor_2.getView();
|
|
15887
|
+
const editorState = view_18?.state;
|
|
15935
15888
|
const result_2 = await serializeCanonicalSave({
|
|
15936
15889
|
snapshot: snapshot_0,
|
|
15937
15890
|
options,
|
|
@@ -15943,15 +15896,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15943
15896
|
message: `Canonical save used a fidelity fallback: ${diagnostic.type} (${diagnostic.part}).`
|
|
15944
15897
|
}));
|
|
15945
15898
|
tripwireResult = result_2.tripwireResult;
|
|
15946
|
-
if (
|
|
15899
|
+
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));
|
|
15947
15900
|
savedBuffer = result_2.buffer;
|
|
15948
15901
|
} else {
|
|
15949
15902
|
if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.save)) return null;
|
|
15950
|
-
const
|
|
15951
|
-
const editorState_0 =
|
|
15903
|
+
const view_19 = pagedEditorRef.current?.getView();
|
|
15904
|
+
const editorState_0 = view_19?.state;
|
|
15952
15905
|
const baselineBuffer = originalBufferRef.current;
|
|
15953
|
-
const
|
|
15954
|
-
const doc_1 =
|
|
15906
|
+
const current_0 = buildCurrentDocument();
|
|
15907
|
+
const doc_1 = current_0 ? withoutUnreferencedNotes(current_0) : null;
|
|
15955
15908
|
if (!doc_1) return null;
|
|
15956
15909
|
const { resolveSelectiveSaveFlags } = await import("@stll/folio-core/docx/selectiveSaveFlags");
|
|
15957
15910
|
const flags = resolveSelectiveSaveFlags(featureFlags);
|
|
@@ -15989,9 +15942,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15989
15942
|
const { compareSelectiveVsFull } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
|
|
15990
15943
|
tripwireResult = await compareSelectiveVsFull(selectiveBuffer, fullBuffer);
|
|
15991
15944
|
} catch {}
|
|
15992
|
-
if (
|
|
15945
|
+
if (view_19 && pagedEditorRef.current?.getView() === view_19 && view_19.state.doc === editorState_0?.doc) {
|
|
15993
15946
|
originalBufferRef.current = buffer;
|
|
15994
|
-
|
|
15947
|
+
view_19.dispatch(clearTrackedChanges(view_19.state));
|
|
15995
15948
|
}
|
|
15996
15949
|
savedBuffer = buffer;
|
|
15997
15950
|
}
|
|
@@ -16032,9 +15985,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16032
15985
|
serializeCurrentDocx
|
|
16033
15986
|
]);
|
|
16034
15987
|
const handleEditorError = useCallback((error_1) => {
|
|
16035
|
-
if (CanonicalSessionRefusalError.is(error_1)) toast(error_1.
|
|
15988
|
+
if (CanonicalSessionRefusalError.is(error_1)) toast(canonicalRefusalNotice(error_1.ground, t));
|
|
16036
15989
|
onError?.(error_1);
|
|
16037
|
-
}, [onError]);
|
|
15990
|
+
}, [onError, t]);
|
|
16038
15991
|
useImperativeHandle(ref, () => ({
|
|
16039
15992
|
getReadOnlyReason: () => readOnlyReason,
|
|
16040
15993
|
getDocument: () => buildCurrentDocument(),
|
|
@@ -16047,9 +16000,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16047
16000
|
getFindResult,
|
|
16048
16001
|
clearFind: resetFindResult,
|
|
16049
16002
|
hasPendingChanges: () => {
|
|
16050
|
-
const
|
|
16051
|
-
if (!
|
|
16052
|
-
return getCommentsDirty() || getChangedParagraphIds(
|
|
16003
|
+
const view_20 = pagedEditorRef.current?.getView();
|
|
16004
|
+
if (!view_20) return false;
|
|
16005
|
+
return getCommentsDirty() || getChangedParagraphIds(view_20.state).size > 0 || hasStructuralChanges(view_20.state) || hasUntrackedChanges(view_20.state);
|
|
16053
16006
|
},
|
|
16054
16007
|
getEditorRef: () => pagedEditorRef.current,
|
|
16055
16008
|
getEditor: () => pagedEditorRef.current?.getEditor() ?? null,
|
|
@@ -16094,13 +16047,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16094
16047
|
pagedEditorRef.current?.ensureView(options_3);
|
|
16095
16048
|
},
|
|
16096
16049
|
createAIEditSnapshot: () => {
|
|
16097
|
-
const
|
|
16098
|
-
return
|
|
16050
|
+
const view_21 = pagedEditorRef.current?.getView();
|
|
16051
|
+
return view_21 ? createFolioAIEditSnapshot(view_21.state.doc) : null;
|
|
16099
16052
|
},
|
|
16100
16053
|
applyDocumentOperations: ({ undefinedReferences, snapshot: snapshot_1, batch, author: operationAuthor = author }) => {
|
|
16101
16054
|
assertSupportedFolioDocumentOperationVersion(batch.version);
|
|
16102
|
-
const
|
|
16103
|
-
if (!
|
|
16055
|
+
const view_22 = pagedEditorRef.current?.getView();
|
|
16056
|
+
if (!view_22) {
|
|
16104
16057
|
let status = "committed";
|
|
16105
16058
|
if (batch.dryRun === true) status = "previewed";
|
|
16106
16059
|
else if (batch.atomic === true) status = "rejected";
|
|
@@ -16118,25 +16071,36 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16118
16071
|
undoHandle: null
|
|
16119
16072
|
};
|
|
16120
16073
|
}
|
|
16074
|
+
const activeBeforeCanonical = new Set(getSuggestions(view_22.state).map((s_0) => s_0.suggestionId));
|
|
16121
16075
|
const canonical_1 = getCanonicalApi()?.applyCanonicalDocumentOperations({
|
|
16122
16076
|
undefinedReferences,
|
|
16123
16077
|
snapshot: snapshot_1,
|
|
16124
16078
|
batch,
|
|
16125
16079
|
author: operationAuthor
|
|
16126
16080
|
});
|
|
16127
|
-
if (canonical_1)
|
|
16081
|
+
if (canonical_1) {
|
|
16082
|
+
if (batch.mode === "suggested" && canonical_1.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
|
|
16083
|
+
snapshot: snapshot_1,
|
|
16084
|
+
story: { type: "main" },
|
|
16085
|
+
operations: batch.operations,
|
|
16086
|
+
applied: canonical_1.applied,
|
|
16087
|
+
author: operationAuthor,
|
|
16088
|
+
activeSuggestionIds: activeBeforeCanonical
|
|
16089
|
+
});
|
|
16090
|
+
return canonical_1;
|
|
16091
|
+
}
|
|
16128
16092
|
const existingUndoEntry = documentOperationUndoEntriesRef.current.at(-1);
|
|
16129
|
-
if (existingUndoEntry && (!
|
|
16130
|
-
const commentsBefore = commentsRef.current;
|
|
16093
|
+
if (existingUndoEntry && (!view_22.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentRecordsOf(view_22.state)) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
|
|
16131
16094
|
const createdComments = [];
|
|
16095
|
+
const recordingView = recordingCommentsView(view_22, createdComments);
|
|
16132
16096
|
const operationView = {
|
|
16133
|
-
state:
|
|
16097
|
+
state: view_22.state,
|
|
16134
16098
|
dispatch: (transaction) => {
|
|
16135
|
-
|
|
16136
|
-
operationView.state =
|
|
16099
|
+
recordingView.dispatch(closeHistory(transaction));
|
|
16100
|
+
operationView.state = view_22.state;
|
|
16137
16101
|
}
|
|
16138
16102
|
};
|
|
16139
|
-
const activeSuggestionIds = new Set(getSuggestions(
|
|
16103
|
+
const activeSuggestionIds = new Set(getSuggestions(view_22.state).map((s_1) => s_1.suggestionId));
|
|
16140
16104
|
const result_3 = applyFolioDocumentOperations({
|
|
16141
16105
|
undefinedReferences,
|
|
16142
16106
|
view: operationView,
|
|
@@ -16161,14 +16125,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16161
16125
|
author: operationAuthor,
|
|
16162
16126
|
activeSuggestionIds
|
|
16163
16127
|
});
|
|
16164
|
-
const batchComments = appliedOperationComments(createdComments, result_3.applied);
|
|
16165
|
-
const commentsAfter = batchComments.length > 0 ? [...commentsRef.current, ...batchComments] : commentsRef.current;
|
|
16166
|
-
if (batchComments.length > 0) replaceComments(commentsAfter);
|
|
16167
16128
|
if (result_3.undoHandle !== null) documentOperationUndoEntriesRef.current.push({
|
|
16168
16129
|
undoHandle: result_3.undoHandle,
|
|
16169
|
-
afterState:
|
|
16170
|
-
|
|
16171
|
-
commentsAfterJson: canonicalJson(commentsAfter)
|
|
16130
|
+
afterState: view_22.state,
|
|
16131
|
+
commentsAfterJson: canonicalJson(commentRecordsOf(view_22.state))
|
|
16172
16132
|
});
|
|
16173
16133
|
return result_3;
|
|
16174
16134
|
},
|
|
@@ -16188,23 +16148,22 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16188
16148
|
reason: "notLatest"
|
|
16189
16149
|
};
|
|
16190
16150
|
const entry_3 = entries_0.at(-1);
|
|
16191
|
-
const
|
|
16192
|
-
if (!entry_3 || !
|
|
16151
|
+
const view_23 = pagedEditorRef.current?.getView();
|
|
16152
|
+
if (!entry_3 || !view_23) return {
|
|
16193
16153
|
status: "rejected",
|
|
16194
16154
|
undoHandle,
|
|
16195
16155
|
reason: "unknownHandle"
|
|
16196
16156
|
};
|
|
16197
|
-
if (!
|
|
16157
|
+
if (!view_23.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentRecordsOf(view_23.state)) !== entry_3.commentsAfterJson) return {
|
|
16198
16158
|
status: "rejected",
|
|
16199
16159
|
undoHandle,
|
|
16200
16160
|
reason: "documentChanged"
|
|
16201
16161
|
};
|
|
16202
|
-
if (!undo(
|
|
16162
|
+
if (!undo(view_23.state, view_23.dispatch)) return {
|
|
16203
16163
|
status: "rejected",
|
|
16204
16164
|
undoHandle,
|
|
16205
16165
|
reason: "documentChanged"
|
|
16206
16166
|
};
|
|
16207
|
-
replaceComments(entry_3.commentsBefore);
|
|
16208
16167
|
entries_0.pop();
|
|
16209
16168
|
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
16210
16169
|
return {
|
|
@@ -16213,14 +16172,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16213
16172
|
};
|
|
16214
16173
|
},
|
|
16215
16174
|
applyAIEditOperations: ({ undefinedReferences: undefinedReferences_0, snapshot: snapshot_2, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
|
|
16216
|
-
const
|
|
16217
|
-
if (!
|
|
16175
|
+
const view_24 = pagedEditorRef.current?.getView();
|
|
16176
|
+
if (!view_24) return {
|
|
16218
16177
|
applied: [],
|
|
16219
16178
|
skipped: operations.map((operation_0) => ({
|
|
16220
16179
|
id: operation_0.id,
|
|
16221
16180
|
reason: "unsupportedBlock"
|
|
16222
16181
|
}))
|
|
16223
16182
|
};
|
|
16183
|
+
const activeSuggestionIds_0 = new Set(getSuggestions(view_24.state).map((s_2) => s_2.suggestionId));
|
|
16224
16184
|
const canonical_3 = getCanonicalApi()?.applyCanonicalDocumentOperations({
|
|
16225
16185
|
undefinedReferences: undefinedReferences_0,
|
|
16226
16186
|
snapshot: snapshot_2,
|
|
@@ -16231,12 +16191,21 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16231
16191
|
},
|
|
16232
16192
|
author: operationAuthor_0
|
|
16233
16193
|
});
|
|
16234
|
-
if (canonical_3)
|
|
16194
|
+
if (canonical_3) {
|
|
16195
|
+
if (mode === "suggested" && canonical_3.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
|
|
16196
|
+
snapshot: snapshot_2,
|
|
16197
|
+
story: { type: "main" },
|
|
16198
|
+
operations,
|
|
16199
|
+
applied: canonical_3.applied,
|
|
16200
|
+
author: operationAuthor_0,
|
|
16201
|
+
activeSuggestionIds: activeSuggestionIds_0
|
|
16202
|
+
});
|
|
16203
|
+
return canonical_3;
|
|
16204
|
+
}
|
|
16235
16205
|
const createdComments_0 = [];
|
|
16236
|
-
const activeSuggestionIds_0 = new Set(getSuggestions(view_23.state).map((s_1) => s_1.suggestionId));
|
|
16237
16206
|
const { applied: applied_0, skipped: skipped_0 } = applyFolioDocumentOperations({
|
|
16238
16207
|
undefinedReferences: undefinedReferences_0,
|
|
16239
|
-
view:
|
|
16208
|
+
view: recordingCommentsView(view_24, createdComments_0),
|
|
16240
16209
|
snapshot: snapshot_2,
|
|
16241
16210
|
batch: {
|
|
16242
16211
|
version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
|
|
@@ -16250,8 +16219,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16250
16219
|
return comment_0.id;
|
|
16251
16220
|
}
|
|
16252
16221
|
});
|
|
16253
|
-
const batchComments_0 = appliedOperationComments(createdComments_0, applied_0);
|
|
16254
|
-
if (batchComments_0.length > 0) updateComments((currentComments_0) => [...currentComments_0, ...batchComments_0]);
|
|
16255
16222
|
if (mode === "suggested") pendingSuggestionRegistryRef.current.recordApplied({
|
|
16256
16223
|
snapshot: snapshot_2,
|
|
16257
16224
|
story: { type: "main" },
|
|
@@ -16266,18 +16233,18 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16266
16233
|
};
|
|
16267
16234
|
},
|
|
16268
16235
|
acceptAIEditOperation: (revisionId) => {
|
|
16269
|
-
const
|
|
16270
|
-
if (!
|
|
16236
|
+
const view_25 = pagedEditorRef.current?.getView();
|
|
16237
|
+
if (!view_25) return false;
|
|
16271
16238
|
const editor_5 = pagedEditorRef.current?.getEditor();
|
|
16272
16239
|
if (editor_5?.getCanonicalDocument()) return editor_5.resolveCanonicalRevisions(typeof revisionId === "number" ? [revisionId] : revisionId, "accept");
|
|
16273
|
-
return acceptAIEditRevision(revisionId)(
|
|
16240
|
+
return acceptAIEditRevision(revisionId)(view_25.state, view_25.dispatch);
|
|
16274
16241
|
},
|
|
16275
16242
|
rejectAIEditOperation: (revisionId_0) => {
|
|
16276
|
-
const
|
|
16277
|
-
if (!
|
|
16243
|
+
const view_26 = pagedEditorRef.current?.getView();
|
|
16244
|
+
if (!view_26) return false;
|
|
16278
16245
|
const editor_6 = pagedEditorRef.current?.getEditor();
|
|
16279
16246
|
if (editor_6?.getCanonicalDocument()) return editor_6.resolveCanonicalRevisions(typeof revisionId_0 === "number" ? [revisionId_0] : revisionId_0, "reject");
|
|
16280
|
-
return rejectAIEditRevision(revisionId_0)(
|
|
16247
|
+
return rejectAIEditRevision(revisionId_0)(view_26.state, view_26.dispatch);
|
|
16281
16248
|
},
|
|
16282
16249
|
undo: () => {
|
|
16283
16250
|
if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
|
|
@@ -16292,44 +16259,44 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16292
16259
|
return redone;
|
|
16293
16260
|
},
|
|
16294
16261
|
scrollToAIEditOperation: (revisionId_1) => {
|
|
16295
|
-
const
|
|
16296
|
-
if (!
|
|
16297
|
-
const range_1 = findAIEditRevisionRange(
|
|
16262
|
+
const view_27 = pagedEditorRef.current?.getView();
|
|
16263
|
+
if (!view_27) return false;
|
|
16264
|
+
const range_1 = findAIEditRevisionRange(view_27.state, revisionId_1);
|
|
16298
16265
|
if (!range_1) return false;
|
|
16299
|
-
const { from: from_8, to: to_8 } = clampRangeToDocSize(
|
|
16300
|
-
const $from =
|
|
16301
|
-
const $to =
|
|
16302
|
-
|
|
16266
|
+
const { from: from_8, to: to_8 } = clampRangeToDocSize(view_27.state.doc.content.size, range_1);
|
|
16267
|
+
const $from = view_27.state.doc.resolve(from_8);
|
|
16268
|
+
const $to = view_27.state.doc.resolve(to_8);
|
|
16269
|
+
view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from, $to)));
|
|
16303
16270
|
requestAnimationFrame(() => {
|
|
16304
16271
|
pagedEditorRef.current?.scrollToPosition(from_8);
|
|
16305
16272
|
});
|
|
16306
16273
|
return true;
|
|
16307
16274
|
},
|
|
16308
16275
|
scrollToBlock: (blockId, snapshot_3) => {
|
|
16309
|
-
const
|
|
16310
|
-
if (!
|
|
16276
|
+
const view_28 = pagedEditorRef.current?.getView();
|
|
16277
|
+
if (!view_28) return false;
|
|
16311
16278
|
const range_2 = resolveFolioAIBlockRange({
|
|
16312
16279
|
blockId,
|
|
16313
|
-
doc:
|
|
16280
|
+
doc: view_28.state.doc,
|
|
16314
16281
|
snapshot: snapshot_3
|
|
16315
16282
|
});
|
|
16316
16283
|
if (range_2 === null) return false;
|
|
16317
16284
|
const { from: from_9, to: to_9 } = range_2;
|
|
16318
|
-
const $from_0 =
|
|
16319
|
-
const $to_0 =
|
|
16320
|
-
|
|
16285
|
+
const $from_0 = view_28.state.doc.resolve(from_9);
|
|
16286
|
+
const $to_0 = view_28.state.doc.resolve(to_9);
|
|
16287
|
+
view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
|
|
16321
16288
|
requestAnimationFrame(() => {
|
|
16322
16289
|
pagedEditorRef.current?.scrollToPosition(from_9);
|
|
16323
16290
|
});
|
|
16324
16291
|
return true;
|
|
16325
16292
|
},
|
|
16326
16293
|
highlightPassage: ({ blockId: blockId_0, text: text_5, snapshot: snapshot_4 }) => {
|
|
16327
|
-
const
|
|
16328
|
-
if (!
|
|
16294
|
+
const view_29 = pagedEditorRef.current?.getView();
|
|
16295
|
+
if (!view_29) return "none";
|
|
16329
16296
|
const passageRange = resolvePassageRange({
|
|
16330
16297
|
blockId: blockId_0,
|
|
16331
16298
|
text: text_5,
|
|
16332
|
-
doc:
|
|
16299
|
+
doc: view_29.state.doc,
|
|
16333
16300
|
snapshot: snapshot_4
|
|
16334
16301
|
});
|
|
16335
16302
|
if (passageRange !== null) {
|
|
@@ -16342,16 +16309,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16342
16309
|
pagedEditorRef.current?.setPassageHighlight(null);
|
|
16343
16310
|
const blockRange = resolveFolioAIBlockRange({
|
|
16344
16311
|
blockId: blockId_0,
|
|
16345
|
-
doc:
|
|
16312
|
+
doc: view_29.state.doc,
|
|
16346
16313
|
snapshot: snapshot_4
|
|
16347
16314
|
});
|
|
16348
16315
|
if (blockRange === null) return "none";
|
|
16349
16316
|
const paraId_0 = getFolioParaIdFromBlockId(blockId_0);
|
|
16350
16317
|
if (paraId_0 !== null && pagedEditorRef.current?.scrollToParaId(paraId_0, { highlight: {} })) return "block";
|
|
16351
16318
|
const { from: from_10, to: to_10 } = blockRange;
|
|
16352
|
-
const $from_1 =
|
|
16353
|
-
const $to_1 =
|
|
16354
|
-
|
|
16319
|
+
const $from_1 = view_29.state.doc.resolve(from_10);
|
|
16320
|
+
const $to_1 = view_29.state.doc.resolve(to_10);
|
|
16321
|
+
view_29.dispatch(view_29.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
|
|
16355
16322
|
requestAnimationFrame(() => {
|
|
16356
16323
|
pagedEditorRef.current?.scrollToPosition(from_10);
|
|
16357
16324
|
});
|
|
@@ -16361,52 +16328,52 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16361
16328
|
pagedEditorRef.current?.setPassageHighlight(null);
|
|
16362
16329
|
},
|
|
16363
16330
|
showInDocument: (target_1, snapshot_5) => {
|
|
16364
|
-
const
|
|
16365
|
-
if (!
|
|
16331
|
+
const view_30 = pagedEditorRef.current?.getView();
|
|
16332
|
+
if (!view_30) return false;
|
|
16366
16333
|
const range_3 = target_1.type === "textRange" ? resolveFolioAITextRange({
|
|
16367
16334
|
range: target_1,
|
|
16368
|
-
doc:
|
|
16335
|
+
doc: view_30.state.doc,
|
|
16369
16336
|
snapshot: snapshot_5
|
|
16370
16337
|
}) : resolveFolioAIBlockRange({
|
|
16371
16338
|
blockId: target_1.blockId,
|
|
16372
|
-
doc:
|
|
16339
|
+
doc: view_30.state.doc,
|
|
16373
16340
|
snapshot: snapshot_5
|
|
16374
16341
|
});
|
|
16375
16342
|
if (range_3 === null) return false;
|
|
16376
16343
|
const { from: from_11, to: to_11 } = range_3;
|
|
16377
|
-
const $from_2 =
|
|
16378
|
-
const $to_2 =
|
|
16379
|
-
|
|
16344
|
+
const $from_2 = view_30.state.doc.resolve(from_11);
|
|
16345
|
+
const $to_2 = view_30.state.doc.resolve(to_11);
|
|
16346
|
+
view_30.dispatch(view_30.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
|
|
16380
16347
|
requestAnimationFrame(() => {
|
|
16381
16348
|
pagedEditorRef.current?.scrollToPosition(from_11);
|
|
16382
16349
|
});
|
|
16383
16350
|
return true;
|
|
16384
16351
|
},
|
|
16385
16352
|
getSuggestions: () => {
|
|
16386
|
-
const
|
|
16387
|
-
return
|
|
16353
|
+
const view_31 = pagedEditorRef.current?.getView();
|
|
16354
|
+
return view_31 ? getSuggestions(view_31.state) : [];
|
|
16388
16355
|
},
|
|
16389
16356
|
exportPendingSuggestions: () => {
|
|
16390
|
-
const
|
|
16391
|
-
const activeIds = new Set(
|
|
16357
|
+
const view_32 = pagedEditorRef.current?.getView();
|
|
16358
|
+
const activeIds = new Set(view_32 ? getSuggestions(view_32.state).map((s_3) => s_3.suggestionId) : []);
|
|
16392
16359
|
return pendingSuggestionRegistryRef.current.exportPendingSuggestions({
|
|
16393
16360
|
activeSuggestionIds: activeIds,
|
|
16394
|
-
snapshotForStory: (story_0, commentIds) => story_0.type === "main" &&
|
|
16361
|
+
snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_32 ? createPendingSuggestionSourceSnapshot(view_32.state, commentIds) : null
|
|
16395
16362
|
});
|
|
16396
16363
|
},
|
|
16397
16364
|
loadPendingSuggestions: (records) => pendingSuggestionRegistryRef.current.loadPendingSuggestions({
|
|
16398
16365
|
records,
|
|
16399
16366
|
snapshotForStory: (story_1) => {
|
|
16400
|
-
const
|
|
16401
|
-
return story_1.type === "main" &&
|
|
16367
|
+
const view_33 = pagedEditorRef.current?.getView();
|
|
16368
|
+
return story_1.type === "main" && view_33 ? createFolioAIEditSnapshot(view_33.state.doc) : null;
|
|
16402
16369
|
},
|
|
16403
16370
|
sourceSnapshotForStory: (story_2, commentIds_0) => {
|
|
16404
|
-
const
|
|
16405
|
-
return story_2.type === "main" &&
|
|
16371
|
+
const view_34 = pagedEditorRef.current?.getView();
|
|
16372
|
+
return story_2.type === "main" && view_34 ? createPendingSuggestionSourceSnapshot(view_34.state, commentIds_0) : null;
|
|
16406
16373
|
},
|
|
16407
16374
|
apply: (record, snapshot_6) => {
|
|
16408
|
-
const
|
|
16409
|
-
if (!
|
|
16375
|
+
const view_35 = pagedEditorRef.current?.getView();
|
|
16376
|
+
if (!view_35) return {
|
|
16410
16377
|
applied: [],
|
|
16411
16378
|
skipped: []
|
|
16412
16379
|
};
|
|
@@ -16424,7 +16391,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16424
16391
|
const createdComments_1 = [];
|
|
16425
16392
|
const result_4 = applyFolioDocumentOperations({
|
|
16426
16393
|
undefinedReferences: "refuse",
|
|
16427
|
-
view:
|
|
16394
|
+
view: recordingCommentsView(view_35, createdComments_1),
|
|
16428
16395
|
snapshot: snapshot_6,
|
|
16429
16396
|
batch: {
|
|
16430
16397
|
version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
|
|
@@ -16438,83 +16405,84 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16438
16405
|
return comment_1.id;
|
|
16439
16406
|
}
|
|
16440
16407
|
});
|
|
16441
|
-
const appliedComments = appliedOperationComments(createdComments_1, result_4.applied);
|
|
16442
|
-
if (appliedComments.length > 0) updateComments((currentComments_1) => [...currentComments_1, ...appliedComments]);
|
|
16443
16408
|
return {
|
|
16444
16409
|
applied: result_4.applied,
|
|
16445
16410
|
skipped: result_4.skipped
|
|
16446
16411
|
};
|
|
16447
16412
|
},
|
|
16448
16413
|
activeSuggestionIds: () => {
|
|
16449
|
-
const
|
|
16450
|
-
return new Set(
|
|
16414
|
+
const view_36 = pagedEditorRef.current?.getView();
|
|
16415
|
+
return new Set(view_36 ? getSuggestions(view_36.state).map((s_4) => s_4.suggestionId) : []);
|
|
16451
16416
|
}
|
|
16452
16417
|
}),
|
|
16453
16418
|
acceptSuggestion: (suggestionId, options_4) => {
|
|
16454
|
-
const
|
|
16455
|
-
if (!
|
|
16419
|
+
const view_37 = pagedEditorRef.current?.getView();
|
|
16420
|
+
if (!view_37) return {
|
|
16456
16421
|
accepted: false,
|
|
16457
16422
|
appliedAs: null
|
|
16458
16423
|
};
|
|
16459
|
-
const appliedAs = getSuggestions(
|
|
16460
|
-
const
|
|
16424
|
+
const appliedAs = getSuggestions(view_37.state).find((s_5) => s_5.suggestionId === suggestionId)?.appliedAs ?? null;
|
|
16425
|
+
const editor_7 = pagedEditorRef.current?.getEditor();
|
|
16426
|
+
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);
|
|
16461
16427
|
return {
|
|
16462
16428
|
accepted,
|
|
16463
16429
|
appliedAs: accepted ? appliedAs : null
|
|
16464
16430
|
};
|
|
16465
16431
|
},
|
|
16466
16432
|
rejectSuggestion: (suggestionId_0) => {
|
|
16467
|
-
const view_37 = pagedEditorRef.current?.getView();
|
|
16468
|
-
if (!view_37) return false;
|
|
16469
|
-
return rejectSuggestion(suggestionId_0)(view_37.state, view_37.dispatch);
|
|
16470
|
-
},
|
|
16471
|
-
scrollToSuggestion: (suggestionId_1) => {
|
|
16472
16433
|
const view_38 = pagedEditorRef.current?.getView();
|
|
16473
16434
|
if (!view_38) return false;
|
|
16474
|
-
const
|
|
16435
|
+
const editor_8 = pagedEditorRef.current?.getEditor();
|
|
16436
|
+
if (editor_8?.getCanonicalDocument()) return editor_8.resolveCanonicalSuggestion(suggestionId_0, "reject", author);
|
|
16437
|
+
return rejectSuggestion(suggestionId_0)(view_38.state, view_38.dispatch);
|
|
16438
|
+
},
|
|
16439
|
+
scrollToSuggestion: (suggestionId_1) => {
|
|
16440
|
+
const view_39 = pagedEditorRef.current?.getView();
|
|
16441
|
+
if (!view_39) return false;
|
|
16442
|
+
const range_4 = findSuggestionRange(view_39.state, suggestionId_1);
|
|
16475
16443
|
if (!range_4) return false;
|
|
16476
|
-
const { from: from_12, to: to_12 } = clampRangeToDocSize(
|
|
16477
|
-
const $from_3 =
|
|
16478
|
-
const $to_3 =
|
|
16479
|
-
|
|
16444
|
+
const { from: from_12, to: to_12 } = clampRangeToDocSize(view_39.state.doc.content.size, range_4);
|
|
16445
|
+
const $from_3 = view_39.state.doc.resolve(from_12);
|
|
16446
|
+
const $to_3 = view_39.state.doc.resolve(to_12);
|
|
16447
|
+
view_39.dispatch(view_39.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
|
|
16480
16448
|
requestAnimationFrame(() => {
|
|
16481
16449
|
pagedEditorRef.current?.scrollToPosition(from_12);
|
|
16482
16450
|
});
|
|
16483
16451
|
return true;
|
|
16484
16452
|
},
|
|
16485
16453
|
getTrackedChanges: () => {
|
|
16486
|
-
const
|
|
16487
|
-
return
|
|
16454
|
+
const view_40 = pagedEditorRef.current?.getView();
|
|
16455
|
+
return view_40 ? getTrackedChangesFromDoc(view_40.state.doc) : [];
|
|
16488
16456
|
},
|
|
16489
16457
|
getCommentAnchors: () => {
|
|
16490
|
-
const
|
|
16491
|
-
return
|
|
16458
|
+
const view_41 = pagedEditorRef.current?.getView();
|
|
16459
|
+
return view_41 ? getCommentAnchorsFromDoc(view_41.state.doc) : [];
|
|
16492
16460
|
},
|
|
16493
16461
|
getSelectionText: () => {
|
|
16494
|
-
const
|
|
16495
|
-
return
|
|
16462
|
+
const view_42 = pagedEditorRef.current?.getView();
|
|
16463
|
+
return view_42 ? getSelectedText(view_42.state) : "";
|
|
16496
16464
|
},
|
|
16497
16465
|
getPageText: (page_0) => {
|
|
16498
|
-
const
|
|
16499
|
-
if (!
|
|
16466
|
+
const view_43 = pagedEditorRef.current?.getView();
|
|
16467
|
+
if (!view_43) return null;
|
|
16500
16468
|
const layout_0 = pagedEditorRef.current?.getEditor()?.getLayout() ?? null;
|
|
16501
16469
|
return getPageTextFromLayout({
|
|
16502
16470
|
layout: layout_0,
|
|
16503
|
-
doc:
|
|
16471
|
+
doc: view_43.state.doc,
|
|
16504
16472
|
page: page_0,
|
|
16505
|
-
projection: projectMarkupView(
|
|
16473
|
+
projection: projectMarkupView(view_43.state, displayMode)
|
|
16506
16474
|
});
|
|
16507
16475
|
},
|
|
16508
16476
|
getTargetPage: (target_2, snapshot_7) => {
|
|
16509
|
-
const
|
|
16510
|
-
if (!
|
|
16477
|
+
const view_44 = pagedEditorRef.current?.getView();
|
|
16478
|
+
if (!view_44) return null;
|
|
16511
16479
|
const range_5 = target_2.type === "textRange" ? resolveFolioAITextRange({
|
|
16512
16480
|
range: target_2,
|
|
16513
|
-
doc:
|
|
16481
|
+
doc: view_44.state.doc,
|
|
16514
16482
|
snapshot: snapshot_7
|
|
16515
16483
|
}) : resolveFolioAIBlockRange({
|
|
16516
16484
|
blockId: target_2.blockId,
|
|
16517
|
-
doc:
|
|
16485
|
+
doc: view_44.state.doc,
|
|
16518
16486
|
snapshot: snapshot_7
|
|
16519
16487
|
});
|
|
16520
16488
|
if (range_5 === null) return null;
|
|
@@ -16525,49 +16493,49 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16525
16493
|
getScrollRoot: () => pagedEditorRef.current?.getScrollRoot() ?? null,
|
|
16526
16494
|
onLayoutChange: (listener) => pagedEditorRef.current?.onLayoutChange(listener) ?? (() => {}),
|
|
16527
16495
|
getContentControls: (filter = {}) => {
|
|
16528
|
-
const
|
|
16529
|
-
if (!
|
|
16530
|
-
return findBlockSdtMatches(
|
|
16496
|
+
const view_45 = pagedEditorRef.current?.getView();
|
|
16497
|
+
if (!view_45) return [];
|
|
16498
|
+
return findBlockSdtMatches(view_45.state.doc, filter).map((match_0) => ({
|
|
16531
16499
|
properties: blockSdtAttrsToSdtProperties(match_0.node),
|
|
16532
16500
|
path: match_0.path,
|
|
16533
16501
|
pmPos: match_0.pos
|
|
16534
16502
|
}));
|
|
16535
16503
|
},
|
|
16536
16504
|
scrollToContentControl: (filter_0) => {
|
|
16537
|
-
const
|
|
16538
|
-
if (!
|
|
16539
|
-
const match_1 = findBlockSdtMatch(
|
|
16505
|
+
const view_46 = pagedEditorRef.current?.getView();
|
|
16506
|
+
if (!view_46) return false;
|
|
16507
|
+
const match_1 = findBlockSdtMatch(view_46.state.doc, filter_0);
|
|
16540
16508
|
if (!match_1) return false;
|
|
16541
16509
|
const inside = match_1.pos + 1;
|
|
16542
|
-
const $pos =
|
|
16543
|
-
|
|
16510
|
+
const $pos = view_46.state.doc.resolve(inside);
|
|
16511
|
+
view_46.dispatch(view_46.state.tr.setSelection(TextSelection.near($pos)));
|
|
16544
16512
|
requestAnimationFrame(() => {
|
|
16545
16513
|
pagedEditorRef.current?.scrollToPosition(inside);
|
|
16546
16514
|
});
|
|
16547
16515
|
return true;
|
|
16548
16516
|
},
|
|
16549
16517
|
setContentControlContent: (filter_1, input, options_5 = {}) => {
|
|
16550
|
-
const
|
|
16551
|
-
if (!
|
|
16552
|
-
const tr_0 = typeof input === "string" ? setContentControlContentTr(
|
|
16518
|
+
const view_47 = pagedEditorRef.current?.getView();
|
|
16519
|
+
if (!view_47) return false;
|
|
16520
|
+
const tr_0 = typeof input === "string" ? setContentControlContentTr(view_47.state, filter_1, input, options_5) : setContentControlContentBlocksTr(view_47.state, filter_1, input, options_5);
|
|
16553
16521
|
if (!tr_0) return false;
|
|
16554
|
-
|
|
16522
|
+
view_47.dispatch(tr_0);
|
|
16555
16523
|
return true;
|
|
16556
16524
|
},
|
|
16557
16525
|
setContentControlValue: (filter_2, input_0, options_6 = {}) => {
|
|
16558
|
-
const
|
|
16559
|
-
if (!
|
|
16560
|
-
const tr_1 = setContentControlValueTr(
|
|
16526
|
+
const view_48 = pagedEditorRef.current?.getView();
|
|
16527
|
+
if (!view_48) return false;
|
|
16528
|
+
const tr_1 = setContentControlValueTr(view_48.state, filter_2, input_0, options_6);
|
|
16561
16529
|
if (!tr_1) return false;
|
|
16562
|
-
|
|
16530
|
+
view_48.dispatch(tr_1);
|
|
16563
16531
|
return true;
|
|
16564
16532
|
},
|
|
16565
16533
|
removeContentControl: (filter_3, options_7 = {}) => {
|
|
16566
|
-
const
|
|
16567
|
-
if (!
|
|
16568
|
-
const tr_2 = removeContentControlTr(
|
|
16534
|
+
const view_49 = pagedEditorRef.current?.getView();
|
|
16535
|
+
if (!view_49) return false;
|
|
16536
|
+
const tr_2 = removeContentControlTr(view_49.state, filter_3, options_7);
|
|
16569
16537
|
if (!tr_2) return false;
|
|
16570
|
-
|
|
16538
|
+
view_49.dispatch(tr_2);
|
|
16571
16539
|
return true;
|
|
16572
16540
|
}
|
|
16573
16541
|
}), [
|
|
@@ -16660,47 +16628,47 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16660
16628
|
if (isDisplayMode(value)) setDisplayMode(value);
|
|
16661
16629
|
}, [setDisplayMode]);
|
|
16662
16630
|
const handleAcceptActiveChange = useCallback(() => {
|
|
16663
|
-
const
|
|
16664
|
-
if (!
|
|
16665
|
-
const { from: from_13, to: to_13 } =
|
|
16666
|
-
const range_6 = findChangeAtPosition(
|
|
16631
|
+
const view_50 = pagedEditorRef.current?.getView();
|
|
16632
|
+
if (!view_50) return;
|
|
16633
|
+
const { from: from_13, to: to_13 } = view_50.state.selection;
|
|
16634
|
+
const range_6 = findChangeAtPosition(view_50.state, from_13, to_13);
|
|
16667
16635
|
if (resolveCanonicalReviewRange({
|
|
16668
16636
|
editor: pagedEditorRef.current?.getEditor(),
|
|
16669
16637
|
...range_6,
|
|
16670
16638
|
resolution: "accept"
|
|
16671
|
-
}) === null) acceptChange(range_6.from, range_6.to)(
|
|
16639
|
+
}) === null) acceptChange(range_6.from, range_6.to)(view_50.state, view_50.dispatch);
|
|
16672
16640
|
}, []);
|
|
16673
16641
|
const handleRejectActiveChange = useCallback(() => {
|
|
16674
|
-
const
|
|
16675
|
-
if (!
|
|
16676
|
-
const { from: from_14, to: to_14 } =
|
|
16677
|
-
const range_7 = findChangeAtPosition(
|
|
16642
|
+
const view_51 = pagedEditorRef.current?.getView();
|
|
16643
|
+
if (!view_51) return;
|
|
16644
|
+
const { from: from_14, to: to_14 } = view_51.state.selection;
|
|
16645
|
+
const range_7 = findChangeAtPosition(view_51.state, from_14, to_14);
|
|
16678
16646
|
if (resolveCanonicalReviewRange({
|
|
16679
16647
|
editor: pagedEditorRef.current?.getEditor(),
|
|
16680
16648
|
...range_7,
|
|
16681
16649
|
resolution: "reject"
|
|
16682
|
-
}) === null) rejectChange(range_7.from, range_7.to)(
|
|
16650
|
+
}) === null) rejectChange(range_7.from, range_7.to)(view_51.state, view_51.dispatch);
|
|
16683
16651
|
}, []);
|
|
16684
16652
|
const handlePreviousChange = useCallback(() => {
|
|
16685
|
-
const
|
|
16686
|
-
if (!
|
|
16687
|
-
const { from: from_15 } =
|
|
16688
|
-
const change = findPreviousChange(
|
|
16653
|
+
const view_52 = pagedEditorRef.current?.getView();
|
|
16654
|
+
if (!view_52) return;
|
|
16655
|
+
const { from: from_15 } = view_52.state.selection;
|
|
16656
|
+
const change = findPreviousChange(view_52.state, from_15);
|
|
16689
16657
|
if (!change) return;
|
|
16690
|
-
|
|
16691
|
-
|
|
16658
|
+
view_52.dispatch(view_52.state.tr.setSelection(TextSelection.create(view_52.state.doc, change.from, change.to)));
|
|
16659
|
+
view_52.focus();
|
|
16692
16660
|
requestAnimationFrame(() => {
|
|
16693
16661
|
pagedEditorRef.current?.scrollToPosition(change.from);
|
|
16694
16662
|
});
|
|
16695
16663
|
}, []);
|
|
16696
16664
|
const handleNextChange = useCallback(() => {
|
|
16697
|
-
const
|
|
16698
|
-
if (!
|
|
16699
|
-
const { to: to_15 } =
|
|
16700
|
-
const change_0 = findNextChange(
|
|
16665
|
+
const view_53 = pagedEditorRef.current?.getView();
|
|
16666
|
+
if (!view_53) return;
|
|
16667
|
+
const { to: to_15 } = view_53.state.selection;
|
|
16668
|
+
const change_0 = findNextChange(view_53.state, to_15);
|
|
16701
16669
|
if (!change_0) return;
|
|
16702
|
-
|
|
16703
|
-
|
|
16670
|
+
view_53.dispatch(view_53.state.tr.setSelection(TextSelection.create(view_53.state.doc, change_0.from, change_0.to)));
|
|
16671
|
+
view_53.focus();
|
|
16704
16672
|
requestAnimationFrame(() => {
|
|
16705
16673
|
pagedEditorRef.current?.scrollToPosition(change_0.from);
|
|
16706
16674
|
});
|
|
@@ -16812,15 +16780,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16812
16780
|
}),
|
|
16813
16781
|
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
16814
16782
|
onClick: handleAcceptActiveChange,
|
|
16815
|
-
disabled: readOnly || !state.activeTrackedChange,
|
|
16816
|
-
title: t("acceptChange"),
|
|
16783
|
+
disabled: readOnly || !state.activeTrackedChange || state.activeTrackedChange.heldByLock.accept,
|
|
16784
|
+
title: state.activeTrackedChange?.heldByLock.accept ? t("trackedChanges.heldByLock") : t("acceptChange"),
|
|
16817
16785
|
ariaLabel: t("acceptChange"),
|
|
16818
16786
|
children: /* @__PURE__ */ jsx(CheckIcon, { size: 16 })
|
|
16819
16787
|
}),
|
|
16820
16788
|
/* @__PURE__ */ jsx(ToolbarButton, {
|
|
16821
16789
|
onClick: handleRejectActiveChange,
|
|
16822
|
-
disabled: readOnly || !state.activeTrackedChange,
|
|
16823
|
-
title: t("rejectChange"),
|
|
16790
|
+
disabled: readOnly || !state.activeTrackedChange || state.activeTrackedChange.heldByLock.reject,
|
|
16791
|
+
title: state.activeTrackedChange?.heldByLock.reject ? t("trackedChanges.heldByLock") : t("rejectChange"),
|
|
16824
16792
|
ariaLabel: t("rejectChange"),
|
|
16825
16793
|
children: /* @__PURE__ */ jsx(XIcon, { size: 16 })
|
|
16826
16794
|
}),
|
|
@@ -16870,8 +16838,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16870
16838
|
requestAnimationFrame(syncCommentHighlightStyles);
|
|
16871
16839
|
}, [onScrollTopChange, syncCommentHighlightStyles]);
|
|
16872
16840
|
const handlePagedSelectionChange = useCallback((_from, _to) => {
|
|
16873
|
-
const
|
|
16874
|
-
handleSelectionChange(
|
|
16841
|
+
const view_54 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
|
|
16842
|
+
handleSelectionChange(view_54 ? extractSelectionState(view_54.state) : null);
|
|
16875
16843
|
}, [getActiveEditorView, handleSelectionChange]);
|
|
16876
16844
|
const handleTotalPagesChange = useCallback((totalPages) => {
|
|
16877
16845
|
setScrollPageInfo((previous_0) => updateScrollPageTotal(previous_0, totalPages));
|
|
@@ -16883,11 +16851,20 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16883
16851
|
id: id_1,
|
|
16884
16852
|
status: "resolved"
|
|
16885
16853
|
}) !== null) return;
|
|
16854
|
+
if (readOnly) {
|
|
16855
|
+
notifyReadonlyEditAttempt();
|
|
16856
|
+
return;
|
|
16857
|
+
}
|
|
16886
16858
|
updateComments((previous_1) => previous_1.map((comment_2) => comment_2.id === id_1 ? {
|
|
16887
16859
|
...comment_2,
|
|
16888
16860
|
done: true
|
|
16889
16861
|
} : comment_2));
|
|
16890
|
-
}, [
|
|
16862
|
+
}, [
|
|
16863
|
+
applyCanonicalComment,
|
|
16864
|
+
notifyReadonlyEditAttempt,
|
|
16865
|
+
readOnly,
|
|
16866
|
+
updateComments
|
|
16867
|
+
]);
|
|
16891
16868
|
const handleCommentDelete = useCallback((id_2) => {
|
|
16892
16869
|
const result_5 = applyCanonicalComment({
|
|
16893
16870
|
type: "delete",
|
|
@@ -16897,11 +16874,25 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16897
16874
|
if (result_5.status === "applied" && activeCommentId === id_2) setActiveCommentId(null);
|
|
16898
16875
|
return;
|
|
16899
16876
|
}
|
|
16900
|
-
|
|
16877
|
+
if (readOnly) {
|
|
16878
|
+
notifyReadonlyEditAttempt();
|
|
16879
|
+
return;
|
|
16880
|
+
}
|
|
16881
|
+
const view_55 = pagedEditorRef.current?.getView();
|
|
16882
|
+
if (view_55 && commentRecordsOf(view_55.state) !== null) {
|
|
16883
|
+
const deleted = deleteCommentThread(view_55.state, id_2);
|
|
16884
|
+
if (deleted) view_55.dispatch(deleted);
|
|
16885
|
+
} else {
|
|
16886
|
+
const thread = commentThreadIds(commentsRef.current, id_2);
|
|
16887
|
+
updateComments((previous_2) => previous_2.filter((comment_3) => !thread.has(comment_3.id)));
|
|
16888
|
+
}
|
|
16901
16889
|
if (activeCommentId === id_2) setActiveCommentId(null);
|
|
16902
16890
|
}, [
|
|
16903
16891
|
activeCommentId,
|
|
16904
16892
|
applyCanonicalComment,
|
|
16893
|
+
commentsRef,
|
|
16894
|
+
notifyReadonlyEditAttempt,
|
|
16895
|
+
readOnly,
|
|
16905
16896
|
setActiveCommentId,
|
|
16906
16897
|
updateComments
|
|
16907
16898
|
]);
|
|
@@ -16915,16 +16906,22 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16915
16906
|
parentId: id_3
|
|
16916
16907
|
}
|
|
16917
16908
|
}) !== null) return;
|
|
16909
|
+
if (readOnly) {
|
|
16910
|
+
notifyReadonlyEditAttempt();
|
|
16911
|
+
return;
|
|
16912
|
+
}
|
|
16918
16913
|
updateComments((previous_3) => [...previous_3, createComment(text_6, author, id_3)]);
|
|
16919
16914
|
}, [
|
|
16920
16915
|
applyCanonicalComment,
|
|
16921
16916
|
author,
|
|
16922
16917
|
createComment,
|
|
16918
|
+
notifyReadonlyEditAttempt,
|
|
16919
|
+
readOnly,
|
|
16923
16920
|
updateComments
|
|
16924
16921
|
]);
|
|
16925
16922
|
const handleAddComment = useCallback((addText) => {
|
|
16926
|
-
const
|
|
16927
|
-
if (!
|
|
16923
|
+
const view_56 = pagedEditorRef.current?.getView();
|
|
16924
|
+
if (!view_56 || !commentSelectionRange) return false;
|
|
16928
16925
|
const result_6 = applyCanonicalComment({
|
|
16929
16926
|
type: "create",
|
|
16930
16927
|
text: addText,
|
|
@@ -16937,9 +16934,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16937
16934
|
});
|
|
16938
16935
|
if (result_6 !== null) {
|
|
16939
16936
|
if (result_6?.status !== "applied") return false;
|
|
16940
|
-
setVisibleCommentAuthors((
|
|
16941
|
-
if (
|
|
16942
|
-
const next_1 = new Set(
|
|
16937
|
+
setVisibleCommentAuthors((current_1) => {
|
|
16938
|
+
if (current_1 === null) return null;
|
|
16939
|
+
const next_1 = new Set(current_1);
|
|
16943
16940
|
const created = result_6.comments.find(({ id: id_4 }) => id_4 === result_6.commentId);
|
|
16944
16941
|
if (created) next_1.add(getCommentAuthorKey(created.author));
|
|
16945
16942
|
return next_1;
|
|
@@ -16950,17 +16947,20 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16950
16947
|
setAddCommentYPosition(null);
|
|
16951
16948
|
return true;
|
|
16952
16949
|
}
|
|
16950
|
+
if (readOnly) {
|
|
16951
|
+
notifyReadonlyEditAttempt();
|
|
16952
|
+
return false;
|
|
16953
|
+
}
|
|
16953
16954
|
const comment_4 = createComment(addText, author);
|
|
16954
|
-
if (!
|
|
16955
|
+
if (!commitCommentThread(view_56, commentSelectionRange, comment_4)) return false;
|
|
16955
16956
|
const commentAuthor_2 = getCommentAuthorKey(comment_4.author);
|
|
16956
|
-
setVisibleCommentAuthors((
|
|
16957
|
-
if (
|
|
16958
|
-
const next_2 = new Set(
|
|
16957
|
+
setVisibleCommentAuthors((current_2) => {
|
|
16958
|
+
if (current_2 === null) return null;
|
|
16959
|
+
const next_2 = new Set(current_2);
|
|
16959
16960
|
next_2.add(commentAuthor_2);
|
|
16960
16961
|
return next_2;
|
|
16961
16962
|
});
|
|
16962
16963
|
setActiveCommentId(comment_4.id);
|
|
16963
|
-
updateComments((previous_4) => [...previous_4, comment_4]);
|
|
16964
16964
|
pagedEditorRef.current?.relayout();
|
|
16965
16965
|
requestAnimationFrame(() => {
|
|
16966
16966
|
syncCommentHighlightStyles();
|
|
@@ -16975,13 +16975,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16975
16975
|
applyCanonicalComment,
|
|
16976
16976
|
commentSelectionRange,
|
|
16977
16977
|
createComment,
|
|
16978
|
+
notifyReadonlyEditAttempt,
|
|
16979
|
+
readOnly,
|
|
16978
16980
|
setActiveCommentId,
|
|
16979
16981
|
setAddCommentYPosition,
|
|
16980
16982
|
setCommentSelectionRange,
|
|
16981
16983
|
setIsAddingComment,
|
|
16982
16984
|
setVisibleCommentAuthors,
|
|
16983
|
-
syncCommentHighlightStyles
|
|
16984
|
-
updateComments
|
|
16985
|
+
syncCommentHighlightStyles
|
|
16985
16986
|
]);
|
|
16986
16987
|
const handleTrackedChangeReply = useCallback((revisionId_2, text_7) => {
|
|
16987
16988
|
if (applyCanonicalComment({
|
|
@@ -16994,16 +16995,22 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16994
16995
|
revisionId: revisionId_2
|
|
16995
16996
|
}
|
|
16996
16997
|
}) !== null) return;
|
|
16997
|
-
|
|
16998
|
+
if (readOnly) {
|
|
16999
|
+
notifyReadonlyEditAttempt();
|
|
17000
|
+
return;
|
|
17001
|
+
}
|
|
17002
|
+
updateComments((previous_4) => [...previous_4, createComment(text_7, author, revisionId_2)]);
|
|
16998
17003
|
}, [
|
|
16999
17004
|
applyCanonicalComment,
|
|
17000
17005
|
author,
|
|
17001
17006
|
createComment,
|
|
17007
|
+
notifyReadonlyEditAttempt,
|
|
17008
|
+
readOnly,
|
|
17002
17009
|
updateComments
|
|
17003
17010
|
]);
|
|
17004
17011
|
const handleCancelAddComment = useCallback(() => {
|
|
17005
|
-
const
|
|
17006
|
-
if (
|
|
17012
|
+
const view_57 = pagedEditorRef.current?.getView();
|
|
17013
|
+
if (view_57 && commentSelectionRange && commentDraftMode === "prosemirror") clearPendingComment(view_57, commentSelectionRange);
|
|
17007
17014
|
setIsAddingComment(false);
|
|
17008
17015
|
setCommentSelectionRange(null);
|
|
17009
17016
|
setAddCommentYPosition(null);
|
|
@@ -17020,23 +17027,23 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17020
17027
|
})?.revisionId ?? null;
|
|
17021
17028
|
}, []);
|
|
17022
17029
|
const handleSidebarAcceptChange = useCallback((from_17, to_17) => {
|
|
17023
|
-
const
|
|
17024
|
-
if (!
|
|
17030
|
+
const view_58 = pagedEditorRef.current?.getView();
|
|
17031
|
+
if (!view_58) return;
|
|
17025
17032
|
const revisionId_3 = resolveSidebarChangeRevisionId(from_17, to_17);
|
|
17026
17033
|
if (revisionId_3 === null) return;
|
|
17027
|
-
const
|
|
17028
|
-
if (
|
|
17029
|
-
else acceptAIEditRevision(revisionId_3)(
|
|
17034
|
+
const editor_9 = pagedEditorRef.current?.getEditor();
|
|
17035
|
+
if (editor_9?.getCanonicalDocument()) editor_9.resolveCanonicalRevisions([revisionId_3], "accept");
|
|
17036
|
+
else acceptAIEditRevision(revisionId_3)(view_58.state, view_58.dispatch);
|
|
17030
17037
|
extractTrackedChanges();
|
|
17031
17038
|
}, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
|
|
17032
17039
|
const handleSidebarRejectChange = useCallback((from_18, to_18) => {
|
|
17033
|
-
const
|
|
17034
|
-
if (!
|
|
17040
|
+
const view_59 = pagedEditorRef.current?.getView();
|
|
17041
|
+
if (!view_59) return;
|
|
17035
17042
|
const revisionId_4 = resolveSidebarChangeRevisionId(from_18, to_18);
|
|
17036
17043
|
if (revisionId_4 === null) return;
|
|
17037
|
-
const
|
|
17038
|
-
if (
|
|
17039
|
-
else rejectAIEditRevision(revisionId_4)(
|
|
17044
|
+
const editor_10 = pagedEditorRef.current?.getEditor();
|
|
17045
|
+
if (editor_10?.getCanonicalDocument()) editor_10.resolveCanonicalRevisions([revisionId_4], "reject");
|
|
17046
|
+
else rejectAIEditRevision(revisionId_4)(view_59.state, view_59.dispatch);
|
|
17040
17047
|
extractTrackedChanges();
|
|
17041
17048
|
}, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
|
|
17042
17049
|
const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
|
|
@@ -17160,7 +17167,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17160
17167
|
attempts++;
|
|
17161
17168
|
const container_0 = scrollContainerRef.current;
|
|
17162
17169
|
if (!container_0) return;
|
|
17163
|
-
const element_1 = container_0.querySelector(`.layout-page-content
|
|
17170
|
+
const element_1 = container_0.querySelector(`.layout-page-content ${paintedStartSelector(pmPos)}`);
|
|
17164
17171
|
if (element_1) {
|
|
17165
17172
|
delete element_1.dataset["folioOutlineFlash"];
|
|
17166
17173
|
element_1.offsetWidth;
|
|
@@ -17186,8 +17193,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17186
17193
|
}, [readOnly]);
|
|
17187
17194
|
const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
|
|
17188
17195
|
const applyTableProperties = useCallback((props_0) => {
|
|
17189
|
-
const
|
|
17190
|
-
if (
|
|
17196
|
+
const view_60 = getActiveEditorView();
|
|
17197
|
+
if (view_60) setTableProperties(props_0)(view_60.state, view_60.dispatch);
|
|
17191
17198
|
}, [getActiveEditorView]);
|
|
17192
17199
|
const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
|
|
17193
17200
|
const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
|
|
@@ -17195,8 +17202,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17195
17202
|
const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
|
|
17196
17203
|
const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
|
|
17197
17204
|
const insertSymbol = useCallback((symbol) => {
|
|
17198
|
-
const
|
|
17199
|
-
if (
|
|
17205
|
+
const view_61 = getActiveEditorView();
|
|
17206
|
+
if (view_61) view_61.dispatch(view_61.state.tr.insertText(symbol).scrollIntoView());
|
|
17200
17207
|
}, [getActiveEditorView]);
|
|
17201
17208
|
const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
|
|
17202
17209
|
const { close: closeFindDialog } = findReplace;
|
|
@@ -17287,8 +17294,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17287
17294
|
]);
|
|
17288
17295
|
const closeNumberingValueDialog = useCallback(() => setNumberingValueDialogOpen(false), []);
|
|
17289
17296
|
const applyNumberingValue = useCallback((value_0) => {
|
|
17290
|
-
const
|
|
17291
|
-
if (
|
|
17297
|
+
const view_62 = getActiveEditorView();
|
|
17298
|
+
if (view_62) setNumberingValue(value_0)(view_62.state, view_62.dispatch);
|
|
17292
17299
|
}, [getActiveEditorView]);
|
|
17293
17300
|
const numberingValueDialog = useMemo(() => ({
|
|
17294
17301
|
isOpen: numberingValueDialogOpen,
|
|
@@ -17588,11 +17595,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17588
17595
|
delayMs: 300,
|
|
17589
17596
|
children: /* @__PURE__ */ jsx("button", {
|
|
17590
17597
|
type: "button",
|
|
17598
|
+
"aria-label": "Add comment",
|
|
17591
17599
|
onMouseDown: (e_1) => {
|
|
17592
17600
|
e_1.preventDefault();
|
|
17593
17601
|
e_1.stopPropagation();
|
|
17594
|
-
const
|
|
17595
|
-
if (!
|
|
17602
|
+
const view_63 = pagedEditorRef.current?.getView();
|
|
17603
|
+
if (!view_63) {
|
|
17596
17604
|
setFloatingCommentBtn(null);
|
|
17597
17605
|
return;
|
|
17598
17606
|
}
|
|
@@ -17600,9 +17608,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17600
17608
|
from: floatingCommentBtn.from,
|
|
17601
17609
|
to: floatingCommentBtn.to
|
|
17602
17610
|
};
|
|
17603
|
-
const currentSelection =
|
|
17611
|
+
const currentSelection = view_63.state.selection;
|
|
17604
17612
|
const safeRange = resolveCommentCreationRange({
|
|
17605
|
-
docSize:
|
|
17613
|
+
docSize: view_63.state.doc.content.size,
|
|
17606
17614
|
capturedRange,
|
|
17607
17615
|
currentRange: {
|
|
17608
17616
|
from: currentSelection.from,
|
|
@@ -17617,7 +17625,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17617
17625
|
}
|
|
17618
17626
|
setCommentSelectionRange(safeRange);
|
|
17619
17627
|
if (commentDraftMode === "prosemirror") {
|
|
17620
|
-
if (!
|
|
17628
|
+
if (!markPendingComment(view_63, safeRange, { selectEnd: true })) {
|
|
17621
17629
|
setCommentSelectionRange(null);
|
|
17622
17630
|
setFloatingCommentBtn(null);
|
|
17623
17631
|
return;
|
|
@@ -17674,13 +17682,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17674
17682
|
if (hfEditPosition === "header") return headerContent;
|
|
17675
17683
|
return footerContent;
|
|
17676
17684
|
})()) return null;
|
|
17677
|
-
const targetEl = editorContentElement?.querySelector(hfEditPosition === "header" ? ".layout-page-header" : ".layout-page-footer");
|
|
17678
17685
|
const parentEl_0 = editorContentElement;
|
|
17679
|
-
if (!
|
|
17686
|
+
if (!parentEl_0) return null;
|
|
17680
17687
|
return /* @__PURE__ */ jsx(InlineHeaderFooterEditor, {
|
|
17681
17688
|
ref: hfEditorRef,
|
|
17682
17689
|
position: hfEditPosition,
|
|
17683
|
-
|
|
17690
|
+
targetSelector: hfEditPosition === "header" ? ".layout-page-header" : ".layout-page-footer",
|
|
17684
17691
|
parentElement: parentEl_0,
|
|
17685
17692
|
getActiveView: getActiveHfView,
|
|
17686
17693
|
onClose: handleBodyClick,
|