~dricottone/noticable

ref: ef0b3a690cfd0421bbed57a058445814a5fc348c noticable/index.html -rw-r--r-- 1.5 KiB
ef0b3a69Dominic Ricottone functional markdown rendering 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Test</title>
    <meta name="descrption" content="" />
    <style>
#container-editor {
  width: 500px;
  height: 300px;
  border: 1px solid #ccc;
}
#container-results {
  width: 500px;
  height: 300px;
}
    </style>
  </head>
  <body>
    <div id="container-editor"></div>
    <div id="container-results"></div>
    <script src="node_modules/jquery/dist/jquery.min.js"></script>
    <script src="node_modules/monaco-editor/min/vs/loader.js"></script>
    <script>
// initialize monaco editor
require.config({ paths: { vs: 'node_modules/monaco-editor/min/vs' } });
require(['vs/editor/editor.main'], function () {
  window.editor = monaco.editor.create(document.getElementById('container-editor'), {
    language: 'markdown',
    minimap: {
      enabled: false
    },
    value: ''
  });
});

// listen to preload
window.addEventListener("message", (event) => {
  if (event.source != window) return;
  if (event.data.type && (event.data.type == "request-post-markdown")) {
    console.log("[renderer] caught 'request-post-markdown'!");
    console.log("[renderer] sending 'post-markdown'...");
    window.postMessage({ type: "post-markdown", text: window.editor.getValue() }, "*");
  };
  if (event.data.type && (event.data.type == "request-insert-html")) {
    console.log("[renderer] caught 'request-insert-html'!");
    $('#container-results').html(event.data.text);
  };
}, false);

    </script>
  </body>
</html>