You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
689 B
28 lines
689 B
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(); |