Skip to content

Commit

Permalink
fix...
Browse files Browse the repository at this point in the history
Signed-off-by: Alex A. Naanou <[email protected]>
  • Loading branch information
flynx committed Oct 25, 2023
1 parent 9e8557e commit 44a542e
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions experiments/outline-editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ var Outline = {
var cur = this.get(node)
if(!cur){
return }
var prev = this.path(cur)
var siblings = this.get(node, 'siblings')
// deindent...
if(indent == 'out'){
Expand All @@ -1056,17 +1057,19 @@ var Outline = {
this.setUndo(
this.path(cur),
'indent',
['in'])
['in'],
prev)
this.__change__() }
// indent...
} else {
var parent = siblings[siblings.indexOf(cur) - 1]
if(parent){
parent.lastChild.append(cur)
this.setUndo(
this.path(cur),
'indent',
['out'])
this.setUndo(
this.path(cur),
'indent',
['out'],
prev)
this.__change__()} }
return cur },
shift: function(node='focused', direction){
Expand All @@ -1084,13 +1087,11 @@ var Outline = {
if(direction == 'up'
&& i > 0){
siblings[i-1].before(node)
focused
&& this.focus()
} else if(direction == 'down'
&& i < siblings.length-1){
siblings[i+1].after(node)
focused
&& this.focus() }
siblings[i+1].after(node) }
focused
&& this.focus()
this.setUndo(
this.path(node),
'shift',
Expand Down Expand Up @@ -1211,8 +1212,8 @@ var Outline = {
// are reassigning the stacks manually.
__undo_stack: undefined,
__redo_stack: undefined,
setUndo: function(path, action, args){
;(this.__undo_stack ??= []).push([path, action, args])
setUndo: function(path, action, args, next){
;(this.__undo_stack ??= []).push([path, action, args, next])
this.__redo_stack = undefined
return this },
clearUndo: function(){
Expand All @@ -1223,11 +1224,14 @@ var Outline = {
if(from == null
|| from.length == 0){
return [from, to] }
var [path, action, args] = from.pop()
var [path, action, args, next] = from.pop()
var l = from.length
path != null
&& this.focus(path)
this[action](...args)
next != null ?
this.focus(next)
: this.focus()
if(l < from.length){
to ??= []
to.push(
Expand Down

0 comments on commit 44a542e

Please sign in to comment.