diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f89392..12454d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @tokens-studio/token-configurator +## 0.0.9 + +### Patch Changes + +- Export ensureMonacoIsLoaded util for easier use of replaceSource util, which doesn't work very well if Monaco isn't loaded. + ## 0.0.8 ### Patch Changes diff --git a/package.json b/package.json index b973f3b..817d7b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tokens-studio/configurator", - "version": "0.0.8", + "version": "0.0.9", "description": "Online IDE for configuring Style-Dictionary", "license": "MIT", "author": "Tokens Studio (https://tokens.studio)", diff --git a/src/configurator-element.js b/src/configurator-element.js index 8865cd5..0cc4ca7 100644 --- a/src/configurator-element.js +++ b/src/configurator-element.js @@ -91,6 +91,7 @@ export class ConfiguratorElement extends LitElement { constructor() { super(); this.preventInit = false; + this.hasInitialized = false; } firstUpdated() { @@ -121,18 +122,21 @@ export class ConfiguratorElement extends LitElement { } async init() { - await setupEditorChangeHandlers(); - await sdState.loadSDFunctions(); - await sdState.runStyleDictionary(); - - await openAllFolders(); - const fileTreeEl = await getFileTreeEl(); - if (fileTreeEl.outputFiles.length > 0) { - await fileTreeEl.switchToFile(fileTreeEl.outputFiles[0]); + if (!this.hasInitialized) { + await setupEditorChangeHandlers(); + await sdState.loadSDFunctions(); + await sdState.runStyleDictionary(); + + await openAllFolders(); + const fileTreeEl = await getFileTreeEl(); + if (fileTreeEl.outputFiles.length > 0) { + await fileTreeEl.switchToFile(fileTreeEl.outputFiles[0]); + } + await switchToFile(findUsedConfigPath(), editorConfig); + + resizeMonacoLayout(); + this.hasInitialized = true; } - await switchToFile(findUsedConfigPath(), editorConfig); - - resizeMonacoLayout(); } } diff --git a/src/utils.js b/src/utils.js index 31e89ee..1a1cdd7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -8,5 +8,5 @@ export { replaceSource, openAllFolders, } from "./utils/file-tree.js"; -export { resizeMonacoLayout } from "./monaco/monaco.js"; +export { resizeMonacoLayout, ensureMonacoIsLoaded } from "./monaco/monaco.js"; export * from "./constants.js";