@odoo/o-spreadsheet 16.1.1 → 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 -107
- package/dist/o_spreadsheet.d.ts +26 -25
- package/dist/o_spreadsheet.esm.js +153 -107
- package/dist/o_spreadsheet.iife.js +153 -107
- package/dist/o_spreadsheet.iife.min.js +156 -156
- package/package.json +7 -4
|
@@ -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
|
}
|
|
@@ -20518,7 +20515,6 @@ class ChartPanel extends owl.Component {
|
|
|
20518
20515
|
...this.getChartDefinition(),
|
|
20519
20516
|
...updateDefinition,
|
|
20520
20517
|
};
|
|
20521
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
20522
20518
|
return this.env.model.dispatch("UPDATE_CHART", {
|
|
20523
20519
|
definition,
|
|
20524
20520
|
id: this.figureId,
|
|
@@ -20526,12 +20522,11 @@ class ChartPanel extends owl.Component {
|
|
|
20526
20522
|
});
|
|
20527
20523
|
}
|
|
20528
20524
|
onTypeChange(type) {
|
|
20529
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
20525
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
20530
20526
|
if (!context) {
|
|
20531
20527
|
throw new Error("Chart not defined.");
|
|
20532
20528
|
}
|
|
20533
20529
|
const definition = getChartDefinitionFromContextCreation(context, type);
|
|
20534
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
20535
20530
|
this.env.model.dispatch("UPDATE_CHART", {
|
|
20536
20531
|
definition,
|
|
20537
20532
|
id: this.figureId,
|
|
@@ -20539,7 +20534,7 @@ class ChartPanel extends owl.Component {
|
|
|
20539
20534
|
});
|
|
20540
20535
|
}
|
|
20541
20536
|
get chartPanel() {
|
|
20542
|
-
const type = this.env.model.getters.getChartType(this.
|
|
20537
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
20543
20538
|
if (!type) {
|
|
20544
20539
|
throw new Error("Chart not defined.");
|
|
20545
20540
|
}
|
|
@@ -20549,8 +20544,8 @@ class ChartPanel extends owl.Component {
|
|
|
20549
20544
|
}
|
|
20550
20545
|
return chartPanel;
|
|
20551
20546
|
}
|
|
20552
|
-
getChartDefinition() {
|
|
20553
|
-
return this.env.model.getters.getChartDefinition(
|
|
20547
|
+
getChartDefinition(figureId = this.figureId) {
|
|
20548
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
20554
20549
|
}
|
|
20555
20550
|
get chartTypes() {
|
|
20556
20551
|
return getChartTypes();
|
|
@@ -27109,13 +27104,7 @@ function load(data, verboseImport) {
|
|
|
27109
27104
|
data = migrate(data);
|
|
27110
27105
|
}
|
|
27111
27106
|
}
|
|
27112
|
-
|
|
27113
|
-
// sensible default values
|
|
27114
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
27115
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
27116
|
-
if (data.sheets.length === 0) {
|
|
27117
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
27118
|
-
}
|
|
27107
|
+
data = repairData(data);
|
|
27119
27108
|
return data;
|
|
27120
27109
|
}
|
|
27121
27110
|
function migrate(data) {
|
|
@@ -27353,6 +27342,48 @@ const MIGRATIONS = [
|
|
|
27353
27342
|
},
|
|
27354
27343
|
},
|
|
27355
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
|
+
}
|
|
27356
27387
|
/**
|
|
27357
27388
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
27358
27389
|
* a bug.
|
|
@@ -27491,6 +27522,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
27491
27522
|
formats: {},
|
|
27492
27523
|
borders: {},
|
|
27493
27524
|
revisionId: DEFAULT_REVISION_ID,
|
|
27525
|
+
uniqueFigureIds: true,
|
|
27494
27526
|
};
|
|
27495
27527
|
return data;
|
|
27496
27528
|
}
|
|
@@ -28488,10 +28520,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
28488
28520
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
28489
28521
|
}
|
|
28490
28522
|
adaptRanges(applyChange) {
|
|
28491
|
-
for (const
|
|
28492
|
-
|
|
28493
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28494
|
-
}
|
|
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));
|
|
28495
28525
|
}
|
|
28496
28526
|
}
|
|
28497
28527
|
// ---------------------------------------------------------------------------
|
|
@@ -28502,20 +28532,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
28502
28532
|
case "CREATE_CHART":
|
|
28503
28533
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
28504
28534
|
case "UPDATE_CHART":
|
|
28505
|
-
return this.
|
|
28535
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
28506
28536
|
default:
|
|
28507
28537
|
return 0 /* CommandResult.Success */;
|
|
28508
28538
|
}
|
|
28509
28539
|
}
|
|
28510
28540
|
handle(cmd) {
|
|
28511
|
-
var _a
|
|
28541
|
+
var _a;
|
|
28512
28542
|
switch (cmd.type) {
|
|
28513
28543
|
case "CREATE_CHART":
|
|
28514
28544
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
28515
|
-
this.addChart(cmd.id, cmd.
|
|
28545
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28516
28546
|
break;
|
|
28517
28547
|
case "UPDATE_CHART": {
|
|
28518
|
-
this.addChart(cmd.id, cmd.
|
|
28548
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28519
28549
|
break;
|
|
28520
28550
|
}
|
|
28521
28551
|
case "DUPLICATE_SHEET": {
|
|
@@ -28524,7 +28554,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
28524
28554
|
if (fig.tag === "chart") {
|
|
28525
28555
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
28526
28556
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
28527
|
-
const chart = (
|
|
28557
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
28528
28558
|
if (chart) {
|
|
28529
28559
|
this.dispatch("CREATE_CHART", {
|
|
28530
28560
|
id: duplicatedFigureId,
|
|
@@ -28539,44 +28569,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
28539
28569
|
break;
|
|
28540
28570
|
}
|
|
28541
28571
|
case "DELETE_FIGURE":
|
|
28542
|
-
this.history.update("charts", cmd.
|
|
28572
|
+
this.history.update("charts", cmd.id, undefined);
|
|
28543
28573
|
break;
|
|
28544
28574
|
case "DELETE_SHEET":
|
|
28545
|
-
this.
|
|
28575
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
28576
|
+
this.history.update("charts", id, undefined);
|
|
28577
|
+
}
|
|
28546
28578
|
break;
|
|
28547
28579
|
}
|
|
28548
28580
|
}
|
|
28549
28581
|
// ---------------------------------------------------------------------------
|
|
28550
28582
|
// Getters
|
|
28551
28583
|
// ---------------------------------------------------------------------------
|
|
28552
|
-
getContextCreationChart(
|
|
28553
|
-
var _a, _b;
|
|
28554
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
28555
|
-
}
|
|
28556
|
-
getChart(sheetId, figureId) {
|
|
28584
|
+
getContextCreationChart(figureId) {
|
|
28557
28585
|
var _a;
|
|
28558
|
-
return (_a = this.charts[
|
|
28586
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
28559
28587
|
}
|
|
28560
|
-
|
|
28561
|
-
|
|
28562
|
-
|
|
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;
|
|
28563
28594
|
if (!type) {
|
|
28564
28595
|
throw new Error("Chart not defined.");
|
|
28565
28596
|
}
|
|
28566
28597
|
return type;
|
|
28567
28598
|
}
|
|
28568
|
-
isChartDefined(
|
|
28569
|
-
return figureId in
|
|
28599
|
+
isChartDefined(figureId) {
|
|
28600
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
28570
28601
|
}
|
|
28571
28602
|
getChartIds(sheetId) {
|
|
28572
|
-
|
|
28573
|
-
|
|
28574
|
-
|
|
28575
|
-
return Object.keys(this.charts[sheetId] || {});
|
|
28603
|
+
return Object.entries(this.charts)
|
|
28604
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
28605
|
+
.map(([id]) => id);
|
|
28576
28606
|
}
|
|
28577
|
-
getChartDefinition(
|
|
28578
|
-
var _a
|
|
28579
|
-
const definition = (
|
|
28607
|
+
getChartDefinition(figureId) {
|
|
28608
|
+
var _a;
|
|
28609
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28580
28610
|
if (!definition) {
|
|
28581
28611
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
28582
28612
|
}
|
|
@@ -28588,28 +28618,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
28588
28618
|
import(data) {
|
|
28589
28619
|
for (let sheet of data.sheets) {
|
|
28590
28620
|
if (sheet.figures) {
|
|
28591
|
-
const charts = {};
|
|
28592
28621
|
for (let figure of sheet.figures) {
|
|
28593
28622
|
// TODO:
|
|
28594
28623
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
28595
28624
|
// instead of in figure.data
|
|
28596
28625
|
if (figure.tag === "chart") {
|
|
28597
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28626
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28598
28627
|
}
|
|
28599
28628
|
}
|
|
28600
|
-
this.charts[sheet.id] = charts;
|
|
28601
28629
|
}
|
|
28602
28630
|
}
|
|
28603
28631
|
}
|
|
28604
28632
|
export(data) {
|
|
28633
|
+
var _a;
|
|
28605
28634
|
if (data.sheets) {
|
|
28606
28635
|
for (let sheet of data.sheets) {
|
|
28607
28636
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
28608
28637
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28609
|
-
const figures =
|
|
28610
|
-
for (let
|
|
28638
|
+
const figures = [];
|
|
28639
|
+
for (let sheetFigure of sheetFigures) {
|
|
28640
|
+
const figure = sheetFigure;
|
|
28611
28641
|
if (figure && figure.tag === "chart") {
|
|
28612
|
-
|
|
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);
|
|
28613
28650
|
}
|
|
28614
28651
|
}
|
|
28615
28652
|
sheet.figures = figures;
|
|
@@ -28617,13 +28654,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
28617
28654
|
}
|
|
28618
28655
|
}
|
|
28619
28656
|
exportForExcel(data) {
|
|
28620
|
-
var _a
|
|
28657
|
+
var _a;
|
|
28621
28658
|
for (let sheet of data.sheets) {
|
|
28622
28659
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28623
28660
|
const figures = [];
|
|
28624
28661
|
for (let figure of sheetFigures) {
|
|
28625
28662
|
if (figure && figure.tag === "chart") {
|
|
28626
|
-
const figureData = (
|
|
28663
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
28627
28664
|
if (figureData) {
|
|
28628
28665
|
figures.push({
|
|
28629
28666
|
...figure,
|
|
@@ -28662,15 +28699,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
28662
28699
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
28663
28700
|
* replaced
|
|
28664
28701
|
*/
|
|
28665
|
-
addChart(id,
|
|
28666
|
-
|
|
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
|
+
}
|
|
28667
28707
|
}
|
|
28668
28708
|
checkChartDuplicate(cmd) {
|
|
28669
|
-
|
|
28670
|
-
|
|
28671
|
-
|
|
28672
|
-
|
|
28673
|
-
|
|
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 */;
|
|
28674
28717
|
}
|
|
28675
28718
|
}
|
|
28676
28719
|
ChartPlugin.getters = [
|
|
@@ -29051,7 +29094,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29051
29094
|
allowDispatch(cmd) {
|
|
29052
29095
|
switch (cmd.type) {
|
|
29053
29096
|
case "CREATE_FIGURE":
|
|
29054
|
-
return this.checkFigureDuplicate(cmd.
|
|
29097
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
29055
29098
|
case "UPDATE_FIGURE":
|
|
29056
29099
|
case "DELETE_FIGURE":
|
|
29057
29100
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -29117,9 +29160,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
29117
29160
|
}
|
|
29118
29161
|
return 0 /* CommandResult.Success */;
|
|
29119
29162
|
}
|
|
29120
|
-
checkFigureDuplicate(
|
|
29121
|
-
|
|
29122
|
-
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])) {
|
|
29123
29165
|
return 82 /* CommandResult.DuplicatedFigureId */;
|
|
29124
29166
|
}
|
|
29125
29167
|
return 0 /* CommandResult.Success */;
|
|
@@ -29134,6 +29176,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
29134
29176
|
var _a;
|
|
29135
29177
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
29136
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
|
+
}
|
|
29137
29182
|
// ---------------------------------------------------------------------------
|
|
29138
29183
|
// Import/Export
|
|
29139
29184
|
// ---------------------------------------------------------------------------
|
|
@@ -29158,7 +29203,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29158
29203
|
this.export(data);
|
|
29159
29204
|
}
|
|
29160
29205
|
}
|
|
29161
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
29206
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
29162
29207
|
|
|
29163
29208
|
class FilterTable {
|
|
29164
29209
|
constructor(zone) {
|
|
@@ -29885,7 +29930,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29885
29930
|
switch (cmd.type) {
|
|
29886
29931
|
case "CREATE_IMAGE":
|
|
29887
29932
|
if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
|
|
29888
|
-
return 28 /* CommandResult.
|
|
29933
|
+
return 28 /* CommandResult.InvalidFigureId */;
|
|
29889
29934
|
}
|
|
29890
29935
|
return 0 /* CommandResult.Success */;
|
|
29891
29936
|
default:
|
|
@@ -29905,7 +29950,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29905
29950
|
if (fig.tag === "image") {
|
|
29906
29951
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
29907
29952
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
29908
|
-
const image = this.getImage(
|
|
29953
|
+
const image = this.getImage(fig.id);
|
|
29909
29954
|
if (image) {
|
|
29910
29955
|
const size = { width: fig.width, height: fig.height };
|
|
29911
29956
|
this.dispatch("CREATE_IMAGE", {
|
|
@@ -29943,13 +29988,19 @@ class ImagePlugin extends CorePlugin {
|
|
|
29943
29988
|
// ---------------------------------------------------------------------------
|
|
29944
29989
|
// Getters
|
|
29945
29990
|
// ---------------------------------------------------------------------------
|
|
29946
|
-
getImage(
|
|
29947
|
-
|
|
29948
|
-
|
|
29949
|
-
|
|
29950
|
-
|
|
29991
|
+
getImage(figureId) {
|
|
29992
|
+
for (const sheet of Object.values(this.images)) {
|
|
29993
|
+
if (sheet && sheet[figureId]) {
|
|
29994
|
+
return sheet[figureId];
|
|
29995
|
+
}
|
|
29951
29996
|
}
|
|
29952
|
-
|
|
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;
|
|
29953
30004
|
}
|
|
29954
30005
|
// ---------------------------------------------------------------------------
|
|
29955
30006
|
// Private
|
|
@@ -29991,7 +30042,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29991
30042
|
return images;
|
|
29992
30043
|
}
|
|
29993
30044
|
}
|
|
29994
|
-
ImagePlugin.getters = ["getImage"];
|
|
30045
|
+
ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
|
|
29995
30046
|
|
|
29996
30047
|
class MergePlugin extends CorePlugin {
|
|
29997
30048
|
constructor() {
|
|
@@ -31792,9 +31843,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31792
31843
|
return formatColors.filter(isDefined$1);
|
|
31793
31844
|
}
|
|
31794
31845
|
getChartColors(sheetId) {
|
|
31795
|
-
const charts = this.getters
|
|
31796
|
-
.getChartIds(sheetId)
|
|
31797
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
31846
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31798
31847
|
let chartsColors = new Set();
|
|
31799
31848
|
for (let chart of charts) {
|
|
31800
31849
|
if (chart === undefined) {
|
|
@@ -32150,37 +32199,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
32150
32199
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
32151
32200
|
cmd.type === "EVALUATE_CELLS" ||
|
|
32152
32201
|
cmd.type === "UPDATE_CELL") {
|
|
32153
|
-
for (const
|
|
32154
|
-
|
|
32155
|
-
this.charts[sheetId][chartId] = undefined;
|
|
32156
|
-
}
|
|
32202
|
+
for (const chartId in this.charts) {
|
|
32203
|
+
this.charts[chartId] = undefined;
|
|
32157
32204
|
}
|
|
32158
32205
|
}
|
|
32159
32206
|
switch (cmd.type) {
|
|
32160
32207
|
case "UPDATE_CHART":
|
|
32161
32208
|
case "CREATE_CHART":
|
|
32162
32209
|
case "DELETE_FIGURE":
|
|
32163
|
-
|
|
32164
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
32165
|
-
}
|
|
32210
|
+
this.charts[cmd.id] = undefined;
|
|
32166
32211
|
break;
|
|
32167
32212
|
case "DELETE_SHEET":
|
|
32168
|
-
|
|
32213
|
+
for (let chartId in this.charts) {
|
|
32214
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
32215
|
+
this.charts[chartId] = undefined;
|
|
32216
|
+
}
|
|
32217
|
+
}
|
|
32169
32218
|
break;
|
|
32170
32219
|
}
|
|
32171
32220
|
}
|
|
32172
|
-
getChartRuntime(
|
|
32173
|
-
|
|
32174
|
-
|
|
32175
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
32221
|
+
getChartRuntime(figureId) {
|
|
32222
|
+
if (!this.charts[figureId]) {
|
|
32223
|
+
const chart = this.getters.getChart(figureId);
|
|
32176
32224
|
if (!chart) {
|
|
32177
32225
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
32178
32226
|
}
|
|
32179
|
-
|
|
32180
|
-
this.charts[sheetId] = {};
|
|
32181
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
32227
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
32182
32228
|
}
|
|
32183
|
-
return this.charts[
|
|
32229
|
+
return this.charts[figureId];
|
|
32184
32230
|
}
|
|
32185
32231
|
/**
|
|
32186
32232
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -37824,7 +37870,7 @@ class ClipboardFigureChart {
|
|
|
37824
37870
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37825
37871
|
this.dispatch = dispatch;
|
|
37826
37872
|
this.sheetId = sheetId;
|
|
37827
|
-
const chart = getters.getChart(
|
|
37873
|
+
const chart = getters.getChart(copiedFigureId);
|
|
37828
37874
|
if (!chart) {
|
|
37829
37875
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
37830
37876
|
}
|
|
@@ -37845,7 +37891,7 @@ class ClipboardFigureImage {
|
|
|
37845
37891
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37846
37892
|
this.dispatch = dispatch;
|
|
37847
37893
|
this.sheetId = sheetId;
|
|
37848
|
-
const image = getters.getImage(
|
|
37894
|
+
const image = getters.getImage(copiedFigureId);
|
|
37849
37895
|
this.copiedImage = deepCopy(image);
|
|
37850
37896
|
}
|
|
37851
37897
|
paste(sheetId, figureId, position, size) {
|
|
@@ -43853,6 +43899,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
43853
43899
|
exports.tokenize = tokenize;
|
|
43854
43900
|
|
|
43855
43901
|
|
|
43856
|
-
__info__.version = '16.1.
|
|
43857
|
-
__info__.date = '2023-
|
|
43858
|
-
__info__.hash = '
|
|
43902
|
+
__info__.version = '16.1.3';
|
|
43903
|
+
__info__.date = '2023-03-06T07:18:06.669Z';
|
|
43904
|
+
__info__.hash = '7e26a7c';
|