Topic on Talk:VisualEditor

Is there a way to preserve textarea undo history when injecting/inserting characters into the edit textarea?

10
Jasonkhanlar (talkcontribs)

I was just glancing at https://stackoverflow.com/questions/44471699/how-to-make-undo-work-in-an-html-textarea-after-setting-the-value and https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#browser_compatibility shows that execCommand is supported by all major web browsers. I noticed on Wikipedia both in the edit area at top (Special Characters), as well as the additional ones on the bottom (dropdown menu for Insert, Wiki markup, Symbols, etc.), that undo states are lost when clicking on any of the characters to insert. Is there a way that future versions can fix this to preserve the undo history?


Note: I see that execCommand is "Deprecated: This feature is no longer recommended." but otherwise still I would like to see a way to insert characters that preserves undo history. Also see https://stackoverflow.com/a/70831583

Whatamidoing (WMF) (talkcontribs)

Do you know whether this is specific to Firefox?

Jasonkhanlar (talkcontribs)

It is not specific to Mozilla Firefox. The issue affects Chrome/Chromium and Opera

Whatamidoing (WMF) (talkcontribs)

So that's most editors. @ESanders (WMF), do you have any thoughts about how this could be done?

ESanders (WMF) (talkcontribs)

What does this have to do with VE?

Whatamidoing (WMF) (talkcontribs)

I assumed that "textarea" was "the area where the text is" (e.g., ContentEditable), but I don't know.

ESanders (WMF) (talkcontribs)

I think @Jasonkhanlar is referring to <textarea> in the 2010 wikitext editor. That has known issues with the undo stack (T33780), and my go-to answer is to use the 2017 wikitext editor, which has it's own undo stack implementation.

Jasonkhanlar (talkcontribs)

I see. That is correct. It seems that https://en.wikipedia.org/ is using the 2010 wikitext editor, I tried to find the 2017 wikitext editor, and according to 2017 wikitext editor it is part of VisualEditor, which perhaps solves the undo state issue that I mentioned. Unfortunately, since neither Wikipedia seems to use it, nor does my webhost allow me to add "AllowEncodedSlashes NoDecode" to my website's VirtualHost section, and I get "Error contacting the Parsoid/RESTBase server (HTTP 404)" when enabling the VisualEditor extension for my site, I cannot check to see the 2017 wikitext editor in action. I read: https://mediawiki.org/wiki/Extension:VisualEditor#Allowing_VisualEditor_on_page_titles_containing_slashes Also whichever editor is used on Mediawiki.org, also undo does not work here either, when clicking the buttons to add special characters.

ESanders (WMF) (talkcontribs)

Your webhost may allow adding an .htaccess file?

Jasonkhanlar (talkcontribs)

Q: "Your webhost may allow adding an .htaccess file?"

A: https://httpd.apache.org/docs/2.4/mod/core.html#allowencodedslashes shows 2 contexts: server config or virtual host. There is no .htaccess context for the AllowEncodedSlashes Directive. Therefore, I am unable to enable encoded slashes from within a .htaccess file in my webhost environment.

Reply to "Is there a way to preserve textarea undo history when injecting/inserting characters into the edit textarea?"