Page MenuHomePhabricator

Add image captions - issues with pasting text with links
Closed, ResolvedPublic

Description

See the relevant comment - https://phabricator.wikimedia.org/T295434#7496935

  • Paste some text with links from a wiki article in Read mode (or some random text with links from any web site), e.g. select and copy the following text: "SpaceX Crew-3 is the third operational flight of a Crew Dragon spacecraft" (https://en.wikipedia.org/wiki/SpaceX_Crew-3)

Screen Shot 2021-11-19 at 1.14.35 PM.png (2,020×408 px, 109 KB)

  • On an article with add image recommendation, say 'yes' to insert an image and paste the text into the caption

Issues:
1) The pasted text will display the text exactly how it looks originally (in the article where it was copied from)

Screen Shot 2021-11-19 at 1.21.32 PM.png (1,098×1,434 px, 375 KB)

2) The Submit button is not active after pasting the text
3) The caption validation message is displayed although the entered text is longer than 5 characters
4) The error is present in the Console:

 Uncaught Error: Element must have a .type property load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:37

    at VeDmAnnotationFactory.ve.dm.ModelFactory.createFromElement (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:37)
    at VeCeTextState.ve.ce.TextState.getChangeTransaction (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:365)
    at VeCeSurface.ve.ce.Surface.handleObservedChanges (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:481)
    at VeCeSurfaceObserver.ve.ce.SurfaceObserver.pollOnceInternal (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:508)
    at VeCeSurfaceObserver.ve.ce.SurfaceObserver.pollOnce (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:508)
    at VeCeSurface.ve.ce.Surface.onDocumentInput (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:477)
    at VeEventSequencer.ve.EventSequencer.callListener (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:24)
    at VeEventSequencer.ve.EventSequencer.onEvent (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:21)
    at HTMLDivElement.<anonymous> (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:19)
    at HTMLDivElement.dispatch (load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=14xhh:70)
ve.dm.ModelFactory.createFromElement @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:37
ve.ce.TextState.getChangeTransaction @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:365
ve.ce.Surface.handleObservedChanges @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:481
ve.ce.SurfaceObserver.pollOnceInternal @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:508
ve.ce.SurfaceObserver.pollOnce @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:508
ve.ce.Surface.onDocumentInput @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:477
ve.EventSequencer.callListener @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:24
ve.EventSequencer.onEvent @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:21
(anonymous) @ load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:19
dispatch @ load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=14xhh:70
elemData.handle @ load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=14xhh:66

5) Attempting to edit the caption i.e. click at the end of the caption and click 'delete' to delete some text, results in another Console error:

Uncaught TypeError: Cannot read properties of undefined (reading 'focus') load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:433 
    at VeCeSurface.ve.ce.Surface.focus (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:433)
    at Object.ve.ce.LinearDeleteKeyDownHandler.static.execute (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:527)
    at Object.AddImageLinearDeleteKeyDownHandler.static.execute (load.php?lang=en&modules=ext.growthExperiments.StructuredTask|ext.growthExperiments.StructuredTask.mobile&skin=minerva&version=p5895:121)
    at VeCeKeyDownHandlerFactory.ve.ce.KeyDownHandlerFactory.executeHandlersForKey (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:510)
    at VeCeSurface.ve.ce.Surface.onDocumentKeyDown (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:447)
    at VeEventSequencer.ve.EventSequencer.callListener (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:24)
    at VeEventSequencer.ve.EventSequencer.onEvent (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:21)
    at HTMLDivElement.<anonymous> (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:19)
    at HTMLDivElement.dispatch (load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=14xhh:70)
    at HTMLDivElement.elemData.handle (load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=14xhh:66)

6) Deleting in the middle of the text produces multiple Console errors:

Uncaught Error: Unbalanced set of replace operations found load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:89
   at VeDmTransactionProcessor.ve.dm.TransactionProcessor.process (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:89)
   at VeDmDocument.ve.dm.Document.commit (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:211)
   at VeDmSurface.ve.dm.Surface.changeInternal (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:172)
   at VeDmSurface.ve.dm.Surface.change (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:172)
   at VeCeSurface.ve.ce.Surface.changeModel (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:502)
   at VeCeSurface.ve.ce.Surface.handleObservedChanges (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:481)
   at VeCeSurfaceObserver.ve.ce.SurfaceObserver.pollOnceInternal (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:508)
   at VeCeSurfaceObserver.ve.ce.SurfaceObserver.pollOnce (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:508)
   at VeCeSurface.ve.ce.Surface.afterDocumentKeyDown (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:453)
   at VeEventSequencer.ve.EventSequencer.callListener (load.php?lang=en&modules=ext.visualEditor.core%2Cmwsave%2Cmwtransclusion&skin=minerva&version=17zkv:24)

Comparing with entering caption via VE:

  • Open VE and insert an image file, click "Use this image" to add caption text. Paste the same text as in Step 1 above - the link is removed. "Apply changes " button is active.

Screen Shot 2021-11-19 at 1.46.37 PM.png (1,194×1,528 px, 225 KB)

  • the Published look

Screen Shot 2021-11-19 at 1.50.03 PM.png (938×726 px, 116 KB)

Event Timeline

@Sgs -- we do not want the pasted link to survive in the caption. Although captions can technically (and sometimes legitimately) have links, we don't want them because (a) we don't want to encourage pasting into the caption, (b) we don't make the tools available for the user to edit the link that they will have pasted.

@RHo is going to file a task only allowing the pasting of plain text. That should theoretically solve this, but we will leave this bug open to test and validate it.

@RHo is going to file a task only allowing the pasting of plain text. That should theoretically solve this, but we will leave this bug open to test and validate it.

filed as T296217

Etonkovidova renamed this task from Add image captions - issues wiht pasting text with links to Add image captions - issues with pasting text with links .Nov 23 2021, 11:10 PM
Etonkovidova claimed this task.

Checked in testwiki- works as expected per the specs in T296217.