|
19 | 19 | </div>
|
20 | 20 | <div class="wds-editor__content" id="content">
|
21 | 21 | <div id="editor" class="wds-editor__editor"></div>
|
22 |
| - <div id="playground" class="wds-editor__playground"></div> |
| 22 | + <div id="playground" class="wds-editor__playground hidden"></div> |
23 | 23 | </div>
|
24 | 24 | <div class="wds-editor__console" id="console"></div>
|
25 | 25 | </div>
|
|
59 | 59 | method: "POST",
|
60 | 60 | });
|
61 | 61 |
|
62 |
| - output.innerText = await encode(await req.json()); |
| 62 | + output.innerText = 'Done.' |
63 | 63 | updatePreview();
|
64 | 64 | };
|
65 | 65 |
|
66 |
| - const addPreview = async (title, html) => { |
67 |
| - const frame = document.createElement("iframe"); |
68 |
| - const heading = document.createElement("h2"); |
69 |
| - heading.innerText = title; |
70 |
| - heading.className = "wds-editor__snippet"; |
71 |
| - playground.appendChild(heading); |
72 |
| - playground.appendChild(frame); |
73 |
| - |
74 |
| - const fbody = frame.contentDocument.body; |
75 |
| - fbody.innerHTML = |
76 |
| - `<link rel="stylesheet" href="/assets/${presetName}.css" />` + html; |
77 |
| - }; |
78 |
| - |
79 | 66 | const updatePreview = async () => {
|
80 | 67 | const snippets = (await decode(editor.getValue())).snippets;
|
81 | 68 |
|
|
87 | 74 | playground.innerHTML = "";
|
88 | 75 | togglePlayground(false);
|
89 | 76 |
|
90 |
| - Object.entries(snippets).forEach(([key, value]) => |
91 |
| - addPreview(key, value) |
92 |
| - ); |
| 77 | + const frame = document.createElement("iframe"); |
| 78 | + const heading = document.createElement("h2"); |
| 79 | + playground.appendChild(frame); |
| 80 | + |
| 81 | + const fbody = frame.contentDocument.body; |
| 82 | + fbody.innerHTML = |
| 83 | + `<link rel="stylesheet" href="/assets/${presetName}.css" />` + |
| 84 | + Object.entries(snippets).map(([key, value]) => `<div style="font-weight: bold">${key}</div>${value}`).join(''); |
93 | 85 | };
|
94 | 86 |
|
95 | 87 | const actions = {
|
|
0 commit comments