require("./styles/main.scss");
import flowtype from 'flowtype';
import Remarkable from 'remarkable';
import hljs from 'highlight.js';

// Wait for DOM content to load

document.addEventListener("DOMContentLoaded", function(event) {

  console.log("DOM Content loaded");


  var markdownViewer = document.getElementById('markdownViewer');
  if (!markdownViewer) {
    return;
  }

  // Now just to set up markdownParser.set
  var markdownParser = new Remarkable({
    breaks: true,
    typographer: true,
    // This highlights languages
    highlight: function (str, lang) {
      if (lang && hljs.getLanguage(lang)) {
        try {
          return hljs.highlight(lang, str).value;
        } catch (err) {}
      }

      try {
        return hljs.highlightAuto(str).value;
      } catch (err) {}

      return ''; // use external default escaping
    },
  });

  flowtype(markdownViewer, {
    maxWidth: '800px',
    minWidth: '300px',
    lineRatio: 1.45,
    min: 14,
    max: 22
  });


  // Set some props from the data we just received from SN.
  // This is where we output the message onto html I think.
  window.addEventListener("message", function(event){
    
    console.log("message received");

    window.noteText = event.data.text || "";
    window.noteId = event.data.id;
    markdownViewer.innerHTML = markdownParser.render(window.noteText);
  }, false);

  // postMessage is how we communicate with Standard Notes
  if (window.parent != window) {
    window.parent.postMessage({status: 'ready'}, '*');
  };

});






@@ -264,16 +264,585 @@
 ded%22);%0A%0A
+  // postMessage is how we communicate with Standard Notes%0A  if (window.parent != window) %7B%0A    window.parent.postMessage(%7Bstatus: 'ready'%7D, '*');%0A    console.log('message posted')%0A  %7D;%0A%0A%0A  // Set some props from the data we just received from SN.%0A  // This is where we output the message onto html I think.%0A  window.addEventListener(%22message%22, function(event)%7B    %0A    console.log(%22message received%22);%0A%0A    window.noteText = event.data.text %7C%7C %22%22;%0A    window.noteId = event.data.id;%0A    markdownViewer.innerHTML = markdownParser.render(window.noteText);%0A  %7D, false);%0A%0A
 %0A  var m
@@ -1560,540 +1560,96 @@
 %0A%0A  
-// Set some props from the data we just received from SN.%0A  // This is where we output the message onto html I think.%0A  window.addEventListener(%22message%22, function(event)%7B%0A    %0A    console.log(%22message received%22);%0A%0A    window.noteText = event.data.text %7C%7C %22%22;%0A    window.noteId = event.data.id;%0A    markdownViewer.innerHTML = markdownParser.render(window.noteText);%0A  %7D, false);%0A%0A  // postMessage is how we communicate with Standard Notes%0A  if (window.parent != window) %7B%0A    window.parent.postMessage(%7Bstatus: 'ready'%7D, '*');%0A  %7D;%0A
+markdownViewer.innerHTML = markdownParser.render(window.noteText);%0A  console.log(window)
 %0A%7D);

Update index