diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index fddb1bd..de9efc2 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -178,9 +178,9 @@ var Outline = { focus: function(node='focused', offset){}, edit: function(node='focused', offset){}, - // XXX should this handle children??? update: function(node='focused', data){ var node = this.get(node) + data ??= this.data(node, false) typeof(data.collapsed) == 'boolean' && (data.collapsed ? node.setAttribute('collapsed', '') @@ -193,9 +193,9 @@ var Outline = { var parsed = this.__code2html__(data.text) html.innerHTML = parsed.text // heading... - parsed.style ? - node.classList.add(...parsed.style) - : node.classList.remove(...this.__styles) + node.classList.remove(...this.__styles) + parsed.style + && node.classList.add(...parsed.style) } else { html.innerHTML = data.text } text.value = data.text @@ -312,36 +312,50 @@ var Outline = { return '' }) // markdown... // style: headings... - .replace(/^######\s*(.*)$/m, style('heading-6')) - .replace(/^#####\s*(.*)$/m, style('heading-5')) - .replace(/^####\s*(.*)$/m, style('heading-4')) - .replace(/^###\s*(.*)$/m, style('heading-3')) - .replace(/^##\s*(.*)$/m, style('heading-2')) - .replace(/^#\s*(.*)$/m, style('heading-1')) + .replace(/^(?ASAP$2') + .replace(/^(?ASAP$2') // elements... - .replace(/(\n|^)---*\h*(\n|$)/m, '$1
') + .replace(/(\n|^)(?') // ToDo... - .replace(/^TODO\s*/m, style('todo', '')) - .replace(/^DONE\s*/m, style('todo', '')) + .replace(/^(?')) + .replace(/^(?')) // checkboxes... - .replace(/\[_\]/gm, style('check', '')) - .replace(/\[[X]\]/gm, style('check', '')) + .replace(/(?')) + .replace(/(?')) // basic styling... - // XXX these are quite naive... - .replace(/\*(.*)\*/gm, '$1') - .replace(/~([^~]*)~/gm, '$1') - .replace(/_([^_]*)_/gm, '$1') + .replace(/(?$1') + .replace(/(?$1') + .replace(/(?$1') + // quoting... + .replace(/(?