Skip to content

Commit 2db1b3a

Browse files
committed
use defined hashParams
1 parent 09e9710 commit 2db1b3a

File tree

5 files changed

+30
-60
lines changed

5 files changed

+30
-60
lines changed

editor/package-lock.json

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

editor/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
"@emotion/react": "^11.11.1",
2626
"@emotion/styled": "^11.11.0",
2727
"@fontsource-variable/jetbrains-mono": "^5.1.1",
28-
"@metapages/hash-query": "^0.8.4",
28+
"@metapages/hash-query": "^0.9.8",
2929
"@metapages/metaframe-chakra-theme": "^0.0.4",
30-
"@metapages/metapage": "^1.4.4",
31-
"@metapages/metapage-react": "^0.2.0",
30+
"@metapages/metapage": "^1.8.18",
31+
"@metapages/metapage-react": "^0.2.5",
3232
"@phosphor-icons/react": "^2.1.7",
3333
"@react-typed-hooks/use-key-press": "^1.0.5",
3434
"debounce": "^2.2.0",

editor/src/hooks/useMetaframeUrl.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ import {
99
useHashParamBase64,
1010
useHashParamJson,
1111
} from "@metapages/hash-query/react-hooks";
12-
import { MetaframeDefinitionV1 } from "@metapages/metapage";
12+
import { MetaframeDefinitionV2 } from "@metapages/metapage";
1313

1414
export const useMetaframeUrl = () => {
1515
const [url, setUrl] = useState<string>();
1616
const [code] = useHashParamBase64("md");
1717
const [config] = useHashParamJson<ConfigOptions>("c");
18-
const [metaframeDef] = useHashParamJson<MetaframeDefinitionV1>("definition");
18+
const [metaframeDef] = useHashParamJson<MetaframeDefinitionV2>("definition");
1919
const [modules] = useHashParamJson<string[]>("modules");
2020

2121
// update the url
2222
useEffect(() => {
23-
let href = window.location.href;
23+
let url = new URL(window.location.href);
2424
if (metaframeDef) {
25-
href = setHashParamValueJsonInUrl(href, "definition", metaframeDef);
25+
url = setHashParamValueJsonInUrl(url, "definition", metaframeDef);
2626
}
2727
if (modules) {
28-
href = setHashParamValueJsonInUrl(href, "modules", modules);
28+
url = setHashParamValueJsonInUrl(url, "modules", modules);
2929
}
3030
if (config) {
31-
href = setHashParamValueJsonInUrl(href, "c", config);
31+
url = setHashParamValueJsonInUrl(url, "c", config);
3232
}
3333

34-
const url = new URL(href);
34+
3535

3636
// I am not sure about this anymore
3737
url.pathname = "";

worker/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@
204204
setHashParamInWindow,
205205
getHashParamValueBase64DecodedFromWindow,
206206
stringFromBase64String
207-
} from "https://cdn.jsdelivr.net/npm/@metapages/hash-query@0.8.4";
208-
import {Metapage, Metaframe, isIframe} from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.4.4";
207+
} from "https://cdn.jsdelivr.net/npm/@metapages/hash-query@0.9.8";
208+
import {Metapage, Metaframe, isIframe} from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.8.18";
209209
import Mermaid from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm';
210210
import {MermaidPlugIn} from './markdown-plugins/mermaid/index.js';
211211
import SingleScreenPlugin from './markdown-plugins/single-screen/index.js';

worker/server.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,20 @@ import {
66
} from "https://deno.land/x/[email protected]/mod.ts";
77
import staticFiles from "https://deno.land/x/[email protected]/mod.ts";
88
import {
9-
MetaframeDefinitionV1,
9+
MetaframeDefinitionV2,
1010
MetaframeVersionCurrent,
11-
} from "https://esm.sh/@metapages/metapage@1.1.0";
11+
} from "https://esm.sh/@metapages/metapage@1.8.18";
1212

1313
const port: number = parseInt(Deno.env.get("PORT") || "3000");
1414

15-
const DEFAULT_METAFRAME_DEFINITION: MetaframeDefinitionV1 = {
15+
const DEFAULT_METAFRAME_DEFINITION: MetaframeDefinitionV2 = {
1616
version: MetaframeVersionCurrent,
1717
metadata: {
1818
name: "Markdown renderer",
19-
// operations: {
20-
// edit: {
21-
// type: "url",
22-
// url: "https://js.mtfm.io/#?edit=1",
23-
// params: [
24-
// {
25-
// from: "js",
26-
// to: "js",
27-
// },
28-
// {
29-
// from: "modules",
30-
// to: "modules",
31-
// },
32-
// {
33-
// from: "c",
34-
// to: "c",
35-
// },
36-
// ],
37-
// },
38-
// },
3919
},
4020
inputs: {},
4121
outputs: {},
22+
hashParams: ["edit", "md", "bgColor", "editorWidth", "minimalheader", "hm", "modules", "definition", "options"]
4223
};
4324

4425
const DEFAULT_METAFRAME_DEFINITION_STRING = JSON.stringify(

0 commit comments

Comments
 (0)