ElkArte Community

Elk Development => Bug Reports => Topic started by: emanuele on April 07, 2017, 06:10:42 pm

Title: Undo plugin
Post by: emanuele on April 07, 2017, 06:10:42 pm
Could someone please try this sequence:
1) type something (anything really)
2) hit ctrl+z
3) type something else
4) hit ctrl+z
What do you see?
What I would expect is that the text I typed in 3 is removed, but instead nothing happens. And if I click the "redo" icon then the text I removed with the ctrl+z of 2 appears again, removing the text I types in 3.
Title: Re: Undo plugin
Post by: Spuds on April 07, 2017, 06:40:39 pm
Behavior seems to depend on how quickly I hit crtl-z but yeah I can reproduce what you said above.

There may have been an editor fix to help with this, not sure.

When the "latest" 1.5.x editor was released, there was still a myriad of issues open, but instead of fixing them in the 1.5.x branch most were pushed to a new 2.X branch, which of course will force us to change just about every plugin and interaction with the editor.   I've been back porting some of the fixes to a 1.X elk branch so we can try that but have mixed feelings about the entire thing.

I'm kind of tired of dealing with the editors development, two many things are left broken in ..x releases, and then fixes do become available they are in a version that requires API changes everywhere breaking the core and addons and not fitting well in any release cycles.
Title: Re: Undo plugin
Post by: emanuele on April 07, 2017, 08:05:01 pm
Yeah, it's becoming pretty annoying... :-\
Title: Re: Undo plugin
Post by: Jorin on April 25, 2017, 05:19:43 am
Quote from: emanuele – Could someone please try this sequence:
1) type something (anything really)
2) hit ctrl+z
3) type something else
4) hit ctrl+z
What do you see?
What I would expect is that the text I typed in 3 is removed, but instead nothing happens. And if I click the "redo" icon then the text I removed with the ctrl+z of 2 appears again, removing the text I types in 3.

Exactly the same happening here with me.
Title: Re: Undo plugin
Post by: Spuds on April 25, 2017, 09:43:35 am
I marked them to be removed, now someone just needs to do so.
Title: Re: Undo plugin
Post by: emanuele on April 25, 2017, 05:10:35 pm
I'm trying to understand the plugin:
https://github.com/samclarke/SCEditor/blob/master/src/plugins/undo.js#L170
if I'm not entirely wrong, this means:
1) if less than 20 chars added since last stored step, exit,
2) if less than 50 chars added since last stored step and the last char is not a space, exit,
3) otherwise store the undo step

Funny thing, I'm not able to replicate the isse any more on my localhost.
I'll try to update the files here, maybe something was fixed somewhere in the meantime since the last update?
Title: Re: Undo plugin
Post by: emanuele on July 29, 2017, 04:02:11 pm
I uploaded here in a version of the plugin I modified. O:-)
https://github.com/elkarte/Elkarte/issues/2919#issuecomment-318855290
Let me know if it works any better.
Title: Re: Undo plugin
Post by: Spuds on July 30, 2017, 01:54:19 pm
We need to make a tweak to fix the editor focus messing up the page scroll to a named link on load.  I'll comment in the gist in a bit.
Title: Re: Undo plugin
Post by: emanuele on July 30, 2017, 05:03:47 pm
O_O
Page scroll?
Title: Re: Undo plugin
Post by: Spuds on July 30, 2017, 06:23:06 pm
On editor init the undo plugin does an editor focus event to get the initial cursor position in the editor. 

This is not normally a problem unless you have the full editor set in Quick Reply.   In that case the focus event will pull the screen down to the editor area  (as some browsers feel that is in focus)  overriding any #blabla in the url like #new.
Title: Re: Undo plugin
Post by: Spuds on July 31, 2017, 07:17:55 am
I made the updates to the file on the site since jumping to wrong area on the page was making me very sad  :'(

Now lets hope I did not mess up the changes you were trying  O:-)
Title: Re: Undo plugin
Post by: emanuele on July 31, 2017, 10:10:20 am
Now the funny part is I have no idea of the changes you made because everything is minified. xD
Title: Re: Undo plugin
Post by: Spuds on July 31, 2017, 03:56:27 pm
The changes I made are left in a comment in the gist of your updates ;)
Title: Re: Undo plugin
Post by: emanuele on July 31, 2017, 05:33:26 pm
Ohhh... I learned that github doesn't send notifications for comments on gists... or at least I didn't receive any. :-\
Title: Re: Undo plugin
Post by: Spuds on July 31, 2017, 08:19:06 pm
gist can be strange. 

Anyway the change is simple, it just avoids the editor focus event (needed to get cursor position) when the editor is empty.  When empty the cursor is at 0,0
Title: Re: Undo plugin
Post by: Frenzie on August 01, 2017, 06:52:17 am
Quote from: emanuele – Ohhh... I learned that github doesn't send notifications for comments on gists... or at least I didn't receive any. :-\
It also doesn't notify you of changes on the wiki. GH is pretty great for the main stuff but some of the side features can be a little rough. :P
Title: Re: Undo plugin
Post by: emanuele on August 12, 2017, 07:27:29 am
It seems to work fine in Chrome, I have some issues with my other browser, but I'd like to hear others if it is working fine with their browsers. Speak up! :D
Title: Re: Undo plugin
Post by: Frenzie on August 13, 2017, 10:36:12 am
If you're talking about the undo plugin, all you need to do is type fast enough and it'll break. Doesn't matter if it's Chrome(ium) or Firefox. :P But I think when I say "break" I guess I might mean it only does one undo action?
Title: Re: Undo plugin
Post by: emanuele on August 13, 2017, 04:48:05 pm
BTW I don't see the icons now... am I the only one?
/me feels I messed something while working on the other stuff.
Title: Re: Undo plugin
Post by: Spuds on August 13, 2017, 04:54:33 pm
That was probably me messing something up ...

I was trying to figure out the editor issue with Edge but local test bed does not work with Edge ... So I used the site to test  O:-)

I could not figure out why Edge does not work (highlight some text in source mode, then use the toolbar to make something bold for example, it does not wrap the highlighted text but inserts the bbc codes at the start of all the text).  Using the keyboard shortcuts works fine, so its some interaction with the click event and selectionEnd / selectionStart returning zero, but just for Edge. 

Oh its not just our version, its the 1.5 branch and Dev branches as well, so ..............

Anyway I'll see what I've done :P
Title: Re: Undo plugin
Post by: emanuele on August 13, 2017, 05:03:04 pm
hmm... what a pain. xD