@a3s-lab/office 0.2.2 → 0.4.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/COLLABORATION_ROADMAP.md +426 -0
- package/README.md +649 -10
- package/dist/0~1403.js +1 -1
- package/dist/0~2805.js +1279 -0
- package/dist/{0~use-office-draft.js → 0~345.js} +30 -1
- package/dist/0~3539.js +1 -1
- package/dist/0~3557.js +1 -1
- package/dist/0~3635.js +1 -1
- package/dist/0~4595.js +123 -12
- package/dist/0~4980.js +154 -0
- package/dist/0~5050.js +124 -113
- package/dist/{0~9512.js → 0~6090.js} +540 -3
- package/dist/0~7048.js +92 -66
- package/dist/0~7614.js +2 -1
- package/dist/0~7754.js +5653 -0
- package/dist/0~9445.js +1 -1
- package/dist/0~document-editor.js +4992 -3323
- package/dist/0~markdown-editor.js +250 -44
- package/dist/0~pdf-viewer.js +1016 -24
- package/dist/0~presentation-editor.js +179 -8
- package/dist/0~spreadsheet-editor.js +3371 -578
- package/dist/0~work-docx-export.js +6801 -658
- package/dist/0~work-docx-import.js +1388 -795
- package/dist/0~work-office-diagnostics.js +524 -30
- package/dist/0~work-pptx-export.js +2 -1
- package/dist/0~work-pptx-import.js +1 -2
- package/dist/0~work-presentation-charts.js +1 -1
- package/dist/2591.js +197 -0
- package/dist/3818.js +1090 -0
- package/dist/4104.js +970 -60
- package/dist/432.js +171 -14
- package/dist/4476.js +2008 -0
- package/dist/4560.js +674 -0
- package/dist/4650.js +70 -0
- package/dist/{1134.js → 5184.js} +183 -1
- package/dist/6489.js +18 -18
- package/dist/7060.js +132 -0
- package/dist/8715.js +2 -136
- package/dist/8928.js +16778 -0
- package/dist/9787.js +209 -0
- package/dist/core.d.ts +29 -9
- package/dist/core.js +10 -2
- package/dist/index.js +13 -3
- package/dist/internal/collaboration/office-collaboration-flat-json.d.ts +13 -0
- package/dist/internal/collaboration/office-collaboration-json.d.ts +4 -0
- package/dist/internal/collaboration/office-collaboration-presence.d.ts +86 -0
- package/dist/internal/collaboration/office-collaboration-transport.d.ts +42 -0
- package/dist/internal/collaboration/office-collaboration.d.ts +85 -0
- package/dist/internal/collaboration/office-document-collaboration-bibliography.d.ts +7 -0
- package/dist/internal/collaboration/office-document-collaboration-claims.d.ts +9 -0
- package/dist/internal/collaboration/office-document-collaboration-comments.d.ts +7 -0
- package/dist/internal/collaboration/office-document-collaboration-sidecar-utils.d.ts +27 -0
- package/dist/internal/collaboration/office-document-collaboration-sidecars.d.ts +16 -0
- package/dist/internal/collaboration/office-document-collaboration.d.ts +45 -0
- package/dist/internal/collaboration/office-markdown-collaboration.d.ts +31 -0
- package/dist/internal/collaboration/office-pdf-collaboration-claims.d.ts +4 -0
- package/dist/internal/collaboration/office-pdf-collaboration-conflicts.d.ts +2 -0
- package/dist/internal/collaboration/office-pdf-collaboration-model.d.ts +26 -0
- package/dist/internal/collaboration/office-pdf-collaboration-records.d.ts +21 -0
- package/dist/internal/collaboration/office-pdf-collaboration-types.d.ts +91 -0
- package/dist/internal/collaboration/office-pdf-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-pdf-collaboration.d.ts +35 -0
- package/dist/internal/collaboration/office-presentation-collaboration-model.d.ts +25 -0
- package/dist/internal/collaboration/office-presentation-collaboration-records.d.ts +22 -0
- package/dist/internal/collaboration/office-presentation-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-presentation-collaboration.d.ts +32 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-cells.d.ts +13 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-claims.d.ts +4 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-conflicts.d.ts +2 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-flat-json.d.ts +10 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-model.d.ts +31 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-records.d.ts +17 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration.d.ts +32 -0
- package/dist/internal/design-system/primitives/navigation/tabs.d.ts +3 -1
- package/dist/internal/features/work/components/work-document-page-border.d.ts +6 -0
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +536 -0
- package/dist/internal/features/work/editors/document-editor-focus.d.ts +1 -1
- package/dist/internal/features/work/editors/document-editor-support.d.ts +7 -3
- package/dist/internal/features/work/editors/document-editor.d.ts +8 -2
- package/dist/internal/features/work/editors/document-external-content.d.ts +14 -0
- package/dist/internal/features/work/editors/document-format-clipboard.d.ts +6 -0
- package/dist/internal/features/work/editors/document-format-tools.d.ts +4 -0
- package/dist/internal/features/work/editors/document-layout-panel.d.ts +4 -1
- package/dist/internal/features/work/editors/document-page-chrome-wps-shortcuts.d.ts +2 -0
- package/dist/internal/features/work/editors/document-page-layout-ribbon.d.ts +14 -0
- package/dist/internal/features/work/editors/document-page-stack.d.ts +10 -1
- package/dist/internal/features/work/editors/document-page-thumbnail.d.ts +2 -0
- package/dist/internal/features/work/editors/document-pagination-run-coordinator.d.ts +26 -0
- package/dist/internal/features/work/editors/document-picture-properties-dialog-model.d.ts +20 -1
- package/dist/internal/features/work/editors/document-review-navigation.d.ts +9 -0
- package/dist/internal/features/work/editors/document-statistics-dialog.d.ts +7 -0
- package/dist/internal/features/work/editors/document-status-bar.d.ts +2 -1
- package/dist/internal/features/work/editors/document-table-properties-dialog-model.d.ts +4 -1
- package/dist/internal/features/work/editors/document-toolbar.d.ts +19 -42
- package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +12 -0
- package/dist/internal/features/work/editors/document-zoom.d.ts +17 -0
- package/dist/internal/features/work/editors/markdown-editor-focus.d.ts +1 -1
- package/dist/internal/features/work/editors/markdown-editor.d.ts +5 -1
- package/dist/internal/features/work/editors/markdown-toolbar.d.ts +2 -1
- package/dist/internal/features/work/editors/office-collaboration-participants.d.ts +3 -0
- package/dist/internal/features/work/editors/office-collaboration-presence-context.d.ts +17 -0
- package/dist/internal/features/work/editors/office-collaboration-presence-ui.d.ts +25 -0
- package/dist/internal/features/work/editors/office-editor-focus-handoff.d.ts +27 -0
- package/dist/internal/features/work/editors/pdf-annotation-controller.d.ts +5 -0
- package/dist/internal/features/work/editors/pdf-collaboration-presence.d.ts +3 -0
- package/dist/internal/features/work/editors/pdf-collaboration-projection.d.ts +10 -0
- package/dist/internal/features/work/editors/pdf-evidence-contract.d.ts +36 -0
- package/dist/internal/features/work/editors/pdf-evidence-overlay.d.ts +37 -0
- package/dist/internal/features/work/editors/pdf-toolbar.d.ts +2 -1
- package/dist/internal/features/work/editors/pdf-viewer-controller.d.ts +7 -1
- package/dist/internal/features/work/editors/pdf-viewer.d.ts +11 -1
- package/dist/internal/features/work/editors/presentation-collaboration-presence.d.ts +5 -0
- package/dist/internal/features/work/editors/presentation-editor-focus.d.ts +3 -2
- package/dist/internal/features/work/editors/presentation-editor-types.d.ts +3 -0
- package/dist/internal/features/work/editors/presentation-editor.d.ts +1 -1
- package/dist/internal/features/work/editors/spreadsheet-auto-filter.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-clear.d.ts +3 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-merge.d.ts +12 -0
- package/dist/internal/features/work/editors/spreadsheet-clipboard-shortcuts.d.ts +3 -7
- package/dist/internal/features/work/editors/spreadsheet-collaboration-presence.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +464 -0
- package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +45 -9
- package/dist/internal/features/work/editors/spreadsheet-context-menu.d.ts +2 -0
- package/dist/internal/features/work/editors/spreadsheet-editor-ribbon.d.ts +9 -28
- package/dist/internal/features/work/editors/spreadsheet-editor.d.ts +8 -2
- package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +27 -0
- package/dist/internal/features/work/editors/spreadsheet-freeze-panes.d.ts +14 -0
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +3 -2
- package/dist/internal/features/work/editors/use-document-pagination.d.ts +6 -1
- package/dist/internal/features/work/editors/use-document-review-conflicts.d.ts +28 -0
- package/dist/internal/features/work/editors/use-spreadsheet-auto-filter.d.ts +21 -0
- package/dist/internal/features/work/editors/use-spreadsheet-collaboration.d.ts +27 -0
- package/dist/internal/features/work/editors/use-spreadsheet-format-painter.d.ts +18 -0
- package/dist/internal/features/work/editors/work-office-chrome.d.ts +22 -3
- package/dist/internal/features/work/editors/work-office-ribbon-overflow.d.ts +2 -0
- package/dist/internal/features/work/work-document-bookmark-references.d.ts +37 -0
- package/dist/internal/features/work/work-document-bookmarks.d.ts +29 -0
- package/dist/internal/features/work/work-document-caption-nodes.d.ts +4 -1
- package/dist/internal/features/work/work-document-comments.d.ts +1 -1
- package/dist/internal/features/work/work-document-equations.d.ts +513 -0
- package/dist/internal/features/work/work-document-extensions.d.ts +1 -0
- package/dist/internal/features/work/work-document-field-identity.d.ts +2 -0
- package/dist/internal/features/work/work-document-field-node.d.ts +2 -2
- package/dist/internal/features/work/work-document-fields.d.ts +7 -0
- package/dist/internal/features/work/work-document-image-identity.d.ts +30 -0
- package/dist/internal/features/work/work-document-image-layout.d.ts +46 -1
- package/dist/internal/features/work/work-document-image-wrap-contour.d.ts +16 -0
- package/dist/internal/features/work/work-document-incremental-layout.d.ts +2 -2
- package/dist/internal/features/work/work-document-model-codec.d.ts +4 -1
- package/dist/internal/features/work/work-document-note-integrity.d.ts +2 -0
- package/dist/internal/features/work/work-document-page-borders.d.ts +25 -0
- package/dist/internal/features/work/work-document-page-capture.d.ts +8 -0
- package/dist/internal/features/work/work-document-page-frames.d.ts +15 -0
- package/dist/internal/features/work/work-document-page-margins.d.ts +56 -0
- package/dist/internal/features/work/work-document-page-size.d.ts +47 -0
- package/dist/internal/features/work/work-document-pagination-measurement.d.ts +1 -2
- package/dist/internal/features/work/work-document-pagination-types.d.ts +7 -2
- package/dist/internal/features/work/work-document-pagination.d.ts +2 -2
- package/dist/internal/features/work/work-document-paragraph-borders.d.ts +32 -0
- package/dist/internal/features/work/work-document-paragraph-identity.d.ts +26 -0
- package/dist/internal/features/work/work-document-paragraph-shading.d.ts +18 -0
- package/dist/internal/features/work/work-document-review-conflicts.d.ts +35 -0
- package/dist/internal/features/work/work-document-section.d.ts +4 -0
- package/dist/internal/features/work/work-document-snapshot.d.ts +19 -0
- package/dist/internal/features/work/work-document-source.d.ts +23 -0
- package/dist/internal/features/work/work-document-table-column-widths.d.ts +7 -0
- package/dist/internal/features/work/work-document-table-property-changes.d.ts +3 -0
- package/dist/internal/features/work/work-document-table-row-identity.d.ts +15 -0
- package/dist/internal/features/work/work-document-table-sizing.d.ts +3 -0
- package/dist/internal/features/work/work-document-text-layout.d.ts +3 -1
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +2 -0
- package/dist/internal/features/work/work-docx-bookmark-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-bookmark-import.d.ts +24 -0
- package/dist/internal/features/work/work-docx-bookmarks.d.ts +17 -0
- package/dist/internal/features/work/work-docx-comment-durable-id-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-comment-export.d.ts +3 -0
- package/dist/internal/features/work/work-docx-comment-metadata.d.ts +2 -0
- package/dist/internal/features/work/work-docx-drawing-extension-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-equation-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-equation-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-equation-import.d.ts +30 -0
- package/dist/internal/features/work/work-docx-equation-story.d.ts +9 -0
- package/dist/internal/features/work/work-docx-export-formatting.d.ts +3 -1
- package/dist/internal/features/work/work-docx-export-image.d.ts +5 -1
- package/dist/internal/features/work/work-docx-export.d.ts +1 -1
- package/dist/internal/features/work/work-docx-field-instructions.d.ts +8 -0
- package/dist/internal/features/work/work-docx-font-table-preservation.d.ts +3 -0
- package/dist/internal/features/work/work-docx-ignorable-extension-preservation.d.ts +15 -0
- package/dist/internal/features/work/work-docx-image-crop.d.ts +12 -0
- package/dist/internal/features/work/work-docx-image-identity.d.ts +17 -0
- package/dist/internal/features/work/work-docx-image-layer.d.ts +12 -0
- package/dist/internal/features/work/work-docx-image-layout-import.d.ts +14 -2
- package/dist/internal/features/work/work-docx-image-wrap.d.ts +15 -0
- package/dist/internal/features/work/work-docx-import.d.ts +13 -3
- package/dist/internal/features/work/work-docx-list-export.d.ts +18 -0
- package/dist/internal/features/work/work-docx-list-import.d.ts +14 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-block-preservation.d.ts +18 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-model.d.ts +47 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-properties.d.ts +17 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-table-model.d.ts +17 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-xml.d.ts +14 -0
- package/dist/internal/features/work/work-docx-note-comment-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-content.d.ts +40 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-preservation.d.ts +5 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-relationships.d.ts +35 -0
- package/dist/internal/features/work/work-docx-note-comment-identity.d.ts +15 -0
- package/dist/internal/features/work/work-docx-note-comment-run-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-note-comment-run-properties.d.ts +2 -0
- package/dist/internal/features/work/work-docx-note-image-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-note-image-relationships.d.ts +1 -0
- package/dist/internal/features/work/work-docx-numbering-extension-preservation.d.ts +6 -0
- package/dist/internal/features/work/work-docx-numbering.d.ts +1 -0
- package/dist/internal/features/work/work-docx-page-borders-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-page-borders-import.d.ts +10 -0
- package/dist/internal/features/work/work-docx-page-margins-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-page-margins-import.d.ts +18 -0
- package/dist/internal/features/work/work-docx-page-size-diagnostics.d.ts +2 -0
- package/dist/internal/features/work/work-docx-page-size-import.d.ts +17 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-export.d.ts +18 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-import.d.ts +24 -0
- package/dist/internal/features/work/work-docx-paragraph-default-collapsed.d.ts +19 -0
- package/dist/internal/features/work/work-docx-paragraph-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-paragraph-identity-import.d.ts +10 -0
- package/dist/internal/features/work/work-docx-paragraph-identity.d.ts +18 -0
- package/dist/internal/features/work/work-docx-paragraph-pagination-import.d.ts +6 -1
- package/dist/internal/features/work/work-docx-paragraph-shading-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-paragraph-shading-export.d.ts +5 -0
- package/dist/internal/features/work/work-docx-paragraph-shading-import.d.ts +18 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +3 -0
- package/dist/internal/features/work/work-docx-settings-preservation.d.ts +10 -0
- package/dist/internal/features/work/work-docx-settings-xml.d.ts +16 -0
- package/dist/internal/features/work/work-docx-style-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-cell-export.d.ts +2 -1
- package/dist/internal/features/work/work-docx-table-cell-import.d.ts +3 -0
- package/dist/internal/features/work/work-docx-table-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-row-import.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-sizing-import.d.ts +1 -0
- package/dist/internal/features/work/work-docx-theme-reference.d.ts +23 -0
- package/dist/internal/features/work/work-docx-theme.d.ts +4 -1
- package/dist/internal/features/work/work-docx-twips.d.ts +12 -0
- package/dist/internal/features/work/work-file-contract.d.ts +1 -0
- package/dist/internal/features/work/work-file-io.d.ts +1 -1
- package/dist/internal/features/work/work-markdown-extensions.d.ts +4 -1
- package/dist/internal/features/work/work-ooxml-package-preservation.d.ts +12 -0
- package/dist/internal/features/work/work-ooxml-package-security.d.ts +6 -0
- package/dist/internal/features/work/work-ooxml-relationship-preservation.d.ts +10 -0
- package/dist/internal/features/work/work-ooxml-xml.d.ts +2 -0
- package/dist/internal/features/work/work-pdf-export.d.ts +10 -0
- package/dist/internal/features/work/work-repository.d.ts +2 -0
- package/dist/internal/features/work/work-types.d.ts +15 -2
- package/dist/internal/kernel/office-kernel-client-types.d.ts +1 -0
- package/dist/internal/kernel/office-kernel-protocol.d.ts +7 -0
- package/dist/internal/kernel/office-kernel-version.d.ts +1 -1
- package/dist/office-kernel.wasm +0 -0
- package/dist/office-kernel.worker.js +93 -41
- package/dist/react.d.ts +18 -12
- package/dist/react.js +1 -1
- package/dist/styles.css +1367 -16
- package/dist/vue.d.ts +48 -5
- package/dist/vue.js +42 -3
- package/dist/web-component.d.ts +24 -2
- package/dist/web-component.js +101 -2
- package/docs/latest/en/browser-editor-architecture.md +262 -47
- package/package.json +29 -4
- package/dist/0~152.js +0 -94
- package/dist/0~2582.js +0 -485
- package/dist/0~4750.js +0 -939
- package/dist/0~5861.js +0 -596
- package/dist/0~work-document-extensions.js +0 -3045
- package/dist/0~work-document-model-codec.js +0 -42
- package/dist/0~work-docx-bibliography.js +0 -347
- package/dist/0~work-docx-page-color.js +0 -42
- package/dist/2881.js +0 -1455
- package/dist/8728.js +0 -723
package/dist/8728.js
DELETED
|
@@ -1,723 +0,0 @@
|
|
|
1
|
-
import { formatSpreadsheetCellRanges, parseSpreadsheetCellRanges } from "./8715.js";
|
|
2
|
-
const DEFAULT_PROTECTION_HINT = '此工作表已受保护。若要更改锁定的单元格,请先取消工作表保护。';
|
|
3
|
-
function defaultSheetProtectionAuthority(enabled = false) {
|
|
4
|
-
return {
|
|
5
|
-
sheet: enabled ? 1 : 0,
|
|
6
|
-
selectLockedCells: 1,
|
|
7
|
-
selectunLockedCells: 1,
|
|
8
|
-
formatCells: 0,
|
|
9
|
-
formatColumns: 0,
|
|
10
|
-
formatRows: 0,
|
|
11
|
-
insertColumns: 0,
|
|
12
|
-
insertRows: 0,
|
|
13
|
-
insertHyperlinks: 0,
|
|
14
|
-
deleteColumns: 0,
|
|
15
|
-
deleteRows: 0,
|
|
16
|
-
sort: 0,
|
|
17
|
-
filter: 0,
|
|
18
|
-
usePivotTablereports: 0,
|
|
19
|
-
editObjects: 0,
|
|
20
|
-
editScenarios: 0,
|
|
21
|
-
hintText: '',
|
|
22
|
-
defaultSheetHintText: DEFAULT_PROTECTION_HINT,
|
|
23
|
-
allowRangeList: []
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function sheetProtectionAuthority(sheet) {
|
|
27
|
-
return normalizeSheetProtectionAuthority(sheet.config?.authority);
|
|
28
|
-
}
|
|
29
|
-
function normalizeSheetProtectionAuthority(source) {
|
|
30
|
-
const defaults = defaultSheetProtectionAuthority();
|
|
31
|
-
if (!source || 'object' != typeof source) return defaults;
|
|
32
|
-
const authority = source;
|
|
33
|
-
return {
|
|
34
|
-
sheet: flag(authority.sheet, defaults.sheet),
|
|
35
|
-
selectLockedCells: flag(authority.selectLockedCells, defaults.selectLockedCells),
|
|
36
|
-
selectunLockedCells: flag(authority.selectunLockedCells, defaults.selectunLockedCells),
|
|
37
|
-
formatCells: flag(authority.formatCells, defaults.formatCells),
|
|
38
|
-
formatColumns: flag(authority.formatColumns, defaults.formatColumns),
|
|
39
|
-
formatRows: flag(authority.formatRows, defaults.formatRows),
|
|
40
|
-
insertColumns: flag(authority.insertColumns, defaults.insertColumns),
|
|
41
|
-
insertRows: flag(authority.insertRows, defaults.insertRows),
|
|
42
|
-
insertHyperlinks: flag(authority.insertHyperlinks, defaults.insertHyperlinks),
|
|
43
|
-
deleteColumns: flag(authority.deleteColumns, defaults.deleteColumns),
|
|
44
|
-
deleteRows: flag(authority.deleteRows, defaults.deleteRows),
|
|
45
|
-
sort: flag(authority.sort, defaults.sort),
|
|
46
|
-
filter: flag(authority.filter, defaults.filter),
|
|
47
|
-
usePivotTablereports: flag(authority.usePivotTablereports, defaults.usePivotTablereports),
|
|
48
|
-
editObjects: flag(authority.editObjects, defaults.editObjects),
|
|
49
|
-
editScenarios: flag(authority.editScenarios, defaults.editScenarios),
|
|
50
|
-
hintText: stringValue(authority.hintText),
|
|
51
|
-
defaultSheetHintText: stringValue(authority.defaultSheetHintText) || DEFAULT_PROTECTION_HINT,
|
|
52
|
-
allowRangeList: editableRangeList(authority.allowRangeList),
|
|
53
|
-
xlsxAttributes: stringRecord(authority.xlsxAttributes)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function withSheetProtection(sheet, enabled) {
|
|
57
|
-
const authority = sheetProtectionAuthority(sheet);
|
|
58
|
-
authority.sheet = enabled ? 1 : 0;
|
|
59
|
-
return withAuthority(sheet, authority);
|
|
60
|
-
}
|
|
61
|
-
function withSheetSelectionPermissions(sheet, permissions) {
|
|
62
|
-
const authority = sheetProtectionAuthority(sheet);
|
|
63
|
-
if (void 0 !== permissions.selectLockedCells) authority.selectLockedCells = permissions.selectLockedCells ? 1 : 0;
|
|
64
|
-
if (void 0 !== permissions.selectUnlockedCells) authority.selectunLockedCells = permissions.selectUnlockedCells ? 1 : 0;
|
|
65
|
-
return withAuthority(sheet, authority);
|
|
66
|
-
}
|
|
67
|
-
function withEditableRange(sheet, index, editableRange) {
|
|
68
|
-
const authority = sheetProtectionAuthority(sheet);
|
|
69
|
-
const nextRange = {
|
|
70
|
-
name: editableRange.name.trim(),
|
|
71
|
-
sqref: canonicalRangeReference(editableRange.sqref),
|
|
72
|
-
hintText: editableRange.hintText?.trim() || void 0,
|
|
73
|
-
xlsxAttributes: editableRange.xlsxAttributes
|
|
74
|
-
};
|
|
75
|
-
if (null !== index && authority.allowRangeList[index]) authority.allowRangeList[index] = nextRange;
|
|
76
|
-
else authority.allowRangeList.push(nextRange);
|
|
77
|
-
const ranges = parseSpreadsheetCellRanges(nextRange.sqref) ?? [];
|
|
78
|
-
return withAuthority(withCellProtection(sheet, ranges, false), authority);
|
|
79
|
-
}
|
|
80
|
-
function withoutEditableRange(sheet, index) {
|
|
81
|
-
const authority = sheetProtectionAuthority(sheet);
|
|
82
|
-
const removed = authority.allowRangeList[index];
|
|
83
|
-
if (!removed) return sheet;
|
|
84
|
-
authority.allowRangeList.splice(index, 1);
|
|
85
|
-
const removedRanges = parseSpreadsheetCellRanges(removed.sqref) ?? [];
|
|
86
|
-
let next = withCellProtection(sheet, removedRanges, true);
|
|
87
|
-
for (const editableRange of authority.allowRangeList)if (!editableRangeRequiresCredentials(editableRange)) next = withCellProtection(next, parseSpreadsheetCellRanges(editableRange.sqref) ?? [], false);
|
|
88
|
-
return withAuthority(next, authority);
|
|
89
|
-
}
|
|
90
|
-
function withCellProtection(sheet, ranges, locked, hidden = false) {
|
|
91
|
-
if (!ranges.length) return sheet;
|
|
92
|
-
const data = cloneMatrix(sheet.data);
|
|
93
|
-
let rowCount = Math.max(sheet.row ?? 0, data.length);
|
|
94
|
-
let columnCount = Math.max(sheet.column ?? 0, ...data.map((row)=>row.length));
|
|
95
|
-
for (const range of ranges){
|
|
96
|
-
rowCount = Math.max(rowCount, range.row[1] + 1);
|
|
97
|
-
columnCount = Math.max(columnCount, range.column[1] + 1);
|
|
98
|
-
for(let row = range.row[0]; row <= range.row[1]; row += 1){
|
|
99
|
-
data[row] ??= [];
|
|
100
|
-
for(let column = range.column[0]; column <= range.column[1]; column += 1){
|
|
101
|
-
const cell = {
|
|
102
|
-
...data[row][column] ?? {}
|
|
103
|
-
};
|
|
104
|
-
cell.lo = locked ? 1 : 0;
|
|
105
|
-
if (hidden) cell.hi = 1;
|
|
106
|
-
else if (void 0 !== cell.hi) delete cell.hi;
|
|
107
|
-
data[row][column] = cell;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
normalizeMatrix(data, rowCount, columnCount);
|
|
112
|
-
return {
|
|
113
|
-
...sheet,
|
|
114
|
-
row: rowCount,
|
|
115
|
-
column: columnCount,
|
|
116
|
-
data
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function applySpreadsheetCellProtectionRanges(data, ranges, rowCount, columnCount) {
|
|
120
|
-
for (const item of ranges){
|
|
121
|
-
const lastRow = Math.min(item.range.row[1], rowCount - 1);
|
|
122
|
-
const lastColumn = Math.min(item.range.column[1], columnCount - 1);
|
|
123
|
-
for(let row = Math.max(0, item.range.row[0]); row <= lastRow; row += 1){
|
|
124
|
-
data[row] ??= [];
|
|
125
|
-
for(let column = Math.max(0, item.range.column[0]); column <= lastColumn; column += 1){
|
|
126
|
-
const cell = {
|
|
127
|
-
...data[row][column] ?? {}
|
|
128
|
-
};
|
|
129
|
-
cell.lo = item.locked ? 1 : 0;
|
|
130
|
-
if (item.hidden) cell.hi = 1;
|
|
131
|
-
else if (void 0 !== cell.hi) delete cell.hi;
|
|
132
|
-
data[row][column] = cell;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function applyPasswordlessEditableRanges(data, ranges, rowCount, columnCount) {
|
|
138
|
-
const protectionRanges = ranges.filter((range)=>!editableRangeRequiresCredentials(range)).flatMap((range)=>parseSpreadsheetCellRanges(range.sqref) ?? []).map((range)=>({
|
|
139
|
-
range,
|
|
140
|
-
locked: false,
|
|
141
|
-
hidden: false
|
|
142
|
-
}));
|
|
143
|
-
applySpreadsheetCellProtectionRanges(data, protectionRanges, rowCount, columnCount);
|
|
144
|
-
}
|
|
145
|
-
function editableRangeRequiresCredentials(range) {
|
|
146
|
-
const attributes = range.xlsxAttributes ?? {};
|
|
147
|
-
return Boolean(attributes.password || attributes.hashValue || attributes.saltValue || attributes.securityDescriptor || attributes.securitydescriptor);
|
|
148
|
-
}
|
|
149
|
-
function sheetHasProtectionState(sheet) {
|
|
150
|
-
const authority = sheetProtectionAuthority(sheet);
|
|
151
|
-
if (1 === authority.sheet || authority.allowRangeList.length || Object.keys(authority.xlsxAttributes ?? {}).length) return true;
|
|
152
|
-
return (sheet.data ?? []).some((row)=>row.some((cell)=>cell?.lo !== void 0 || cell?.hi !== void 0));
|
|
153
|
-
}
|
|
154
|
-
function protectedSheetCount(sheets) {
|
|
155
|
-
return sheets.filter((sheet)=>1 === sheetProtectionAuthority(sheet).sheet).length;
|
|
156
|
-
}
|
|
157
|
-
function unlockedCellCount(sheet) {
|
|
158
|
-
return (sheet.data ?? []).reduce((total, row)=>total + row.reduce((rowTotal, cell)=>rowTotal + (cell?.lo === 0 ? 1 : 0), 0), 0);
|
|
159
|
-
}
|
|
160
|
-
function spreadsheetProtectionKey(sheets) {
|
|
161
|
-
return sheets.map((sheet)=>{
|
|
162
|
-
const authority = sheetProtectionAuthority(sheet);
|
|
163
|
-
const cells = [];
|
|
164
|
-
for (const [row, values] of (sheet.data ?? []).entries())for (const [column, cell] of values.entries()){
|
|
165
|
-
const hidden = cell?.hi;
|
|
166
|
-
if (cell?.lo !== void 0 || void 0 !== hidden) cells.push(`${row}_${column}:${cell?.lo ?? ''}:${hidden ?? ''}`);
|
|
167
|
-
}
|
|
168
|
-
return `${sheet.id ?? sheet.name}:${JSON.stringify(authority)}:${cells.join(',')}`;
|
|
169
|
-
}).join('|');
|
|
170
|
-
}
|
|
171
|
-
function editableRangeCellCount(ranges) {
|
|
172
|
-
return ranges.reduce((total, range)=>total + (range.row[1] - range.row[0] + 1) * (range.column[1] - range.column[0] + 1), 0);
|
|
173
|
-
}
|
|
174
|
-
function withAuthority(sheet, authority) {
|
|
175
|
-
return {
|
|
176
|
-
...sheet,
|
|
177
|
-
config: {
|
|
178
|
-
...sheet.config ?? {},
|
|
179
|
-
authority
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function editableRangeList(value) {
|
|
184
|
-
if (!Array.isArray(value)) return [];
|
|
185
|
-
return value.flatMap((item, index)=>{
|
|
186
|
-
if (!item || 'object' != typeof item) return [];
|
|
187
|
-
const range = item;
|
|
188
|
-
const sqref = stringValue(range.sqref);
|
|
189
|
-
if (!sqref || !parseSpreadsheetCellRanges(sqref)) return [];
|
|
190
|
-
return [
|
|
191
|
-
{
|
|
192
|
-
name: stringValue(range.name) || `Range ${index + 1}`,
|
|
193
|
-
sqref: canonicalRangeReference(sqref),
|
|
194
|
-
hintText: stringValue(range.hintText) || void 0,
|
|
195
|
-
xlsxAttributes: stringRecord(range.xlsxAttributes)
|
|
196
|
-
}
|
|
197
|
-
];
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
function canonicalRangeReference(value) {
|
|
201
|
-
const ranges = parseSpreadsheetCellRanges(value);
|
|
202
|
-
return ranges ? formatSpreadsheetCellRanges(ranges) : value.trim();
|
|
203
|
-
}
|
|
204
|
-
function cloneMatrix(source) {
|
|
205
|
-
return (source ?? []).map((row)=>[
|
|
206
|
-
...row
|
|
207
|
-
]);
|
|
208
|
-
}
|
|
209
|
-
function normalizeMatrix(data, rows, columns) {
|
|
210
|
-
while(data.length < rows)data.push([]);
|
|
211
|
-
for(let index = 0; index < data.length; index += 1){
|
|
212
|
-
const row = data[index] ?? [];
|
|
213
|
-
data[index] = row;
|
|
214
|
-
while(row.length < columns)row.push(null);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
function flag(value, fallback) {
|
|
218
|
-
if (1 === value || true === value || '1' === value) return 1;
|
|
219
|
-
if (0 === value || false === value || '0' === value) return 0;
|
|
220
|
-
return fallback;
|
|
221
|
-
}
|
|
222
|
-
function stringValue(value) {
|
|
223
|
-
return 'string' == typeof value ? value : '';
|
|
224
|
-
}
|
|
225
|
-
function stringRecord(value) {
|
|
226
|
-
if (!value || 'object' != typeof value || Array.isArray(value)) return;
|
|
227
|
-
const entries = Object.entries(value).filter((entry)=>'string' == typeof entry[1]);
|
|
228
|
-
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
229
|
-
}
|
|
230
|
-
const SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS = [
|
|
231
|
-
'greaterThan',
|
|
232
|
-
'greaterThanOrEqual',
|
|
233
|
-
'lessThan',
|
|
234
|
-
'lessThanOrEqual',
|
|
235
|
-
'equal',
|
|
236
|
-
'notEqual',
|
|
237
|
-
'between',
|
|
238
|
-
'notBetween'
|
|
239
|
-
];
|
|
240
|
-
function isSpreadsheetConditionalComparisonOperator(value) {
|
|
241
|
-
return SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS.some((operator)=>operator === value);
|
|
242
|
-
}
|
|
243
|
-
function spreadsheetConditionalComparisonNeedsUpperValue(operator) {
|
|
244
|
-
return 'between' === operator || 'notBetween' === operator;
|
|
245
|
-
}
|
|
246
|
-
const DEFAULT_DATA_BAR_MIN_LENGTH = 10;
|
|
247
|
-
const DEFAULT_DATA_BAR_MAX_LENGTH = 90;
|
|
248
|
-
function defaultSpreadsheetColorScaleThresholds(colorCount) {
|
|
249
|
-
return 3 === colorCount ? [
|
|
250
|
-
{
|
|
251
|
-
type: 'min'
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
type: 'percentile',
|
|
255
|
-
value: 50
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
type: 'max'
|
|
259
|
-
}
|
|
260
|
-
] : [
|
|
261
|
-
{
|
|
262
|
-
type: 'min'
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
type: 'max'
|
|
266
|
-
}
|
|
267
|
-
];
|
|
268
|
-
}
|
|
269
|
-
function defaultSpreadsheetDataBarOptions() {
|
|
270
|
-
return {
|
|
271
|
-
thresholds: [
|
|
272
|
-
{
|
|
273
|
-
type: 'min'
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
type: 'max'
|
|
277
|
-
}
|
|
278
|
-
],
|
|
279
|
-
showValue: true,
|
|
280
|
-
minLength: DEFAULT_DATA_BAR_MIN_LENGTH,
|
|
281
|
-
maxLength: DEFAULT_DATA_BAR_MAX_LENGTH
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
function normalizeSpreadsheetConditionalThreshold(value) {
|
|
285
|
-
if (!value || 'object' != typeof value || Array.isArray(value)) return null;
|
|
286
|
-
const source = value;
|
|
287
|
-
if (![
|
|
288
|
-
'min',
|
|
289
|
-
'max',
|
|
290
|
-
'num',
|
|
291
|
-
'percent',
|
|
292
|
-
'percentile'
|
|
293
|
-
].includes(String(source.type))) return null;
|
|
294
|
-
const type = source.type;
|
|
295
|
-
if ('min' === type || 'max' === type) return {
|
|
296
|
-
type
|
|
297
|
-
};
|
|
298
|
-
if ('number' != typeof source.value || !Number.isFinite(source.value)) return null;
|
|
299
|
-
return {
|
|
300
|
-
type,
|
|
301
|
-
value: source.value
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
function normalizeSpreadsheetConditionalVisualOptions(value, expectedThresholdCount, kind) {
|
|
305
|
-
if (!value || 'object' != typeof value || Array.isArray(value)) return null;
|
|
306
|
-
const source = value;
|
|
307
|
-
if (!Array.isArray(source.thresholds) || source.thresholds.length !== expectedThresholdCount) return null;
|
|
308
|
-
const thresholds = source.thresholds.map(normalizeSpreadsheetConditionalThreshold);
|
|
309
|
-
if (thresholds.some((threshold)=>!threshold)) return null;
|
|
310
|
-
if ('colorScale' === kind) return {
|
|
311
|
-
thresholds: thresholds
|
|
312
|
-
};
|
|
313
|
-
const minLength = source.minLength ?? DEFAULT_DATA_BAR_MIN_LENGTH;
|
|
314
|
-
const maxLength = source.maxLength ?? DEFAULT_DATA_BAR_MAX_LENGTH;
|
|
315
|
-
if ('number' != typeof minLength || !Number.isFinite(minLength) || minLength < 0 || minLength > 100 || 'number' != typeof maxLength || !Number.isFinite(maxLength) || maxLength < 0 || maxLength > 100 || minLength > maxLength) return null;
|
|
316
|
-
return {
|
|
317
|
-
thresholds: thresholds,
|
|
318
|
-
showValue: false !== source.showValue,
|
|
319
|
-
minLength,
|
|
320
|
-
maxLength
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
function spreadsheetConditionalThresholdValue(threshold, sourceValues) {
|
|
324
|
-
const values = sourceValues.filter(Number.isFinite).sort((left, right)=>left - right);
|
|
325
|
-
if (!values.length) return null;
|
|
326
|
-
const minimum = values[0];
|
|
327
|
-
const maximum = values.at(-1);
|
|
328
|
-
if ('min' === threshold.type) return minimum;
|
|
329
|
-
if ('max' === threshold.type) return maximum;
|
|
330
|
-
if ('num' === threshold.type) return threshold.value ?? null;
|
|
331
|
-
const percentage = threshold.value;
|
|
332
|
-
if (void 0 === percentage || !Number.isFinite(percentage)) return null;
|
|
333
|
-
if ('percent' === threshold.type) return minimum + (maximum - minimum) * percentage / 100;
|
|
334
|
-
const position = Math.max(0, Math.min(100, percentage)) / 100 * (values.length - 1);
|
|
335
|
-
const lower = Math.floor(position);
|
|
336
|
-
const upper = Math.ceil(position);
|
|
337
|
-
if (lower === upper) return values[lower];
|
|
338
|
-
return values[lower] + (values[upper] - values[lower]) * (position - lower);
|
|
339
|
-
}
|
|
340
|
-
function spreadsheetConditionalThresholdsEqual(left, right) {
|
|
341
|
-
return left.length === right.length && left.every((threshold, index)=>threshold.type === right[index]?.type && threshold.value === right[index]?.value);
|
|
342
|
-
}
|
|
343
|
-
const SPREADSHEET_CONDITIONAL_ICON_SETS = [
|
|
344
|
-
{
|
|
345
|
-
name: '3Arrows',
|
|
346
|
-
label: '三向彩色箭头',
|
|
347
|
-
count: 3
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
name: '3ArrowsGray',
|
|
351
|
-
label: '三向灰色箭头',
|
|
352
|
-
count: 3
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
name: '3Flags',
|
|
356
|
-
label: '三色旗帜',
|
|
357
|
-
count: 3
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
name: '3TrafficLights1',
|
|
361
|
-
label: '三色交通灯(实心)',
|
|
362
|
-
count: 3
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
name: '3TrafficLights2',
|
|
366
|
-
label: '三色交通灯(边框)',
|
|
367
|
-
count: 3
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
name: '3Signs',
|
|
371
|
-
label: '三色标志',
|
|
372
|
-
count: 3
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
name: '3Symbols',
|
|
376
|
-
label: '三色符号(圆形)',
|
|
377
|
-
count: 3
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
name: '3Symbols2',
|
|
381
|
-
label: '三色符号',
|
|
382
|
-
count: 3
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
name: '4Arrows',
|
|
386
|
-
label: '四向彩色箭头',
|
|
387
|
-
count: 4
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
name: '4ArrowsGray',
|
|
391
|
-
label: '四向灰色箭头',
|
|
392
|
-
count: 4
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
name: '4RedToBlack',
|
|
396
|
-
label: '红到黑圆点',
|
|
397
|
-
count: 4
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
name: '4Rating',
|
|
401
|
-
label: '四级评分',
|
|
402
|
-
count: 4
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
name: '4TrafficLights',
|
|
406
|
-
label: '四色交通灯',
|
|
407
|
-
count: 4
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
name: '5Arrows',
|
|
411
|
-
label: '五向彩色箭头',
|
|
412
|
-
count: 5
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
name: '5ArrowsGray',
|
|
416
|
-
label: '五向灰色箭头',
|
|
417
|
-
count: 5
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
name: '5Rating',
|
|
421
|
-
label: '五级评分',
|
|
422
|
-
count: 5
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
name: '5Quarters',
|
|
426
|
-
label: '五级圆饼',
|
|
427
|
-
count: 5
|
|
428
|
-
}
|
|
429
|
-
];
|
|
430
|
-
const COLOR_3 = [
|
|
431
|
-
'#c62828',
|
|
432
|
-
'#f9a825',
|
|
433
|
-
'#2e7d32'
|
|
434
|
-
];
|
|
435
|
-
const COLOR_4 = [
|
|
436
|
-
'#c62828',
|
|
437
|
-
'#ef6c00',
|
|
438
|
-
'#7cb342',
|
|
439
|
-
'#2e7d32'
|
|
440
|
-
];
|
|
441
|
-
const COLOR_5 = [
|
|
442
|
-
'#c62828',
|
|
443
|
-
'#ef6c00',
|
|
444
|
-
'#f9a825',
|
|
445
|
-
'#7cb342',
|
|
446
|
-
'#2e7d32'
|
|
447
|
-
];
|
|
448
|
-
function isSpreadsheetConditionalIconSetName(value) {
|
|
449
|
-
return SPREADSHEET_CONDITIONAL_ICON_SETS.some((item)=>item.name === value);
|
|
450
|
-
}
|
|
451
|
-
function spreadsheetConditionalIconSetCount(iconSet) {
|
|
452
|
-
return SPREADSHEET_CONDITIONAL_ICON_SETS.find((item)=>item.name === iconSet).count;
|
|
453
|
-
}
|
|
454
|
-
function defaultSpreadsheetConditionalIconThresholds(iconSet) {
|
|
455
|
-
const count = spreadsheetConditionalIconSetCount(iconSet);
|
|
456
|
-
return Array.from({
|
|
457
|
-
length: count
|
|
458
|
-
}, (_, index)=>0 === index ? {
|
|
459
|
-
type: 'min',
|
|
460
|
-
gte: true
|
|
461
|
-
} : {
|
|
462
|
-
type: 'percent',
|
|
463
|
-
value: Math.round(100 * index / count),
|
|
464
|
-
gte: true
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
function normalizeSpreadsheetConditionalIconSetFormat(value) {
|
|
468
|
-
if (!value || 'object' != typeof value || Array.isArray(value)) return null;
|
|
469
|
-
const source = value;
|
|
470
|
-
if (!isSpreadsheetConditionalIconSetName(source.iconSet) || !Array.isArray(source.thresholds)) return null;
|
|
471
|
-
const count = spreadsheetConditionalIconSetCount(source.iconSet);
|
|
472
|
-
if (source.thresholds.length !== count) return null;
|
|
473
|
-
const thresholds = source.thresholds.map(normalizeThreshold);
|
|
474
|
-
if (thresholds.some((threshold)=>!threshold)) return null;
|
|
475
|
-
return {
|
|
476
|
-
iconSet: source.iconSet,
|
|
477
|
-
showValue: false !== source.showValue,
|
|
478
|
-
reverse: true === source.reverse,
|
|
479
|
-
percent: false !== source.percent,
|
|
480
|
-
thresholds: thresholds
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
function spreadsheetConditionalIconForValue(sourceFormat, value, sourceValues) {
|
|
484
|
-
const format = normalizeSpreadsheetConditionalIconSetFormat(sourceFormat);
|
|
485
|
-
const values = sourceValues.filter(Number.isFinite);
|
|
486
|
-
if (!format || !Number.isFinite(value) || !values.length) return null;
|
|
487
|
-
const count = spreadsheetConditionalIconSetCount(format.iconSet);
|
|
488
|
-
let level = 0;
|
|
489
|
-
for(let index = 1; index < count; index += 1){
|
|
490
|
-
const threshold = format.thresholds[index];
|
|
491
|
-
const cutoff = spreadsheetConditionalThresholdValue(threshold, values);
|
|
492
|
-
if (null === cutoff) return null;
|
|
493
|
-
if (threshold.gte ? value >= cutoff : value > cutoff) level = index;
|
|
494
|
-
}
|
|
495
|
-
return {
|
|
496
|
-
iconSet: format.iconSet,
|
|
497
|
-
index: format.reverse ? count - 1 - level : level,
|
|
498
|
-
count,
|
|
499
|
-
showValue: format.showValue
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
function spreadsheetConditionalIconAppearance(icon) {
|
|
503
|
-
const index = Math.max(0, Math.min(icon.count - 1, icon.index));
|
|
504
|
-
const definition = SPREADSHEET_CONDITIONAL_ICON_SETS.find((item)=>item.name === icon.iconSet);
|
|
505
|
-
const label = `${definition.label} ${index + 1}/${icon.count}`;
|
|
506
|
-
if (icon.iconSet.includes('Arrows')) {
|
|
507
|
-
const glyphs = 3 === icon.count ? [
|
|
508
|
-
'↓',
|
|
509
|
-
'→',
|
|
510
|
-
'↑'
|
|
511
|
-
] : 4 === icon.count ? [
|
|
512
|
-
'↓',
|
|
513
|
-
'↘',
|
|
514
|
-
'↗',
|
|
515
|
-
'↑'
|
|
516
|
-
] : [
|
|
517
|
-
'↓',
|
|
518
|
-
'↘',
|
|
519
|
-
'→',
|
|
520
|
-
'↗',
|
|
521
|
-
'↑'
|
|
522
|
-
];
|
|
523
|
-
return {
|
|
524
|
-
glyph: glyphs[index],
|
|
525
|
-
color: icon.iconSet.includes('Gray') ? '#606a78' : palette(icon.count)[index],
|
|
526
|
-
label
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
if ('3Flags' === icon.iconSet) return {
|
|
530
|
-
glyph: '⚑',
|
|
531
|
-
color: COLOR_3[index],
|
|
532
|
-
label
|
|
533
|
-
};
|
|
534
|
-
if (icon.iconSet.includes('TrafficLights')) return {
|
|
535
|
-
glyph: '3TrafficLights2' === icon.iconSet ? '◉' : '●',
|
|
536
|
-
color: palette(icon.count)[index],
|
|
537
|
-
label
|
|
538
|
-
};
|
|
539
|
-
if ('3Signs' === icon.iconSet) return {
|
|
540
|
-
glyph: [
|
|
541
|
-
'◆',
|
|
542
|
-
'▲',
|
|
543
|
-
'●'
|
|
544
|
-
][index],
|
|
545
|
-
color: COLOR_3[index],
|
|
546
|
-
label
|
|
547
|
-
};
|
|
548
|
-
if ('3Symbols' === icon.iconSet || '3Symbols2' === icon.iconSet) return {
|
|
549
|
-
glyph: [
|
|
550
|
-
'✕',
|
|
551
|
-
'!',
|
|
552
|
-
'✓'
|
|
553
|
-
][index],
|
|
554
|
-
color: COLOR_3[index],
|
|
555
|
-
label
|
|
556
|
-
};
|
|
557
|
-
if ('4RedToBlack' === icon.iconSet) return {
|
|
558
|
-
glyph: '●',
|
|
559
|
-
color: [
|
|
560
|
-
'#c62828',
|
|
561
|
-
'#e45b4f',
|
|
562
|
-
'#697386',
|
|
563
|
-
'#111827'
|
|
564
|
-
][index],
|
|
565
|
-
label
|
|
566
|
-
};
|
|
567
|
-
if ('4Rating' === icon.iconSet) return {
|
|
568
|
-
glyph: [
|
|
569
|
-
'▁',
|
|
570
|
-
'▃',
|
|
571
|
-
'▆',
|
|
572
|
-
'█'
|
|
573
|
-
][index],
|
|
574
|
-
color: '#54708f',
|
|
575
|
-
label
|
|
576
|
-
};
|
|
577
|
-
if ('5Rating' === icon.iconSet) return {
|
|
578
|
-
glyph: [
|
|
579
|
-
'▁',
|
|
580
|
-
'▂',
|
|
581
|
-
'▄',
|
|
582
|
-
'▆',
|
|
583
|
-
'█'
|
|
584
|
-
][index],
|
|
585
|
-
color: '#54708f',
|
|
586
|
-
label
|
|
587
|
-
};
|
|
588
|
-
return {
|
|
589
|
-
glyph: [
|
|
590
|
-
'○',
|
|
591
|
-
'◔',
|
|
592
|
-
'◑',
|
|
593
|
-
'◕',
|
|
594
|
-
'●'
|
|
595
|
-
][index],
|
|
596
|
-
color: '#54708f',
|
|
597
|
-
label
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
function drawSpreadsheetConditionalIcon(context, bounds, icon, background, maskValue = !icon.showValue) {
|
|
601
|
-
const width = bounds.endX - bounds.startX;
|
|
602
|
-
const height = bounds.endY - bounds.startY;
|
|
603
|
-
if (width < 6 || height < 6) return;
|
|
604
|
-
const appearance = spreadsheetConditionalIconAppearance(icon);
|
|
605
|
-
context.save();
|
|
606
|
-
context.beginPath();
|
|
607
|
-
context.rect(bounds.startX + 1, bounds.startY + 1, Math.max(0, width - 3), Math.max(0, height - 3));
|
|
608
|
-
context.clip();
|
|
609
|
-
if (maskValue) {
|
|
610
|
-
context.fillStyle = background;
|
|
611
|
-
context.fillRect(bounds.startX + 1, bounds.startY + 1, Math.max(0, width - 3), Math.max(0, height - 3));
|
|
612
|
-
}
|
|
613
|
-
const size = Math.max(9, Math.min(16, height - 5));
|
|
614
|
-
context.fillStyle = appearance.color;
|
|
615
|
-
context.font = `700 ${size}px "Arial Unicode MS", "Segoe UI Symbol", sans-serif`;
|
|
616
|
-
context.textAlign = 'left';
|
|
617
|
-
context.textBaseline = 'middle';
|
|
618
|
-
context.fillText(appearance.glyph, bounds.startX + 4, bounds.startY + height / 2);
|
|
619
|
-
context.restore();
|
|
620
|
-
}
|
|
621
|
-
function normalizeThreshold(value) {
|
|
622
|
-
if (!value || 'object' != typeof value || Array.isArray(value)) return null;
|
|
623
|
-
const source = value;
|
|
624
|
-
const threshold = normalizeSpreadsheetConditionalThreshold(source);
|
|
625
|
-
return threshold ? {
|
|
626
|
-
...threshold,
|
|
627
|
-
gte: false !== source.gte
|
|
628
|
-
} : null;
|
|
629
|
-
}
|
|
630
|
-
function palette(count) {
|
|
631
|
-
if (3 === count) return COLOR_3;
|
|
632
|
-
if (4 === count) return COLOR_4;
|
|
633
|
-
return COLOR_5;
|
|
634
|
-
}
|
|
635
|
-
function effectiveSpreadsheetHeaderFooterSections(sections) {
|
|
636
|
-
return {
|
|
637
|
-
left: sections?.left ?? '',
|
|
638
|
-
center: sections?.center ?? '',
|
|
639
|
-
right: sections?.right ?? ''
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
const DEFAULT_MARGINS = {
|
|
643
|
-
top: 19.05,
|
|
644
|
-
right: 17.78,
|
|
645
|
-
bottom: 19.05,
|
|
646
|
-
left: 17.78,
|
|
647
|
-
header: 7.62,
|
|
648
|
-
footer: 7.62
|
|
649
|
-
};
|
|
650
|
-
const PAPER_DIMENSIONS = {
|
|
651
|
-
a3: {
|
|
652
|
-
width: 297,
|
|
653
|
-
height: 420
|
|
654
|
-
},
|
|
655
|
-
a4: {
|
|
656
|
-
width: 210,
|
|
657
|
-
height: 297
|
|
658
|
-
},
|
|
659
|
-
a5: {
|
|
660
|
-
width: 148,
|
|
661
|
-
height: 210
|
|
662
|
-
},
|
|
663
|
-
letter: {
|
|
664
|
-
width: 215.9,
|
|
665
|
-
height: 279.4
|
|
666
|
-
},
|
|
667
|
-
legal: {
|
|
668
|
-
width: 215.9,
|
|
669
|
-
height: 355.6
|
|
670
|
-
},
|
|
671
|
-
tabloid: {
|
|
672
|
-
width: 279.4,
|
|
673
|
-
height: 431.8
|
|
674
|
-
}
|
|
675
|
-
};
|
|
676
|
-
PAPER_DIMENSIONS.a4.height, DEFAULT_MARGINS.left, DEFAULT_MARGINS.right;
|
|
677
|
-
PAPER_DIMENSIONS.a4.width, DEFAULT_MARGINS.top, DEFAULT_MARGINS.bottom;
|
|
678
|
-
function effectiveSpreadsheetPageSetup(pageSetup) {
|
|
679
|
-
return {
|
|
680
|
-
paperSize: normalizeSpreadsheetPaperSize(pageSetup?.paperSize),
|
|
681
|
-
orientation: pageSetup?.orientation === 'portrait' ? 'portrait' : 'landscape',
|
|
682
|
-
scale: boundedInteger(pageSetup?.scale, 10, 400, 100),
|
|
683
|
-
fitToPage: Boolean(pageSetup?.fitToPage),
|
|
684
|
-
fitToWidth: boundedInteger(pageSetup?.fitToWidth, 0, 32767, 1),
|
|
685
|
-
fitToHeight: boundedInteger(pageSetup?.fitToHeight, 0, 32767, 0),
|
|
686
|
-
horizontalCentered: Boolean(pageSetup?.horizontalCentered),
|
|
687
|
-
verticalCentered: Boolean(pageSetup?.verticalCentered),
|
|
688
|
-
header: effectiveSpreadsheetHeaderFooterSections(pageSetup?.header),
|
|
689
|
-
footer: effectiveSpreadsheetHeaderFooterSections(pageSetup?.footer),
|
|
690
|
-
pageNumberStart: boundedInteger(pageSetup?.pageNumberStart, 1, 32767, 1),
|
|
691
|
-
pageOrder: pageSetup?.pageOrder === 'downThenOver' ? 'downThenOver' : 'overThenDown',
|
|
692
|
-
scaleWithDocument: pageSetup?.scaleWithDocument !== false,
|
|
693
|
-
alignWithMargins: pageSetup?.alignWithMargins !== false,
|
|
694
|
-
margins: {
|
|
695
|
-
top: boundedNumber(pageSetup?.margins?.top, 0, 100, DEFAULT_MARGINS.top),
|
|
696
|
-
right: boundedNumber(pageSetup?.margins?.right, 0, 100, DEFAULT_MARGINS.right),
|
|
697
|
-
bottom: boundedNumber(pageSetup?.margins?.bottom, 0, 100, DEFAULT_MARGINS.bottom),
|
|
698
|
-
left: boundedNumber(pageSetup?.margins?.left, 0, 100, DEFAULT_MARGINS.left),
|
|
699
|
-
header: boundedNumber(pageSetup?.margins?.header, 0, 100, DEFAULT_MARGINS.header),
|
|
700
|
-
footer: boundedNumber(pageSetup?.margins?.footer, 0, 100, DEFAULT_MARGINS.footer)
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
function normalizeSpreadsheetPaperSize(value) {
|
|
705
|
-
switch(value){
|
|
706
|
-
case 'a3':
|
|
707
|
-
case 'a4':
|
|
708
|
-
case 'a5':
|
|
709
|
-
case 'letter':
|
|
710
|
-
case 'legal':
|
|
711
|
-
case 'tabloid':
|
|
712
|
-
return value;
|
|
713
|
-
default:
|
|
714
|
-
return 'a4';
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
function boundedInteger(value, minimum, maximum, fallback) {
|
|
718
|
-
return Math.trunc(boundedNumber(value, minimum, maximum, fallback));
|
|
719
|
-
}
|
|
720
|
-
function boundedNumber(value, minimum, maximum, fallback) {
|
|
721
|
-
return 'number' == typeof value && Number.isFinite(value) && value >= minimum && value <= maximum ? value : fallback;
|
|
722
|
-
}
|
|
723
|
-
export { DEFAULT_PROTECTION_HINT, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, SPREADSHEET_CONDITIONAL_ICON_SETS, applyPasswordlessEditableRanges, applySpreadsheetCellProtectionRanges, defaultSpreadsheetColorScaleThresholds, defaultSpreadsheetConditionalIconThresholds, defaultSpreadsheetDataBarOptions, drawSpreadsheetConditionalIcon, editableRangeCellCount, editableRangeRequiresCredentials, effectiveSpreadsheetPageSetup, isSpreadsheetConditionalComparisonOperator, isSpreadsheetConditionalIconSetName, normalizeSheetProtectionAuthority, normalizeSpreadsheetConditionalIconSetFormat, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetPaperSize, protectedSheetCount, sheetHasProtectionState, sheetProtectionAuthority, spreadsheetConditionalComparisonNeedsUpperValue, spreadsheetConditionalIconForValue, spreadsheetConditionalIconSetCount, spreadsheetConditionalThresholdValue, spreadsheetConditionalThresholdsEqual, spreadsheetProtectionKey, unlockedCellCount, withEditableRange, withSheetProtection, withSheetSelectionPermissions, withoutEditableRange };
|