aboutsummaryrefslogtreecommitdiff
path: root/public/edit.html
blob: 204b537d1b7a4b7d3d79d1a196c257b25fb70d4b (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!doctype html>
<html lang="fr">
<head>
  <meta charset="utf-8">
  <meta name="viewport"
        content="width=device-width,minimum-scale=1,initial-scale=1">
  <title>hmarkdown example</title>

  <script src="js/script.js"></script>
  <script src="js/qcm.js"></script>
  <script src="js/hmd.min.js"></script>
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <link rel="stylesheet" type="text/css" href="css/rainbow.css">

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" crossorigin="anonymous">
<style>
html {
  height: 100vh;
  width: 100vv;
  overflow-y: hidden;
}
body {
  display: grid;
  grid-template-columns: 50% 50%;
  grid-template-row: 100vv;
  grid-template-areas: "edit preview";
  height: 100vh;
  width:  100vv;
  margin: 0;
  padding: 0;
  overflow-y: hidden;
  overflow-x: hidden;
}
#edit {
  grid-area: edit;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
}
#edit-zone{
  overflow-x: hidden;
}
#preview {
  grid-area: preview;
  overflow-y: scroll;
  overflow-x: hidden;
}
</style>
</head>
<body>
  <div id="edit"><div contenteditable="true" id="edit-zone">Yeah x2</div></div>
  <div id="preview" contenteditable="false">Yeah ! </div>

  <!-- This is the bundle generated by rollup.js -->
  <script>
let edit = document.getElementById('edit-zone');
let preview = document.getElementById('preview');
let modification = false;
let interval = setInterval( () => {
  if( modification ) {
    hmd(edit.innerText, (err, file) => {
      let finalString = String(file);
      if( finalString )  {
        preview.innerHTML = String(file);
        modification = false;
      }
    });
  }
}, 500);

edit.addEventListener('input', () => {
  modification = true;
  /*
  edit.style.width = '';
  edit.style.height = '';
  if(edit.scrollWidth >  edit.clientWidth)  edit.style.width = edit.scrollWidth + 'px';
  if(exit.scrollHeight > edit.clientHeight) edit.style.height = edit.scrollHeight + 'px';
  */
}, false);

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