diff --git a/static/mdnotes.css b/static/mdnotes.css index 6dca185..c037ec0 100644 --- a/static/mdnotes.css +++ b/static/mdnotes.css @@ -31,6 +31,11 @@ div#mdnotes { min-height: 90%; } +div#mdnotes span.tokenfictif { + font-weight: 1; + color: #1353b3; +} + div#mdnotes:focus { outline: none; } diff --git a/static/modules/mdnotes.js b/static/modules/mdnotes.js index 2aa621e..df30733 100644 --- a/static/modules/mdnotes.js +++ b/static/modules/mdnotes.js @@ -45,7 +45,7 @@ function onedit(e) { let newline = formatLine(line.innerText); line.parentNode.replaceChild(newline, line); - formatTable(newline, 5.5); + formatTable(newline, dpwidth()); setStartPositionInLine(newline, position); } @@ -104,11 +104,28 @@ function oncopy(e) { alert(e.clipboardData.getData('text/plain')); } +var _dpwidth = null; +function dpwidth(div) { + if (_dpwidth != null) { + return _dpwidth; + } + let dp = document.createElement('span'); + dp.classList.add('tokenfictif'); + div.append(dp); + dp.innerText = ':'; + _dpwidth = dp.getBoundingClientRect().width; + div.removeChild(dp); + return _dpwidth; +} + function init(pagename = null) { /*if (pagename != null) { window.history.replaceState(null, '', '/page/' + pagename); }*/ let mdnotesdiv = document.getElementById('mdnotes'); + + dpwidth(mdnotesdiv); + mdnotesdiv.addEventListener('input', onedit); mdnotesdiv.addEventListener('keyup', onkeyup); mdnotesdiv.addEventListener('keypress', onkeypress); @@ -116,10 +133,9 @@ function init(pagename = null) { mdnotesdiv.addEventListener('paste', onpaste); mdnotesdiv.addEventListener('copy', oncopy); mdnotesdiv.addEventListener('blur', () => {redrawTables(mdnotesdiv);}); - mdnotesdiv.addEventListener('focus', () => {redrawTables(mdnotesdiv, 5.5);}); + mdnotesdiv.addEventListener('focus', () => {redrawTables(mdnotesdiv, dpwidth());}); let saveButton = document.getElementById('saveButton'); saveButton.addEventListener('click', onsave); - loadButton.addEventListener('click', onload); taButton.addEventListener('click', ontextarea); onload(); diff --git a/templates/page.html b/templates/page.html index 03779e4..1feb15a 100644 --- a/templates/page.html +++ b/templates/page.html @@ -12,7 +12,7 @@ -
+