@@ -2,18 +2,22 @@ import React, { useCallback, useRef } from "react";
22
33import { useMetaframeUrl } from "/@/hooks/useMetaframeUrl" ;
44import { useOptions } from "/@/hooks/useOptions" ;
5- import stringify from "safe-stable-stringify" ;
65import debounce from "debounce" ;
76
8- import { useHashParamBase64 } from "@metapages/hash-query/react-hooks" ;
7+ import {
8+ blobToBase64String ,
9+ setHashParamValueInUrl ,
10+ setHashParamValueJsonInUrl ,
11+ useHashParamBase64 ,
12+ } from "@metapages/hash-query/react-hooks" ;
913import { MetaframeInputMap } from "@metapages/metapage" ;
1014import { MetaframeStandaloneComponent } from "@metapages/metapage-react" ;
1115
12- export const encodeOptions = ( options : any ) : string => {
13- const text : string = stringify ( options ) || "" ;
14- const b64 = btoa ( encodeURIComponent ( text ) ) ;
15- return b64 ;
16- } ;
16+ // export const encodeOptions = (options: any): string => {
17+ // const text: string = stringify(options) || "";
18+ // const b64 = btoa(encodeURIComponent(text));
19+ // return b64;
20+ // };
1721
1822export const PanelCode : React . FC = ( ) => {
1923 const [ code , setCode ] = useHashParamBase64 ( "md" ) ;
@@ -31,14 +35,18 @@ const LocalEditor: React.FC<{
3135 const inputs = useRef < { text : string } > ( { text : codeInternal . current } ) ;
3236
3337 const urlWithOptions = ( ) => {
34- const options = encodeOptions ( {
38+ const options = blobToBase64String ( {
3539 autosend : true ,
3640 hidemenuififrame : true ,
3741 mode : "markdown" ,
3842 theme : themeOptions ?. theme || "vs-light" ,
3943 hideLineNumbers : true ,
4044 } ) ;
41- return `https://editor.mtfm.io/#?hm=disabled&options=${ options } ` ;
45+ let url = new URL ( "https://editor.mtfm.io" ) ;
46+ url = setHashParamValueJsonInUrl ( url , "options" , options ) ;
47+ url = setHashParamValueInUrl ( url , "hm" , "disabled" ) ;
48+
49+ return url . href ;
4250 } ;
4351
4452 const onCodeOutputsUpdate = useCallback (
0 commit comments