diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index d4fc058..d9822f1 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -1075,7 +1075,7 @@ var JSONOutline = { .join('') return ( `
\ -\ +\ ${ parsed.text }\
${ children }
\
`) }, @@ -1821,13 +1821,15 @@ var Outline = { this.setUndo(this.path(cur), 'remove', [this.path(block)]) } return block }, - // XXX see inside... + /*/ XXX load: function(data){ var that = this data = typeof(data) == 'string' ? this.parse(data) : data instanceof Array ? data + : data == null ? + this.json() : [data] // generate dom... var level = function(lst){ @@ -1851,9 +1853,31 @@ var Outline = { var f = that._updateTextareaSize for(var e of [...that.outline.querySelectorAll('textarea')]){ f(e) } }, 0) - // restore focus... - this.focus() return this }, + /*/ // XXX JSON version... + load: function(data){ + var that = this + data = typeof(data) == 'string' ? + this.parse(data) + : data instanceof Array ? + data + : data == null ? + this.json() + : [data] + + this.outline.innerHTML = this.html(data) + + // update sizes of all the textareas (transparent)... + // NOTE: this is needed to make initial clicking into multi-line + // blocks place the cursor into the clicked location. + // ...this is done by expanding the textarea to the element + // size and enabling it to intercept clicks correctly... + setTimeout(function(){ + var f = that._updateTextareaSize + for(var e of [...that.outline.querySelectorAll('textarea')]){ + f(e) } }, 0) + return this }, + //*/ sync: function(){ this.code = this.text() diff --git a/experiments/outline-editor/index.html b/experiments/outline-editor/index.html index 1b9f55c..f84b72b 100755 --- a/experiments/outline-editor/index.html +++ b/experiments/outline-editor/index.html @@ -48,6 +48,10 @@ var setup = function(){ - - ## Bugs: focused:: true + - BUG: navigation in edit mode broken... + - + - // can't go past this down... + - - BUG: caret positioning broken - Example: - text text text @@ -110,6 +114,7 @@ var setup = function(){ - side margins are a bit too large (account for toolbat to the right) - - ## ToDo: + - ASAP: edit/view sizes slightly different... - Q: should we use `HTMLTextAreaElement.autoUpdateSize(..)` or handle it globally in setup??? - _...I'm leaning towards the later..._ - Q: can we place a cursor in a table correctly???