mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
fixed collapsing nodes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2fd8fbdbeb
commit
a7d9d9e40f
@ -26,7 +26,6 @@ var atLine = function(elem, index){
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
var Node = {
|
||||
dom: undefined,
|
||||
document: undefined,
|
||||
@ -251,14 +250,14 @@ var Outline = {
|
||||
// .toggleCollapse(<state>)
|
||||
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()
|
||||
|
||||
@ -49,10 +49,12 @@ var setup = function(){
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<!-- XXX these all should focus the node back so as not to hide the keyboard on mobine -->
|
||||
<button onclick="editor.deindent()"><</button>
|
||||
<button onclick="editor.indent()">></button>
|
||||
<button onclick="editor.Block('before').focus()">O</button>
|
||||
<button onclick="editor.Block('after').focus()">o</button>
|
||||
<button onclick="editor.Block('before').focus()" style="text-decoration:underline">+</button>
|
||||
<button onclick="editor.Block('after').focus()" style="text-decoration:overline">+</button>
|
||||
<button onclick="editor.toggleCollapse()">+/-</button>
|
||||
<button onclick="editor.remove()">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user