diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index 226baa3..2d51ce2 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -1120,13 +1120,15 @@ var JSONOutline = { attrs.splice(i, 1) : undefined } } - var children = data.children + var children = (data.children ?? []) .map(function(data){ return that.htmlBlock(data) }) .join('') + // NOTE: the '\n' at the start of the textarea body below helps + // preserve whitespace when parsing HTML... return ( `
\ -\ +\ ${ parsed.text }\
${ children }
\
`) }, diff --git a/experiments/outline-editor/index.html b/experiments/outline-editor/index.html index af5680d..ae69058 100755 --- a/experiments/outline-editor/index.html +++ b/experiments/outline-editor/index.html @@ -52,14 +52,25 @@ var setup = function(){ - blank line at end of block is initially not shown - this block contains two lines (empty below) + - `editor.Block(editor.data(editor.get())).querySelector('.view').innerHTML` -- '\n' present + - _...is this a resize issue???_ - this block also contains two lines (empty above) - this block contains three lines (empty above and below) - - blank line at start of block is shown but removed on edit + - DONE blank line at start of block is shown but removed on edit + collapsed:: true - this block also contains two lines (empty above) + - `editor.data(editor.get()).text` -- no `\n` at start... + - `editor.get().querySelector('.code').value` -- no `\n` at start... + - ``` + d = document.createElement('div') + d.innerHTML = editor.htmlBlock({text: '\nabc\n'}) // -> '\n' exists... + d.querySelector('.code').value // -> no '\n' at start... + ``` + ...seems that the `\n` is lost on html parse... - this block contains three lines (empty above and below)