diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index bbefb8e..0461092 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -173,6 +173,7 @@ var getMarkdownOffset = function(markdown, text, i){ // (not implemented) backtracking... // ...needs thought... // Q: can we cheat with this? =) +// XXX BUG: clicking right of last line places the caret before the last char... var getMarkdownOffset = function(markdown, text, i){ i = i ?? text.length var map = [] @@ -255,12 +256,12 @@ var blocks = { return text // markdown... // style: headings... - .replace(/^(?${ e.innerText.split(/\n/)[0] }` + }) + var lst = document.createElement('ul') + lst.innerHTML = headings.join('\n') + for(var toc of tocs){ + toc.append(lst) } }, + + __setup__: function(editor){ + return this.update(editor) }, + __editedcode__: function(evt, editor, elem){ + return this.update(editor, elem) }, + + __parse__: function(text, editor, elem){ + return text + .replace(/^\s*TOC\s*$/, + this.style(editor, elem, 'toc', '')) }, +} + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // XXX Hackish... @@ -1144,6 +1186,7 @@ var Outline = { // NOTE: this needs to be before styling to prevent it from // treating '[_] ... [_]' as italic... tasks, + //toc, styling, // XXX //attributes, @@ -2088,7 +2131,8 @@ var Outline = { var a = edited.selectionStart var b = edited.selectionEnd // position 0: focus empty node above... - if(a == 0){ + if(a == 0 + && edited.value.trim() != ''){ this.Block('prev') this.edit('prev') // focus new node... @@ -2480,6 +2524,7 @@ var Outline = { setTimeout(function(){ that.focus() }, 0) } /*/ + // XXX this for some reason takes lots of time at this point... this.focus() } //*/ diff --git a/experiments/outline-editor/index.html b/experiments/outline-editor/index.html index 557faed..0b30027 100755 --- a/experiments/outline-editor/index.html +++ b/experiments/outline-editor/index.html @@ -48,12 +48,15 @@ - - ## Bugs: focused:: true + - BUG: deleting an element in edit mode breaks code (err) + - click the next line and press `backspace` + - - BUG: navigation in edit mode broken... - - // can't go past this down... - - BUG: caret positioning broken - - Example: + - *TODO*:: - text text text