@openworkbook/react 0.1.1 → 0.2.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/dist/{chunk-6JJNRZAC.js → chunk-YMZE7SCY.js} +170 -30
- package/dist/client.cjs +7068 -5801
- package/dist/client.js +5426 -4305
- package/dist/index.cjs +2199 -1978
- package/dist/index.d.cts +205 -7
- package/dist/index.d.ts +205 -7
- package/dist/index.js +278 -58
- package/dist/{printSettingsUi-O3255F6Z.js → printSettingsUi-JFNADOSF.js} +1 -1
- package/package.json +2 -2
|
@@ -1805,6 +1805,7 @@ var STRINGS_UI2 = {
|
|
|
1805
1805
|
"sheetRename.badChar": "the name contains one of \\ / ? * [ ] :",
|
|
1806
1806
|
"sheetRename.apostrophe": "the name starts or ends with an apostrophe",
|
|
1807
1807
|
"sheetRename.duplicate": "the name is already used by another sheet",
|
|
1808
|
+
"sheetRename.reserved": "History is a name Excel reserves",
|
|
1808
1809
|
// built-in number formats of the format lists (core's builtinFormats labels)
|
|
1809
1810
|
"numFormat.general": "General",
|
|
1810
1811
|
"numFormat.number": "Number",
|
|
@@ -2819,6 +2820,7 @@ var STRINGS_CORE = {
|
|
|
2819
2820
|
"err.sheet.name.tooLong": "Invalid sheet name {name}: the name is longer than 31 characters",
|
|
2820
2821
|
"err.sheet.name.chars": "Invalid sheet name {name}: the name contains one of \\ / ? * [ ] :",
|
|
2821
2822
|
"err.sheet.name.apostrophe": "Invalid sheet name {name}: the name starts or ends with an apostrophe",
|
|
2823
|
+
"err.sheet.name.reserved": "Invalid sheet name {name}: History is a name Excel reserves",
|
|
2822
2824
|
"err.sheet.name.taken": "Invalid sheet name {name}: the name is already used by another sheet",
|
|
2823
2825
|
"err.sheet.noIndex": "There is no sheet at index {index}.",
|
|
2824
2826
|
"err.sheet.notFound": 'No sheet "{name}" in this workbook.',
|
|
@@ -3269,8 +3271,18 @@ var STRINGS_I18N = {
|
|
|
3269
3271
|
"options.languageDefault": "Default ({0})"
|
|
3270
3272
|
};
|
|
3271
3273
|
|
|
3274
|
+
// src/i18n/strings-security.ts
|
|
3275
|
+
var STRINGS_SECURITY = {
|
|
3276
|
+
"security.pictures.title": "External pictures blocked",
|
|
3277
|
+
"security.pictures.message": "This workbook shows pictures from other web sites. They have not been loaded: loading them sends a request, which can include data from the workbook, to {hosts}.",
|
|
3278
|
+
"security.pictures.thisSite": "this site",
|
|
3279
|
+
"security.pictures.more": "{host} and {n, plural, one {# other site} other {# other sites}}",
|
|
3280
|
+
"security.pictures.enable": "Enable content",
|
|
3281
|
+
"security.pictures.dismiss": "Close the message"
|
|
3282
|
+
};
|
|
3283
|
+
|
|
3272
3284
|
// src/i18n/extraLabels.ts
|
|
3273
|
-
var EXTRA_LABELS = { ...STRINGS_UI, ...STRINGS_UI2, ...STRINGS_CORE, ...STRINGS_A11Y, ...STRINGS_A11Y2, ...STRINGS_A11Y_GRID, ...STRINGS_I18N };
|
|
3285
|
+
var EXTRA_LABELS = { ...STRINGS_UI, ...STRINGS_UI2, ...STRINGS_CORE, ...STRINGS_A11Y, ...STRINGS_A11Y2, ...STRINGS_A11Y_GRID, ...STRINGS_I18N, ...STRINGS_SECURITY };
|
|
3274
3286
|
|
|
3275
3287
|
// src/labels.ts
|
|
3276
3288
|
var CHART_LABELS = {
|
|
@@ -3288,18 +3300,18 @@ var CHART_LABELS = {
|
|
|
3288
3300
|
areaStacked100: "100% Stacked Area",
|
|
3289
3301
|
pie: "Pie",
|
|
3290
3302
|
doughnut: "Doughnut",
|
|
3291
|
-
scatter: "Scatter",
|
|
3292
|
-
scatterLines: "Scatter with Straight Lines",
|
|
3303
|
+
scatter: "Scatter with only Markers",
|
|
3304
|
+
scatterLines: "Scatter with Straight Lines and Markers",
|
|
3293
3305
|
bubble: "Bubble",
|
|
3294
3306
|
radar: "Radar",
|
|
3295
3307
|
radarFilled: "Filled Radar",
|
|
3296
|
-
combo: "
|
|
3308
|
+
combo: "Column Clustered - Line",
|
|
3297
3309
|
stock: "Stock (High-Low-Close)",
|
|
3298
3310
|
funnel: "Funnel",
|
|
3299
3311
|
waterfall: "Waterfall",
|
|
3300
3312
|
histogram: "Histogram",
|
|
3301
3313
|
pareto: "Pareto",
|
|
3302
|
-
boxWhisker: "Box
|
|
3314
|
+
boxWhisker: "Box and Whisker",
|
|
3303
3315
|
treemap: "Treemap",
|
|
3304
3316
|
sunburst: "Sunburst",
|
|
3305
3317
|
gauge: "Gauge",
|
|
@@ -3326,7 +3338,17 @@ var CHART_LABELS = {
|
|
|
3326
3338
|
surfaceContour: "Contour",
|
|
3327
3339
|
surfaceContourWireframe: "Wireframe Contour"
|
|
3328
3340
|
};
|
|
3329
|
-
var
|
|
3341
|
+
var CHART_PRESET_LABELS = {
|
|
3342
|
+
lineStackedMarkers: "Stacked Line with Markers",
|
|
3343
|
+
lineStacked100Markers: "100% Stacked Line with Markers",
|
|
3344
|
+
scatterSmoothMarkers: "Scatter with Smooth Lines and Markers",
|
|
3345
|
+
scatterSmooth: "Scatter with Smooth Lines",
|
|
3346
|
+
scatterStraight: "Scatter with Straight Lines",
|
|
3347
|
+
comboColumnLineSecondary: "Column Clustered - Line on Secondary Axis",
|
|
3348
|
+
comboAreaColumn: "Stacked Area - Column Clustered",
|
|
3349
|
+
radarMarkers: "Radar with Markers"
|
|
3350
|
+
};
|
|
3351
|
+
var CHART_COMMANDS = /* @__PURE__ */ Object.fromEntries(Object.entries({ ...CHART_LABELS, ...CHART_PRESET_LABELS }).map(([t, label]) => [`insert.chart.${t}`, label]));
|
|
3330
3352
|
var COMMANDS = {
|
|
3331
3353
|
// ---- File
|
|
3332
3354
|
"file.new": "New",
|
|
@@ -4159,7 +4181,14 @@ var COMMANDS = {
|
|
|
4159
4181
|
"home.cf.dataBarSolid": "Solid Fill Data Bar",
|
|
4160
4182
|
"home.cf.dataBarRule": "Data Bar Rule\u2026",
|
|
4161
4183
|
"home.cf.colorScaleRule": "Color Scale Rule\u2026",
|
|
4162
|
-
"home.cf.averageRule": "Above or Below Average Rule\u2026"
|
|
4184
|
+
"home.cf.averageRule": "Above or Below Average Rule\u2026",
|
|
4185
|
+
// ---- [classic ribbon] the ribbon display options (the chevron at the right end of the ribbon)
|
|
4186
|
+
"ribbon.options": "Ribbon Display Options",
|
|
4187
|
+
"ribbon.layout.classic": "Classic Ribbon",
|
|
4188
|
+
"ribbon.layout.singleLine": "Single Line Ribbon",
|
|
4189
|
+
"ribbon.show.always": "Always show ribbon",
|
|
4190
|
+
"ribbon.show.tabsOnly": "Show tabs only",
|
|
4191
|
+
"ribbon.show.auto": "Adjust automatically"
|
|
4163
4192
|
};
|
|
4164
4193
|
var UI = {
|
|
4165
4194
|
// ribbon tabs
|
|
@@ -4236,6 +4265,88 @@ var UI = {
|
|
|
4236
4265
|
"shapeFormat.down": "Down",
|
|
4237
4266
|
"shapeFormat.ccw": "Counter-clockwise",
|
|
4238
4267
|
"shapeFormat.cw": "Clockwise",
|
|
4268
|
+
// [classic ribbon] menu headings, the command search path and the group names of the ribbon tabs
|
|
4269
|
+
"head.ribbonLayout": "Ribbon Layout",
|
|
4270
|
+
"head.showRibbon": "Show Ribbon",
|
|
4271
|
+
"ui.ribbon": "Ribbon",
|
|
4272
|
+
"group.undo": "Undo",
|
|
4273
|
+
"group.clipboard": "Clipboard",
|
|
4274
|
+
"group.font": "Font",
|
|
4275
|
+
"group.alignment": "Alignment",
|
|
4276
|
+
"group.number": "Number",
|
|
4277
|
+
"group.styles": "Styles",
|
|
4278
|
+
"group.cells": "Cells",
|
|
4279
|
+
"group.editing": "Editing",
|
|
4280
|
+
"group.tables": "Tables",
|
|
4281
|
+
"group.illustrations": "Illustrations",
|
|
4282
|
+
"group.charts": "Charts",
|
|
4283
|
+
"group.controls": "Controls",
|
|
4284
|
+
"group.links": "Links",
|
|
4285
|
+
"group.comments": "Comments",
|
|
4286
|
+
"group.symbols": "Symbols",
|
|
4287
|
+
"group.tools": "Tools",
|
|
4288
|
+
"group.pens": "Pens",
|
|
4289
|
+
"group.ink": "Ink",
|
|
4290
|
+
"group.touch": "Touch",
|
|
4291
|
+
"group.pageSetup": "Page Setup",
|
|
4292
|
+
"group.printSetup": "Print Setup",
|
|
4293
|
+
"group.gridlines": "Gridlines",
|
|
4294
|
+
"group.headings": "Headings",
|
|
4295
|
+
"group.themes": "Themes",
|
|
4296
|
+
"group.sheetDirection": "Sheet Direction",
|
|
4297
|
+
"group.print": "Print",
|
|
4298
|
+
"group.functionLibrary": "Function Library",
|
|
4299
|
+
"group.definedNames": "Defined Names",
|
|
4300
|
+
"group.formulaAuditing": "Formula Auditing",
|
|
4301
|
+
"group.calculation": "Calculation",
|
|
4302
|
+
"group.getData": "Get & Transform Data",
|
|
4303
|
+
"group.dataTypes": "Data Types",
|
|
4304
|
+
"group.sortFilter": "Sort & Filter",
|
|
4305
|
+
"group.dataTools": "Data Tools",
|
|
4306
|
+
"group.outline": "Outline",
|
|
4307
|
+
"group.forecast": "Forecast",
|
|
4308
|
+
"group.dataStore": "Data Store",
|
|
4309
|
+
"group.analyze": "Analyze",
|
|
4310
|
+
"group.workbookLinks": "Workbook Links",
|
|
4311
|
+
"group.proofing": "Proofing",
|
|
4312
|
+
"group.accessibility": "Accessibility",
|
|
4313
|
+
"group.notes": "Notes",
|
|
4314
|
+
"group.protection": "Protection",
|
|
4315
|
+
"group.changes": "Changes",
|
|
4316
|
+
"group.sheetView": "Sheet View",
|
|
4317
|
+
"group.workbookViews": "Workbook Views",
|
|
4318
|
+
"group.panes": "Panes",
|
|
4319
|
+
"group.show": "Show",
|
|
4320
|
+
"group.zoom": "Zoom",
|
|
4321
|
+
"group.display": "Display",
|
|
4322
|
+
"group.regionalFormat": "Regional Format",
|
|
4323
|
+
"group.window": "Window",
|
|
4324
|
+
"group.help": "Help",
|
|
4325
|
+
"group.data": "Data",
|
|
4326
|
+
"group.chartElements": "Chart Elements",
|
|
4327
|
+
"group.analysis": "Analysis",
|
|
4328
|
+
"group.shapeStyles": "Shape Styles",
|
|
4329
|
+
"group.text": "Text",
|
|
4330
|
+
"group.picture": "Picture",
|
|
4331
|
+
"group.adjust": "Adjust",
|
|
4332
|
+
"group.barcode": "Barcode",
|
|
4333
|
+
"group.slicer": "Slicer",
|
|
4334
|
+
"group.selection": "Selection",
|
|
4335
|
+
"group.buttons": "Buttons",
|
|
4336
|
+
"group.timeline": "Timeline",
|
|
4337
|
+
"group.arrange": "Arrange",
|
|
4338
|
+
"group.size": "Size",
|
|
4339
|
+
"group.properties": "Properties",
|
|
4340
|
+
"group.tableStyles": "Table Styles",
|
|
4341
|
+
"group.styleOptions": "Style Options",
|
|
4342
|
+
"group.pivotTable": "PivotTable",
|
|
4343
|
+
"group.activeField": "Active Field",
|
|
4344
|
+
"group.group": "Group",
|
|
4345
|
+
"group.filter": "Filter",
|
|
4346
|
+
"group.actions": "Actions",
|
|
4347
|
+
"group.calculations": "Calculations",
|
|
4348
|
+
"group.layout": "Layout",
|
|
4349
|
+
"group.pivotStyles": "PivotTable Styles",
|
|
4239
4350
|
// buttons and chrome
|
|
4240
4351
|
"ui.ok": "OK",
|
|
4241
4352
|
"ui.cancel": "Cancel",
|
|
@@ -4382,8 +4493,15 @@ var UI = {
|
|
|
4382
4493
|
"menu.chart.radar": "Radar",
|
|
4383
4494
|
"menu.chart.surface": "Surface",
|
|
4384
4495
|
"menu.chart.statistical": "Statistical",
|
|
4385
|
-
"menu.chart.hierarchy": "
|
|
4386
|
-
"menu.chart.other": "Other
|
|
4496
|
+
"menu.chart.hierarchy": "Hierarchical",
|
|
4497
|
+
"menu.chart.other": "Other",
|
|
4498
|
+
// [chart gallery] headings of the chart gallery and of its "More charts" part
|
|
4499
|
+
"menu.chart.pie": "Pie",
|
|
4500
|
+
"menu.chart.combo": "Combo",
|
|
4501
|
+
"menu.chart.more": "More charts",
|
|
4502
|
+
"menu.chart.threeD": "3-D",
|
|
4503
|
+
"menu.chart.stock": "Stock",
|
|
4504
|
+
"menu.chart.polar": "Gauge and Polar",
|
|
4387
4505
|
// dialog titles that differ from their command label
|
|
4388
4506
|
"dlg.newWorkbook": "New Workbook",
|
|
4389
4507
|
"dlg.newWorkbook.text": "Start a new blank workbook? Unsaved changes will be lost.",
|
|
@@ -6380,6 +6498,11 @@ var Icon = {
|
|
|
6380
6498
|
/* @__PURE__ */ jsx("path", { d: "M9 3v12M3 9h12", strokeDasharray: "1.5 1.8" }),
|
|
6381
6499
|
/* @__PURE__ */ jsx("path", { d: "M3 15h12", strokeWidth: "1.8", stroke: A })
|
|
6382
6500
|
] }),
|
|
6501
|
+
fillDown: () => /* @__PURE__ */ jsxs(Svg, { children: [
|
|
6502
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "2.5", width: "12", height: "13", rx: "1" }),
|
|
6503
|
+
/* @__PURE__ */ jsx("path", { d: "M9 5v7M6 9.5 9 12.5l3-3", stroke: A })
|
|
6504
|
+
] }),
|
|
6505
|
+
// [classic ribbon] Home > Fill
|
|
6383
6506
|
fill: (color2) => /* @__PURE__ */ jsxs(Svg, { children: [
|
|
6384
6507
|
/* @__PURE__ */ jsx("path", { d: "m8 3 5 5-4.5 4.5a1.4 1.4 0 0 1-2 0L3.6 9.6a1.4 1.4 0 0 1 0-2L8 3Z" }),
|
|
6385
6508
|
/* @__PURE__ */ jsx("path", { d: "M14.5 10.5c.8 1.2 1.2 2 .1 2.6-1 .5-1.6-.6-.1-2.6Z", fill: "currentColor" }),
|
|
@@ -7204,7 +7327,7 @@ function MenuList({ items, close, x, y, alignRight, autoFocus, returnFocus, end,
|
|
|
7204
7327
|
"button",
|
|
7205
7328
|
{
|
|
7206
7329
|
type: "button",
|
|
7207
|
-
role: it.checked !== void 0 ? "menuitemcheckbox" : "menuitem",
|
|
7330
|
+
role: it.checked !== void 0 ? it.radio ? "menuitemradio" : "menuitemcheckbox" : "menuitem",
|
|
7208
7331
|
"aria-checked": it.checked,
|
|
7209
7332
|
"aria-haspopup": it.items ? "menu" : void 0,
|
|
7210
7333
|
"aria-expanded": it.items ? sub?.index === i : void 0,
|
|
@@ -7228,7 +7351,7 @@ function MenuList({ items, close, x, y, alignRight, autoFocus, returnFocus, end,
|
|
|
7228
7351
|
it.onClick?.();
|
|
7229
7352
|
},
|
|
7230
7353
|
children: [
|
|
7231
|
-
/* @__PURE__ */ jsx3("span", { className: "ox-ico", children: it.checked ? /* @__PURE__ */ jsx3("svg", { width: "14", height: "14", viewBox: "0 0 14 14", "aria-hidden": "true", children: /* @__PURE__ */ jsx3("path", { d: "m2.5 7.5 3 3 6-7", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) : it.icon }),
|
|
7354
|
+
/* @__PURE__ */ jsx3("span", { className: "ox-ico", children: it.checked && it.radio ? /* @__PURE__ */ jsx3("svg", { width: "14", height: "14", viewBox: "0 0 14 14", "aria-hidden": "true", children: /* @__PURE__ */ jsx3("circle", { cx: "7", cy: "7", r: "3", fill: "currentColor" }) }) : it.checked ? /* @__PURE__ */ jsx3("svg", { width: "14", height: "14", viewBox: "0 0 14 14", "aria-hidden": "true", children: /* @__PURE__ */ jsx3("path", { d: "m2.5 7.5 3 3 6-7", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) : it.icon }),
|
|
7232
7355
|
/* @__PURE__ */ jsx3("span", { className: "ox-lbl", children: it.label }),
|
|
7233
7356
|
it.shortcut && /* @__PURE__ */ jsx3("span", { className: "ox-key", children: it.shortcut }),
|
|
7234
7357
|
it.items && /* @__PURE__ */ jsx3(Chevron, { dir: "right" })
|
|
@@ -7842,7 +7965,7 @@ import { roundedBoxCss } from "@openworkbook/core";
|
|
|
7842
7965
|
import { pivotPrintMarks } from "@openworkbook/core";
|
|
7843
7966
|
|
|
7844
7967
|
// src/cellDecorHtml.ts
|
|
7845
|
-
import { cellPadding, cssColor, cssFontFamily, cssNumber, escapeAttr, escapeHtml, labelShown, safeImageSrc } from "@openworkbook/core";
|
|
7968
|
+
import { cellPadding, cssColor, cssFontFamily, cssNumber, escapeAttr, escapeHtml, labelShown, safeImageSrc, htmlPictureSrc } from "@openworkbook/core";
|
|
7846
7969
|
var px = (v, d, max = 200) => cssNumber(v, 0, max) ?? d;
|
|
7847
7970
|
function cellPaddingCss(st) {
|
|
7848
7971
|
const indent = cssNumber(st.indent, 0, 250) || 0;
|
|
@@ -7866,7 +7989,7 @@ function cellBackgroundCss(st, layers) {
|
|
|
7866
7989
|
add(`linear-gradient(${dir},${c} 50%,transparent 50%)`, `${n}px ${n}px`, at);
|
|
7867
7990
|
}
|
|
7868
7991
|
for (const l of layers) add(l, "100% 100%", "0 0");
|
|
7869
|
-
const src = st.backImage ?
|
|
7992
|
+
const src = st.backImage ? htmlPictureSrc(st.backImage, { kind: "decoration" }) : null;
|
|
7870
7993
|
if (src) {
|
|
7871
7994
|
const fit = st.backImageFit;
|
|
7872
7995
|
add(`url('${src}')`, fit === "contain" ? "contain" : fit === "cover" ? "cover" : fit === "center" ? "auto" : "100% 100%", "center");
|
|
@@ -7888,7 +8011,7 @@ function cellDecorHtml(st, empty) {
|
|
|
7888
8011
|
}
|
|
7889
8012
|
let left = 2, right = 2, outL = 2, outR = 1;
|
|
7890
8013
|
for (const ic of st.decoration?.icons || []) {
|
|
7891
|
-
const src = ic &&
|
|
8014
|
+
const src = ic && htmlPictureSrc(ic.src, { kind: "decoration" });
|
|
7892
8015
|
if (!src) continue;
|
|
7893
8016
|
const w = cssNumber(ic.width, 1, 200) || 12, h = cssNumber(ic.height, 1, 200) || w, pos = ic.position;
|
|
7894
8017
|
const place = pos === "outsideLeft" ? `left:${-(outL + w)}px` : pos === "outsideRight" ? `right:${-(outR + w)}px` : pos === "right" || pos === "afterText" ? `right:${right}px` : `left:${left}px`;
|
|
@@ -7922,7 +8045,8 @@ function cellWatermarkHtml(st) {
|
|
|
7922
8045
|
|
|
7923
8046
|
// src/print.ts
|
|
7924
8047
|
import { generalAlign, singleLineRuns, singleLineText } from "@openworkbook/core";
|
|
7925
|
-
import { cssColor as cssColor2, cssFontFamily as cssFontFamily2, cssKeyword, cssNumber as cssNumber2, escapeAttr as escapeAttr4, escapeHtml as escapeHtml3
|
|
8048
|
+
import { cssColor as cssColor2, cssFontFamily as cssFontFamily2, cssKeyword, cssNumber as cssNumber2, escapeAttr as escapeAttr4, escapeHtml as escapeHtml3 } from "@openworkbook/core";
|
|
8049
|
+
import { BLOCKED_PICTURE_HTML_STYLE, currentPictureGate, pictureGateFor, withPictureGate } from "@openworkbook/core";
|
|
7926
8050
|
import {
|
|
7927
8051
|
ObjectPainter,
|
|
7928
8052
|
PRINT_HEADING_HEIGHT,
|
|
@@ -7949,12 +8073,12 @@ import {
|
|
|
7949
8073
|
headerFooterPicturePosition,
|
|
7950
8074
|
pageHeaderFooter,
|
|
7951
8075
|
printsBackgroundOnPage,
|
|
7952
|
-
|
|
8076
|
+
htmlPictureSrc as htmlPictureSrc2,
|
|
7953
8077
|
splitAtPictureCode
|
|
7954
8078
|
} from "@openworkbook/core";
|
|
7955
8079
|
var num = (n) => Math.round((isFinite(n) ? n : 0) * 100) / 100;
|
|
7956
8080
|
function pictureHtml(p) {
|
|
7957
|
-
const src = p ?
|
|
8081
|
+
const src = p ? htmlPictureSrc2(p.src, { kind: "header-footer" }) : null;
|
|
7958
8082
|
if (!p || !src) return "";
|
|
7959
8083
|
return `<img alt="" src="${escapeAttr2(src)}" style="display:inline-block;vertical-align:bottom;width:${num(p.width)}pt;height:${num(p.height)}pt">`;
|
|
7960
8084
|
}
|
|
@@ -7974,7 +8098,7 @@ function headerFooterBlockHtml(kind, st, ctx, pageIndex) {
|
|
|
7974
8098
|
}
|
|
7975
8099
|
function backgroundBlockHtml(sheet, st, box2, at, position = 1) {
|
|
7976
8100
|
if (!printsBackgroundOnPage(st, position) || !sheet.backgroundImage) return "";
|
|
7977
|
-
const src =
|
|
8101
|
+
const src = htmlPictureSrc2(sheet.backgroundImage, { kind: "background", sheet: sheet.name }, sheet.wb);
|
|
7978
8102
|
if (!src || /["'()\\\s<>]/.test(src)) return "";
|
|
7979
8103
|
const side = sheet.rightToLeft ? "right" : "left", o = sheet.backgroundOptions;
|
|
7980
8104
|
const over = o?.layer === "over", opacity = o && o.opacity < 1 ? `opacity:${num(o.opacity)};` : "";
|
|
@@ -7983,7 +8107,7 @@ function backgroundBlockHtml(sheet, st, box2, at, position = 1) {
|
|
|
7983
8107
|
|
|
7984
8108
|
// src/printSparks.ts
|
|
7985
8109
|
import { cellSparkAt, drawSparkView, ruleRanges, sparkEnv, sparkImageSource, usesSparkFunction } from "@openworkbook/core";
|
|
7986
|
-
import { escapeAttr as escapeAttr3,
|
|
8110
|
+
import { escapeAttr as escapeAttr3, htmlPictureSrc as htmlPictureSrc3 } from "@openworkbook/core";
|
|
7987
8111
|
function hasSparkContent(sheet) {
|
|
7988
8112
|
if (sheet.condFormats.some((r) => r.type === "sparkline")) return true;
|
|
7989
8113
|
for (const cell of sheet.cells.values()) if (usesSparkFunction(cell.f)) return true;
|
|
@@ -8037,7 +8161,7 @@ function sparkOverlayItems(sheet, ratio, rasterize2) {
|
|
|
8037
8161
|
const box2 = `position:absolute;left:${Math.round(x - dx)}px;top:${Math.round(y - dy)}px;width:${Math.round(w)}px;height:${Math.round(h)}px`;
|
|
8038
8162
|
let html = "";
|
|
8039
8163
|
for (const p of pics) {
|
|
8040
|
-
const u =
|
|
8164
|
+
const u = htmlPictureSrc3(p.src, { kind: "sparkline", sheet: sheet.name, row, col }, sheet.wb);
|
|
8041
8165
|
if (u) html += `<img alt="" src="${escapeAttr3(u)}" style="${box2};box-sizing:border-box;padding:2px;${imageCss(p.view)}">`;
|
|
8042
8166
|
}
|
|
8043
8167
|
if (png) html += `<img alt="" src="${escapeAttr3(png)}" style="${box2}">`;
|
|
@@ -8053,6 +8177,11 @@ import { DEFAULT_PAGE_SETUP } from "@openworkbook/core";
|
|
|
8053
8177
|
var esc = escapeHtml3;
|
|
8054
8178
|
var num2 = (v, min, max) => cssNumber2(v, min, max) ?? 0;
|
|
8055
8179
|
var span = (v) => Math.max(1, Math.round(num2(v, 1, 1e5)));
|
|
8180
|
+
function htmlPicture(src, context, sheet) {
|
|
8181
|
+
const r = currentPictureGate(sheet?.wb).check(src, { output: "print", ...context });
|
|
8182
|
+
return r.decision === "allow" ? { src: r.picture.url } : r.picture ? { blocked: true } : {};
|
|
8183
|
+
}
|
|
8184
|
+
var printGate = (sheet, o) => o.pictureGate ?? pictureGateFor(sheet.wb, o);
|
|
8056
8185
|
function color(v) {
|
|
8057
8186
|
const c = cssColor2(v);
|
|
8058
8187
|
return c && c[0] === "#" ? v.trim() : c;
|
|
@@ -8122,13 +8251,14 @@ function rasterize(w, h, ratio, draw) {
|
|
|
8122
8251
|
}
|
|
8123
8252
|
function overlayItems(sheet, ratio) {
|
|
8124
8253
|
const painter = new ObjectPainter(sheet.wb), out = [];
|
|
8254
|
+
painter.pictureGate = currentPictureGate(sheet.wb);
|
|
8125
8255
|
const lazy = (make) => {
|
|
8126
8256
|
let v;
|
|
8127
8257
|
return () => v === void 0 ? v = make() : v;
|
|
8128
8258
|
};
|
|
8129
|
-
const img = (src, x, y, w, h, alt = "") => {
|
|
8130
|
-
const u =
|
|
8131
|
-
return u ? `<img alt="${escapeAttr4(alt)}" src="${escapeAttr4(u)}" style="
|
|
8259
|
+
const img = (src, x, y, w, h, alt = "", context = { kind: "other" }) => {
|
|
8260
|
+
const u = htmlPicture(src, context, sheet), box2 = `position:absolute;left:${Math.round(num2(x))}px;top:${Math.round(num2(y))}px;width:${Math.round(num2(w))}px;height:${Math.round(num2(h))}px`;
|
|
8261
|
+
return u.src ? `<img alt="${escapeAttr4(alt)}" src="${escapeAttr4(u.src)}" style="${box2}">` : u.blocked ? `<div class="os-print-blocked" style="${box2};${BLOCKED_PICTURE_HTML_STYLE}"></div>` : "";
|
|
8132
8262
|
};
|
|
8133
8263
|
for (const sp of sheet.sparklines) {
|
|
8134
8264
|
if (sheet.rows.isHidden(sp.row) || sheet.cols.isHidden(sp.col)) continue;
|
|
@@ -8150,20 +8280,25 @@ function overlayItems(sheet, ratio) {
|
|
|
8150
8280
|
if (!ph) continue;
|
|
8151
8281
|
if (ph.src) {
|
|
8152
8282
|
const src2 = ph.src, alt = obj.alt ?? ph.text;
|
|
8153
|
-
out.push({ ...b, html: (dx, dy) => img(src2, b.x - dx, b.y - dy, b.w, b.h, alt) });
|
|
8283
|
+
out.push({ ...b, html: (dx, dy) => img(src2, b.x - dx, b.y - dy, b.w, b.h, alt, { kind: "placeholder", sheet: sheet.name, objectId: obj.id }) });
|
|
8154
8284
|
continue;
|
|
8155
8285
|
}
|
|
8156
8286
|
}
|
|
8157
8287
|
const tf = objectTransform(obj);
|
|
8158
8288
|
if (obj.kind === "image") {
|
|
8159
8289
|
const crop = normCrop(obj.crop);
|
|
8290
|
+
const pctx = { kind: "object", sheet: sheet.name, objectId: obj.id };
|
|
8160
8291
|
if (!crop && !tf.rotation && !tf.flipH && !tf.flipV) {
|
|
8161
|
-
out.push({ ...b, html: (dx, dy) => img(obj.src, b.x - dx, b.y - dy, b.w, b.h, obj.alt) });
|
|
8292
|
+
out.push({ ...b, html: (dx, dy) => img(obj.src, b.x - dx, b.y - dy, b.w, b.h, obj.alt, pctx) });
|
|
8162
8293
|
continue;
|
|
8163
8294
|
}
|
|
8164
8295
|
const c = crop || { left: 0, top: 0, right: 0, bottom: 0 }, fw = b.w / (1 - c.left - c.right), fh = b.h / (1 - c.top - c.bottom);
|
|
8165
8296
|
const transform = `${tf.rotation ? `rotate(${num2(tf.rotation)}deg) ` : ""}${tf.flipH || tf.flipV ? `scale(${tf.flipH ? -1 : 1},${tf.flipV ? -1 : 1})` : ""}`.trim();
|
|
8166
|
-
const
|
|
8297
|
+
const pic = htmlPicture(obj.src, pctx, sheet), src2 = pic.src;
|
|
8298
|
+
if (pic.blocked) {
|
|
8299
|
+
out.push({ ...b, html: (dx, dy) => img(obj.src, b.x - dx, b.y - dy, b.w, b.h, obj.alt, pctx) });
|
|
8300
|
+
continue;
|
|
8301
|
+
}
|
|
8167
8302
|
if (!src2) continue;
|
|
8168
8303
|
out.push({ ...b, html: (dx, dy) => `<div style="position:absolute;overflow:hidden;left:${Math.round(num2(b.x - dx))}px;top:${Math.round(num2(b.y - dy))}px;width:${Math.round(num2(b.w))}px;height:${Math.round(num2(b.h))}px${transform ? `;transform:${transform}` : ""}"><img alt="${escapeAttr4(obj.alt || "")}" src="${escapeAttr4(src2)}" style="position:absolute;max-width:none;left:${num2(-fw * c.left).toFixed(1)}px;top:${num2(-fh * c.top).toFixed(1)}px;width:${num2(fw).toFixed(1)}px;height:${num2(fh).toFixed(1)}px"></div>` });
|
|
8169
8304
|
continue;
|
|
@@ -8312,7 +8447,7 @@ function tableHtml(sheet, g, look, titleRows, titleCols, marks) {
|
|
|
8312
8447
|
const cellCss = css(st, generalAlign(v, st.format) === "right", { w: bw, h: bh }, sheet.rightToLeft) + (cond?.bar ? dataBarCss(cond.bar, bw, bh, sheet.rightToLeft) : "");
|
|
8313
8448
|
const pic = cellImageAt(sheet, ar, ac);
|
|
8314
8449
|
if (pic) {
|
|
8315
|
-
html += `<td${spans} style="${cellCss};padding:2px 0 0 2px;vertical-align:top">${cellPictureHtml(pic, bw, bh)}</td>`;
|
|
8450
|
+
html += `<td${spans} style="${cellCss};padding:2px 0 0 2px;vertical-align:top">${cellPictureHtml(pic, bw, bh, { kind: pic.formula ? "formula" : "cell", sheet: sheet.name, row: ar, col: ac }, sheet)}</td>`;
|
|
8316
8451
|
return;
|
|
8317
8452
|
}
|
|
8318
8453
|
const control = sheet.cellTypes.length ? cellTypeHtml(sheet.getCellType(ar, ac), v, f.text) : null;
|
|
@@ -8343,10 +8478,12 @@ function tableHtml(sheet, g, look, titleRows, titleCols, marks) {
|
|
|
8343
8478
|
});
|
|
8344
8479
|
return { html: html + "</table>", width, height, left, top };
|
|
8345
8480
|
}
|
|
8346
|
-
function cellPictureHtml(pic, w, h) {
|
|
8347
|
-
const
|
|
8481
|
+
function cellPictureHtml(pic, w, h, context, sheet) {
|
|
8482
|
+
const p = htmlPicture(pic.src, context, sheet), src = p.src;
|
|
8483
|
+
const bw = Math.max(1, num2(w) - 5), bh = Math.max(1, num2(h) - 5);
|
|
8484
|
+
if (p.blocked) return `<div class="os-print-blocked" style="width:${bw}px;height:${bh}px;${BLOCKED_PICTURE_HTML_STYLE}"></div>`;
|
|
8348
8485
|
if (!src) return "";
|
|
8349
|
-
const
|
|
8486
|
+
const pw = cssNumber2(pic.width, 0, 1e5), ph = cssNumber2(pic.height, 0, 1e5);
|
|
8350
8487
|
const fit = pic.sizing === 1 ? "width:100%;height:100%;object-fit:fill" : pic.sizing === 2 ? "flex:none" : pic.sizing === 3 ? `flex:none;width:${pw !== null ? `${pw}px` : "auto"};height:${ph !== null ? `${ph}px` : "auto"}` : "width:100%;height:100%;object-fit:contain";
|
|
8351
8488
|
return `<div class="os-print-cellpic" style="display:flex;align-items:center;justify-content:center;overflow:hidden;width:${bw}px;height:${bh}px"><img alt="${escapeAttr4(pic.alt ?? "")}" src="${escapeAttr4(src)}" style="${fit}"></div>`;
|
|
8352
8489
|
}
|
|
@@ -8376,6 +8513,9 @@ body{-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
|
8376
8513
|
`;
|
|
8377
8514
|
}
|
|
8378
8515
|
function sheetPrintPages(sheet, setup, options = {}) {
|
|
8516
|
+
return withPictureGate(printGate(sheet, options), () => printPages(sheet, setup, options));
|
|
8517
|
+
}
|
|
8518
|
+
function printPages(sheet, setup, options) {
|
|
8379
8519
|
const st = resolvePageSetup(setup, sheet.pageSetup);
|
|
8380
8520
|
const withObjects = options.objects !== false && !st.draft && canDraw() && (sheet.objects.length > 0 || sheet.sparklines.length > 0 || hasSparkContent(sheet));
|
|
8381
8521
|
const layout = sheetPrintLayout(sheet, st, { objects: withObjects, pageBreaks: options.pageBreaks });
|