From 94dd0dbae81970470a9990b23bb344805ed23f14 Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Wed, 15 Jan 2025 12:27:02 +0100 Subject: [PATCH 1/2] Fix registerLanguage() issue in the code examples (#1484) Make code examples check for registered languages before registering new ones --- 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 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/examples/i18n/example1.js b/docs/examples/i18n/example1.js index 6f97e6e1a8..16967ff0ee 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 4b48b0c7c1..a59236f60b 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 0b9af1d2bd..d7388ac47b 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 2a827bed4d..daa70fe052 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({ From f392eaec77f9fd051a2772f9475611b65fe30a0f Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Wed, 15 Jan 2025 16:10:30 +0100 Subject: [PATCH 2/2] 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/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2c31e49c17..940ae43403 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/index.md b/docs/index.md index c73b5aa0a7..f74c47da29 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