@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
|
@@ -2823,7 +2823,7 @@ class ChartJsComponent extends Component {
|
|
|
2823
2823
|
return `background-color: ${this.background}`;
|
|
2824
2824
|
}
|
|
2825
2825
|
get chartRuntime() {
|
|
2826
|
-
const runtime = this.env.model.getters.getChartRuntime(this.
|
|
2826
|
+
const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
2827
2827
|
if (!("chartJsConfig" in runtime)) {
|
|
2828
2828
|
throw new Error("Unsupported chart runtime");
|
|
2829
2829
|
}
|
|
@@ -3077,7 +3077,7 @@ class ScorecardChart$1 extends Component {
|
|
|
3077
3077
|
this.ctx = document.createElement("canvas").getContext("2d");
|
|
3078
3078
|
}
|
|
3079
3079
|
get runtime() {
|
|
3080
|
-
return this.env.model.getters.getChartRuntime(this.
|
|
3080
|
+
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
3081
3081
|
}
|
|
3082
3082
|
get title() {
|
|
3083
3083
|
return this.runtime.title;
|
|
@@ -3468,7 +3468,7 @@ var CommandResult;
|
|
|
3468
3468
|
CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
|
|
3469
3469
|
CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
|
|
3470
3470
|
CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
|
|
3471
|
-
CommandResult[CommandResult["
|
|
3471
|
+
CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
|
|
3472
3472
|
CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
|
|
3473
3473
|
CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
|
|
3474
3474
|
CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
|
|
@@ -3525,6 +3525,7 @@ var CommandResult;
|
|
|
3525
3525
|
CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
|
|
3526
3526
|
CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
|
|
3527
3527
|
CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
|
|
3528
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
|
|
3528
3529
|
})(CommandResult || (CommandResult = {}));
|
|
3529
3530
|
|
|
3530
3531
|
var DIRECTION;
|
|
@@ -6065,7 +6066,7 @@ class ChartFigure extends Component {
|
|
|
6065
6066
|
return registry;
|
|
6066
6067
|
}
|
|
6067
6068
|
get chartType() {
|
|
6068
|
-
return this.env.model.getters.getChartType(this.
|
|
6069
|
+
return this.env.model.getters.getChartType(this.props.figure.id);
|
|
6069
6070
|
}
|
|
6070
6071
|
onContextMenu(ev) {
|
|
6071
6072
|
const position = {
|
|
@@ -18800,7 +18801,7 @@ class ImageFigure extends Component {
|
|
|
18800
18801
|
name: _lt("Reset size"),
|
|
18801
18802
|
sequence: 3,
|
|
18802
18803
|
action: () => {
|
|
18803
|
-
const size = this.env.model.getters.
|
|
18804
|
+
const size = this.env.model.getters.getImageSize(this.figureId);
|
|
18804
18805
|
const { height, width } = getMaxFigureSize(this.env.model.getters, size);
|
|
18805
18806
|
this.env.model.dispatch("UPDATE_FIGURE", {
|
|
18806
18807
|
sheetId: this.env.model.getters.getActiveSheetId(),
|
|
@@ -18851,8 +18852,7 @@ class ImageFigure extends Component {
|
|
|
18851
18852
|
return this.props.figure.id;
|
|
18852
18853
|
}
|
|
18853
18854
|
get getImagePath() {
|
|
18854
|
-
return this.env.model.getters.
|
|
18855
|
-
.path;
|
|
18855
|
+
return this.env.model.getters.getImagePath(this.figureId);
|
|
18856
18856
|
}
|
|
18857
18857
|
}
|
|
18858
18858
|
ImageFigure.template = "o-spreadsheet-ImageFigure";
|
|
@@ -19807,7 +19807,6 @@ class LineBarPieConfigPanel extends Component {
|
|
|
19807
19807
|
LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
|
|
19808
19808
|
LineBarPieConfigPanel.components = { SelectionInput };
|
|
19809
19809
|
LineBarPieConfigPanel.props = {
|
|
19810
|
-
sheetId: String,
|
|
19811
19810
|
figureId: String,
|
|
19812
19811
|
definition: Object,
|
|
19813
19812
|
updateChart: Function,
|
|
@@ -20137,7 +20136,6 @@ class GaugeChartConfigPanel extends Component {
|
|
|
20137
20136
|
GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
|
|
20138
20137
|
GaugeChartConfigPanel.components = { SelectionInput };
|
|
20139
20138
|
GaugeChartConfigPanel.props = {
|
|
20140
|
-
sheetId: String,
|
|
20141
20139
|
figureId: String,
|
|
20142
20140
|
definition: Object,
|
|
20143
20141
|
updateChart: Function,
|
|
@@ -20291,7 +20289,7 @@ GaugeChartDesignPanel.props = {
|
|
|
20291
20289
|
|
|
20292
20290
|
class LineConfigPanel extends LineBarPieConfigPanel {
|
|
20293
20291
|
get canTreatLabelsAsText() {
|
|
20294
|
-
const chart = this.env.model.getters.getChart(this.props.
|
|
20292
|
+
const chart = this.env.model.getters.getChart(this.props.figureId);
|
|
20295
20293
|
if (chart && chart instanceof LineChart) {
|
|
20296
20294
|
return canChartParseLabels(chart.labelRange, this.env.model.getters);
|
|
20297
20295
|
}
|
|
@@ -20368,7 +20366,6 @@ class ScorecardChartConfigPanel extends Component {
|
|
|
20368
20366
|
ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
|
|
20369
20367
|
ScorecardChartConfigPanel.components = { SelectionInput };
|
|
20370
20368
|
ScorecardChartConfigPanel.props = {
|
|
20371
|
-
sheetId: String,
|
|
20372
20369
|
figureId: String,
|
|
20373
20370
|
definition: Object,
|
|
20374
20371
|
updateChart: Function,
|
|
@@ -20500,7 +20497,7 @@ class ChartPanel extends Component {
|
|
|
20500
20497
|
else {
|
|
20501
20498
|
this.shouldUpdateChart = true;
|
|
20502
20499
|
}
|
|
20503
|
-
if (!this.env.model.getters.isChartDefined(this.
|
|
20500
|
+
if (!this.env.model.getters.isChartDefined(this.figureId)) {
|
|
20504
20501
|
this.props.onCloseSidePanel();
|
|
20505
20502
|
return;
|
|
20506
20503
|
}
|
|
@@ -20514,7 +20511,6 @@ class ChartPanel extends Component {
|
|
|
20514
20511
|
...this.getChartDefinition(),
|
|
20515
20512
|
...updateDefinition,
|
|
20516
20513
|
};
|
|
20517
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
20518
20514
|
return this.env.model.dispatch("UPDATE_CHART", {
|
|
20519
20515
|
definition,
|
|
20520
20516
|
id: this.figureId,
|
|
@@ -20522,12 +20518,11 @@ class ChartPanel extends Component {
|
|
|
20522
20518
|
});
|
|
20523
20519
|
}
|
|
20524
20520
|
onTypeChange(type) {
|
|
20525
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
20521
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
20526
20522
|
if (!context) {
|
|
20527
20523
|
throw new Error("Chart not defined.");
|
|
20528
20524
|
}
|
|
20529
20525
|
const definition = getChartDefinitionFromContextCreation(context, type);
|
|
20530
|
-
// TODORAR add a putain de test - c'est faux de nouveau ...
|
|
20531
20526
|
this.env.model.dispatch("UPDATE_CHART", {
|
|
20532
20527
|
definition,
|
|
20533
20528
|
id: this.figureId,
|
|
@@ -20535,7 +20530,7 @@ class ChartPanel extends Component {
|
|
|
20535
20530
|
});
|
|
20536
20531
|
}
|
|
20537
20532
|
get chartPanel() {
|
|
20538
|
-
const type = this.env.model.getters.getChartType(this.
|
|
20533
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
20539
20534
|
if (!type) {
|
|
20540
20535
|
throw new Error("Chart not defined.");
|
|
20541
20536
|
}
|
|
@@ -20545,8 +20540,8 @@ class ChartPanel extends Component {
|
|
|
20545
20540
|
}
|
|
20546
20541
|
return chartPanel;
|
|
20547
20542
|
}
|
|
20548
|
-
getChartDefinition() {
|
|
20549
|
-
return this.env.model.getters.getChartDefinition(
|
|
20543
|
+
getChartDefinition(figureId = this.figureId) {
|
|
20544
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
20550
20545
|
}
|
|
20551
20546
|
get chartTypes() {
|
|
20552
20547
|
return getChartTypes();
|
|
@@ -27105,13 +27100,7 @@ function load(data, verboseImport) {
|
|
|
27105
27100
|
data = migrate(data);
|
|
27106
27101
|
}
|
|
27107
27102
|
}
|
|
27108
|
-
|
|
27109
|
-
// sensible default values
|
|
27110
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
27111
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
27112
|
-
if (data.sheets.length === 0) {
|
|
27113
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
27114
|
-
}
|
|
27103
|
+
data = repairData(data);
|
|
27115
27104
|
return data;
|
|
27116
27105
|
}
|
|
27117
27106
|
function migrate(data) {
|
|
@@ -27349,6 +27338,48 @@ const MIGRATIONS = [
|
|
|
27349
27338
|
},
|
|
27350
27339
|
},
|
|
27351
27340
|
];
|
|
27341
|
+
/**
|
|
27342
|
+
* This function is used to repair faulty data independently of the migration.
|
|
27343
|
+
*/
|
|
27344
|
+
function repairData(data) {
|
|
27345
|
+
data = forceUnicityOfFigure(data);
|
|
27346
|
+
data = setDefaults(data);
|
|
27347
|
+
return data;
|
|
27348
|
+
}
|
|
27349
|
+
/**
|
|
27350
|
+
* Force the unicity of figure ids accross sheets
|
|
27351
|
+
*/
|
|
27352
|
+
function forceUnicityOfFigure(data) {
|
|
27353
|
+
if (data.uniqueFigureIds) {
|
|
27354
|
+
return data;
|
|
27355
|
+
}
|
|
27356
|
+
const figureIds = new Set();
|
|
27357
|
+
const uuidGenerator = new UuidGenerator();
|
|
27358
|
+
for (const sheet of data.sheets || []) {
|
|
27359
|
+
for (const figure of sheet.figures || []) {
|
|
27360
|
+
if (figureIds.has(figure.id)) {
|
|
27361
|
+
figure.id += uuidGenerator.uuidv4();
|
|
27362
|
+
}
|
|
27363
|
+
figureIds.add(figure.id);
|
|
27364
|
+
}
|
|
27365
|
+
}
|
|
27366
|
+
data.uniqueFigureIds = true;
|
|
27367
|
+
return data;
|
|
27368
|
+
}
|
|
27369
|
+
/**
|
|
27370
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
27371
|
+
* sensible default values
|
|
27372
|
+
*/
|
|
27373
|
+
function setDefaults(data) {
|
|
27374
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
27375
|
+
data.sheets = data.sheets
|
|
27376
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
27377
|
+
: [];
|
|
27378
|
+
if (data.sheets.length === 0) {
|
|
27379
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
27380
|
+
}
|
|
27381
|
+
return data;
|
|
27382
|
+
}
|
|
27352
27383
|
/**
|
|
27353
27384
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
27354
27385
|
* a bug.
|
|
@@ -27487,6 +27518,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
27487
27518
|
formats: {},
|
|
27488
27519
|
borders: {},
|
|
27489
27520
|
revisionId: DEFAULT_REVISION_ID,
|
|
27521
|
+
uniqueFigureIds: true,
|
|
27490
27522
|
};
|
|
27491
27523
|
return data;
|
|
27492
27524
|
}
|
|
@@ -28484,10 +28516,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
28484
28516
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
28485
28517
|
}
|
|
28486
28518
|
adaptRanges(applyChange) {
|
|
28487
|
-
for (const
|
|
28488
|
-
|
|
28489
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28490
|
-
}
|
|
28519
|
+
for (const [chartId, chart] of Object.entries(this.charts)) {
|
|
28520
|
+
this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28491
28521
|
}
|
|
28492
28522
|
}
|
|
28493
28523
|
// ---------------------------------------------------------------------------
|
|
@@ -28498,20 +28528,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
28498
28528
|
case "CREATE_CHART":
|
|
28499
28529
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
28500
28530
|
case "UPDATE_CHART":
|
|
28501
|
-
return this.
|
|
28531
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
28502
28532
|
default:
|
|
28503
28533
|
return 0 /* CommandResult.Success */;
|
|
28504
28534
|
}
|
|
28505
28535
|
}
|
|
28506
28536
|
handle(cmd) {
|
|
28507
|
-
var _a
|
|
28537
|
+
var _a;
|
|
28508
28538
|
switch (cmd.type) {
|
|
28509
28539
|
case "CREATE_CHART":
|
|
28510
28540
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
28511
|
-
this.addChart(cmd.id, cmd.
|
|
28541
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28512
28542
|
break;
|
|
28513
28543
|
case "UPDATE_CHART": {
|
|
28514
|
-
this.addChart(cmd.id, cmd.
|
|
28544
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28515
28545
|
break;
|
|
28516
28546
|
}
|
|
28517
28547
|
case "DUPLICATE_SHEET": {
|
|
@@ -28520,7 +28550,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
28520
28550
|
if (fig.tag === "chart") {
|
|
28521
28551
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
28522
28552
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
28523
|
-
const chart = (
|
|
28553
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
28524
28554
|
if (chart) {
|
|
28525
28555
|
this.dispatch("CREATE_CHART", {
|
|
28526
28556
|
id: duplicatedFigureId,
|
|
@@ -28535,44 +28565,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
28535
28565
|
break;
|
|
28536
28566
|
}
|
|
28537
28567
|
case "DELETE_FIGURE":
|
|
28538
|
-
this.history.update("charts", cmd.
|
|
28568
|
+
this.history.update("charts", cmd.id, undefined);
|
|
28539
28569
|
break;
|
|
28540
28570
|
case "DELETE_SHEET":
|
|
28541
|
-
this.
|
|
28571
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
28572
|
+
this.history.update("charts", id, undefined);
|
|
28573
|
+
}
|
|
28542
28574
|
break;
|
|
28543
28575
|
}
|
|
28544
28576
|
}
|
|
28545
28577
|
// ---------------------------------------------------------------------------
|
|
28546
28578
|
// Getters
|
|
28547
28579
|
// ---------------------------------------------------------------------------
|
|
28548
|
-
getContextCreationChart(
|
|
28549
|
-
var _a, _b;
|
|
28550
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
28551
|
-
}
|
|
28552
|
-
getChart(sheetId, figureId) {
|
|
28580
|
+
getContextCreationChart(figureId) {
|
|
28553
28581
|
var _a;
|
|
28554
|
-
return (_a = this.charts[
|
|
28582
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
28555
28583
|
}
|
|
28556
|
-
|
|
28557
|
-
|
|
28558
|
-
|
|
28584
|
+
getChart(figureId) {
|
|
28585
|
+
return this.charts[figureId];
|
|
28586
|
+
}
|
|
28587
|
+
getChartType(figureId) {
|
|
28588
|
+
var _a;
|
|
28589
|
+
const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
|
|
28559
28590
|
if (!type) {
|
|
28560
28591
|
throw new Error("Chart not defined.");
|
|
28561
28592
|
}
|
|
28562
28593
|
return type;
|
|
28563
28594
|
}
|
|
28564
|
-
isChartDefined(
|
|
28565
|
-
return figureId in
|
|
28595
|
+
isChartDefined(figureId) {
|
|
28596
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
28566
28597
|
}
|
|
28567
28598
|
getChartIds(sheetId) {
|
|
28568
|
-
|
|
28569
|
-
|
|
28570
|
-
|
|
28571
|
-
return Object.keys(this.charts[sheetId] || {});
|
|
28599
|
+
return Object.entries(this.charts)
|
|
28600
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
28601
|
+
.map(([id]) => id);
|
|
28572
28602
|
}
|
|
28573
|
-
getChartDefinition(
|
|
28574
|
-
var _a
|
|
28575
|
-
const definition = (
|
|
28603
|
+
getChartDefinition(figureId) {
|
|
28604
|
+
var _a;
|
|
28605
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28576
28606
|
if (!definition) {
|
|
28577
28607
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
28578
28608
|
}
|
|
@@ -28584,28 +28614,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
28584
28614
|
import(data) {
|
|
28585
28615
|
for (let sheet of data.sheets) {
|
|
28586
28616
|
if (sheet.figures) {
|
|
28587
|
-
const charts = {};
|
|
28588
28617
|
for (let figure of sheet.figures) {
|
|
28589
28618
|
// TODO:
|
|
28590
28619
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
28591
28620
|
// instead of in figure.data
|
|
28592
28621
|
if (figure.tag === "chart") {
|
|
28593
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28622
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28594
28623
|
}
|
|
28595
28624
|
}
|
|
28596
|
-
this.charts[sheet.id] = charts;
|
|
28597
28625
|
}
|
|
28598
28626
|
}
|
|
28599
28627
|
}
|
|
28600
28628
|
export(data) {
|
|
28629
|
+
var _a;
|
|
28601
28630
|
if (data.sheets) {
|
|
28602
28631
|
for (let sheet of data.sheets) {
|
|
28603
28632
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
28604
28633
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28605
|
-
const figures =
|
|
28606
|
-
for (let
|
|
28634
|
+
const figures = [];
|
|
28635
|
+
for (let sheetFigure of sheetFigures) {
|
|
28636
|
+
const figure = sheetFigure;
|
|
28607
28637
|
if (figure && figure.tag === "chart") {
|
|
28608
|
-
|
|
28638
|
+
const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28639
|
+
if (data) {
|
|
28640
|
+
figure.data = data;
|
|
28641
|
+
figures.push(figure);
|
|
28642
|
+
}
|
|
28643
|
+
}
|
|
28644
|
+
else {
|
|
28645
|
+
figures.push(figure);
|
|
28609
28646
|
}
|
|
28610
28647
|
}
|
|
28611
28648
|
sheet.figures = figures;
|
|
@@ -28613,13 +28650,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
28613
28650
|
}
|
|
28614
28651
|
}
|
|
28615
28652
|
exportForExcel(data) {
|
|
28616
|
-
var _a
|
|
28653
|
+
var _a;
|
|
28617
28654
|
for (let sheet of data.sheets) {
|
|
28618
28655
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28619
28656
|
const figures = [];
|
|
28620
28657
|
for (let figure of sheetFigures) {
|
|
28621
28658
|
if (figure && figure.tag === "chart") {
|
|
28622
|
-
const figureData = (
|
|
28659
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
28623
28660
|
if (figureData) {
|
|
28624
28661
|
figures.push({
|
|
28625
28662
|
...figure,
|
|
@@ -28658,15 +28695,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
28658
28695
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
28659
28696
|
* replaced
|
|
28660
28697
|
*/
|
|
28661
|
-
addChart(id,
|
|
28662
|
-
|
|
28698
|
+
addChart(id, definition) {
|
|
28699
|
+
const sheetId = this.getters.getFigureSheetId(id);
|
|
28700
|
+
if (sheetId) {
|
|
28701
|
+
this.history.update("charts", id, this.createChart(id, definition, sheetId));
|
|
28702
|
+
}
|
|
28663
28703
|
}
|
|
28664
28704
|
checkChartDuplicate(cmd) {
|
|
28665
|
-
|
|
28666
|
-
|
|
28667
|
-
|
|
28668
|
-
|
|
28669
|
-
|
|
28705
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28706
|
+
? 84 /* CommandResult.DuplicatedChartId */
|
|
28707
|
+
: 0 /* CommandResult.Success */;
|
|
28708
|
+
}
|
|
28709
|
+
checkChartExists(cmd) {
|
|
28710
|
+
return this.getters.getFigureSheetId(cmd.id)
|
|
28711
|
+
? 0 /* CommandResult.Success */
|
|
28712
|
+
: 85 /* CommandResult.ChartDoesNotExist */;
|
|
28670
28713
|
}
|
|
28671
28714
|
}
|
|
28672
28715
|
ChartPlugin.getters = [
|
|
@@ -29047,7 +29090,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29047
29090
|
allowDispatch(cmd) {
|
|
29048
29091
|
switch (cmd.type) {
|
|
29049
29092
|
case "CREATE_FIGURE":
|
|
29050
|
-
return this.checkFigureDuplicate(cmd.
|
|
29093
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
29051
29094
|
case "UPDATE_FIGURE":
|
|
29052
29095
|
case "DELETE_FIGURE":
|
|
29053
29096
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -29113,9 +29156,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
29113
29156
|
}
|
|
29114
29157
|
return 0 /* CommandResult.Success */;
|
|
29115
29158
|
}
|
|
29116
|
-
checkFigureDuplicate(
|
|
29117
|
-
|
|
29118
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
29159
|
+
checkFigureDuplicate(figureId) {
|
|
29160
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
29119
29161
|
return 82 /* CommandResult.DuplicatedFigureId */;
|
|
29120
29162
|
}
|
|
29121
29163
|
return 0 /* CommandResult.Success */;
|
|
@@ -29130,6 +29172,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
29130
29172
|
var _a;
|
|
29131
29173
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
29132
29174
|
}
|
|
29175
|
+
getFigureSheetId(figureId) {
|
|
29176
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
29177
|
+
}
|
|
29133
29178
|
// ---------------------------------------------------------------------------
|
|
29134
29179
|
// Import/Export
|
|
29135
29180
|
// ---------------------------------------------------------------------------
|
|
@@ -29154,7 +29199,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29154
29199
|
this.export(data);
|
|
29155
29200
|
}
|
|
29156
29201
|
}
|
|
29157
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
29202
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
29158
29203
|
|
|
29159
29204
|
class FilterTable {
|
|
29160
29205
|
constructor(zone) {
|
|
@@ -29881,7 +29926,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29881
29926
|
switch (cmd.type) {
|
|
29882
29927
|
case "CREATE_IMAGE":
|
|
29883
29928
|
if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
|
|
29884
|
-
return 28 /* CommandResult.
|
|
29929
|
+
return 28 /* CommandResult.InvalidFigureId */;
|
|
29885
29930
|
}
|
|
29886
29931
|
return 0 /* CommandResult.Success */;
|
|
29887
29932
|
default:
|
|
@@ -29901,7 +29946,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29901
29946
|
if (fig.tag === "image") {
|
|
29902
29947
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
29903
29948
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
29904
|
-
const image = this.getImage(
|
|
29949
|
+
const image = this.getImage(fig.id);
|
|
29905
29950
|
if (image) {
|
|
29906
29951
|
const size = { width: fig.width, height: fig.height };
|
|
29907
29952
|
this.dispatch("CREATE_IMAGE", {
|
|
@@ -29939,13 +29984,19 @@ class ImagePlugin extends CorePlugin {
|
|
|
29939
29984
|
// ---------------------------------------------------------------------------
|
|
29940
29985
|
// Getters
|
|
29941
29986
|
// ---------------------------------------------------------------------------
|
|
29942
|
-
getImage(
|
|
29943
|
-
|
|
29944
|
-
|
|
29945
|
-
|
|
29946
|
-
|
|
29987
|
+
getImage(figureId) {
|
|
29988
|
+
for (const sheet of Object.values(this.images)) {
|
|
29989
|
+
if (sheet && sheet[figureId]) {
|
|
29990
|
+
return sheet[figureId];
|
|
29991
|
+
}
|
|
29947
29992
|
}
|
|
29948
|
-
|
|
29993
|
+
throw new Error(`There is no image with the given figureId: ${figureId}`);
|
|
29994
|
+
}
|
|
29995
|
+
getImagePath(figureId) {
|
|
29996
|
+
return this.getImage(figureId).path;
|
|
29997
|
+
}
|
|
29998
|
+
getImageSize(figureId) {
|
|
29999
|
+
return this.getImage(figureId).size;
|
|
29949
30000
|
}
|
|
29950
30001
|
// ---------------------------------------------------------------------------
|
|
29951
30002
|
// Private
|
|
@@ -29987,7 +30038,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29987
30038
|
return images;
|
|
29988
30039
|
}
|
|
29989
30040
|
}
|
|
29990
|
-
ImagePlugin.getters = ["getImage"];
|
|
30041
|
+
ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
|
|
29991
30042
|
|
|
29992
30043
|
class MergePlugin extends CorePlugin {
|
|
29993
30044
|
constructor() {
|
|
@@ -31788,9 +31839,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31788
31839
|
return formatColors.filter(isDefined$1);
|
|
31789
31840
|
}
|
|
31790
31841
|
getChartColors(sheetId) {
|
|
31791
|
-
const charts = this.getters
|
|
31792
|
-
.getChartIds(sheetId)
|
|
31793
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
31842
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31794
31843
|
let chartsColors = new Set();
|
|
31795
31844
|
for (let chart of charts) {
|
|
31796
31845
|
if (chart === undefined) {
|
|
@@ -32146,37 +32195,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
32146
32195
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
32147
32196
|
cmd.type === "EVALUATE_CELLS" ||
|
|
32148
32197
|
cmd.type === "UPDATE_CELL") {
|
|
32149
|
-
for (const
|
|
32150
|
-
|
|
32151
|
-
this.charts[sheetId][chartId] = undefined;
|
|
32152
|
-
}
|
|
32198
|
+
for (const chartId in this.charts) {
|
|
32199
|
+
this.charts[chartId] = undefined;
|
|
32153
32200
|
}
|
|
32154
32201
|
}
|
|
32155
32202
|
switch (cmd.type) {
|
|
32156
32203
|
case "UPDATE_CHART":
|
|
32157
32204
|
case "CREATE_CHART":
|
|
32158
32205
|
case "DELETE_FIGURE":
|
|
32159
|
-
|
|
32160
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
32161
|
-
}
|
|
32206
|
+
this.charts[cmd.id] = undefined;
|
|
32162
32207
|
break;
|
|
32163
32208
|
case "DELETE_SHEET":
|
|
32164
|
-
|
|
32209
|
+
for (let chartId in this.charts) {
|
|
32210
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
32211
|
+
this.charts[chartId] = undefined;
|
|
32212
|
+
}
|
|
32213
|
+
}
|
|
32165
32214
|
break;
|
|
32166
32215
|
}
|
|
32167
32216
|
}
|
|
32168
|
-
getChartRuntime(
|
|
32169
|
-
|
|
32170
|
-
|
|
32171
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
32217
|
+
getChartRuntime(figureId) {
|
|
32218
|
+
if (!this.charts[figureId]) {
|
|
32219
|
+
const chart = this.getters.getChart(figureId);
|
|
32172
32220
|
if (!chart) {
|
|
32173
32221
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
32174
32222
|
}
|
|
32175
|
-
|
|
32176
|
-
this.charts[sheetId] = {};
|
|
32177
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
32223
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
32178
32224
|
}
|
|
32179
|
-
return this.charts[
|
|
32225
|
+
return this.charts[figureId];
|
|
32180
32226
|
}
|
|
32181
32227
|
/**
|
|
32182
32228
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -37820,7 +37866,7 @@ class ClipboardFigureChart {
|
|
|
37820
37866
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37821
37867
|
this.dispatch = dispatch;
|
|
37822
37868
|
this.sheetId = sheetId;
|
|
37823
|
-
const chart = getters.getChart(
|
|
37869
|
+
const chart = getters.getChart(copiedFigureId);
|
|
37824
37870
|
if (!chart) {
|
|
37825
37871
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
37826
37872
|
}
|
|
@@ -37841,7 +37887,7 @@ class ClipboardFigureImage {
|
|
|
37841
37887
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37842
37888
|
this.dispatch = dispatch;
|
|
37843
37889
|
this.sheetId = sheetId;
|
|
37844
|
-
const image = getters.getImage(
|
|
37890
|
+
const image = getters.getImage(copiedFigureId);
|
|
37845
37891
|
this.copiedImage = deepCopy(image);
|
|
37846
37892
|
}
|
|
37847
37893
|
paste(sheetId, figureId, position, size) {
|
|
@@ -43821,6 +43867,6 @@ function addFunction(functionName, functionDescription) {
|
|
|
43821
43867
|
export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
|
|
43822
43868
|
|
|
43823
43869
|
|
|
43824
|
-
__info__.version = '16.1.
|
|
43825
|
-
__info__.date = '2023-
|
|
43826
|
-
__info__.hash = '
|
|
43870
|
+
__info__.version = '16.1.3';
|
|
43871
|
+
__info__.date = '2023-03-06T07:18:06.669Z';
|
|
43872
|
+
__info__.hash = '7e26a7c';
|