Skip to content

Commit 709e4ba

Browse files
Dion WhiteheadDion Whitehead
authored andcommitted
Fix URLS
1 parent 2db1b3a commit 709e4ba

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

editor/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@metapages/hash-query": "^0.9.8",
2929
"@metapages/metaframe-chakra-theme": "^0.0.4",
3030
"@metapages/metapage": "^1.8.18",
31-
"@metapages/metapage-react": "^0.2.5",
31+
"@metapages/metapage-react": "^0.2.6",
3232
"@phosphor-icons/react": "^2.1.7",
3333
"@react-typed-hooks/use-key-press": "^1.0.5",
3434
"debounce": "^2.2.0",

editor/src/components/sections/PanelCode.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ import React, { useCallback, useRef } from "react";
22

33
import { useMetaframeUrl } from "/@/hooks/useMetaframeUrl";
44
import { useOptions } from "/@/hooks/useOptions";
5-
import stringify from "safe-stable-stringify";
65
import 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";
913
import { MetaframeInputMap } from "@metapages/metapage";
1014
import { 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

1822
export 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

Comments
 (0)