diff --git a/README.md b/README.md index 2c31e49c1..940ae4340 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ hf.setCellContents({ sheet: sheetId, row: 0, col: 0 }, [['Monthly Payment', '=PM console.log(`${hf.getCellValue({ sheet: sheetId, row: 0, col: 0 })}: ${hf.getCellValue({ sheet: sheetId, row: 0, col: 1 })}`); ``` -[Run this code in CodeSandbox](https://codesandbox.io/p/sandbox/github/handsontable/hyperformula-demos/tree/3.0.x/mortgage-calculator) +[Run this code in StackBlitz](https://stackblitz.com/github/handsontable/hyperformula-demos/tree/3.0.x/mortgage-calculator) ## Contributing diff --git a/docs/examples/i18n/example1.js b/docs/examples/i18n/example1.js index 6f97e6e1a..16967ff0e 100644 --- a/docs/examples/i18n/example1.js +++ b/docs/examples/i18n/example1.js @@ -65,7 +65,9 @@ const config = { licenseKey: 'gpl-v3', }; -HyperFormula.registerLanguage('enUS', enUS); +if (!HyperFormula.getRegisteredLanguagesCodes().includes('enUS')) { + HyperFormula.registerLanguage('enUS', enUS); +} // Create an empty HyperFormula instance. const hf = HyperFormula.buildEmpty(config); diff --git a/docs/examples/i18n/example1.ts b/docs/examples/i18n/example1.ts index 4b48b0c7c..a59236f60 100644 --- a/docs/examples/i18n/example1.ts +++ b/docs/examples/i18n/example1.ts @@ -67,7 +67,9 @@ const config = { licenseKey: 'gpl-v3', }; -HyperFormula.registerLanguage('enUS', enUS); +if (!HyperFormula.getRegisteredLanguagesCodes().includes('enUS')) { + HyperFormula.registerLanguage('enUS', enUS); +} // Create an empty HyperFormula instance. const hf = HyperFormula.buildEmpty(config); diff --git a/docs/examples/localizing-functions/example1.js b/docs/examples/localizing-functions/example1.js index 0b9af1d2b..d7388ac47 100644 --- a/docs/examples/localizing-functions/example1.js +++ b/docs/examples/localizing-functions/example1.js @@ -28,7 +28,9 @@ const tableData = [ ]; // register language -HyperFormula.registerLanguage('frFR', frFR); +if (!HyperFormula.getRegisteredLanguagesCodes().includes('frFR')) { + HyperFormula.registerLanguage('frFR', frFR); +} // Create an empty HyperFormula instance. const hf = HyperFormula.buildEmpty({ diff --git a/docs/examples/localizing-functions/example1.ts b/docs/examples/localizing-functions/example1.ts index 2a827bed4..daa70fe05 100644 --- a/docs/examples/localizing-functions/example1.ts +++ b/docs/examples/localizing-functions/example1.ts @@ -30,7 +30,9 @@ const tableData = [ ]; // register language -HyperFormula.registerLanguage('frFR', frFR); +if (!HyperFormula.getRegisteredLanguagesCodes().includes('frFR')) { + HyperFormula.registerLanguage('frFR', frFR); +} // Create an empty HyperFormula instance. const hf = HyperFormula.buildEmpty({ diff --git a/docs/index.md b/docs/index.md index c73b5aa0a..f74c47da2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -102,7 +102,7 @@ hf.setCellContents({ sheet: sheetId, row: 0, col: 0 }, [['Monthly Payment', '=PM console.log(`${hf.getCellValue({ sheet: sheetId, row: 0, col: 0 })}: ${hf.getCellValue({ sheet: sheetId, row: 0, col: 1 })}`); ``` -[Run this code in CodeSandbox](https://codesandbox.io/p/sandbox/github/handsontable/hyperformula-demos/tree/3.0.x/mortgage-calculator) +[Run this code in StackBlitz](https://stackblitz.com/github/handsontable/hyperformula-demos/tree/3.0.x/mortgage-calculator) ## Contributing diff --git a/src/DependencyGraph/DependencyGraph.ts b/src/DependencyGraph/DependencyGraph.ts index 0cdf1778a..d32f40e3b 100644 --- a/src/DependencyGraph/DependencyGraph.ts +++ b/src/DependencyGraph/DependencyGraph.ts @@ -224,12 +224,20 @@ export class DependencyGraph { const namedExpression = this.namedExpressions.namedExpressionOrPlaceholder(expressionName, sheetId) return this.fetchCellOrCreateEmpty(namedExpression.address) } - + public markAllNamedExpressionsAsDirty(): void { + const allExpressions = this.namedExpressions.getAllNamedExpressions(); + for (const { expression } of allExpressions) { + const vertex = this.shrinkPossibleArrayAndGetCell(expression.address); + if (vertex !== undefined) { + this.graph.markNodeAsDirty(vertex); + } + } + } public exchangeNode(addressFrom: SimpleCellAddress, addressTo: SimpleCellAddress) { - const vertexFrom = this.fetchCellOrCreateEmpty(addressFrom).vertex - const vertexTo = this.fetchCellOrCreateEmpty(addressTo).vertex - this.addressMapping.removeCell(addressFrom) - this.exchangeGraphNode(vertexFrom, vertexTo) + const vertexFrom = this.fetchCellOrCreateEmpty(addressFrom).vertex; + const vertexTo = this.fetchCellOrCreateEmpty(addressTo).vertex; + this.addressMapping.removeCell(addressFrom); + this.exchangeGraphNode(vertexFrom, vertexTo); } public fetchCellOrCreateEmpty(address: SimpleCellAddress): { vertex: CellVertex, id: Maybe } { diff --git a/src/HyperFormula.ts b/src/HyperFormula.ts index 664ee1480..0393855e9 100644 --- a/src/HyperFormula.ts +++ b/src/HyperFormula.ts @@ -4503,6 +4503,7 @@ export class HyperFormula implements TypedEmitter { const changes = this._crudOperations.getAndClearContentChanges() const verticesToRecomputeFrom = this.dependencyGraph.verticesToRecompute() this.dependencyGraph.clearDirtyVertices() + this.dependencyGraph.markAllNamedExpressionsAsDirty() if (verticesToRecomputeFrom.length > 0) { changes.addAll(this.evaluator.partialRun(verticesToRecomputeFrom))