From 469c9ddfdf252f8a9c35ec34be7c054e68fede7f Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Wed, 15 Jan 2025 16:59:28 +0100 Subject: [PATCH 1/2] Merge develop to master to deploy documentation and fix #1480 and #1481 (#1487) * Fix registerLanguage() issue in the code examples (#1484) Make code examples check for registered languages before registering new ones * Fix mortgage calculator demo error `Cannot load native addon because loading addons is disabled` (#1486) Migrate mortgage-calculator demo in readme from Codestandbox to Stackblitz --- README.md | 2 +- docs/examples/i18n/example1.js | 4 +++- docs/examples/i18n/example1.ts | 4 +++- docs/examples/localizing-functions/example1.js | 4 +++- docs/examples/localizing-functions/example1.ts | 4 +++- docs/index.md | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) 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 From 64191717da4c0200bbe6729713d40004184fccbe Mon Sep 17 00:00:00 2001 From: Esmail-Rahmani <60963312+Esmail-Rahmani@users.noreply.github.com> Date: Sat, 26 Apr 2025 10:28:30 +0430 Subject: [PATCH 2/2] fix(named-expressions): mark named expressions as dirty before recomputation --- src/DependencyGraph/DependencyGraph.ts | 18 +++++++++++++----- src/HyperFormula.ts | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) 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))