@openworkbook/react 0.1.1 → 0.2.1
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-MV44TEEG.js} +175 -30
- package/dist/client.cjs +7092 -5803
- package/dist/client.js +5443 -4305
- package/dist/index.cjs +2199 -1978
- package/dist/index.d.cts +217 -7
- package/dist/index.d.ts +217 -7
- package/dist/index.js +278 -58
- package/dist/{printSettingsUi-O3255F6Z.js → printSettingsUi-HSDXW6ZE.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" }),
|
|
@@ -6598,6 +6721,11 @@ var Icon = {
|
|
|
6598
6721
|
/* @__PURE__ */ jsx("path", { d: "M6 3H3.500v12H6" }),
|
|
6599
6722
|
/* @__PURE__ */ jsx("path", { d: "M8.500 5.500h7M8.500 9h7M8.500 12.500h7" })
|
|
6600
6723
|
] }),
|
|
6724
|
+
errorCheck: () => /* @__PURE__ */ jsxs(Svg, { children: [
|
|
6725
|
+
/* @__PURE__ */ jsx("path", { d: "M9 2 16 9 9 16 2 9Z" }),
|
|
6726
|
+
/* @__PURE__ */ jsx("path", { d: "M9 5.500v4.200" }),
|
|
6727
|
+
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "12.300", r: "0.600", fill: "currentColor" })
|
|
6728
|
+
] }),
|
|
6601
6729
|
eye: () => /* @__PURE__ */ jsxs(Svg, { children: [
|
|
6602
6730
|
/* @__PURE__ */ jsx("path", { d: "M1.500 9S4.500 4 9 4s7.500 5 7.500 5-3 5-7.500 5S1.500 9 1.500 9Z" }),
|
|
6603
6731
|
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "9", r: "2.200" })
|
|
@@ -7204,7 +7332,7 @@ function MenuList({ items, close, x, y, alignRight, autoFocus, returnFocus, end,
|
|
|
7204
7332
|
"button",
|
|
7205
7333
|
{
|
|
7206
7334
|
type: "button",
|
|
7207
|
-
role: it.checked !== void 0 ? "menuitemcheckbox" : "menuitem",
|
|
7335
|
+
role: it.checked !== void 0 ? it.radio ? "menuitemradio" : "menuitemcheckbox" : "menuitem",
|
|
7208
7336
|
"aria-checked": it.checked,
|
|
7209
7337
|
"aria-haspopup": it.items ? "menu" : void 0,
|
|
7210
7338
|
"aria-expanded": it.items ? sub?.index === i : void 0,
|
|
@@ -7228,7 +7356,7 @@ function MenuList({ items, close, x, y, alignRight, autoFocus, returnFocus, end,
|
|
|
7228
7356
|
it.onClick?.();
|
|
7229
7357
|
},
|
|
7230
7358
|
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 }),
|
|
7359
|
+
/* @__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
7360
|
/* @__PURE__ */ jsx3("span", { className: "ox-lbl", children: it.label }),
|
|
7233
7361
|
it.shortcut && /* @__PURE__ */ jsx3("span", { className: "ox-key", children: it.shortcut }),
|
|
7234
7362
|
it.items && /* @__PURE__ */ jsx3(Chevron, { dir: "right" })
|
|
@@ -7842,7 +7970,7 @@ import { roundedBoxCss } from "@openworkbook/core";
|
|
|
7842
7970
|
import { pivotPrintMarks } from "@openworkbook/core";
|
|
7843
7971
|
|
|
7844
7972
|
// src/cellDecorHtml.ts
|
|
7845
|
-
import { cellPadding, cssColor, cssFontFamily, cssNumber, escapeAttr, escapeHtml, labelShown, safeImageSrc } from "@openworkbook/core";
|
|
7973
|
+
import { cellPadding, cssColor, cssFontFamily, cssNumber, escapeAttr, escapeHtml, labelShown, safeImageSrc, htmlPictureSrc } from "@openworkbook/core";
|
|
7846
7974
|
var px = (v, d, max = 200) => cssNumber(v, 0, max) ?? d;
|
|
7847
7975
|
function cellPaddingCss(st) {
|
|
7848
7976
|
const indent = cssNumber(st.indent, 0, 250) || 0;
|
|
@@ -7866,7 +7994,7 @@ function cellBackgroundCss(st, layers) {
|
|
|
7866
7994
|
add(`linear-gradient(${dir},${c} 50%,transparent 50%)`, `${n}px ${n}px`, at);
|
|
7867
7995
|
}
|
|
7868
7996
|
for (const l of layers) add(l, "100% 100%", "0 0");
|
|
7869
|
-
const src = st.backImage ?
|
|
7997
|
+
const src = st.backImage ? htmlPictureSrc(st.backImage, { kind: "decoration" }) : null;
|
|
7870
7998
|
if (src) {
|
|
7871
7999
|
const fit = st.backImageFit;
|
|
7872
8000
|
add(`url('${src}')`, fit === "contain" ? "contain" : fit === "cover" ? "cover" : fit === "center" ? "auto" : "100% 100%", "center");
|
|
@@ -7888,7 +8016,7 @@ function cellDecorHtml(st, empty) {
|
|
|
7888
8016
|
}
|
|
7889
8017
|
let left = 2, right = 2, outL = 2, outR = 1;
|
|
7890
8018
|
for (const ic of st.decoration?.icons || []) {
|
|
7891
|
-
const src = ic &&
|
|
8019
|
+
const src = ic && htmlPictureSrc(ic.src, { kind: "decoration" });
|
|
7892
8020
|
if (!src) continue;
|
|
7893
8021
|
const w = cssNumber(ic.width, 1, 200) || 12, h = cssNumber(ic.height, 1, 200) || w, pos = ic.position;
|
|
7894
8022
|
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 +8050,8 @@ function cellWatermarkHtml(st) {
|
|
|
7922
8050
|
|
|
7923
8051
|
// src/print.ts
|
|
7924
8052
|
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
|
|
8053
|
+
import { cssColor as cssColor2, cssFontFamily as cssFontFamily2, cssKeyword, cssNumber as cssNumber2, escapeAttr as escapeAttr4, escapeHtml as escapeHtml3 } from "@openworkbook/core";
|
|
8054
|
+
import { BLOCKED_PICTURE_HTML_STYLE, currentPictureGate, pictureGateFor, withPictureGate } from "@openworkbook/core";
|
|
7926
8055
|
import {
|
|
7927
8056
|
ObjectPainter,
|
|
7928
8057
|
PRINT_HEADING_HEIGHT,
|
|
@@ -7949,12 +8078,12 @@ import {
|
|
|
7949
8078
|
headerFooterPicturePosition,
|
|
7950
8079
|
pageHeaderFooter,
|
|
7951
8080
|
printsBackgroundOnPage,
|
|
7952
|
-
|
|
8081
|
+
htmlPictureSrc as htmlPictureSrc2,
|
|
7953
8082
|
splitAtPictureCode
|
|
7954
8083
|
} from "@openworkbook/core";
|
|
7955
8084
|
var num = (n) => Math.round((isFinite(n) ? n : 0) * 100) / 100;
|
|
7956
8085
|
function pictureHtml(p) {
|
|
7957
|
-
const src = p ?
|
|
8086
|
+
const src = p ? htmlPictureSrc2(p.src, { kind: "header-footer" }) : null;
|
|
7958
8087
|
if (!p || !src) return "";
|
|
7959
8088
|
return `<img alt="" src="${escapeAttr2(src)}" style="display:inline-block;vertical-align:bottom;width:${num(p.width)}pt;height:${num(p.height)}pt">`;
|
|
7960
8089
|
}
|
|
@@ -7974,7 +8103,7 @@ function headerFooterBlockHtml(kind, st, ctx, pageIndex) {
|
|
|
7974
8103
|
}
|
|
7975
8104
|
function backgroundBlockHtml(sheet, st, box2, at, position = 1) {
|
|
7976
8105
|
if (!printsBackgroundOnPage(st, position) || !sheet.backgroundImage) return "";
|
|
7977
|
-
const src =
|
|
8106
|
+
const src = htmlPictureSrc2(sheet.backgroundImage, { kind: "background", sheet: sheet.name }, sheet.wb);
|
|
7978
8107
|
if (!src || /["'()\\\s<>]/.test(src)) return "";
|
|
7979
8108
|
const side = sheet.rightToLeft ? "right" : "left", o = sheet.backgroundOptions;
|
|
7980
8109
|
const over = o?.layer === "over", opacity = o && o.opacity < 1 ? `opacity:${num(o.opacity)};` : "";
|
|
@@ -7983,7 +8112,7 @@ function backgroundBlockHtml(sheet, st, box2, at, position = 1) {
|
|
|
7983
8112
|
|
|
7984
8113
|
// src/printSparks.ts
|
|
7985
8114
|
import { cellSparkAt, drawSparkView, ruleRanges, sparkEnv, sparkImageSource, usesSparkFunction } from "@openworkbook/core";
|
|
7986
|
-
import { escapeAttr as escapeAttr3,
|
|
8115
|
+
import { escapeAttr as escapeAttr3, htmlPictureSrc as htmlPictureSrc3 } from "@openworkbook/core";
|
|
7987
8116
|
function hasSparkContent(sheet) {
|
|
7988
8117
|
if (sheet.condFormats.some((r) => r.type === "sparkline")) return true;
|
|
7989
8118
|
for (const cell of sheet.cells.values()) if (usesSparkFunction(cell.f)) return true;
|
|
@@ -8037,7 +8166,7 @@ function sparkOverlayItems(sheet, ratio, rasterize2) {
|
|
|
8037
8166
|
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
8167
|
let html = "";
|
|
8039
8168
|
for (const p of pics) {
|
|
8040
|
-
const u =
|
|
8169
|
+
const u = htmlPictureSrc3(p.src, { kind: "sparkline", sheet: sheet.name, row, col }, sheet.wb);
|
|
8041
8170
|
if (u) html += `<img alt="" src="${escapeAttr3(u)}" style="${box2};box-sizing:border-box;padding:2px;${imageCss(p.view)}">`;
|
|
8042
8171
|
}
|
|
8043
8172
|
if (png) html += `<img alt="" src="${escapeAttr3(png)}" style="${box2}">`;
|
|
@@ -8053,6 +8182,11 @@ import { DEFAULT_PAGE_SETUP } from "@openworkbook/core";
|
|
|
8053
8182
|
var esc = escapeHtml3;
|
|
8054
8183
|
var num2 = (v, min, max) => cssNumber2(v, min, max) ?? 0;
|
|
8055
8184
|
var span = (v) => Math.max(1, Math.round(num2(v, 1, 1e5)));
|
|
8185
|
+
function htmlPicture(src, context, sheet) {
|
|
8186
|
+
const r = currentPictureGate(sheet?.wb).check(src, { output: "print", ...context });
|
|
8187
|
+
return r.decision === "allow" ? { src: r.picture.url } : r.picture ? { blocked: true } : {};
|
|
8188
|
+
}
|
|
8189
|
+
var printGate = (sheet, o) => o.pictureGate ?? pictureGateFor(sheet.wb, o);
|
|
8056
8190
|
function color(v) {
|
|
8057
8191
|
const c = cssColor2(v);
|
|
8058
8192
|
return c && c[0] === "#" ? v.trim() : c;
|
|
@@ -8122,13 +8256,14 @@ function rasterize(w, h, ratio, draw) {
|
|
|
8122
8256
|
}
|
|
8123
8257
|
function overlayItems(sheet, ratio) {
|
|
8124
8258
|
const painter = new ObjectPainter(sheet.wb), out = [];
|
|
8259
|
+
painter.pictureGate = currentPictureGate(sheet.wb);
|
|
8125
8260
|
const lazy = (make) => {
|
|
8126
8261
|
let v;
|
|
8127
8262
|
return () => v === void 0 ? v = make() : v;
|
|
8128
8263
|
};
|
|
8129
|
-
const img = (src, x, y, w, h, alt = "") => {
|
|
8130
|
-
const u =
|
|
8131
|
-
return u ? `<img alt="${escapeAttr4(alt)}" src="${escapeAttr4(u)}" style="
|
|
8264
|
+
const img = (src, x, y, w, h, alt = "", context = { kind: "other" }) => {
|
|
8265
|
+
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`;
|
|
8266
|
+
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
8267
|
};
|
|
8133
8268
|
for (const sp of sheet.sparklines) {
|
|
8134
8269
|
if (sheet.rows.isHidden(sp.row) || sheet.cols.isHidden(sp.col)) continue;
|
|
@@ -8150,20 +8285,25 @@ function overlayItems(sheet, ratio) {
|
|
|
8150
8285
|
if (!ph) continue;
|
|
8151
8286
|
if (ph.src) {
|
|
8152
8287
|
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) });
|
|
8288
|
+
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
8289
|
continue;
|
|
8155
8290
|
}
|
|
8156
8291
|
}
|
|
8157
8292
|
const tf = objectTransform(obj);
|
|
8158
8293
|
if (obj.kind === "image") {
|
|
8159
8294
|
const crop = normCrop(obj.crop);
|
|
8295
|
+
const pctx = { kind: "object", sheet: sheet.name, objectId: obj.id };
|
|
8160
8296
|
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) });
|
|
8297
|
+
out.push({ ...b, html: (dx, dy) => img(obj.src, b.x - dx, b.y - dy, b.w, b.h, obj.alt, pctx) });
|
|
8162
8298
|
continue;
|
|
8163
8299
|
}
|
|
8164
8300
|
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
8301
|
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
|
|
8302
|
+
const pic = htmlPicture(obj.src, pctx, sheet), src2 = pic.src;
|
|
8303
|
+
if (pic.blocked) {
|
|
8304
|
+
out.push({ ...b, html: (dx, dy) => img(obj.src, b.x - dx, b.y - dy, b.w, b.h, obj.alt, pctx) });
|
|
8305
|
+
continue;
|
|
8306
|
+
}
|
|
8167
8307
|
if (!src2) continue;
|
|
8168
8308
|
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
8309
|
continue;
|
|
@@ -8312,7 +8452,7 @@ function tableHtml(sheet, g, look, titleRows, titleCols, marks) {
|
|
|
8312
8452
|
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
8453
|
const pic = cellImageAt(sheet, ar, ac);
|
|
8314
8454
|
if (pic) {
|
|
8315
|
-
html += `<td${spans} style="${cellCss};padding:2px 0 0 2px;vertical-align:top">${cellPictureHtml(pic, bw, bh)}</td>`;
|
|
8455
|
+
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
8456
|
return;
|
|
8317
8457
|
}
|
|
8318
8458
|
const control = sheet.cellTypes.length ? cellTypeHtml(sheet.getCellType(ar, ac), v, f.text) : null;
|
|
@@ -8343,10 +8483,12 @@ function tableHtml(sheet, g, look, titleRows, titleCols, marks) {
|
|
|
8343
8483
|
});
|
|
8344
8484
|
return { html: html + "</table>", width, height, left, top };
|
|
8345
8485
|
}
|
|
8346
|
-
function cellPictureHtml(pic, w, h) {
|
|
8347
|
-
const
|
|
8486
|
+
function cellPictureHtml(pic, w, h, context, sheet) {
|
|
8487
|
+
const p = htmlPicture(pic.src, context, sheet), src = p.src;
|
|
8488
|
+
const bw = Math.max(1, num2(w) - 5), bh = Math.max(1, num2(h) - 5);
|
|
8489
|
+
if (p.blocked) return `<div class="os-print-blocked" style="width:${bw}px;height:${bh}px;${BLOCKED_PICTURE_HTML_STYLE}"></div>`;
|
|
8348
8490
|
if (!src) return "";
|
|
8349
|
-
const
|
|
8491
|
+
const pw = cssNumber2(pic.width, 0, 1e5), ph = cssNumber2(pic.height, 0, 1e5);
|
|
8350
8492
|
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
8493
|
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
8494
|
}
|
|
@@ -8376,6 +8518,9 @@ body{-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
|
8376
8518
|
`;
|
|
8377
8519
|
}
|
|
8378
8520
|
function sheetPrintPages(sheet, setup, options = {}) {
|
|
8521
|
+
return withPictureGate(printGate(sheet, options), () => printPages(sheet, setup, options));
|
|
8522
|
+
}
|
|
8523
|
+
function printPages(sheet, setup, options) {
|
|
8379
8524
|
const st = resolvePageSetup(setup, sheet.pageSetup);
|
|
8380
8525
|
const withObjects = options.objects !== false && !st.draft && canDraw() && (sheet.objects.length > 0 || sheet.sparklines.length > 0 || hasSparkContent(sheet));
|
|
8381
8526
|
const layout = sheetPrintLayout(sheet, st, { objects: withObjects, pageBreaks: options.pageBreaks });
|