import { getStartPositionInLine, setStartPositionInLine } from './position.js'; import { formatLine, load } from './md.js'; function onedit(e) { let ret = getStartPositionInLine(); let line = ret[0]; let position = ret[1]; if (line.innerText == '\n') { line.className = 'mdnotes_line'; return; } let newline = formatLine(line.innerText); line.parentNode.replaceChild(newline, line); setStartPositionInLine(newline, position); } function init() { let mdnotesdiv = document.getElementById('mdnotes'); mdnotesdiv.addEventListener('input', onedit); load(document.getElementById('ta'), mdnotesdiv); } export { onedit }; init();