@a3s-lab/office 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -2
- package/dist/0~4595.js +16 -2
- package/dist/0~5093.js +563 -201
- package/dist/0~6090.js +77 -77
- package/dist/{0~2805.js → 0~7043.js} +305 -2
- package/dist/0~document-editor.js +2633 -976
- package/dist/0~spreadsheet-editor.js +1324 -378
- package/dist/0~work-docx-export.js +737 -17
- package/dist/0~work-docx-import.js +173 -98
- package/dist/0~work-office-diagnostics.js +250 -5
- package/dist/{164.js → 1544.js} +1083 -785
- package/dist/4104.js +145 -29
- package/dist/5184.js +13 -0
- package/dist/6282.js +1898 -345
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +102 -0
- package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +111 -0
- package/dist/internal/features/work/editors/document-font-dialog-script-font-model.d.ts +18 -0
- package/dist/internal/features/work/editors/document-font-dialog.d.ts +9 -0
- package/dist/internal/features/work/editors/document-home-ribbon.d.ts +2 -1
- package/dist/internal/features/work/editors/document-page-chrome-editor.d.ts +6 -0
- package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
- package/dist/internal/features/work/editors/document-strike-ribbon.d.ts +7 -0
- package/dist/internal/features/work/editors/document-text-case-ribbon.d.ts +4 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
- package/dist/internal/features/work/editors/document-underline-ribbon.d.ts +9 -0
- package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +1 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-fill-format.d.ts +11 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-format.d.ts +2 -1
- package/dist/internal/features/work/editors/spreadsheet-format-cells-dialog-model.d.ts +13 -2
- package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-panel.d.ts +13 -0
- package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-preview.d.ts +6 -0
- package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +1 -1
- package/dist/internal/features/work/editors/work-office-chrome.d.ts +9 -1
- package/dist/internal/features/work/work-document-character-formatting.d.ts +16 -1
- package/dist/internal/features/work/work-document-character-position.d.ts +9 -0
- package/dist/internal/features/work/work-document-character-scale.d.ts +8 -0
- package/dist/internal/features/work/work-document-character-spacing.d.ts +8 -0
- package/dist/internal/features/work/work-document-emphasis.d.ts +7 -0
- package/dist/internal/features/work/work-document-equations.d.ts +2 -1
- package/dist/internal/features/work/work-document-format-changes.d.ts +20 -2
- package/dist/internal/features/work/work-document-hidden-text.d.ts +5 -0
- package/dist/internal/features/work/work-document-kerning.d.ts +10 -0
- package/dist/internal/features/work/work-document-legacy-text-effects.d.ts +27 -0
- package/dist/internal/features/work/work-document-script-font-extension.d.ts +2 -0
- package/dist/internal/features/work/work-document-script-fonts.d.ts +51 -0
- package/dist/internal/features/work/work-document-strike.d.ts +21 -0
- package/dist/internal/features/work/work-document-text-case.d.ts +10 -0
- package/dist/internal/features/work/work-document-underline.d.ts +37 -0
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +16 -0
- package/dist/internal/features/work/work-docx-character-position.d.ts +2 -0
- package/dist/internal/features/work/work-docx-character-scale.d.ts +2 -0
- package/dist/internal/features/work/work-docx-character-spacing.d.ts +4 -0
- package/dist/internal/features/work/work-docx-emphasis-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-emphasis.d.ts +14 -0
- package/dist/internal/features/work/work-docx-hidden-text-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-hidden-text-export.d.ts +17 -0
- package/dist/internal/features/work/work-docx-hidden-text.d.ts +11 -0
- package/dist/internal/features/work/work-docx-kerning-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-kerning.d.ts +14 -0
- package/dist/internal/features/work/work-docx-legacy-text-effects-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-legacy-text-effects-export.d.ts +18 -0
- package/dist/internal/features/work/work-docx-legacy-text-effects.d.ts +12 -0
- package/dist/internal/features/work/work-docx-run-fonts-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-run-fonts-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-run-fonts.d.ts +13 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +27 -2
- package/dist/internal/features/work/work-docx-run-property-order.d.ts +2 -0
- package/dist/internal/features/work/work-docx-run-script-font-import.d.ts +9 -0
- package/dist/internal/features/work/work-docx-strike.d.ts +8 -0
- package/dist/internal/features/work/work-docx-theme-reference.d.ts +1 -1
- package/dist/internal/features/work/work-docx-twips.d.ts +6 -0
- package/dist/internal/features/work/work-docx-underline.d.ts +3 -0
- package/dist/internal/features/work/work-spreadsheet-gradient-fill-canvas.d.ts +10 -0
- package/dist/internal/features/work/work-spreadsheet-native-fill-canvas.d.ts +8 -0
- package/dist/internal/features/work/work-spreadsheet-pattern-fill-canvas.d.ts +8 -0
- package/dist/internal/features/work/work-xlsx-cell-style-origin.d.ts +2 -1
- package/dist/internal/features/work/work-xlsx-cell-style-writer.d.ts +3 -0
- package/dist/internal/features/work/work-xlsx-cell-styles.d.ts +4 -0
- package/dist/internal/features/work/work-xlsx-gradient-fill.d.ts +31 -0
- package/dist/internal/features/work/work-xlsx-native-fill.d.ts +17 -0
- package/dist/internal/features/work/work-xlsx-pattern-fill.d.ts +21 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +809 -78
- package/docs/latest/en/browser-editor-architecture.md +24 -0
- package/package.json +35 -1
package/dist/4104.js
CHANGED
|
@@ -5,7 +5,7 @@ import { OFFICE_COLLABORATION_PROTOCOL as WORK_OFFICE_COLLABORATION_PROTOCOL, Of
|
|
|
5
5
|
import { contentTypeForPart, directChildren, bytesToDataUrl, OoxmlPackage as work_ooxml_package_OoxmlPackage, parseXml, firstDescendant, xmlNamespacePrefix, descendants, directChild, createArtifact as createWorkArtifact, xmlContainsAnyElement, createOfficeId as createWorkId, attribute as work_ooxml_package_attribute } from "./5184.js";
|
|
6
6
|
import { mountWorkLiveDocumentCapture, materializeWorkDocumentContent as work_document_model_codec_materializeWorkDocumentContent, documentPageSurfaceGeometryForElement, createWorkDocumentModel, documentContentLayoutProperties, documentModelForContent, createWorkDocumentExtensions, positionWorkLiveDocumentCapture } from "./6282.js";
|
|
7
7
|
import { normalizeWorkSpreadsheetDataLabels, workSpreadsheetChartSupportsGrouping, normalizeSpreadsheetPrintArea, normalizeWorkSpreadsheetChartLegendPosition, formatSpreadsheetCellRanges, spreadsheetCellAddress, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetFormulaRangeForCell, normalizeWorkSpreadsheetChartColor, readXlsxDrawingAnchor, sparseArrayEntries, qualifySpreadsheetRange, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, normalizeSpreadsheetPrintTitleRows, normalizeSpreadsheetPrintTitleColumns, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, stripSpreadsheetSheetQualifier, normalizeWorkSpreadsheetChartLegendOverlay, normalizeWorkSpreadsheetChartGapWidth, normalizeWorkSpreadsheetChartGrouping, workSpreadsheetChartSupportsBarSpacing, workSpreadsheetChartSupportsSmoothLines, workSpreadsheetChartGroupingIsStacked, xlsxDrawingAnchorToBounds, xlsxTwoCellAnchorMarkers, workSpreadsheetChartSupportsErrorBars, sparseMatrixColumnCount, refreshSpreadsheetPivotTables, normalizeWorkSpreadsheetChartAxisGroup, isValidSpreadsheetDefinedName, normalizeWorkSpreadsheetScatterStyle, workSpreadsheetChartAxisDefaultLabelPosition, spreadsheetPivotValidation, resolveSpreadsheetChart, parseSpreadsheetCellRanges, workSpreadsheetChartAxisIsCategoryAxis, spreadsheetPivotFields, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartAxes, parseSpreadsheetPrintTitles, spreadsheetFormulaRangeConflict, spreadsheetFormulaForXlsx, editableSpreadsheetFormula, workSpreadsheetChartUsesNumericXAxis, normalizeWorkSpreadsheetChartOverlap, workSpreadsheetChartSupportsAxes, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, normalizeWorkSpreadsheetCombinationSeriesType, effectiveSpreadsheetCalculationSettings, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetRadarStyle } from "./8715.js";
|
|
8
|
-
import { freezeImportedSpreadsheetCell,
|
|
8
|
+
import { freezeImportedSpreadsheetCell, readXlsxGradientFill, withXlsxPatternFill, xlsxCellStyleOriginSemanticColors, setXlsxToggleChild, work_xlsx_cell_style_values_xlsxBooleanAttribute, spreadsheetCellValueWithDiagonalBorder, xlsxRichTextCellText, xlsxColorElementMatchesOrigin, ensureXlsxStyleCollection, xlsxSemanticColorOriginKey, applyImportedXlsxRichText, hasXlsxDirectFontStyle, isSpreadsheetConditionalComparisonOperator, xlsxStyleCollectionIndex, spreadsheetExplicitTextOrientationFromCell, readXlsxSemanticColorOrigin, activeXlsxNativeFill, defaultSpreadsheetConditionalIconThresholds, DEFAULT_PROTECTION_HINT, sheetHasXlsxRichTextCells, normalizeSpreadsheetDateValidationBoundary, createXlsxColorResolver, resolveXlsxColor, setXlsxBorderLine, xlsxAlignmentMatches, xlsxBorderLineMatches, xlsxNativeFillKey, defaultXlsxBorder, editableRangeRequiresCredentials, spreadsheetDateValidationFormula, defaultSpreadsheetColorScaleThresholds, writeXlsxAlignment, xlsxGradientFillKey, applyXlsxSemanticColorOrigin, spreadsheetUnderlineCellValueFromXlsx, xlsxWorksheetCellEntries, defaultXlsxFill, spreadsheetConditionalThresholdsEqual, spreadsheetUnderlineCellValueFromSheetJs, xlsxColorMatches, withXlsxCellStyleOrigin, normalizeSpreadsheetPaperSize, normalizeSpreadsheetConditionalVisualOptions, xlsxRichTextStyleOrigins, withXlsxGradientFill, xlsxCellStyleOrigin, directXlsxAlignment, readXlsxPatternFill, spreadsheetTextOrientationFromXlsx, directXlsxFontStyle, registerImportedSpreadsheetMatrix, setXlsxUnderlineChild, readXlsxRichTextCells, xlsxGradientFillFallbackColor, setXlsxColorChild, createXlsxRichTextReadContext, spreadsheetTextOrientationCellStyle, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, prepareXlsxSemanticPalette, normalizeSheetProtectionAuthority, importedSheetProtectionAuthority, spreadsheetDiagonalBorderFromCellValue, xlsxRgbColor, xlsxUnderlineStyle, sheetHasProtectionState, spreadsheetConditionalComparisonNeedsUpperValue, xlsxToggleEnabled, writeXlsxRichTextCells, activeXlsxSemanticColorOrigin, xlsxNativeFillSemanticColors, isSpreadsheetConditionalIconSetName, setXlsxValueChild, spreadsheetConditionalIconSetCount } from "./1544.js";
|
|
9
9
|
import { WorkFileImportController, materializeWorkFileSource } from "./9356.js";
|
|
10
10
|
import "./2591.js";
|
|
11
11
|
import "./3818.js";
|
|
@@ -3385,7 +3385,7 @@ class XlsxDirectCellStyleWriter {
|
|
|
3385
3385
|
const baseBorderId = xlsxStyleCollectionIndex(this.borders, 'border', work_ooxml_package_attribute(base, 'borderId'));
|
|
3386
3386
|
const origin = xlsxCellStyleOrigin(cell);
|
|
3387
3387
|
const fontId = this.fontId(baseFontId, cell, origin?.fontColor);
|
|
3388
|
-
const fillId = this.fillId(baseFillId, cell, origin?.fillColor);
|
|
3388
|
+
const fillId = this.fillId(baseFillId, cell, origin?.fillColor, activeXlsxNativeFill(cell));
|
|
3389
3389
|
const borderId = this.borderId(baseBorderId, border, origin?.borderColors);
|
|
3390
3390
|
const alignment = directXlsxAlignment(cell);
|
|
3391
3391
|
const alignmentChanged = Boolean(alignment && !xlsxAlignmentMatches(base, alignment));
|
|
@@ -3448,26 +3448,43 @@ class XlsxDirectCellStyleWriter {
|
|
|
3448
3448
|
this.updateCounts();
|
|
3449
3449
|
return index;
|
|
3450
3450
|
}
|
|
3451
|
-
fillId(baseFillId, cell, colorOrigin) {
|
|
3452
|
-
if (
|
|
3453
|
-
const
|
|
3454
|
-
if (!
|
|
3451
|
+
fillId(baseFillId, cell, colorOrigin, nativeFill) {
|
|
3452
|
+
if (nativeFill?.kind === 'gradient') return this.gradientFillId(baseFillId, nativeFill.value);
|
|
3453
|
+
const patternFill = nativeFill?.kind === 'pattern' ? nativeFill.value : void 0;
|
|
3454
|
+
if (!patternFill && void 0 === cell.bg) return baseFillId;
|
|
3455
|
+
const solidColor = patternFill ? null : xlsxRgbColor(cell.bg);
|
|
3456
|
+
if (!patternFill && !solidColor) return baseFillId;
|
|
3455
3457
|
const fills = directChildren(this.fills, 'fill');
|
|
3456
3458
|
const baseIndex = fills[baseFillId] ? baseFillId : 0;
|
|
3457
3459
|
const basePattern = directChild(fills[baseIndex], 'patternFill');
|
|
3458
|
-
const
|
|
3459
|
-
|
|
3460
|
-
const
|
|
3460
|
+
const foregroundColor = patternFill?.foregroundColor ?? solidColor;
|
|
3461
|
+
const backgroundColor = patternFill?.backgroundColor;
|
|
3462
|
+
const patternType = patternFill?.patternType ?? 'solid';
|
|
3463
|
+
const foregroundOrigin = activeXlsxSemanticColorOrigin(patternFill?.foregroundColorOrigin ?? colorOrigin, foregroundColor, this.semanticPalette);
|
|
3464
|
+
const backgroundOrigin = patternFill ? activeXlsxSemanticColorOrigin(patternFill.backgroundColorOrigin, patternFill.backgroundColor, this.semanticPalette) : void 0;
|
|
3465
|
+
if (work_ooxml_package_attribute(basePattern ?? fills[baseIndex], 'patternType') === patternType && (foregroundOrigin ? xlsxColorElementMatchesOrigin(directChild(basePattern ?? fills[baseIndex], 'fgColor'), foregroundOrigin) : xlsxColorMatches(directChild(basePattern ?? fills[baseIndex], 'fgColor'), foregroundColor, this.colors, '#000000')) && (!patternFill || (backgroundOrigin ? xlsxColorElementMatchesOrigin(directChild(basePattern ?? fills[baseIndex], 'bgColor'), backgroundOrigin) : xlsxColorMatches(directChild(basePattern ?? fills[baseIndex], 'bgColor'), backgroundColor, this.colors, '#ffffff')))) return baseIndex;
|
|
3466
|
+
const key = patternFill ? xlsxNativeFillKey({
|
|
3467
|
+
kind: 'pattern',
|
|
3468
|
+
value: {
|
|
3469
|
+
backgroundColor: patternFill.backgroundColor,
|
|
3470
|
+
...backgroundOrigin ? {
|
|
3471
|
+
backgroundColorOrigin: backgroundOrigin
|
|
3472
|
+
} : {},
|
|
3473
|
+
foregroundColor: patternFill.foregroundColor,
|
|
3474
|
+
...foregroundOrigin ? {
|
|
3475
|
+
foregroundColorOrigin: foregroundOrigin
|
|
3476
|
+
} : {},
|
|
3477
|
+
patternType: patternFill.patternType
|
|
3478
|
+
}
|
|
3479
|
+
}) : `solid:${foregroundColor}:${xlsxSemanticColorOriginKey(foregroundOrigin)}`;
|
|
3461
3480
|
const cached = this.generatedFills.get(key);
|
|
3462
3481
|
if (void 0 !== cached) return cached;
|
|
3463
3482
|
const fill = this.styles.createElementNS(this.styles.documentElement.namespaceURI, 'fill');
|
|
3464
3483
|
const pattern = this.styles.createElementNS(this.styles.documentElement.namespaceURI, 'patternFill');
|
|
3465
|
-
pattern.setAttribute('patternType',
|
|
3466
|
-
const foreground = this.
|
|
3467
|
-
|
|
3468
|
-
if (
|
|
3469
|
-
const background = this.styles.createElementNS(this.styles.documentElement.namespaceURI, 'bgColor');
|
|
3470
|
-
background.setAttribute('indexed', '64');
|
|
3484
|
+
pattern.setAttribute('patternType', patternType);
|
|
3485
|
+
const foreground = this.fillColorElement('fgColor', foregroundColor, foregroundOrigin);
|
|
3486
|
+
const background = patternFill ? this.fillColorElement('bgColor', patternFill.backgroundColor, backgroundOrigin) : this.styles.createElementNS(this.styles.documentElement.namespaceURI, 'bgColor');
|
|
3487
|
+
if (!patternFill) background.setAttribute('indexed', '64');
|
|
3471
3488
|
pattern.append(foreground, background);
|
|
3472
3489
|
fill.append(pattern);
|
|
3473
3490
|
const index = directChildren(this.fills, 'fill').length;
|
|
@@ -3477,6 +3494,74 @@ class XlsxDirectCellStyleWriter {
|
|
|
3477
3494
|
this.updateCounts();
|
|
3478
3495
|
return index;
|
|
3479
3496
|
}
|
|
3497
|
+
gradientFillId(baseFillId, source) {
|
|
3498
|
+
const gradient = this.exportGradientFill(source);
|
|
3499
|
+
const fills = directChildren(this.fills, 'fill');
|
|
3500
|
+
const baseIndex = fills[baseFillId] ? baseFillId : 0;
|
|
3501
|
+
const baseFill = fills[baseIndex];
|
|
3502
|
+
const baseGradient = directChild(baseFill, 'gradientFill');
|
|
3503
|
+
if (!directChild(baseFill, 'patternFill') && xlsxGradientFillKey(readXlsxGradientFill(baseGradient, this.colors)) === xlsxGradientFillKey(gradient)) return baseIndex;
|
|
3504
|
+
const key = xlsxNativeFillKey({
|
|
3505
|
+
kind: 'gradient',
|
|
3506
|
+
value: gradient
|
|
3507
|
+
});
|
|
3508
|
+
const cached = this.generatedFills.get(key);
|
|
3509
|
+
if (void 0 !== cached) return cached;
|
|
3510
|
+
const fill = this.styles.createElementNS(this.styles.documentElement.namespaceURI, 'fill');
|
|
3511
|
+
const element = this.styles.createElementNS(this.styles.documentElement.namespaceURI, 'gradientFill');
|
|
3512
|
+
if ('linear' === gradient.type) element.setAttribute('degree', String(gradient.degree));
|
|
3513
|
+
else {
|
|
3514
|
+
element.setAttribute('type', 'path');
|
|
3515
|
+
element.setAttribute('left', String(gradient.left));
|
|
3516
|
+
element.setAttribute('right', String(gradient.right));
|
|
3517
|
+
element.setAttribute('top', String(gradient.top));
|
|
3518
|
+
element.setAttribute('bottom', String(gradient.bottom));
|
|
3519
|
+
}
|
|
3520
|
+
for (const gradientStop of gradient.stops){
|
|
3521
|
+
const stop = this.styles.createElementNS(this.styles.documentElement.namespaceURI, 'stop');
|
|
3522
|
+
stop.setAttribute('position', String(gradientStop.position));
|
|
3523
|
+
stop.append(this.fillColorElement('color', gradientStop.color, gradientStop.colorOrigin));
|
|
3524
|
+
element.append(stop);
|
|
3525
|
+
}
|
|
3526
|
+
fill.append(element);
|
|
3527
|
+
const index = fills.length;
|
|
3528
|
+
this.fills.append(fill);
|
|
3529
|
+
this.generatedFills.set(key, index);
|
|
3530
|
+
this.changed = true;
|
|
3531
|
+
this.updateCounts();
|
|
3532
|
+
return index;
|
|
3533
|
+
}
|
|
3534
|
+
exportGradientFill(source) {
|
|
3535
|
+
const stops = source.stops.map(({ color, colorOrigin, position })=>{
|
|
3536
|
+
const semanticColor = activeXlsxSemanticColorOrigin(colorOrigin, color, this.semanticPalette);
|
|
3537
|
+
return {
|
|
3538
|
+
color,
|
|
3539
|
+
...semanticColor ? {
|
|
3540
|
+
colorOrigin: semanticColor
|
|
3541
|
+
} : {},
|
|
3542
|
+
position
|
|
3543
|
+
};
|
|
3544
|
+
});
|
|
3545
|
+
return 'linear' === source.type ? {
|
|
3546
|
+
degree: source.degree,
|
|
3547
|
+
stops,
|
|
3548
|
+
type: 'linear'
|
|
3549
|
+
} : {
|
|
3550
|
+
bottom: source.bottom,
|
|
3551
|
+
left: source.left,
|
|
3552
|
+
right: source.right,
|
|
3553
|
+
stops,
|
|
3554
|
+
top: source.top,
|
|
3555
|
+
type: 'path'
|
|
3556
|
+
};
|
|
3557
|
+
}
|
|
3558
|
+
fillColorElement(name, color, origin) {
|
|
3559
|
+
const element = this.styles.createElementNS(this.styles.documentElement.namespaceURI, name);
|
|
3560
|
+
const rgb = xlsxRgbColor(color);
|
|
3561
|
+
if (rgb) element.setAttribute('rgb', rgb);
|
|
3562
|
+
if (origin) applyXlsxSemanticColorOrigin(element, origin);
|
|
3563
|
+
return element;
|
|
3564
|
+
}
|
|
3480
3565
|
borderId(baseBorderId, update, colorOrigins) {
|
|
3481
3566
|
if (!update) return baseBorderId;
|
|
3482
3567
|
const borders = directChildren(this.borders, 'border');
|
|
@@ -3567,12 +3652,21 @@ function readXlsxDirectCellStyles(worksheet, styles, theme = null) {
|
|
|
3567
3652
|
if (!coordinate || !xf) return [];
|
|
3568
3653
|
const style = readDirectCellStyle(xf, fonts, fills, colors);
|
|
3569
3654
|
const border = readDirectCellBorder(xf, borders, colors);
|
|
3655
|
+
const { gradientFill, patternFill } = readDirectCellNativeFill(xf, fills, colors);
|
|
3656
|
+
if (gradientFill) style.bg = xlsxGradientFillFallbackColor(gradientFill);
|
|
3657
|
+
else if (patternFill) style.bg = patternFill.backgroundColor;
|
|
3570
3658
|
const origin = readDirectCellStyleOrigin(xf, fonts, fills, borders, colors);
|
|
3571
|
-
return Object.keys(style).length || border ? [
|
|
3659
|
+
return Object.keys(style).length || border || patternFill || gradientFill ? [
|
|
3572
3660
|
{
|
|
3573
3661
|
...coordinate,
|
|
3574
3662
|
border,
|
|
3663
|
+
...gradientFill ? {
|
|
3664
|
+
gradientFill
|
|
3665
|
+
} : {},
|
|
3575
3666
|
origin,
|
|
3667
|
+
...patternFill ? {
|
|
3668
|
+
patternFill
|
|
3669
|
+
} : {},
|
|
3576
3670
|
style
|
|
3577
3671
|
}
|
|
3578
3672
|
] : [];
|
|
@@ -3675,9 +3769,30 @@ function readDirectFontStyle(style, font, colors) {
|
|
|
3675
3769
|
}
|
|
3676
3770
|
function readDirectFillStyle(style, fill, colors) {
|
|
3677
3771
|
const pattern = directChild(fill, 'patternFill');
|
|
3678
|
-
if (!pattern ||
|
|
3679
|
-
|
|
3680
|
-
|
|
3772
|
+
if (!pattern || directChild(fill, 'gradientFill')) return;
|
|
3773
|
+
if ('solid' === work_ooxml_package_attribute(pattern, 'patternType')) {
|
|
3774
|
+
const color = resolveXlsxColor(directChild(pattern, 'fgColor'), colors);
|
|
3775
|
+
if (color) style.bg = color;
|
|
3776
|
+
return;
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
function readDirectCellNativeFill(xf, fills, colors) {
|
|
3780
|
+
const fillId = work_xlsx_cell_styles_nonNegativeInteger(work_ooxml_package_attribute(xf, 'fillId')) ?? 0;
|
|
3781
|
+
const fill = fills[fillId];
|
|
3782
|
+
if (!fill || 0 === fillId && !work_xlsx_cell_styles_booleanAttribute(xf, 'applyFill')) return {};
|
|
3783
|
+
const pattern = directChild(fill, 'patternFill');
|
|
3784
|
+
const gradient = directChild(fill, 'gradientFill');
|
|
3785
|
+
if (Boolean(pattern) === Boolean(gradient)) return {};
|
|
3786
|
+
if (gradient) {
|
|
3787
|
+
const gradientFill = readXlsxGradientFill(gradient, colors);
|
|
3788
|
+
return gradientFill ? {
|
|
3789
|
+
gradientFill
|
|
3790
|
+
} : {};
|
|
3791
|
+
}
|
|
3792
|
+
const patternFill = readXlsxPatternFill(pattern, colors);
|
|
3793
|
+
return patternFill ? {
|
|
3794
|
+
patternFill
|
|
3795
|
+
} : {};
|
|
3681
3796
|
}
|
|
3682
3797
|
function readDirectAlignmentStyle(style, alignment) {
|
|
3683
3798
|
const horizontal = work_ooxml_package_attribute(alignment, 'horizontal');
|
|
@@ -6093,7 +6208,7 @@ async function patchXlsxSheetFeatures(buffer, content) {
|
|
|
6093
6208
|
const zip = await jszip.loadAsync(buffer);
|
|
6094
6209
|
const styles = archive.has('xl/styles.xml') ? await archive.xml('xl/styles.xml') : null;
|
|
6095
6210
|
const theme = archive.has('xl/theme/theme1.xml') ? await archive.xml('xl/theme/theme1.xml') : null;
|
|
6096
|
-
const semanticPalette = styles ? prepareXlsxSemanticPalette(styles, theme,
|
|
6211
|
+
const semanticPalette = styles ? prepareXlsxSemanticPalette(styles, theme, spreadsheetXlsxSemanticColors(content)) : void 0;
|
|
6097
6212
|
const differentialFormats = styles ? new XlsxDifferentialFormatWriter(styles) : void 0;
|
|
6098
6213
|
const directCellStyles = styles ? new XlsxDirectCellStyleWriter(styles, theme, semanticPalette?.palette) : void 0;
|
|
6099
6214
|
const cellProtection = styles ? new XlsxCellProtectionWriter(styles) : void 0;
|
|
@@ -6123,16 +6238,17 @@ async function patchXlsxSheetFeatures(buffer, content) {
|
|
|
6123
6238
|
compression: 'DEFLATE'
|
|
6124
6239
|
});
|
|
6125
6240
|
}
|
|
6126
|
-
function
|
|
6127
|
-
const
|
|
6241
|
+
function spreadsheetXlsxSemanticColors(content) {
|
|
6242
|
+
const colors = [];
|
|
6128
6243
|
for (const sheet of content.sheets){
|
|
6129
6244
|
for (const [, row] of sparseArrayEntries(sheet.data))for (const [, cell] of sparseArrayEntries(row)){
|
|
6130
6245
|
const origin = xlsxCellStyleOrigin(cell);
|
|
6131
|
-
if (origin)
|
|
6246
|
+
if (origin) colors.push(...xlsxCellStyleOriginSemanticColors(origin));
|
|
6247
|
+
colors.push(...xlsxNativeFillSemanticColors(activeXlsxNativeFill(cell)));
|
|
6132
6248
|
}
|
|
6133
|
-
|
|
6249
|
+
for (const origin of xlsxRichTextStyleOrigins(sheet))colors.push(...xlsxCellStyleOriginSemanticColors(origin));
|
|
6134
6250
|
}
|
|
6135
|
-
return
|
|
6251
|
+
return colors;
|
|
6136
6252
|
}
|
|
6137
6253
|
async function work_xlsx_interop_readWorksheetParts(archive, workbookDocument) {
|
|
6138
6254
|
if (!archive.has('xl/workbook.xml')) return new Map();
|
|
@@ -8050,7 +8166,7 @@ async function importWorkSpreadsheetFile(file, extension, context) {
|
|
|
8050
8166
|
const directCellStyle = directCellStyles.get(spreadsheetCellKey(row, column));
|
|
8051
8167
|
directCellStyles.delete(spreadsheetCellKey(row, column));
|
|
8052
8168
|
data[row] ??= [];
|
|
8053
|
-
data[row][column] = freezeImportedSpreadsheetCell(withXlsxCellStyleOrigin(applyImportedXlsxRichText(fortuneCellFromXlsx(source, row, column, id, hyperlink, comment, XLSX, directCellStyle?.style), richTextCells.get(spreadsheetCellKey(row, column))), directCellStyle?.origin));
|
|
8169
|
+
data[row][column] = freezeImportedSpreadsheetCell(withXlsxGradientFill(withXlsxPatternFill(withXlsxCellStyleOrigin(applyImportedXlsxRichText(fortuneCellFromXlsx(source, row, column, id, hyperlink, comment, XLSX, directCellStyle?.style), richTextCells.get(spreadsheetCellKey(row, column))), directCellStyle?.origin), directCellStyle?.patternFill), directCellStyle?.gradientFill));
|
|
8054
8170
|
if (source.f) formulaCells.push({
|
|
8055
8171
|
column,
|
|
8056
8172
|
row
|
|
@@ -8063,15 +8179,15 @@ async function importWorkSpreadsheetFile(file, extension, context) {
|
|
|
8063
8179
|
}
|
|
8064
8180
|
releaseImportedWorksheetCells(worksheet);
|
|
8065
8181
|
}
|
|
8066
|
-
for (const { column, origin, row, style } of directCellStyles.values()){
|
|
8182
|
+
for (const { column, gradientFill, origin, patternFill, row, style } of directCellStyles.values()){
|
|
8067
8183
|
rowCount = Math.max(rowCount, row + 1);
|
|
8068
8184
|
columnCount = Math.max(columnCount, column + 1);
|
|
8069
8185
|
data[row] ??= [];
|
|
8070
8186
|
const existing = data[row][column];
|
|
8071
|
-
data[row][column] = freezeImportedSpreadsheetCell(withXlsxCellStyleOrigin({
|
|
8187
|
+
data[row][column] = freezeImportedSpreadsheetCell(withXlsxGradientFill(withXlsxPatternFill(withXlsxCellStyleOrigin({
|
|
8072
8188
|
...existing ?? {},
|
|
8073
8189
|
...style
|
|
8074
|
-
}, origin));
|
|
8190
|
+
}, origin), patternFill), gradientFill));
|
|
8075
8191
|
if (!existing) entryIndex += 1;
|
|
8076
8192
|
}
|
|
8077
8193
|
populatedCellCount += entryIndex;
|
package/dist/5184.js
CHANGED
|
@@ -14,6 +14,13 @@ const WORK_TEMPLATES = [
|
|
|
14
14
|
description: '目标、范围、里程碑与风险',
|
|
15
15
|
accent: '#536de2'
|
|
16
16
|
},
|
|
17
|
+
{
|
|
18
|
+
id: 'text-effects',
|
|
19
|
+
kind: 'document',
|
|
20
|
+
name: '文字效果',
|
|
21
|
+
description: '空心、阴影、阳文与阴文',
|
|
22
|
+
accent: '#6b5bd2'
|
|
23
|
+
},
|
|
17
24
|
{
|
|
18
25
|
id: 'blank-markdown',
|
|
19
26
|
kind: 'markdown',
|
|
@@ -72,6 +79,7 @@ function createWorkId(prefix) {
|
|
|
72
79
|
function initialTitle(templateId, kind) {
|
|
73
80
|
const titles = {
|
|
74
81
|
'project-brief': '新项目方案',
|
|
82
|
+
'text-effects': '文字效果示例',
|
|
75
83
|
'quarterly-plan': '季度执行计划',
|
|
76
84
|
'strategy-deck': '业务策略汇报'
|
|
77
85
|
};
|
|
@@ -87,6 +95,11 @@ function contentForTemplate(templateId) {
|
|
|
87
95
|
pageSize: 'a4',
|
|
88
96
|
html: "<h1>新项目方案</h1><p><strong>负责人:</strong>项目团队 <strong>更新日期:</strong>今天</p><blockquote><p>用一句话说明这项工作的目标,以及完成后会带来什么变化。</p></blockquote><h2>背景与目标</h2><p>描述当前情况、核心问题和可衡量的成功标准。</p><h2>工作范围</h2><ul><li><p>需要完成的关键交付物</p></li><li><p>明确不在本期范围内的事项</p></li></ul><h2>里程碑</h2><ol><li><p>方案确认</p></li><li><p>执行与评审</p></li><li><p>交付与复盘</p></li></ol><h2>风险与决策</h2><p>记录尚未解决的问题、依赖和决策负责人。</p>"
|
|
89
97
|
};
|
|
98
|
+
if ('text-effects' === templateId) return {
|
|
99
|
+
type: 'document',
|
|
100
|
+
pageSize: 'a4',
|
|
101
|
+
html: '<h1>原生文字效果</h1><p>选择下面任一示例并打开字体高级设置,可以组合空心与阴影,或在互斥的阳文和阴文之间切换。</p><h2>可组合效果</h2><p><span data-office-legacy-text-outline="true" data-office-legacy-text-shadow="true">空心 + 阴影</span></p><p><span data-office-legacy-text-outline="true">空心</span></p><p><span data-office-legacy-text-shadow="true">阴影</span></p><h2>互斥效果</h2><p><span data-office-legacy-text-emboss="true">阳文</span></p><p><span data-office-legacy-text-imprint="true">阴文</span></p>'
|
|
102
|
+
};
|
|
90
103
|
if ('quarterly-plan' === templateId) return {
|
|
91
104
|
type: 'spreadsheet',
|
|
92
105
|
sheets: quarterlyPlanSheets()
|