@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
|
@@ -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
|
}
|
|
@@ -20521,7 +20518,7 @@ class ChartPanel extends Component {
|
|
|
20521
20518
|
});
|
|
20522
20519
|
}
|
|
20523
20520
|
onTypeChange(type) {
|
|
20524
|
-
const context = this.env.model.getters.getContextCreationChart(this.
|
|
20521
|
+
const context = this.env.model.getters.getContextCreationChart(this.figureId);
|
|
20525
20522
|
if (!context) {
|
|
20526
20523
|
throw new Error("Chart not defined.");
|
|
20527
20524
|
}
|
|
@@ -20533,7 +20530,7 @@ class ChartPanel extends Component {
|
|
|
20533
20530
|
});
|
|
20534
20531
|
}
|
|
20535
20532
|
get chartPanel() {
|
|
20536
|
-
const type = this.env.model.getters.getChartType(this.
|
|
20533
|
+
const type = this.env.model.getters.getChartType(this.figureId);
|
|
20537
20534
|
if (!type) {
|
|
20538
20535
|
throw new Error("Chart not defined.");
|
|
20539
20536
|
}
|
|
@@ -20543,8 +20540,8 @@ class ChartPanel extends Component {
|
|
|
20543
20540
|
}
|
|
20544
20541
|
return chartPanel;
|
|
20545
20542
|
}
|
|
20546
|
-
getChartDefinition() {
|
|
20547
|
-
return this.env.model.getters.getChartDefinition(
|
|
20543
|
+
getChartDefinition(figureId = this.figureId) {
|
|
20544
|
+
return this.env.model.getters.getChartDefinition(figureId);
|
|
20548
20545
|
}
|
|
20549
20546
|
get chartTypes() {
|
|
20550
20547
|
return getChartTypes();
|
|
@@ -27103,13 +27100,7 @@ function load(data, verboseImport) {
|
|
|
27103
27100
|
data = migrate(data);
|
|
27104
27101
|
}
|
|
27105
27102
|
}
|
|
27106
|
-
|
|
27107
|
-
// sensible default values
|
|
27108
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
27109
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
27110
|
-
if (data.sheets.length === 0) {
|
|
27111
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
27112
|
-
}
|
|
27103
|
+
data = repairData(data);
|
|
27113
27104
|
return data;
|
|
27114
27105
|
}
|
|
27115
27106
|
function migrate(data) {
|
|
@@ -27347,6 +27338,48 @@ const MIGRATIONS = [
|
|
|
27347
27338
|
},
|
|
27348
27339
|
},
|
|
27349
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
|
+
}
|
|
27350
27383
|
/**
|
|
27351
27384
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
27352
27385
|
* a bug.
|
|
@@ -27485,6 +27518,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
27485
27518
|
formats: {},
|
|
27486
27519
|
borders: {},
|
|
27487
27520
|
revisionId: DEFAULT_REVISION_ID,
|
|
27521
|
+
uniqueFigureIds: true,
|
|
27488
27522
|
};
|
|
27489
27523
|
return data;
|
|
27490
27524
|
}
|
|
@@ -28482,10 +28516,8 @@ class ChartPlugin extends CorePlugin {
|
|
|
28482
28516
|
this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
|
|
28483
28517
|
}
|
|
28484
28518
|
adaptRanges(applyChange) {
|
|
28485
|
-
for (const
|
|
28486
|
-
|
|
28487
|
-
this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
|
|
28488
|
-
}
|
|
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));
|
|
28489
28521
|
}
|
|
28490
28522
|
}
|
|
28491
28523
|
// ---------------------------------------------------------------------------
|
|
@@ -28496,20 +28528,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
28496
28528
|
case "CREATE_CHART":
|
|
28497
28529
|
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
|
|
28498
28530
|
case "UPDATE_CHART":
|
|
28499
|
-
return this.
|
|
28531
|
+
return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
|
|
28500
28532
|
default:
|
|
28501
28533
|
return 0 /* CommandResult.Success */;
|
|
28502
28534
|
}
|
|
28503
28535
|
}
|
|
28504
28536
|
handle(cmd) {
|
|
28505
|
-
var _a
|
|
28537
|
+
var _a;
|
|
28506
28538
|
switch (cmd.type) {
|
|
28507
28539
|
case "CREATE_CHART":
|
|
28508
28540
|
this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
|
|
28509
|
-
this.addChart(cmd.id, cmd.
|
|
28541
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28510
28542
|
break;
|
|
28511
28543
|
case "UPDATE_CHART": {
|
|
28512
|
-
this.addChart(cmd.id, cmd.
|
|
28544
|
+
this.addChart(cmd.id, cmd.definition);
|
|
28513
28545
|
break;
|
|
28514
28546
|
}
|
|
28515
28547
|
case "DUPLICATE_SHEET": {
|
|
@@ -28518,7 +28550,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
28518
28550
|
if (fig.tag === "chart") {
|
|
28519
28551
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
28520
28552
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
28521
|
-
const chart = (
|
|
28553
|
+
const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
|
|
28522
28554
|
if (chart) {
|
|
28523
28555
|
this.dispatch("CREATE_CHART", {
|
|
28524
28556
|
id: duplicatedFigureId,
|
|
@@ -28533,41 +28565,44 @@ class ChartPlugin extends CorePlugin {
|
|
|
28533
28565
|
break;
|
|
28534
28566
|
}
|
|
28535
28567
|
case "DELETE_FIGURE":
|
|
28536
|
-
this.history.update("charts", cmd.
|
|
28568
|
+
this.history.update("charts", cmd.id, undefined);
|
|
28537
28569
|
break;
|
|
28538
28570
|
case "DELETE_SHEET":
|
|
28539
|
-
this.
|
|
28571
|
+
for (let id of this.getChartIds(cmd.sheetId)) {
|
|
28572
|
+
this.history.update("charts", id, undefined);
|
|
28573
|
+
}
|
|
28540
28574
|
break;
|
|
28541
28575
|
}
|
|
28542
28576
|
}
|
|
28543
28577
|
// ---------------------------------------------------------------------------
|
|
28544
28578
|
// Getters
|
|
28545
28579
|
// ---------------------------------------------------------------------------
|
|
28546
|
-
getContextCreationChart(
|
|
28547
|
-
var _a, _b;
|
|
28548
|
-
return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
|
|
28549
|
-
}
|
|
28550
|
-
getChart(sheetId, figureId) {
|
|
28580
|
+
getContextCreationChart(figureId) {
|
|
28551
28581
|
var _a;
|
|
28552
|
-
return (_a = this.charts[
|
|
28582
|
+
return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
|
|
28553
28583
|
}
|
|
28554
|
-
|
|
28555
|
-
|
|
28556
|
-
|
|
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;
|
|
28557
28590
|
if (!type) {
|
|
28558
28591
|
throw new Error("Chart not defined.");
|
|
28559
28592
|
}
|
|
28560
28593
|
return type;
|
|
28561
28594
|
}
|
|
28562
|
-
isChartDefined(
|
|
28563
|
-
return figureId in
|
|
28595
|
+
isChartDefined(figureId) {
|
|
28596
|
+
return figureId in this.charts && this.charts !== undefined;
|
|
28564
28597
|
}
|
|
28565
28598
|
getChartIds(sheetId) {
|
|
28566
|
-
return Object.
|
|
28599
|
+
return Object.entries(this.charts)
|
|
28600
|
+
.filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
|
|
28601
|
+
.map(([id]) => id);
|
|
28567
28602
|
}
|
|
28568
|
-
getChartDefinition(
|
|
28569
|
-
var _a
|
|
28570
|
-
const definition = (
|
|
28603
|
+
getChartDefinition(figureId) {
|
|
28604
|
+
var _a;
|
|
28605
|
+
const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
|
|
28571
28606
|
if (!definition) {
|
|
28572
28607
|
throw new Error(`There is no chart with the given figureId: ${figureId}`);
|
|
28573
28608
|
}
|
|
@@ -28579,28 +28614,35 @@ class ChartPlugin extends CorePlugin {
|
|
|
28579
28614
|
import(data) {
|
|
28580
28615
|
for (let sheet of data.sheets) {
|
|
28581
28616
|
if (sheet.figures) {
|
|
28582
|
-
const charts = {};
|
|
28583
28617
|
for (let figure of sheet.figures) {
|
|
28584
28618
|
// TODO:
|
|
28585
28619
|
// figure data should be external IMO => chart should be in sheet.chart
|
|
28586
28620
|
// instead of in figure.data
|
|
28587
28621
|
if (figure.tag === "chart") {
|
|
28588
|
-
charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28622
|
+
this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
|
|
28589
28623
|
}
|
|
28590
28624
|
}
|
|
28591
|
-
this.charts[sheet.id] = charts;
|
|
28592
28625
|
}
|
|
28593
28626
|
}
|
|
28594
28627
|
}
|
|
28595
28628
|
export(data) {
|
|
28629
|
+
var _a;
|
|
28596
28630
|
if (data.sheets) {
|
|
28597
28631
|
for (let sheet of data.sheets) {
|
|
28598
28632
|
// TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
|
|
28599
28633
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28600
|
-
const figures =
|
|
28601
|
-
for (let
|
|
28634
|
+
const figures = [];
|
|
28635
|
+
for (let sheetFigure of sheetFigures) {
|
|
28636
|
+
const figure = sheetFigure;
|
|
28602
28637
|
if (figure && figure.tag === "chart") {
|
|
28603
|
-
|
|
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);
|
|
28604
28646
|
}
|
|
28605
28647
|
}
|
|
28606
28648
|
sheet.figures = figures;
|
|
@@ -28608,13 +28650,13 @@ class ChartPlugin extends CorePlugin {
|
|
|
28608
28650
|
}
|
|
28609
28651
|
}
|
|
28610
28652
|
exportForExcel(data) {
|
|
28611
|
-
var _a
|
|
28653
|
+
var _a;
|
|
28612
28654
|
for (let sheet of data.sheets) {
|
|
28613
28655
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
28614
28656
|
const figures = [];
|
|
28615
28657
|
for (let figure of sheetFigures) {
|
|
28616
28658
|
if (figure && figure.tag === "chart") {
|
|
28617
|
-
const figureData = (
|
|
28659
|
+
const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
|
|
28618
28660
|
if (figureData) {
|
|
28619
28661
|
figures.push({
|
|
28620
28662
|
...figure,
|
|
@@ -28653,15 +28695,21 @@ class ChartPlugin extends CorePlugin {
|
|
|
28653
28695
|
* Add a chart in the local state. If a chart already exists, this chart is
|
|
28654
28696
|
* replaced
|
|
28655
28697
|
*/
|
|
28656
|
-
addChart(id,
|
|
28657
|
-
|
|
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
|
+
}
|
|
28658
28703
|
}
|
|
28659
28704
|
checkChartDuplicate(cmd) {
|
|
28660
|
-
|
|
28661
|
-
|
|
28662
|
-
|
|
28663
|
-
|
|
28664
|
-
|
|
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 */;
|
|
28665
28713
|
}
|
|
28666
28714
|
}
|
|
28667
28715
|
ChartPlugin.getters = [
|
|
@@ -29042,7 +29090,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29042
29090
|
allowDispatch(cmd) {
|
|
29043
29091
|
switch (cmd.type) {
|
|
29044
29092
|
case "CREATE_FIGURE":
|
|
29045
|
-
return this.checkFigureDuplicate(cmd.
|
|
29093
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
29046
29094
|
case "UPDATE_FIGURE":
|
|
29047
29095
|
case "DELETE_FIGURE":
|
|
29048
29096
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -29108,9 +29156,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
29108
29156
|
}
|
|
29109
29157
|
return 0 /* CommandResult.Success */;
|
|
29110
29158
|
}
|
|
29111
|
-
checkFigureDuplicate(
|
|
29112
|
-
|
|
29113
|
-
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])) {
|
|
29114
29161
|
return 82 /* CommandResult.DuplicatedFigureId */;
|
|
29115
29162
|
}
|
|
29116
29163
|
return 0 /* CommandResult.Success */;
|
|
@@ -29125,6 +29172,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
29125
29172
|
var _a;
|
|
29126
29173
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
29127
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
|
+
}
|
|
29128
29178
|
// ---------------------------------------------------------------------------
|
|
29129
29179
|
// Import/Export
|
|
29130
29180
|
// ---------------------------------------------------------------------------
|
|
@@ -29149,7 +29199,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
29149
29199
|
this.export(data);
|
|
29150
29200
|
}
|
|
29151
29201
|
}
|
|
29152
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
29202
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
29153
29203
|
|
|
29154
29204
|
class FilterTable {
|
|
29155
29205
|
constructor(zone) {
|
|
@@ -29876,7 +29926,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29876
29926
|
switch (cmd.type) {
|
|
29877
29927
|
case "CREATE_IMAGE":
|
|
29878
29928
|
if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
|
|
29879
|
-
return 28 /* CommandResult.
|
|
29929
|
+
return 28 /* CommandResult.InvalidFigureId */;
|
|
29880
29930
|
}
|
|
29881
29931
|
return 0 /* CommandResult.Success */;
|
|
29882
29932
|
default:
|
|
@@ -29896,7 +29946,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29896
29946
|
if (fig.tag === "image") {
|
|
29897
29947
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
29898
29948
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
29899
|
-
const image = this.getImage(
|
|
29949
|
+
const image = this.getImage(fig.id);
|
|
29900
29950
|
if (image) {
|
|
29901
29951
|
const size = { width: fig.width, height: fig.height };
|
|
29902
29952
|
this.dispatch("CREATE_IMAGE", {
|
|
@@ -29934,13 +29984,19 @@ class ImagePlugin extends CorePlugin {
|
|
|
29934
29984
|
// ---------------------------------------------------------------------------
|
|
29935
29985
|
// Getters
|
|
29936
29986
|
// ---------------------------------------------------------------------------
|
|
29937
|
-
getImage(
|
|
29938
|
-
|
|
29939
|
-
|
|
29940
|
-
|
|
29941
|
-
|
|
29987
|
+
getImage(figureId) {
|
|
29988
|
+
for (const sheet of Object.values(this.images)) {
|
|
29989
|
+
if (sheet && sheet[figureId]) {
|
|
29990
|
+
return sheet[figureId];
|
|
29991
|
+
}
|
|
29942
29992
|
}
|
|
29943
|
-
|
|
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;
|
|
29944
30000
|
}
|
|
29945
30001
|
// ---------------------------------------------------------------------------
|
|
29946
30002
|
// Private
|
|
@@ -29982,7 +30038,7 @@ class ImagePlugin extends CorePlugin {
|
|
|
29982
30038
|
return images;
|
|
29983
30039
|
}
|
|
29984
30040
|
}
|
|
29985
|
-
ImagePlugin.getters = ["getImage"];
|
|
30041
|
+
ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
|
|
29986
30042
|
|
|
29987
30043
|
class MergePlugin extends CorePlugin {
|
|
29988
30044
|
constructor() {
|
|
@@ -31783,9 +31839,7 @@ class CustomColorsPlugin extends UIPlugin {
|
|
|
31783
31839
|
return formatColors.filter(isDefined$1);
|
|
31784
31840
|
}
|
|
31785
31841
|
getChartColors(sheetId) {
|
|
31786
|
-
const charts = this.getters
|
|
31787
|
-
.getChartIds(sheetId)
|
|
31788
|
-
.map((cid) => this.getters.getChart(sheetId, cid));
|
|
31842
|
+
const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
|
|
31789
31843
|
let chartsColors = new Set();
|
|
31790
31844
|
for (let chart of charts) {
|
|
31791
31845
|
if (chart === undefined) {
|
|
@@ -32141,37 +32195,34 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
32141
32195
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
32142
32196
|
cmd.type === "EVALUATE_CELLS" ||
|
|
32143
32197
|
cmd.type === "UPDATE_CELL") {
|
|
32144
|
-
for (const
|
|
32145
|
-
|
|
32146
|
-
this.charts[sheetId][chartId] = undefined;
|
|
32147
|
-
}
|
|
32198
|
+
for (const chartId in this.charts) {
|
|
32199
|
+
this.charts[chartId] = undefined;
|
|
32148
32200
|
}
|
|
32149
32201
|
}
|
|
32150
32202
|
switch (cmd.type) {
|
|
32151
32203
|
case "UPDATE_CHART":
|
|
32152
32204
|
case "CREATE_CHART":
|
|
32153
32205
|
case "DELETE_FIGURE":
|
|
32154
|
-
|
|
32155
|
-
this.charts[cmd.sheetId][cmd.id] = undefined;
|
|
32156
|
-
}
|
|
32206
|
+
this.charts[cmd.id] = undefined;
|
|
32157
32207
|
break;
|
|
32158
32208
|
case "DELETE_SHEET":
|
|
32159
|
-
|
|
32209
|
+
for (let chartId in this.charts) {
|
|
32210
|
+
if (!this.getters.isChartDefined(chartId)) {
|
|
32211
|
+
this.charts[chartId] = undefined;
|
|
32212
|
+
}
|
|
32213
|
+
}
|
|
32160
32214
|
break;
|
|
32161
32215
|
}
|
|
32162
32216
|
}
|
|
32163
|
-
getChartRuntime(
|
|
32164
|
-
|
|
32165
|
-
|
|
32166
|
-
const chart = this.getters.getChart(sheetId, figureId);
|
|
32217
|
+
getChartRuntime(figureId) {
|
|
32218
|
+
if (!this.charts[figureId]) {
|
|
32219
|
+
const chart = this.getters.getChart(figureId);
|
|
32167
32220
|
if (!chart) {
|
|
32168
32221
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
32169
32222
|
}
|
|
32170
|
-
|
|
32171
|
-
this.charts[sheetId] = {};
|
|
32172
|
-
this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
|
|
32223
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
32173
32224
|
}
|
|
32174
|
-
return this.charts[
|
|
32225
|
+
return this.charts[figureId];
|
|
32175
32226
|
}
|
|
32176
32227
|
/**
|
|
32177
32228
|
* Get the background color of a chart based on the color of the first cell of the main range
|
|
@@ -37815,7 +37866,7 @@ class ClipboardFigureChart {
|
|
|
37815
37866
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37816
37867
|
this.dispatch = dispatch;
|
|
37817
37868
|
this.sheetId = sheetId;
|
|
37818
|
-
const chart = getters.getChart(
|
|
37869
|
+
const chart = getters.getChart(copiedFigureId);
|
|
37819
37870
|
if (!chart) {
|
|
37820
37871
|
throw new Error(`No chart for the given id: ${copiedFigureId}`);
|
|
37821
37872
|
}
|
|
@@ -37836,7 +37887,7 @@ class ClipboardFigureImage {
|
|
|
37836
37887
|
constructor(dispatch, getters, sheetId, copiedFigureId) {
|
|
37837
37888
|
this.dispatch = dispatch;
|
|
37838
37889
|
this.sheetId = sheetId;
|
|
37839
|
-
const image = getters.getImage(
|
|
37890
|
+
const image = getters.getImage(copiedFigureId);
|
|
37840
37891
|
this.copiedImage = deepCopy(image);
|
|
37841
37892
|
}
|
|
37842
37893
|
paste(sheetId, figureId, position, size) {
|
|
@@ -43816,6 +43867,6 @@ function addFunction(functionName, functionDescription) {
|
|
|
43816
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 };
|
|
43817
43868
|
|
|
43818
43869
|
|
|
43819
|
-
__info__.version = '16.1.
|
|
43820
|
-
__info__.date = '2023-03-
|
|
43821
|
-
__info__.hash = '
|
|
43870
|
+
__info__.version = '16.1.3';
|
|
43871
|
+
__info__.date = '2023-03-06T07:18:06.669Z';
|
|
43872
|
+
__info__.hash = '7e26a7c';
|