@odoo/o-spreadsheet 16.1.2 → 16.1.3
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/o_spreadsheet.cjs.js +153 -102
- package/dist/o_spreadsheet.d.ts +26 -25
- package/dist/o_spreadsheet.esm.js +153 -102
- package/dist/o_spreadsheet.iife.js +153 -102
- package/dist/o_spreadsheet.iife.min.js +156 -156
- package/package.json +2 -2
|
@@ -2827,7 +2827,7 @@ class ChartJsComponent extends owl.Component {
|
|
|
2827
2827
|
return `background-color: ${this.background}`;
|
|
2828
2828
|
}
|
|
2829
2829
|
get chartRuntime() {
|
|
2830
|
-
const runtime = this.env.model.getters.getChartRuntime(this.
|
|
2830
|
+
const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
2831
2831
|
if (!("chartJsConfig" in runtime)) {
|
|
2832
2832
|
throw new Error("Unsupported chart runtime");
|
|
2833
2833
|
}
|
|
@@ -3081,7 +3081,7 @@ class ScorecardChart$1 extends owl.Component {
|
|
|
3081
3081
|
this.ctx = document.createElement("canvas").getContext("2d");
|
|
3082
3082
|
}
|
|
3083
3083
|
get runtime() {
|
|
3084
|
-
return this.env.model.getters.getChartRuntime(this.
|
|
3084
|
+
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
3085
3085
|
}
|
|
3086
3086
|
get title() {
|
|
3087
3087
|
return this.runtime.title;
|
|
@@ -3472,7 +3472,7 @@ exports.CommandResult = void 0;
|
|
|
3472
3472
|
CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
|
|
3473
3473
|
CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
|
|
3474
3474
|
CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
|
|
3475
|
-
CommandResult[CommandResult["
|
|
3475
|
+
CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
|
|
3476
3476
|
CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
|
|
3477
3477
|
CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
|
|
3478
3478
|
CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
|
|
@@ -3529,6 +3529,7 @@ exports.CommandResult = void 0;
|
|
|
3529
3529
|
CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
|
|
3530
3530
|
CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
|
|
3531
3531
|
CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
|
|
3532
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
|
|
3532
3533
|
})(exports.CommandResult || (exports.CommandResult = {}));
|
|
3533
3534
|
|
|
3534
3535
|
var DIRECTION;
|
|
@@ -6069,7 +6070,7 @@ class ChartFigure extends owl.Component {
|
|
|
6069
6070
|
return registry;
|
|
6070
6071
|
}
|
|
6071
6072
|
get chartType() {
|
|
6072
|
-
return this.env.model.getters.getChartType(this.
|
|
6073
|
+
return this.env.model.getters.getChartType(this.props.figure.id);
|
|
6073
6074
|
}
|
|
6074
6075
|
onContextMenu(ev) {
|
|
6075
6076
|
const position = {
|
|
@@ -18804,7 +18805,7 @@ class ImageFigure extends owl.Component {
|
|
|
18804
18805
|
name: _lt("Reset size"),
|
|
18805
18806
|
sequence: 3,
|
|
18806
18807
|
action: () => {
|
|
18807
|
-
const size = this.env.model.getters.
|
|
18808
|
+
const size = this.env.model.getters.getImageSize(this.figureId);
|
|
18808
18809
|
const { height, width } = getMaxFigureSize(this.env.model.getters, size);
|
|
18809
18810
|
this.env.model.dispatch("UPDATE_FIGURE", {
|
|
18810
18811
|
sheetId: this.env.model.getters.getActiveSheetId(),
|
|
@@ -18855,8 +18856,7 @@ class ImageFigure extends owl.Component {
|
|
|
18855
18856
|
return this.props.figure.id;
|
|
18856
18857
|
}
|
|
18857
18858
|
get getImagePath() {
|
|
18858
|
-
return this.env.model.getters.
|
|
18859
|
-
.path;
|
|
18859
|
+
return this.env.model.getters.getImagePath(this.figureId);
|
|
18860
18860
|
}
|
|
18861
18861
|
}
|
|
18862
18862
|
ImageFigure.template = "o-spreadsheet-ImageFigure";
|
|
@@ -19811,7 +19811,6 @@ class LineBarPieConfigPanel extends owl.Component {
|
|
|
19811
19811
|
LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
|
|
19812
19812
|
LineBarPieConfigPanel.components = { SelectionInput };
|
|
19813
19813
|
LineBarPieConfigPanel.props = {
|
|
19814
|
-
sheetId: String,
|
|
19815
19814
|
figureId: String,
|
|
19816
19815
|
definition: Object,
|
|
19817
19816
|
updateChart: Function,
|
|
@@ -20141,7 +20140,6 @@ class GaugeChartConfigPanel extends owl.Component {
|
|
|
20141
20140
|
GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
|
|
20142
20141
|
GaugeChartConfigPanel.components = { SelectionInput };
|
|
20143
20142
|
GaugeChartConfigPanel.props = {
|
|
20144
|
-
sheetId: String,
|
|
20145
20143
|
figureId: String,
|
|
20146
20144
|
definition: Object,
|
|
20147
20145
|
updateChart: Function,
|
|
@@ -20295,7 +20293,7 @@ GaugeChartDesignPanel.props = {
|
|
|
20295
20293
|
|
|
20296
20294
|
class LineConfigPanel extends LineBarPieConfigPanel {
|
|
20297
20295
|
get canTreatLabelsAsText() {
|
|
20298
|
-
const chart = this.env.model.getters.getChart(this.props.
|
|
20296
|
+
const chart = this.env.model.getters.getChart(this.props.figureId);
|
|
20299
20297
|
if (chart && chart instanceof LineChart) {
|
|
20300
20298
|
return canChartParseLabels(chart.labelRange, this.env.model.getters);
|
|
20301
20299
|
}
|
|
@@ -20372,7 +20370,6 @@ class ScorecardChartConfigPanel extends owl.Component {
|
|
|
20372
20370
|
ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
|
|
20373
20371
|
ScorecardChartConfigPanel.components = { SelectionInput };
|
|
20374
20372
|
ScorecardChartConfigPanel.props = {
|
|
20375
|
-
sheetId: String,
|
|
20376
20373
|
figureId: String,
|
|
20377
20374
|
definition: Object,
|
|
20378
20375
|
updateChart: Function,
|
|
@@ -20504,7 +20501,7 @@ class ChartPanel extends owl.Component {
|
|
|
20504
20501
|
else {
|
|
20505
20502
|
this.shouldUpdateChart = true;
|
|
20506
20503
|
}
|
|
20507
|
-
if (!this.env.model.getters.isChartDefined(this.
|
|
20504
|
+
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
20508
20505
|
this.props.onCloseSidePanel();
|
|
20509
20506
|
return;
|
|
20510
20507
|
}
|
|
@@ -20525,7 +20522,7 @@ class ChartPanel extends owl.Component {
|
|
|
20525
20522
|
});
|
|
20526
20523
|
}
|
|
20527
20524
|
onTypeChange(type) {
|
|
20528
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
20525
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
20529
20526
|
if (!context) {
|
|
20530
20527
|
throw new Error("Chart not defined.");
|
|
20531
20528
|
}
|
|
@@ -20537,7 +20534,7 @@ class ChartPanel extends owl.Component {
|
|
|
20537
20534
|
});
|
|
20538
20535
|
}
|
|
20539
20536
|
get chartPanel() {
|
|
20540
|
-
const type = this.env.model.getters.getChartType(this.
|
|
20537
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
20541
20538
|
if (!type) {
|
|
20542
20539
|
throw new Error("Chart not defined.");
|
|
20543
20540
|
}
|
|
@@ -20547,8 +20544,8 @@ class ChartPanel extends owl.Component {
|
|
|
20547
20544
|
}
|
|
20548
20545
|
return chartPanel;
|
|
20549
20546
|
}
|
|
20550
|
-
getChartDefinition() {
|
|
20551
|
-
return this.env.model.getters.getChartDefinition(
|
|
20547
|
+
getChartDefinition(figureId = this.figureId) {
|
|
20548
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
20552
20549
|
}
|
|
20553
20550
|
get chartTypes() {
|
|
20554
20551
|
return getChartTypes();
|
|
@@ -27107,13 +27104,7 @@ function load(data, verboseImport) {
|
|
|
27107
27104
|
data = migrate(data);
|
|
27108
27105
|
}
|
|
27109
27106
|
}
|
|
27110
|
-
|
|
27111
|
-
// sensible default values
|
|
27112
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
27113
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
27114
|
-
if (data.sheets.length === 0) {
|
|
27115
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
27116
|
-
}
|
|
27107
|
+
data = repairData(data);
|
|
27117
27108
|
return data;
|
|
27118
27109
|
}
|
|
27119
27110
|
function migrate(data) {
|
|
@@ -27351,6 +27342,48 @@ const MIGRATIONS = [
|
|
|
27351
27342
|
},
|
|
27352
27343
|
},
|
|
27353
27344
|
];
|
|
27345
|
+
/**
|
|
27346
|
+
* This function is used to repair faulty data independently of the migration.
|
|
27347
|
+
*/
|
|
27348
|
+
function repairData(data) {
|
|
27349
|
+
data = forceUnicityOfFigure(data);
|
|
27350
|
+
data = setDefaults(data);
|
|
27351
|
+
return data;
|
|
27352
|
+
}
|
|
27353
|
+
/**
|
|
27354
|
+
* Force the unicity of figure ids accross sheets
|
|
27355
|
+
*/
|
|
27356
|
+
function forceUnicityOfFigure(data) {
|
|
27357
|
+
if (data.uniqueFigureIds) {
|
|
27358
|
+
return data;
|
|
27359
|
+
}
|
|
27360
|
+
const figureIds = new Set();
|
|
27361
|
+
const uuidGenerator = new UuidGenerator();
|
|
27362
|
+
for (const sheet of data.sheets || []) {
|
|
27363
|
+
for (const figure of sheet.figures || []) {
|
|
27364
|
+
if (figureIds.has(figure.id)) {
|
|
27365
|
+
figure.id += uuidGenerator.uuidv4();
|
|
27366
|
+
}
|
|
27367
|
+
figureIds.add(figure.id);
|
|
27368
|
+
}
|
|
27369
|
+
}
|
|
27370
|
+
data.uniqueFigureIds = true;
|
|
27371
|
+
return data;
|
|
27372
|
+
}
|
|
27373
|
+
/**
|
|
27374
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
27375
|
+
* sensible default values
|
|
27376
|
+
*/
|
|
27377
|
+
function setDefaults(data) {
|
|
27378
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
27379
|
+
data.sheets = data.sheets
|
|
27380
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
27381
|
+
: [];
|
|
27382
|
+
if (data.sheets.length === 0) {
|
|
27383
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
27384
|
+
}
|
|
27385
|
+
return data;
|
|
27386
|
+
}
|
|
27354
27387
|
/**
|
|
27355
27388
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
27356
27389
|
* a bug.
|
|
@@ -27489,6 +27522,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
27489
27522
|
formats: {},
|
|
27490
27523
|
borders: {},
|
|
27491
27524
|
revisionId: DEFAULT_REVISION_ID,
|
|
27525
|
+
uniqueFigureIds: true,
|
|
27492
27526
|
};
|
|
27493
27527
|
return data;
|
|
27494
27528
|
}
|
|
@@ -28486,10 +28520,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
28486
28520
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
28487
28521
|
}
|
|
28488
28522
|
adaptRanges(applyChange) {
|
|
28489
|
-
for (const
|
|
28490
|
-
|
|
28491
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28492
|
-
}
|
|
28523
|
+
for (const [chartId, chart] of Object.entries(this.charts)) {
|
|
28524
|
+
this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28493
28525
|
}
|
|
28494
28526
|
}
|
|
28495
28527
|
// ---------------------------------------------------------------------------
|
|
@@ -28500,20 +28532,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
28500
28532
|
case "CREATE_CHART":
|
|
28501
28533
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
28502
28534
|
case "UPDATE_CHART":
|
|
28503
|
-
return this.
|
|
28535
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
28504
28536
|
default:
|
|
28505
28537
|
return 0 /* CommandResult.Success */;
|
|
28506
28538
|
}
|
|
28507
28539
|
}
|
|
28508
28540
|
handle(cmd) {
|
|
28509
|
-
var _a
|
|
28541
|
+
var _a;
|
|
28510
28542
|
switch (cmd.type) {
|
|
28511
28543
|
case "CREATE_CHART":
|
|
28512
28544
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
28513
|
-
this.addChart(cmd.id, cmd.
|
|
28545
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28514
28546
|
break;
|
|
28515
28547
|
case "UPDATE_CHART": {
|
|
28516
|
-
this.addChart(cmd.id, cmd.
|
|
28548
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28517
28549
|
break;
|
|
28518
28550
|
}
|
|
28519
28551
|
case "DUPLICATE_SHEET": {
|
|
@@ -28522,7 +28554,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
28522
28554
|
if (fig.tag === "chart") {
|
|
28523
28555
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
28524
28556
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
28525
|
-
const chart = (
|
|
28557
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
28526
28558
|
if (chart) {
|
|
28527
28559
|
this.dispatch("CREATE_CHART", {
|
|
28528
28560
|
id: duplicatedFigureId,
|
|
@@ -28537,41 +28569,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
28537
28569
|
break;
|
|
28538
28570
|
}
|
|
28539
28571
|
case "DELETE_FIGURE":
|
|
28540
|
-
this.history.update("charts", cmd.
|
|
28572
|
+
this.history.update("charts", cmd.id, undefined);
|
|
28541
28573
|
break;
|
|
28542
28574
|
case "DELETE_SHEET":
|
|
28543
|
-
this.
|
|
28575
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
28576
|
+
this.history.update("charts", id, undefined);
|
|
28577
|
+
}
|
|
28544
28578
|
break;
|
|
28545
28579
|
}
|
|
28546
28580
|
}
|
|
28547
28581
|
// ---------------------------------------------------------------------------
|
|
28548
28582
|
// Getters
|
|
28549
28583
|
// ---------------------------------------------------------------------------
|
|
28550
|
-
getContextCreationChart(
|
|
28551
|
-
var _a, _b;
|
|
28552
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
28553
|
-
}
|
|
28554
|
-
getChart(sheetId, figureId) {
|
|
28584
|
+
getContextCreationChart(figureId) {
|
|
28555
28585
|
var _a;
|
|
28556
|
-
return (_a = this.charts[
|
|
28586
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
28557
28587
|
}
|
|
28558
|
-
|
|
28559
|
-
|
|
28560
|
-
|
|
28588
|
+
getChart(figureId) {
|
|
28589
|
+
return this.charts[figureId];
|
|
28590
|
+
}
|
|
28591
|
+
getChartType(figureId) {
|
|
28592
|
+
var _a;
|
|
28593
|
+
const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
|
|
28561
28594
|
if (!type) {
|
|
28562
28595
|
throw new Error("Chart not defined.");
|
|
28563
28596
|
}
|
|
28564
28597
|
return type;
|
|
28565
28598
|
}
|
|
28566
|
-
isChartDefined(
|
|
28567
|
-
return figureId in
|
|
28599
|
+
isChartDefined(figureId) {
|
|
28600
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
28568
28601
|
}
|
|
28569
28602
|
getChartIds(sheetId) {
|
|
28570
|
-
return Object.
|
|
28603
|
+
return Object.entries(this.charts)
|
|
28604
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
28605
|
+
.map(([id]) => id);
|
|
28571
28606
|
}
|
|
28572
|
-
getChartDefinition(
|
|
28573
|
-
var _a
|
|
28574
|
-
const definition = (
|
|
28607
|
+
getChartDefinition(figureId) {
|
|
28608
|
+
var _a;
|
|
28609
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28575
28610
|
if (!definition) {
|
|
28576
28611
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
28577
28612
|
}
|
|
@@ -28583,28 +28618,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
28583
28618
|
import(data) {
|
|
28584
28619
|
for (let sheet of data.sheets) {
|
|
28585
28620
|
if (sheet.figures) {
|
|
28586
|
-
const charts = {};
|
|
28587
28621
|
for (let figure of sheet.figures) {
|
|
28588
28622
|
// TODO:
|
|
28589
28623
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
28590
28624
|
// instead of in figure.data
|
|
28591
28625
|
if (figure.tag === "chart") {
|
|
28592
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28626
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28593
28627
|
}
|
|
28594
28628
|
}
|
|
28595
|
-
this.charts[sheet.id] = charts;
|
|
28596
28629
|
}
|
|
28597
28630
|
}
|
|
28598
28631
|
}
|
|
28599
28632
|
export(data) {
|
|
28633
|
+
var _a;
|
|
28600
28634
|
if (data.sheets) {
|
|
28601
28635
|
for (let sheet of data.sheets) {
|
|
28602
28636
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
28603
28637
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28604
|
-
const figures =
|
|
28605
|
-
for (let
|
|
28638
|
+
const figures = [];
|
|
28639
|
+
for (let sheetFigure of sheetFigures) {
|
|
28640
|
+
const figure = sheetFigure;
|
|
28606
28641
|
if (figure && figure.tag === "chart") {
|
|
28607
|
-
|
|
28642
|
+
const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28643
|
+
if (data) {
|
|
28644
|
+
figure.data = data;
|
|
28645
|
+
figures.push(figure);
|
|
28646
|
+
}
|
|
28647
|
+
}
|
|
28648
|
+
else {
|
|
28649
|
+
figures.push(figure);
|
|
28608
28650
|
}
|
|
28609
28651
|
}
|
|
28610
28652
|
sheet.figures = figures;
|
|
@@ -28612,13 +28654,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
28612
28654
|
}
|
|
28613
28655
|
}
|
|
28614
28656
|
exportForExcel(data) {
|
|
28615
|
-
var _a
|
|
28657
|
+
var _a;
|
|
28616
28658
|
for (let sheet of data.sheets) {
|
|
28617
28659
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28618
28660
|
const figures = [];
|
|
28619
28661
|
for (let figure of sheetFigures) {
|
|
28620
28662
|
if (figure && figure.tag === "chart") {
|
|
28621
|
-
const figureData = (
|
|
28663
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
28622
28664
|
if (figureData) {
|
|
28623
28665
|
figures.push({
|
|
28624
28666
|
...figure,
|
|
@@ -28657,15 +28699,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
28657
28699
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
28658
28700
|
* replaced
|
|
28659
28701
|
*/
|
|
28660
|
-
addChart(id,
|
|
28661
|
-
|
|
28702
|
+
addChart(id, definition) {
|
|
28703
|
+
const sheetId = this.getters.getFigureSheetId(id);
|
|
28704
|
+
if (sheetId) {
|
|
28705
|
+
this.history.update("charts", id, this.createChart(id, definition, sheetId));
|
|
28706
|
+
}
|
|
28662
28707
|
}
|
|
28663
28708
|
checkChartDuplicate(cmd) {
|
|
28664
|
-
|
|
28665
|
-
|
|
28666
|
-
|
|
28667
|
-
|
|
28668
|
-
|
|
28709
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28710
|
+
? 84 /* CommandResult.DuplicatedChartId */
|
|
28711
|
+
: 0 /* CommandResult.Success */;
|
|
28712
|
+
}
|
|
28713
|
+
checkChartExists(cmd) {
|
|
28714
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28715
|
+
? 0 /* CommandResult.Success */
|
|
28716
|
+
: 85 /* CommandResult.ChartDoesNotExist */;
|
|
28669
28717
|
}
|
|
28670
28718
|
}
|
|
28671
28719
|
ChartPlugin.getters = [
|
|
@@ -29046,7 +29094,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29046
29094
|
allowDispatch(cmd) {
|
|
29047
29095
|
switch (cmd.type) {
|
|
29048
29096
|
case "CREATE_FIGURE":
|
|
29049
|
-
return this.checkFigureDuplicate(cmd.
|
|
29097
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
29050
29098
|
case "UPDATE_FIGURE":
|
|
29051
29099
|
case "DELETE_FIGURE":
|
|
29052
29100
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -29112,9 +29160,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
29112
29160
|
}
|
|
29113
29161
|
return 0 /* CommandResult.Success */;
|
|
29114
29162
|
}
|
|
29115
|
-
checkFigureDuplicate(
|
|
29116
|
-
|
|
29117
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
29163
|
+
checkFigureDuplicate(figureId) {
|
|
29164
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
29118
29165
|
return 82 /* CommandResult.DuplicatedFigureId */;
|
|
29119
29166
|
}
|
|
29120
29167
|
return 0 /* CommandResult.Success */;
|
|
@@ -29129,6 +29176,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
29129
29176
|
var _a;
|
|
29130
29177
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
29131
29178
|
}
|
|
29179
|
+
getFigureSheetId(figureId) {
|
|
29180
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
29181
|
+
}
|
|
29132
29182
|
// ---------------------------------------------------------------------------
|
|
29133
29183
|
// Import/Export
|
|
29134
29184
|
// ---------------------------------------------------------------------------
|
|
@@ -29153,7 +29203,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29153
29203
|
this.export(data);
|
|
29154
29204
|
}
|
|
29155
29205
|
}
|
|
29156
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
29206
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
29157
29207
|
|
|
29158
29208
|
class FilterTable {
|
|
29159
29209
|
constructor(zone) {
|
|
@@ -29880,7 +29930,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29880
29930
|
switch (cmd.type) {
|
|
29881
29931
|
case "CREATE_IMAGE":
|
|
29882
29932
|
if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
|
|
29883
|
-
return 28 /* CommandResult.
|
|
29933
|
+
return 28 /* CommandResult.InvalidFigureId */;
|
|
29884
29934
|
}
|
|
29885
29935
|
return 0 /* CommandResult.Success */;
|
|
29886
29936
|
default:
|
|
@@ -29900,7 +29950,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29900
29950
|
if (fig.tag === "image") {
|
|
29901
29951
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
29902
29952
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
29903
|
-
const image = this.getImage(
|
|
29953
|
+
const image = this.getImage(fig.id);
|
|
29904
29954
|
if (image) {
|
|
29905
29955
|
const size = { width: fig.width, height: fig.height };
|
|
29906
29956
|
this.dispatch("CREATE_IMAGE", {
|
|
@@ -29938,13 +29988,19 @@ class ImagePlugin extends CorePlugin {
|
|
|
29938
29988
|
// ---------------------------------------------------------------------------
|
|
29939
29989
|
// Getters
|
|
29940
29990
|
// ---------------------------------------------------------------------------
|
|
29941
|
-
getImage(
|
|
29942
|
-
|
|
29943
|
-
|
|
29944
|
-
|
|
29945
|
-
|
|
29991
|
+
getImage(figureId) {
|
|
29992
|
+
for (const sheet of Object.values(this.images)) {
|
|
29993
|
+
if (sheet && sheet[figureId]) {
|
|
29994
|
+
return sheet[figureId];
|
|
29995
|
+
}
|
|
29946
29996
|
}
|
|
29947
|
-
|
|
29997
|
+
throw new Error(`There is no image with the given figureId: ${figureId}`);
|
|
29998
|
+
}
|
|
29999
|
+
getImagePath(figureId) {
|
|
30000
|
+
return this.getImage(figureId).path;
|
|
30001
|
+
}
|
|
30002
|
+
getImageSize(figureId) {
|
|
30003
|
+
return this.getImage(figureId).size;
|
|
29948
30004
|
}
|
|
29949
30005
|
// ---------------------------------------------------------------------------
|
|
29950
30006
|
// Private
|
|
@@ -29986,7 +30042,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29986
30042
|
return images;
|
|
29987
30043
|
}
|
|
29988
30044
|
}
|
|
29989
|
-
ImagePlugin.getters = ["getImage"];
|
|
30045
|
+
ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
|
|
29990
30046
|
|
|
29991
30047
|
class MergePlugin extends CorePlugin {
|
|
29992
30048
|
constructor() {
|
|
@@ -31787,9 +31843,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31787
31843
|
return formatColors.filter(isDefined$1);
|
|
31788
31844
|
}
|
|
31789
31845
|
getChartColors(sheetId) {
|
|
31790
|
-
const charts = this.getters
|
|
31791
|
-
.getChartIds(sheetId)
|
|
31792
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
31846
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31793
31847
|
let chartsColors = new Set();
|
|
31794
31848
|
for (let chart of charts) {
|
|
31795
31849
|
if (chart === undefined) {
|
|
@@ -32145,37 +32199,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
32145
32199
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
32146
32200
|
cmd.type === "EVALUATE_CELLS" ||
|
|
32147
32201
|
cmd.type === "UPDATE_CELL") {
|
|
32148
|
-
for (const
|
|
32149
|
-
|
|
32150
|
-
this.charts[sheetId][chartId] = undefined;
|
|
32151
|
-
}
|
|
32202
|
+
for (const chartId in this.charts) {
|
|
32203
|
+
this.charts[chartId] = undefined;
|
|
32152
32204
|
}
|
|
32153
32205
|
}
|
|
32154
32206
|
switch (cmd.type) {
|
|
32155
32207
|
case "UPDATE_CHART":
|
|
32156
32208
|
case "CREATE_CHART":
|
|
32157
32209
|
case "DELETE_FIGURE":
|
|
32158
|
-
|
|
32159
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
32160
|
-
}
|
|
32210
|
+
this.charts[cmd.id] = undefined;
|
|
32161
32211
|
break;
|
|
32162
32212
|
case "DELETE_SHEET":
|
|
32163
|
-
|
|
32213
|
+
for (let chartId in this.charts) {
|
|
32214
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
32215
|
+
this.charts[chartId] = undefined;
|
|
32216
|
+
}
|
|
32217
|
+
}
|
|
32164
32218
|
break;
|
|
32165
32219
|
}
|
|
32166
32220
|
}
|
|
32167
|
-
getChartRuntime(
|
|
32168
|
-
|
|
32169
|
-
|
|
32170
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
32221
|
+
getChartRuntime(figureId) {
|
|
32222
|
+
if (!this.charts[figureId]) {
|
|
32223
|
+
const chart = this.getters.getChart(figureId);
|
|
32171
32224
|
if (!chart) {
|
|
32172
32225
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
32173
32226
|
}
|
|
32174
|
-
|
|
32175
|
-
this.charts[sheetId] = {};
|
|
32176
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
32227
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
32177
32228
|
}
|
|
32178
|
-
return this.charts[
|
|
32229
|
+
return this.charts[figureId];
|
|
32179
32230
|
}
|
|
32180
32231
|
/**
|
|
32181
32232
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -37819,7 +37870,7 @@ class ClipboardFigureChart {
|
|
|
37819
37870
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37820
37871
|
this.dispatch = dispatch;
|
|
37821
37872
|
this.sheetId = sheetId;
|
|
37822
|
-
const chart = getters.getChart(
|
|
37873
|
+
const chart = getters.getChart(copiedFigureId);
|
|
37823
37874
|
if (!chart) {
|
|
37824
37875
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
37825
37876
|
}
|
|
@@ -37840,7 +37891,7 @@ class ClipboardFigureImage {
|
|
|
37840
37891
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37841
37892
|
this.dispatch = dispatch;
|
|
37842
37893
|
this.sheetId = sheetId;
|
|
37843
|
-
const image = getters.getImage(
|
|
37894
|
+
const image = getters.getImage(copiedFigureId);
|
|
37844
37895
|
this.copiedImage = deepCopy(image);
|
|
37845
37896
|
}
|
|
37846
37897
|
paste(sheetId, figureId, position, size) {
|
|
@@ -43848,6 +43899,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
43848
43899
|
exports.tokenize = tokenize;
|
|
43849
43900
|
|
|
43850
43901
|
|
|
43851
|
-
__info__.version = '16.1.
|
|
43852
|
-
__info__.date = '2023-03-
|
|
43853
|
-
__info__.hash = '
|
|
43902
|
+
__info__.version = '16.1.3';
|
|
43903
|
+
__info__.date = '2023-03-06T07:18:06.669Z';
|
|
43904
|
+
__info__.hash = '7e26a7c';
|