@a3s-lab/office 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -5
- package/dist/{0~7231.js → 0~4808.js} +189 -2
- package/dist/0~5050.js +10 -1
- package/dist/{0~7360.js → 0~7240.js} +244 -15
- package/dist/0~document-editor.js +622 -125
- package/dist/0~work-docx-export.js +214 -26
- package/dist/0~work-docx-import.js +17 -6
- package/dist/0~work-office-diagnostics.js +25 -4
- package/dist/4104.js +1 -1
- package/dist/4121.js +412 -11
- package/dist/6282.js +431 -2
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +27 -0
- package/dist/internal/features/work/editors/document-dom-selection.d.ts +7 -0
- package/dist/internal/features/work/editors/document-editor-support.d.ts +1 -0
- package/dist/internal/features/work/editors/document-index-dialog.d.ts +10 -0
- package/dist/internal/features/work/editors/document-index-entry-dialog.d.ts +10 -0
- package/dist/internal/features/work/editors/document-references-ribbon.d.ts +19 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +4 -1
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +3 -0
- package/dist/internal/features/work/work-document-index-fields.d.ts +19 -0
- package/dist/internal/features/work/work-document-index-nodes.d.ts +32 -0
- package/dist/internal/features/work/work-document-index.d.ts +63 -0
- package/dist/internal/features/work/work-docx-import.d.ts +3 -1
- package/dist/internal/features/work/work-docx-index-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-index-import.d.ts +23 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +296 -0
- package/docs/latest/en/browser-editor-architecture.md +14 -0
- package/package.json +4 -1
|
@@ -6,7 +6,7 @@ import { Fragment as external_react_Fragment, forwardRef, useCallback, useEffect
|
|
|
6
6
|
import { Extension, createNodeFromContent } from "@tiptap/core";
|
|
7
7
|
import { NodeSelection, Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
|
|
8
8
|
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
9
|
-
import { AArrowDown, AArrowUp, ALargeSmall, AlignCenter, AlignJustify, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, BetweenHorizontalEnd, BetweenHorizontalStart, BetweenVerticalEnd, BetweenVerticalStart, Bold, BookMarked, BookOpen, Bookmark, CaseUpper, Check, CheckCheck, CheckCircle2, ChevronDown, ChevronRight, ChevronUp, ClipboardCopy, ClipboardPaste, Cloud, Columns3, Eraser, Eye, FileDiff, FilePlus2, FileText, Globe2, Grid2X2, Hash, Highlighter, Image, IndentDecrease, IndentIncrease, Italic, Languages, Link2, List, ListChecks, ListOrdered, ListTree, MessageSquarePlus, MessageSquareReply, MessagesSquare, MoveVertical, Paintbrush, Palette, PanelBottom, PanelBottomOpen, PanelLeftOpen, PanelTop, PanelTopOpen, Pilcrow, PilcrowLeft, PilcrowRight, Plus, Quote, Redo2, RefreshCw, Replace, ReplaceAll, RotateCcw, Rows3, Ruler, Scan, Search, Settings2, Square, StretchHorizontal, Strikethrough, Subscript, Superscript, Table2, TableCellsMerge, TableCellsSplit, TableProperties, TextWrap, Trash2, TriangleAlert, Type, Underline, Undo2, Unlink, Unlink2, X, XCircle, ZoomIn, ZoomOut } from "lucide-react";
|
|
9
|
+
import { AArrowDown, AArrowUp, ALargeSmall, AlignCenter, AlignJustify, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, BetweenHorizontalEnd, BetweenHorizontalStart, BetweenVerticalEnd, BetweenVerticalStart, Bold, BookMarked, BookOpen, Bookmark, CaseUpper, Check, CheckCheck, CheckCircle2, ChevronDown, ChevronRight, ChevronUp, ClipboardCopy, ClipboardPaste, Cloud, Columns3, Eraser, Eye, FileDiff, FilePlus2, FileText, Globe2, Grid2X2, Hash, Highlighter, Image, IndentDecrease, IndentIncrease, Italic, Languages, Link2, List, ListChecks, ListOrdered, ListTree, MessageSquarePlus, MessageSquareReply, MessagesSquare, MoveVertical, Paintbrush, Palette, PanelBottom, PanelBottomOpen, PanelLeftOpen, PanelTop, PanelTopOpen, Pilcrow, PilcrowLeft, PilcrowRight, Plus, Quote, Redo2, RefreshCw, Replace, ReplaceAll, RotateCcw, Rows3, Ruler, Scan, Search, Settings2, Square, StretchHorizontal, Strikethrough, Subscript, Superscript, Table2, TableCellsMerge, TableCellsSplit, TableProperties, Tags, TextWrap, Trash2, TriangleAlert, Type, Underline, Undo2, Unlink, Unlink2, X, XCircle, ZoomIn, ZoomOut } from "lucide-react";
|
|
10
10
|
import { Node as model_Node } from "@tiptap/pm/model";
|
|
11
11
|
import extension_color from "@tiptap/extension-color";
|
|
12
12
|
import { TableKit } from "@tiptap/extension-table";
|
|
@@ -15,15 +15,15 @@ import font_size from "@tiptap/extension-text-style/font-size";
|
|
|
15
15
|
import starter_kit from "@tiptap/starter-kit";
|
|
16
16
|
import { BubbleMenu } from "@tiptap/react/menus";
|
|
17
17
|
import { TableMap, isInTable, selectedRect } from "@tiptap/pm/tables";
|
|
18
|
-
import { documentTableSizing, transferChangedDocumentTextStatistics, documentPageBordersVisible, documentUnderlineStyle, DOCUMENT_PAGE_BORDER_EDGES, documentTableRowOptions, normalizeDocumentColumns, clampDocumentMargin, materializeLazyDocumentEditorRoot, documentKerningThresholdPoints,
|
|
18
|
+
import { documentTableSizing, transferChangedDocumentTextStatistics, documentPageBordersVisible, documentUnderlineStyle, DOCUMENT_PAGE_BORDER_EDGES, documentTableRowOptions, normalizeDocumentColumns, clampDocumentMargin, materializeLazyDocumentEditorRoot, documentKerningThresholdPoints, selectedDocumentIndexOptions, nextDocumentTabAlignment, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, normalizedTabPosition, documentCitationCount, resolveDocumentPageBorders, documentLazyHtmlChunkFragment, DocumentFontFamily, normalizeDocumentHiddenText, documentLegacyTextEffectsConflict, DOCUMENT_CHUNK_VISIBLE_IDS_META, selectedDocumentIndexDraft, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, retainAnchoredDocumentComments, DocumentTableRowIdentity, work_document_page_margins_twipsToMillimeters, DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, resolveWorkDocumentEditorInput, documentCharacterPositionPoints, documentBulletListStyle, collectDocumentTextLayoutParagraphs, readOfficeDocumentCollaboration as readWorkOfficeDocumentCollaboration, normalizeDocumentCharacterScalePercent, documentOrderedListState, normalizeDocumentPageChrome, documentTextStatistics, documentPageMarginsForLayout, invalidateDocumentLazyHtmlProjection, documentTableCellFormat, normalizeDocumentPageGeometry, normalizeDocumentImageLayer, documentImageProperties, isValidDocumentCitationTag, sanitizeDocumentPageChromeHtml, pageTwipsToMillimeters, normalizeDocumentPageBorders, activeDocumentSection, DocumentParagraphFormatting, normalizeDocumentHtml, documentInitialSectionLayout, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentParagraphDirection, documentParagraphPagination, documentPageChromeLegacyFields, documentChunkMountedIds, collectDocumentCommentAnchors, documentTextCaseKeyboardShortcuts, DocumentTextStyle, canChangeDocumentIndent, documentCharacterSpacingPoints, documentKerningIsEffective, DocumentSuperscript, documentSectionById, activeDocumentBookmark, DocumentEquation, documentLazyHtmlProjectionFingerprint, documentLazyHtmlProjection, normalizeDocumentParagraphIndent, updateDocumentGutterPosition, DocumentStrike, mountWorkLiveDocumentCapture, registerDocumentPageSurfaceGeometry, documentHiddenTextKeyboardShortcut, documentHasIndex, syncDocumentContentFromHtml, documentLegacyTextEffectsCss, editorDocumentCaptionTargets, resolveDocumentPageChrome, documentImageLayoutOptions, MAX_DOCUMENT_NUMBERING_START, resolveDocumentPageSize, editorDocumentBookmarkReferenceTargets, serializeWorkDocumentNode, DOCUMENT_CHUNK_PAGINATION_META, createOfficeDocumentCollaborationBinding as createWorkOfficeDocumentCollaborationBinding, documentModelForContent, documentLegacyTextEffectsFromTextStyleAttributes, normalizeDocumentEmphasisMark, selectedDocumentChunkId, documentCommentViews, documentParagraphSpacing, normalizeDocumentTabStops, patchDocumentLazyHtmlProjection, normalizeDocumentTextCase, documentUnderlineColor, documentBookmarkNameExists, collectDocumentChanges, DocumentImage, selectedDocumentTableOfContentsOptions, resolveDocumentPageMargins, updateDocumentPageMarginMode, canSetDocumentTableRowRepeatHeader, normalizeDocumentCharacterSpacingTwips, DocumentCharacterFormatting, millimetersToPixels as work_document_layout_millimetersToPixels, DOCUMENT_CHUNK_HYDRATION_META, documentTabLeaderLabel, createSchemaDerivedWorkDocumentModel, updateDocumentCustomPageMillimeters, DocumentUnderline, documentCommentDraftRange, documentParagraphTabStops, documentTableHorizontalAlignment, documentUnderlineKeyboardShortcuts, documentParagraphIndent, DocumentScriptFontFormatting, canInsertDocumentComment, documentHasTableOfContents, documentTextLayoutBatches, normalizeDocumentImageWrapSide, updateDocumentPageOrientation, documentCitationStyleDetails, validateDocumentBookmarkName, setCustomDocumentColumns, updateDocumentPageMarginMillimeters, documentCitationStyle, normalizeDocumentCharacterPositionHalfPoints, documentTransactionsOnlyHydrateChunks, normalizeDocumentKerningThresholdHalfPoints, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DOCUMENT_TABLE_STYLE_OPTIONS, updateDocumentColumnWidth, updateDocumentPaperSizePreset, documentPageMetrics, documentStrikeStyle, DocumentHighlight, createDocumentBibliography, DocumentSubscript, selectedDocumentIndexEntry, updateDocumentPageChromeVariant, updateDocumentMirrorMargins, activeDocumentTableStyle, measureDocumentLayoutBlocksIncrementally, documentWordLineHeightFactor, normalizeDocumentLegacyTextEffect, createWorkDocumentExtensions } from "./6282.js";
|
|
19
19
|
import { useOfficeTaskPaneEscape, normalizeOfficeFontFamily, OfficeCheckbox, useOfficeDialog, useOfficeTaskPaneModal, CommittedOfficeNumberField, officeFontFamilyLabel, officeFontFamilies, CollectionState, createOfficeKernelClient, OfficeNumberField } from "./0~7048.js";
|
|
20
20
|
import { moveOfficeMenuFocus, office_text_field_OfficeTextArea, Popover, officeOverlayPortalRoot, button_Button, useOfficePublishPresenceLocation, OfficeTiptapPresenceLayer, icon_button_IconButton, office_text_field_OfficeTextField, useDialogFocusScope, useOfficeEditorWheelZoom, office_text_field_OfficeFileInput } from "./0~6090.js";
|
|
21
21
|
import { WorkOfficePreviewBar, isWorkspaceContextMenuKeyboardEvent, Tabs, WorkOfficeZoomControls, WorkOfficeStatusBar, Dialog, WorkOfficeRibbon, workspaceContextMenuPosition, OfficeSelect, WorkspaceContextMenu, WorkOfficeRibbonGroup, WorkOfficeRibbonButton } from "./0~4595.js";
|
|
22
|
-
import { documentFontNameFromCssFamily, normalizeDocumentRunBorder, parseDocumentScriptFonts, parseDocumentRunShading, DOCUMENT_RUN_BORDER_STYLES, serializeDocumentRunBorder, documentScriptFontDirectFamily, serializeDocumentRunShading, patchDocumentScriptFonts, serializeDocumentScriptFonts, documentRunBorderIsVisible, cssDocumentFontFamily, isDocumentParagraphArtBorderStyle, visibleWorkDocumentOutlineItems, DEFAULT_DOCUMENT_TABLE_OF_CONTENTS_OPTIONS, createOfficeId as createWorkId, normalizeDocumentLanguageTag, currentWorkDocumentOutlineItem, normalizeDocumentNoProof, parseDocumentRunBorder, DocumentParagraphIdentity, parseDocumentProofingLanguages, collectWorkDocumentOutline, documentScriptFontSlotFromHint, documentBorderPresentation, documentScriptFontFamilyForRendering, normalizeDocumentRunShading, normalizeDocumentScriptFontSlot, documentScriptFontSegments, patchDocumentProofingLanguages, serializeDocumentProofingLanguages, documentRunShadingDomAttributes } from "./4121.js";
|
|
22
|
+
import { documentFontNameFromCssFamily, normalizeDocumentRunBorder, parseDocumentScriptFonts, parseDocumentRunShading, DOCUMENT_RUN_BORDER_STYLES, serializeDocumentRunBorder, documentScriptFontDirectFamily, serializeDocumentRunShading, patchDocumentScriptFonts, serializeDocumentScriptFonts, documentRunBorderIsVisible, cssDocumentFontFamily, isDocumentParagraphArtBorderStyle, visibleWorkDocumentOutlineItems, DEFAULT_DOCUMENT_TABLE_OF_CONTENTS_OPTIONS, createOfficeId as createWorkId, DEFAULT_DOCUMENT_INDEX_OPTIONS, normalizeDocumentLanguageTag, currentWorkDocumentOutlineItem, normalizeDocumentNoProof, parseDocumentRunBorder, DocumentParagraphIdentity, parseDocumentProofingLanguages, collectWorkDocumentOutline, documentScriptFontSlotFromHint, documentBorderPresentation, documentScriptFontFamilyForRendering, normalizeDocumentRunShading, normalizeDocumentScriptFontSlot, documentScriptFontSegments, patchDocumentProofingLanguages, serializeDocumentProofingLanguages, documentRunShadingDomAttributes } from "./4121.js";
|
|
23
23
|
import { normalizeDocumentHref, DOCUMENT_LINK_VALIDATION_MESSAGE } from "./0~work-document-links.js";
|
|
24
24
|
import { OfficeColorPicker, isOfficeShortcutBlocked } from "./0~3635.js";
|
|
25
25
|
import { OfficeTableInsertPopover, readOfficeFileAsDataUrl } from "./0~9445.js";
|
|
26
|
-
import { mergeOfficeTiptapExtensions,
|
|
26
|
+
import { mergeOfficeTiptapExtensions, documentHasRefreshableFields, documentCurrentPage, documentAgentMenuItems, documentPageCount, createWorkDocumentSelectionSnapshot, documentPlainTextAsHtml, createWorkDocumentSelectionAction, documentCustomSelectionMenuItems } from "./0~5050.js";
|
|
27
27
|
import { WorkEditorLoadingState, documentLayoutFontKey, useOfficeCollaborationLocationNavigator, OFFICE_DOCUMENT_LAYOUT_HEBREW_FONT_ID, useOfficeEditorInitialFocus, OFFICE_DOCUMENT_LAYOUT_FONT_ID, OFFICE_DOCUMENT_LAYOUT_ARABIC_FONT_ID, OFFICE_DOCUMENT_LAYOUT_LATIN_FONT_ID } from "./432.js";
|
|
28
28
|
import { useOfficeDraft, InlineNotice } from "./0~345.js";
|
|
29
29
|
import { documentPageColor, normalizeDocumentPageColor } from "./0~work-document-page-color.js";
|
|
@@ -7483,6 +7483,33 @@ const documentCommandCatalog = {
|
|
|
7483
7483
|
group: 'tableOfContents'
|
|
7484
7484
|
}
|
|
7485
7485
|
},
|
|
7486
|
+
markIndexEntry: {
|
|
7487
|
+
id: 'references.markIndexEntry',
|
|
7488
|
+
label: '标记索引项',
|
|
7489
|
+
location: {
|
|
7490
|
+
area: 'ribbon',
|
|
7491
|
+
tab: 'references',
|
|
7492
|
+
group: 'index'
|
|
7493
|
+
}
|
|
7494
|
+
},
|
|
7495
|
+
index: {
|
|
7496
|
+
id: 'references.index',
|
|
7497
|
+
label: '插入或自定义索引',
|
|
7498
|
+
location: {
|
|
7499
|
+
area: 'ribbon',
|
|
7500
|
+
tab: 'references',
|
|
7501
|
+
group: 'index'
|
|
7502
|
+
}
|
|
7503
|
+
},
|
|
7504
|
+
refreshIndex: {
|
|
7505
|
+
id: 'references.refreshIndex',
|
|
7506
|
+
label: '更新索引',
|
|
7507
|
+
location: {
|
|
7508
|
+
area: 'ribbon',
|
|
7509
|
+
tab: 'references',
|
|
7510
|
+
group: 'index'
|
|
7511
|
+
}
|
|
7512
|
+
},
|
|
7486
7513
|
refreshFields: {
|
|
7487
7514
|
id: 'references.refreshFields',
|
|
7488
7515
|
label: '更新域',
|
|
@@ -8069,6 +8096,28 @@ function DocumentStatusBar({ bibliographyCount, citationCount, currentPage, page
|
|
|
8069
8096
|
]
|
|
8070
8097
|
});
|
|
8071
8098
|
}
|
|
8099
|
+
function synchronizeDocumentEditorSelectionFromDom(editor) {
|
|
8100
|
+
if (editor.isDestroyed) return false;
|
|
8101
|
+
const { view } = editor;
|
|
8102
|
+
const domSelection = view.dom.ownerDocument.getSelection();
|
|
8103
|
+
if (!domSelection || domSelection.isCollapsed || 1 !== domSelection.rangeCount) return false;
|
|
8104
|
+
const range = domSelection.getRangeAt(0);
|
|
8105
|
+
if (!view.dom.contains(range.startContainer) || !view.dom.contains(range.endContainer)) return false;
|
|
8106
|
+
let from;
|
|
8107
|
+
let to;
|
|
8108
|
+
try {
|
|
8109
|
+
from = view.posAtDOM(range.startContainer, range.startOffset, 1);
|
|
8110
|
+
to = view.posAtDOM(range.endContainer, range.endOffset, -1);
|
|
8111
|
+
} catch {
|
|
8112
|
+
return false;
|
|
8113
|
+
}
|
|
8114
|
+
const maximum = editor.state.doc.content.size;
|
|
8115
|
+
if (from < 0 || to <= from || to > maximum) return false;
|
|
8116
|
+
const nextSelection = TextSelection.between(editor.state.doc.resolve(from), editor.state.doc.resolve(to), 1);
|
|
8117
|
+
if (nextSelection.empty || nextSelection.eq(editor.state.selection)) return false;
|
|
8118
|
+
view.dispatch(editor.state.tr.setSelection(nextSelection).setMeta('addToHistory', false));
|
|
8119
|
+
return true;
|
|
8120
|
+
}
|
|
8072
8121
|
const proofingStateOptions = [
|
|
8073
8122
|
{
|
|
8074
8123
|
value: 'mixed',
|
|
@@ -13137,6 +13186,158 @@ function PictureButton({ label, active = false, disabled = false, onClick, child
|
|
|
13137
13186
|
children: children
|
|
13138
13187
|
});
|
|
13139
13188
|
}
|
|
13189
|
+
function DocumentReferencesRibbon({ editor, citationsOpen, citationSourceCount, onInsertNote, onInsertCaption, onInsertCrossReference, onOpenTableOfContents, onRefreshTableOfContents, onOpenIndexEntry, onOpenIndex, onRefreshIndex, onToggleCitations, onRefreshFields }) {
|
|
13190
|
+
const hasTableOfContents = documentHasTableOfContents(editor);
|
|
13191
|
+
const hasIndex = documentHasIndex(editor);
|
|
13192
|
+
const canMarkIndexEntry = Boolean(selectedDocumentIndexDraft(editor));
|
|
13193
|
+
const hasRefreshableFields = documentHasRefreshableFields(editor);
|
|
13194
|
+
const refreshFieldsCommand = getDocumentCommandDefinition('refreshFields');
|
|
13195
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
13196
|
+
children: [
|
|
13197
|
+
/*#__PURE__*/ jsxs(WorkOfficeRibbonGroup, {
|
|
13198
|
+
label: "目录",
|
|
13199
|
+
priority: "high",
|
|
13200
|
+
children: [
|
|
13201
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13202
|
+
label: "插入或自定义目录",
|
|
13203
|
+
onClick: onOpenTableOfContents,
|
|
13204
|
+
children: /*#__PURE__*/ jsx(ListTree, {
|
|
13205
|
+
size: 19
|
|
13206
|
+
})
|
|
13207
|
+
}),
|
|
13208
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13209
|
+
label: "更新目录",
|
|
13210
|
+
disabled: !hasTableOfContents,
|
|
13211
|
+
title: hasTableOfContents ? '根据当前标题和页码更新目录' : '文档中没有可更新的目录',
|
|
13212
|
+
onClick: onRefreshTableOfContents,
|
|
13213
|
+
children: /*#__PURE__*/ jsx(RefreshCw, {
|
|
13214
|
+
size: 19
|
|
13215
|
+
})
|
|
13216
|
+
})
|
|
13217
|
+
]
|
|
13218
|
+
}),
|
|
13219
|
+
/*#__PURE__*/ jsxs(WorkOfficeRibbonGroup, {
|
|
13220
|
+
label: "脚注",
|
|
13221
|
+
priority: "high",
|
|
13222
|
+
children: [
|
|
13223
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13224
|
+
label: "插入脚注",
|
|
13225
|
+
onClick: ()=>onInsertNote('footnote'),
|
|
13226
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
13227
|
+
className: "work-ribbon-glyph",
|
|
13228
|
+
children: "\xb9"
|
|
13229
|
+
})
|
|
13230
|
+
}),
|
|
13231
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13232
|
+
label: "插入尾注",
|
|
13233
|
+
onClick: ()=>onInsertNote('endnote'),
|
|
13234
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
13235
|
+
className: "work-ribbon-glyph",
|
|
13236
|
+
children: "ⅰ"
|
|
13237
|
+
})
|
|
13238
|
+
})
|
|
13239
|
+
]
|
|
13240
|
+
}),
|
|
13241
|
+
/*#__PURE__*/ jsxs(WorkOfficeRibbonGroup, {
|
|
13242
|
+
label: "题注",
|
|
13243
|
+
children: [
|
|
13244
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13245
|
+
label: "插入图片题注",
|
|
13246
|
+
onClick: ()=>onInsertCaption('figure'),
|
|
13247
|
+
children: /*#__PURE__*/ jsx(Image, {
|
|
13248
|
+
size: 19
|
|
13249
|
+
})
|
|
13250
|
+
}),
|
|
13251
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13252
|
+
label: "插入表格题注",
|
|
13253
|
+
onClick: ()=>onInsertCaption('table'),
|
|
13254
|
+
children: /*#__PURE__*/ jsx(Table2, {
|
|
13255
|
+
size: 19
|
|
13256
|
+
})
|
|
13257
|
+
}),
|
|
13258
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13259
|
+
label: "插入交叉引用",
|
|
13260
|
+
onClick: onInsertCrossReference,
|
|
13261
|
+
children: /*#__PURE__*/ jsx(Link2, {
|
|
13262
|
+
size: 19
|
|
13263
|
+
})
|
|
13264
|
+
})
|
|
13265
|
+
]
|
|
13266
|
+
}),
|
|
13267
|
+
/*#__PURE__*/ jsx(WorkOfficeRibbonGroup, {
|
|
13268
|
+
label: "引文和书目",
|
|
13269
|
+
priority: "high",
|
|
13270
|
+
children: /*#__PURE__*/ jsx(ReferencesButton, {
|
|
13271
|
+
label: `文献库${citationSourceCount ? `(${citationSourceCount})` : ''}`,
|
|
13272
|
+
active: citationsOpen,
|
|
13273
|
+
onClick: onToggleCitations,
|
|
13274
|
+
children: /*#__PURE__*/ jsx(BookOpen, {
|
|
13275
|
+
size: 19
|
|
13276
|
+
})
|
|
13277
|
+
})
|
|
13278
|
+
}),
|
|
13279
|
+
/*#__PURE__*/ jsxs(WorkOfficeRibbonGroup, {
|
|
13280
|
+
label: "索引",
|
|
13281
|
+
priority: "high",
|
|
13282
|
+
children: [
|
|
13283
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13284
|
+
label: "标记索引项",
|
|
13285
|
+
disabled: !canMarkIndexEntry,
|
|
13286
|
+
title: canMarkIndexEntry ? '把当前选中文字标记为索引项' : '请先选择正文文字或已有索引项',
|
|
13287
|
+
onClick: onOpenIndexEntry,
|
|
13288
|
+
children: /*#__PURE__*/ jsx(Tags, {
|
|
13289
|
+
size: 19
|
|
13290
|
+
})
|
|
13291
|
+
}),
|
|
13292
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13293
|
+
label: "插入或自定义索引",
|
|
13294
|
+
onClick: onOpenIndex,
|
|
13295
|
+
children: /*#__PURE__*/ jsx(ListOrdered, {
|
|
13296
|
+
size: 19
|
|
13297
|
+
})
|
|
13298
|
+
}),
|
|
13299
|
+
/*#__PURE__*/ jsx(ReferencesButton, {
|
|
13300
|
+
label: "更新索引",
|
|
13301
|
+
disabled: !hasIndex,
|
|
13302
|
+
title: hasIndex ? '根据当前索引项和页码更新索引' : '文档中没有可更新的索引',
|
|
13303
|
+
onClick: onRefreshIndex,
|
|
13304
|
+
children: /*#__PURE__*/ jsx(RefreshCw, {
|
|
13305
|
+
size: 19
|
|
13306
|
+
})
|
|
13307
|
+
})
|
|
13308
|
+
]
|
|
13309
|
+
}),
|
|
13310
|
+
/*#__PURE__*/ jsx(WorkOfficeRibbonGroup, {
|
|
13311
|
+
label: "更新",
|
|
13312
|
+
priority: "low",
|
|
13313
|
+
children: /*#__PURE__*/ jsx(ReferencesButton, {
|
|
13314
|
+
label: "更新页码和日期",
|
|
13315
|
+
shortcut: refreshFieldsCommand.shortcut?.label,
|
|
13316
|
+
ariaKeyShortcuts: refreshFieldsCommand.shortcut?.aria,
|
|
13317
|
+
disabled: !hasRefreshableFields,
|
|
13318
|
+
title: hasRefreshableFields ? `更新页码和日期(${refreshFieldsCommand.shortcut?.label})` : '文档中没有可更新的页码或日期',
|
|
13319
|
+
onClick: onRefreshFields,
|
|
13320
|
+
children: /*#__PURE__*/ jsx(RefreshCw, {
|
|
13321
|
+
size: 19
|
|
13322
|
+
})
|
|
13323
|
+
})
|
|
13324
|
+
})
|
|
13325
|
+
]
|
|
13326
|
+
});
|
|
13327
|
+
}
|
|
13328
|
+
function ReferencesButton({ label, title, shortcut, ariaKeyShortcuts, active = false, disabled = false, onClick, children }) {
|
|
13329
|
+
return /*#__PURE__*/ jsx(WorkOfficeRibbonButton, {
|
|
13330
|
+
label: label,
|
|
13331
|
+
visibleLabel: label.replace(/(\d+)$/, ''),
|
|
13332
|
+
title: title ?? (shortcut ? `${label}(${shortcut})` : label),
|
|
13333
|
+
"aria-keyshortcuts": ariaKeyShortcuts,
|
|
13334
|
+
active: active,
|
|
13335
|
+
displayLabel: true,
|
|
13336
|
+
disabled: disabled,
|
|
13337
|
+
onClick: onClick,
|
|
13338
|
+
children: children
|
|
13339
|
+
});
|
|
13340
|
+
}
|
|
13140
13341
|
function selectedDocumentChangeIndex(changes, selection) {
|
|
13141
13342
|
const index = changes.findIndex((change)=>selection.from === selection.to ? change.from <= selection.from && selection.from <= change.to : change.from < selection.to && change.to > selection.from);
|
|
13142
13343
|
return index >= 0 ? index : null;
|
|
@@ -14942,7 +15143,7 @@ function headingLevelForShortcut(code, key) {
|
|
|
14942
15143
|
if ('3' === value) return 3;
|
|
14943
15144
|
return null;
|
|
14944
15145
|
}
|
|
14945
|
-
function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly = false, suggestionOnly = false, history, layoutOpen, layout, layoutFonts = [], navigationOpen, pageColor, showPageNumbers, showHiddenText, showRulers, spellcheckEnabled, viewMode, zoom, pageChromeEditor, pageChromeEditingPart, pageChromeShowPageNumber, onRequestImage, onPageChromeEditingPartChange, onClosePageChrome, onTogglePageChromePageNumber, onToggleLayout, onLayoutChange, onOpenLayout, onToggleNavigation, onTogglePageNumbers, onToggleHiddenText, onToggleRulers, onPageColorChange, onToggleSpellcheck, onViewModeChange, onZoomChange, onZoomFit, onInsertSection, onInsertNote, onInsertCaption, onInsertCrossReference, onOpenTableOfContents, citationsOpen, citationSourceCount, onToggleCitations, onInsertField, onRefreshFields, onRefreshTableOfContents, canInsertComment, onInsertComment, commentsOpen, commentCount, onToggleComments, trackChanges, changesOpen, changeCount, findReplaceMode, fileActions, onRibbonTabChange, onToggleTrackChanges, onToggleChanges, onDecideChange, onOpenWordCount, onOpenFindReplace }) {
|
|
15146
|
+
function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly = false, suggestionOnly = false, history, layoutOpen, layout, layoutFonts = [], navigationOpen, pageColor, showPageNumbers, showHiddenText, showRulers, spellcheckEnabled, viewMode, zoom, pageChromeEditor, pageChromeEditingPart, pageChromeShowPageNumber, onRequestImage, onPageChromeEditingPartChange, onClosePageChrome, onTogglePageChromePageNumber, onToggleLayout, onLayoutChange, onOpenLayout, onToggleNavigation, onTogglePageNumbers, onToggleHiddenText, onToggleRulers, onPageColorChange, onToggleSpellcheck, onViewModeChange, onZoomChange, onZoomFit, onInsertSection, onInsertNote, onInsertCaption, onInsertCrossReference, onOpenTableOfContents, onOpenIndexEntry, onOpenIndex, citationsOpen, citationSourceCount, onToggleCitations, onInsertField, onRefreshFields, onRefreshIndex, onRefreshTableOfContents, canInsertComment, onInsertComment, commentsOpen, commentCount, onToggleComments, trackChanges, changesOpen, changeCount, findReplaceMode, fileActions, onRibbonTabChange, onToggleTrackChanges, onToggleChanges, onDecideChange, onOpenWordCount, onOpenFindReplace }) {
|
|
14946
15147
|
const [activeTab, setActiveTab] = useState(reviewOnly ? 'review' : 'home');
|
|
14947
15148
|
const [fontDialogRequest, setFontDialogRequest] = useState(null);
|
|
14948
15149
|
const [proofingDialogRequest, setProofingDialogRequest] = useState(null);
|
|
@@ -14952,19 +15153,18 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
|
|
|
14952
15153
|
const tableSelected = editor.isActive('table');
|
|
14953
15154
|
const activeBookmark = activeDocumentBookmark(editor);
|
|
14954
15155
|
const hasRefreshableFields = documentHasRefreshableFields(editor);
|
|
14955
|
-
const hasTableOfContents = documentHasTableOfContents(editor);
|
|
14956
15156
|
const documentChanges = collectDocumentChanges(editor.state.doc);
|
|
14957
15157
|
const previousChangeIndex = adjacentDocumentChangeIndex(documentChanges, editor.state.selection, -1);
|
|
14958
15158
|
const nextChangeIndex = adjacentDocumentChangeIndex(documentChanges, editor.state.selection, 1);
|
|
14959
15159
|
const actionableChangeIndex = actionableDocumentChangeIndex(documentChanges, editor.state.selection);
|
|
14960
15160
|
const undoCommand = getDocumentCommandDefinition('undo');
|
|
14961
15161
|
const redoCommand = getDocumentCommandDefinition('redo');
|
|
14962
|
-
const refreshFieldsCommand = getDocumentCommandDefinition('refreshFields');
|
|
14963
15162
|
const spellingCommand = getDocumentCommandDefinition('spelling');
|
|
14964
15163
|
const insertCommentCommand = getDocumentCommandDefinition('insertComment');
|
|
14965
15164
|
const trackChangesCommand = getDocumentCommandDefinition('trackChanges');
|
|
14966
15165
|
const openFontDialog = useCallback((target)=>{
|
|
14967
15166
|
if (target.isDestroyed) return;
|
|
15167
|
+
synchronizeDocumentEditorSelectionFromDom(target);
|
|
14968
15168
|
const { from, to } = target.state.selection;
|
|
14969
15169
|
setFontDialogRequest({
|
|
14970
15170
|
editor: target,
|
|
@@ -14977,6 +15177,7 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
|
|
|
14977
15177
|
}, []);
|
|
14978
15178
|
const openProofingDialog = useCallback((target)=>{
|
|
14979
15179
|
if (target.isDestroyed) return;
|
|
15180
|
+
synchronizeDocumentEditorSelectionFromDom(target);
|
|
14980
15181
|
const { from, to } = target.state.selection;
|
|
14981
15182
|
setProofingDialogRequest({
|
|
14982
15183
|
editor: target,
|
|
@@ -15360,115 +15561,20 @@ function DocumentToolbar({ editor, defaultRibbonCollapsed = false, reviewOnly =
|
|
|
15360
15561
|
onPageColorChange: onPageColorChange,
|
|
15361
15562
|
onInsertSection: onInsertSection
|
|
15362
15563
|
}),
|
|
15363
|
-
references: reviewOnly ? null : /*#__PURE__*/
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
/*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
15378
|
-
label: "更新目录",
|
|
15379
|
-
displayLabel: true,
|
|
15380
|
-
disabled: !hasTableOfContents,
|
|
15381
|
-
title: hasTableOfContents ? '根据当前标题和页码更新目录' : '文档中没有可更新的目录',
|
|
15382
|
-
onClick: onRefreshTableOfContents,
|
|
15383
|
-
children: /*#__PURE__*/ jsx(RefreshCw, {
|
|
15384
|
-
size: 19
|
|
15385
|
-
})
|
|
15386
|
-
})
|
|
15387
|
-
]
|
|
15388
|
-
}),
|
|
15389
|
-
/*#__PURE__*/ jsxs(document_toolbar_RibbonGroup, {
|
|
15390
|
-
label: "脚注",
|
|
15391
|
-
priority: "high",
|
|
15392
|
-
children: [
|
|
15393
|
-
/*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
15394
|
-
label: "插入脚注",
|
|
15395
|
-
displayLabel: true,
|
|
15396
|
-
onClick: ()=>onInsertNote('footnote'),
|
|
15397
|
-
children: /*#__PURE__*/ jsx("span", {
|
|
15398
|
-
className: "work-ribbon-glyph",
|
|
15399
|
-
children: "\xb9"
|
|
15400
|
-
})
|
|
15401
|
-
}),
|
|
15402
|
-
/*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
15403
|
-
label: "插入尾注",
|
|
15404
|
-
displayLabel: true,
|
|
15405
|
-
onClick: ()=>onInsertNote('endnote'),
|
|
15406
|
-
children: /*#__PURE__*/ jsx("span", {
|
|
15407
|
-
className: "work-ribbon-glyph",
|
|
15408
|
-
children: "ⅰ"
|
|
15409
|
-
})
|
|
15410
|
-
})
|
|
15411
|
-
]
|
|
15412
|
-
}),
|
|
15413
|
-
/*#__PURE__*/ jsxs(document_toolbar_RibbonGroup, {
|
|
15414
|
-
label: "题注",
|
|
15415
|
-
children: [
|
|
15416
|
-
/*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
15417
|
-
label: "插入图片题注",
|
|
15418
|
-
displayLabel: true,
|
|
15419
|
-
onClick: ()=>onInsertCaption('figure'),
|
|
15420
|
-
children: /*#__PURE__*/ jsx(Image, {
|
|
15421
|
-
size: 19
|
|
15422
|
-
})
|
|
15423
|
-
}),
|
|
15424
|
-
/*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
15425
|
-
label: "插入表格题注",
|
|
15426
|
-
displayLabel: true,
|
|
15427
|
-
onClick: ()=>onInsertCaption('table'),
|
|
15428
|
-
children: /*#__PURE__*/ jsx(Table2, {
|
|
15429
|
-
size: 19
|
|
15430
|
-
})
|
|
15431
|
-
}),
|
|
15432
|
-
/*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
15433
|
-
label: "插入交叉引用",
|
|
15434
|
-
displayLabel: true,
|
|
15435
|
-
onClick: onInsertCrossReference,
|
|
15436
|
-
children: /*#__PURE__*/ jsx(Link2, {
|
|
15437
|
-
size: 19
|
|
15438
|
-
})
|
|
15439
|
-
})
|
|
15440
|
-
]
|
|
15441
|
-
}),
|
|
15442
|
-
/*#__PURE__*/ jsx(document_toolbar_RibbonGroup, {
|
|
15443
|
-
label: "引文和书目",
|
|
15444
|
-
priority: "high",
|
|
15445
|
-
children: /*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
15446
|
-
label: `文献库${citationSourceCount ? `(${citationSourceCount})` : ''}`,
|
|
15447
|
-
displayLabel: true,
|
|
15448
|
-
active: citationsOpen,
|
|
15449
|
-
onClick: onToggleCitations,
|
|
15450
|
-
children: /*#__PURE__*/ jsx(BookOpen, {
|
|
15451
|
-
size: 19
|
|
15452
|
-
})
|
|
15453
|
-
})
|
|
15454
|
-
}),
|
|
15455
|
-
/*#__PURE__*/ jsx(document_toolbar_RibbonGroup, {
|
|
15456
|
-
label: "更新",
|
|
15457
|
-
priority: "low",
|
|
15458
|
-
children: /*#__PURE__*/ jsx(document_toolbar_ToolbarButton, {
|
|
15459
|
-
label: "更新页码和日期",
|
|
15460
|
-
displayLabel: true,
|
|
15461
|
-
shortcut: refreshFieldsCommand.shortcut?.label,
|
|
15462
|
-
ariaKeyShortcuts: refreshFieldsCommand.shortcut?.aria,
|
|
15463
|
-
disabled: !hasRefreshableFields,
|
|
15464
|
-
title: hasRefreshableFields ? `更新页码和日期(${refreshFieldsCommand.shortcut?.label})` : '文档中没有可更新的页码或日期',
|
|
15465
|
-
onClick: onRefreshFields,
|
|
15466
|
-
children: /*#__PURE__*/ jsx(RefreshCw, {
|
|
15467
|
-
size: 19
|
|
15468
|
-
})
|
|
15469
|
-
})
|
|
15470
|
-
})
|
|
15471
|
-
]
|
|
15564
|
+
references: reviewOnly ? null : /*#__PURE__*/ jsx(DocumentReferencesRibbon, {
|
|
15565
|
+
editor: editor,
|
|
15566
|
+
citationsOpen: citationsOpen,
|
|
15567
|
+
citationSourceCount: citationSourceCount,
|
|
15568
|
+
onInsertNote: onInsertNote,
|
|
15569
|
+
onInsertCaption: onInsertCaption,
|
|
15570
|
+
onInsertCrossReference: onInsertCrossReference,
|
|
15571
|
+
onOpenTableOfContents: onOpenTableOfContents,
|
|
15572
|
+
onRefreshTableOfContents: onRefreshTableOfContents,
|
|
15573
|
+
onOpenIndexEntry: onOpenIndexEntry,
|
|
15574
|
+
onOpenIndex: onOpenIndex,
|
|
15575
|
+
onRefreshIndex: onRefreshIndex,
|
|
15576
|
+
onToggleCitations: onToggleCitations,
|
|
15577
|
+
onRefreshFields: onRefreshFields
|
|
15472
15578
|
}),
|
|
15473
15579
|
review: /*#__PURE__*/ jsxs(Fragment, {
|
|
15474
15580
|
children: [
|
|
@@ -15838,15 +15944,6 @@ function DocumentFieldSelect({ onInsertField }) {
|
|
|
15838
15944
|
}
|
|
15839
15945
|
});
|
|
15840
15946
|
}
|
|
15841
|
-
function documentHasRefreshableFields(editor) {
|
|
15842
|
-
let found = false;
|
|
15843
|
-
editor.state.doc.descendants((node)=>{
|
|
15844
|
-
if ('documentField' !== node.type.name) return !found;
|
|
15845
|
-
found = true;
|
|
15846
|
-
return false;
|
|
15847
|
-
});
|
|
15848
|
-
return found;
|
|
15849
|
-
}
|
|
15850
15947
|
function DocumentVerticalRuler({ layout, onLayoutChange }) {
|
|
15851
15948
|
const rulerRef = useRef(null);
|
|
15852
15949
|
const pageHeight = documentRulerPageHeight(layout);
|
|
@@ -16322,6 +16419,320 @@ const tableOfContentsLeaderOptions = [
|
|
|
16322
16419
|
label: '无'
|
|
16323
16420
|
}
|
|
16324
16421
|
];
|
|
16422
|
+
function DocumentIndexDialog({ editing, options, restoreFocusTarget, onCancel, onOptionsChange, onSubmit }) {
|
|
16423
|
+
const update = (patch)=>onOptionsChange({
|
|
16424
|
+
...options,
|
|
16425
|
+
...patch
|
|
16426
|
+
});
|
|
16427
|
+
return /*#__PURE__*/ jsxs(Dialog, {
|
|
16428
|
+
title: editing ? '自定义索引' : '插入索引',
|
|
16429
|
+
description: "从已标记的索引项生成可更新索引,并保留原生 DOCX INDEX 域。",
|
|
16430
|
+
className: "work-document-index-dialog",
|
|
16431
|
+
restoreFocusTarget: restoreFocusTarget,
|
|
16432
|
+
onClose: onCancel,
|
|
16433
|
+
footer: /*#__PURE__*/ jsxs(Fragment, {
|
|
16434
|
+
children: [
|
|
16435
|
+
/*#__PURE__*/ jsx(button_Button, {
|
|
16436
|
+
tone: "quiet",
|
|
16437
|
+
onClick: onCancel,
|
|
16438
|
+
children: "取消"
|
|
16439
|
+
}),
|
|
16440
|
+
/*#__PURE__*/ jsx(button_Button, {
|
|
16441
|
+
tone: "primary",
|
|
16442
|
+
onClick: onSubmit,
|
|
16443
|
+
children: editing ? '应用' : '插入索引'
|
|
16444
|
+
})
|
|
16445
|
+
]
|
|
16446
|
+
}),
|
|
16447
|
+
children: [
|
|
16448
|
+
/*#__PURE__*/ jsxs("div", {
|
|
16449
|
+
className: "work-document-index-dialog-grid",
|
|
16450
|
+
children: [
|
|
16451
|
+
/*#__PURE__*/ jsxs("div", {
|
|
16452
|
+
className: "work-document-index-dialog-field",
|
|
16453
|
+
children: [
|
|
16454
|
+
/*#__PURE__*/ jsx("span", {
|
|
16455
|
+
children: "栏数"
|
|
16456
|
+
}),
|
|
16457
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
16458
|
+
initialFocus: true,
|
|
16459
|
+
ariaLabel: "索引栏数",
|
|
16460
|
+
value: String(options.columns),
|
|
16461
|
+
options: indexColumnOptions,
|
|
16462
|
+
onValueChange: (columns)=>update({
|
|
16463
|
+
columns: Number(columns)
|
|
16464
|
+
})
|
|
16465
|
+
})
|
|
16466
|
+
]
|
|
16467
|
+
}),
|
|
16468
|
+
/*#__PURE__*/ jsxs("div", {
|
|
16469
|
+
className: "work-document-index-dialog-field",
|
|
16470
|
+
children: [
|
|
16471
|
+
/*#__PURE__*/ jsx("span", {
|
|
16472
|
+
children: "次索引项布局"
|
|
16473
|
+
}),
|
|
16474
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
16475
|
+
ariaLabel: "索引布局",
|
|
16476
|
+
value: options.format,
|
|
16477
|
+
options: indexFormatOptions,
|
|
16478
|
+
onValueChange: (format)=>update({
|
|
16479
|
+
format
|
|
16480
|
+
})
|
|
16481
|
+
})
|
|
16482
|
+
]
|
|
16483
|
+
})
|
|
16484
|
+
]
|
|
16485
|
+
}),
|
|
16486
|
+
/*#__PURE__*/ jsxs("div", {
|
|
16487
|
+
className: "work-document-index-dialog-options",
|
|
16488
|
+
children: [
|
|
16489
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
16490
|
+
ariaLabel: "页码右对齐",
|
|
16491
|
+
checked: options.rightAlignPageNumbers,
|
|
16492
|
+
onCheckedChange: (rightAlignPageNumbers)=>update({
|
|
16493
|
+
rightAlignPageNumbers
|
|
16494
|
+
}),
|
|
16495
|
+
children: "页码右对齐"
|
|
16496
|
+
}),
|
|
16497
|
+
/*#__PURE__*/ jsxs("div", {
|
|
16498
|
+
className: "work-document-index-dialog-field",
|
|
16499
|
+
children: [
|
|
16500
|
+
/*#__PURE__*/ jsx("span", {
|
|
16501
|
+
children: "前导符"
|
|
16502
|
+
}),
|
|
16503
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
16504
|
+
ariaLabel: "索引前导符",
|
|
16505
|
+
value: options.leader,
|
|
16506
|
+
options: indexLeaderOptions,
|
|
16507
|
+
disabled: !options.rightAlignPageNumbers,
|
|
16508
|
+
onValueChange: (leader)=>update({
|
|
16509
|
+
leader
|
|
16510
|
+
})
|
|
16511
|
+
})
|
|
16512
|
+
]
|
|
16513
|
+
})
|
|
16514
|
+
]
|
|
16515
|
+
}),
|
|
16516
|
+
/*#__PURE__*/ jsxs("fieldset", {
|
|
16517
|
+
className: "work-document-index-dialog-preview",
|
|
16518
|
+
"aria-label": "索引预览",
|
|
16519
|
+
"data-index-format": options.format,
|
|
16520
|
+
"data-index-leader": options.leader,
|
|
16521
|
+
"data-index-right-align-page-numbers": String(options.rightAlignPageNumbers),
|
|
16522
|
+
children: [
|
|
16523
|
+
/*#__PURE__*/ jsx("legend", {
|
|
16524
|
+
children: "索引"
|
|
16525
|
+
}),
|
|
16526
|
+
/*#__PURE__*/ jsxs("span", {
|
|
16527
|
+
children: [
|
|
16528
|
+
"Architecture ",
|
|
16529
|
+
/*#__PURE__*/ jsx("i", {
|
|
16530
|
+
"aria-hidden": "true"
|
|
16531
|
+
}),
|
|
16532
|
+
" 1, 3"
|
|
16533
|
+
]
|
|
16534
|
+
}),
|
|
16535
|
+
/*#__PURE__*/ jsxs("span", {
|
|
16536
|
+
className: "nested",
|
|
16537
|
+
children: [
|
|
16538
|
+
"Runtime ",
|
|
16539
|
+
/*#__PURE__*/ jsx("i", {
|
|
16540
|
+
"aria-hidden": "true"
|
|
16541
|
+
}),
|
|
16542
|
+
" 5"
|
|
16543
|
+
]
|
|
16544
|
+
})
|
|
16545
|
+
]
|
|
16546
|
+
})
|
|
16547
|
+
]
|
|
16548
|
+
});
|
|
16549
|
+
}
|
|
16550
|
+
const indexColumnOptions = [
|
|
16551
|
+
{
|
|
16552
|
+
value: '1',
|
|
16553
|
+
label: '一栏'
|
|
16554
|
+
},
|
|
16555
|
+
{
|
|
16556
|
+
value: '2',
|
|
16557
|
+
label: '两栏'
|
|
16558
|
+
},
|
|
16559
|
+
{
|
|
16560
|
+
value: '3',
|
|
16561
|
+
label: '三栏'
|
|
16562
|
+
},
|
|
16563
|
+
{
|
|
16564
|
+
value: '4',
|
|
16565
|
+
label: '四栏'
|
|
16566
|
+
}
|
|
16567
|
+
];
|
|
16568
|
+
const indexFormatOptions = [
|
|
16569
|
+
{
|
|
16570
|
+
value: 'indented',
|
|
16571
|
+
label: '缩进式'
|
|
16572
|
+
},
|
|
16573
|
+
{
|
|
16574
|
+
value: 'run-in',
|
|
16575
|
+
label: '连续式'
|
|
16576
|
+
}
|
|
16577
|
+
];
|
|
16578
|
+
const indexLeaderOptions = [
|
|
16579
|
+
{
|
|
16580
|
+
value: 'dot',
|
|
16581
|
+
label: '点线(……)'
|
|
16582
|
+
},
|
|
16583
|
+
{
|
|
16584
|
+
value: 'dash',
|
|
16585
|
+
label: '短横线(----)'
|
|
16586
|
+
},
|
|
16587
|
+
{
|
|
16588
|
+
value: 'underline',
|
|
16589
|
+
label: '下划线(____)'
|
|
16590
|
+
},
|
|
16591
|
+
{
|
|
16592
|
+
value: 'none',
|
|
16593
|
+
label: '无'
|
|
16594
|
+
}
|
|
16595
|
+
];
|
|
16596
|
+
function DocumentIndexEntryDialog({ editing, value, restoreFocusTarget, onCancel, onChange, onSubmit }) {
|
|
16597
|
+
const update = (patch)=>onChange({
|
|
16598
|
+
...value,
|
|
16599
|
+
...patch
|
|
16600
|
+
});
|
|
16601
|
+
const crossReferenceEnabled = Boolean(value.crossReference);
|
|
16602
|
+
const mainEntryId = useId();
|
|
16603
|
+
const subEntryId = useId();
|
|
16604
|
+
const crossReferenceId = useId();
|
|
16605
|
+
return /*#__PURE__*/ jsxs(Dialog, {
|
|
16606
|
+
title: editing ? '编辑索引项' : '标记索引项',
|
|
16607
|
+
description: "标记主索引项、次索引项或交叉引用,并保留原生 DOCX XE 域。",
|
|
16608
|
+
className: "work-document-index-entry-dialog",
|
|
16609
|
+
restoreFocusTarget: restoreFocusTarget,
|
|
16610
|
+
onClose: onCancel,
|
|
16611
|
+
footer: /*#__PURE__*/ jsxs(Fragment, {
|
|
16612
|
+
children: [
|
|
16613
|
+
/*#__PURE__*/ jsx(button_Button, {
|
|
16614
|
+
tone: "quiet",
|
|
16615
|
+
onClick: onCancel,
|
|
16616
|
+
children: "取消"
|
|
16617
|
+
}),
|
|
16618
|
+
/*#__PURE__*/ jsx(button_Button, {
|
|
16619
|
+
tone: "primary",
|
|
16620
|
+
disabled: !value.mainEntry.trim(),
|
|
16621
|
+
onClick: onSubmit,
|
|
16622
|
+
children: editing ? '应用' : '标记'
|
|
16623
|
+
})
|
|
16624
|
+
]
|
|
16625
|
+
}),
|
|
16626
|
+
children: [
|
|
16627
|
+
/*#__PURE__*/ jsxs("div", {
|
|
16628
|
+
className: "work-document-index-entry-dialog-fields",
|
|
16629
|
+
children: [
|
|
16630
|
+
/*#__PURE__*/ jsxs("label", {
|
|
16631
|
+
htmlFor: mainEntryId,
|
|
16632
|
+
children: [
|
|
16633
|
+
/*#__PURE__*/ jsx("span", {
|
|
16634
|
+
children: "主索引项"
|
|
16635
|
+
}),
|
|
16636
|
+
/*#__PURE__*/ jsx(office_text_field_OfficeTextField, {
|
|
16637
|
+
id: mainEntryId,
|
|
16638
|
+
"data-autofocus": true,
|
|
16639
|
+
"aria-label": "主索引项",
|
|
16640
|
+
value: value.mainEntry,
|
|
16641
|
+
maxLength: 240,
|
|
16642
|
+
onChange: (event)=>update({
|
|
16643
|
+
mainEntry: event.target.value
|
|
16644
|
+
}),
|
|
16645
|
+
onKeyDown: (event)=>{
|
|
16646
|
+
if ('Enter' !== event.key || !value.mainEntry.trim()) return;
|
|
16647
|
+
event.preventDefault();
|
|
16648
|
+
onSubmit();
|
|
16649
|
+
}
|
|
16650
|
+
})
|
|
16651
|
+
]
|
|
16652
|
+
}),
|
|
16653
|
+
/*#__PURE__*/ jsxs("label", {
|
|
16654
|
+
htmlFor: subEntryId,
|
|
16655
|
+
children: [
|
|
16656
|
+
/*#__PURE__*/ jsx("span", {
|
|
16657
|
+
children: "次索引项"
|
|
16658
|
+
}),
|
|
16659
|
+
/*#__PURE__*/ jsx(office_text_field_OfficeTextField, {
|
|
16660
|
+
id: subEntryId,
|
|
16661
|
+
"aria-label": "次索引项",
|
|
16662
|
+
value: value.subEntry,
|
|
16663
|
+
maxLength: 240,
|
|
16664
|
+
placeholder: "可选",
|
|
16665
|
+
onChange: (event)=>update({
|
|
16666
|
+
subEntry: event.target.value
|
|
16667
|
+
})
|
|
16668
|
+
})
|
|
16669
|
+
]
|
|
16670
|
+
})
|
|
16671
|
+
]
|
|
16672
|
+
}),
|
|
16673
|
+
/*#__PURE__*/ jsxs("div", {
|
|
16674
|
+
className: "work-document-index-entry-dialog-mode",
|
|
16675
|
+
children: [
|
|
16676
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
16677
|
+
ariaLabel: "使用交叉引用",
|
|
16678
|
+
checked: crossReferenceEnabled,
|
|
16679
|
+
onCheckedChange: (enabled)=>update({
|
|
16680
|
+
crossReference: enabled ? value.crossReference || '参见' : '',
|
|
16681
|
+
pageBold: enabled ? false : value.pageBold,
|
|
16682
|
+
pageItalic: enabled ? false : value.pageItalic
|
|
16683
|
+
}),
|
|
16684
|
+
children: "使用交叉引用"
|
|
16685
|
+
}),
|
|
16686
|
+
crossReferenceEnabled && /*#__PURE__*/ jsxs("label", {
|
|
16687
|
+
htmlFor: crossReferenceId,
|
|
16688
|
+
children: [
|
|
16689
|
+
/*#__PURE__*/ jsx("span", {
|
|
16690
|
+
children: "引用目标"
|
|
16691
|
+
}),
|
|
16692
|
+
/*#__PURE__*/ jsx(office_text_field_OfficeTextField, {
|
|
16693
|
+
id: crossReferenceId,
|
|
16694
|
+
"aria-label": "交叉引用目标",
|
|
16695
|
+
value: value.crossReference,
|
|
16696
|
+
maxLength: 240,
|
|
16697
|
+
placeholder: "例如:Architecture",
|
|
16698
|
+
onChange: (event)=>update({
|
|
16699
|
+
crossReference: event.target.value
|
|
16700
|
+
})
|
|
16701
|
+
})
|
|
16702
|
+
]
|
|
16703
|
+
})
|
|
16704
|
+
]
|
|
16705
|
+
}),
|
|
16706
|
+
/*#__PURE__*/ jsxs("fieldset", {
|
|
16707
|
+
className: "work-document-index-entry-dialog-page-style",
|
|
16708
|
+
disabled: crossReferenceEnabled,
|
|
16709
|
+
children: [
|
|
16710
|
+
/*#__PURE__*/ jsx("legend", {
|
|
16711
|
+
children: "当前页码格式"
|
|
16712
|
+
}),
|
|
16713
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
16714
|
+
ariaLabel: "页码加粗",
|
|
16715
|
+
checked: value.pageBold,
|
|
16716
|
+
disabled: crossReferenceEnabled,
|
|
16717
|
+
onCheckedChange: (pageBold)=>update({
|
|
16718
|
+
pageBold
|
|
16719
|
+
}),
|
|
16720
|
+
children: "页码加粗"
|
|
16721
|
+
}),
|
|
16722
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
16723
|
+
ariaLabel: "页码倾斜",
|
|
16724
|
+
checked: value.pageItalic,
|
|
16725
|
+
disabled: crossReferenceEnabled,
|
|
16726
|
+
onCheckedChange: (pageItalic)=>update({
|
|
16727
|
+
pageItalic
|
|
16728
|
+
}),
|
|
16729
|
+
children: "页码倾斜"
|
|
16730
|
+
})
|
|
16731
|
+
]
|
|
16732
|
+
})
|
|
16733
|
+
]
|
|
16734
|
+
});
|
|
16735
|
+
}
|
|
16325
16736
|
function useDocumentInsertCommands({ contentRef, editor, resolveFieldContext }) {
|
|
16326
16737
|
const officeDialog = useOfficeDialog();
|
|
16327
16738
|
const [insertDialog, setInsertDialog] = useState(null);
|
|
@@ -16428,6 +16839,37 @@ function useDocumentInsertCommands({ contentRef, editor, resolveFieldContext })
|
|
|
16428
16839
|
editor,
|
|
16429
16840
|
rememberInvoker
|
|
16430
16841
|
]);
|
|
16842
|
+
const openIndexEntry = useCallback(()=>{
|
|
16843
|
+
if (!editor) return;
|
|
16844
|
+
const value = selectedDocumentIndexDraft(editor);
|
|
16845
|
+
if (!value) return void officeDialog.notice({
|
|
16846
|
+
title: '请选择索引文字',
|
|
16847
|
+
description: '请先选择要标记的正文文字,或选中一个已有索引项。'
|
|
16848
|
+
});
|
|
16849
|
+
rememberInvoker();
|
|
16850
|
+
setInsertDialog({
|
|
16851
|
+
kind: 'indexEntry',
|
|
16852
|
+
editing: Boolean(selectedDocumentIndexEntry(editor)),
|
|
16853
|
+
value
|
|
16854
|
+
});
|
|
16855
|
+
}, [
|
|
16856
|
+
editor,
|
|
16857
|
+
officeDialog,
|
|
16858
|
+
rememberInvoker
|
|
16859
|
+
]);
|
|
16860
|
+
const openIndex = useCallback(()=>{
|
|
16861
|
+
if (!editor) return;
|
|
16862
|
+
rememberInvoker();
|
|
16863
|
+
const selected = selectedDocumentIndexOptions(editor);
|
|
16864
|
+
setInsertDialog({
|
|
16865
|
+
kind: 'index',
|
|
16866
|
+
editing: Boolean(selected),
|
|
16867
|
+
options: selected ?? DEFAULT_DOCUMENT_INDEX_OPTIONS
|
|
16868
|
+
});
|
|
16869
|
+
}, [
|
|
16870
|
+
editor,
|
|
16871
|
+
rememberInvoker
|
|
16872
|
+
]);
|
|
16431
16873
|
const refreshFields = useCallback(()=>editor?.commands.refreshDocumentFields(contentRef.current, {
|
|
16432
16874
|
resolveContext: resolveFieldContext ?? void 0
|
|
16433
16875
|
}) ?? false, [
|
|
@@ -16441,6 +16883,12 @@ function useDocumentInsertCommands({ contentRef, editor, resolveFieldContext })
|
|
|
16441
16883
|
editor,
|
|
16442
16884
|
resolveFieldContext
|
|
16443
16885
|
]);
|
|
16886
|
+
const refreshIndex = useCallback(()=>editor?.commands.refreshDocumentIndexes({
|
|
16887
|
+
resolveContext: resolveFieldContext ?? void 0
|
|
16888
|
+
}) ?? false, [
|
|
16889
|
+
editor,
|
|
16890
|
+
resolveFieldContext
|
|
16891
|
+
]);
|
|
16444
16892
|
const submitCaption = ()=>{
|
|
16445
16893
|
if (!editor || insertDialog?.kind !== 'caption') return;
|
|
16446
16894
|
const inserted = editor.chain().focus().insertDocumentCaption(insertDialog.captionKind, insertDialog.title.trim()).run();
|
|
@@ -16467,6 +16915,23 @@ function useDocumentInsertCommands({ contentRef, editor, resolveFieldContext })
|
|
|
16467
16915
|
invokerRef.current = editor.view.dom;
|
|
16468
16916
|
setInsertDialog(null);
|
|
16469
16917
|
};
|
|
16918
|
+
const submitIndexEntry = ()=>{
|
|
16919
|
+
if (!editor || insertDialog?.kind !== 'indexEntry') return;
|
|
16920
|
+
const applied = insertDialog.editing ? editor.commands.updateDocumentIndexEntry(insertDialog.value) : editor.commands.markDocumentIndexEntry(insertDialog.value);
|
|
16921
|
+
if (!applied) return;
|
|
16922
|
+
invokerRef.current = editor.view.dom;
|
|
16923
|
+
setInsertDialog(null);
|
|
16924
|
+
};
|
|
16925
|
+
const submitIndex = ()=>{
|
|
16926
|
+
if (!editor || insertDialog?.kind !== 'index') return;
|
|
16927
|
+
const buildOptions = {
|
|
16928
|
+
resolveContext: resolveFieldContext ?? void 0
|
|
16929
|
+
};
|
|
16930
|
+
const applied = insertDialog.editing ? editor.commands.updateDocumentIndex(insertDialog.options, buildOptions) : editor.commands.insertDocumentIndex(insertDialog.options, buildOptions);
|
|
16931
|
+
if (!applied) return;
|
|
16932
|
+
invokerRef.current = editor.view.dom;
|
|
16933
|
+
setInsertDialog(null);
|
|
16934
|
+
};
|
|
16470
16935
|
const moveReferenceSelection = (event, currentIndex)=>{
|
|
16471
16936
|
if (insertDialog?.kind !== 'crossReference') return;
|
|
16472
16937
|
let nextIndex = currentIndex;
|
|
@@ -16608,6 +17073,28 @@ function useDocumentInsertCommands({ contentRef, editor, resolveFieldContext })
|
|
|
16608
17073
|
options
|
|
16609
17074
|
}),
|
|
16610
17075
|
onSubmit: submitTableOfContents
|
|
17076
|
+
}),
|
|
17077
|
+
insertDialog?.kind === 'indexEntry' && /*#__PURE__*/ jsx(DocumentIndexEntryDialog, {
|
|
17078
|
+
editing: insertDialog.editing,
|
|
17079
|
+
value: insertDialog.value,
|
|
17080
|
+
restoreFocusTarget: ()=>invokerRef.current,
|
|
17081
|
+
onCancel: ()=>setInsertDialog(null),
|
|
17082
|
+
onChange: (value)=>setInsertDialog({
|
|
17083
|
+
...insertDialog,
|
|
17084
|
+
value
|
|
17085
|
+
}),
|
|
17086
|
+
onSubmit: submitIndexEntry
|
|
17087
|
+
}),
|
|
17088
|
+
insertDialog?.kind === 'index' && /*#__PURE__*/ jsx(DocumentIndexDialog, {
|
|
17089
|
+
editing: insertDialog.editing,
|
|
17090
|
+
options: insertDialog.options,
|
|
17091
|
+
restoreFocusTarget: ()=>invokerRef.current,
|
|
17092
|
+
onCancel: ()=>setInsertDialog(null),
|
|
17093
|
+
onOptionsChange: (options)=>setInsertDialog({
|
|
17094
|
+
...insertDialog,
|
|
17095
|
+
options
|
|
17096
|
+
}),
|
|
17097
|
+
onSubmit: submitIndex
|
|
16611
17098
|
})
|
|
16612
17099
|
]
|
|
16613
17100
|
});
|
|
@@ -16618,8 +17105,11 @@ function useDocumentInsertCommands({ contentRef, editor, resolveFieldContext })
|
|
|
16618
17105
|
insertField,
|
|
16619
17106
|
insertImage,
|
|
16620
17107
|
insertNote,
|
|
17108
|
+
openIndexEntry,
|
|
17109
|
+
openIndex,
|
|
16621
17110
|
openTableOfContents,
|
|
16622
17111
|
refreshFields,
|
|
17112
|
+
refreshIndex,
|
|
16623
17113
|
refreshTableOfContents
|
|
16624
17114
|
};
|
|
16625
17115
|
}
|
|
@@ -18689,6 +19179,10 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
18689
19179
|
documentInsert.refreshTableOfContents();
|
|
18690
19180
|
restoreDocumentBodyFocus();
|
|
18691
19181
|
};
|
|
19182
|
+
const refreshDocumentIndex = ()=>{
|
|
19183
|
+
documentInsert.refreshIndex();
|
|
19184
|
+
restoreDocumentBodyFocus();
|
|
19185
|
+
};
|
|
18692
19186
|
const openSelectionContextMenu = (event)=>{
|
|
18693
19187
|
if (!canEditDocument || !getSelectionMenuItems && !onAgentRequest) return false;
|
|
18694
19188
|
const snapshot = createWorkDocumentSelectionSnapshot(editor, contentRef.current);
|
|
@@ -18786,11 +19280,14 @@ function DocumentEditorSurface({ artifactId, autoFocus = true, collaboration, co
|
|
|
18786
19280
|
onInsertCaption: documentInsert.insertCaption,
|
|
18787
19281
|
onInsertCrossReference: documentInsert.insertCrossReference,
|
|
18788
19282
|
onOpenTableOfContents: documentInsert.openTableOfContents,
|
|
19283
|
+
onOpenIndexEntry: documentInsert.openIndexEntry,
|
|
19284
|
+
onOpenIndex: documentInsert.openIndex,
|
|
18789
19285
|
citationsOpen: citationsOpen,
|
|
18790
19286
|
citationSourceCount: currentContent.bibliography?.sources.length ?? 0,
|
|
18791
19287
|
onToggleCitations: ()=>void toggleTaskPane('citations'),
|
|
18792
19288
|
onInsertField: documentInsert.insertField,
|
|
18793
19289
|
onRefreshFields: refreshDocumentFields,
|
|
19290
|
+
onRefreshIndex: refreshDocumentIndex,
|
|
18794
19291
|
onRefreshTableOfContents: refreshDocumentTableOfContents,
|
|
18795
19292
|
canInsertComment: documentComments.canInsert,
|
|
18796
19293
|
onInsertComment: ()=>void startCommentDraft(),
|