@a3s-lab/office 0.7.3 → 0.8.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/COLLABORATION_ROADMAP.md +62 -35
- package/README.md +59 -6
- package/dist/0~document-editor.js +115 -43
- package/dist/8928.js +395 -23
- package/dist/9787.js +3 -2
- package/dist/core.d.ts +1 -1
- package/dist/internal/collaboration/office-collaboration.d.ts +1 -1
- package/dist/internal/collaboration/office-document-collaboration-change-decisions.d.ts +7 -0
- package/dist/internal/collaboration/office-document-collaboration-claims.d.ts +2 -1
- package/dist/internal/collaboration/office-document-collaboration-sidecars.d.ts +3 -1
- package/dist/internal/collaboration/office-document-collaboration-suggestions.d.ts +6 -0
- package/dist/internal/collaboration/office-document-collaboration.d.ts +6 -2
- package/dist/internal/features/work/editors/document-changes-panel.d.ts +7 -1
- package/dist/internal/features/work/editors/document-toolbar.d.ts +4 -1
- package/dist/internal/features/work/work-document-changes.d.ts +5 -2
- package/dist/internal/features/work/work-document-extensions.d.ts +1 -0
- package/dist/internal/features/work/work-document-paragraph-identity.d.ts +1 -0
- package/dist/internal/features/work/work-document-table-row-identity.d.ts +5 -1
- package/dist/internal/features/work/work-types.d.ts +20 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +65 -0
- package/package.json +5 -3
|
@@ -605,7 +605,7 @@ function DocumentTaskPane({ ariaLabel, title, description, closeLabel, className
|
|
|
605
605
|
const DOCUMENT_CHANGE_ITEM_HEIGHT = 84;
|
|
606
606
|
const DOCUMENT_CHANGE_ITEM_GAP = 7;
|
|
607
607
|
const DOCUMENT_CHANGE_LIST_PADDING_TOP = 10;
|
|
608
|
-
function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesChange, onClose }) {
|
|
608
|
+
function DocumentChangesPanel({ editor, changes, decisions = [], trackChanges, suggestionOnly = false, onDecideChanges, onTrackChangesChange, onClose }) {
|
|
609
609
|
const officeDialog = useOfficeDialog();
|
|
610
610
|
const decisionButtonRefs = useRef(new Map());
|
|
611
611
|
const pendingFocusRef = useRef(null);
|
|
@@ -654,7 +654,9 @@ function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesCha
|
|
|
654
654
|
decision
|
|
655
655
|
};
|
|
656
656
|
setRovingChangeKey(nextChangeKey);
|
|
657
|
-
const handled =
|
|
657
|
+
const handled = onDecideChanges ? onDecideChanges([
|
|
658
|
+
change
|
|
659
|
+
], decision) : 'accept' === decision ? editor.commands.acceptDocumentChange(change.id) : editor.commands.rejectDocumentChange(change.id);
|
|
658
660
|
if (!handled) {
|
|
659
661
|
pendingFocusRef.current = null;
|
|
660
662
|
setRovingChangeKey(currentChangeKey);
|
|
@@ -673,7 +675,8 @@ function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesCha
|
|
|
673
675
|
confirmLabel: '全部接受'
|
|
674
676
|
});
|
|
675
677
|
if (confirmed && !editor.isDestroyed) {
|
|
676
|
-
|
|
678
|
+
if (onDecideChanges) onDecideChanges(changes, 'accept');
|
|
679
|
+
else editor.commands.acceptAllDocumentChanges();
|
|
677
680
|
requestAnimationFrame(()=>{
|
|
678
681
|
if (!editor.isDestroyed) editor.view.dom.focus();
|
|
679
682
|
});
|
|
@@ -687,7 +690,8 @@ function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesCha
|
|
|
687
690
|
confirmTone: 'danger'
|
|
688
691
|
});
|
|
689
692
|
if (confirmed && !editor.isDestroyed) {
|
|
690
|
-
|
|
693
|
+
if (onDecideChanges) onDecideChanges(changes, 'reject');
|
|
694
|
+
else editor.commands.rejectAllDocumentChanges();
|
|
691
695
|
requestAnimationFrame(()=>{
|
|
692
696
|
if (!editor.isDestroyed) editor.view.dom.focus();
|
|
693
697
|
});
|
|
@@ -698,11 +702,11 @@ function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesCha
|
|
|
698
702
|
/*#__PURE__*/ jsxs(DocumentTaskPane, {
|
|
699
703
|
className: "work-document-changes-panel",
|
|
700
704
|
title: "修订审阅",
|
|
701
|
-
description: changes.length ? `${changes.length}
|
|
705
|
+
description: changes.length ? `${changes.length} 项待处理 · ${decisions.length} 项已决定` : decisions.length ? `没有待处理的修订 · ${decisions.length} 项已决定` : '没有待处理的修订',
|
|
702
706
|
closeLabel: "关闭修订审阅",
|
|
703
707
|
onClose: onClose,
|
|
704
708
|
children: [
|
|
705
|
-
changes.length > 0 && /*#__PURE__*/ jsxs("div", {
|
|
709
|
+
changes.length > 0 && !suggestionOnly && /*#__PURE__*/ jsxs("div", {
|
|
706
710
|
className: "work-document-changes-bulk-actions",
|
|
707
711
|
children: [
|
|
708
712
|
/*#__PURE__*/ jsxs(button_Button, {
|
|
@@ -778,7 +782,7 @@ function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesCha
|
|
|
778
782
|
})
|
|
779
783
|
]
|
|
780
784
|
}),
|
|
781
|
-
/*#__PURE__*/ jsxs("div", {
|
|
785
|
+
!suggestionOnly && /*#__PURE__*/ jsxs("div", {
|
|
782
786
|
children: [
|
|
783
787
|
/*#__PURE__*/ jsxs(button_Button, {
|
|
784
788
|
ref: (element)=>{
|
|
@@ -822,7 +826,7 @@ function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesCha
|
|
|
822
826
|
children: /*#__PURE__*/ jsx(CollectionState, {
|
|
823
827
|
className: "work-document-changes-empty",
|
|
824
828
|
icon: /*#__PURE__*/ jsx(FileDiff, {}),
|
|
825
|
-
actions: /*#__PURE__*/ jsx(button_Button, {
|
|
829
|
+
actions: suggestionOnly ? void 0 : /*#__PURE__*/ jsx(button_Button, {
|
|
826
830
|
size: "compact",
|
|
827
831
|
tone: trackChanges ? 'quiet' : 'primary',
|
|
828
832
|
onClick: ()=>onTrackChangesChange(!trackChanges),
|
|
@@ -830,8 +834,11 @@ function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesCha
|
|
|
830
834
|
}),
|
|
831
835
|
tone: trackChanges ? 'info' : 'neutral',
|
|
832
836
|
role: "status",
|
|
833
|
-
children: trackChanges ? '正在记录新的改动。' : '当前没有记录新的改动。'
|
|
837
|
+
children: suggestionOnly ? '建议模式会自动记录带身份的新改动。' : trackChanges ? '正在记录新的改动。' : '当前没有记录新的改动。'
|
|
834
838
|
})
|
|
839
|
+
}),
|
|
840
|
+
decisions.length > 0 && /*#__PURE__*/ jsx(DocumentChangeDecisionHistory, {
|
|
841
|
+
decisions: decisions
|
|
835
842
|
})
|
|
836
843
|
]
|
|
837
844
|
}),
|
|
@@ -839,6 +846,49 @@ function DocumentChangesPanel({ editor, changes, trackChanges, onTrackChangesCha
|
|
|
839
846
|
]
|
|
840
847
|
});
|
|
841
848
|
}
|
|
849
|
+
function DocumentChangeDecisionHistory({ decisions }) {
|
|
850
|
+
const visible = decisions.slice(-20).reverse();
|
|
851
|
+
return /*#__PURE__*/ jsxs("section", {
|
|
852
|
+
className: "work-document-change-decisions",
|
|
853
|
+
"aria-label": "修订决定记录",
|
|
854
|
+
children: [
|
|
855
|
+
/*#__PURE__*/ jsxs("header", {
|
|
856
|
+
children: [
|
|
857
|
+
/*#__PURE__*/ jsx("strong", {
|
|
858
|
+
children: "决定记录"
|
|
859
|
+
}),
|
|
860
|
+
/*#__PURE__*/ jsxs("span", {
|
|
861
|
+
children: [
|
|
862
|
+
decisions.length,
|
|
863
|
+
" 项"
|
|
864
|
+
]
|
|
865
|
+
})
|
|
866
|
+
]
|
|
867
|
+
}),
|
|
868
|
+
/*#__PURE__*/ jsx("ol", {
|
|
869
|
+
children: visible.map((decision)=>/*#__PURE__*/ jsxs("li", {
|
|
870
|
+
"data-document-change-decision": decision.decision,
|
|
871
|
+
children: [
|
|
872
|
+
/*#__PURE__*/ jsx("span", {
|
|
873
|
+
children: 'accept' === decision.decision ? '已接受' : '已拒绝'
|
|
874
|
+
}),
|
|
875
|
+
/*#__PURE__*/ jsx("strong", {
|
|
876
|
+
children: decision.text.trim() || '(空白字符)'
|
|
877
|
+
}),
|
|
878
|
+
/*#__PURE__*/ jsxs("small", {
|
|
879
|
+
children: [
|
|
880
|
+
decision.suggestedBy,
|
|
881
|
+
" → ",
|
|
882
|
+
decision.decidedBy,
|
|
883
|
+
decision.decidedAt ? ` · ${formatChangeDate(decision.decidedAt)}` : ''
|
|
884
|
+
]
|
|
885
|
+
})
|
|
886
|
+
]
|
|
887
|
+
}, decision.id))
|
|
888
|
+
})
|
|
889
|
+
]
|
|
890
|
+
});
|
|
891
|
+
}
|
|
842
892
|
function documentChangeDecisionKey(changeKey, decision) {
|
|
843
893
|
return `${changeKey}:${decision}`;
|
|
844
894
|
}
|
|
@@ -11696,7 +11746,7 @@ function headingLevelForShortcut(code, key) {
|
|
|
11696
11746
|
if ('3' === value) return 3;
|
|
11697
11747
|
return null;
|
|
11698
11748
|
}
|
|
11699
|
-
function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly = false, history, layoutOpen, layout, layoutFonts = [], navigationOpen, pageColor, showPageNumbers, showRulers, spellcheckEnabled, viewMode, zoom, pageChromeEditor, pageChromeEditingPart, pageChromeShowPageNumber, onRequestImage, onPageChromeEditingPartChange, onClosePageChrome, onTogglePageChromePageNumber, onToggleLayout, onLayoutChange, onOpenLayout, onToggleNavigation, onTogglePageNumbers, onToggleRulers, onPageColorChange, onToggleSpellcheck, onViewModeChange, onZoomChange, onZoomFit, onInsertSection, onInsertNote, onInsertCaption, onInsertCrossReference, citationsOpen, citationSourceCount, onToggleCitations, onInsertField, onRefreshFields, canInsertComment, onInsertComment, commentsOpen, commentCount, onToggleComments, trackChanges, changesOpen, changeCount, findReplaceMode, fileActions, onRibbonTabChange, onToggleTrackChanges, onToggleChanges, onOpenWordCount, onOpenFindReplace }) {
|
|
11749
|
+
function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly = false, suggestionOnly = false, history, layoutOpen, layout, layoutFonts = [], navigationOpen, pageColor, showPageNumbers, showRulers, spellcheckEnabled, viewMode, zoom, pageChromeEditor, pageChromeEditingPart, pageChromeShowPageNumber, onRequestImage, onPageChromeEditingPartChange, onClosePageChrome, onTogglePageChromePageNumber, onToggleLayout, onLayoutChange, onOpenLayout, onToggleNavigation, onTogglePageNumbers, onToggleRulers, onPageColorChange, onToggleSpellcheck, onViewModeChange, onZoomChange, onZoomFit, onInsertSection, onInsertNote, onInsertCaption, onInsertCrossReference, citationsOpen, citationSourceCount, onToggleCitations, onInsertField, onRefreshFields, canInsertComment, onInsertComment, commentsOpen, commentCount, onToggleComments, trackChanges, changesOpen, changeCount, findReplaceMode, fileActions, onRibbonTabChange, onToggleTrackChanges, onToggleChanges, onDecideChange, onOpenWordCount, onOpenFindReplace }) {
|
|
11700
11750
|
const [activeTab, setActiveTab] = useState(reviewOnly ? 'review' : 'home');
|
|
11701
11751
|
const officeDialog = useOfficeDialog();
|
|
11702
11752
|
const prompt = officeDialog.prompt;
|
|
@@ -11901,7 +11951,7 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
|
|
|
11901
11951
|
changes[index + 1]?.id,
|
|
11902
11952
|
changes[index - 1]?.id
|
|
11903
11953
|
].filter((id)=>Boolean(id));
|
|
11904
|
-
const handled = 'accept' === decision ? editor.commands.acceptDocumentChange(change.id) : editor.commands.rejectDocumentChange(change.id);
|
|
11954
|
+
const handled = onDecideChange ? onDecideChange(change, decision) : 'accept' === decision ? editor.commands.acceptDocumentChange(change.id) : editor.commands.rejectDocumentChange(change.id);
|
|
11905
11955
|
if (!handled) return;
|
|
11906
11956
|
const remaining = collectDocumentChanges(editor.state.doc);
|
|
11907
11957
|
const next = nextIds.map((id)=>remaining.find((candidate)=>candidate.id === id)).find((candidate)=>Boolean(candidate));
|
|
@@ -11925,7 +11975,7 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
|
|
|
11925
11975
|
adaptive: true,
|
|
11926
11976
|
collapsible: true,
|
|
11927
11977
|
fileActions: fileActions,
|
|
11928
|
-
quickAccessActions: reviewOnly ? [] : [
|
|
11978
|
+
quickAccessActions: reviewOnly && !suggestionOnly ? [] : [
|
|
11929
11979
|
{
|
|
11930
11980
|
id: undoCommand.id,
|
|
11931
11981
|
label: undoCommand.label,
|
|
@@ -12180,7 +12230,7 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
|
|
|
12180
12230
|
})
|
|
12181
12231
|
})
|
|
12182
12232
|
}),
|
|
12183
|
-
/*#__PURE__*/ jsxs(document_toolbar_RibbonGroup, {
|
|
12233
|
+
!suggestionOnly && /*#__PURE__*/ jsxs(document_toolbar_RibbonGroup, {
|
|
12184
12234
|
label: "批注",
|
|
12185
12235
|
priority: "high",
|
|
12186
12236
|
children: [
|
|
@@ -12207,18 +12257,20 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
|
|
|
12207
12257
|
})
|
|
12208
12258
|
]
|
|
12209
12259
|
}),
|
|
12210
|
-
!reviewOnly && /*#__PURE__*/ jsxs(Fragment, {
|
|
12260
|
+
(!reviewOnly || suggestionOnly) && /*#__PURE__*/ jsxs(Fragment, {
|
|
12211
12261
|
children: [
|
|
12212
12262
|
/*#__PURE__*/ jsxs(document_toolbar_RibbonGroup, {
|
|
12213
12263
|
label: "修订",
|
|
12214
12264
|
priority: "high",
|
|
12215
12265
|
children: [
|
|
12216
12266
|
/*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
12217
|
-
label:
|
|
12267
|
+
label: suggestionOnly ? '建议模式' : '修订模式',
|
|
12218
12268
|
displayLabel: true,
|
|
12219
12269
|
shortcut: trackChangesCommand.shortcut?.label,
|
|
12220
12270
|
ariaKeyShortcuts: trackChangesCommand.shortcut?.aria,
|
|
12221
|
-
active: trackChanges,
|
|
12271
|
+
active: suggestionOnly || trackChanges,
|
|
12272
|
+
disabled: suggestionOnly,
|
|
12273
|
+
title: suggestionOnly ? '建议模式始终记录带身份的文字修订' : void 0,
|
|
12222
12274
|
onClick: onToggleTrackChanges,
|
|
12223
12275
|
children: /*#__PURE__*/ jsx(FileDiff, {
|
|
12224
12276
|
size: 19
|
|
@@ -12235,7 +12287,7 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
|
|
|
12235
12287
|
})
|
|
12236
12288
|
]
|
|
12237
12289
|
}),
|
|
12238
|
-
/*#__PURE__*/ jsxs(document_toolbar_RibbonGroup, {
|
|
12290
|
+
!suggestionOnly && /*#__PURE__*/ jsxs(document_toolbar_RibbonGroup, {
|
|
12239
12291
|
label: "更改",
|
|
12240
12292
|
priority: "high",
|
|
12241
12293
|
children: [
|
|
@@ -14186,10 +14238,13 @@ function DocumentReviewConflictNotice({ conflicts, onDismiss }) {
|
|
|
14186
14238
|
}
|
|
14187
14239
|
const EMPTY_DOCUMENT_LAYOUT_FONTS = [];
|
|
14188
14240
|
const EMPTY_DOCUMENT_EXTENSIONS = [];
|
|
14189
|
-
function createTrackedDocumentChange(_kind) {
|
|
14241
|
+
function createTrackedDocumentChange(_kind, actor) {
|
|
14190
14242
|
return {
|
|
14191
14243
|
id: createWorkId('change'),
|
|
14192
|
-
|
|
14244
|
+
...actor ? {
|
|
14245
|
+
actorId: actor.id
|
|
14246
|
+
} : {},
|
|
14247
|
+
author: actor?.name ?? 'A3S Work 用户',
|
|
14193
14248
|
date: new Date().toISOString()
|
|
14194
14249
|
};
|
|
14195
14250
|
}
|
|
@@ -14212,7 +14267,7 @@ function CollaborativeDocumentEditor(props) {
|
|
|
14212
14267
|
if (!initial.current) initial.current = readWorkOfficeDocumentCollaboration(collaboration);
|
|
14213
14268
|
const bridge = useRef({
|
|
14214
14269
|
getContent: ()=>initial.current,
|
|
14215
|
-
isTracking: ()=>Boolean(initial.current?.trackChanges),
|
|
14270
|
+
isTracking: ()=>'suggest' === collaboration.mode || Boolean(initial.current?.trackChanges),
|
|
14216
14271
|
onContentChange: ()=>void 0,
|
|
14217
14272
|
onTrackingChange: ()=>void 0
|
|
14218
14273
|
});
|
|
@@ -14226,7 +14281,7 @@ function CollaborativeDocumentEditor(props) {
|
|
|
14226
14281
|
workExtensions: {
|
|
14227
14282
|
getContent: ()=>bridge.current.getContent(),
|
|
14228
14283
|
isTracking: ()=>bridge.current.isTracking(),
|
|
14229
|
-
createChange: createTrackedDocumentChange,
|
|
14284
|
+
createChange: (kind)=>createTrackedDocumentChange(kind, collaboration.actor),
|
|
14230
14285
|
onContentChange: (content)=>bridge.current.onContentChange(content),
|
|
14231
14286
|
onTrackingChange: (enabled)=>bridge.current.onTrackingChange(enabled)
|
|
14232
14287
|
}
|
|
@@ -14256,11 +14311,13 @@ function CollaborativeDocumentEditor(props) {
|
|
|
14256
14311
|
});
|
|
14257
14312
|
}
|
|
14258
14313
|
function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, collaborationBinding, collaborationBridge, collaborationInitialContent, content, extensions = EMPTY_DOCUMENT_EXTENSIONS, preview: requestedPreview, defaultRibbonCollapsed = false, saveStatus = '已自动保存', kernelWasmUrl, layoutFonts = EMPTY_DOCUMENT_LAYOUT_FONTS, fileActions, getSelectionMenuItems, onChange, onAgentRequest, onReviewConflict }) {
|
|
14259
|
-
const
|
|
14260
|
-
const
|
|
14314
|
+
const commentOnly = collaboration?.mode === 'comment' && !requestedPreview;
|
|
14315
|
+
const suggestionOnly = collaboration?.mode === 'suggest' && Boolean(collaboration.actor) && !requestedPreview;
|
|
14316
|
+
const collaborationInteractive = !collaboration || 'edit' === collaboration.mode || 'comment' === collaboration.mode || 'suggest' === collaboration.mode && Boolean(collaboration.actor);
|
|
14261
14317
|
const preview = requestedPreview || !collaborationInteractive;
|
|
14262
14318
|
const canEditDocument = !preview && (!collaboration || 'edit' === collaboration.mode);
|
|
14263
14319
|
const canCommentDocument = !preview && (!collaboration || 'edit' === collaboration.mode || 'comment' === collaboration.mode && Boolean(collaboration.actor));
|
|
14320
|
+
const canReviewDocumentChanges = canEditDocument || suggestionOnly;
|
|
14264
14321
|
const readOnly = preview;
|
|
14265
14322
|
const initialContentRef = useRef(collaborationInitialContent ?? content);
|
|
14266
14323
|
const effectiveContent = collaboration ? initialContentRef.current : content;
|
|
@@ -14277,7 +14334,7 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14277
14334
|
const statisticsInvokerRef = useRef(null);
|
|
14278
14335
|
const contentRef = useRef(effectiveContent);
|
|
14279
14336
|
const onChangeRef = useRef(onChange);
|
|
14280
|
-
const trackChangesRef = useRef(Boolean(effectiveContent.trackChanges));
|
|
14337
|
+
const trackChangesRef = useRef(suggestionOnly || Boolean(effectiveContent.trackChanges));
|
|
14281
14338
|
const collaborationBindingRef = useRef(collaborationBinding);
|
|
14282
14339
|
const normalizedContent = useMemo(()=>normalizeDocumentHtml(effectiveContent), [
|
|
14283
14340
|
effectiveContent
|
|
@@ -14312,7 +14369,7 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14312
14369
|
const loadedLayoutFontIds = useDocumentLayoutFonts(layoutFonts);
|
|
14313
14370
|
if (!collaboration) contentRef.current = content;
|
|
14314
14371
|
onChangeRef.current = onChange;
|
|
14315
|
-
trackChangesRef.current = Boolean(contentRef.current.trackChanges);
|
|
14372
|
+
trackChangesRef.current = suggestionOnly || Boolean(contentRef.current.trackChanges);
|
|
14316
14373
|
const commitContentChange = useCallback((next)=>{
|
|
14317
14374
|
const previous = contentRef.current;
|
|
14318
14375
|
const binding = collaborationBindingRef.current;
|
|
@@ -14323,9 +14380,10 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14323
14380
|
collaborationBindingRef.current = collaborationBinding;
|
|
14324
14381
|
if (collaborationBridge) collaborationBridge.current = {
|
|
14325
14382
|
getContent: ()=>contentRef.current,
|
|
14326
|
-
isTracking: ()=>trackChangesRef.current,
|
|
14383
|
+
isTracking: ()=>suggestionOnly || trackChangesRef.current,
|
|
14327
14384
|
onContentChange: (next)=>commitContentChange(next),
|
|
14328
14385
|
onTrackingChange: (trackChanges)=>{
|
|
14386
|
+
if (suggestionOnly) return;
|
|
14329
14387
|
trackChangesRef.current = trackChanges;
|
|
14330
14388
|
commitContentChange({
|
|
14331
14389
|
...contentRef.current,
|
|
@@ -14337,11 +14395,12 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14337
14395
|
...collaborationBinding?.extensions ?? createWorkDocumentExtensions({
|
|
14338
14396
|
getContent: ()=>contentRef.current,
|
|
14339
14397
|
isTracking: ()=>trackChangesRef.current,
|
|
14340
|
-
createChange: createTrackedDocumentChange,
|
|
14398
|
+
createChange: (kind)=>createTrackedDocumentChange(kind, collaboration?.actor),
|
|
14341
14399
|
onContentChange: (next)=>{
|
|
14342
14400
|
commitContentChange(next);
|
|
14343
14401
|
},
|
|
14344
14402
|
onTrackingChange: (trackChanges)=>{
|
|
14403
|
+
if (suggestionOnly) return;
|
|
14345
14404
|
trackChangesRef.current = trackChanges;
|
|
14346
14405
|
const next = {
|
|
14347
14406
|
...contentRef.current,
|
|
@@ -14364,12 +14423,12 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14364
14423
|
attributes: {
|
|
14365
14424
|
'aria-label': '文档正文',
|
|
14366
14425
|
'aria-multiline': 'true',
|
|
14367
|
-
'aria-readonly':
|
|
14426
|
+
'aria-readonly': commentOnly ? 'true' : 'false',
|
|
14368
14427
|
role: 'textbox',
|
|
14369
14428
|
spellcheck: 'true'
|
|
14370
14429
|
}
|
|
14371
14430
|
}), [
|
|
14372
|
-
|
|
14431
|
+
commentOnly
|
|
14373
14432
|
]);
|
|
14374
14433
|
const editor = useEditor({
|
|
14375
14434
|
extensions: editorExtensions,
|
|
@@ -14450,7 +14509,7 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14450
14509
|
const documentComments = useDocumentComments({
|
|
14451
14510
|
actor: collaboration?.actor,
|
|
14452
14511
|
contentRef,
|
|
14453
|
-
deleteOwnOnly:
|
|
14512
|
+
deleteOwnOnly: commentOnly,
|
|
14454
14513
|
editor,
|
|
14455
14514
|
enabled: canCommentDocument,
|
|
14456
14515
|
onBeforeDraft: ()=>setTaskPane(null)
|
|
@@ -14463,7 +14522,7 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14463
14522
|
const unsubscribeChange = collaborationBinding.subscribe((change)=>{
|
|
14464
14523
|
pendingCollaborationContentRef.current = change.content;
|
|
14465
14524
|
contentRef.current = change.content;
|
|
14466
|
-
trackChangesRef.current = Boolean(change.content.trackChanges);
|
|
14525
|
+
trackChangesRef.current = suggestionOnly || Boolean(change.content.trackChanges);
|
|
14467
14526
|
setCollaborationVersion((value)=>value + 1);
|
|
14468
14527
|
});
|
|
14469
14528
|
const unsubscribeError = collaborationBinding.subscribeError((error)=>{
|
|
@@ -14488,7 +14547,7 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14488
14547
|
const next = pendingCollaborationContentRef.current;
|
|
14489
14548
|
pendingCollaborationContentRef.current = void 0;
|
|
14490
14549
|
contentRef.current = next;
|
|
14491
|
-
trackChangesRef.current = Boolean(next.trackChanges);
|
|
14550
|
+
trackChangesRef.current = suggestionOnly || Boolean(next.trackChanges);
|
|
14492
14551
|
onChangeRef.current(next);
|
|
14493
14552
|
}, [
|
|
14494
14553
|
collaborationVersion
|
|
@@ -14689,7 +14748,7 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14689
14748
|
editor.setEditable(!readOnly);
|
|
14690
14749
|
const editorDom = editor.view.dom;
|
|
14691
14750
|
editorDom.setAttribute('role', preview ? 'document' : 'textbox');
|
|
14692
|
-
editorDom.setAttribute('aria-readonly', String(
|
|
14751
|
+
editorDom.setAttribute('aria-readonly', String(commentOnly || preview));
|
|
14693
14752
|
if (preview) editorDom.removeAttribute('aria-multiline');
|
|
14694
14753
|
else editorDom.setAttribute('aria-multiline', 'true');
|
|
14695
14754
|
};
|
|
@@ -14699,10 +14758,10 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14699
14758
|
editor.off('mount', applyEditableState);
|
|
14700
14759
|
};
|
|
14701
14760
|
}, [
|
|
14761
|
+
commentOnly,
|
|
14702
14762
|
editor,
|
|
14703
14763
|
preview,
|
|
14704
|
-
readOnly
|
|
14705
|
-
reviewOnly
|
|
14764
|
+
readOnly
|
|
14706
14765
|
]);
|
|
14707
14766
|
useEffect(()=>{
|
|
14708
14767
|
if (!editor) return;
|
|
@@ -14810,6 +14869,11 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14810
14869
|
});
|
|
14811
14870
|
const finalPageNumber = pagination.pages.at(-1)?.pageNumber ?? Math.max(1, layout.pageNumberStart ?? 1) + pageCount - 1;
|
|
14812
14871
|
const changes = collectDocumentChanges(editor.state.doc);
|
|
14872
|
+
const decideDocumentChanges = (selectedChanges, decision)=>{
|
|
14873
|
+
if (collaborationBinding) return collaborationBinding.decideChanges(editor, selectedChanges.map(({ id })=>id), decision);
|
|
14874
|
+
const ids = selectedChanges.map(({ id })=>id);
|
|
14875
|
+
return 'accept' === decision ? editor.commands.acceptDocumentChanges(ids) : editor.commands.rejectDocumentChanges(ids);
|
|
14876
|
+
};
|
|
14813
14877
|
const citationCount = documentCitationCount(editor);
|
|
14814
14878
|
const textStatistics = documentTextStatistics(editor);
|
|
14815
14879
|
const paragraphIndent = documentParagraphIndent(editor);
|
|
@@ -14943,8 +15007,9 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14943
15007
|
}) : /*#__PURE__*/ jsx(DocumentToolbar, {
|
|
14944
15008
|
editor: editor,
|
|
14945
15009
|
defaultRibbonCollapsed: defaultRibbonCollapsed,
|
|
14946
|
-
reviewOnly:
|
|
14947
|
-
|
|
15010
|
+
reviewOnly: commentOnly || suggestionOnly,
|
|
15011
|
+
suggestionOnly: suggestionOnly,
|
|
15012
|
+
history: collaborationBinding && !commentOnly ? {
|
|
14948
15013
|
canRedo: collaborationBinding.canRedo(),
|
|
14949
15014
|
canUndo: collaborationBinding.canUndo(),
|
|
14950
15015
|
redo: ()=>collaborationBinding.redo(),
|
|
@@ -14996,7 +15061,7 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
14996
15061
|
commentsOpen: documentComments.open,
|
|
14997
15062
|
commentCount: documentComments.comments.length,
|
|
14998
15063
|
onToggleComments: ()=>void toggleCommentsPanel(),
|
|
14999
|
-
trackChanges: Boolean(currentContent.trackChanges),
|
|
15064
|
+
trackChanges: suggestionOnly || Boolean(currentContent.trackChanges),
|
|
15000
15065
|
changesOpen: changesOpen,
|
|
15001
15066
|
changeCount: changes.length,
|
|
15002
15067
|
findReplaceMode: findReplaceMode,
|
|
@@ -15005,10 +15070,14 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
15005
15070
|
return requestEditorViewChange(keepCurrentPane ? taskPane : null, 'review' !== tab);
|
|
15006
15071
|
},
|
|
15007
15072
|
onToggleTrackChanges: ()=>{
|
|
15073
|
+
if (suggestionOnly) return;
|
|
15008
15074
|
editor.commands.toggleDocumentTrackChanges();
|
|
15009
15075
|
restoreDocumentBodyFocus();
|
|
15010
15076
|
},
|
|
15011
15077
|
onToggleChanges: ()=>void toggleTaskPane('changes'),
|
|
15078
|
+
onDecideChange: (change, decision)=>decideDocumentChanges([
|
|
15079
|
+
change
|
|
15080
|
+
], decision),
|
|
15012
15081
|
onOpenWordCount: openDocumentStatistics,
|
|
15013
15082
|
onOpenFindReplace: openFindReplace
|
|
15014
15083
|
}),
|
|
@@ -15174,12 +15243,12 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
15174
15243
|
editor: editor,
|
|
15175
15244
|
kind: "document"
|
|
15176
15245
|
}),
|
|
15177
|
-
!preview && /*#__PURE__*/ jsx(DocumentSelectionToolbar, {
|
|
15246
|
+
!preview && (canEditDocument || canCommentDocument) && /*#__PURE__*/ jsx(DocumentSelectionToolbar, {
|
|
15178
15247
|
editor: editor,
|
|
15179
15248
|
canInsertComment: documentComments.canInsert,
|
|
15180
15249
|
layoutFonts: layoutFonts,
|
|
15181
15250
|
onInsertComment: ()=>void startCommentDraft(),
|
|
15182
|
-
reviewOnly:
|
|
15251
|
+
reviewOnly: commentOnly
|
|
15183
15252
|
})
|
|
15184
15253
|
]
|
|
15185
15254
|
}),
|
|
@@ -15259,11 +15328,14 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
15259
15328
|
onClose: closeTaskPane,
|
|
15260
15329
|
onDirtyChange: setCitationsDirty
|
|
15261
15330
|
}),
|
|
15262
|
-
|
|
15331
|
+
canReviewDocumentChanges && changesOpen && /*#__PURE__*/ jsx(DocumentChangesPanel, {
|
|
15263
15332
|
editor: editor,
|
|
15264
15333
|
changes: changes,
|
|
15265
|
-
|
|
15266
|
-
|
|
15334
|
+
decisions: currentContent.changeDecisions,
|
|
15335
|
+
trackChanges: suggestionOnly || Boolean(currentContent.trackChanges),
|
|
15336
|
+
suggestionOnly: suggestionOnly,
|
|
15337
|
+
onDecideChanges: canEditDocument ? decideDocumentChanges : void 0,
|
|
15338
|
+
onTrackChangesChange: (enabled)=>suggestionOnly ? false : editor.commands.setDocumentTrackChanges(enabled),
|
|
15267
15339
|
onClose: closeTaskPane
|
|
15268
15340
|
}),
|
|
15269
15341
|
canEditDocument && layoutOpen && section && /*#__PURE__*/ jsx(DocumentLayoutPanel, {
|