@rowsncolumns/spreadsheet 10.6.4 → 10.6.5
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/dist/cjs/components/cell/alignment.d.ts +25 -0
- package/dist/cjs/components/cell/alignment.d.ts.map +1 -1
- package/dist/cjs/components/cell/alignment.js +39 -1
- package/dist/cjs/components/cell/cell-background.d.ts +16 -0
- package/dist/cjs/components/cell/cell-background.d.ts.map +1 -1
- package/dist/cjs/components/cell/cell-background.js +141 -54
- package/dist/cjs/components/cell/cell-text-runs.d.ts +12 -5
- package/dist/cjs/components/cell/cell-text-runs.d.ts.map +1 -1
- package/dist/cjs/components/cell/cell-text-runs.js +18 -20
- package/dist/cjs/components/cell/index.d.ts.map +1 -1
- package/dist/cjs/components/cell/index.js +20 -14
- package/dist/cjs/helpers.d.ts +5 -0
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/helpers.js +8 -4
- package/dist/esm/components/cell/alignment.d.ts +25 -0
- package/dist/esm/components/cell/alignment.d.ts.map +1 -1
- package/dist/esm/components/cell/alignment.js +33 -0
- package/dist/esm/components/cell/cell-background.d.ts +16 -0
- package/dist/esm/components/cell/cell-background.d.ts.map +1 -1
- package/dist/esm/components/cell/cell-background.js +106 -36
- package/dist/esm/components/cell/cell-text-runs.d.ts +12 -5
- package/dist/esm/components/cell/cell-text-runs.d.ts.map +1 -1
- package/dist/esm/components/cell/cell-text-runs.js +17 -22
- package/dist/esm/components/cell/index.d.ts.map +1 -1
- package/dist/esm/components/cell/index.js +17 -11
- package/dist/esm/helpers.d.ts +5 -0
- package/dist/esm/helpers.d.ts.map +1 -1
- package/dist/esm/helpers.js +8 -4
- package/package.json +2 -2
|
@@ -154,4 +154,29 @@ export type DistributedWord = {
|
|
|
154
154
|
* the words of each line with their x inside `width`.
|
|
155
155
|
*/
|
|
156
156
|
export declare const layoutDistributedLines: (text: string, width: number, measure: (text: string) => number) => DistributedWord[][];
|
|
157
|
+
/**
|
|
158
|
+
* Excel's superscript sits on a baseline raised by a third of the line's
|
|
159
|
+
* font size, subscript on one dropped by about a seventh (Format Cells ▸
|
|
160
|
+
* Font ▸ Effects): a true baseline shift, not the glyphs pushed to the top
|
|
161
|
+
* or bottom of the cell.
|
|
162
|
+
*/
|
|
163
|
+
export declare const SUPERSCRIPT_RISE_EM = 0.33;
|
|
164
|
+
export declare const SUBSCRIPT_DROP_EM = 0.14;
|
|
165
|
+
/** Baseline shift (px, down positive) of a sup/sub run on a `lineFontSize` line. */
|
|
166
|
+
export declare const getScriptBaselineShift: (baselineOffset: "superscript" | "subscript" | string | null | undefined, lineFontSize: number) => number;
|
|
167
|
+
/**
|
|
168
|
+
* Konva `offsetY` (up positive) for a cell whose whole text is superscript /
|
|
169
|
+
* subscript: the text node draws the smaller script font aligned like the
|
|
170
|
+
* cell, and this moves its baseline to where Excel puts it — the base
|
|
171
|
+
* font's baseline in that alignment, shifted by
|
|
172
|
+
* {@link getScriptBaselineShift}.
|
|
173
|
+
*/
|
|
174
|
+
export declare const getScriptTextOffsetY: ({ baselineOffset, verticalAlign, baseFontSize, scriptFontSize, lineHeight, }: {
|
|
175
|
+
baselineOffset: "superscript" | "subscript" | string | null | undefined;
|
|
176
|
+
verticalAlign: "top" | "middle" | "bottom";
|
|
177
|
+
baseFontSize: number;
|
|
178
|
+
scriptFontSize: number;
|
|
179
|
+
/** Line-box multiple of the font size the text node uses. */
|
|
180
|
+
lineHeight: number;
|
|
181
|
+
}) => number;
|
|
157
182
|
//# sourceMappingURL=alignment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alignment.d.ts","sourceRoot":"","sources":["../../../../components/cell/alignment.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM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,MAAM,sBAAsB,GACjC,MAAM,MAAM,EACZ,OAAO,MAAM,EACb,SAAS,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,KAChC,eAAe,EAAE,EA0CnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,oFAAoF;AACpF,eAAO,MAAM,sBAAsB,GACjC,gBAAgB,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACvE,cAAc,MAAM,KACnB,MAKI,CAAC;AAKR;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,8EAMlC;IACD,cAAc,EAAE,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxE,aAAa,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;CACpB,KAAG,MAWH,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// (scale font down when text overflows) and textRotation (numeric degrees
|
|
4
4
|
// or stacked "vertical" layout).
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.layoutDistributedLines = exports.getRotatedTextLayout = exports.stackTextVertically = exports.getKonvaRotationDegrees = exports.computeShrinkToFitFontSize = exports.fillCellText = exports.isFillAlignment = exports.getUnderlineStrokes = exports.resolveReadingOrderAlignment = exports.getVerticalSpreadLineHeight = exports.resolveCanvasVerticalAlign = exports.verticalAlignmentImpliesWrap = exports.alignmentImpliesWrap = exports.resolveCanvasTextAlign = void 0;
|
|
6
|
+
exports.getScriptTextOffsetY = exports.getScriptBaselineShift = exports.SUBSCRIPT_DROP_EM = exports.SUPERSCRIPT_RISE_EM = exports.layoutDistributedLines = exports.getRotatedTextLayout = exports.stackTextVertically = exports.getKonvaRotationDegrees = exports.computeShrinkToFitFontSize = exports.fillCellText = exports.isFillAlignment = exports.getUnderlineStrokes = exports.resolveReadingOrderAlignment = exports.getVerticalSpreadLineHeight = exports.resolveCanvasVerticalAlign = exports.verticalAlignmentImpliesWrap = exports.alignmentImpliesWrap = exports.resolveCanvasTextAlign = void 0;
|
|
7
7
|
var tslib_1 = require("tslib");
|
|
8
8
|
/**
|
|
9
9
|
* Map a cell's `horizontalAlignment` onto the canvas text alignment. Excel's
|
|
@@ -333,3 +333,41 @@ var layoutDistributedLines = function (text, width, measure) {
|
|
|
333
333
|
return lines;
|
|
334
334
|
};
|
|
335
335
|
exports.layoutDistributedLines = layoutDistributedLines;
|
|
336
|
+
/**
|
|
337
|
+
* Excel's superscript sits on a baseline raised by a third of the line's
|
|
338
|
+
* font size, subscript on one dropped by about a seventh (Format Cells ▸
|
|
339
|
+
* Font ▸ Effects): a true baseline shift, not the glyphs pushed to the top
|
|
340
|
+
* or bottom of the cell.
|
|
341
|
+
*/
|
|
342
|
+
exports.SUPERSCRIPT_RISE_EM = 0.33;
|
|
343
|
+
exports.SUBSCRIPT_DROP_EM = 0.14;
|
|
344
|
+
/** Baseline shift (px, down positive) of a sup/sub run on a `lineFontSize` line. */
|
|
345
|
+
var getScriptBaselineShift = function (baselineOffset, lineFontSize) {
|
|
346
|
+
return baselineOffset === "superscript"
|
|
347
|
+
? -exports.SUPERSCRIPT_RISE_EM * lineFontSize
|
|
348
|
+
: baselineOffset === "subscript"
|
|
349
|
+
? exports.SUBSCRIPT_DROP_EM * lineFontSize
|
|
350
|
+
: 0;
|
|
351
|
+
};
|
|
352
|
+
exports.getScriptBaselineShift = getScriptBaselineShift;
|
|
353
|
+
/** Distance from a Konva line box's top to its alphabetic baseline, ≈. */
|
|
354
|
+
var BASELINE_BELOW_CENTRE_EM = 0.35;
|
|
355
|
+
/**
|
|
356
|
+
* Konva `offsetY` (up positive) for a cell whose whole text is superscript /
|
|
357
|
+
* subscript: the text node draws the smaller script font aligned like the
|
|
358
|
+
* cell, and this moves its baseline to where Excel puts it — the base
|
|
359
|
+
* font's baseline in that alignment, shifted by
|
|
360
|
+
* {@link getScriptBaselineShift}.
|
|
361
|
+
*/
|
|
362
|
+
var getScriptTextOffsetY = function (_a) {
|
|
363
|
+
var baselineOffset = _a.baselineOffset, verticalAlign = _a.verticalAlign, baseFontSize = _a.baseFontSize, scriptFontSize = _a.scriptFontSize, lineHeight = _a.lineHeight;
|
|
364
|
+
if (baselineOffset !== "superscript" && baselineOffset !== "subscript") {
|
|
365
|
+
return 0;
|
|
366
|
+
}
|
|
367
|
+
var boxDelta = ((baseFontSize - scriptFontSize) * lineHeight) / 2;
|
|
368
|
+
var centreDelta = BASELINE_BELOW_CENTRE_EM * (baseFontSize - scriptFontSize);
|
|
369
|
+
var alignDelta = verticalAlign === "top" ? boxDelta : verticalAlign === "bottom" ? -boxDelta : 0;
|
|
370
|
+
var down = alignDelta + centreDelta + (0, exports.getScriptBaselineShift)(baselineOffset, baseFontSize);
|
|
371
|
+
return -down;
|
|
372
|
+
};
|
|
373
|
+
exports.getScriptTextOffsetY = getScriptTextOffsetY;
|
|
@@ -12,6 +12,22 @@ type CellBackgroundProps = RendererProps & {
|
|
|
12
12
|
foregroundColor?: string;
|
|
13
13
|
gradient?: GradientFill | null;
|
|
14
14
|
};
|
|
15
|
+
export type PathGradientRegion = {
|
|
16
|
+
/** Polygon to fill, in shape coordinates. */
|
|
17
|
+
points: [number, number][];
|
|
18
|
+
/** Gradient axis: inner stop at (x0, y0), outer stop at (x1, y1). */
|
|
19
|
+
axis: [number, number, number, number];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Excel's path gradient over the rectangle `[x0, y0]–[x1, y1]`: the core
|
|
23
|
+
* rectangle (inner stop colour) and four trapezoids cut along the
|
|
24
|
+
* core-to-corner diagonals, each a linear gradient from the core edge out
|
|
25
|
+
* to its cell edge — together, concentric rectangles of colour.
|
|
26
|
+
*/
|
|
27
|
+
export declare const getPathGradientRegions: (gradient: Pick<GradientFill, "left" | "right" | "top" | "bottom">, x0: number, y0: number, x1: number, y1: number) => {
|
|
28
|
+
core: [number, number, number, number];
|
|
29
|
+
regions: PathGradientRegion[];
|
|
30
|
+
};
|
|
15
31
|
export declare const CellBackground: ({ x, y, width, height, backgroundColor, defaultBackgroundColor, scale, showGridLines, isMergedCell, fillPattern, foregroundColor, gradient, }: CellBackgroundProps) => React.JSX.Element;
|
|
16
32
|
export {};
|
|
17
33
|
//# sourceMappingURL=cell-background.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-background.d.ts","sourceRoot":"","sources":["../../../../components/cell/cell-background.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD,KAAK,mBAAmB,GAAG,aAAa,GAAG;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"cell-background.d.ts","sourceRoot":"","sources":["../../../../components/cell/cell-background.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD,KAAK,mBAAmB,GAAG,aAAa,GAAG;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAChC,CAAC;AAWF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,6CAA6C;IAC7C,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3B,qEAAqE;IACrE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC,EACjE,IAAI,MAAM,EACV,IAAI,MAAM,EACV,IAAI,MAAM,EACV,IAAI,MAAM,KACT;IAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,kBAAkB,EAAE,CAAA;CAoDzE,CAAC;AAkFF,eAAO,MAAM,cAAc,GAAI,+IAa5B,mBAAmB,sBAmGrB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CellBackground = exports.AUTOMATIC_PATTERN_COLOR = void 0;
|
|
3
|
+
exports.CellBackground = exports.getPathGradientRegions = exports.AUTOMATIC_PATTERN_COLOR = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var utils_1 = require("@rowsncolumns/utils");
|
|
6
6
|
var react_1 = tslib_1.__importDefault(require("react"));
|
|
@@ -8,35 +8,132 @@ var react_konva_1 = require("react-konva");
|
|
|
8
8
|
var fill_patterns_1 = require("../../api/fill-patterns");
|
|
9
9
|
/** Excel's Automatic pattern colour: a pattern with no colour of its own. */
|
|
10
10
|
exports.AUTOMATIC_PATTERN_COLOR = "#000000";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Excel's path gradient over the rectangle `[x0, y0]–[x1, y1]`: the core
|
|
13
|
+
* rectangle (inner stop colour) and four trapezoids cut along the
|
|
14
|
+
* core-to-corner diagonals, each a linear gradient from the core edge out
|
|
15
|
+
* to its cell edge — together, concentric rectangles of colour.
|
|
16
|
+
*/
|
|
17
|
+
var getPathGradientRegions = function (gradient, x0, y0, x1, y1) {
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
|
+
var width = x1 - x0;
|
|
20
|
+
var height = y1 - y0;
|
|
21
|
+
var cl = x0 + ((_a = gradient.left) !== null && _a !== void 0 ? _a : 0) * width;
|
|
22
|
+
var cr = x1 - ((_b = gradient.right) !== null && _b !== void 0 ? _b : 0) * width;
|
|
23
|
+
var ct = y0 + ((_c = gradient.top) !== null && _c !== void 0 ? _c : 0) * height;
|
|
24
|
+
var cb = y1 - ((_d = gradient.bottom) !== null && _d !== void 0 ? _d : 0) * height;
|
|
25
|
+
var coreLeft = Math.min(cl, cr);
|
|
26
|
+
var coreRight = Math.max(cl, cr);
|
|
27
|
+
var coreTop = Math.min(ct, cb);
|
|
28
|
+
var coreBottom = Math.max(ct, cb);
|
|
29
|
+
return {
|
|
30
|
+
core: [coreLeft, coreTop, coreRight, coreBottom],
|
|
31
|
+
regions: [
|
|
32
|
+
{
|
|
33
|
+
points: [
|
|
34
|
+
[x0, y0],
|
|
35
|
+
[x1, y0],
|
|
36
|
+
[coreRight, coreTop],
|
|
37
|
+
[coreLeft, coreTop],
|
|
38
|
+
],
|
|
39
|
+
axis: [coreLeft, coreTop, coreLeft, y0],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
points: [
|
|
43
|
+
[x1, y0],
|
|
44
|
+
[x1, y1],
|
|
45
|
+
[coreRight, coreBottom],
|
|
46
|
+
[coreRight, coreTop],
|
|
47
|
+
],
|
|
48
|
+
axis: [coreRight, coreTop, x1, coreTop],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
points: [
|
|
52
|
+
[x1, y1],
|
|
53
|
+
[x0, y1],
|
|
54
|
+
[coreLeft, coreBottom],
|
|
55
|
+
[coreRight, coreBottom],
|
|
56
|
+
],
|
|
57
|
+
axis: [coreLeft, coreBottom, coreLeft, y1],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
points: [
|
|
61
|
+
[x0, y1],
|
|
62
|
+
[x0, y0],
|
|
63
|
+
[coreLeft, coreTop],
|
|
64
|
+
[coreLeft, coreBottom],
|
|
65
|
+
],
|
|
66
|
+
axis: [coreLeft, coreTop, x0, coreTop],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
exports.getPathGradientRegions = getPathGradientRegions;
|
|
72
|
+
var addStops = function (canvasGrad, gradient) {
|
|
73
|
+
var e_1, _a;
|
|
74
|
+
try {
|
|
75
|
+
for (var _b = tslib_1.__values(gradient.stops), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
76
|
+
var stop_1 = _c.value;
|
|
77
|
+
// Clamp position to [0,1] — Canvas API rejects out-of-range values.
|
|
78
|
+
var pos = Math.max(0, Math.min(1, stop_1.position));
|
|
79
|
+
try {
|
|
80
|
+
canvasGrad.addColorStop(pos, stop_1.color);
|
|
81
|
+
}
|
|
82
|
+
catch (_d) {
|
|
83
|
+
// Invalid color string — skip rather than blow up the render.
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
88
|
+
finally {
|
|
89
|
+
try {
|
|
90
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
91
|
+
}
|
|
92
|
+
finally { if (e_1) throw e_1.error; }
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var paintPathGradient = function (context, native, gradient, rect) {
|
|
96
|
+
var e_2, _a;
|
|
97
|
+
var _b = exports.getPathGradientRegions.apply(void 0, tslib_1.__spreadArray([gradient], tslib_1.__read(rect), false)), core = _b.core, regions = _b.regions;
|
|
98
|
+
var sorted = tslib_1.__spreadArray([], tslib_1.__read(gradient.stops), false).sort(function (a, b) { return a.position - b.position; });
|
|
99
|
+
context.setAttr("fillStyle", sorted[0].color);
|
|
100
|
+
context.fillRect(core[0], core[1], core[2] - core[0], core[3] - core[1]);
|
|
101
|
+
try {
|
|
102
|
+
for (var regions_1 = tslib_1.__values(regions), regions_1_1 = regions_1.next(); !regions_1_1.done; regions_1_1 = regions_1.next()) {
|
|
103
|
+
var region = regions_1_1.value;
|
|
104
|
+
var _c = tslib_1.__read(region.axis, 4), ax0 = _c[0], ay0 = _c[1], ax1 = _c[2], ay1 = _c[3];
|
|
105
|
+
if (ax0 === ax1 && ay0 === ay1)
|
|
106
|
+
continue;
|
|
107
|
+
var canvasGrad = native.createLinearGradient(ax0, ay0, ax1, ay1);
|
|
108
|
+
addStops(canvasGrad, gradient);
|
|
109
|
+
context.beginPath();
|
|
110
|
+
region.points.forEach(function (_a, index) {
|
|
111
|
+
var _b = tslib_1.__read(_a, 2), px = _b[0], py = _b[1];
|
|
112
|
+
return index ? context.lineTo(px, py) : context.moveTo(px, py);
|
|
113
|
+
});
|
|
114
|
+
context.closePath();
|
|
115
|
+
context.setAttr("fillStyle", canvasGrad);
|
|
116
|
+
context.fill();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
120
|
+
finally {
|
|
121
|
+
try {
|
|
122
|
+
if (regions_1_1 && !regions_1_1.done && (_a = regions_1.return)) _a.call(regions_1);
|
|
123
|
+
}
|
|
124
|
+
finally { if (e_2) throw e_2.error; }
|
|
125
|
+
}
|
|
126
|
+
};
|
|
20
127
|
var buildCanvasGradient = function (native, gradient, width, height) {
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
if (!((
|
|
128
|
+
var e_3, _a;
|
|
129
|
+
var _b, _c;
|
|
130
|
+
if (!((_b = gradient.stops) === null || _b === void 0 ? void 0 : _b.length))
|
|
24
131
|
return null;
|
|
25
132
|
var canvasGrad;
|
|
26
|
-
|
|
27
|
-
var left = (_d = gradient.left) !== null && _d !== void 0 ? _d : 0;
|
|
28
|
-
var right = (_e = gradient.right) !== null && _e !== void 0 ? _e : 0;
|
|
29
|
-
var top_1 = (_f = gradient.top) !== null && _f !== void 0 ? _f : 0;
|
|
30
|
-
var bottom = (_g = gradient.bottom) !== null && _g !== void 0 ? _g : 0;
|
|
31
|
-
var cx = ((left + (1 - right)) / 2) * width;
|
|
32
|
-
var cy = ((top_1 + (1 - bottom)) / 2) * height;
|
|
33
|
-
var farthestCorner = Math.max(Math.hypot(cx, cy), Math.hypot(width - cx, cy), Math.hypot(cx, height - cy), Math.hypot(width - cx, height - cy));
|
|
34
|
-
canvasGrad = native.createRadialGradient(cx, cy, 0, cx, cy, farthestCorner || 1);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
133
|
+
{
|
|
37
134
|
// Linear. Map degrees → axis vector. Excel: degree=0 runs the
|
|
38
135
|
// gradient from LEFT to RIGHT. degree increases clockwise.
|
|
39
|
-
var deg = ((((
|
|
136
|
+
var deg = ((((_c = gradient.degree) !== null && _c !== void 0 ? _c : 0) % 360) + 360) % 360;
|
|
40
137
|
var rad = (deg * Math.PI) / 180;
|
|
41
138
|
// Project the axis through the rect's center; the start/end points
|
|
42
139
|
// are where that axis exits the bounding box (handled by computing
|
|
@@ -55,7 +152,7 @@ var buildCanvasGradient = function (native, gradient, width, height) {
|
|
|
55
152
|
var maxProj = -Infinity;
|
|
56
153
|
try {
|
|
57
154
|
for (var corners_1 = tslib_1.__values(corners), corners_1_1 = corners_1.next(); !corners_1_1.done; corners_1_1 = corners_1.next()) {
|
|
58
|
-
var
|
|
155
|
+
var _d = tslib_1.__read(corners_1_1.value, 2), px = _d[0], py = _d[1];
|
|
59
156
|
var proj = (px - cx) * dx + (py - cy) * dy;
|
|
60
157
|
if (proj < minProj)
|
|
61
158
|
minProj = proj;
|
|
@@ -63,12 +160,12 @@ var buildCanvasGradient = function (native, gradient, width, height) {
|
|
|
63
160
|
maxProj = proj;
|
|
64
161
|
}
|
|
65
162
|
}
|
|
66
|
-
catch (
|
|
163
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
67
164
|
finally {
|
|
68
165
|
try {
|
|
69
166
|
if (corners_1_1 && !corners_1_1.done && (_a = corners_1.return)) _a.call(corners_1);
|
|
70
167
|
}
|
|
71
|
-
finally { if (
|
|
168
|
+
finally { if (e_3) throw e_3.error; }
|
|
72
169
|
}
|
|
73
170
|
var x0 = cx + dx * minProj;
|
|
74
171
|
var y0 = cy + dy * minProj;
|
|
@@ -76,26 +173,7 @@ var buildCanvasGradient = function (native, gradient, width, height) {
|
|
|
76
173
|
var y1 = cy + dy * maxProj;
|
|
77
174
|
canvasGrad = native.createLinearGradient(x0, y0, x1, y1);
|
|
78
175
|
}
|
|
79
|
-
|
|
80
|
-
for (var _k = tslib_1.__values(gradient.stops), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
81
|
-
var stop_1 = _l.value;
|
|
82
|
-
// Clamp position to [0,1] — Canvas API rejects out-of-range values.
|
|
83
|
-
var pos = Math.max(0, Math.min(1, stop_1.position));
|
|
84
|
-
try {
|
|
85
|
-
canvasGrad.addColorStop(pos, stop_1.color);
|
|
86
|
-
}
|
|
87
|
-
catch (_m) {
|
|
88
|
-
// Invalid color string — skip rather than blow up the render.
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
93
|
-
finally {
|
|
94
|
-
try {
|
|
95
|
-
if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
|
|
96
|
-
}
|
|
97
|
-
finally { if (e_2) throw e_2.error; }
|
|
98
|
-
}
|
|
176
|
+
addStops(canvasGrad, gradient);
|
|
99
177
|
return canvasGrad;
|
|
100
178
|
};
|
|
101
179
|
var CellBackground = function (_a) {
|
|
@@ -124,7 +202,14 @@ var CellBackground = function (_a) {
|
|
|
124
202
|
var useTile = fillPattern && fillPattern !== "solid" && fillPattern !== "none";
|
|
125
203
|
var useGradient = !!gradient && ((_c = (_b = gradient.stops) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0;
|
|
126
204
|
var native = context._context;
|
|
127
|
-
|
|
205
|
+
var fillRectArea = (isMergedCell || !showFaintBorder) && showGridLines
|
|
206
|
+
? [1, 1, shape.width(), shape.height()]
|
|
207
|
+
: [0, 0, shape.width() + 1, shape.height() + 1];
|
|
208
|
+
var usePathGradient = useGradient && native && gradient.type === "path";
|
|
209
|
+
if (usePathGradient) {
|
|
210
|
+
paintPathGradient(context, native, gradient, fillRectArea);
|
|
211
|
+
}
|
|
212
|
+
else if (useGradient && native) {
|
|
128
213
|
var canvasGrad = buildCanvasGradient(native, gradient, shape.width(), shape.height());
|
|
129
214
|
if (canvasGrad) {
|
|
130
215
|
context.setAttr("fillStyle", canvasGrad);
|
|
@@ -149,11 +234,13 @@ var CellBackground = function (_a) {
|
|
|
149
234
|
else {
|
|
150
235
|
context.setAttr("fillStyle", finalBackgroundColor);
|
|
151
236
|
}
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
237
|
+
if (!usePathGradient) {
|
|
238
|
+
if ((isMergedCell || !showFaintBorder) && showGridLines) {
|
|
239
|
+
context.fillRect(1, 1, shape.width() - 1, shape.height() - 1);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
context.fillRect(0, 0, shape.width() + 1, shape.height() + 1);
|
|
243
|
+
}
|
|
157
244
|
}
|
|
158
245
|
if (showFaintBorder) {
|
|
159
246
|
var lightColor = (0, utils_1.lightenColor)(-0.1, backgroundColor);
|
|
@@ -46,6 +46,13 @@ export type CellTextRunsProps = {
|
|
|
46
46
|
wrap: boolean;
|
|
47
47
|
/** Theme — used to resolve segment `color` objects to CSS strings. */
|
|
48
48
|
theme: SpreadsheetTheme;
|
|
49
|
+
/**
|
|
50
|
+
* Multiplier for run font sizes given in points (zoom × shrink-to-fit),
|
|
51
|
+
* so a run's own size follows the cell's.
|
|
52
|
+
*/
|
|
53
|
+
fontScale?: number;
|
|
54
|
+
/** Konva rotation (degrees, clockwise) of the whole block — rotated text. */
|
|
55
|
+
rotation?: number;
|
|
49
56
|
};
|
|
50
57
|
export type Resolved = {
|
|
51
58
|
bold: boolean;
|
|
@@ -64,7 +71,7 @@ export type Resolved = {
|
|
|
64
71
|
* merged style carries a `baselineOffset` (own or inherited from the
|
|
65
72
|
* base) the sup/sub font scale is applied here, exactly once.
|
|
66
73
|
*/
|
|
67
|
-
export declare const resolveSegmentStyle: (seg: RichTextSegment, base: Resolved, theme: SpreadsheetTheme) => Resolved;
|
|
74
|
+
export declare const resolveSegmentStyle: (seg: RichTextSegment, base: Resolved, theme: SpreadsheetTheme, fontScale?: number) => Resolved;
|
|
68
75
|
/** A segment paired with its fully-resolved paint style. */
|
|
69
76
|
export type ResolvedSegment = {
|
|
70
77
|
seg: RichTextSegment;
|
|
@@ -83,10 +90,10 @@ export declare const computeLineMetrics: (resolvedLines: ResolvedSegment[][], ba
|
|
|
83
90
|
};
|
|
84
91
|
/**
|
|
85
92
|
* Vertical draw position (textBaseline="top") for one segment within
|
|
86
|
-
* its line box.
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
93
|
+
* its line box. Every run shares the line's alphabetic baseline (smaller
|
|
94
|
+
* runs shift down); superscript / subscript runs then move that baseline
|
|
95
|
+
* up / down by Excel's shift ({@link getScriptBaselineShift}). Exported
|
|
96
|
+
* for unit tests.
|
|
90
97
|
*/
|
|
91
98
|
export declare const computeSegmentTop: (lineTop: number, lineFontSize: number, segFontSize: number, baselineOffset: "superscript" | "subscript" | undefined) => number;
|
|
92
99
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-text-runs.d.ts","sourceRoot":"","sources":["../../../../components/cell/cell-text-runs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAsB,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"cell-text-runs.d.ts","sourceRoot":"","sources":["../../../../components/cell/cell-text-runs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAsB,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,kD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d,OAAO,gBAAgB,EACvB,kBAAa,KACZ,QAwBF,CAAC;AAKF,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,eAAe,CAAC;IACrB,CAAC,EAAE,QAAQ,CAAC;CACb,CAAC;AAYF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC7B,eAAe,eAAe,EAAE,EAAE,EAClC,MAAM,QAAQ,EACd,WAAW,CAAC,CAAC,EAAE,QAAQ,KAAK,MAAM,KACjC;IAAE,aAAa,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CASvE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,EACf,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,gBAAgB,aAAa,GAAG,WAAW,GAAG,SAAS,KACtD,MAGmD,CAAC;AAoHvD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,oCAAsB,iBAAiB,uBAgQ9D,CAAC"}
|
|
@@ -5,6 +5,7 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
var react_konva_1 = require("react-konva");
|
|
7
7
|
var themes_1 = require("../../themes");
|
|
8
|
+
var alignment_1 = require("./alignment");
|
|
8
9
|
var line_height_1 = require("./line-height");
|
|
9
10
|
var rich_text_1 = require("./rich-text");
|
|
10
11
|
var BASELINE_OFFSET_FONT_SCALE = 0.58;
|
|
@@ -45,13 +46,12 @@ var buildFontString = function (r) {
|
|
|
45
46
|
* merged style carries a `baselineOffset` (own or inherited from the
|
|
46
47
|
* base) the sup/sub font scale is applied here, exactly once.
|
|
47
48
|
*/
|
|
48
|
-
var resolveSegmentStyle = function (seg, base, theme) {
|
|
49
|
+
var resolveSegmentStyle = function (seg, base, theme, fontScale) {
|
|
49
50
|
var _a, _b, _c, _d, _e, _f;
|
|
51
|
+
if (fontScale === void 0) { fontScale = 1; }
|
|
50
52
|
var f = seg.format;
|
|
51
53
|
var baselineOffset = (_a = f.baselineOffset) !== null && _a !== void 0 ? _a : base.baselineOffset;
|
|
52
|
-
var fontSize = typeof f.fontSize === "number"
|
|
53
|
-
? (f.fontSize / pointFromPx(base.fontSize)) * base.fontSize
|
|
54
|
-
: base.fontSize;
|
|
54
|
+
var fontSize = typeof f.fontSize === "number" ? f.fontSize * PT_TO_PX * fontScale : base.fontSize;
|
|
55
55
|
return {
|
|
56
56
|
bold: (_b = f.bold) !== null && _b !== void 0 ? _b : base.bold,
|
|
57
57
|
italic: (_c = f.italic) !== null && _c !== void 0 ? _c : base.italic,
|
|
@@ -72,8 +72,8 @@ var resolveSegmentStyle = function (seg, base, theme) {
|
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
exports.resolveSegmentStyle = resolveSegmentStyle;
|
|
75
|
-
/**
|
|
76
|
-
var
|
|
75
|
+
/** CSS pixels per point (96 / 72), as `pointToPixel`. */
|
|
76
|
+
var PT_TO_PX = 96 / 72;
|
|
77
77
|
/**
|
|
78
78
|
* Fraction of the em box above the alphabetic baseline for typical
|
|
79
79
|
* Latin fonts. Used to baseline-align mixed-size runs on one line:
|
|
@@ -108,18 +108,15 @@ var computeLineMetrics = function (resolvedLines, base, advanceOf) {
|
|
|
108
108
|
exports.computeLineMetrics = computeLineMetrics;
|
|
109
109
|
/**
|
|
110
110
|
* Vertical draw position (textBaseline="top") for one segment within
|
|
111
|
-
* its line box.
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
111
|
+
* its line box. Every run shares the line's alphabetic baseline (smaller
|
|
112
|
+
* runs shift down); superscript / subscript runs then move that baseline
|
|
113
|
+
* up / down by Excel's shift ({@link getScriptBaselineShift}). Exported
|
|
114
|
+
* for unit tests.
|
|
115
115
|
*/
|
|
116
116
|
var computeSegmentTop = function (lineTop, lineFontSize, segFontSize, baselineOffset) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return lineTop + (lineFontSize - segFontSize);
|
|
121
|
-
}
|
|
122
|
-
return lineTop + (lineFontSize - segFontSize) * ALPHABETIC_BASELINE_RATIO;
|
|
117
|
+
return lineTop +
|
|
118
|
+
(lineFontSize - segFontSize) * ALPHABETIC_BASELINE_RATIO +
|
|
119
|
+
(0, alignment_1.getScriptBaselineShift)(baselineOffset, lineFontSize);
|
|
123
120
|
};
|
|
124
121
|
exports.computeSegmentTop = computeSegmentTop;
|
|
125
122
|
/**
|
|
@@ -256,7 +253,7 @@ var atomsToSegments = function (atoms) {
|
|
|
256
253
|
* - Mention runs render as their inline label only (no chrome).
|
|
257
254
|
*/
|
|
258
255
|
exports.CellTextRuns = react_1.default.memo(function (props) {
|
|
259
|
-
var x = props.x, y = props.y, width = props.width, height = props.height, padding = props.padding, value = props.value, runs = props.runs, baseColor = props.baseColor, baseFontFamily = props.baseFontFamily, baseFontSize = props.baseFontSize, baseBold = props.baseBold, baseItalic = props.baseItalic, baseUnderline = props.baseUnderline, baseStrikethrough = props.baseStrikethrough, baseBaselineOffset = props.baseBaselineOffset, horizontalAlign = props.horizontalAlign, verticalAlign = props.verticalAlign, lineHeight = props.lineHeight, lineHeightMode = props.lineHeightMode, scale = props.scale, wrap = props.wrap, theme = props.theme;
|
|
256
|
+
var x = props.x, y = props.y, width = props.width, height = props.height, padding = props.padding, value = props.value, runs = props.runs, baseColor = props.baseColor, baseFontFamily = props.baseFontFamily, baseFontSize = props.baseFontSize, baseBold = props.baseBold, baseItalic = props.baseItalic, baseUnderline = props.baseUnderline, baseStrikethrough = props.baseStrikethrough, baseBaselineOffset = props.baseBaselineOffset, horizontalAlign = props.horizontalAlign, verticalAlign = props.verticalAlign, lineHeight = props.lineHeight, lineHeightMode = props.lineHeightMode, scale = props.scale, wrap = props.wrap, theme = props.theme, _a = props.fontScale, fontScale = _a === void 0 ? 1 : _a, rotation = props.rotation;
|
|
260
257
|
var sceneFunc = (0, react_1.useCallback)(function (context, _shape) {
|
|
261
258
|
var e_3, _a, e_4, _b, e_5, _c, e_6, _d, e_7, _e;
|
|
262
259
|
var baseResolved = {
|
|
@@ -281,7 +278,7 @@ exports.CellTextRuns = react_1.default.memo(function (props) {
|
|
|
281
278
|
// it walks; the per-segment paint loop below sets it again per
|
|
282
279
|
// segment so the mutation here is safe.
|
|
283
280
|
var measureAtom = function (atom) {
|
|
284
|
-
var r = (0, exports.resolveSegmentStyle)({ text: atom.text, format: atom.format }, baseResolved, theme);
|
|
281
|
+
var r = (0, exports.resolveSegmentStyle)({ text: atom.text, format: atom.format }, baseResolved, theme, fontScale);
|
|
285
282
|
context.setAttr("font", buildFontString(r));
|
|
286
283
|
return context.measureText(atom.text).width;
|
|
287
284
|
};
|
|
@@ -365,7 +362,7 @@ exports.CellTextRuns = react_1.default.memo(function (props) {
|
|
|
365
362
|
var resolvedLines = lines.map(function (lineSegments) {
|
|
366
363
|
return lineSegments.map(function (seg) { return ({
|
|
367
364
|
seg: seg,
|
|
368
|
-
r: (0, exports.resolveSegmentStyle)(seg, baseResolved, theme),
|
|
365
|
+
r: (0, exports.resolveSegmentStyle)(seg, baseResolved, theme, fontScale),
|
|
369
366
|
}); });
|
|
370
367
|
});
|
|
371
368
|
var _h = (0, exports.computeLineMetrics)(resolvedLines, baseResolved, function (r) {
|
|
@@ -476,7 +473,8 @@ exports.CellTextRuns = react_1.default.memo(function (props) {
|
|
|
476
473
|
height,
|
|
477
474
|
padding,
|
|
478
475
|
theme,
|
|
476
|
+
fontScale,
|
|
479
477
|
]);
|
|
480
|
-
return (react_1.default.createElement(react_konva_1.Shape, { x: x, y: y, width: width, height: height, sceneFunc: sceneFunc, listening: false, perfectDrawEnabled: false }));
|
|
478
|
+
return (react_1.default.createElement(react_konva_1.Shape, { x: x, y: y, width: width, height: height, rotation: rotation, sceneFunc: sceneFunc, listening: false, perfectDrawEnabled: false }));
|
|
481
479
|
});
|
|
482
480
|
exports.CellTextRuns.displayName = "CellTextRuns";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/cell/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAA4B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/cell/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAuDjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAO3C,eAAO,MAAM,IAAI,oCAAgB,SAAS,uBAoiCxC,CAAC"}
|