Page MenuHomePhabricator

Create a read-only mode for Visual Editor that allows inspection
Closed, ResolvedPublic

Description

Visual Editor allows to represent content as either in disabled or editable modes. The current disabled mode shows the final rendering of the page (as you would expect), but does not allow users to inspect some relevant information such as templates, references, or links.

A read-only mode, while not allowing users to modify the content, would show the different inspectors and dialogs to access additional information. This would be useful for the following scenarios:

  • Visual access to protected pages (T53547). Pages that cannot be edited are currently exposed in wikitext to users. For example, users trying to copy an image or infobox from a protected article, will find themselves in the middle of wikitext to identify the code corresponding to such element to copy it, instead of having a more visual and simple experience (select the image/infobox, copy, and paste it).
  • Inspecting the original content in Content translation (T203775, T197075). Translating content requires users to dig into the original information to better understand context and being able to translate it.

The read-only mode is defined as an intermediate mode between the current disabled and editable modes. It can be supported as an additional new mode, or as an improvement of the current disabled mode in VE that replaces it. It will support the following aspects:

  • Present the content in a way that allows users to select the text but not modifying it (as the current disabled mode does).
  • Inspectors and dialogs will be shown for elements (like "editing" mode), but replacing the edit/delete actions with an action to view the details instead.
  • Inspected contents presented inside these dialogs will be shown using either the disabled mode (for plain text content) or the read-only mode (for rich text fields) to make sure that they cannot be modified but it is provided access to further details when needed.

Related Objects

Event Timeline

(This is repeatedly brought up in focused feedback from outreach to wikis.)

(This is repeatedly brought up in focused feedback from outreach to wikis.)

Which use case in particular are they interested in?

Both T203775 and T197075. These issues are a regression from the capabilities of CX1, where you could easily adapt references and links by clicking on them.

The "inspect" mode is defined as an intermediate mode between "read-only" and "editable" modes

I would propose that this would replace VE's "ready-only" mode. If a completely non-interactive mode is still required then the user can use raw Parsoid HTML. I know CX needed a VE-rendering of the HTML to get better layout-parity (e.g. include block slugs), but that was a bit of an edge case. We would be left with:

  • Read mode (static Parsoid HTML, no VE code required)
  • Inspect/read-only/edit-disabled mode (this proposal)
  • Edit mode

Unless someone can think of a sensible use case for disabling the edit surface and the inspectors...

The "inspect" mode is defined as an intermediate mode between "read-only" and "editable" modes

I would propose that this would replace VE's "ready-only" mode. If a completely non-interactive mode is still required then the user can use raw Parsoid HTML. I know CX needed a VE-rendering of the HTML to get better layout-parity (e.g. include block slugs), but that was a bit of an edge case. We would be left with:

  • Read mode (static Parsoid HTML, no VE code required)
  • Inspect/read-only/edit-disabled mode (this proposal)
  • Edit mode

Unless someone can think of a sensible use case for disabling the edit surface and the inspectors...

What's proposed sounds like a good approach to me. I updated the description to make it more clear that's ok for the "inspect" mode to replace the current "read-only" mode in VE.

Copied from my comment on T197075:

All of this work should be done in VE core, and note that in implementing this you would also fix T53547!

Change 489297 had a related patch set uploaded (by Esanders; owner: Esanders):
[VisualEditor/VisualEditor@master] WIP Replace surface disable with readonly mode

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

Esanders renamed this task from Create an "inspect" mode for Visual Editor to Create a read-only mode for Visual Editor that allows inspection.Feb 22 2019, 3:45 PM
Esanders updated the task description. (Show Details)

Change 489297 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] Replace surface disable with read-only mode

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

Change 492360 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (541222565)

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

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

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

matmarex subscribed.

The patches are merged, but the read-only mode is not being used anywhere yet (see the parent tasks for that) okay, never mind, I went ahead and merged the patch for T53547 too – you will be able to switch from old wikitext editor to read-only visual editor when viewing source of protected pages.

We will need to do some more work to update various interfaces to be aware of the read-only mode, and disable or hide various inputs. I've been testing with T53547 and Ed had already fixed most, but not all.

Patches to update interface that were already merged:

More issues I noticed:

  • gallery add/remove image buttons are still available
  • template add parameter interface is still available
  • ISBN inspector's input is editable
  • everything in the meta dialog is editable
  • Ctrl+K (link tool) still opens a link dialog in insertion mode when plain text with no link is selected
  • Ctrl+Shift+K (reference tool) crashes in read-only mode

For testing, you can enter this in to the console: ve.init.target.surface.setReadOnly(true)

Change 492539 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/VisualEditor@master] Gallery: Disable add/remove image buttons in read-only mode

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

Change 492645 had a related patch set uploaded (by Esanders; owner: Esanders):
[VisualEditor/VisualEditor@master] Abort opening window for insertion when in readonly mode

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

The above patch fixes the ctrl+k/ctrl+shift+k issues.

Change 492654 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/VisualEditor@master] MWMetaDialog: Implement read-only mode

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

Change 492645 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] Abort opening window for insertion when in readonly mode

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

Change 492654 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] MWMetaDialog: Implement read-only mode

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

Change 492539 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Add more read-only implementations

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

Change 493049 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (4669eff2b)

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

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

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

I found a related issue about the inspection leading to the wrong wiki: T217410: Inspecting a template in the source language wrongly leads to the target wiki template documentation.

I don't know whether that's a problem in the Content Translation side, the new read-only mode, or both. Feel free to share any thoughts in the ticket if anyone has a guess.

I found a related issue about the inspection leading to the wrong wiki: T217410: Inspecting a template in the source language wrongly leads to the target wiki template documentation.

I don't know whether that's a problem in the Content Translation side, the new read-only mode, or both. Feel free to share any thoughts in the ticket if anyone has a guess.

@Petar.petkovic also noticed this a similar issue and mentioned it in code review of https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ContentTranslation/+/489392:

Information for all link cards is obtained from target wiki, because that is hardcoded currently. There will need to be more work to complete T197075, but that is outside the scope of this patch.

So I guess it's a known issue in ContentTranslation.

The above patch fixes the ctrl+k/ctrl+shift+k issues.

Like @matmarex already pointed out, patch 494145 reintroduces ctrl+k/ctrl+shift+k problems in source.

Yes and T217880 is used to track that, although that bug is not listed in the commit message of the patch.