From a7d9d9e40fe160adb663dc7da8d13942853e6b38 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 4 Oct 2023 03:00:57 +0300 Subject: [PATCH] fixed collapsing nodes... Signed-off-by: Alex A. Naanou --- experiments/outline-editor/editor.js | 10 ++++------ experiments/outline-editor/index.html | 6 ++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/experiments/outline-editor/editor.js b/experiments/outline-editor/editor.js index ce310de..1151c8e 100755 --- a/experiments/outline-editor/editor.js +++ b/experiments/outline-editor/editor.js @@ -26,7 +26,6 @@ var atLine = function(elem, index){ //--------------------------------------------------------------------- - var Node = { dom: undefined, document: undefined, @@ -251,14 +250,14 @@ var Outline = { // .toggleCollapse() if(['next', true, false].includes(node)){ state = node - node = null } - node ??= this.get() + node = 'focused' } + node = this.get(node) if(!node // only nodes with children can be collapsed... || !node.querySelector('[tabindex]')){ return } state = state == 'next' ? - !node.getAttribute('collapsed') + node.getAttribute('collapsed') != '' : state if(state){ node.setAttribute('collapsed', '') @@ -267,13 +266,12 @@ var Outline = { for(var elem of [...node.querySelectorAll('textarea')]){ elem.updateSize() } } return node }, - remove: function(node='focused', offset){ var elem = this.get(...arguments) var next if(elem.classList.contains('focused')){ // XXX need to be able to get the next elem on same level... - this.toggleCollapse(elem) + this.toggleCollapse(elem, true) next = this.get(elem, 'next') } elem?.remove() next?.focus() diff --git a/experiments/outline-editor/index.html b/experiments/outline-editor/index.html index 108e607..25aefe4 100755 --- a/experiments/outline-editor/index.html +++ b/experiments/outline-editor/index.html @@ -49,10 +49,12 @@ var setup = function(){
+ - - + + +