diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index 0739ddb..863d079 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -1210,6 +1210,7 @@ var JSONOutline = { // XXX add plugin hooks... // XXX add option to customize indent size... text: function(node, indent, level){ + var that = this // .text(, ) if(typeof(node) == 'string'){ ;[node, indent=' ', level=''] = [undefined, ...arguments] } @@ -1225,8 +1226,7 @@ var JSONOutline = { // attrs... + (Object.keys(elem) .reduce(function(res, attr){ - return (attr == 'text' - || attr == 'children') ? + return that.__system_attrs__.includes(attr) ? res : res + (elem[attr] ? @@ -1252,7 +1252,7 @@ var JSONOutline = { var attrs = [] for(var [attr, value] of Object.entries({...data, ...parsed})){ - if(attr == 'children' || attr == 'text'){ + if(this.__system_attrs__.includes(attr)){ continue } var i var type = this.__block_attrs__[attr] @@ -1675,9 +1675,13 @@ var Outline = { //this._syncTextSize(code, html) } for(var [attr, value] of Object.entries({...data, ...parsed})){ - if(attr == 'children' || attr == 'text'){ + if(this.__system_attrs__.includes(attr)){ continue } + // quoted value... + if(value && /^\s*([`'"])([^\1]*)\1\s*$/.test(value)){ + value = value.replace(/^\s*([`'"])([^\1]*)\1\s*$/, '$2') } + var type = this.__block_attrs__[attr] if(type == 'cls'){ value ? @@ -1693,6 +1697,7 @@ var Outline = { : node.removeAttribute(attr) // dataset... } else { + // remove attr... if(value == null || value == 'null' || value == 'undefined'){ diff --git a/experiments/outline-editor/index.html b/experiments/outline-editor/index.html index 1495a22..ce9ddb0 100755 --- a/experiments/outline-editor/index.html +++ b/experiments/outline-editor/index.html @@ -148,8 +148,9 @@ var setup = function(){ attr::value - DONE `.__parse_code__(..)`: add data attributes to code if missing... - DONE do we need `.__code_attrs__` / `.__view_attrs__`??? -- YES - - handle attr delete correctly -- i.e. if shown attr removed from code -> delete attr... - - BUG? can't set `''` as attr value -- parser?? + - DONE delete attr from code -- by setting it to `"null"` or `"undefined"`... + - delete attr from code -- by removing it from attr list (when shown)... + - DONE BUG? can't set `''` as attr value -- parser?? - TOC: tweaking: add args like depth, ... -- as attributes... - TOC: should it be persistently generated as code and be serializable? - simple use strategies: