Page MenuHomePhabricator

Come up with an alternative to having multiple slugs (invitations to add a paragraph) next to each other that preserves editing capabilities
Closed, ResolvedPublic40 Estimated Story Points

Description

While editing this article with Visual Editor, I found 4 invitations to add a new paragraph one after the other. As shown below it seems too many of them:

insert-paragraph.gif (324×677 px, 116 KB)

The article starts with several images, and that may be creating some confusion to VE.

Event Timeline

Pginer-WMF raised the priority of this task from to Needs Triage.
Pginer-WMF updated the task description. (Show Details)
Pginer-WMF added a project: VisualEditor.
Pginer-WMF subscribed.

Yup, one for each of the floated-right block items in the context. The alternative is picking which point we 'allow' the user to insert content between images, which is worse.

It is not clear to me why there are just two alternatives. I was thinking on the following options instead:

  • Detect when there are several elements in a row and show the invitation to add a paragraph just once.
  • Avoid images (and similar elements) to trigger the new paragraph invite at all.

Those may require more effort than what is worth it for the value they provide (I'll leave that assessment to you), but I think today's technology seems powerful enough to not declare this problem unsolvable.

Jdforrester-WMF renamed this task from Multiple invitations to add a paragraph next to each other to Come up with an alternative to having multiple slugs (invitations to add a paragraph) next to each other that preserves editing capabilities.Aug 4 2015, 7:05 PM
Jdforrester-WMF triaged this task as Lowest priority.
Jdforrester-WMF moved this task from To Triage to Freezer on the VisualEditor board.
Jdforrester-WMF set Security to None.
Jdforrester-WMF edited a custom field.

Wrapping the list of images in a begin/end pair of templates solves the issue of multiple slugs, see: https://ca.wikipedia.org/w/index.php?title=Usuari:Ad_Huikeshoven/proves&veaction=edit.

The begin template is just <div> and the end template is just </div>. Just a pair of tags that has been split over two templates. Visual editor the matching pair of templates and all in between as a single transclusion, hence no slugs, let alone multiple slugs.

It also prevents you from editing the images visually… please don't do that :) It helps for the specific case nl.wp had a problem with (T161408), but unless the content you wrap is already mostly made up of templates, it will result in worse interface in VE (and it's clutter in the page source).

Detect when there are several elements in a row and show the invitation to add a paragraph just once.

This makes sense for floated images, but image floating is part of the styling, not really the document semantics so this layout is no different from:

text.....................
    [ centred image ]
    [ centred image ]
    [ centred image ]
text.....................

In this case it is more clear that we would want to preserve the ability to insert text between the images.

For images we can guess that an image is floated using data in the model, so MWBlockImageNodes could look at their attributes and use this to disable some of these slugs if they are floated. However other elements can be floated (e.g. Infoboxes) and in these cases there is nothing in the model that would tell us that.

I think any proper solution to this requires a big re-think of block slugs.

In the past one idea has been to replace slugs with a "layout mode" that removes all floating from the document, and allows the user to re-order any block level element (image/infobox/paragraph/heading), or insert new ones.

A less dramatic idea might be to only show slugs when the node they are in-between is focused, so for example when one of these block images is selected, buttons are shown above and below the image, however this may just clutter the UI around focusable nodes, and may be just as confusing.

For images we can guess that an image is floated using data in the model

This might be worth doing anyway - it will not fix all cases, but it should reduce the number of edge cases where this is a major issue.

Change 478660 had a related patch set uploaded (by Esanders; owner: Esanders):
[VisualEditor/VisualEditor@master] Allow slugs to be suppressed based on context

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

Change 478661 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/VisualEditor@master] Suppress slugs between floated images

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

The above patches fix the documented case with sequential floated images, but would not work with other floated elements, such as infoboxes.

Another limitation is that slugs are only recalculated on items are removed/inserted, and not on attribute change, so changing the alignment of an image would not re-evaluate which slugs should be suppressed, however this seems like an edge case of an edge case.

Change 478660 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] Allow slugs to be suppressed based on context

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

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

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

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

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

Change 478661 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/VisualEditor@master] Suppress slugs between floated images

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

Change 478661 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Suppress slugs between floated images

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