From 331b90175694d3267cd28bd436dff99d4b41582f Mon Sep 17 00:00:00 2001 From: Rustem Mussabekov Date: Tue, 24 Sep 2024 12:49:24 +0300 Subject: [PATCH] Better base64 encode, utf8 support --- src/co/common/webview/browser.js | 11 +++++-- .../background/highlights/highlight.js | 30 +++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/co/common/webview/browser.js b/src/co/common/webview/browser.js index 4e312f6e..2e972998 100644 --- a/src/co/common/webview/browser.js +++ b/src/co/common/webview/browser.js @@ -1,5 +1,5 @@ import s from './browser.module.styl' -import React, { useEffect } from 'react' +import React, { useEffect, useMemo } from 'react' import { PREVIEW_URL } from '~data/constants/app' export default function WebViewBrowser({ src, forwardedRef, className='', onError, ...etc }) { @@ -12,6 +12,13 @@ export default function WebViewBrowser({ src, forwardedRef, className='', onErro return ()=>window.removeEventListener('message', onMessage) }, [onError]) + const base64 = useMemo(()=> + btoa( + String.fromCharCode(...new TextEncoder('utf-8').encode(src)) + ), + [src] + ) + return (