diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index cb841a6..3db1c02 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -186,107 +186,6 @@ var Outline = { : nodes : (edited ?? node) }, - /*/ - get: function(node='focused', offset){ - var that = this - - // shorthands... - if(node == 'next'){ - return this.get('focused', 1) } - if(node == 'prev' || node == 'previous'){ - return this.get('focused', -1) } - - var outline = this.outline - - var parent = function(node){ - return node?.parentElement?.parentElement } - var children = function(node){ - return [...node?.lastChild?.children] } - - // get parent node... - if(node instanceof HTMLElement){ - while(!node.classList.contains('block')){ - node = node.parentElement - if(node === this.outline){ - return undefined } } } - - // node lists... - var NO_NODES = {} - var nodes = - node == 'all' ? - [...outline.querySelectorAll('.block')] - : node == 'visible' ? - [...outline.querySelectorAll('.block')] - .filter(function(e){ - return e.offsetParent != null }) - : node == 'editable' ? - [...outline.querySelectorAll('.block>textarea')] - : node == 'selected' ? - [...outline.querySelectorAll('.block[selected]')] - : node == 'top' ? - [...outline.children] - .filter(function(elem){ - return elem.getAttribute('tabindex') != null }) - : ['siblings', 'children'].includes(node) ? - this.get('focused', node) - : node instanceof Array ? - node - : NO_NODES - if(nodes !== NO_NODES){ - return offset == null ? - nodes - : typeof(offset) == 'number' ? - nodes.at(offset) - : nodes - .map(function(elem){ - return that.get(elem, offset) }) } - - // single base node... - node = - typeof(node) == 'number' ? - this.at(node) - : node == 'focused' ? - (outline.querySelector(`.block:focus`) - || outline.querySelector(`textarea:focus`)?.parentElement - || outline.querySelector('.block.focused')) - : node == 'parent' ? - parent(this.get('focused')) - : node - var edited - if(node == 'edited'){ - edited = outline.querySelector(`textarea:focus`) - node = edited?.parentElement } - - if(!node || typeof(node) == 'string'){ - return undefined } - - // children... - if(offset == 'children'){ - return children(node) } - - // siblings... - if(offset == 'siblings'){ - return children(parent(node)) } - - // offset... - offset = - offset == 'next' ? - 1 - : offset == 'prev' ? - -1 - : offset - if(typeof(offset) == 'number'){ - nodes = this.get('visible') - var i = nodes.indexOf(node) + offset - i = i < 0 ? - nodes.length + i - : i % nodes.length - node = nodes[i] - edited = edited - && node.querySelector('.code') } - return edited - || node }, - //*/ at: function(index, nodes='visible'){ return this.get(nodes).at(index) }, focus: function(node='focused', offset){