mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +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.__undo_stack ??= []).push([path, action, args, next])
|
||||||
this.__redo_stack = undefined
|
this.__redo_stack = undefined
|
||||||
return this },
|
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(){
|
clearUndo: function(){
|
||||||
this.__undo_stack = undefined
|
this.__undo_stack = undefined
|
||||||
this.__redo_stack = undefined
|
this.__redo_stack = undefined
|
||||||
@ -1262,14 +1269,19 @@ var Outline = {
|
|||||||
if(from == null
|
if(from == null
|
||||||
|| from.length == 0){
|
|| from.length == 0){
|
||||||
return [from, to] }
|
return [from, to] }
|
||||||
var [path, action, args, next] = from.pop()
|
var actions = from.pop()
|
||||||
var l = from.length
|
actions = typeof(actions[1]) == 'string' ?
|
||||||
path != null
|
[actions]
|
||||||
&& this.focus(path)
|
: actions
|
||||||
this[action](...args)
|
while(actions.length > 0){
|
||||||
next != null ?
|
var [path, action, args, next] = actions.pop()
|
||||||
this.focus(next)
|
var l = from.length
|
||||||
: this.focus()
|
path != null
|
||||||
|
&& this.focus(path)
|
||||||
|
this[action](...args)
|
||||||
|
next != null ?
|
||||||
|
this.focus(next)
|
||||||
|
: this.focus() }
|
||||||
if(l < from.length){
|
if(l < from.length){
|
||||||
to ??= []
|
to ??= []
|
||||||
to.push(
|
to.push(
|
||||||
@ -1551,7 +1563,9 @@ var Outline = {
|
|||||||
cur.after(block)
|
cur.after(block)
|
||||||
: (place == 'before' || place == 'after') ?
|
: (place == 'before' || place == 'after') ?
|
||||||
cur[place](block)
|
cur[place](block)
|
||||||
: undefined }
|
: undefined
|
||||||
|
|
||||||
|
this.setUndo(this.path(cur), 'remove', [this.path(block)]) }
|
||||||
return block },
|
return block },
|
||||||
// XXX see inside...
|
// XXX see inside...
|
||||||
load: function(data){
|
load: function(data){
|
||||||
@ -1789,15 +1803,20 @@ var Outline = {
|
|||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
var a = edited.selectionStart
|
var a = edited.selectionStart
|
||||||
var b = edited.selectionEnd
|
var b = edited.selectionEnd
|
||||||
var prev = edited.value.slice(0, a)
|
// position 0: focus empty node above...
|
||||||
var next = edited.value.slice(b)
|
if(a == 0){
|
||||||
edited.value = prev
|
this.Block('prev')
|
||||||
this.Block({text: next}, 'next')
|
this.edit('prev')
|
||||||
// focus next if not at position 0, otherwise keep focus...
|
// focus new node...
|
||||||
if(a != 0){
|
} else {
|
||||||
|
var prev = edited.value.slice(0, a)
|
||||||
|
var next = edited.value.slice(b)
|
||||||
|
edited.value = prev
|
||||||
|
this.Block({text: next}, 'next')
|
||||||
edited = this.edit('next')
|
edited = this.edit('next')
|
||||||
edited.selectionStart = 0
|
edited.selectionStart = 0
|
||||||
edited.selectionEnd = 0 }
|
edited.selectionEnd = 0
|
||||||
|
this.mergeUndo(2) }
|
||||||
return }
|
return }
|
||||||
// view -> edit...
|
// view -> edit...
|
||||||
evt.preventDefault()
|
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...
|
- 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._
|
_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...
|
- BUG: mobile browsers behave quite chaotically ignoring parts of the styling...
|
||||||
- FF:
|
- FF:
|
||||||
- zooming on edited field
|
- zooming on edited field
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user