@a3s-lab/office 0.1.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/LICENSE +21 -0
- package/README.md +470 -0
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/dist/0~1403.js +245 -0
- package/dist/0~152.js +94 -0
- package/dist/0~3539.js +1856 -0
- package/dist/0~3557.js +179 -0
- package/dist/0~3635.js +302 -0
- package/dist/0~4595.js +1162 -0
- package/dist/0~5050.js +308 -0
- package/dist/0~6552.js +787 -0
- package/dist/0~7048.js +2110 -0
- package/dist/0~7614.js +1037 -0
- package/dist/0~8155.js +299 -0
- package/dist/0~9445.js +283 -0
- package/dist/0~9512.js +743 -0
- package/dist/0~document-editor.js +10967 -0
- package/dist/0~markdown-editor.js +2260 -0
- package/dist/0~pdf-viewer.js +2156 -0
- package/dist/0~presentation-editor.js +8359 -0
- package/dist/0~rslib-runtime.js +27 -0
- package/dist/0~spreadsheet-editor.js +10388 -0
- package/dist/0~use-office-draft.js +46 -0
- package/dist/0~work-document-extensions.js +2470 -0
- package/dist/0~work-document-links.js +14 -0
- package/dist/0~work-document-model-codec.js +42 -0
- package/dist/0~work-document-page-color.js +11 -0
- package/dist/0~work-document-paragraph-formatting.js +425 -0
- package/dist/0~work-docx-bibliography.js +347 -0
- package/dist/0~work-docx-export.js +1151 -0
- package/dist/0~work-docx-import.js +3116 -0
- package/dist/0~work-docx-page-color.js +42 -0
- package/dist/0~work-office-diagnostics.js +1377 -0
- package/dist/0~work-pptx-export.js +1009 -0
- package/dist/0~work-pptx-import.js +1138 -0
- package/dist/0~work-presentation-charts.js +442 -0
- package/dist/0~work-presentation-transition.js +38 -0
- package/dist/0~work-presentation-visual-scale.js +38 -0
- package/dist/0~work-spreadsheet-formula-support.js +9 -0
- package/dist/1134.js +445 -0
- package/dist/4104.js +5786 -0
- package/dist/432.js +211 -0
- package/dist/4704.js +1364 -0
- package/dist/6489.js +182 -0
- package/dist/8715.js +3959 -0
- package/dist/8728.js +723 -0
- package/dist/9356.js +10 -0
- package/dist/core.d.ts +15 -0
- package/dist/core.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/internal/design-system/primitives/button/button.d.ts +9 -0
- package/dist/internal/design-system/primitives/button/icon-button.d.ts +7 -0
- package/dist/internal/design-system/primitives/dialog/dialog.d.ts +12 -0
- package/dist/internal/design-system/primitives/feedback/collection-state.d.ts +9 -0
- package/dist/internal/design-system/primitives/feedback/inline-notice.d.ts +10 -0
- package/dist/internal/design-system/primitives/feedback/state-view.d.ts +13 -0
- package/dist/internal/design-system/primitives/form/field.d.ts +19 -0
- package/dist/internal/design-system/primitives/index.d.ts +14 -0
- package/dist/internal/design-system/primitives/layout/split-handle.d.ts +17 -0
- package/dist/internal/design-system/primitives/navigation/segmented-control.d.ts +19 -0
- package/dist/internal/design-system/primitives/navigation/tab-navigation.d.ts +13 -0
- package/dist/internal/design-system/primitives/navigation/tabs.d.ts +21 -0
- package/dist/internal/design-system/primitives/overlay/dialog-focus-scope.d.ts +17 -0
- package/dist/internal/design-system/primitives/overlay/popover.d.ts +34 -0
- package/dist/internal/design-system/primitives/overlay/portal-root.d.ts +1 -0
- package/dist/internal/design-system/primitives/status/status-badge.d.ts +6 -0
- package/dist/internal/features/work/components/work-document-pages.d.ts +4 -0
- package/dist/internal/features/work/components/work-editor-agent-menus.d.ts +12 -0
- package/dist/internal/features/work/components/work-editor-loading-state.d.ts +3 -0
- package/dist/internal/features/work/editors/document-changes-panel.d.ts +9 -0
- package/dist/internal/features/work/editors/document-citation-source-form.d.ts +33 -0
- package/dist/internal/features/work/editors/document-citations-panel.d.ts +8 -0
- package/dist/internal/features/work/editors/document-columns-panel.d.ts +5 -0
- package/dist/internal/features/work/editors/document-comment-composer.d.ts +13 -0
- package/dist/internal/features/work/editors/document-comments-panel.d.ts +17 -0
- package/dist/internal/features/work/editors/document-editor-focus.d.ts +1 -0
- package/dist/internal/features/work/editors/document-editor-pagination.d.ts +3 -0
- package/dist/internal/features/work/editors/document-editor-support.d.ts +34 -0
- package/dist/internal/features/work/editors/document-editor.d.ts +20 -0
- package/dist/internal/features/work/editors/document-find-highlight.d.ts +8 -0
- package/dist/internal/features/work/editors/document-find-replace-panel.d.ts +10 -0
- package/dist/internal/features/work/editors/document-formatting-options.d.ts +113 -0
- package/dist/internal/features/work/editors/document-home-ribbon.d.ts +9 -0
- package/dist/internal/features/work/editors/document-layout-panel.d.ts +10 -0
- package/dist/internal/features/work/editors/document-list-gallery.d.ts +4 -0
- package/dist/internal/features/work/editors/document-navigation-panel.d.ts +9 -0
- package/dist/internal/features/work/editors/document-page-chrome-editor.d.ts +39 -0
- package/dist/internal/features/work/editors/document-page-chrome-panel.d.ts +5 -0
- package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +10 -0
- package/dist/internal/features/work/editors/document-page-navigation.d.ts +14 -0
- package/dist/internal/features/work/editors/document-page-stack.d.ts +8 -0
- package/dist/internal/features/work/editors/document-pagination-popover.d.ts +4 -0
- package/dist/internal/features/work/editors/document-paragraph-spacing-popover.d.ts +4 -0
- package/dist/internal/features/work/editors/document-picture-ribbon.d.ts +4 -0
- package/dist/internal/features/work/editors/document-ruler-tab-stops.d.ts +12 -0
- package/dist/internal/features/work/editors/document-ruler.d.ts +15 -0
- package/dist/internal/features/work/editors/document-selection-context-menu.d.ts +22 -0
- package/dist/internal/features/work/editors/document-selection-toolbar.d.ts +8 -0
- package/dist/internal/features/work/editors/document-status-bar.d.ts +19 -0
- package/dist/internal/features/work/editors/document-style-gallery.d.ts +4 -0
- package/dist/internal/features/work/editors/document-table-insert-popover.d.ts +4 -0
- package/dist/internal/features/work/editors/document-table-ribbon.d.ts +7 -0
- package/dist/internal/features/work/editors/document-task-pane.d.ts +11 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +100 -0
- package/dist/internal/features/work/editors/document-vertical-ruler.d.ts +6 -0
- package/dist/internal/features/work/editors/markdown-editor-focus.d.ts +2 -0
- package/dist/internal/features/work/editors/markdown-editor.d.ts +16 -0
- package/dist/internal/features/work/editors/markdown-insert-dialog.d.ts +19 -0
- package/dist/internal/features/work/editors/markdown-selection-context-menu.d.ts +14 -0
- package/dist/internal/features/work/editors/markdown-source-commands.d.ts +41 -0
- package/dist/internal/features/work/editors/markdown-status.d.ts +7 -0
- package/dist/internal/features/work/editors/markdown-toolbar.d.ts +22 -0
- package/dist/internal/features/work/editors/markdown-workspace.d.ts +26 -0
- package/dist/internal/features/work/editors/office-checkbox.d.ts +9 -0
- package/dist/internal/features/work/editors/office-color-picker.d.ts +11 -0
- package/dist/internal/features/work/editors/office-controls.d.ts +7 -0
- package/dist/internal/features/work/editors/office-dialog.d.ts +35 -0
- package/dist/internal/features/work/editors/office-editor-extension.d.ts +86 -0
- package/dist/internal/features/work/editors/office-file-data.d.ts +1 -0
- package/dist/internal/features/work/editors/office-font-families.d.ts +187 -0
- package/dist/internal/features/work/editors/office-menu-keyboard.d.ts +2 -0
- package/dist/internal/features/work/editors/office-number-field.d.ts +21 -0
- package/dist/internal/features/work/editors/office-number-normalization.d.ts +9 -0
- package/dist/internal/features/work/editors/office-select.d.ts +19 -0
- package/dist/internal/features/work/editors/office-shortcuts.d.ts +1 -0
- package/dist/internal/features/work/editors/office-slider.d.ts +10 -0
- package/dist/internal/features/work/editors/office-table-dimensions.d.ts +4 -0
- package/dist/internal/features/work/editors/office-table-insert-popover.d.ts +7 -0
- package/dist/internal/features/work/editors/office-task-pane.d.ts +7 -0
- package/dist/internal/features/work/editors/office-text-field.d.ts +20 -0
- package/dist/internal/features/work/editors/office-tiptap-extensions.d.ts +2 -0
- package/dist/internal/features/work/editors/pdf-annotation-controller.d.ts +23 -0
- package/dist/internal/features/work/editors/pdf-editor-extensions.d.ts +36 -0
- package/dist/internal/features/work/editors/pdf-thumbnail-rail.d.ts +26 -0
- package/dist/internal/features/work/editors/pdf-toolbar.d.ts +23 -0
- package/dist/internal/features/work/editors/pdf-viewer-controller.d.ts +48 -0
- package/dist/internal/features/work/editors/pdf-viewer.d.ts +11 -0
- package/dist/internal/features/work/editors/presentation-arrangement-controller.d.ts +19 -0
- package/dist/internal/features/work/editors/presentation-chart-analysis-canvas.d.ts +21 -0
- package/dist/internal/features/work/editors/presentation-chart-axis-canvas.d.ts +33 -0
- package/dist/internal/features/work/editors/presentation-chart-axis-editor.d.ts +5 -0
- package/dist/internal/features/work/editors/presentation-chart-canvas.d.ts +5 -0
- package/dist/internal/features/work/editors/presentation-chart-cartesian-canvas.d.ts +3 -0
- package/dist/internal/features/work/editors/presentation-chart-data-label-editor.d.ts +6 -0
- package/dist/internal/features/work/editors/presentation-chart-data-labels.d.ts +26 -0
- package/dist/internal/features/work/editors/presentation-chart-layout-editor.d.ts +5 -0
- package/dist/internal/features/work/editors/presentation-chart-legend-canvas.d.ts +15 -0
- package/dist/internal/features/work/editors/presentation-chart-panel.d.ts +7 -0
- package/dist/internal/features/work/editors/presentation-chart-series-analysis-editor.d.ts +6 -0
- package/dist/internal/features/work/editors/presentation-chart-series-canvas.d.ts +15 -0
- package/dist/internal/features/work/editors/presentation-command-controller.d.ts +3 -0
- package/dist/internal/features/work/editors/presentation-command-types.d.ts +206 -0
- package/dist/internal/features/work/editors/presentation-comments-panel.d.ts +9 -0
- package/dist/internal/features/work/editors/presentation-context-menu.d.ts +11 -0
- package/dist/internal/features/work/editors/presentation-design-panel.d.ts +13 -0
- package/dist/internal/features/work/editors/presentation-editor-focus.d.ts +12 -0
- package/dist/internal/features/work/editors/presentation-editor-operations.d.ts +10 -0
- package/dist/internal/features/work/editors/presentation-editor-types.d.ts +22 -0
- package/dist/internal/features/work/editors/presentation-editor.d.ts +3 -0
- package/dist/internal/features/work/editors/presentation-keyboard-extension.d.ts +3 -0
- package/dist/internal/features/work/editors/presentation-player.d.ts +7 -0
- package/dist/internal/features/work/editors/presentation-presenter-view.d.ts +15 -0
- package/dist/internal/features/work/editors/presentation-selection.d.ts +21 -0
- package/dist/internal/features/work/editors/presentation-slide-canvas.d.ts +26 -0
- package/dist/internal/features/work/editors/presentation-slide-thumbnail.d.ts +18 -0
- package/dist/internal/features/work/editors/presentation-status-bar.d.ts +10 -0
- package/dist/internal/features/work/editors/presentation-text-editor.d.ts +22 -0
- package/dist/internal/features/work/editors/presentation-text-formatting.d.ts +3 -0
- package/dist/internal/features/work/editors/presentation-thumbnail-rail.d.ts +20 -0
- package/dist/internal/features/work/editors/presentation-toolbar.d.ts +19 -0
- package/dist/internal/features/work/editors/presentation-transition-panel.d.ts +9 -0
- package/dist/internal/features/work/editors/presentation-workspace.d.ts +38 -0
- package/dist/internal/features/work/editors/spreadsheet-calculation-model.d.ts +8 -0
- package/dist/internal/features/work/editors/spreadsheet-calculation-projection.d.ts +32 -0
- package/dist/internal/features/work/editors/spreadsheet-chart-axis-editor.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-chart-draft.d.ts +17 -0
- package/dist/internal/features/work/editors/spreadsheet-chart-layout-editor.d.ts +13 -0
- package/dist/internal/features/work/editors/spreadsheet-chart-panel.d.ts +10 -0
- package/dist/internal/features/work/editors/spreadsheet-chart-series-style-editor.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-clipboard-shortcuts.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +121 -0
- package/dist/internal/features/work/editors/spreadsheet-conditional-comparison-fields.d.ts +7 -0
- package/dist/internal/features/work/editors/spreadsheet-conditional-format-model.d.ts +72 -0
- package/dist/internal/features/work/editors/spreadsheet-conditional-format-panel.d.ts +7 -0
- package/dist/internal/features/work/editors/spreadsheet-conditional-threshold-fields.d.ts +10 -0
- package/dist/internal/features/work/editors/spreadsheet-context-menu.d.ts +36 -0
- package/dist/internal/features/work/editors/spreadsheet-data-label-editor.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-editor-ribbon.d.ts +46 -0
- package/dist/internal/features/work/editors/spreadsheet-editor-support.d.ts +31 -0
- package/dist/internal/features/work/editors/spreadsheet-editor.d.ts +16 -0
- package/dist/internal/features/work/editors/spreadsheet-error-bar-editor.d.ts +10 -0
- package/dist/internal/features/work/editors/spreadsheet-find-bar.d.ts +8 -0
- package/dist/internal/features/work/editors/spreadsheet-find.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-formula-panel.d.ts +10 -0
- package/dist/internal/features/work/editors/spreadsheet-header-footer-fields.d.ts +5 -0
- package/dist/internal/features/work/editors/spreadsheet-keyboard-navigation.d.ts +18 -0
- package/dist/internal/features/work/editors/spreadsheet-number-format.d.ts +11 -0
- package/dist/internal/features/work/editors/spreadsheet-pivot-panel.d.ts +10 -0
- package/dist/internal/features/work/editors/spreadsheet-print-settings-panel.d.ts +6 -0
- package/dist/internal/features/work/editors/spreadsheet-protection-panel.d.ts +7 -0
- package/dist/internal/features/work/editors/spreadsheet-sheet-bar.d.ts +17 -0
- package/dist/internal/features/work/editors/spreadsheet-sheet-model.d.ts +13 -0
- package/dist/internal/features/work/editors/spreadsheet-trendline-editor.d.ts +8 -0
- package/dist/internal/features/work/editors/spreadsheet-workbook-panel.d.ts +16 -0
- package/dist/internal/features/work/editors/use-document-comments.d.ts +26 -0
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +19 -0
- package/dist/internal/features/work/editors/use-document-layout-fonts.d.ts +2 -0
- package/dist/internal/features/work/editors/use-document-page-chrome.d.ts +33 -0
- package/dist/internal/features/work/editors/use-document-pagination.d.ts +46 -0
- package/dist/internal/features/work/editors/use-markdown-source-history.d.ts +16 -0
- package/dist/internal/features/work/editors/use-office-draft.d.ts +10 -0
- package/dist/internal/features/work/editors/use-office-editor-keyboard-shortcuts.d.ts +9 -0
- package/dist/internal/features/work/editors/use-office-editor-runtime.d.ts +6 -0
- package/dist/internal/features/work/editors/use-office-editor-wheel-zoom.d.ts +19 -0
- package/dist/internal/features/work/editors/use-office-history.d.ts +10 -0
- package/dist/internal/features/work/editors/use-presentation-clipboard.d.ts +22 -0
- package/dist/internal/features/work/editors/use-presentation-design-commands.d.ts +33 -0
- package/dist/internal/features/work/editors/use-presentation-element-commands.d.ts +29 -0
- package/dist/internal/features/work/editors/use-presentation-geometry.d.ts +17 -0
- package/dist/internal/features/work/editors/use-presentation-history.d.ts +12 -0
- package/dist/internal/features/work/editors/use-presentation-review-commands.d.ts +22 -0
- package/dist/internal/features/work/editors/use-presentation-selection.d.ts +11 -0
- package/dist/internal/features/work/editors/use-presentation-slide-commands.d.ts +18 -0
- package/dist/internal/features/work/editors/use-presentation-thumbnail-visibility.d.ts +4 -0
- package/dist/internal/features/work/editors/use-presentation-thumbnail-window.d.ts +17 -0
- package/dist/internal/features/work/editors/use-presentation-transform.d.ts +53 -0
- package/dist/internal/features/work/editors/use-spreadsheet-calculation.d.ts +17 -0
- package/dist/internal/features/work/editors/use-spreadsheet-workbook-sync.d.ts +10 -0
- package/dist/internal/features/work/editors/work-office-chrome.d.ts +61 -0
- package/dist/internal/features/work/editors/work-office-ribbon-overflow.d.ts +18 -0
- package/dist/internal/features/work/work-agent-proposal-apply.d.ts +8 -0
- package/dist/internal/features/work/work-agent-proposal.d.ts +55 -0
- package/dist/internal/features/work/work-agent-request.d.ts +6 -0
- package/dist/internal/features/work/work-chart-series-analysis-context.d.ts +3 -0
- package/dist/internal/features/work/work-document-caption-nodes.d.ts +13 -0
- package/dist/internal/features/work/work-document-captions.d.ts +14 -0
- package/dist/internal/features/work/work-document-changes.d.ts +35 -0
- package/dist/internal/features/work/work-document-character-formatting.d.ts +13 -0
- package/dist/internal/features/work/work-document-citation-nodes.d.ts +25 -0
- package/dist/internal/features/work/work-document-citations.d.ts +21 -0
- package/dist/internal/features/work/work-document-columns.d.ts +15 -0
- package/dist/internal/features/work/work-document-comments.d.ts +48 -0
- package/dist/internal/features/work/work-document-extensions.d.ts +11 -0
- package/dist/internal/features/work/work-document-field-node.d.ts +12 -0
- package/dist/internal/features/work/work-document-fields.d.ts +15 -0
- package/dist/internal/features/work/work-document-file-io.d.ts +4 -0
- package/dist/internal/features/work/work-document-fonts.d.ts +16 -0
- package/dist/internal/features/work/work-document-image-layout.d.ts +29 -0
- package/dist/internal/features/work/work-document-incremental-layout.d.ts +17 -0
- package/dist/internal/features/work/work-document-layout.d.ts +5 -0
- package/dist/internal/features/work/work-document-line-measurement.d.ts +24 -0
- package/dist/internal/features/work/work-document-links.d.ts +2 -0
- package/dist/internal/features/work/work-document-lists.d.ts +25 -0
- package/dist/internal/features/work/work-document-model-codec.d.ts +3 -0
- package/dist/internal/features/work/work-document-model.d.ts +12 -0
- package/dist/internal/features/work/work-document-note-nodes.d.ts +11 -0
- package/dist/internal/features/work/work-document-notes.d.ts +18 -0
- package/dist/internal/features/work/work-document-outline.d.ts +14 -0
- package/dist/internal/features/work/work-document-page-break.d.ts +2 -0
- package/dist/internal/features/work/work-document-page-chrome-commands.d.ts +15 -0
- package/dist/internal/features/work/work-document-page-chrome.d.ts +19 -0
- package/dist/internal/features/work/work-document-page-color.d.ts +3 -0
- package/dist/internal/features/work/work-document-pages.d.ts +19 -0
- package/dist/internal/features/work/work-document-pagination-decorations.d.ts +3 -0
- package/dist/internal/features/work/work-document-pagination-dom.d.ts +35 -0
- package/dist/internal/features/work/work-document-pagination-measurement.d.ts +9 -0
- package/dist/internal/features/work/work-document-pagination-types.d.ts +88 -0
- package/dist/internal/features/work/work-document-pagination.d.ts +17 -0
- package/dist/internal/features/work/work-document-paragraph-formatting.d.ts +61 -0
- package/dist/internal/features/work/work-document-search.d.ts +11 -0
- package/dist/internal/features/work/work-document-section-editor.d.ts +20 -0
- package/dist/internal/features/work/work-document-section-node.d.ts +13 -0
- package/dist/internal/features/work/work-document-section.d.ts +34 -0
- package/dist/internal/features/work/work-document-selection-menu.d.ts +54 -0
- package/dist/internal/features/work/work-document-tab-node.d.ts +6 -0
- package/dist/internal/features/work/work-document-tab-stops.d.ts +29 -0
- package/dist/internal/features/work/work-document-table-cell-formatting.d.ts +46 -0
- package/dist/internal/features/work/work-document-table-commands.d.ts +17 -0
- package/dist/internal/features/work/work-document-table-pagination.d.ts +5 -0
- package/dist/internal/features/work/work-document-table-row.d.ts +37 -0
- package/dist/internal/features/work/work-document-table-sizing.d.ts +27 -0
- package/dist/internal/features/work/work-document-text-layout.d.ts +14 -0
- package/dist/internal/features/work/work-docx-bibliography.d.ts +12 -0
- package/dist/internal/features/work/work-docx-caption-diagnostics.d.ts +6 -0
- package/dist/internal/features/work/work-docx-caption-export.d.ts +4 -0
- package/dist/internal/features/work/work-docx-caption-fields.d.ts +5 -0
- package/dist/internal/features/work/work-docx-caption-import.d.ts +20 -0
- package/dist/internal/features/work/work-docx-change-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-citation-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-citation-export.d.ts +3 -0
- package/dist/internal/features/work/work-docx-citation-import.d.ts +23 -0
- package/dist/internal/features/work/work-docx-column-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-column-import.d.ts +2 -0
- package/dist/internal/features/work/work-docx-comment-import.d.ts +14 -0
- package/dist/internal/features/work/work-docx-export-formatting.d.ts +30 -0
- package/dist/internal/features/work/work-docx-export-image.d.ts +2 -0
- package/dist/internal/features/work/work-docx-export.d.ts +2 -0
- package/dist/internal/features/work/work-docx-field-export.d.ts +2 -0
- package/dist/internal/features/work/work-docx-field-import.d.ts +16 -0
- package/dist/internal/features/work/work-docx-field-instructions.d.ts +8 -0
- package/dist/internal/features/work/work-docx-image-layout-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-import.d.ts +50 -0
- package/dist/internal/features/work/work-docx-list-import.d.ts +14 -0
- package/dist/internal/features/work/work-docx-note-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-note-import.d.ts +3 -0
- package/dist/internal/features/work/work-docx-page-chrome-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-page-chrome-import.d.ts +11 -0
- package/dist/internal/features/work/work-docx-page-color.d.ts +2 -0
- package/dist/internal/features/work/work-docx-paragraph-alignment-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-paragraph-direction-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-paragraph-indent-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-paragraph-pagination-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-paragraph-spacing-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-paragraph-styles.d.ts +18 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +19 -0
- package/dist/internal/features/work/work-docx-tab-stop-import.d.ts +13 -0
- package/dist/internal/features/work/work-docx-table-cell-export.d.ts +4 -0
- package/dist/internal/features/work/work-docx-table-cell-import.d.ts +16 -0
- package/dist/internal/features/work/work-docx-table-row-import.d.ts +13 -0
- package/dist/internal/features/work/work-docx-table-sizing-export.d.ts +8 -0
- package/dist/internal/features/work/work-docx-table-sizing-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-theme.d.ts +9 -0
- package/dist/internal/features/work/work-file-data.d.ts +1 -0
- package/dist/internal/features/work/work-file-download.d.ts +3 -0
- package/dist/internal/features/work/work-file-io.d.ts +8 -0
- package/dist/internal/features/work/work-markdown-extensions.d.ts +19 -0
- package/dist/internal/features/work/work-markdown-file-io.d.ts +3 -0
- package/dist/internal/features/work/work-markdown-selection-menu.d.ts +57 -0
- package/dist/internal/features/work/work-office-diagnostics.d.ts +9 -0
- package/dist/internal/features/work/work-ooxml-package.d.ts +28 -0
- package/dist/internal/features/work/work-pdf-export.d.ts +23 -0
- package/dist/internal/features/work/work-pptx-chart-axes.d.ts +3 -0
- package/dist/internal/features/work/work-pptx-chart-axis-diagnostics.d.ts +5 -0
- package/dist/internal/features/work/work-pptx-chart-data-labels.d.ts +12 -0
- package/dist/internal/features/work/work-pptx-chart-import.d.ts +11 -0
- package/dist/internal/features/work/work-pptx-chart-layout-style.d.ts +15 -0
- package/dist/internal/features/work/work-pptx-chart-series-analysis.d.ts +13 -0
- package/dist/internal/features/work/work-pptx-chart-xy.d.ts +3 -0
- package/dist/internal/features/work/work-pptx-comments.d.ts +17 -0
- package/dist/internal/features/work/work-pptx-export.d.ts +4 -0
- package/dist/internal/features/work/work-pptx-groups.d.ts +19 -0
- package/dist/internal/features/work/work-pptx-import.d.ts +6 -0
- package/dist/internal/features/work/work-pptx-layout-export.d.ts +13 -0
- package/dist/internal/features/work/work-pptx-layout-import.d.ts +30 -0
- package/dist/internal/features/work/work-pptx-style.d.ts +13 -0
- package/dist/internal/features/work/work-pptx-transition.d.ts +13 -0
- package/dist/internal/features/work/work-presentation-agent-context.d.ts +6 -0
- package/dist/internal/features/work/work-presentation-chart-axes.d.ts +14 -0
- package/dist/internal/features/work/work-presentation-charts.d.ts +37 -0
- package/dist/internal/features/work/work-presentation-clipboard.d.ts +26 -0
- package/dist/internal/features/work/work-presentation-file-io.d.ts +15 -0
- package/dist/internal/features/work/work-presentation-groups.d.ts +17 -0
- package/dist/internal/features/work/work-presentation-layouts.d.ts +13 -0
- package/dist/internal/features/work/work-presentation-transition.d.ts +4 -0
- package/dist/internal/features/work/work-presentation-visual-scale.d.ts +2 -0
- package/dist/internal/features/work/work-repository.d.ts +4 -0
- package/dist/internal/features/work/work-spreadsheet-agent-context.d.ts +15 -0
- package/dist/internal/features/work/work-spreadsheet-chart-axis.d.ts +42 -0
- package/dist/internal/features/work/work-spreadsheet-chart-layout.d.ts +29 -0
- package/dist/internal/features/work/work-spreadsheet-chart-legend-svg.d.ts +18 -0
- package/dist/internal/features/work/work-spreadsheet-chart-series-layout.d.ts +24 -0
- package/dist/internal/features/work/work-spreadsheet-chart-series-style.d.ts +29 -0
- package/dist/internal/features/work/work-spreadsheet-chart-svg-utils.d.ts +7 -0
- package/dist/internal/features/work/work-spreadsheet-chart-svg.d.ts +3 -0
- package/dist/internal/features/work/work-spreadsheet-chart-types.d.ts +147 -0
- package/dist/internal/features/work/work-spreadsheet-chart-validation.d.ts +2 -0
- package/dist/internal/features/work/work-spreadsheet-charts.d.ts +17 -0
- package/dist/internal/features/work/work-spreadsheet-combination-chart-svg.d.ts +9 -0
- package/dist/internal/features/work/work-spreadsheet-comments.d.ts +7 -0
- package/dist/internal/features/work/work-spreadsheet-conditional-canvas.d.ts +5 -0
- package/dist/internal/features/work/work-spreadsheet-conditional-colors.d.ts +9 -0
- package/dist/internal/features/work/work-spreadsheet-conditional-comparisons.d.ts +4 -0
- package/dist/internal/features/work/work-spreadsheet-conditional-data-bar.d.ts +8 -0
- package/dist/internal/features/work/work-spreadsheet-conditional-format.d.ts +10 -0
- package/dist/internal/features/work/work-spreadsheet-conditional-icons.d.ts +107 -0
- package/dist/internal/features/work/work-spreadsheet-conditional-values.d.ts +19 -0
- package/dist/internal/features/work/work-spreadsheet-data-label-svg.d.ts +27 -0
- package/dist/internal/features/work/work-spreadsheet-error-bar-svg.d.ts +5 -0
- package/dist/internal/features/work/work-spreadsheet-error-bars.d.ts +8 -0
- package/dist/internal/features/work/work-spreadsheet-formula-analysis.d.ts +30 -0
- package/dist/internal/features/work/work-spreadsheet-formula-support.d.ts +1 -0
- package/dist/internal/features/work/work-spreadsheet-formulas.d.ts +19 -0
- package/dist/internal/features/work/work-spreadsheet-header-footer.d.ts +14 -0
- package/dist/internal/features/work/work-spreadsheet-line-chart-svg.d.ts +10 -0
- package/dist/internal/features/work/work-spreadsheet-page-breaks.d.ts +4 -0
- package/dist/internal/features/work/work-spreadsheet-page-setup.d.ts +26 -0
- package/dist/internal/features/work/work-spreadsheet-pivot-engine.d.ts +21 -0
- package/dist/internal/features/work/work-spreadsheet-pivot-values.d.ts +7 -0
- package/dist/internal/features/work/work-spreadsheet-pivots.d.ts +27 -0
- package/dist/internal/features/work/work-spreadsheet-protection.d.ts +55 -0
- package/dist/internal/features/work/work-spreadsheet-ranges.d.ts +25 -0
- package/dist/internal/features/work/work-spreadsheet-trendline-svg.d.ts +9 -0
- package/dist/internal/features/work/work-spreadsheet-trendlines.d.ts +11 -0
- package/dist/internal/features/work/work-spreadsheet-xy-chart-axes-svg.d.ts +10 -0
- package/dist/internal/features/work/work-templates.d.ts +4 -0
- package/dist/internal/features/work/work-types.d.ts +513 -0
- package/dist/internal/features/work/work-xlsx-chart-axes.d.ts +4 -0
- package/dist/internal/features/work/work-xlsx-chart-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-xlsx-chart-layout.d.ts +16 -0
- package/dist/internal/features/work/work-xlsx-chart-series-style.d.ts +6 -0
- package/dist/internal/features/work/work-xlsx-chart-values.d.ts +10 -0
- package/dist/internal/features/work/work-xlsx-charts.d.ts +32 -0
- package/dist/internal/features/work/work-xlsx-conditional-format-diagnostics.d.ts +6 -0
- package/dist/internal/features/work/work-xlsx-conditional-format-write.d.ts +11 -0
- package/dist/internal/features/work/work-xlsx-conditional-format.d.ts +29 -0
- package/dist/internal/features/work/work-xlsx-defined-names.d.ts +4 -0
- package/dist/internal/features/work/work-xlsx-drawing-geometry.d.ts +27 -0
- package/dist/internal/features/work/work-xlsx-formula-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-xlsx-formulas.d.ts +40 -0
- package/dist/internal/features/work/work-xlsx-header-footer.d.ts +12 -0
- package/dist/internal/features/work/work-xlsx-images.d.ts +17 -0
- package/dist/internal/features/work/work-xlsx-interop.d.ts +39 -0
- package/dist/internal/features/work/work-xlsx-page-breaks.d.ts +7 -0
- package/dist/internal/features/work/work-xlsx-page-setup-diagnostics.d.ts +2 -0
- package/dist/internal/features/work/work-xlsx-page-setup.d.ts +5 -0
- package/dist/internal/features/work/work-xlsx-pivot-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-xlsx-pivot-xml.d.ts +9 -0
- package/dist/internal/features/work/work-xlsx-pivots.d.ts +32 -0
- package/dist/internal/features/work/work-xlsx-protection.d.ts +24 -0
- package/dist/internal/features/workspace/components/workspace-context-menu.d.ts +29 -0
- package/dist/internal/features/workspace/components/workspace-text-control-selection.d.ts +7 -0
- package/dist/internal/kernel/office-kernel-client-types.d.ts +40 -0
- package/dist/internal/kernel/office-kernel-client.d.ts +4 -0
- package/dist/internal/kernel/office-kernel-fallback.d.ts +2 -0
- package/dist/internal/kernel/office-kernel-presentation-fallback.d.ts +2 -0
- package/dist/internal/kernel/office-kernel-protocol.d.ts +229 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-fallback-formula.d.ts +3 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-fallback-validation.d.ts +5 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-fallback-value.d.ts +6 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-fallback.d.ts +2 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-protocol.d.ts +112 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-session-fallback.d.ts +8 -0
- package/dist/internal/kernel/office-kernel-text-fallback.d.ts +10 -0
- package/dist/internal/kernel/office-kernel-version.d.ts +1 -0
- package/dist/internal/kernel/office-kernel.worker.d.ts +1 -0
- package/dist/internal/keyboard-shortcuts.d.ts +2 -0
- package/dist/internal/state/app-state.d.ts +8 -0
- package/dist/noto-naskh-arabic-regular.ttf +0 -0
- package/dist/noto-naskh-arabic.LICENSE.txt +94 -0
- package/dist/noto-sans-hans-regular.otf +0 -0
- package/dist/noto-sans-hans.LICENSE.txt +94 -0
- package/dist/noto-sans-hebrew-regular.ttf +0 -0
- package/dist/noto-sans-hebrew.LICENSE.txt +94 -0
- package/dist/noto-sans-regular.ttf +0 -0
- package/dist/noto-sans.LICENSE.txt +94 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/office-kernel.worker.js +14605 -0
- package/dist/office-surface.d.ts +10 -0
- package/dist/pdfium.LICENSE.txt +196 -0
- package/dist/pdfium.wasm +0 -0
- package/dist/pptxgen.LICENSE.txt +21 -0
- package/dist/pptxgen.bundle.js +11244 -0
- package/dist/react.d.ts +51 -0
- package/dist/react.js +1 -0
- package/dist/styles.css +17435 -0
- package/dist/styles.js +0 -0
- package/dist/vue.d.ts +282 -0
- package/dist/vue.js +231 -0
- package/dist/web-component.d.ts +98 -0
- package/dist/web-component.js +335 -0
- package/docs/browser-editor-architecture.md +947 -0
- package/package.json +165 -0
package/dist/0~3539.js
ADDED
|
@@ -0,0 +1,1856 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BarChart3, Copy, FileText, ListChecks, MessageSquareText, Plus, Sparkles, Trash2, WandSparkles } from "lucide-react";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { showToast, createAgentProposalRequest as createWorkAgentProposalRequest } from "./6489.js";
|
|
5
|
+
import { effectiveSpreadsheetCalculationSettings, workSpreadsheetCombinationSeriesTypeLabel, workSpreadsheetChartSupportsGrouping, spreadsheetPivotIntersects, workSpreadsheetErrorBarValueTypeLabel, workSpreadsheetChartAxisTickMarkLabel, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetFormulaRangesForSelection, normalizeWorkSpreadsheetChartSeriesStyle, workSpreadsheetErrorBarTypeLabel, workSpreadsheetChartAxisPositionLabel, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetChartLegendOverlay, workSpreadsheetChartSupportsTrendlines, normalizeWorkSpreadsheetChartGapWidth, workSpreadsheetChartSupportsBarSpacing, normalizeWorkSpreadsheetChartGrouping, workSpreadsheetChartSupportsSmoothLines, parseSpreadsheetChartReference, workSpreadsheetChartSupportsErrorBars, workSpreadsheetChartLegendPositionLabel, workSpreadsheetChartAxisLabelPositionLabel, normalizeWorkSpreadsheetChartAxisGroup, workSpreadsheetChartAxisDefaultLabelPosition, workSpreadsheetChartGroupingLabel, workSpreadsheetDataLabelPositionLabel, workSpreadsheetChartSupportsSeriesAnalysis, defaultWorkSpreadsheetChartSeriesStyle, spreadsheetPivotAggregationLabel, resolveSpreadsheetChart, spreadsheetPivotFields, parseSpreadsheetCellRanges, normalizeWorkSpreadsheetChartAxes, normalizeWorkSpreadsheetChartOverlap, workSpreadsheetChartUsesNumericXAxis, normalizeWorkSpreadsheetChartLegendPosition, workSpreadsheetChartTypeLabel, workSpreadsheetTrendlineTypeLabel, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetCombinationSeriesType, spreadsheetChartSeriesStyleContext, normalizeWorkSpreadsheetDataLabels } from "./8715.js";
|
|
6
|
+
import { presentationChartLegendPositionLabel, presentationChartShowsLegend, normalizePresentationChartLegendPosition, presentationChartUsesNumericXAxis, normalizePresentationBubbleSizeRepresents, normalizePresentationBubbleScale, presentationChartAxes, normalizePresentationChartDataLabels, presentationChartTypeLabel, presentationChartDataLabelPositionLabel, normalizePresentationScatterStyle } from "./0~work-presentation-charts.js";
|
|
7
|
+
import { OfficeCheckbox, CommittedOfficeNumberField, CollectionState } from "./0~7048.js";
|
|
8
|
+
import { OfficeColorPicker } from "./0~3635.js";
|
|
9
|
+
import { OfficeSelect } from "./0~4595.js";
|
|
10
|
+
import { office_text_field_OfficeTextField, CommittedOfficeTextField } from "./0~9512.js";
|
|
11
|
+
function spreadsheetAgentMenuItems(selection, onAgentRequest, applyProposal) {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
id: 'ask',
|
|
15
|
+
label: '询问 AI 助手',
|
|
16
|
+
icon: /*#__PURE__*/ jsx(MessageSquareText, {
|
|
17
|
+
size: 14
|
|
18
|
+
}),
|
|
19
|
+
onSelect: ()=>void onAgentRequest({
|
|
20
|
+
instruction: '请围绕这个表格选区回答我的问题:\n\n问题:',
|
|
21
|
+
selection: selection.context
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'analyze',
|
|
26
|
+
label: '分析数据与异常',
|
|
27
|
+
icon: /*#__PURE__*/ jsx(ListChecks, {
|
|
28
|
+
size: 14
|
|
29
|
+
}),
|
|
30
|
+
onSelect: ()=>void onAgentRequest({
|
|
31
|
+
instruction: '请分析这个表格选区,概括关键趋势、异常值、缺失值和可能的数据质量问题。明确区分事实、推断与需要补充的信息。',
|
|
32
|
+
selection: selection.context
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'formula',
|
|
37
|
+
label: '解释公式与错误',
|
|
38
|
+
icon: /*#__PURE__*/ jsx(FileText, {
|
|
39
|
+
size: 14
|
|
40
|
+
}),
|
|
41
|
+
onSelect: ()=>void onAgentRequest({
|
|
42
|
+
instruction: '请检查这个表格选区中的公式和值,解释计算逻辑并指出潜在错误、循环引用或不一致。只提供诊断,不要直接修改工作簿。',
|
|
43
|
+
selection: selection.context
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'chart',
|
|
48
|
+
label: '建议图表与数据叙事',
|
|
49
|
+
icon: /*#__PURE__*/ jsx(BarChart3, {
|
|
50
|
+
size: 14
|
|
51
|
+
}),
|
|
52
|
+
onSelect: ()=>void onAgentRequest({
|
|
53
|
+
instruction: '请根据这个表格选区建议最合适的图表类型、分类范围、数据系列、标题和需要突出表达的结论。可在柱形图、条形图、折线图、饼图、圆环图、面积图和雷达图中选择,并解释选择理由;先提供可审阅方案,不要直接修改工作簿。',
|
|
54
|
+
selection: selection.context
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'propose',
|
|
59
|
+
label: '建议公式或整理方案',
|
|
60
|
+
icon: /*#__PURE__*/ jsx(WandSparkles, {
|
|
61
|
+
size: 14
|
|
62
|
+
}),
|
|
63
|
+
onSelect: ()=>void onAgentRequest({
|
|
64
|
+
instruction: '请为这个表格选区提出公式、格式或数据整理建议。用 Markdown 表格列出“单元格或范围 / 当前内容 / 建议内容 / 理由”,形成可审阅的差异清单;不要直接修改工作簿。',
|
|
65
|
+
selection: selection.context,
|
|
66
|
+
...applyProposal && selection.proposalTargets.length ? {
|
|
67
|
+
proposal: createWorkAgentProposalRequest({
|
|
68
|
+
title: '审阅表格修改',
|
|
69
|
+
description: `${selection.sheetName}!${selection.reference} · ${selection.proposalTargets.length} 个可修改单元格`,
|
|
70
|
+
targets: selection.proposalTargets,
|
|
71
|
+
apply: applyProposal
|
|
72
|
+
})
|
|
73
|
+
} : {}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
function presentationAgentMenuItems(selection, target, onAgentRequest, proposalOptions) {
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
id: 'copy',
|
|
82
|
+
label: 'element' === target ? '复制元素内容摘要' : '复制幻灯片内容摘要',
|
|
83
|
+
icon: /*#__PURE__*/ jsx(Copy, {
|
|
84
|
+
size: 14
|
|
85
|
+
}),
|
|
86
|
+
onSelect: ()=>void copyEditorSelection(selection, '演示内容摘要已复制')
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'ask',
|
|
90
|
+
label: '询问 AI 助手',
|
|
91
|
+
icon: /*#__PURE__*/ jsx(MessageSquareText, {
|
|
92
|
+
size: 14
|
|
93
|
+
}),
|
|
94
|
+
separatorBefore: true,
|
|
95
|
+
onSelect: ()=>void onAgentRequest({
|
|
96
|
+
instruction: `请围绕这${'element' === target ? '个选中元素' : '张幻灯片'}回答我的问题:\n\n问题:`,
|
|
97
|
+
selection
|
|
98
|
+
})
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'summarize',
|
|
102
|
+
label: 'element' === target ? '总结元素信息' : '总结这张幻灯片',
|
|
103
|
+
icon: /*#__PURE__*/ jsx(FileText, {
|
|
104
|
+
size: 14
|
|
105
|
+
}),
|
|
106
|
+
onSelect: ()=>void onAgentRequest({
|
|
107
|
+
instruction: `请总结这${'element' === target ? '个演示元素' : '张幻灯片'}传达的核心信息、关键证据和行动项。`,
|
|
108
|
+
selection
|
|
109
|
+
})
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'rewrite',
|
|
113
|
+
label: '改进文案与叙事',
|
|
114
|
+
icon: /*#__PURE__*/ jsx(Sparkles, {
|
|
115
|
+
size: 14
|
|
116
|
+
}),
|
|
117
|
+
onSelect: ()=>void onAgentRequest({
|
|
118
|
+
instruction: '请改进选中演示内容的文案、信息层级与叙事节奏。用“原内容 / 建议内容 / 理由”给出可审阅的差异清单;不要直接修改演示文稿。',
|
|
119
|
+
selection,
|
|
120
|
+
...proposalOptions?.rewriteTargets.length ? {
|
|
121
|
+
proposal: createWorkAgentProposalRequest({
|
|
122
|
+
title: '审阅演示文案修改',
|
|
123
|
+
description: 'element' === target ? `${proposalOptions.rewriteTargets.length} 个元素内容目标` : `${proposalOptions.rewriteTargets.length} 个幻灯片内容目标`,
|
|
124
|
+
targets: proposalOptions.rewriteTargets,
|
|
125
|
+
apply: proposalOptions.apply
|
|
126
|
+
})
|
|
127
|
+
} : {}
|
|
128
|
+
})
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'design',
|
|
132
|
+
label: '建议版式与视觉层级',
|
|
133
|
+
icon: /*#__PURE__*/ jsx(WandSparkles, {
|
|
134
|
+
size: 14
|
|
135
|
+
}),
|
|
136
|
+
onSelect: ()=>void onAgentRequest({
|
|
137
|
+
instruction: '请检查选中演示内容的版式、对齐、密度、颜色和视觉层级,给出具体可执行的设计建议。先提供方案,不要直接移动、删除或改写元素。',
|
|
138
|
+
selection
|
|
139
|
+
})
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: 'notes',
|
|
143
|
+
label: '起草演讲者备注',
|
|
144
|
+
icon: /*#__PURE__*/ jsx(FileText, {
|
|
145
|
+
size: 14
|
|
146
|
+
}),
|
|
147
|
+
onSelect: ()=>void onAgentRequest({
|
|
148
|
+
instruction: '请根据选中的演示内容起草简洁自然的演讲者备注,补足过渡语、需要强调的证据和可能被问到的问题。只提供草稿,不要直接修改备注。',
|
|
149
|
+
selection,
|
|
150
|
+
...proposalOptions ? {
|
|
151
|
+
proposal: createWorkAgentProposalRequest({
|
|
152
|
+
title: '审阅演讲者备注',
|
|
153
|
+
description: proposalOptions.notesTarget.label,
|
|
154
|
+
targets: [
|
|
155
|
+
proposalOptions.notesTarget
|
|
156
|
+
],
|
|
157
|
+
apply: proposalOptions.apply
|
|
158
|
+
})
|
|
159
|
+
} : {}
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
async function copyEditorSelection(value, successMessage) {
|
|
165
|
+
try {
|
|
166
|
+
if (!navigator.clipboard?.writeText) throw new Error('Clipboard API is unavailable');
|
|
167
|
+
await navigator.clipboard.writeText(value);
|
|
168
|
+
showToast(successMessage, 'success');
|
|
169
|
+
} catch {
|
|
170
|
+
showToast('无法访问剪贴板,请使用系统复制快捷键。', 'error');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function chartSeriesTrendlineContext(series) {
|
|
174
|
+
if (!series.trendlines?.length) return '';
|
|
175
|
+
const descriptions = series.trendlines.map((source)=>{
|
|
176
|
+
const trendline = normalizeWorkSpreadsheetTrendline(source);
|
|
177
|
+
return [
|
|
178
|
+
`${workSpreadsheetTrendlineTypeLabel(trendline.type)}${trendline.name ? `“${trendline.name}”` : ''}`,
|
|
179
|
+
'polynomial' === trendline.type ? `${trendline.order} 阶` : '',
|
|
180
|
+
'movingAverage' === trendline.type ? `${trendline.period} 期` : '',
|
|
181
|
+
trendline.forward ? `前推 ${trendline.forward}` : '',
|
|
182
|
+
trendline.backward ? `后推 ${trendline.backward}` : '',
|
|
183
|
+
void 0 !== trendline.intercept ? `截距 ${trendline.intercept}` : '',
|
|
184
|
+
trendline.displayEquation ? '显示公式' : '',
|
|
185
|
+
trendline.displayRSquared ? '显示 R 方' : ''
|
|
186
|
+
].filter(Boolean).join(',');
|
|
187
|
+
});
|
|
188
|
+
return `;趋势线:${descriptions.join(';')}`;
|
|
189
|
+
}
|
|
190
|
+
function chartSeriesErrorBarContext(series, chartType) {
|
|
191
|
+
if (!series.errorBars?.length) return '';
|
|
192
|
+
const descriptions = series.errorBars.map((source)=>{
|
|
193
|
+
const errorBars = normalizeWorkSpreadsheetErrorBars(source, chartType);
|
|
194
|
+
const amount = 'percentage' === errorBars.valueType ? `${errorBars.value}%` : 'fixedValue' === errorBars.valueType ? String(errorBars.value) : 'standardDeviation' === errorBars.valueType ? `${errorBars.value} 倍` : '';
|
|
195
|
+
const custom = 'custom' === errorBars.valueType ? [
|
|
196
|
+
customErrorAmount('正误差', errorBars.plusReference, errorBars.plusValues),
|
|
197
|
+
customErrorAmount('负误差', errorBars.minusReference, errorBars.minusValues)
|
|
198
|
+
].filter(Boolean).join(',') : '';
|
|
199
|
+
return [
|
|
200
|
+
errorBars.direction.toUpperCase(),
|
|
201
|
+
`${workSpreadsheetErrorBarTypeLabel(errorBars.barType)}${workSpreadsheetErrorBarValueTypeLabel(errorBars.valueType)}`,
|
|
202
|
+
amount,
|
|
203
|
+
custom,
|
|
204
|
+
false === errorBars.showEndCaps ? '无端帽' : ''
|
|
205
|
+
].filter(Boolean).join(' ');
|
|
206
|
+
});
|
|
207
|
+
return `;误差线:${descriptions.join(';')}`;
|
|
208
|
+
}
|
|
209
|
+
function customErrorAmount(label, reference, values) {
|
|
210
|
+
if (reference) return `${label} ${reference}`;
|
|
211
|
+
return values?.length ? `${label} ${values.join('、')}` : '';
|
|
212
|
+
}
|
|
213
|
+
function presentationAgentSelection(slide, slideIndex, slideCount, element) {
|
|
214
|
+
const heading = [
|
|
215
|
+
`幻灯片 ${slideIndex + 1} / ${slideCount}`,
|
|
216
|
+
`名称:${slide.name}`,
|
|
217
|
+
`背景:${slide.background}`
|
|
218
|
+
];
|
|
219
|
+
if (element) return [
|
|
220
|
+
...heading,
|
|
221
|
+
'',
|
|
222
|
+
`当前选择:${slideElementLabel(element)}`,
|
|
223
|
+
`位置:x ${formatPercent(element.x)},y ${formatPercent(element.y)},宽 ${formatPercent(element.width)},高 ${formatPercent(element.height)}`,
|
|
224
|
+
...slideElementDetails(element),
|
|
225
|
+
...slide.notes?.trim() ? [
|
|
226
|
+
'',
|
|
227
|
+
`演讲者备注:${slide.notes.trim()}`
|
|
228
|
+
] : []
|
|
229
|
+
].join('\n');
|
|
230
|
+
const elements = slide.elements.flatMap((candidate, index)=>[
|
|
231
|
+
`元素 ${index + 1}(${slideElementLabel(candidate)})`,
|
|
232
|
+
...slideElementDetails(candidate).map((line)=>` ${line}`)
|
|
233
|
+
]);
|
|
234
|
+
return [
|
|
235
|
+
...heading,
|
|
236
|
+
'',
|
|
237
|
+
'整页内容:',
|
|
238
|
+
...elements.length ? elements : [
|
|
239
|
+
'(空白幻灯片)'
|
|
240
|
+
],
|
|
241
|
+
...slide.notes?.trim() ? [
|
|
242
|
+
'',
|
|
243
|
+
`演讲者备注:${slide.notes.trim()}`
|
|
244
|
+
] : []
|
|
245
|
+
].join('\n');
|
|
246
|
+
}
|
|
247
|
+
function presentationAgentProposalTargets(slide, element) {
|
|
248
|
+
const candidates = element ? [
|
|
249
|
+
element
|
|
250
|
+
] : slide.elements;
|
|
251
|
+
return candidates.flatMap((candidate, elementIndex)=>{
|
|
252
|
+
const label = element ? slideElementLabel(candidate) : `元素 ${elementIndex + 1} · ${slideElementLabel(candidate)}`;
|
|
253
|
+
if (candidate.table) return candidate.table.rows.flatMap((row, rowIndex)=>row.map((cell, columnIndex)=>({
|
|
254
|
+
id: `table:${candidate.id}:${rowIndex}:${columnIndex}`,
|
|
255
|
+
label: `${label} · 单元格 ${rowIndex + 1},${columnIndex + 1}`,
|
|
256
|
+
before: cell
|
|
257
|
+
})));
|
|
258
|
+
const text = presentationElementText(candidate);
|
|
259
|
+
return text ? [
|
|
260
|
+
{
|
|
261
|
+
id: `text:${candidate.id}`,
|
|
262
|
+
label,
|
|
263
|
+
before: text
|
|
264
|
+
}
|
|
265
|
+
] : [];
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
function presentationNotesProposalTarget(slide) {
|
|
269
|
+
return {
|
|
270
|
+
id: 'notes',
|
|
271
|
+
label: `${slide.name} · 演讲者备注`,
|
|
272
|
+
before: slide.notes ?? ''
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function presentationElementText(element) {
|
|
276
|
+
return element.textRuns?.map((run)=>run.text).join('') || element.text;
|
|
277
|
+
}
|
|
278
|
+
function slideElementDetails(element) {
|
|
279
|
+
const lines = [];
|
|
280
|
+
const text = presentationElementText(element);
|
|
281
|
+
if (text.trim()) lines.push(`文本:${text.trim()}`);
|
|
282
|
+
if (element.table?.rows.length) lines.push('表格:', ...element.table.rows.map((row)=>row.map(normalizeValue).join('\t')));
|
|
283
|
+
if (element.chart) lines.push(`图表:${element.chart.title || '无标题'}(${presentationChartTypeLabel(element.chart.type)})`, `${presentationChartUsesNumericXAxis(element.chart.type) ? 'X 值' : '分类'}:${element.chart.categories.map(normalizeValue).join(',')}`, ...presentationChartSeriesLines(element.chart), `图例:${presentationChartShowsLegend(element.chart) ? `显示(${presentationChartLegendPositionLabel(normalizePresentationChartLegendPosition(element.chart.legendPosition))})${element.chart.legendOverlay ? ';叠加绘图区' : ''}` : '隐藏'}`, ...presentationChartPlotLayoutLines(element.chart), ...presentationChartAxisLines(element.chart), ...presentationChartDataLabelLines(element.chart), ...'doughnut' === element.chart.type ? [
|
|
284
|
+
`圆环孔径:${element.chart.doughnutHoleSize ?? 50}%`
|
|
285
|
+
] : [], ...'radar' === element.chart.type ? [
|
|
286
|
+
`雷达样式:${radarStyleLabel(element.chart.radarStyle)}`
|
|
287
|
+
] : [], ...'scatter' === element.chart.type ? [
|
|
288
|
+
`散点样式:${scatterStyleLabel(element.chart.scatterStyle)}`
|
|
289
|
+
] : [], ...'bubble' === element.chart.type ? [
|
|
290
|
+
presentationBubbleSettingsLine(element.chart)
|
|
291
|
+
] : []);
|
|
292
|
+
if (element.image) lines.push(`图片:${element.image.name}`);
|
|
293
|
+
if (element.altText?.trim()) lines.push(`替代文本:${element.altText.trim()}`);
|
|
294
|
+
if (element.href?.trim()) lines.push(`链接:${element.href.trim()}`);
|
|
295
|
+
if (!lines.length) lines.push('(无文本内容)');
|
|
296
|
+
return lines;
|
|
297
|
+
}
|
|
298
|
+
function presentationChartDataLabelLines(chart) {
|
|
299
|
+
if (!chart.dataLabels) return [];
|
|
300
|
+
const labels = normalizePresentationChartDataLabels(chart.dataLabels, chart.type);
|
|
301
|
+
const content = [
|
|
302
|
+
labels.showValue ? '数值' : '',
|
|
303
|
+
labels.showCategoryName ? '分类名称' : '',
|
|
304
|
+
labels.showSeriesName ? '系列名称' : '',
|
|
305
|
+
labels.showPercentage ? '百分比' : '',
|
|
306
|
+
labels.showBubbleSize ? '气泡大小' : ''
|
|
307
|
+
].filter(Boolean);
|
|
308
|
+
const position = presentationChartDataLabelPositionLabel(labels.position);
|
|
309
|
+
return [
|
|
310
|
+
`数据标签:${content.length ? content.join('、') : '无内容'};位置:${position};分隔符:“${labels.separator ?? ', '}”`
|
|
311
|
+
];
|
|
312
|
+
}
|
|
313
|
+
function presentationChartSeriesLines(chart) {
|
|
314
|
+
const analysisContext = (series)=>`${workSpreadsheetChartSupportsSeriesAnalysis(chart) && workSpreadsheetChartSupportsTrendlines(chart.type) ? chartSeriesTrendlineContext(series) : ''}${workSpreadsheetChartSupportsSeriesAnalysis(chart) && workSpreadsheetChartSupportsErrorBars(chart.type) ? chartSeriesErrorBarContext(series, chart.type) : ''}${spreadsheetChartSeriesStyleContext(series.style)}`;
|
|
315
|
+
if (!presentationChartUsesNumericXAxis(chart.type)) return chart.series.map((series)=>`系列 ${series.name}:${series.values.map((value)=>normalizeValue(String(value))).join(',')}${analysisContext(series)}`);
|
|
316
|
+
const xValues = chart.categories.map(normalizeValue).join(',');
|
|
317
|
+
return chart.series.map((series)=>`系列 ${series.name}:X=${xValues};Y=${series.values.map((value)=>normalizeValue(String(value))).join(',')}${'bubble' === chart.type ? `;大小=${series.bubbleSizes?.map((value)=>normalizeValue(String(value))).join(',') || '无'}` : ''}${analysisContext(series)}`);
|
|
318
|
+
}
|
|
319
|
+
function presentationChartPlotLayoutLines(chart) {
|
|
320
|
+
if (!workSpreadsheetChartSupportsGrouping(chart.type)) return [];
|
|
321
|
+
const grouping = normalizeWorkSpreadsheetChartGrouping(chart.grouping, chart.type);
|
|
322
|
+
const settings = [
|
|
323
|
+
workSpreadsheetChartGroupingLabel(grouping)
|
|
324
|
+
];
|
|
325
|
+
if (workSpreadsheetChartSupportsBarSpacing(chart.type)) {
|
|
326
|
+
settings.push(`分类间距 ${normalizeWorkSpreadsheetChartGapWidth(chart.gapWidth)}%`);
|
|
327
|
+
settings.push(`系列重叠 ${normalizeWorkSpreadsheetChartOverlap(chart.overlap, grouping)}%`);
|
|
328
|
+
}
|
|
329
|
+
if (workSpreadsheetChartSupportsSmoothLines(chart.type)) settings.push(normalizeWorkSpreadsheetChartSmoothLines(chart.smoothLines) ? '平滑线' : '直线');
|
|
330
|
+
return [
|
|
331
|
+
`绘图区:${settings.join(',')}`
|
|
332
|
+
];
|
|
333
|
+
}
|
|
334
|
+
function presentationBubbleSettingsLine(chart) {
|
|
335
|
+
return `气泡设置:缩放 ${normalizePresentationBubbleScale(chart.bubbleScale)}%,${chart.showNegativeBubbles ? '显示负气泡' : '隐藏负气泡'},大小表示${'width' === normalizePresentationBubbleSizeRepresents(chart.bubbleSizeRepresents) ? '宽度' : '面积'}`;
|
|
336
|
+
}
|
|
337
|
+
function scatterStyleLabel(style) {
|
|
338
|
+
const normalized = normalizePresentationScatterStyle(style);
|
|
339
|
+
if ('marker' === normalized) return '仅数据标记';
|
|
340
|
+
if ('line' === normalized) return '直线';
|
|
341
|
+
if ('smooth' === normalized) return '平滑线';
|
|
342
|
+
if ('smoothMarker' === normalized) return '平滑线和数据标记';
|
|
343
|
+
return '直线和数据标记';
|
|
344
|
+
}
|
|
345
|
+
function presentationChartAxisLines(chart) {
|
|
346
|
+
const axes = presentationChartAxes(chart);
|
|
347
|
+
if (!axes) return [];
|
|
348
|
+
const descriptions = [
|
|
349
|
+
presentationChartAxisDescription(chart, 'bottom', '横轴', axes.bottom),
|
|
350
|
+
presentationChartAxisDescription(chart, 'left', '纵轴', axes.left)
|
|
351
|
+
].filter(Boolean);
|
|
352
|
+
return descriptions.length ? [
|
|
353
|
+
`坐标轴:${descriptions.join(';')}`
|
|
354
|
+
] : [];
|
|
355
|
+
}
|
|
356
|
+
function presentationChartAxisDescription(chart, position, label, axis) {
|
|
357
|
+
if (!axis) return '';
|
|
358
|
+
const parts = [
|
|
359
|
+
axis.title?.trim() ? `标题“${axis.title.trim()}”` : '',
|
|
360
|
+
!axis.title?.trim() && axis.titleReference?.trim() ? `标题引用“${axis.titleReference.trim()}”` : '',
|
|
361
|
+
axis.reverseOrder ? '逆序' : '',
|
|
362
|
+
axis.labelPosition && axis.labelPosition !== workSpreadsheetChartAxisDefaultLabelPosition(chart.type, position) ? `标签${workSpreadsheetChartAxisLabelPositionLabel(axis.labelPosition)}` : '',
|
|
363
|
+
axis.majorTickMark && 'none' !== axis.majorTickMark ? `主要刻度${workSpreadsheetChartAxisTickMarkLabel(axis.majorTickMark)}` : '',
|
|
364
|
+
void 0 !== axis.labelInterval ? `标签间隔 ${axis.labelInterval}` : '',
|
|
365
|
+
void 0 !== axis.minimum && void 0 !== axis.maximum ? `范围 ${axis.minimum}–${axis.maximum}` : void 0 !== axis.minimum ? `最小值 ${axis.minimum}` : void 0 !== axis.maximum ? `最大值 ${axis.maximum}` : '',
|
|
366
|
+
void 0 !== axis.majorUnit ? `主单位 ${axis.majorUnit}` : '',
|
|
367
|
+
axis.numberFormat?.trim() ? `数字格式 ${axis.numberFormat.trim()}` : '',
|
|
368
|
+
true === axis.showMajorGridlines ? '显示主要网格线' : false === axis.showMajorGridlines ? '不显示主要网格线' : ''
|
|
369
|
+
].filter(Boolean);
|
|
370
|
+
return parts.length ? `${label}(${parts.join(',')})` : '';
|
|
371
|
+
}
|
|
372
|
+
function slideElementLabel(element) {
|
|
373
|
+
if ('text' === element.type) return '文本框';
|
|
374
|
+
if ('shape' === element.type) return '形状';
|
|
375
|
+
if ('image' === element.type) return '图片';
|
|
376
|
+
if ('table' === element.type) return '表格';
|
|
377
|
+
if ('chart' === element.type) return '图表';
|
|
378
|
+
return '线条';
|
|
379
|
+
}
|
|
380
|
+
function formatPercent(value) {
|
|
381
|
+
return `${Number.isFinite(value) ? value.toFixed(1) : '0.0'}%`;
|
|
382
|
+
}
|
|
383
|
+
function normalizeValue(value) {
|
|
384
|
+
return value.replace(/\r?\n/g, ' ').replace(/\t/g, ' ').trim();
|
|
385
|
+
}
|
|
386
|
+
function radarStyleLabel(style) {
|
|
387
|
+
if ('marker' === style) return '带数据标记';
|
|
388
|
+
if ('filled' === style) return '填充';
|
|
389
|
+
return '标准';
|
|
390
|
+
}
|
|
391
|
+
function spreadsheetAgentSelection(content, sheetId, selection, maximumCells = 200) {
|
|
392
|
+
const sheet = content.sheets.find((candidate)=>candidate.id === sheetId) ?? content.sheets[0];
|
|
393
|
+
if (!sheet || selection.row.length < 2 || selection.column.length < 2) return null;
|
|
394
|
+
const rowStart = Math.max(0, Math.min(selection.row[0], selection.row[1]));
|
|
395
|
+
const rowEnd = Math.max(rowStart, Math.max(selection.row[0], selection.row[1]));
|
|
396
|
+
const columnStart = Math.max(0, Math.min(selection.column[0], selection.column[1]));
|
|
397
|
+
const columnEnd = Math.max(columnStart, Math.max(selection.column[0], selection.column[1]));
|
|
398
|
+
const rowCount = rowEnd - rowStart + 1;
|
|
399
|
+
const columnCount = columnEnd - columnStart + 1;
|
|
400
|
+
const cellCount = rowCount * columnCount;
|
|
401
|
+
const limit = Math.max(1, Math.floor(maximumCells));
|
|
402
|
+
const rows = [];
|
|
403
|
+
const formulas = [];
|
|
404
|
+
const proposalTargets = [];
|
|
405
|
+
let included = 0;
|
|
406
|
+
for(let row = rowStart; row <= rowEnd && included < limit; row += 1){
|
|
407
|
+
const values = [];
|
|
408
|
+
for(let column = columnStart; column <= columnEnd && included < limit; column += 1){
|
|
409
|
+
const cell = sheet.data?.[row]?.[column] ?? null;
|
|
410
|
+
const cellReference = spreadsheetCellReference(row, column);
|
|
411
|
+
values.push(spreadsheetCellText(cell));
|
|
412
|
+
proposalTargets.push({
|
|
413
|
+
id: cellReference,
|
|
414
|
+
label: `${sheet.name}!${cellReference}`,
|
|
415
|
+
before: spreadsheetCellSourceText(cell)
|
|
416
|
+
});
|
|
417
|
+
if (cell?.f) {
|
|
418
|
+
const sourceFormula = sheet.formulaMetadata?.sourceFormulas?.[cellReference] ?? cell.f;
|
|
419
|
+
formulas.push(`${cellReference}:${normalizeCellText(sourceFormula)}`);
|
|
420
|
+
}
|
|
421
|
+
included += 1;
|
|
422
|
+
}
|
|
423
|
+
rows.push(values.join('\t'));
|
|
424
|
+
}
|
|
425
|
+
const reference = `${spreadsheetCellReference(rowStart, columnStart)}:${spreadsheetCellReference(rowEnd, columnEnd)}`;
|
|
426
|
+
const clipboard = rows.join('\n');
|
|
427
|
+
const truncated = cellCount > included;
|
|
428
|
+
const chartContext = relatedChartContext(content, sheet, {
|
|
429
|
+
rowStart,
|
|
430
|
+
rowEnd,
|
|
431
|
+
columnStart,
|
|
432
|
+
columnEnd
|
|
433
|
+
});
|
|
434
|
+
const formulaRanges = spreadsheetFormulaRangesForSelection(sheet, {
|
|
435
|
+
startRow: rowStart,
|
|
436
|
+
endRow: rowEnd,
|
|
437
|
+
startColumn: columnStart,
|
|
438
|
+
endColumn: columnEnd
|
|
439
|
+
});
|
|
440
|
+
const formulaContext = formulas.length || formulaRanges.length ? [
|
|
441
|
+
`计算模式:${calculationModeLabel(effectiveSpreadsheetCalculationSettings(content.calculation).mode)}`,
|
|
442
|
+
...formulaRanges.map((range)=>`${range.reference}:${formulaRangeTypeLabel(range.type)}(锚点 ${range.anchor})`)
|
|
443
|
+
] : [];
|
|
444
|
+
const pivotContext = relatedPivotContext(content, sheet, {
|
|
445
|
+
rowStart,
|
|
446
|
+
rowEnd,
|
|
447
|
+
columnStart,
|
|
448
|
+
columnEnd
|
|
449
|
+
});
|
|
450
|
+
const context = [
|
|
451
|
+
`工作表:${sheet.name}`,
|
|
452
|
+
`选区:${reference}`,
|
|
453
|
+
`单元格数量:${cellCount}`,
|
|
454
|
+
'内容(制表符分隔,空白单元格保留):',
|
|
455
|
+
clipboard,
|
|
456
|
+
...formulas.length ? [
|
|
457
|
+
'',
|
|
458
|
+
'公式:',
|
|
459
|
+
...formulas
|
|
460
|
+
] : [],
|
|
461
|
+
...formulaContext.length ? [
|
|
462
|
+
'',
|
|
463
|
+
'公式与计算:',
|
|
464
|
+
...formulaContext
|
|
465
|
+
] : [],
|
|
466
|
+
...pivotContext.length ? [
|
|
467
|
+
'',
|
|
468
|
+
'关联数据透视表:',
|
|
469
|
+
...pivotContext
|
|
470
|
+
] : [],
|
|
471
|
+
...chartContext.length ? [
|
|
472
|
+
'',
|
|
473
|
+
'关联图表:',
|
|
474
|
+
...chartContext
|
|
475
|
+
] : [],
|
|
476
|
+
...truncated ? [
|
|
477
|
+
'',
|
|
478
|
+
`[选区过大,仅包含前 ${included} 个单元格]`
|
|
479
|
+
] : []
|
|
480
|
+
].join('\n');
|
|
481
|
+
return {
|
|
482
|
+
sheetId: sheet.id ?? sheetId,
|
|
483
|
+
sheetName: sheet.name,
|
|
484
|
+
reference,
|
|
485
|
+
cellCount,
|
|
486
|
+
context,
|
|
487
|
+
clipboard,
|
|
488
|
+
truncated,
|
|
489
|
+
proposalTargets
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function relatedPivotContext(content, sheet, selection) {
|
|
493
|
+
const related = new Map();
|
|
494
|
+
for (const owner of content.sheets)for (const pivot of owner.pivotTables ?? []){
|
|
495
|
+
if (owner.id === sheet.id && spreadsheetPivotIntersects(owner, {
|
|
496
|
+
startRow: selection.rowStart,
|
|
497
|
+
endRow: selection.rowEnd,
|
|
498
|
+
startColumn: selection.columnStart,
|
|
499
|
+
endColumn: selection.columnEnd
|
|
500
|
+
}).some((candidate)=>candidate.id === pivot.id)) {
|
|
501
|
+
related.set(pivot.id, {
|
|
502
|
+
pivot,
|
|
503
|
+
owner
|
|
504
|
+
});
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (pivot.sourceSheetId !== sheet.id) continue;
|
|
508
|
+
const source = parseSpreadsheetCellRanges(pivot.sourceReference)?.[0];
|
|
509
|
+
if (source && source.row[0] <= selection.rowEnd && source.row[1] >= selection.rowStart && source.column[0] <= selection.columnEnd && source.column[1] >= selection.columnStart) related.set(pivot.id, {
|
|
510
|
+
pivot,
|
|
511
|
+
owner
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
return Array.from(related.values()).map(({ pivot, owner })=>{
|
|
515
|
+
const fields = spreadsheetPivotFields(content, pivot);
|
|
516
|
+
const rows = pivot.rowFields.map((index)=>fields[index]?.name).filter(Boolean).join('、') || '无';
|
|
517
|
+
const columns = pivot.columnFields.map((index)=>fields[index]?.name).filter(Boolean).join('、') || '无';
|
|
518
|
+
const values = pivot.values.map((value)=>`${value.caption || fields[value.fieldIndex]?.name || `字段 ${value.fieldIndex + 1}`}(${spreadsheetPivotAggregationLabel(value.aggregation)})`).join('、') || '无';
|
|
519
|
+
const filters = (pivot.reportFilters ?? []).map((filter)=>{
|
|
520
|
+
const field = fields[filter.fieldIndex]?.name ?? `字段 ${filter.fieldIndex + 1}`;
|
|
521
|
+
const selected = void 0 === filter.selectedItem ? '(全部)' : spreadsheetPivotFilterDisplay(filter.selectedItem);
|
|
522
|
+
return `${field}=${selected}`;
|
|
523
|
+
}).join('、') || '无';
|
|
524
|
+
const sourceSheet = content.sheets.find((candidate)=>candidate.id === pivot.sourceSheetId);
|
|
525
|
+
return `${pivot.name}(来源:${sourceSheet?.name ?? '缺失工作表'}!${pivot.sourceReference};行:${rows};列:${columns};值:${values};筛选:${filters};输出:${owner.name}!${pivot.outputReference ?? pivot.anchor})`;
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function spreadsheetPivotFilterDisplay(value) {
|
|
529
|
+
if (null === value) return '(空白)';
|
|
530
|
+
if ('boolean' == typeof value) return value ? 'TRUE' : 'FALSE';
|
|
531
|
+
return String(value);
|
|
532
|
+
}
|
|
533
|
+
function relatedChartContext(content, sheet, selection) {
|
|
534
|
+
return (sheet.charts ?? []).flatMap((chart)=>{
|
|
535
|
+
const references = [
|
|
536
|
+
chart.titleReference,
|
|
537
|
+
chart.categoryReference,
|
|
538
|
+
chart.axes?.bottom?.titleReference,
|
|
539
|
+
chart.axes?.left?.titleReference,
|
|
540
|
+
chart.axes?.top?.titleReference,
|
|
541
|
+
chart.axes?.right?.titleReference,
|
|
542
|
+
...chart.series.flatMap((series)=>[
|
|
543
|
+
series.nameReference,
|
|
544
|
+
series.valuesReference,
|
|
545
|
+
series.xValuesReference,
|
|
546
|
+
series.bubbleSizesReference,
|
|
547
|
+
...(series.errorBars ?? []).flatMap((errorBars)=>[
|
|
548
|
+
errorBars.plusReference,
|
|
549
|
+
errorBars.minusReference
|
|
550
|
+
])
|
|
551
|
+
])
|
|
552
|
+
].filter((reference)=>Boolean(reference));
|
|
553
|
+
const related = references.some((reference)=>{
|
|
554
|
+
const range = parseSpreadsheetChartReference(content, sheet, reference);
|
|
555
|
+
if (!range || range.sheet.id !== sheet.id) return false;
|
|
556
|
+
return range.startRow <= selection.rowEnd && range.endRow >= selection.rowStart && range.startColumn <= selection.columnEnd && range.endColumn >= selection.columnStart;
|
|
557
|
+
});
|
|
558
|
+
if (!related) return [];
|
|
559
|
+
const resolved = resolveSpreadsheetChart(content, sheet, chart);
|
|
560
|
+
const axisTitles = chartAxisTitleContext(resolved);
|
|
561
|
+
const axisSettings = chartAxisSettingsContext(resolved);
|
|
562
|
+
const layout = chartLayoutContext(resolved);
|
|
563
|
+
return [
|
|
564
|
+
`${resolved.title || resolved.name}(${workSpreadsheetChartTypeLabel(resolved.type)};${axisTitles ? `${axisTitles};` : ''}${axisSettings ? `${axisSettings};` : ''}${layout ? `${layout};` : ''}分类:${resolved.categories.slice(0, 12).join('、') || '无'};${resolved.series.slice(0, 6).map((series)=>{
|
|
565
|
+
if ('scatter' === resolved.type || 'bubble' === resolved.type) {
|
|
566
|
+
const xValues = series.xValues?.length ? series.xValues : series.values.map((_, index)=>index + 1);
|
|
567
|
+
return `${series.name}:X=${xValues.slice(0, 12).join('、')};Y=${series.values.slice(0, 12).join('、')}${'bubble' === resolved.type ? `;大小=${series.bubbleSizes?.slice(0, 12).join('、') || '无'}` : ''}${spreadsheetChartSeriesStyleContext(series.style)}${seriesDataLabelContext(series, resolved.type)}${chartSeriesErrorBarContext(series, resolved.type)}${chartSeriesTrendlineContext(series)}`;
|
|
568
|
+
}
|
|
569
|
+
if ('combination' === resolved.type) {
|
|
570
|
+
const seriesType = normalizeWorkSpreadsheetCombinationSeriesType(series.chartType);
|
|
571
|
+
const axisGroup = normalizeWorkSpreadsheetChartAxisGroup(series.axisGroup);
|
|
572
|
+
return `${series.name}(${workSpreadsheetCombinationSeriesTypeLabel(seriesType)},${'secondary' === axisGroup ? '次坐标轴' : '主坐标轴'})=${series.values.slice(0, 12).join('、')}${spreadsheetChartSeriesStyleContext(series.style)}${seriesDataLabelContext(series, resolved.type)}${chartSeriesErrorBarContext(series, resolved.type)}${chartSeriesTrendlineContext(series)}`;
|
|
573
|
+
}
|
|
574
|
+
return `${series.name}=${series.values.slice(0, 12).join('、')}${spreadsheetChartSeriesStyleContext(series.style)}${seriesDataLabelContext(series, resolved.type)}${chartSeriesErrorBarContext(series, resolved.type)}${chartSeriesTrendlineContext(series)}`;
|
|
575
|
+
}).join(';')})`
|
|
576
|
+
];
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
function chartLayoutContext(chart) {
|
|
580
|
+
const descriptions = [];
|
|
581
|
+
if (chart.showLegend) {
|
|
582
|
+
const position = normalizeWorkSpreadsheetChartLegendPosition(chart.legendPosition);
|
|
583
|
+
const overlay = normalizeWorkSpreadsheetChartLegendOverlay(chart.legendOverlay) ? '(叠加绘图区)' : '';
|
|
584
|
+
descriptions.push(`图例:${workSpreadsheetChartLegendPositionLabel(position)}${overlay}`);
|
|
585
|
+
}
|
|
586
|
+
if (workSpreadsheetChartSupportsGrouping(chart.type)) {
|
|
587
|
+
const grouping = normalizeWorkSpreadsheetChartGrouping(chart.grouping, chart.type);
|
|
588
|
+
const settings = [
|
|
589
|
+
workSpreadsheetChartGroupingLabel(grouping)
|
|
590
|
+
];
|
|
591
|
+
if (workSpreadsheetChartSupportsBarSpacing(chart.type)) {
|
|
592
|
+
settings.push(`分类间距 ${normalizeWorkSpreadsheetChartGapWidth(chart.gapWidth)}%`);
|
|
593
|
+
settings.push(`系列重叠 ${normalizeWorkSpreadsheetChartOverlap(chart.overlap, grouping)}%`);
|
|
594
|
+
}
|
|
595
|
+
if (workSpreadsheetChartSupportsSmoothLines(chart.type) && normalizeWorkSpreadsheetChartSmoothLines(chart.smoothLines)) settings.push('平滑线');
|
|
596
|
+
descriptions.push(`绘图区:${settings.join(',')}`);
|
|
597
|
+
}
|
|
598
|
+
return descriptions.join(';');
|
|
599
|
+
}
|
|
600
|
+
function chartAxisTitleContext(chart) {
|
|
601
|
+
const hasSecondaryAxes = 'combination' === chart.type && chart.series.some((series)=>'secondary' === normalizeWorkSpreadsheetChartAxisGroup(series.axisGroup));
|
|
602
|
+
const axes = normalizeWorkSpreadsheetChartAxes(chart.axes, chart.type, hasSecondaryAxes);
|
|
603
|
+
if (!axes) return '';
|
|
604
|
+
const descriptions = [
|
|
605
|
+
'bottom',
|
|
606
|
+
'left',
|
|
607
|
+
'top',
|
|
608
|
+
'right'
|
|
609
|
+
].flatMap((position)=>{
|
|
610
|
+
const title = axes[position]?.title?.trim();
|
|
611
|
+
return title ? [
|
|
612
|
+
`${workSpreadsheetChartAxisPositionLabel(position)}“${title}”`
|
|
613
|
+
] : [];
|
|
614
|
+
});
|
|
615
|
+
return descriptions.length ? `坐标轴标题:${descriptions.join(',')}` : '';
|
|
616
|
+
}
|
|
617
|
+
function chartAxisSettingsContext(chart) {
|
|
618
|
+
const hasSecondaryAxes = 'combination' === chart.type && chart.series.some((series)=>'secondary' === normalizeWorkSpreadsheetChartAxisGroup(series.axisGroup));
|
|
619
|
+
const axes = normalizeWorkSpreadsheetChartAxes(chart.axes, chart.type, hasSecondaryAxes);
|
|
620
|
+
if (!axes) return '';
|
|
621
|
+
const descriptions = [
|
|
622
|
+
'bottom',
|
|
623
|
+
'left',
|
|
624
|
+
'top',
|
|
625
|
+
'right'
|
|
626
|
+
].flatMap((position)=>{
|
|
627
|
+
const axis = axes[position];
|
|
628
|
+
if (!axis) return [];
|
|
629
|
+
const settings = [
|
|
630
|
+
void 0 !== axis.minimum && void 0 !== axis.maximum ? `范围 ${axis.minimum}–${axis.maximum}` : void 0 !== axis.minimum ? `最小值 ${axis.minimum}` : void 0 !== axis.maximum ? `最大值 ${axis.maximum}` : '',
|
|
631
|
+
void 0 !== axis.majorUnit ? `主单位 ${axis.majorUnit}` : '',
|
|
632
|
+
axis.numberFormat ? `数字格式 ${axis.numberFormat}${axis.numberFormatSourceLinked ? '(链接源)' : ''}` : axis.numberFormatSourceLinked ? '数字格式链接源' : '',
|
|
633
|
+
void 0 === axis.showMajorGridlines ? '' : axis.showMajorGridlines ? '显示主要网格线' : '不显示主要网格线',
|
|
634
|
+
axis.reverseOrder ? '逆序' : '',
|
|
635
|
+
axis.labelPosition ? `标签置于${workSpreadsheetChartAxisLabelPositionLabel(axis.labelPosition)}` : '',
|
|
636
|
+
axis.majorTickMark ? `主要刻度线${workSpreadsheetChartAxisTickMarkLabel(axis.majorTickMark)}` : '',
|
|
637
|
+
axis.labelInterval ? `标签间隔 ${axis.labelInterval}` : ''
|
|
638
|
+
].filter(Boolean);
|
|
639
|
+
return settings.length ? [
|
|
640
|
+
`${workSpreadsheetChartAxisPositionLabel(position)}(${settings.join(',')})`
|
|
641
|
+
] : [];
|
|
642
|
+
});
|
|
643
|
+
return descriptions.length ? `坐标轴设置:${descriptions.join(';')}` : '';
|
|
644
|
+
}
|
|
645
|
+
function seriesDataLabelContext(series, chartType) {
|
|
646
|
+
if (!series.dataLabels) return '';
|
|
647
|
+
const labels = normalizeWorkSpreadsheetDataLabels(series.dataLabels, chartType);
|
|
648
|
+
const content = [
|
|
649
|
+
labels.showValue ? '数值' : '',
|
|
650
|
+
labels.showCategoryName ? '分类名称' : '',
|
|
651
|
+
labels.showSeriesName ? '系列名称' : '',
|
|
652
|
+
labels.showPercentage ? '百分比' : '',
|
|
653
|
+
labels.showBubbleSize ? '气泡大小' : ''
|
|
654
|
+
].filter(Boolean);
|
|
655
|
+
const description = [
|
|
656
|
+
content.join('、') || '无内容字段',
|
|
657
|
+
labels.position ? workSpreadsheetDataLabelPositionLabel(labels.position) : '',
|
|
658
|
+
void 0 !== labels.separator ? `分隔符“${labels.separator.replace(/\r?\n/g, '↵')}”` : ''
|
|
659
|
+
].filter(Boolean);
|
|
660
|
+
return `;数据标签:${description.join(',')}`;
|
|
661
|
+
}
|
|
662
|
+
function spreadsheetCellText(cell) {
|
|
663
|
+
if (!cell) return '';
|
|
664
|
+
const value = cell.m ?? cell.v ?? '';
|
|
665
|
+
return normalizeCellText(String(value));
|
|
666
|
+
}
|
|
667
|
+
function spreadsheetCellSourceText(cell) {
|
|
668
|
+
if (!cell) return '';
|
|
669
|
+
if (cell.f) return normalizeCellText(cell.f);
|
|
670
|
+
return normalizeCellText(String(cell.v ?? cell.m ?? ''));
|
|
671
|
+
}
|
|
672
|
+
function normalizeCellText(value) {
|
|
673
|
+
return value.replace(/\r?\n/g, ' ').replace(/\t/g, ' ').trim();
|
|
674
|
+
}
|
|
675
|
+
function spreadsheetCellReference(row, column) {
|
|
676
|
+
let value = column + 1;
|
|
677
|
+
let label = '';
|
|
678
|
+
while(value > 0){
|
|
679
|
+
value -= 1;
|
|
680
|
+
label = String.fromCharCode(65 + value % 26) + label;
|
|
681
|
+
value = Math.floor(value / 26);
|
|
682
|
+
}
|
|
683
|
+
return `${label}${row + 1}`;
|
|
684
|
+
}
|
|
685
|
+
function calculationModeLabel(mode) {
|
|
686
|
+
if ('manual' === mode) return '手动';
|
|
687
|
+
if ('automatic-except-data-tables' === mode) return '自动(模拟运算表除外)';
|
|
688
|
+
return '自动';
|
|
689
|
+
}
|
|
690
|
+
function formulaRangeTypeLabel(type) {
|
|
691
|
+
if ('dynamic-array' === type) return '动态数组';
|
|
692
|
+
if ('data-table' === type) return '模拟运算表';
|
|
693
|
+
return '传统数组';
|
|
694
|
+
}
|
|
695
|
+
function applySpreadsheetAgentProposalChanges(content, sheetId, changes) {
|
|
696
|
+
const sheetIndex = content.sheets.findIndex((sheet)=>sheet.id === sheetId);
|
|
697
|
+
if (sheetIndex < 0) return failedOutcome(content, changes, '目标工作表已不存在。');
|
|
698
|
+
const sheet = content.sheets[sheetIndex];
|
|
699
|
+
const data = [
|
|
700
|
+
...sheet.data ?? []
|
|
701
|
+
];
|
|
702
|
+
const clonedRows = new Set();
|
|
703
|
+
const appliedTargetIds = [];
|
|
704
|
+
const conflicts = [];
|
|
705
|
+
for (const change of changes){
|
|
706
|
+
const coordinate = parseCellReference(change.id);
|
|
707
|
+
if (!coordinate) {
|
|
708
|
+
conflicts.push(conflict(change, '建议中的单元格坐标无效。'));
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
const currentCell = data[coordinate.row]?.[coordinate.column] ?? null;
|
|
712
|
+
if (spreadsheetCellSourceText(currentCell) !== change.before) {
|
|
713
|
+
conflicts.push(conflict(change, '单元格内容在建议生成后已发生变化。'));
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
if (!clonedRows.has(coordinate.row)) {
|
|
717
|
+
data[coordinate.row] = [
|
|
718
|
+
...data[coordinate.row] ?? []
|
|
719
|
+
];
|
|
720
|
+
clonedRows.add(coordinate.row);
|
|
721
|
+
}
|
|
722
|
+
data[coordinate.row][coordinate.column] = spreadsheetCellWithContent(currentCell, change.after);
|
|
723
|
+
appliedTargetIds.push(change.id);
|
|
724
|
+
}
|
|
725
|
+
if (!appliedTargetIds.length) return {
|
|
726
|
+
content,
|
|
727
|
+
result: {
|
|
728
|
+
appliedTargetIds,
|
|
729
|
+
conflicts
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
const sheets = [
|
|
733
|
+
...content.sheets
|
|
734
|
+
];
|
|
735
|
+
sheets[sheetIndex] = {
|
|
736
|
+
...sheet,
|
|
737
|
+
data
|
|
738
|
+
};
|
|
739
|
+
return {
|
|
740
|
+
content: {
|
|
741
|
+
...content,
|
|
742
|
+
sheets
|
|
743
|
+
},
|
|
744
|
+
result: {
|
|
745
|
+
appliedTargetIds,
|
|
746
|
+
conflicts
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
function applyPresentationAgentProposalChanges(content, slideId, changes) {
|
|
751
|
+
const slideIndex = content.slides.findIndex((slide)=>slide.id === slideId);
|
|
752
|
+
if (slideIndex < 0) return failedOutcome(content, changes, '目标幻灯片已不存在。');
|
|
753
|
+
const originalSlide = content.slides[slideIndex];
|
|
754
|
+
const nextSlide = {
|
|
755
|
+
...originalSlide,
|
|
756
|
+
elements: [
|
|
757
|
+
...originalSlide.elements
|
|
758
|
+
]
|
|
759
|
+
};
|
|
760
|
+
const clonedElements = new Set();
|
|
761
|
+
const appliedTargetIds = [];
|
|
762
|
+
const conflicts = [];
|
|
763
|
+
const mutableElement = (index)=>{
|
|
764
|
+
if (!clonedElements.has(index)) {
|
|
765
|
+
nextSlide.elements[index] = {
|
|
766
|
+
...nextSlide.elements[index]
|
|
767
|
+
};
|
|
768
|
+
clonedElements.add(index);
|
|
769
|
+
}
|
|
770
|
+
return nextSlide.elements[index];
|
|
771
|
+
};
|
|
772
|
+
for (const change of changes){
|
|
773
|
+
if ('notes' === change.id) {
|
|
774
|
+
if ((nextSlide.notes ?? '') !== change.before) {
|
|
775
|
+
conflicts.push(conflict(change, '演讲者备注在建议生成后已发生变化。'));
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
nextSlide.notes = change.after;
|
|
779
|
+
appliedTargetIds.push(change.id);
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (change.id.startsWith('text:')) {
|
|
783
|
+
const elementId = change.id.slice(5);
|
|
784
|
+
const elementIndex = nextSlide.elements.findIndex((element)=>element.id === elementId);
|
|
785
|
+
if (elementIndex < 0) {
|
|
786
|
+
conflicts.push(conflict(change, '目标演示元素已不存在。'));
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
const element = nextSlide.elements[elementIndex];
|
|
790
|
+
if (presentationElementText(element) !== change.before) {
|
|
791
|
+
conflicts.push(conflict(change, '元素文本在建议生成后已发生变化。'));
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
Object.assign(mutableElement(elementIndex), {
|
|
795
|
+
text: change.after,
|
|
796
|
+
textRuns: void 0
|
|
797
|
+
});
|
|
798
|
+
appliedTargetIds.push(change.id);
|
|
799
|
+
continue;
|
|
800
|
+
}
|
|
801
|
+
const tableTarget = change.id.match(/^table:(.+):(\d+):(\d+)$/);
|
|
802
|
+
if (!tableTarget) {
|
|
803
|
+
conflicts.push(conflict(change, '建议中的演示目标无效。'));
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
const [, elementId, rowText, columnText] = tableTarget;
|
|
807
|
+
const row = Number(rowText);
|
|
808
|
+
const column = Number(columnText);
|
|
809
|
+
const elementIndex = nextSlide.elements.findIndex((element)=>element.id === elementId);
|
|
810
|
+
const element = elementIndex >= 0 ? nextSlide.elements[elementIndex] : null;
|
|
811
|
+
const current = element?.table?.rows[row]?.[column];
|
|
812
|
+
if (void 0 === current) {
|
|
813
|
+
conflicts.push(conflict(change, '目标表格单元格已不存在。'));
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
if (current !== change.before) {
|
|
817
|
+
conflicts.push(conflict(change, '表格单元格在建议生成后已发生变化。'));
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
const nextElement = mutableElement(elementIndex);
|
|
821
|
+
const rows = nextElement.table?.rows.map((candidate)=>[
|
|
822
|
+
...candidate
|
|
823
|
+
]) ?? [];
|
|
824
|
+
rows[row][column] = change.after;
|
|
825
|
+
nextElement.table = {
|
|
826
|
+
...nextElement.table,
|
|
827
|
+
rows
|
|
828
|
+
};
|
|
829
|
+
appliedTargetIds.push(change.id);
|
|
830
|
+
}
|
|
831
|
+
if (!appliedTargetIds.length) return {
|
|
832
|
+
content,
|
|
833
|
+
result: {
|
|
834
|
+
appliedTargetIds,
|
|
835
|
+
conflicts
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
const slides = [
|
|
839
|
+
...content.slides
|
|
840
|
+
];
|
|
841
|
+
slides[slideIndex] = nextSlide;
|
|
842
|
+
return {
|
|
843
|
+
content: {
|
|
844
|
+
...content,
|
|
845
|
+
slides
|
|
846
|
+
},
|
|
847
|
+
result: {
|
|
848
|
+
appliedTargetIds,
|
|
849
|
+
conflicts
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
function spreadsheetCellWithContent(cell, value) {
|
|
854
|
+
const next = cell ? {
|
|
855
|
+
...cell
|
|
856
|
+
} : {};
|
|
857
|
+
if (value.startsWith('=')) {
|
|
858
|
+
next.f = value;
|
|
859
|
+
delete next.v;
|
|
860
|
+
delete next.m;
|
|
861
|
+
return next;
|
|
862
|
+
}
|
|
863
|
+
delete next.f;
|
|
864
|
+
if (!value) {
|
|
865
|
+
delete next.v;
|
|
866
|
+
delete next.m;
|
|
867
|
+
return next;
|
|
868
|
+
}
|
|
869
|
+
next.v = spreadsheetScalar(value);
|
|
870
|
+
next.m = value;
|
|
871
|
+
return next;
|
|
872
|
+
}
|
|
873
|
+
function spreadsheetScalar(value) {
|
|
874
|
+
if (/^[+-]?(?:0|[1-9]\d*)(?:\.\d+)?(?:e[+-]?\d+)?$/i.test(value)) {
|
|
875
|
+
const numeric = Number(value);
|
|
876
|
+
if (Number.isFinite(numeric)) return numeric;
|
|
877
|
+
}
|
|
878
|
+
if ('TRUE' === value.toLocaleUpperCase()) return true;
|
|
879
|
+
if ('FALSE' === value.toLocaleUpperCase()) return false;
|
|
880
|
+
return value;
|
|
881
|
+
}
|
|
882
|
+
function parseCellReference(reference) {
|
|
883
|
+
const match = reference.match(/^([A-Z]+)([1-9]\d*)$/i);
|
|
884
|
+
if (!match) return null;
|
|
885
|
+
let column = 0;
|
|
886
|
+
for (const character of match[1].toLocaleUpperCase())column = 26 * column + character.charCodeAt(0) - 64;
|
|
887
|
+
const row = Number(match[2]) - 1;
|
|
888
|
+
if (!Number.isSafeInteger(row) || row < 0 || column < 1) return null;
|
|
889
|
+
return {
|
|
890
|
+
row,
|
|
891
|
+
column: column - 1
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
function failedOutcome(content, changes, message) {
|
|
895
|
+
return {
|
|
896
|
+
content,
|
|
897
|
+
result: {
|
|
898
|
+
appliedTargetIds: [],
|
|
899
|
+
conflicts: changes.map((change)=>conflict(change, message))
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
function conflict(change, message) {
|
|
904
|
+
return {
|
|
905
|
+
targetId: change.id,
|
|
906
|
+
label: change.label,
|
|
907
|
+
message
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
function normalizeRequiredOfficeNumber(value, options = {}) {
|
|
911
|
+
if (!value.trim()) return null;
|
|
912
|
+
return normalizeOfficeNumber(value, options);
|
|
913
|
+
}
|
|
914
|
+
function normalizeOptionalOfficeNumber(value, options = {}) {
|
|
915
|
+
if (!value.trim()) return;
|
|
916
|
+
return normalizeOfficeNumber(value, options);
|
|
917
|
+
}
|
|
918
|
+
function normalizeOfficeNumber(value, options) {
|
|
919
|
+
const parsed = Number(value);
|
|
920
|
+
if (!Number.isFinite(parsed)) return null;
|
|
921
|
+
let normalized = options.integer ? Math.round(parsed) : roundDecimalPlaces(parsed, options.decimalPlaces);
|
|
922
|
+
normalized = Math.min(options.maximum ?? 1 / 0, Math.max(options.minimum ?? -1 / 0, normalized));
|
|
923
|
+
return !options.isValid || options.isValid(normalized) ? normalized : null;
|
|
924
|
+
}
|
|
925
|
+
function roundDecimalPlaces(value, decimalPlaces) {
|
|
926
|
+
if (void 0 === decimalPlaces) return value;
|
|
927
|
+
const factor = 10 ** Math.max(0, Math.trunc(decimalPlaces));
|
|
928
|
+
return Math.round(value * factor) / factor;
|
|
929
|
+
}
|
|
930
|
+
function SpreadsheetChartSeriesStyleEditor({ seriesNumber, supportsMarkers, value, onChange }) {
|
|
931
|
+
const defaults = seriesStyleDefaults(seriesNumber - 1, supportsMarkers);
|
|
932
|
+
const style = normalizeWorkSpreadsheetChartSeriesStyle(value) ?? defaults;
|
|
933
|
+
const marker = style.marker ?? defaultWorkSpreadsheetChartSeriesStyle(seriesNumber - 1).marker;
|
|
934
|
+
const update = (change)=>onChange(normalizeWorkSpreadsheetChartSeriesStyle({
|
|
935
|
+
...style,
|
|
936
|
+
...change
|
|
937
|
+
}));
|
|
938
|
+
const updateMarker = (change)=>update({
|
|
939
|
+
marker: {
|
|
940
|
+
...marker,
|
|
941
|
+
...change
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
return /*#__PURE__*/ jsxs("section", {
|
|
945
|
+
className: "work-spreadsheet-chart-series-style",
|
|
946
|
+
"aria-label": `系列 ${seriesNumber} 外观设置`,
|
|
947
|
+
children: [
|
|
948
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
949
|
+
className: "check enable-series-style",
|
|
950
|
+
ariaLabel: `系列 ${seriesNumber} 使用自定义外观`,
|
|
951
|
+
checked: Boolean(value),
|
|
952
|
+
onCheckedChange: (checked)=>onChange(checked ? defaults : void 0),
|
|
953
|
+
children: "自定义系列外观"
|
|
954
|
+
}),
|
|
955
|
+
value && /*#__PURE__*/ jsxs("div", {
|
|
956
|
+
children: [
|
|
957
|
+
/*#__PURE__*/ jsxs("div", {
|
|
958
|
+
className: "work-office-field",
|
|
959
|
+
children: [
|
|
960
|
+
/*#__PURE__*/ jsx("span", {
|
|
961
|
+
children: "填充颜色"
|
|
962
|
+
}),
|
|
963
|
+
/*#__PURE__*/ jsx(OfficeColorPicker, {
|
|
964
|
+
ariaLabel: `系列 ${seriesNumber} 填充颜色`,
|
|
965
|
+
value: style.fillColor ?? '#4F6BED',
|
|
966
|
+
onValueChange: (fillColor)=>update({
|
|
967
|
+
fillColor
|
|
968
|
+
})
|
|
969
|
+
})
|
|
970
|
+
]
|
|
971
|
+
}),
|
|
972
|
+
/*#__PURE__*/ jsxs("div", {
|
|
973
|
+
className: "work-office-field",
|
|
974
|
+
children: [
|
|
975
|
+
/*#__PURE__*/ jsx("span", {
|
|
976
|
+
children: "填充透明度(%)"
|
|
977
|
+
}),
|
|
978
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
979
|
+
ariaLabel: `系列 ${seriesNumber} 填充透明度`,
|
|
980
|
+
min: 0,
|
|
981
|
+
max: 100,
|
|
982
|
+
step: 1,
|
|
983
|
+
value: style.fillTransparency ?? 0,
|
|
984
|
+
normalizeValue: (value)=>normalizeRequiredOfficeNumber(value, {
|
|
985
|
+
integer: true,
|
|
986
|
+
minimum: 0,
|
|
987
|
+
maximum: 100
|
|
988
|
+
}),
|
|
989
|
+
onValueCommit: (fillTransparency)=>update({
|
|
990
|
+
fillTransparency
|
|
991
|
+
})
|
|
992
|
+
})
|
|
993
|
+
]
|
|
994
|
+
}),
|
|
995
|
+
/*#__PURE__*/ jsxs("div", {
|
|
996
|
+
className: "work-office-field",
|
|
997
|
+
children: [
|
|
998
|
+
/*#__PURE__*/ jsx("span", {
|
|
999
|
+
children: "线条颜色"
|
|
1000
|
+
}),
|
|
1001
|
+
/*#__PURE__*/ jsx(OfficeColorPicker, {
|
|
1002
|
+
ariaLabel: `系列 ${seriesNumber} 线条颜色`,
|
|
1003
|
+
value: style.lineColor ?? '#4F6BED',
|
|
1004
|
+
onValueChange: (lineColor)=>update({
|
|
1005
|
+
lineColor
|
|
1006
|
+
})
|
|
1007
|
+
})
|
|
1008
|
+
]
|
|
1009
|
+
}),
|
|
1010
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1011
|
+
className: "work-office-field",
|
|
1012
|
+
children: [
|
|
1013
|
+
/*#__PURE__*/ jsx("span", {
|
|
1014
|
+
children: "线条宽度(磅)"
|
|
1015
|
+
}),
|
|
1016
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
1017
|
+
ariaLabel: `系列 ${seriesNumber} 线条宽度`,
|
|
1018
|
+
min: 0.25,
|
|
1019
|
+
max: 20,
|
|
1020
|
+
step: 0.25,
|
|
1021
|
+
value: style.lineWidth ?? 2.25,
|
|
1022
|
+
normalizeValue: (value)=>normalizeRequiredOfficeNumber(value, {
|
|
1023
|
+
decimalPlaces: 2,
|
|
1024
|
+
minimum: 0.25,
|
|
1025
|
+
maximum: 20
|
|
1026
|
+
}),
|
|
1027
|
+
onValueCommit: (lineWidth)=>update({
|
|
1028
|
+
lineWidth
|
|
1029
|
+
})
|
|
1030
|
+
})
|
|
1031
|
+
]
|
|
1032
|
+
}),
|
|
1033
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1034
|
+
className: "work-office-field",
|
|
1035
|
+
children: [
|
|
1036
|
+
/*#__PURE__*/ jsx("span", {
|
|
1037
|
+
children: "线条虚线"
|
|
1038
|
+
}),
|
|
1039
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
1040
|
+
ariaLabel: `系列 ${seriesNumber} 线条虚线`,
|
|
1041
|
+
value: style.lineDash ?? 'solid',
|
|
1042
|
+
options: [
|
|
1043
|
+
{
|
|
1044
|
+
value: 'solid',
|
|
1045
|
+
label: '实线'
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
value: 'dash',
|
|
1049
|
+
label: '虚线'
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
value: 'dot',
|
|
1053
|
+
label: '点线'
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
value: 'dashDot',
|
|
1057
|
+
label: '点划线'
|
|
1058
|
+
}
|
|
1059
|
+
],
|
|
1060
|
+
onValueChange: (lineDash)=>update({
|
|
1061
|
+
lineDash: lineDash
|
|
1062
|
+
})
|
|
1063
|
+
})
|
|
1064
|
+
]
|
|
1065
|
+
}),
|
|
1066
|
+
supportsMarkers && /*#__PURE__*/ jsxs(Fragment, {
|
|
1067
|
+
children: [
|
|
1068
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1069
|
+
className: "work-office-field",
|
|
1070
|
+
children: [
|
|
1071
|
+
/*#__PURE__*/ jsx("span", {
|
|
1072
|
+
children: "数据标记符号"
|
|
1073
|
+
}),
|
|
1074
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
1075
|
+
ariaLabel: `系列 ${seriesNumber} 数据标记符号`,
|
|
1076
|
+
value: marker.symbol ?? 'circle',
|
|
1077
|
+
options: [
|
|
1078
|
+
{
|
|
1079
|
+
value: 'none',
|
|
1080
|
+
label: '无'
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
value: 'circle',
|
|
1084
|
+
label: '圆形'
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
value: 'square',
|
|
1088
|
+
label: '方形'
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
value: 'diamond',
|
|
1092
|
+
label: '菱形'
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
value: 'triangle',
|
|
1096
|
+
label: '三角形'
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
value: 'plus',
|
|
1100
|
+
label: '加号'
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
value: 'x',
|
|
1104
|
+
label: '叉号'
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
value: 'star',
|
|
1108
|
+
label: '星形'
|
|
1109
|
+
}
|
|
1110
|
+
],
|
|
1111
|
+
onValueChange: (symbol)=>updateMarker({
|
|
1112
|
+
symbol: symbol
|
|
1113
|
+
})
|
|
1114
|
+
})
|
|
1115
|
+
]
|
|
1116
|
+
}),
|
|
1117
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1118
|
+
className: "work-office-field",
|
|
1119
|
+
children: [
|
|
1120
|
+
/*#__PURE__*/ jsx("span", {
|
|
1121
|
+
children: "数据标记大小(磅)"
|
|
1122
|
+
}),
|
|
1123
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
1124
|
+
ariaLabel: `系列 ${seriesNumber} 数据标记大小`,
|
|
1125
|
+
min: 2,
|
|
1126
|
+
max: 72,
|
|
1127
|
+
step: 1,
|
|
1128
|
+
value: marker.size ?? 5,
|
|
1129
|
+
normalizeValue: (value)=>normalizeRequiredOfficeNumber(value, {
|
|
1130
|
+
integer: true,
|
|
1131
|
+
minimum: 2,
|
|
1132
|
+
maximum: 72
|
|
1133
|
+
}),
|
|
1134
|
+
onValueCommit: (size)=>updateMarker({
|
|
1135
|
+
size
|
|
1136
|
+
})
|
|
1137
|
+
})
|
|
1138
|
+
]
|
|
1139
|
+
}),
|
|
1140
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1141
|
+
className: "work-office-field",
|
|
1142
|
+
children: [
|
|
1143
|
+
/*#__PURE__*/ jsx("span", {
|
|
1144
|
+
children: "数据标记填充"
|
|
1145
|
+
}),
|
|
1146
|
+
/*#__PURE__*/ jsx(OfficeColorPicker, {
|
|
1147
|
+
ariaLabel: `系列 ${seriesNumber} 数据标记填充颜色`,
|
|
1148
|
+
value: marker.fillColor ?? '#FFFFFF',
|
|
1149
|
+
onValueChange: (fillColor)=>updateMarker({
|
|
1150
|
+
fillColor
|
|
1151
|
+
})
|
|
1152
|
+
})
|
|
1153
|
+
]
|
|
1154
|
+
}),
|
|
1155
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1156
|
+
className: "work-office-field",
|
|
1157
|
+
children: [
|
|
1158
|
+
/*#__PURE__*/ jsx("span", {
|
|
1159
|
+
children: "数据标记轮廓"
|
|
1160
|
+
}),
|
|
1161
|
+
/*#__PURE__*/ jsx(OfficeColorPicker, {
|
|
1162
|
+
ariaLabel: `系列 ${seriesNumber} 数据标记轮廓颜色`,
|
|
1163
|
+
value: marker.lineColor ?? style.lineColor ?? '#4F6BED',
|
|
1164
|
+
onValueChange: (lineColor)=>updateMarker({
|
|
1165
|
+
lineColor
|
|
1166
|
+
})
|
|
1167
|
+
})
|
|
1168
|
+
]
|
|
1169
|
+
})
|
|
1170
|
+
]
|
|
1171
|
+
})
|
|
1172
|
+
]
|
|
1173
|
+
})
|
|
1174
|
+
]
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
function seriesStyleDefaults(seriesIndex, supportsMarkers) {
|
|
1178
|
+
const style = defaultWorkSpreadsheetChartSeriesStyle(seriesIndex);
|
|
1179
|
+
return supportsMarkers ? style : {
|
|
1180
|
+
...style,
|
|
1181
|
+
marker: void 0
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
function SpreadsheetErrorBarEditor({ chartType, seriesNumber, errorBars, onChange, customInput = 'references' }) {
|
|
1185
|
+
const replaceErrorBars = (index, change)=>{
|
|
1186
|
+
onChange(errorBars.map((item, candidate)=>candidate === index ? {
|
|
1187
|
+
...item,
|
|
1188
|
+
...change
|
|
1189
|
+
} : item));
|
|
1190
|
+
};
|
|
1191
|
+
const hasDirection = (direction)=>errorBars.some((item)=>item.direction === direction);
|
|
1192
|
+
const addErrorBars = (direction)=>onChange([
|
|
1193
|
+
...errorBars,
|
|
1194
|
+
{
|
|
1195
|
+
direction,
|
|
1196
|
+
barType: 'both',
|
|
1197
|
+
valueType: 'standardError'
|
|
1198
|
+
}
|
|
1199
|
+
]);
|
|
1200
|
+
return /*#__PURE__*/ jsxs("section", {
|
|
1201
|
+
className: "work-spreadsheet-error-bars",
|
|
1202
|
+
"aria-label": `系列 ${seriesNumber} 误差线`,
|
|
1203
|
+
children: [
|
|
1204
|
+
/*#__PURE__*/ jsxs("header", {
|
|
1205
|
+
children: [
|
|
1206
|
+
/*#__PURE__*/ jsx("strong", {
|
|
1207
|
+
children: "误差线"
|
|
1208
|
+
}),
|
|
1209
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1210
|
+
children: [
|
|
1211
|
+
workSpreadsheetChartUsesNumericXAxis(chartType) && /*#__PURE__*/ jsxs("button", {
|
|
1212
|
+
type: "button",
|
|
1213
|
+
"aria-label": `添加系列 ${seriesNumber} X 误差线`,
|
|
1214
|
+
disabled: hasDirection('x'),
|
|
1215
|
+
onClick: ()=>addErrorBars('x'),
|
|
1216
|
+
children: [
|
|
1217
|
+
/*#__PURE__*/ jsx(Plus, {
|
|
1218
|
+
size: 11
|
|
1219
|
+
}),
|
|
1220
|
+
"X"
|
|
1221
|
+
]
|
|
1222
|
+
}),
|
|
1223
|
+
/*#__PURE__*/ jsxs("button", {
|
|
1224
|
+
type: "button",
|
|
1225
|
+
"aria-label": `添加系列 ${seriesNumber} Y 误差线`,
|
|
1226
|
+
disabled: hasDirection('y'),
|
|
1227
|
+
onClick: ()=>addErrorBars('y'),
|
|
1228
|
+
children: [
|
|
1229
|
+
/*#__PURE__*/ jsx(Plus, {
|
|
1230
|
+
size: 11
|
|
1231
|
+
}),
|
|
1232
|
+
"Y"
|
|
1233
|
+
]
|
|
1234
|
+
})
|
|
1235
|
+
]
|
|
1236
|
+
})
|
|
1237
|
+
]
|
|
1238
|
+
}),
|
|
1239
|
+
!errorBars.length && /*#__PURE__*/ jsx(CollectionState, {
|
|
1240
|
+
className: "work-spreadsheet-error-bars-empty",
|
|
1241
|
+
role: "status",
|
|
1242
|
+
children: "添加固定值、百分比、统计或自定义范围误差线。"
|
|
1243
|
+
}),
|
|
1244
|
+
errorBars.map((item, index)=>{
|
|
1245
|
+
const errorBarNumber = index + 1;
|
|
1246
|
+
const labelPrefix = `系列 ${seriesNumber} 误差线 ${errorBarNumber}`;
|
|
1247
|
+
return /*#__PURE__*/ jsxs("fieldset", {
|
|
1248
|
+
children: [
|
|
1249
|
+
/*#__PURE__*/ jsxs("legend", {
|
|
1250
|
+
children: [
|
|
1251
|
+
item.direction.toUpperCase(),
|
|
1252
|
+
" 误差线 ",
|
|
1253
|
+
errorBarNumber
|
|
1254
|
+
]
|
|
1255
|
+
}),
|
|
1256
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1257
|
+
className: "work-office-field",
|
|
1258
|
+
children: [
|
|
1259
|
+
/*#__PURE__*/ jsx("span", {
|
|
1260
|
+
children: "方向"
|
|
1261
|
+
}),
|
|
1262
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
1263
|
+
ariaLabel: `${labelPrefix} 方向`,
|
|
1264
|
+
value: item.direction,
|
|
1265
|
+
options: [
|
|
1266
|
+
...workSpreadsheetChartUsesNumericXAxis(chartType) ? [
|
|
1267
|
+
{
|
|
1268
|
+
value: 'x',
|
|
1269
|
+
label: 'X'
|
|
1270
|
+
}
|
|
1271
|
+
] : [],
|
|
1272
|
+
{
|
|
1273
|
+
value: 'y',
|
|
1274
|
+
label: 'Y'
|
|
1275
|
+
}
|
|
1276
|
+
],
|
|
1277
|
+
onValueChange: (direction)=>replaceErrorBars(index, {
|
|
1278
|
+
direction: direction
|
|
1279
|
+
})
|
|
1280
|
+
})
|
|
1281
|
+
]
|
|
1282
|
+
}),
|
|
1283
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1284
|
+
className: "work-office-field",
|
|
1285
|
+
children: [
|
|
1286
|
+
/*#__PURE__*/ jsx("span", {
|
|
1287
|
+
children: "误差类型"
|
|
1288
|
+
}),
|
|
1289
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
1290
|
+
ariaLabel: `${labelPrefix} 误差类型`,
|
|
1291
|
+
value: item.barType,
|
|
1292
|
+
options: [
|
|
1293
|
+
{
|
|
1294
|
+
value: 'both',
|
|
1295
|
+
label: '双向'
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
value: 'plus',
|
|
1299
|
+
label: '正向'
|
|
1300
|
+
},
|
|
1301
|
+
{
|
|
1302
|
+
value: 'minus',
|
|
1303
|
+
label: '负向'
|
|
1304
|
+
}
|
|
1305
|
+
],
|
|
1306
|
+
onValueChange: (barType)=>replaceErrorBars(index, {
|
|
1307
|
+
barType: barType
|
|
1308
|
+
})
|
|
1309
|
+
})
|
|
1310
|
+
]
|
|
1311
|
+
}),
|
|
1312
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1313
|
+
className: "work-office-field",
|
|
1314
|
+
children: [
|
|
1315
|
+
/*#__PURE__*/ jsx("span", {
|
|
1316
|
+
children: "计算方式"
|
|
1317
|
+
}),
|
|
1318
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
1319
|
+
ariaLabel: `${labelPrefix} 计算方式`,
|
|
1320
|
+
value: item.valueType,
|
|
1321
|
+
options: [
|
|
1322
|
+
{
|
|
1323
|
+
value: 'fixedValue',
|
|
1324
|
+
label: '固定值'
|
|
1325
|
+
},
|
|
1326
|
+
{
|
|
1327
|
+
value: 'percentage',
|
|
1328
|
+
label: '百分比'
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
value: 'standardDeviation',
|
|
1332
|
+
label: '标准差'
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
value: 'standardError',
|
|
1336
|
+
label: '标准误差'
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
value: 'custom',
|
|
1340
|
+
label: '自定义范围'
|
|
1341
|
+
}
|
|
1342
|
+
],
|
|
1343
|
+
onValueChange: (valueType)=>replaceErrorBars(index, errorBarsWithValueType(item, valueType))
|
|
1344
|
+
})
|
|
1345
|
+
]
|
|
1346
|
+
}),
|
|
1347
|
+
('fixedValue' === item.valueType || 'percentage' === item.valueType || 'standardDeviation' === item.valueType) && /*#__PURE__*/ jsxs("div", {
|
|
1348
|
+
className: "work-office-field",
|
|
1349
|
+
children: [
|
|
1350
|
+
/*#__PURE__*/ jsx("span", {
|
|
1351
|
+
children: 'percentage' === item.valueType ? '百分比(%)' : '数值'
|
|
1352
|
+
}),
|
|
1353
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
1354
|
+
ariaLabel: `${labelPrefix} 数值`,
|
|
1355
|
+
min: 0,
|
|
1356
|
+
step: 0.1,
|
|
1357
|
+
value: item.value ?? ('percentage' === item.valueType ? 5 : 1),
|
|
1358
|
+
normalizeValue: (value)=>normalizeRequiredOfficeNumber(value, {
|
|
1359
|
+
minimum: 0
|
|
1360
|
+
}),
|
|
1361
|
+
onValueCommit: (value)=>replaceErrorBars(index, {
|
|
1362
|
+
value
|
|
1363
|
+
})
|
|
1364
|
+
})
|
|
1365
|
+
]
|
|
1366
|
+
}),
|
|
1367
|
+
'custom' === item.valueType && 'minus' !== item.barType && 'references' === customInput && /*#__PURE__*/ jsxs("div", {
|
|
1368
|
+
className: "work-office-field error-reference",
|
|
1369
|
+
children: [
|
|
1370
|
+
/*#__PURE__*/ jsx("span", {
|
|
1371
|
+
children: "正误差引用"
|
|
1372
|
+
}),
|
|
1373
|
+
/*#__PURE__*/ jsx(office_text_field_OfficeTextField, {
|
|
1374
|
+
"aria-label": `${labelPrefix} 正误差引用`,
|
|
1375
|
+
value: item.plusReference ?? '',
|
|
1376
|
+
placeholder: "'报告'!$C$2:$C$8",
|
|
1377
|
+
onChange: (event)=>replaceErrorBars(index, {
|
|
1378
|
+
plusReference: event.target.value
|
|
1379
|
+
})
|
|
1380
|
+
})
|
|
1381
|
+
]
|
|
1382
|
+
}),
|
|
1383
|
+
'custom' === item.valueType && 'plus' !== item.barType && 'references' === customInput && /*#__PURE__*/ jsxs("div", {
|
|
1384
|
+
className: "work-office-field error-reference",
|
|
1385
|
+
children: [
|
|
1386
|
+
/*#__PURE__*/ jsx("span", {
|
|
1387
|
+
children: "负误差引用"
|
|
1388
|
+
}),
|
|
1389
|
+
/*#__PURE__*/ jsx(office_text_field_OfficeTextField, {
|
|
1390
|
+
"aria-label": `${labelPrefix} 负误差引用`,
|
|
1391
|
+
value: item.minusReference ?? '',
|
|
1392
|
+
placeholder: "'报告'!$D$2:$D$8",
|
|
1393
|
+
onChange: (event)=>replaceErrorBars(index, {
|
|
1394
|
+
minusReference: event.target.value
|
|
1395
|
+
})
|
|
1396
|
+
})
|
|
1397
|
+
]
|
|
1398
|
+
}),
|
|
1399
|
+
'custom' === item.valueType && 'minus' !== item.barType && 'values' === customInput && /*#__PURE__*/ jsxs("div", {
|
|
1400
|
+
className: "work-office-field error-reference",
|
|
1401
|
+
children: [
|
|
1402
|
+
/*#__PURE__*/ jsx("span", {
|
|
1403
|
+
children: "正误差值"
|
|
1404
|
+
}),
|
|
1405
|
+
/*#__PURE__*/ jsx(CustomErrorValuesInput, {
|
|
1406
|
+
label: `${labelPrefix} 正误差值`,
|
|
1407
|
+
id: `work-error-values-${seriesNumber}-${errorBarNumber}-plus`,
|
|
1408
|
+
values: item.plusValues,
|
|
1409
|
+
reference: item.plusReference,
|
|
1410
|
+
onCommit: (plusValues)=>replaceErrorBars(index, {
|
|
1411
|
+
plusValues,
|
|
1412
|
+
plusReference: void 0
|
|
1413
|
+
})
|
|
1414
|
+
}),
|
|
1415
|
+
item.plusReference && /*#__PURE__*/ jsxs("small", {
|
|
1416
|
+
title: item.plusReference,
|
|
1417
|
+
children: [
|
|
1418
|
+
"已保留导入引用:",
|
|
1419
|
+
item.plusReference
|
|
1420
|
+
]
|
|
1421
|
+
})
|
|
1422
|
+
]
|
|
1423
|
+
}),
|
|
1424
|
+
'custom' === item.valueType && 'plus' !== item.barType && 'values' === customInput && /*#__PURE__*/ jsxs("div", {
|
|
1425
|
+
className: "work-office-field error-reference",
|
|
1426
|
+
children: [
|
|
1427
|
+
/*#__PURE__*/ jsx("span", {
|
|
1428
|
+
children: "负误差值"
|
|
1429
|
+
}),
|
|
1430
|
+
/*#__PURE__*/ jsx(CustomErrorValuesInput, {
|
|
1431
|
+
label: `${labelPrefix} 负误差值`,
|
|
1432
|
+
id: `work-error-values-${seriesNumber}-${errorBarNumber}-minus`,
|
|
1433
|
+
values: item.minusValues,
|
|
1434
|
+
reference: item.minusReference,
|
|
1435
|
+
onCommit: (minusValues)=>replaceErrorBars(index, {
|
|
1436
|
+
minusValues,
|
|
1437
|
+
minusReference: void 0
|
|
1438
|
+
})
|
|
1439
|
+
}),
|
|
1440
|
+
item.minusReference && /*#__PURE__*/ jsxs("small", {
|
|
1441
|
+
title: item.minusReference,
|
|
1442
|
+
children: [
|
|
1443
|
+
"已保留导入引用:",
|
|
1444
|
+
item.minusReference
|
|
1445
|
+
]
|
|
1446
|
+
})
|
|
1447
|
+
]
|
|
1448
|
+
}),
|
|
1449
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
1450
|
+
className: "check",
|
|
1451
|
+
ariaLabel: `${labelPrefix} 显示端帽`,
|
|
1452
|
+
checked: false !== item.showEndCaps,
|
|
1453
|
+
onCheckedChange: (showEndCaps)=>replaceErrorBars(index, {
|
|
1454
|
+
showEndCaps
|
|
1455
|
+
}),
|
|
1456
|
+
children: "显示端帽"
|
|
1457
|
+
}),
|
|
1458
|
+
/*#__PURE__*/ jsx("button", {
|
|
1459
|
+
type: "button",
|
|
1460
|
+
className: "remove-error-bars",
|
|
1461
|
+
"aria-label": `删除${labelPrefix}`,
|
|
1462
|
+
onClick: ()=>onChange(errorBars.filter((_, candidate)=>candidate !== index)),
|
|
1463
|
+
children: /*#__PURE__*/ jsx(Trash2, {
|
|
1464
|
+
size: 12
|
|
1465
|
+
})
|
|
1466
|
+
})
|
|
1467
|
+
]
|
|
1468
|
+
}, `${seriesNumber}-${errorBarNumber}`);
|
|
1469
|
+
})
|
|
1470
|
+
]
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
function errorBarsWithValueType(errorBars, valueType) {
|
|
1474
|
+
if ('standardError' === valueType || 'custom' === valueType) return {
|
|
1475
|
+
valueType,
|
|
1476
|
+
value: void 0
|
|
1477
|
+
};
|
|
1478
|
+
return {
|
|
1479
|
+
valueType,
|
|
1480
|
+
value: errorBars.value ?? ('percentage' === valueType ? 5 : 1)
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
function CustomErrorValuesInput({ label, id, values, reference, onCommit }) {
|
|
1484
|
+
return /*#__PURE__*/ jsx(CommittedOfficeTextField, {
|
|
1485
|
+
id: id,
|
|
1486
|
+
"aria-label": label,
|
|
1487
|
+
value: values,
|
|
1488
|
+
formatValue: (items)=>items?.join(', ') ?? '',
|
|
1489
|
+
parseValue: parseCustomValues,
|
|
1490
|
+
placeholder: reference ? '已保留导入引用;输入数值可替换' : '1, 2, 1.5',
|
|
1491
|
+
onValueCommit: onCommit
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
function parseCustomValues(value) {
|
|
1495
|
+
if (!value.trim()) return;
|
|
1496
|
+
const tokens = value.split(/[\s,;,;]+/).map((item)=>item.trim()).filter(Boolean);
|
|
1497
|
+
if (!tokens.length || tokens.length > 256) return null;
|
|
1498
|
+
const values = tokens.map(Number);
|
|
1499
|
+
return values.every((item)=>Number.isFinite(item) && item >= 0) ? values : null;
|
|
1500
|
+
}
|
|
1501
|
+
function SpreadsheetTrendlineEditor({ seriesNumber, trendlines, onChange }) {
|
|
1502
|
+
const replaceTrendline = (index, change)=>{
|
|
1503
|
+
onChange(trendlines.map((trendline, candidate)=>candidate === index ? {
|
|
1504
|
+
...trendline,
|
|
1505
|
+
...change
|
|
1506
|
+
} : trendline));
|
|
1507
|
+
};
|
|
1508
|
+
return /*#__PURE__*/ jsxs("section", {
|
|
1509
|
+
className: "work-spreadsheet-trendlines",
|
|
1510
|
+
"aria-label": `系列 ${seriesNumber} 趋势线`,
|
|
1511
|
+
children: [
|
|
1512
|
+
/*#__PURE__*/ jsxs("header", {
|
|
1513
|
+
children: [
|
|
1514
|
+
/*#__PURE__*/ jsx("strong", {
|
|
1515
|
+
children: "趋势线"
|
|
1516
|
+
}),
|
|
1517
|
+
/*#__PURE__*/ jsxs("button", {
|
|
1518
|
+
type: "button",
|
|
1519
|
+
"aria-label": `添加系列 ${seriesNumber} 趋势线`,
|
|
1520
|
+
onClick: ()=>onChange([
|
|
1521
|
+
...trendlines,
|
|
1522
|
+
{
|
|
1523
|
+
type: 'linear'
|
|
1524
|
+
}
|
|
1525
|
+
]),
|
|
1526
|
+
children: [
|
|
1527
|
+
/*#__PURE__*/ jsx(Plus, {
|
|
1528
|
+
size: 11
|
|
1529
|
+
}),
|
|
1530
|
+
"添加趋势线"
|
|
1531
|
+
]
|
|
1532
|
+
})
|
|
1533
|
+
]
|
|
1534
|
+
}),
|
|
1535
|
+
!trendlines.length && /*#__PURE__*/ jsx("p", {
|
|
1536
|
+
children: "可为同一系列叠加线性、多项式或移动平均等趋势分析。"
|
|
1537
|
+
}),
|
|
1538
|
+
trendlines.map((trendline, index)=>{
|
|
1539
|
+
const trendlineNumber = index + 1;
|
|
1540
|
+
const labelPrefix = `系列 ${seriesNumber} 趋势线 ${trendlineNumber}`;
|
|
1541
|
+
const hasIntercept = void 0 !== trendline.intercept;
|
|
1542
|
+
return /*#__PURE__*/ jsxs("fieldset", {
|
|
1543
|
+
children: [
|
|
1544
|
+
/*#__PURE__*/ jsxs("legend", {
|
|
1545
|
+
children: [
|
|
1546
|
+
"趋势线 ",
|
|
1547
|
+
trendlineNumber
|
|
1548
|
+
]
|
|
1549
|
+
}),
|
|
1550
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1551
|
+
className: "work-office-field",
|
|
1552
|
+
children: [
|
|
1553
|
+
/*#__PURE__*/ jsx("span", {
|
|
1554
|
+
children: "类型"
|
|
1555
|
+
}),
|
|
1556
|
+
/*#__PURE__*/ jsx(OfficeSelect, {
|
|
1557
|
+
ariaLabel: `${labelPrefix} 类型`,
|
|
1558
|
+
value: trendline.type,
|
|
1559
|
+
options: [
|
|
1560
|
+
{
|
|
1561
|
+
value: 'linear',
|
|
1562
|
+
label: '线性'
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
value: 'exponential',
|
|
1566
|
+
label: '指数'
|
|
1567
|
+
},
|
|
1568
|
+
{
|
|
1569
|
+
value: 'logarithmic',
|
|
1570
|
+
label: '对数'
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
value: 'polynomial',
|
|
1574
|
+
label: '多项式'
|
|
1575
|
+
},
|
|
1576
|
+
{
|
|
1577
|
+
value: 'power',
|
|
1578
|
+
label: '幂'
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
value: 'movingAverage',
|
|
1582
|
+
label: '移动平均'
|
|
1583
|
+
}
|
|
1584
|
+
],
|
|
1585
|
+
onValueChange: (value)=>onChange(trendlines.map((item, candidate)=>candidate === index ? trendlineWithType(item, value) : item))
|
|
1586
|
+
})
|
|
1587
|
+
]
|
|
1588
|
+
}),
|
|
1589
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1590
|
+
className: "work-office-field",
|
|
1591
|
+
children: [
|
|
1592
|
+
/*#__PURE__*/ jsx("span", {
|
|
1593
|
+
children: "名称"
|
|
1594
|
+
}),
|
|
1595
|
+
/*#__PURE__*/ jsx(office_text_field_OfficeTextField, {
|
|
1596
|
+
"aria-label": `${labelPrefix} 名称`,
|
|
1597
|
+
value: trendline.name ?? '',
|
|
1598
|
+
maxLength: 255,
|
|
1599
|
+
placeholder: `趋势线 ${trendlineNumber}`,
|
|
1600
|
+
onChange: (event)=>replaceTrendline(index, {
|
|
1601
|
+
name: event.target.value
|
|
1602
|
+
})
|
|
1603
|
+
})
|
|
1604
|
+
]
|
|
1605
|
+
}),
|
|
1606
|
+
'polynomial' === trendline.type && /*#__PURE__*/ jsxs("div", {
|
|
1607
|
+
className: "work-office-field",
|
|
1608
|
+
children: [
|
|
1609
|
+
/*#__PURE__*/ jsx("span", {
|
|
1610
|
+
children: "阶数"
|
|
1611
|
+
}),
|
|
1612
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
1613
|
+
ariaLabel: `${labelPrefix} 阶数`,
|
|
1614
|
+
min: 2,
|
|
1615
|
+
max: 6,
|
|
1616
|
+
step: 1,
|
|
1617
|
+
value: trendline.order ?? 2,
|
|
1618
|
+
normalizeValue: (value)=>normalizeRequiredOfficeNumber(value, {
|
|
1619
|
+
integer: true,
|
|
1620
|
+
minimum: 2,
|
|
1621
|
+
maximum: 6
|
|
1622
|
+
}),
|
|
1623
|
+
onValueCommit: (order)=>replaceTrendline(index, {
|
|
1624
|
+
order
|
|
1625
|
+
})
|
|
1626
|
+
})
|
|
1627
|
+
]
|
|
1628
|
+
}),
|
|
1629
|
+
'movingAverage' === trendline.type && /*#__PURE__*/ jsxs("div", {
|
|
1630
|
+
className: "work-office-field",
|
|
1631
|
+
children: [
|
|
1632
|
+
/*#__PURE__*/ jsx("span", {
|
|
1633
|
+
children: "周期"
|
|
1634
|
+
}),
|
|
1635
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
1636
|
+
ariaLabel: `${labelPrefix} 周期`,
|
|
1637
|
+
min: 2,
|
|
1638
|
+
max: 255,
|
|
1639
|
+
step: 1,
|
|
1640
|
+
value: trendline.period ?? 2,
|
|
1641
|
+
normalizeValue: (value)=>normalizeRequiredOfficeNumber(value, {
|
|
1642
|
+
integer: true,
|
|
1643
|
+
minimum: 2,
|
|
1644
|
+
maximum: 255
|
|
1645
|
+
}),
|
|
1646
|
+
onValueCommit: (period)=>replaceTrendline(index, {
|
|
1647
|
+
period
|
|
1648
|
+
})
|
|
1649
|
+
})
|
|
1650
|
+
]
|
|
1651
|
+
}),
|
|
1652
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1653
|
+
className: "work-office-field",
|
|
1654
|
+
children: [
|
|
1655
|
+
/*#__PURE__*/ jsx("span", {
|
|
1656
|
+
children: "前推"
|
|
1657
|
+
}),
|
|
1658
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
1659
|
+
ariaLabel: `${labelPrefix} 前推`,
|
|
1660
|
+
min: 0,
|
|
1661
|
+
step: 0.1,
|
|
1662
|
+
value: trendline.forward ?? 0,
|
|
1663
|
+
normalizeValue: (value)=>normalizeRequiredOfficeNumber(value, {
|
|
1664
|
+
minimum: 0
|
|
1665
|
+
}),
|
|
1666
|
+
onValueCommit: (forward)=>replaceTrendline(index, {
|
|
1667
|
+
forward
|
|
1668
|
+
})
|
|
1669
|
+
})
|
|
1670
|
+
]
|
|
1671
|
+
}),
|
|
1672
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1673
|
+
className: "work-office-field",
|
|
1674
|
+
children: [
|
|
1675
|
+
/*#__PURE__*/ jsx("span", {
|
|
1676
|
+
children: "后推"
|
|
1677
|
+
}),
|
|
1678
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
1679
|
+
ariaLabel: `${labelPrefix} 后推`,
|
|
1680
|
+
min: 0,
|
|
1681
|
+
step: 0.1,
|
|
1682
|
+
value: trendline.backward ?? 0,
|
|
1683
|
+
normalizeValue: (value)=>normalizeRequiredOfficeNumber(value, {
|
|
1684
|
+
minimum: 0
|
|
1685
|
+
}),
|
|
1686
|
+
onValueCommit: (backward)=>replaceTrendline(index, {
|
|
1687
|
+
backward
|
|
1688
|
+
})
|
|
1689
|
+
})
|
|
1690
|
+
]
|
|
1691
|
+
}),
|
|
1692
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
1693
|
+
className: "check intercept-toggle",
|
|
1694
|
+
ariaLabel: `${labelPrefix} 固定截距`,
|
|
1695
|
+
checked: hasIntercept,
|
|
1696
|
+
onCheckedChange: (checked)=>replaceTrendline(index, {
|
|
1697
|
+
intercept: checked ? 0 : void 0
|
|
1698
|
+
}),
|
|
1699
|
+
children: "固定截距"
|
|
1700
|
+
}),
|
|
1701
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1702
|
+
className: "work-office-field",
|
|
1703
|
+
children: [
|
|
1704
|
+
/*#__PURE__*/ jsx("span", {
|
|
1705
|
+
children: "截距"
|
|
1706
|
+
}),
|
|
1707
|
+
/*#__PURE__*/ jsx(CommittedOfficeNumberField, {
|
|
1708
|
+
ariaLabel: `${labelPrefix} 截距`,
|
|
1709
|
+
step: 0.1,
|
|
1710
|
+
disabled: !hasIntercept,
|
|
1711
|
+
value: trendline.intercept ?? 0,
|
|
1712
|
+
normalizeValue: normalizeRequiredOfficeNumber,
|
|
1713
|
+
onValueCommit: (intercept)=>replaceTrendline(index, {
|
|
1714
|
+
intercept
|
|
1715
|
+
})
|
|
1716
|
+
})
|
|
1717
|
+
]
|
|
1718
|
+
}),
|
|
1719
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
1720
|
+
className: "check",
|
|
1721
|
+
ariaLabel: `${labelPrefix} 显示公式`,
|
|
1722
|
+
checked: true === trendline.displayEquation,
|
|
1723
|
+
onCheckedChange: (displayEquation)=>replaceTrendline(index, {
|
|
1724
|
+
displayEquation
|
|
1725
|
+
}),
|
|
1726
|
+
children: "显示公式"
|
|
1727
|
+
}),
|
|
1728
|
+
/*#__PURE__*/ jsx(OfficeCheckbox, {
|
|
1729
|
+
className: "check",
|
|
1730
|
+
ariaLabel: `${labelPrefix} 显示 R 方`,
|
|
1731
|
+
checked: true === trendline.displayRSquared,
|
|
1732
|
+
onCheckedChange: (displayRSquared)=>replaceTrendline(index, {
|
|
1733
|
+
displayRSquared
|
|
1734
|
+
}),
|
|
1735
|
+
children: "显示 R\xb2"
|
|
1736
|
+
}),
|
|
1737
|
+
/*#__PURE__*/ jsx("button", {
|
|
1738
|
+
type: "button",
|
|
1739
|
+
className: "remove-trendline",
|
|
1740
|
+
"aria-label": `删除${labelPrefix}`,
|
|
1741
|
+
onClick: ()=>onChange(trendlines.filter((_, candidate)=>candidate !== index)),
|
|
1742
|
+
children: /*#__PURE__*/ jsx(Trash2, {
|
|
1743
|
+
size: 12
|
|
1744
|
+
})
|
|
1745
|
+
})
|
|
1746
|
+
]
|
|
1747
|
+
}, `${seriesNumber}-${trendlineNumber}`);
|
|
1748
|
+
})
|
|
1749
|
+
]
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
function trendlineWithType(trendline, type) {
|
|
1753
|
+
const next = {
|
|
1754
|
+
...trendline,
|
|
1755
|
+
type,
|
|
1756
|
+
order: void 0,
|
|
1757
|
+
period: void 0
|
|
1758
|
+
};
|
|
1759
|
+
if ('polynomial' === type) return {
|
|
1760
|
+
...next,
|
|
1761
|
+
order: trendline.order ?? 2
|
|
1762
|
+
};
|
|
1763
|
+
if ('movingAverage' === type) return {
|
|
1764
|
+
...next,
|
|
1765
|
+
period: trendline.period ?? 2,
|
|
1766
|
+
intercept: void 0
|
|
1767
|
+
};
|
|
1768
|
+
return next;
|
|
1769
|
+
}
|
|
1770
|
+
const OFFICE_HISTORY_LIMIT = 100;
|
|
1771
|
+
function useOfficeHistory({ content, onChange, sameValue = sameOfficeHistoryValue }) {
|
|
1772
|
+
const historyRef = useRef({
|
|
1773
|
+
past: [],
|
|
1774
|
+
present: content,
|
|
1775
|
+
future: []
|
|
1776
|
+
});
|
|
1777
|
+
const applyingHistoryRef = useRef(false);
|
|
1778
|
+
const onChangeRef = useRef(onChange);
|
|
1779
|
+
const [, setVersion] = useState(0);
|
|
1780
|
+
onChangeRef.current = onChange;
|
|
1781
|
+
useEffect(()=>{
|
|
1782
|
+
const history = historyRef.current;
|
|
1783
|
+
if (applyingHistoryRef.current) {
|
|
1784
|
+
applyingHistoryRef.current = false;
|
|
1785
|
+
history.present = content;
|
|
1786
|
+
setVersion((value)=>value + 1);
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
if (sameValue(content, history.present)) {
|
|
1790
|
+
history.present = content;
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
history.past = [
|
|
1794
|
+
...history.past.slice(-(OFFICE_HISTORY_LIMIT - 1)),
|
|
1795
|
+
history.present
|
|
1796
|
+
];
|
|
1797
|
+
history.present = content;
|
|
1798
|
+
history.future = [];
|
|
1799
|
+
setVersion((value)=>value + 1);
|
|
1800
|
+
}, [
|
|
1801
|
+
content,
|
|
1802
|
+
sameValue
|
|
1803
|
+
]);
|
|
1804
|
+
const undo = useCallback(()=>{
|
|
1805
|
+
const history = historyRef.current;
|
|
1806
|
+
const previous = history.past.at(-1);
|
|
1807
|
+
if (!previous) return false;
|
|
1808
|
+
history.past = history.past.slice(0, -1);
|
|
1809
|
+
history.future = [
|
|
1810
|
+
...history.future,
|
|
1811
|
+
history.present
|
|
1812
|
+
];
|
|
1813
|
+
history.present = previous;
|
|
1814
|
+
applyingHistoryRef.current = true;
|
|
1815
|
+
setVersion((value)=>value + 1);
|
|
1816
|
+
onChangeRef.current(previous);
|
|
1817
|
+
return true;
|
|
1818
|
+
}, []);
|
|
1819
|
+
const redo = useCallback(()=>{
|
|
1820
|
+
const history = historyRef.current;
|
|
1821
|
+
const next = history.future.at(-1);
|
|
1822
|
+
if (!next) return false;
|
|
1823
|
+
history.future = history.future.slice(0, -1);
|
|
1824
|
+
history.past = [
|
|
1825
|
+
...history.past,
|
|
1826
|
+
history.present
|
|
1827
|
+
].slice(-OFFICE_HISTORY_LIMIT);
|
|
1828
|
+
history.present = next;
|
|
1829
|
+
applyingHistoryRef.current = true;
|
|
1830
|
+
setVersion((value)=>value + 1);
|
|
1831
|
+
onChangeRef.current(next);
|
|
1832
|
+
return true;
|
|
1833
|
+
}, []);
|
|
1834
|
+
return {
|
|
1835
|
+
canUndo: historyRef.current.past.length > 0,
|
|
1836
|
+
canRedo: historyRef.current.future.length > 0,
|
|
1837
|
+
undo,
|
|
1838
|
+
redo
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
function sameOfficeHistoryValue(left, right) {
|
|
1842
|
+
if (left === right) return true;
|
|
1843
|
+
if (null === left || null === right || typeof left !== typeof right) return false;
|
|
1844
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
1845
|
+
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;
|
|
1846
|
+
return left.every((value, index)=>sameOfficeHistoryValue(value, right[index]));
|
|
1847
|
+
}
|
|
1848
|
+
if ('object' != typeof left || 'object' != typeof right) return false;
|
|
1849
|
+
const leftRecord = left;
|
|
1850
|
+
const rightRecord = right;
|
|
1851
|
+
const leftKeys = Object.keys(leftRecord).filter((key)=>void 0 !== leftRecord[key]);
|
|
1852
|
+
const rightKeys = Object.keys(rightRecord).filter((key)=>void 0 !== rightRecord[key]);
|
|
1853
|
+
if (leftKeys.length !== rightKeys.length) return false;
|
|
1854
|
+
return leftKeys.every((key)=>sameOfficeHistoryValue(leftRecord[key], rightRecord[key]));
|
|
1855
|
+
}
|
|
1856
|
+
export { SpreadsheetChartSeriesStyleEditor, SpreadsheetErrorBarEditor, SpreadsheetTrendlineEditor, applyPresentationAgentProposalChanges, applySpreadsheetAgentProposalChanges, normalizeOptionalOfficeNumber, normalizeRequiredOfficeNumber, presentationAgentMenuItems, presentationAgentProposalTargets, presentationAgentSelection, presentationNotesProposalTarget, spreadsheetAgentMenuItems, spreadsheetAgentSelection, useOfficeHistory };
|