diff --git a/code-block-pro.php b/code-block-pro.php index 0b6b30f..a44423e 100644 --- a/code-block-pro.php +++ b/code-block-pro.php @@ -4,7 +4,7 @@ * Description: Code highlighting powered by the VS Code engine * Requires at least: 6.0 * Requires PHP: 7.0 - * Version: 1.11.1 + * Version: 1.11.2 * Author: Kevin Batdorf * License: GPL-2.0-or-later * License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/readme.txt b/readme.txt index 78574df..9c88d8f 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: kbat82 Tags: block, code, syntax, snippet, highlighter, JavaScript, php, vs code Tested up to: 6.1 -Stable tag: 1.11.1 +Stable tag: 1.11.2 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -238,6 +238,8 @@ Themes are rendered inside the editor as you type or make changes, so the code b == Changelog == += 1.11.2 - 2023-01-04 = +- Fix: Update shiki renderer wasm loader to use ArrayBuffer = 1.11.1 - 2023-01-04 = - Fix: Revert code parser as there is a wasm loading error diff --git a/src/editor/Edit.tsx b/src/editor/Edit.tsx index 52fc82f..2bc7c5a 100644 --- a/src/editor/Edit.tsx +++ b/src/editor/Edit.tsx @@ -161,7 +161,7 @@ export const Edit = ({ if ((loading && code) || error) { return (
{error?.message ?? ''}
diff --git a/src/front/front.js b/src/front/front.js index 5003a71..7763067 100644 --- a/src/front/front.js +++ b/src/front/front.js @@ -87,13 +87,15 @@ const handleFontLoading = () => { }); }; -const runAll = () => { +const init = () => { handleCopyButton(); handleHighlighter(); handleFontLoading(); }; // Functions are idempotent, so we can run them on load and DOMContentLoaded -runAll(); -window.addEventListener('DOMContentLoaded', runAll); -window.addEventListener('load', runAll); +init(); +// Useful for when the DOM is modified or loaded in late +window.codeBlockProInit = init; +window.addEventListener('DOMContentLoaded', init); +window.addEventListener('load', init); diff --git a/src/hooks/useTheme.ts b/src/hooks/useTheme.ts index 49094d4..6098789 100644 --- a/src/hooks/useTheme.ts +++ b/src/hooks/useTheme.ts @@ -7,7 +7,7 @@ import useSWRImmutable from 'swr/immutable'; type Params = { theme: Theme; lang: Lang; ready?: boolean }; const fetcher = ({ theme, lang, ready }: Params) => { - if (!ready) throw new Error(__('Loading...', 'code-block-pro')); + if (!ready) throw new Error(); const themeFiltered = applyFilters( 'blocks.codeBlockPro.theme', theme, @@ -39,5 +39,9 @@ export const useTheme = ({ theme, lang, ready = true }: Params) => { }); }, []); - return { highlighter, error, loading: !highlighter && !error }; + return { + highlighter, + error, + loading: (!highlighter && !error) || !wasmLoaded, + }; };