Page MenuHomePhabricator

Prompt user before automatically converting pasted HTML to wikitext
Closed, ResolvedPublic40 Story Points

Description

As discussed in T153315, converting pasted HTML to wikitext is not always the desired result. This can be especially annoying if the formatted HTML contains wikitext, as it will be escaped with <nowiki> tags.

We should instead prompt the user when pasting formatted HTML, and force them to deliberately choose the "convert to wikitext" option, with the default being plain-text (and possibly a reminder about the CTRL+SHIFT+V shortcut?).

This behaviour is similar to the paste dialog shown in excel/calc when the source format can't be inferred (e.g. "CSV or TSV?")

Event Timeline

Esanders created this task.Mar 19 2018, 5:44 PM
Restricted Application added subscribers: jeblad, Aklapper. · View Herald TranscriptMar 19 2018, 5:44 PM
Dvorapa added a subscriber: Dvorapa.
Esanders set the point value for this task to 40.
DLynch claimed this task.Apr 9 2018, 4:06 PM
DLynch moved this task from Incoming to In progress on the VisualEditor (Current work) board.

Change 425462 had a related patch set uploaded (by DLynch; owner: DLynch):
[VisualEditor/VisualEditor@master] SurfaceFragment: tell insertDocument whether it's from a paste

https://gerrit.wikimedia.org/r/425462

Change 425464 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/VisualEditor@master] MWWikitextSurfaceFragment: ask the paster whether to convert to wikitext or use plain text

https://gerrit.wikimedia.org/r/425464

DLynch added a comment.EditedApr 11 2018, 4:28 AM

I'm sure people might want to give feedback on the wording of this.

I was wondering before if the dialog should contain either a visual example of rich vs plaintext, or a snippet of your actual pasted content in both modes? The latter probably has more problems, e.g. when your pasted text is very long or contains almost no formatting.

But maybe this is ok for a first pass.

Snippet of your actual content in both modes does also have the drawback that we'd have to wait for it to run the round trip to the server for the conversion, as well.

I did consider examples, but I wasn't sure I could write something which was sufficiently compact and would make sense to people who didn't already know what the non-example text meant.

Could literally annotate the current message, maybe? "Your inserted content contains rich content. Should we convert the rich content to '''wikitext''', or insert just the plain text?"

I would replace "rich text/content" with "formatting" or "text formatting", as I think the former is too technical.

Could literally annotate the current message, maybe? "Your inserted content contains rich content. Should we convert the rich content to '''wikitext''', or insert just the plain text?"

This could work. Or to drive the point home: " ... text formatting ... '''[[wikitext]]''' ..."

Thoughts @Deskana?

kaldari added a subscriber: kaldari.May 7 2018, 7:59 PM

This could work. Or to drive the point home: " ... text formatting ... '''[[wikitext]]''' ..."

Personally, I think that would cause more confusion than clarity. Curious what @Deskana thinks though.

It'd be:

Versus:

This could work. Or to drive the point home: " ... text formatting ... '''[[wikitext]]''' ..."

Personally, I think that would cause more confusion than clarity. Curious what @Deskana thinks though.

Agreed. I also don't think using "we" is the best here, since the visual editor is not a collective of sentient beings; passive voice would be better. I also also think "pasted" would be better than "inserted", since that's the exact action the user will have taken. I also also also think the button would be better labelled "Convert to wikitext", as that's more consistent with the message, which doesn't contain the word "markup".

Let's go with "Your pasted content contains formatting. Should it be converted to wikitext, or inserted as plain text?" with the buttons "Convert to wikitext" and "Use plain text".

Change 433980 had a related patch set uploaded (by DLynch; owner: DLynch):
[VisualEditor/VisualEditor@master] ce.Surface: Refactor afterPaste

https://gerrit.wikimedia.org/r/433980

Change 425462 abandoned by DLynch:
SurfaceFragment: tell insertDocument whether it's from a paste

Reason:
Replaced by 433980

https://gerrit.wikimedia.org/r/425462

Change 433980 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] ce.Surface: Refactor afterPaste

https://gerrit.wikimedia.org/r/433980

Change 433947 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (511911451)

https://gerrit.wikimedia.org/r/433947

Change 433947 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (511911451)

https://gerrit.wikimedia.org/r/433947

Change 425464 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] ce.MWWikitextSurface: ask on paste about wikitext conversion

https://gerrit.wikimedia.org/r/425464

TheDJ awarded a token.May 24 2018, 7:18 PM

I've found that if I don't want to insert a text (and press Esc) the software inserts it anyway as wikitext. It can cause that user doesn't notice it and saves with undesired texts.

Furthermore, would a default setting for this be possible? Most of the time, I need wikitext format, so it would be very useful if the software doesn't ask it all the time.

DLynch added a comment.Jun 4 2018, 3:46 PM

@Bencemac: On the defaults front, as much as anything that's a UI question. Fitting the setting in, changing the setting later, etc.

I admit, I didn't consider canceling that dialog, since it's inserted at a point in the process where it wasn't previously possible to cancel anything. Thus it's not one which has a cancel action, and OOUI's escape-key behavior is producing unintuitive results.

@DLynch What does this mean: can I hope positive outcome? I think adding a setting should be high priority. Without it, pasting texts is pain even tough I find this function really useful. About escaping, it is a little bit strange; plain text is the default, but it inserting as wikitext?

Deskana closed this task as Resolved.Jun 6 2018, 1:10 PM
Deskana triaged this task as Normal priority.