@a3s-lab/office 0.19.0 → 0.21.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 +14 -5
- package/dist/0~3635.js +23 -2
- package/dist/0~spreadsheet-editor.js +395 -90
- package/dist/0~work-office-diagnostics.js +1 -1
- package/dist/4104.js +714 -282
- package/dist/{6164.js → 5045.js} +109 -56
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/features/work/editors/office-color-picker.d.ts +6 -1
- package/dist/internal/features/work/editors/spreadsheet-cell-border.d.ts +8 -2
- package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +21 -12
- package/dist/internal/features/work/work-spreadsheet-diagonal-border-canvas.d.ts +12 -0
- package/dist/internal/features/work/work-spreadsheet-diagonal-borders.d.ts +13 -0
- package/dist/internal/features/work/work-xlsx-cell-style-origin.d.ts +44 -0
- package/dist/internal/features/work/work-xlsx-cell-style-values.d.ts +26 -0
- package/dist/internal/features/work/work-xlsx-cell-style-writer.d.ts +4 -1
- package/dist/internal/features/work/work-xlsx-cell-styles.d.ts +2 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +73 -4
- package/package.json +7 -1
|
@@ -4,7 +4,7 @@ import { Workbook } from "@fortune-sheet/react";
|
|
|
4
4
|
import { AArrowDown, AArrowUp, AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowDownToLine, ArrowLeft, ArrowLeftToLine, ArrowRight, ArrowRightToLine, ArrowUp, ArrowUpToLine, BadgeJapaneseYen, BarChart3, BetweenHorizontalEnd, BetweenHorizontalStart, BetweenVerticalEnd, BetweenVerticalStart, Bold, Bookmark, Calculator, Check, ChevronDown, ChevronLeft, ChevronRight, ClipboardPaste, Cloud, Columns3, Copy, CopyPlus, DecimalsArrowLeft, DecimalsArrowRight, Eraser, Eye, EyeOff, FileX2, Globe2, Grid2X2, Grid3X3, Hash, Italic, KeyRound, Layers2, Link2, Link2Off, ListChecks, ListFilter, LocateFixed, Merge, MessageSquareX, MoveHorizontal, MoveVertical, Paintbrush, Palette, PanelLeft, PanelTop, PanelsTopLeft, Pencil, Percent, Plus, Printer, Redo2, RefreshCw, Rows3, Save, Scissors, Search, Settings2, ShieldCheck, Sigma, SortAsc, SortDesc, Strikethrough, SwatchBook, Table2, TableProperties, Trash2, Underline, Undo2, WrapText, X } from "lucide-react";
|
|
5
5
|
import { Fragment as external_react_Fragment, cloneElement, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { genarate, indexToColumnChar, update as core_update } from "@fortune-sheet/core";
|
|
7
|
-
import { freezeImportedSpreadsheetCell, spreadsheetTextOrientationFromChoice, spreadsheetMatrixProfile, withoutEditableRange, spreadsheetTextOrientationFromAngle, isSpreadsheetTextOrientationId, normalizeSpreadsheetConditionalVisualOptions, spreadsheetUnderlineCellValue, effectiveSpreadsheetPageSetup, attachSpreadsheetShownCommentCells, withEditableRange, sameSpreadsheetHistoryValue, createOfficeSpreadsheetCollaborationBinding as createWorkOfficeSpreadsheetCollaborationBinding, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconForValue, defaultSpreadsheetConditionalIconThresholds, spreadsheetUnderlineStyle, normalizeSpreadsheetDateValidationBoundary, sheetProtectionAuthority, editableRangeCellCount, unlockedCellCount, registerDerivedSpreadsheetMatrix, editableRangeRequiresCredentials, spreadsheetTextOrientationCellStyle, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, spreadsheetConditionalThresholdValue, spreadsheetTextOrientationChoiceFromCell, normalizeSheetProtectionAuthority, withSheetProtection, defaultSpreadsheetColorScaleThresholds, spreadsheetProtectionKey,
|
|
7
|
+
import { freezeImportedSpreadsheetCell, spreadsheetTextOrientationFromChoice, spreadsheetMatrixProfile, withoutEditableRange, spreadsheetTextOrientationFromAngle, isSpreadsheetTextOrientationId, normalizeSpreadsheetConditionalVisualOptions, spreadsheetCellValueWithDiagonalBorder, spreadsheetUnderlineCellValue, effectiveSpreadsheetPageSetup, attachSpreadsheetShownCommentCells, withEditableRange, sameSpreadsheetHistoryValue, createOfficeSpreadsheetCollaborationBinding as createWorkOfficeSpreadsheetCollaborationBinding, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconForValue, defaultSpreadsheetConditionalIconThresholds, spreadsheetUnderlineStyle, normalizeSpreadsheetDateValidationBoundary, sheetProtectionAuthority, editableRangeCellCount, unlockedCellCount, registerDerivedSpreadsheetMatrix, editableRangeRequiresCredentials, spreadsheetTextOrientationCellStyle, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, spreadsheetConditionalThresholdValue, spreadsheetTextOrientationChoiceFromCell, normalizeSheetProtectionAuthority, withSheetProtection, defaultSpreadsheetColorScaleThresholds, spreadsheetProtectionKey, spreadsheetDiagonalBorderFromCellValue, SPREADSHEET_CONDITIONAL_ICON_SETS, protectedSheetCount, withSheetSelectionPermissions, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, spreadsheetConditionalComparisonNeedsUpperValue, drawSpreadsheetConditionalIcon, spreadsheetTextOrientationFromCell, replaceOfficeSpreadsheetCollaboration as replaceWorkOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration as readWorkOfficeSpreadsheetCollaboration, spreadsheetConditionalThresholdsEqual, isSpreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell } from "./5045.js";
|
|
8
8
|
import { workSpreadsheetChartSupportsGrouping, createSpreadsheetChartFromSelection, normalizeWorkSpreadsheetDataLabelPosition, normalizeSpreadsheetPrintTitleColumns, normalizeSpreadsheetPrintTitleRows, formulaHasStructuredReference, normalizeWorkSpreadsheetErrorBars, defaultPivotValueCaption, workSpreadsheetChartSupportsBarSpacing, normalizeWorkSpreadsheetChartGrouping, spreadsheetGridSize, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetScatterStyle, cloneSparseMatrix, spreadsheetPivotAggregationLabel, workSpreadsheetChartAxisIsCategoryAxis, reconcileSpreadsheetChartPreviews, normalizeWorkSpreadsheetChartAxes, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartLegendPosition, spreadsheetChartCount, workSpreadsheetChartTypeLabel, sparseArrayEntries, normalizeWorkSpreadsheetTrendline, effectiveSpreadsheetCalculationSettings, spreadsheetPivotIntersects, normalizeWorkSpreadsheetDataLabels, spreadsheetPivotOutputContains, normalizeSpreadsheetPrintArea, spreadsheetCellAddress, formatSpreadsheetCellRanges, normalizeWorkSpreadsheetChartLayout, spreadsheetFormulaRangeForCell, workSpreadsheetChartAxisIsValueAxis, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, volatileSpreadsheetFormulaFunctions, sparseArrayIndexes, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, normalizeWorkSpreadsheetChartLegendOverlay, parseSpreadsheetChartReference, workSpreadsheetChartGroupingIsStacked, normalizeWorkSpreadsheetChartGapWidth, workSpreadsheetChartSupportsSmoothLines, refreshSpreadsheetPivotTables, createSpreadsheetPivotFromSelection, reconcileSpreadsheetPivots, spreadsheetPivotCount, sparseMatrixColumnCount, workSpreadsheetChartSupportsErrorBars, formulaHasExternalReference, isValidSpreadsheetDefinedName, spreadsheetPivotValidation, deleteSpreadsheetPivotTable, workSpreadsheetChartAxisDefaultLabelPosition, workSpreadsheetChartSupportsSeriesAnalysis, parseSpreadsheetCellRanges, spreadsheetPivotFilterItems, spreadsheetPivotFields, normalizeWorkSpreadsheetChartOverlap, spreadsheetFormulaRangeConflict, spreadsheetSheetsWithChartPreviews, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, workSpreadsheetChartSupportsAxes, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetRadarStyle } from "./8715.js";
|
|
9
9
|
import { moveOfficeMenuFocus, stepOfficeZoom, useOfficeRemoteParticipants, Popover, officePresenceColor, useOfficePublishPresenceLocation, button_Button, icon_button_IconButton, moveOfficeGridMenuFocus, office_text_field_OfficeTextField, useDialogFocusScope, useOfficeEditorWheelZoom } from "./0~6090.js";
|
|
10
10
|
import { useOfficeTaskPaneEscape, OfficeCheckbox, CommittedOfficeNumberField, useOfficeDialog, useOfficeTaskPaneModal, createOfficeKernelClient, officeFontFamilies, CollectionState, OfficeNumberField, handleOfficeTaskPaneKeyDown } from "./0~7048.js";
|
|
@@ -86,6 +86,74 @@ function drawCellValue(context, bounds, cell, conditionalTextColor) {
|
|
|
86
86
|
context.fillText(String(value), bounds.startX + 4, bounds.startY + height / 2, bounds.endX - bounds.startX - 8);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
function drawSpreadsheetDiagonalDownBorder(context, bounds, line) {
|
|
90
|
+
drawSpreadsheetDiagonalBorder(context, bounds, line, 'down');
|
|
91
|
+
}
|
|
92
|
+
function drawSpreadsheetDiagonalUpBorder(context, bounds, line) {
|
|
93
|
+
drawSpreadsheetDiagonalBorder(context, bounds, line, 'up');
|
|
94
|
+
}
|
|
95
|
+
function drawSpreadsheetDiagonalBorder(context, bounds, line, direction) {
|
|
96
|
+
const left = Math.round(bounds.startX) + 0.5;
|
|
97
|
+
const top = Math.round(bounds.startY) + 0.5;
|
|
98
|
+
const right = Math.round(bounds.endX) - 1.5;
|
|
99
|
+
const bottom = Math.round(bounds.endY) - 1.5;
|
|
100
|
+
if (right <= left || bottom <= top) return;
|
|
101
|
+
context.save();
|
|
102
|
+
context.strokeStyle = line.color;
|
|
103
|
+
context.lineCap = 'butt';
|
|
104
|
+
context.lineWidth = spreadsheetDiagonalLineWidth(line.style);
|
|
105
|
+
context.setLineDash(spreadsheetDiagonalLineDash(line.style));
|
|
106
|
+
const startY = 'down' === direction ? top : bottom;
|
|
107
|
+
const endY = 'down' === direction ? bottom : top;
|
|
108
|
+
if ('7' === line.style) {
|
|
109
|
+
drawLine(context, left, startY - 1, right, endY - 1);
|
|
110
|
+
drawLine(context, left, startY + 1, right, endY + 1);
|
|
111
|
+
} else drawLine(context, left, startY, right, endY);
|
|
112
|
+
context.restore();
|
|
113
|
+
}
|
|
114
|
+
function drawLine(context, startX, startY, endX, endY) {
|
|
115
|
+
context.beginPath();
|
|
116
|
+
context.moveTo(startX, startY);
|
|
117
|
+
context.lineTo(endX, endY);
|
|
118
|
+
context.stroke();
|
|
119
|
+
}
|
|
120
|
+
function spreadsheetDiagonalLineWidth(style) {
|
|
121
|
+
if ('2' === style) return 0.5;
|
|
122
|
+
if ([
|
|
123
|
+
'8',
|
|
124
|
+
'9',
|
|
125
|
+
'10',
|
|
126
|
+
'11',
|
|
127
|
+
'12'
|
|
128
|
+
].includes(style)) return 2;
|
|
129
|
+
if ('13' === style) return 3;
|
|
130
|
+
return 1;
|
|
131
|
+
}
|
|
132
|
+
function spreadsheetDiagonalLineDash(style) {
|
|
133
|
+
if ('3' === style) return [
|
|
134
|
+
1,
|
|
135
|
+
2
|
|
136
|
+
];
|
|
137
|
+
if ('4' === style || '9' === style) return [
|
|
138
|
+
5,
|
|
139
|
+
3
|
|
140
|
+
];
|
|
141
|
+
if ('5' === style || '10' === style || '12' === style) return [
|
|
142
|
+
6,
|
|
143
|
+
3,
|
|
144
|
+
1,
|
|
145
|
+
3
|
|
146
|
+
];
|
|
147
|
+
if ('6' === style || '11' === style) return [
|
|
148
|
+
6,
|
|
149
|
+
3,
|
|
150
|
+
1,
|
|
151
|
+
3,
|
|
152
|
+
1,
|
|
153
|
+
3
|
|
154
|
+
];
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
89
157
|
function parseSpreadsheetConditionalColor(value) {
|
|
90
158
|
const hexadecimal = /^#?([0-9a-f]{6})$/i.exec(value.trim());
|
|
91
159
|
if (hexadecimal) return {
|
|
@@ -577,7 +645,8 @@ const spreadsheetCellBorderTargets = [
|
|
|
577
645
|
'inside',
|
|
578
646
|
'horizontal',
|
|
579
647
|
'vertical',
|
|
580
|
-
'
|
|
648
|
+
'diagonalDown',
|
|
649
|
+
'diagonalUp'
|
|
581
650
|
];
|
|
582
651
|
const spreadsheetCellBorderStyles = [
|
|
583
652
|
'thin',
|
|
@@ -615,8 +684,7 @@ const spreadsheetNativeBorderTypeByTarget = {
|
|
|
615
684
|
outside: 'border-outside',
|
|
616
685
|
inside: 'border-inside',
|
|
617
686
|
horizontal: 'border-horizontal',
|
|
618
|
-
vertical: 'border-vertical'
|
|
619
|
-
diagonal: 'border-slash'
|
|
687
|
+
vertical: 'border-vertical'
|
|
620
688
|
};
|
|
621
689
|
const spreadsheetNativeBorderStyleByName = {
|
|
622
690
|
thin: '1',
|
|
@@ -635,36 +703,29 @@ function spreadsheetNativeBorderStyle(style) {
|
|
|
635
703
|
}
|
|
636
704
|
function canSetSpreadsheetCellBorders(content, sheetId, range, format) {
|
|
637
705
|
const normalizedRange = spreadsheet_cell_range_normalizeSpreadsheetCellRange(range);
|
|
638
|
-
return Boolean(content.sheets.some((sheet)=>sheet.id === sheetId) && normalizedRange && normalizeSpreadsheetBorderFormat(format) && (
|
|
706
|
+
return Boolean(content.sheets.some((sheet)=>sheet.id === sheetId) && normalizedRange && normalizeSpreadsheetBorderFormat(format) && (!isSpreadsheetDiagonalBorderTarget(format.target) || spreadsheet_cell_range_spreadsheetCellRangeArea(normalizedRange) <= MAX_SPREADSHEET_DIAGONAL_BORDER_CELLS) && spreadsheetBorderInfoIsWritable(content.sheets.find((sheet)=>sheet.id === sheetId)));
|
|
639
707
|
}
|
|
640
708
|
function setSpreadsheetCellBorders(content, sheetId, range, format) {
|
|
641
709
|
const sheetIndex = content.sheets.findIndex((sheet)=>sheet.id === sheetId);
|
|
642
710
|
const sheet = content.sheets[sheetIndex];
|
|
643
711
|
const normalizedRange = spreadsheet_cell_range_normalizeSpreadsheetCellRange(range);
|
|
644
712
|
const normalizedFormat = normalizeSpreadsheetBorderFormat(format);
|
|
645
|
-
if (!sheet || !normalizedRange || !normalizedFormat || !spreadsheetBorderInfoIsWritable(sheet) ||
|
|
646
|
-
const borderType = spreadsheetNativeBorderTypeByTarget[normalizedFormat.target];
|
|
713
|
+
if (!sheet || !normalizedRange || !normalizedFormat || !spreadsheetBorderInfoIsWritable(sheet) || isSpreadsheetDiagonalBorderTarget(normalizedFormat.target) && spreadsheet_cell_range_spreadsheetCellRangeArea(normalizedRange) > MAX_SPREADSHEET_DIAGONAL_BORDER_CELLS) return null;
|
|
647
714
|
const source = Array.isArray(sheet.config?.borderInfo) ? sheet.config.borderInfo : [];
|
|
715
|
+
if (isSpreadsheetDiagonalBorderTarget(normalizedFormat.target)) {
|
|
716
|
+
const borderInfo = [
|
|
717
|
+
...compactSpreadsheetBorderInfo(source, normalizedRange, 'border-slash'),
|
|
718
|
+
...spreadsheetDiagonalBorderRecords(sheet, normalizedRange, normalizedFormat.target, normalizedFormat.color, spreadsheetNativeBorderStyleByName[normalizedFormat.style])
|
|
719
|
+
];
|
|
720
|
+
return contentWithSpreadsheetBorderInfo(content, sheetIndex, sheet, borderInfo);
|
|
721
|
+
}
|
|
722
|
+
const borderType = spreadsheetNativeBorderTypeByTarget[normalizedFormat.target];
|
|
648
723
|
const compacted = compactSpreadsheetBorderInfo(source, normalizedRange, borderType);
|
|
649
724
|
const borderInfo = [
|
|
650
725
|
...compacted,
|
|
651
726
|
...spreadsheetNativeBorderRecords(normalizedRange, borderType, normalizedFormat.color, spreadsheetNativeBorderStyleByName[normalizedFormat.style])
|
|
652
727
|
];
|
|
653
|
-
|
|
654
|
-
...sheet,
|
|
655
|
-
config: {
|
|
656
|
-
...sheet.config,
|
|
657
|
-
borderInfo: borderInfo
|
|
658
|
-
}
|
|
659
|
-
};
|
|
660
|
-
const sheets = [
|
|
661
|
-
...content.sheets
|
|
662
|
-
];
|
|
663
|
-
sheets[sheetIndex] = nextSheet;
|
|
664
|
-
return {
|
|
665
|
-
...content,
|
|
666
|
-
sheets
|
|
667
|
-
};
|
|
728
|
+
return contentWithSpreadsheetBorderInfo(content, sheetIndex, sheet, borderInfo);
|
|
668
729
|
}
|
|
669
730
|
function spreadsheetCellBordersAt(sheet, row, column) {
|
|
670
731
|
const borders = {};
|
|
@@ -678,7 +739,7 @@ function spreadsheetCellBordersAt(sheet, row, column) {
|
|
|
678
739
|
applyResolvedCellBorderLine(borders, 'right', candidate.value.r);
|
|
679
740
|
applyResolvedCellBorderLine(borders, 'top', candidate.value.t);
|
|
680
741
|
applyResolvedCellBorderLine(borders, 'bottom', candidate.value.b);
|
|
681
|
-
|
|
742
|
+
applyResolvedCellDiagonalBorders(borders, candidate.value);
|
|
682
743
|
continue;
|
|
683
744
|
}
|
|
684
745
|
if ('range' !== candidate.rangeType || !isSpreadsheetNativeBorderType(candidate.borderType) || !Array.isArray(candidate.range)) continue;
|
|
@@ -690,6 +751,69 @@ function spreadsheetCellBordersAt(sheet, row, column) {
|
|
|
690
751
|
}
|
|
691
752
|
return borders;
|
|
692
753
|
}
|
|
754
|
+
function spreadsheetRenderableDiagonalBorders(sheet) {
|
|
755
|
+
const borders = new Map();
|
|
756
|
+
const source = Array.isArray(sheet.config?.borderInfo) ? sheet.config.borderInfo : [];
|
|
757
|
+
for (const candidate of source){
|
|
758
|
+
if (!spreadsheet_cell_border_isRecord(candidate)) continue;
|
|
759
|
+
if ('cell' === candidate.rangeType) {
|
|
760
|
+
if (!spreadsheet_cell_border_isRecord(candidate.value)) continue;
|
|
761
|
+
const row = finiteSpreadsheetBorderIndex(candidate.value.row_index);
|
|
762
|
+
const column = finiteSpreadsheetBorderIndex(candidate.value.col_index);
|
|
763
|
+
if (null === row || null === column) continue;
|
|
764
|
+
const key = `${row}_${column}`;
|
|
765
|
+
const diagonal = spreadsheetDiagonalBorderFromCellValue(candidate.value);
|
|
766
|
+
if (void 0 === diagonal) continue;
|
|
767
|
+
if (!diagonal) {
|
|
768
|
+
borders.delete(key);
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
const line = resolvedCellBorderLine(diagonal.line);
|
|
772
|
+
if (!line) {
|
|
773
|
+
borders.delete(key);
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
borders.set(key, {
|
|
777
|
+
border: {
|
|
778
|
+
...diagonal.down ? {
|
|
779
|
+
down: line
|
|
780
|
+
} : {},
|
|
781
|
+
...diagonal.up ? {
|
|
782
|
+
up: line
|
|
783
|
+
} : {}
|
|
784
|
+
},
|
|
785
|
+
column,
|
|
786
|
+
row
|
|
787
|
+
});
|
|
788
|
+
continue;
|
|
789
|
+
}
|
|
790
|
+
if ('range' !== candidate.rangeType || 'border-none' !== candidate.borderType && 'border-slash' !== candidate.borderType || !Array.isArray(candidate.range)) continue;
|
|
791
|
+
const line = resolvedRangeBorderLine(candidate);
|
|
792
|
+
for (const rangeCandidate of candidate.range){
|
|
793
|
+
const range = parseSpreadsheetCellRange(rangeCandidate);
|
|
794
|
+
if (range) {
|
|
795
|
+
for (const [key, entry] of borders)if (spreadsheetCellRangeContains(range, entry.row, entry.column)) {
|
|
796
|
+
if ('border-none' === candidate.borderType || !entry.border.up) {
|
|
797
|
+
borders.delete(key);
|
|
798
|
+
continue;
|
|
799
|
+
}
|
|
800
|
+
borders.set(key, {
|
|
801
|
+
...entry,
|
|
802
|
+
border: {
|
|
803
|
+
up: line ?? entry.border.up
|
|
804
|
+
}
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return new Map([
|
|
811
|
+
...borders
|
|
812
|
+
].map(([key, entry])=>[
|
|
813
|
+
key,
|
|
814
|
+
entry.border
|
|
815
|
+
]));
|
|
816
|
+
}
|
|
693
817
|
function normalizeSpreadsheetBorderFormat(format) {
|
|
694
818
|
if (!spreadsheetCellBorderTargets.includes(format.target) || !spreadsheetCellBorderStyles.includes(format.style)) return null;
|
|
695
819
|
const color = normalizeSpreadsheetBorderColor(format.color);
|
|
@@ -716,14 +840,26 @@ function compactSpreadsheetBorderInfo(formats, range, appliedType) {
|
|
|
716
840
|
format
|
|
717
841
|
];
|
|
718
842
|
if ('cell' === format.rangeType) {
|
|
719
|
-
if (!
|
|
843
|
+
if (!spreadsheet_cell_border_isRecord(format.value)) return [
|
|
720
844
|
format
|
|
721
845
|
];
|
|
722
846
|
const row = finiteSpreadsheetBorderIndex(format.value.row_index);
|
|
723
847
|
const column = finiteSpreadsheetBorderIndex(format.value.col_index);
|
|
724
|
-
|
|
848
|
+
const selected = null !== row && null !== column && spreadsheetCellRangeContains(range, row, column);
|
|
849
|
+
if (!selected) return [
|
|
850
|
+
format
|
|
851
|
+
];
|
|
852
|
+
if (supersedesAll) return [];
|
|
853
|
+
if ('border-slash' !== appliedType) return [
|
|
725
854
|
format
|
|
726
855
|
];
|
|
856
|
+
const value = spreadsheetCellValueWithDiagonalBorder(format.value, null);
|
|
857
|
+
return Object.keys(value).some((key)=>'row_index' !== key && 'col_index' !== key) ? [
|
|
858
|
+
{
|
|
859
|
+
...format,
|
|
860
|
+
value
|
|
861
|
+
}
|
|
862
|
+
] : [];
|
|
727
863
|
}
|
|
728
864
|
if ('range' !== format.rangeType || !isSpreadsheetNativeBorderType(format.borderType) || !Array.isArray(format.range) || !supersedesAll && format.borderType !== appliedType) return [
|
|
729
865
|
format
|
|
@@ -733,9 +869,14 @@ function compactSpreadsheetBorderInfo(formats, range, appliedType) {
|
|
|
733
869
|
if (!parsed) return [
|
|
734
870
|
candidate
|
|
735
871
|
];
|
|
736
|
-
if ('border-slash' === format.borderType)
|
|
737
|
-
|
|
738
|
-
|
|
872
|
+
if ('border-slash' === format.borderType) {
|
|
873
|
+
if (!spreadsheetCellRangesIntersect(parsed, range)) return [
|
|
874
|
+
candidate
|
|
875
|
+
];
|
|
876
|
+
return 1 === spreadsheet_cell_range_spreadsheetCellRangeArea(parsed) ? [] : [
|
|
877
|
+
candidate
|
|
878
|
+
];
|
|
879
|
+
}
|
|
739
880
|
return subtractSpreadsheetCellRange(parsed, range);
|
|
740
881
|
});
|
|
741
882
|
return remaining.length ? [
|
|
@@ -747,7 +888,7 @@ function compactSpreadsheetBorderInfo(formats, range, appliedType) {
|
|
|
747
888
|
});
|
|
748
889
|
}
|
|
749
890
|
function spreadsheetNativeBorderRecords(range, borderType, color, style) {
|
|
750
|
-
|
|
891
|
+
return [
|
|
751
892
|
{
|
|
752
893
|
rangeType: 'range',
|
|
753
894
|
borderType,
|
|
@@ -758,28 +899,91 @@ function spreadsheetNativeBorderRecords(range, borderType, color, style) {
|
|
|
758
899
|
]
|
|
759
900
|
}
|
|
760
901
|
];
|
|
902
|
+
}
|
|
903
|
+
function spreadsheetDiagonalBorderRecords(sheet, range, target, color, style) {
|
|
761
904
|
const records = [];
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
905
|
+
const existing = spreadsheetDiagonalBorderDirectionsInRange(sheet, range);
|
|
906
|
+
for(let row = range.row[0]; row <= range.row[1]; row += 1)for(let column = range.column[0]; column <= range.column[1]; column += 1){
|
|
907
|
+
const current = existing.get(`${row}_${column}`);
|
|
908
|
+
const border = {
|
|
909
|
+
down: 'diagonalDown' === target || Boolean(current?.down),
|
|
910
|
+
line: {
|
|
911
|
+
color,
|
|
912
|
+
style
|
|
913
|
+
},
|
|
914
|
+
up: 'diagonalUp' === target || Boolean(current?.up)
|
|
915
|
+
};
|
|
916
|
+
records.push({
|
|
917
|
+
rangeType: 'cell',
|
|
918
|
+
value: spreadsheetCellValueWithDiagonalBorder({
|
|
919
|
+
col_index: column,
|
|
920
|
+
row_index: row
|
|
921
|
+
}, border)
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
return records;
|
|
925
|
+
}
|
|
926
|
+
function spreadsheetDiagonalBorderDirectionsInRange(sheet, selection) {
|
|
927
|
+
const directions = new Map();
|
|
928
|
+
const source = Array.isArray(sheet.config?.borderInfo) ? sheet.config.borderInfo : [];
|
|
929
|
+
for (const candidate of source){
|
|
930
|
+
if (!spreadsheet_cell_border_isRecord(candidate)) continue;
|
|
931
|
+
if ('cell' === candidate.rangeType) {
|
|
932
|
+
if (!spreadsheet_cell_border_isRecord(candidate.value)) continue;
|
|
933
|
+
const row = finiteSpreadsheetBorderIndex(candidate.value.row_index);
|
|
934
|
+
const column = finiteSpreadsheetBorderIndex(candidate.value.col_index);
|
|
935
|
+
if (null === row || null === column || !spreadsheetCellRangeContains(selection, row, column)) continue;
|
|
936
|
+
const diagonal = spreadsheetDiagonalBorderFromCellValue(candidate.value);
|
|
937
|
+
if (void 0 === diagonal) continue;
|
|
938
|
+
const line = diagonal && resolvedCellBorderLine(diagonal.line);
|
|
939
|
+
setSpreadsheetDiagonalDirections(directions, row, column, Boolean(line && diagonal?.down), Boolean(line && diagonal?.up));
|
|
940
|
+
continue;
|
|
941
|
+
}
|
|
942
|
+
if ('range' !== candidate.rangeType || 'border-none' !== candidate.borderType && 'border-slash' !== candidate.borderType || !Array.isArray(candidate.range)) continue;
|
|
943
|
+
const line = resolvedRangeBorderLine(candidate);
|
|
944
|
+
for (const rangeCandidate of candidate.range){
|
|
945
|
+
const range = parseSpreadsheetCellRange(rangeCandidate);
|
|
946
|
+
if (!range || !spreadsheetCellRangesIntersect(range, selection)) continue;
|
|
947
|
+
const startRow = Math.max(range.row[0], selection.row[0]);
|
|
948
|
+
const endRow = Math.min(range.row[1], selection.row[1]);
|
|
949
|
+
const startColumn = Math.max(range.column[0], selection.column[0]);
|
|
950
|
+
const endColumn = Math.min(range.column[1], selection.column[1]);
|
|
951
|
+
for(let row = startRow; row <= endRow; row += 1)for(let column = startColumn; column <= endColumn; column += 1){
|
|
952
|
+
if ('border-none' === candidate.borderType) {
|
|
953
|
+
directions.delete(`${row}_${column}`);
|
|
954
|
+
continue;
|
|
955
|
+
}
|
|
956
|
+
const current = directions.get(`${row}_${column}`);
|
|
957
|
+
setSpreadsheetDiagonalDirections(directions, row, column, Boolean(line), Boolean(current?.up));
|
|
779
958
|
}
|
|
780
|
-
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return directions;
|
|
962
|
+
}
|
|
963
|
+
function setSpreadsheetDiagonalDirections(directions, row, column, down, up) {
|
|
964
|
+
const key = `${row}_${column}`;
|
|
965
|
+
if (!down && !up) return void directions.delete(key);
|
|
966
|
+
directions.set(key, {
|
|
967
|
+
down,
|
|
968
|
+
up
|
|
781
969
|
});
|
|
782
|
-
|
|
970
|
+
}
|
|
971
|
+
function contentWithSpreadsheetBorderInfo(content, sheetIndex, sheet, borderInfo) {
|
|
972
|
+
const nextSheet = {
|
|
973
|
+
...sheet,
|
|
974
|
+
config: {
|
|
975
|
+
...sheet.config,
|
|
976
|
+
borderInfo: borderInfo
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
const sheets = [
|
|
980
|
+
...content.sheets
|
|
981
|
+
];
|
|
982
|
+
sheets[sheetIndex] = nextSheet;
|
|
983
|
+
return {
|
|
984
|
+
...content,
|
|
985
|
+
sheets
|
|
986
|
+
};
|
|
783
987
|
}
|
|
784
988
|
function applyResolvedCellBorderLine(borders, side, value) {
|
|
785
989
|
if (null === value) return void delete borders[side];
|
|
@@ -791,6 +995,26 @@ function applyResolvedCellBorderLine(borders, side, value) {
|
|
|
791
995
|
style
|
|
792
996
|
};
|
|
793
997
|
}
|
|
998
|
+
function applyResolvedCellDiagonalBorders(borders, value) {
|
|
999
|
+
const diagonal = spreadsheetDiagonalBorderFromCellValue(value);
|
|
1000
|
+
if (void 0 === diagonal) return;
|
|
1001
|
+
delete borders.diagonalDown;
|
|
1002
|
+
delete borders.diagonalUp;
|
|
1003
|
+
if (!diagonal) return;
|
|
1004
|
+
const line = resolvedCellBorderLine(diagonal.line);
|
|
1005
|
+
if (!line) return;
|
|
1006
|
+
if (diagonal.down) borders.diagonalDown = line;
|
|
1007
|
+
if (diagonal.up) borders.diagonalUp = line;
|
|
1008
|
+
}
|
|
1009
|
+
function resolvedCellBorderLine(value) {
|
|
1010
|
+
if (!spreadsheet_cell_border_isRecord(value)) return null;
|
|
1011
|
+
const color = 'string' == typeof value.color ? normalizeSpreadsheetBorderColor(value.color) : null;
|
|
1012
|
+
const style = 'string' == typeof value.style ? value.style : null;
|
|
1013
|
+
return color && style ? {
|
|
1014
|
+
color,
|
|
1015
|
+
style
|
|
1016
|
+
} : null;
|
|
1017
|
+
}
|
|
794
1018
|
function resolvedRangeBorderLine(value) {
|
|
795
1019
|
const color = 'string' == typeof value.color ? normalizeSpreadsheetBorderColor(value.color) : null;
|
|
796
1020
|
const style = 'string' == typeof value.style ? value.style : null;
|
|
@@ -826,7 +1050,8 @@ function applyResolvedRangeBorder(borders, range, row, column, type, line) {
|
|
|
826
1050
|
delete borders.bottom;
|
|
827
1051
|
delete borders.left;
|
|
828
1052
|
delete borders.right;
|
|
829
|
-
delete borders.
|
|
1053
|
+
delete borders.diagonalDown;
|
|
1054
|
+
delete borders.diagonalUp;
|
|
830
1055
|
break;
|
|
831
1056
|
case 'border-all':
|
|
832
1057
|
set('top');
|
|
@@ -855,10 +1080,16 @@ function applyResolvedRangeBorder(borders, range, row, column, type, line) {
|
|
|
855
1080
|
if (!onRight) set('right');
|
|
856
1081
|
break;
|
|
857
1082
|
case 'border-slash':
|
|
858
|
-
|
|
1083
|
+
if (line) {
|
|
1084
|
+
borders.diagonalDown = line;
|
|
1085
|
+
if (borders.diagonalUp) borders.diagonalUp = line;
|
|
1086
|
+
} else delete borders.diagonalDown;
|
|
859
1087
|
break;
|
|
860
1088
|
}
|
|
861
1089
|
}
|
|
1090
|
+
function isSpreadsheetDiagonalBorderTarget(target) {
|
|
1091
|
+
return 'diagonalDown' === target || 'diagonalUp' === target;
|
|
1092
|
+
}
|
|
862
1093
|
function isSpreadsheetNativeBorderType(value) {
|
|
863
1094
|
return 'string' == typeof value && spreadsheetNativeBorderTypes.has(value);
|
|
864
1095
|
}
|
|
@@ -2756,10 +2987,11 @@ const spreadsheetCommandCatalog = {
|
|
|
2756
2987
|
group: 'font'
|
|
2757
2988
|
},
|
|
2758
2989
|
shortcut: {
|
|
2759
|
-
label: 'Cmd/Ctrl+B',
|
|
2760
|
-
aria: 'Control+B Meta+B',
|
|
2990
|
+
label: 'Cmd/Ctrl+B 或 Ctrl+2',
|
|
2991
|
+
aria: 'Control+B Meta+B Control+2',
|
|
2761
2992
|
editor: [
|
|
2762
|
-
'Mod-b'
|
|
2993
|
+
'Mod-b',
|
|
2994
|
+
'Control-2'
|
|
2763
2995
|
]
|
|
2764
2996
|
}
|
|
2765
2997
|
},
|
|
@@ -2772,10 +3004,11 @@ const spreadsheetCommandCatalog = {
|
|
|
2772
3004
|
group: 'font'
|
|
2773
3005
|
},
|
|
2774
3006
|
shortcut: {
|
|
2775
|
-
label: 'Cmd/Ctrl+I',
|
|
2776
|
-
aria: 'Control+I Meta+I',
|
|
3007
|
+
label: 'Cmd/Ctrl+I 或 Ctrl+3',
|
|
3008
|
+
aria: 'Control+I Meta+I Control+3',
|
|
2777
3009
|
editor: [
|
|
2778
|
-
'Mod-i'
|
|
3010
|
+
'Mod-i',
|
|
3011
|
+
'Control-3'
|
|
2779
3012
|
]
|
|
2780
3013
|
}
|
|
2781
3014
|
},
|
|
@@ -2788,10 +3021,11 @@ const spreadsheetCommandCatalog = {
|
|
|
2788
3021
|
group: 'font'
|
|
2789
3022
|
},
|
|
2790
3023
|
shortcut: {
|
|
2791
|
-
label: 'Cmd/Ctrl+U',
|
|
2792
|
-
aria: 'Control+U Meta+U',
|
|
3024
|
+
label: 'Cmd/Ctrl+U 或 Ctrl+4',
|
|
3025
|
+
aria: 'Control+U Meta+U Control+4',
|
|
2793
3026
|
editor: [
|
|
2794
|
-
'Mod-u'
|
|
3027
|
+
'Mod-u',
|
|
3028
|
+
'Control-4'
|
|
2795
3029
|
]
|
|
2796
3030
|
}
|
|
2797
3031
|
},
|
|
@@ -3124,9 +3358,18 @@ const spreadsheetCommandCatalog = {
|
|
|
3124
3358
|
group: 'font'
|
|
3125
3359
|
}
|
|
3126
3360
|
},
|
|
3127
|
-
|
|
3128
|
-
id: 'font.
|
|
3129
|
-
label: '
|
|
3361
|
+
borderDiagonalDown: {
|
|
3362
|
+
id: 'font.borderDiagonalDown',
|
|
3363
|
+
label: '斜下框线',
|
|
3364
|
+
location: {
|
|
3365
|
+
area: 'ribbon',
|
|
3366
|
+
tab: 'home',
|
|
3367
|
+
group: 'font'
|
|
3368
|
+
}
|
|
3369
|
+
},
|
|
3370
|
+
borderDiagonalUp: {
|
|
3371
|
+
id: 'font.borderDiagonalUp',
|
|
3372
|
+
label: '斜上框线',
|
|
3130
3373
|
location: {
|
|
3131
3374
|
area: 'ribbon',
|
|
3132
3375
|
tab: 'home',
|
|
@@ -4074,14 +4317,16 @@ const MAX_SPREADSHEET_PER_CELL_BORDER_CELLS = 10000;
|
|
|
4074
4317
|
function setSpreadsheetCellBordersPerCell(content, sheetId, range, formats) {
|
|
4075
4318
|
const normalizedRange = spreadsheet_cell_range_normalizeSpreadsheetCellRange(range);
|
|
4076
4319
|
const normalizedFormats = formats.map(normalizeSpreadsheetBorderFormat);
|
|
4077
|
-
|
|
4320
|
+
const area = normalizedRange ? spreadsheet_cell_range_spreadsheetCellRangeArea(normalizedRange) : 1 / 0;
|
|
4321
|
+
if (!normalizedRange || area > MAX_SPREADSHEET_PER_CELL_BORDER_CELLS || normalizedFormats.some((format)=>!format || ![
|
|
4078
4322
|
'top',
|
|
4079
4323
|
'bottom',
|
|
4080
4324
|
'left',
|
|
4081
4325
|
'right',
|
|
4082
4326
|
'all',
|
|
4083
|
-
'
|
|
4084
|
-
|
|
4327
|
+
'diagonalDown',
|
|
4328
|
+
'diagonalUp'
|
|
4329
|
+
].includes(format.target)) || area > 4096 && normalizedFormats.some((format)=>format?.target === 'diagonalDown' || format?.target === 'diagonalUp')) return null;
|
|
4085
4330
|
const next = setSpreadsheetCellBorders(content, sheetId, normalizedRange, {
|
|
4086
4331
|
target: 'none',
|
|
4087
4332
|
color: '#000000',
|
|
@@ -4097,6 +4342,9 @@ function setSpreadsheetCellBordersPerCell(content, sheetId, range, formats) {
|
|
|
4097
4342
|
row_index: row,
|
|
4098
4343
|
col_index: column
|
|
4099
4344
|
};
|
|
4345
|
+
let diagonalDown = false;
|
|
4346
|
+
let diagonalUp = false;
|
|
4347
|
+
let diagonalLine = null;
|
|
4100
4348
|
for (const format of normalizedFormats){
|
|
4101
4349
|
if (!format) continue;
|
|
4102
4350
|
const line = {
|
|
@@ -4107,11 +4355,22 @@ function setSpreadsheetCellBordersPerCell(content, sheetId, range, formats) {
|
|
|
4107
4355
|
if ('all' === format.target || 'right' === format.target) value.r = line;
|
|
4108
4356
|
if ('all' === format.target || 'top' === format.target) value.t = line;
|
|
4109
4357
|
if ('all' === format.target || 'bottom' === format.target) value.b = line;
|
|
4110
|
-
if ('
|
|
4358
|
+
if ('diagonalDown' === format.target) {
|
|
4359
|
+
diagonalDown = true;
|
|
4360
|
+
diagonalLine = line;
|
|
4361
|
+
}
|
|
4362
|
+
if ('diagonalUp' === format.target) {
|
|
4363
|
+
diagonalUp = true;
|
|
4364
|
+
diagonalLine = line;
|
|
4365
|
+
}
|
|
4111
4366
|
}
|
|
4112
4367
|
records.push({
|
|
4113
4368
|
rangeType: 'cell',
|
|
4114
|
-
value
|
|
4369
|
+
value: diagonalLine && (diagonalDown || diagonalUp) ? spreadsheetCellValueWithDiagonalBorder(value, {
|
|
4370
|
+
down: diagonalDown,
|
|
4371
|
+
line: diagonalLine,
|
|
4372
|
+
up: diagonalUp
|
|
4373
|
+
}) : value
|
|
4115
4374
|
});
|
|
4116
4375
|
}
|
|
4117
4376
|
const borderInfo = [
|
|
@@ -4177,8 +4436,9 @@ function canApplySpreadsheetCellFormat(content, request) {
|
|
|
4177
4436
|
'left',
|
|
4178
4437
|
'right',
|
|
4179
4438
|
'all',
|
|
4180
|
-
'
|
|
4181
|
-
|
|
4439
|
+
'diagonalDown',
|
|
4440
|
+
'diagonalUp'
|
|
4441
|
+
].includes(format.target)) || normalized.some((format)=>format?.target === 'diagonalDown' || format?.target === 'diagonalUp') && spreadsheet_cell_range_spreadsheetCellRangeArea(range) > 4096) return false;
|
|
4182
4442
|
}
|
|
4183
4443
|
return true;
|
|
4184
4444
|
}
|
|
@@ -4696,14 +4956,16 @@ function sameCellStyleBorders(actual, formats) {
|
|
|
4696
4956
|
if ('all' === format.target || 'right' === format.target) expected.right = line;
|
|
4697
4957
|
if ('all' === format.target || 'top' === format.target) expected.top = line;
|
|
4698
4958
|
if ('all' === format.target || 'bottom' === format.target) expected.bottom = line;
|
|
4699
|
-
if ('
|
|
4959
|
+
if ('diagonalDown' === format.target) expected.diagonalDown = line;
|
|
4960
|
+
if ('diagonalUp' === format.target) expected.diagonalUp = line;
|
|
4700
4961
|
}
|
|
4701
4962
|
return [
|
|
4702
4963
|
'top',
|
|
4703
4964
|
'bottom',
|
|
4704
4965
|
'left',
|
|
4705
4966
|
'right',
|
|
4706
|
-
'
|
|
4967
|
+
'diagonalDown',
|
|
4968
|
+
'diagonalUp'
|
|
4707
4969
|
].every((side)=>actual[side]?.color === expected[side]?.color && actual[side]?.style === expected[side]?.style);
|
|
4708
4970
|
}
|
|
4709
4971
|
function createSpreadsheetCellStyleExtension() {
|
|
@@ -6614,15 +6876,18 @@ function createSpreadsheetKeyboardShortcutExtension() {
|
|
|
6614
6876
|
name: 'spreadsheetKeyboardShortcuts',
|
|
6615
6877
|
addKeyboardShortcuts: ()=>({
|
|
6616
6878
|
'Mod-a': ({ can, commands }, event)=>selectSpreadsheetFormulaBarContents(event) || runSpreadsheetSelectionScopeShortcut(event, can.selectCellRange, commands.selectCellRange, 'all'),
|
|
6617
|
-
|
|
6879
|
+
[spreadsheetCommandCatalog.bold.shortcut.editor["0"]]: ({ can, commands, context }, event)=>runSpreadsheetCellFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'bl'),
|
|
6880
|
+
[spreadsheetCommandCatalog.bold.shortcut.editor["1"]]: ({ can, commands, context }, event)=>runSpreadsheetCellFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'bl'),
|
|
6618
6881
|
'Mod-c': ({ can, commands }, event)=>runSpreadsheetClipboardShortcut(event, can.copySelection, commands.copySelection),
|
|
6619
6882
|
'Mod-d': ({ can, commands }, event)=>runSpreadsheetFillShortcut(event, can.fillSelectedCells, commands.fillSelectedCells, 'down'),
|
|
6620
|
-
|
|
6883
|
+
[spreadsheetCommandCatalog.italic.shortcut.editor["0"]]: ({ can, commands, context }, event)=>runSpreadsheetCellFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'it'),
|
|
6884
|
+
[spreadsheetCommandCatalog.italic.shortcut.editor["1"]]: ({ can, commands, context }, event)=>runSpreadsheetCellFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'it'),
|
|
6621
6885
|
'Mod-r': ({ can, commands }, event)=>runSpreadsheetFillShortcut(event, can.fillSelectedCells, commands.fillSelectedCells, 'right'),
|
|
6622
6886
|
'Mod-v': ({ can, commands }, event)=>runSpreadsheetClipboardShortcut(event, can.pasteSelection, commands.pasteSelection),
|
|
6623
6887
|
[spreadsheetCommandCatalog.pasteSpecial.shortcut.editor["0"]]: ({ can, commands }, event)=>runSpreadsheetPasteSpecialShortcut(event, can.openPasteSpecial, commands.openPasteSpecial),
|
|
6624
6888
|
'Mod-x': ({ can, commands }, event)=>runSpreadsheetClipboardShortcut(event, can.cutSelection, commands.cutSelection),
|
|
6625
|
-
|
|
6889
|
+
[spreadsheetCommandCatalog.underline.shortcut.editor["0"]]: ({ can, commands, context }, event)=>runSpreadsheetCellFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'un'),
|
|
6890
|
+
[spreadsheetCommandCatalog.underline.shortcut.editor["1"]]: ({ can, commands, context }, event)=>runSpreadsheetCellFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'un'),
|
|
6626
6891
|
'Mod-5': ({ can, commands, context }, event)=>runSpreadsheetCellFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'cl'),
|
|
6627
6892
|
[spreadsheetCommandCatalog.numberFormatGeneral.shortcut.editor["0"]]: ({ can, commands, context }, event)=>runSpreadsheetNumberFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'general'),
|
|
6628
6893
|
[spreadsheetCommandCatalog.numberFormatNumber.shortcut.editor["0"]]: ({ can, commands, context }, event)=>runSpreadsheetNumberFormatShortcut(event, context, can.setCellFormat, commands.setCellFormat, 'number'),
|
|
@@ -10189,8 +10454,12 @@ const spreadsheetBorderTargetOptions = [
|
|
|
10189
10454
|
definition: spreadsheetCommandCatalog.borderVertical
|
|
10190
10455
|
},
|
|
10191
10456
|
{
|
|
10192
|
-
target: '
|
|
10193
|
-
definition: spreadsheetCommandCatalog.
|
|
10457
|
+
target: 'diagonalDown',
|
|
10458
|
+
definition: spreadsheetCommandCatalog.borderDiagonalDown
|
|
10459
|
+
},
|
|
10460
|
+
{
|
|
10461
|
+
target: 'diagonalUp',
|
|
10462
|
+
definition: spreadsheetCommandCatalog.borderDiagonalUp
|
|
10194
10463
|
}
|
|
10195
10464
|
];
|
|
10196
10465
|
function SpreadsheetBorderRibbon({ can, commands }) {
|
|
@@ -10609,7 +10878,12 @@ function SpreadsheetFontRibbonGroup({ can, commands, toolbarCell }) {
|
|
|
10609
10878
|
ariaLabel: "文字颜色",
|
|
10610
10879
|
value: textColor,
|
|
10611
10880
|
disabled: !can.setCellFormat('fc', textColor),
|
|
10612
|
-
onValueChange: (value)=>commands.setCellFormat('fc', value)
|
|
10881
|
+
onValueChange: (value)=>commands.setCellFormat('fc', value),
|
|
10882
|
+
resetAction: {
|
|
10883
|
+
kind: 'automatic',
|
|
10884
|
+
label: '自动颜色',
|
|
10885
|
+
onSelect: ()=>commands.setCellFormat('fc', void 0)
|
|
10886
|
+
}
|
|
10613
10887
|
}),
|
|
10614
10888
|
/*#__PURE__*/ jsx(OfficeColorPicker, {
|
|
10615
10889
|
compact: true,
|
|
@@ -10617,7 +10891,12 @@ function SpreadsheetFontRibbonGroup({ can, commands, toolbarCell }) {
|
|
|
10617
10891
|
ariaLabel: "填充颜色",
|
|
10618
10892
|
value: fillColor,
|
|
10619
10893
|
disabled: !can.setCellFormat('bg', fillColor),
|
|
10620
|
-
onValueChange: (value)=>commands.setCellFormat('bg', value)
|
|
10894
|
+
onValueChange: (value)=>commands.setCellFormat('bg', value),
|
|
10895
|
+
resetAction: {
|
|
10896
|
+
kind: 'none',
|
|
10897
|
+
label: '无填充',
|
|
10898
|
+
onSelect: ()=>commands.setCellFormat('bg', void 0)
|
|
10899
|
+
}
|
|
10621
10900
|
}),
|
|
10622
10901
|
/*#__PURE__*/ jsx(SpreadsheetBorderRibbon, {
|
|
10623
10902
|
can: can,
|
|
@@ -12664,8 +12943,12 @@ const borderTargets = [
|
|
|
12664
12943
|
label: '右框线'
|
|
12665
12944
|
},
|
|
12666
12945
|
{
|
|
12667
|
-
target: '
|
|
12668
|
-
label: '
|
|
12946
|
+
target: 'diagonalDown',
|
|
12947
|
+
label: '斜下框线'
|
|
12948
|
+
},
|
|
12949
|
+
{
|
|
12950
|
+
target: 'diagonalUp',
|
|
12951
|
+
label: '斜上框线'
|
|
12669
12952
|
}
|
|
12670
12953
|
];
|
|
12671
12954
|
function SpreadsheetFormatCellsPanel(props) {
|
|
@@ -13098,10 +13381,16 @@ function BorderPreview({ draft }) {
|
|
|
13098
13381
|
borderRight: line('right')
|
|
13099
13382
|
}
|
|
13100
13383
|
}),
|
|
13101
|
-
line('
|
|
13102
|
-
className: "diagonal",
|
|
13384
|
+
line('diagonalDown') && /*#__PURE__*/ jsx("span", {
|
|
13385
|
+
className: "diagonal-down",
|
|
13386
|
+
style: {
|
|
13387
|
+
borderTop: line('diagonalDown')
|
|
13388
|
+
}
|
|
13389
|
+
}),
|
|
13390
|
+
line('diagonalUp') && /*#__PURE__*/ jsx("span", {
|
|
13391
|
+
className: "diagonal-up",
|
|
13103
13392
|
style: {
|
|
13104
|
-
borderTop: line('
|
|
13393
|
+
borderTop: line('diagonalUp')
|
|
13105
13394
|
}
|
|
13106
13395
|
}),
|
|
13107
13396
|
/*#__PURE__*/ jsx("strong", {
|
|
@@ -13372,7 +13661,8 @@ function borderFormatsAt(sheet, row, column) {
|
|
|
13372
13661
|
'bottom',
|
|
13373
13662
|
'left',
|
|
13374
13663
|
'right',
|
|
13375
|
-
'
|
|
13664
|
+
'diagonalDown',
|
|
13665
|
+
'diagonalUp'
|
|
13376
13666
|
].flatMap((target)=>{
|
|
13377
13667
|
const line = resolved[target];
|
|
13378
13668
|
if (!line) return [];
|
|
@@ -20310,20 +20600,22 @@ function applySpreadsheetPasteBorders(content, sheetId, snapshot, plan, processe
|
|
|
20310
20600
|
[
|
|
20311
20601
|
'bottom',
|
|
20312
20602
|
'b'
|
|
20313
|
-
],
|
|
20314
|
-
[
|
|
20315
|
-
'diagonal',
|
|
20316
|
-
's'
|
|
20317
20603
|
]
|
|
20318
20604
|
];
|
|
20319
20605
|
for (const [side, key] of sides){
|
|
20320
20606
|
const line = source.borders[side];
|
|
20321
20607
|
if (line) value[key] = structuredClone(line);
|
|
20322
20608
|
}
|
|
20323
|
-
|
|
20609
|
+
const diagonal = source.borders.diagonalUp ?? source.borders.diagonalDown ?? null;
|
|
20610
|
+
const withDiagonal = diagonal ? spreadsheetCellValueWithDiagonalBorder(value, {
|
|
20611
|
+
down: Boolean(source.borders.diagonalDown),
|
|
20612
|
+
line: structuredClone(diagonal),
|
|
20613
|
+
up: Boolean(source.borders.diagonalUp)
|
|
20614
|
+
}) : value;
|
|
20615
|
+
return Object.keys(withDiagonal).length > 2 ? [
|
|
20324
20616
|
{
|
|
20325
20617
|
rangeType: 'cell',
|
|
20326
|
-
value
|
|
20618
|
+
value: withDiagonal
|
|
20327
20619
|
}
|
|
20328
20620
|
] : [];
|
|
20329
20621
|
});
|
|
@@ -22611,6 +22903,16 @@ function SpreadsheetEditorSurface({ autoFocus = true, content, collaborationHist
|
|
|
22611
22903
|
]);
|
|
22612
22904
|
const tableStylesBySheetRef = useRef(tableStylesBySheet);
|
|
22613
22905
|
tableStylesBySheetRef.current = tableStylesBySheet;
|
|
22906
|
+
const diagonalBordersBySheet = useMemo(()=>new Map(materializedContent.sheets.flatMap((sheet)=>sheet.id ? [
|
|
22907
|
+
[
|
|
22908
|
+
sheet.id,
|
|
22909
|
+
spreadsheetRenderableDiagonalBorders(sheet)
|
|
22910
|
+
]
|
|
22911
|
+
] : [])), [
|
|
22912
|
+
materializedContent.sheets
|
|
22913
|
+
]);
|
|
22914
|
+
const diagonalBordersBySheetRef = useRef(diagonalBordersBySheet);
|
|
22915
|
+
diagonalBordersBySheetRef.current = diagonalBordersBySheet;
|
|
22614
22916
|
useEffect(()=>{
|
|
22615
22917
|
setPreviewActiveSheetId(preview ? contentActiveSheetId : null);
|
|
22616
22918
|
}, [
|
|
@@ -22742,6 +23044,9 @@ function SpreadsheetEditorSurface({ autoFocus = true, content, collaborationHist
|
|
|
22742
23044
|
}
|
|
22743
23045
|
} finally{
|
|
22744
23046
|
finishSpreadsheetTableCellRender(cell, cellInfo, tableStyle, context);
|
|
23047
|
+
const diagonal = diagonalBordersBySheetRef.current.get(activeSheetIdRef.current)?.get(`${cellInfo.row}_${cellInfo.column}`);
|
|
23048
|
+
if (diagonal?.down) drawSpreadsheetDiagonalDownBorder(context, cellInfo, diagonal.down);
|
|
23049
|
+
if (diagonal?.up) drawSpreadsheetDiagonalUpBorder(context, cellInfo, diagonal.up);
|
|
22745
23050
|
}
|
|
22746
23051
|
}
|
|
22747
23052
|
}), [
|