mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 18:10:09 +00:00
fixed undo bug...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
cb62d1e1c2
commit
426e8999ba
@ -1254,6 +1254,13 @@ var Outline = {
|
||||
;(this.__undo_stack ??= []).push([path, action, args, next])
|
||||
this.__redo_stack = undefined
|
||||
return this },
|
||||
mergeUndo: function(n, stack){
|
||||
stack ??= this.__undo_stack
|
||||
if(stack == null || stack.length == 0){
|
||||
return this }
|
||||
stack.push(
|
||||
stack.splice(-n, n))
|
||||
return this },
|
||||
clearUndo: function(){
|
||||
this.__undo_stack = undefined
|
||||
this.__redo_stack = undefined
|
||||
@ -1262,14 +1269,19 @@ var Outline = {
|
||||
if(from == null
|
||||
|| from.length == 0){
|
||||
return [from, to] }
|
||||
var [path, action, args, next] = from.pop()
|
||||
var actions = from.pop()
|
||||
actions = typeof(actions[1]) == 'string' ?
|
||||
[actions]
|
||||
: actions
|
||||
while(actions.length > 0){
|
||||
var [path, action, args, next] = actions.pop()
|
||||
var l = from.length
|
||||
path != null
|
||||
&& this.focus(path)
|
||||
this[action](...args)
|
||||
next != null ?
|
||||
this.focus(next)
|
||||
: this.focus()
|
||||
: this.focus() }
|
||||
if(l < from.length){
|
||||
to ??= []
|
||||
to.push(
|
||||
@ -1551,7 +1563,9 @@ var Outline = {
|
||||
cur.after(block)
|
||||
: (place == 'before' || place == 'after') ?
|
||||
cur[place](block)
|
||||
: undefined }
|
||||
: undefined
|
||||
|
||||
this.setUndo(this.path(cur), 'remove', [this.path(block)]) }
|
||||
return block },
|
||||
// XXX see inside...
|
||||
load: function(data){
|
||||
@ -1789,15 +1803,20 @@ var Outline = {
|
||||
evt.preventDefault()
|
||||
var a = edited.selectionStart
|
||||
var b = edited.selectionEnd
|
||||
// position 0: focus empty node above...
|
||||
if(a == 0){
|
||||
this.Block('prev')
|
||||
this.edit('prev')
|
||||
// focus new node...
|
||||
} else {
|
||||
var prev = edited.value.slice(0, a)
|
||||
var next = edited.value.slice(b)
|
||||
edited.value = prev
|
||||
this.Block({text: next}, 'next')
|
||||
// focus next if not at position 0, otherwise keep focus...
|
||||
if(a != 0){
|
||||
edited = this.edit('next')
|
||||
edited.selectionStart = 0
|
||||
edited.selectionEnd = 0 }
|
||||
edited.selectionEnd = 0
|
||||
this.mergeUndo(2) }
|
||||
return }
|
||||
// view -> edit...
|
||||
evt.preventDefault()
|
||||
|
||||
@ -51,13 +51,6 @@ var setup = function(){
|
||||
- BUG: focus at times seems to be biased a bit to the right -- the caret is placed to the right from where expected...
|
||||
-
|
||||
_this seems to only affect text with leading whitespace only, like this._
|
||||
- BUG: undo: does not handle element splitting correctly...
|
||||
- place cursor somewhere here, hit `Enter`, and then undo.
|
||||
- _this will correctly restore the old node but will not remove the new one_
|
||||
- need to:
|
||||
- add undo to `.Block(..)`
|
||||
- group `new` and `cange` into one undo action...
|
||||
- _undo chaining? ...i.e. support nested arrays?_
|
||||
- BUG: mobile browsers behave quite chaotically ignoring parts of the styling...
|
||||
- FF:
|
||||
- zooming on edited field
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user