Page MenuHomePhabricator

VE should translate <span style="font-weight: bold">...</span> into <b>...</b>
Closed, ResolvedPublic

Description

(Broken off from T92969: VE in IE is stripping the contents of <font> tags from pasted text):

When pasting two words, one plain, one bolded from MS Word Online into IE, the console.log shows the following:

Before sanitation: <p data-parsoid='{"dsr":[61,182,0,0]}'>☀<span class="TextRun
SCX167197419" xml:lang="EN-US"><span class="NormalTextRun
SCX167197419">plain </span></span><span class="TextRun SCX167197419"
xml:lang="EN-US"><span class="NormalTextRun SCX167197419">bold</span>
</span></p>

(Line breaks added to improve readability.)

This is a little different than what http://edg2s.github.io/content-editable-sandbox/ shows since the style attribute seems to be stripped instead of interpreted: https://gist.github.com/hexmode/81988a6ad474c5c51553

Plain text appears in VE.

The style elements of the paste should inform VE that one of the <span>s need to be turned into <b>.

Details

Related Gerrit Patches:
mediawiki/extensions/VisualEditor : masterUpdate VE core submodule to master (5838dce23)
VisualEditor/VisualEditor : masterve.ce.Surface: Handles font weight bold

Event Timeline

MarkAHershberger raised the priority of this task from to Needs Triage.
MarkAHershberger updated the task description. (Show Details)
MarkAHershberger added a subscriber: MarkAHershberger.
Restricted Application added a project: VisualEditor. · View Herald TranscriptMar 18 2015, 3:25 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
MarkAHershberger set Security to None.
Jdforrester-WMF triaged this task as Lowest priority.Sep 1 2015, 7:29 PM
Jdforrester-WMF added a project: Epic.
Jdforrester-WMF moved this task from To Triage to Freezer on the VisualEditor board.
Izno added a subscriber: Izno.Sep 17 2016, 4:11 AM

<b> presently has intent in html 5, whereas span style=bold does not. Are we okay with assuming that intent was intended?

Izno removed a subscriber: Izno.Sep 17 2016, 4:11 AM

We have similar hacks targeted at Google Docs (T145252) in ve.ce.Surface#afterPasteSanitizePasteTarget: https://phabricator.wikimedia.org/diffusion/GVED/browse/master/src/ce/ve.ce.Surface.js$2503

It apparently outputs <span style="font-weight: 700;"> instead and we only handle that, so that probably doesn't work for Word Online.

@MarkAHershberger If you have time to experiment with Word Online and its copy-paste output to add similar special-cases for it, I think we'd be happy to accept a patch.

@MarkAHershberger If you have time to experiment with Word Online and its copy-paste output to add similar special-cases for it, I think we'd be happy to accept a patch.

Thanks, I'll see what I can do.

MarkAHershberger added a comment.EditedJan 26 2019, 8:44 PM

@osorio-juan-microsoft I have not had time to spend more time on this myself.

One of my clients probably mentioned this to me, but it wasn't a super-high priority for them.

Do you have a full list of how copied text would paste from MSWord online?

@MarkAHershberger The output from MS Word Online is the following:

<!--StartFragment-->

<span class="TextRun SCXW46128342" xml:lang="EN-US" lang="EN-US" style="margin: 0px; padding: 0px; user-select: text; -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; font-variant-ligatures: none !important; color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; font-size: 11pt; font-family: Calibri, Calibri_MSFontService, sans-serif; line-height: 19.425px;">
    <span class="NormalTextRun SCXW46128342" style="margin: 0px; padding: 0px; user-select: text; -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; background-color: inherit;">
        Testing some<span> </span>
    </span>
</span>
<span class="TextRun SCXW46128342" xml:lang="EN-US" lang="EN-US" style="margin: 0px; padding: 0px; user-select: text; -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; font-variant-ligatures: none !important; color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; font-weight: bold; font-size: 11pt; font-family: Calibri, Calibri_MSFontService, sans-serif; line-height: 19.425px;">
    <span class="NormalTextRun SCXW46128342" style="margin: 0px; padding: 0px; user-select: text; -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; background-color: inherit;">
        bold text
    </span>
</span>
<span class="EOP SCXW46128342" data-ccp-props="{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}" style="margin: 0px; padding: 0px; user-select: text; -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; font-size: 11pt; line-height: 19.425px; font-family: Calibri, Calibri_MSFontService, sans-serif;"> </span>

<!--EndFragment-->

There is a font-weight: bold in there somewhere. For reference, the text I copied is: Testing some bold text

I think just parsing that CSS property correctly would work. What do you think?

There is a font-weight: bold in there somewhere. For reference, the text I copied is: Testing some bold text
I think just parsing that CSS property correctly would work. What do you think?

I'm not really the right person to ask. Let's ping the PM: @Jdforrester-WMF

FYI James has been working on different projects for a while.

Anyway, the team's perspective on this is still "we're not planning to work on it, but happy to accept a patch" (as indicated by the VisualEditor (Freezer) tag).

FYI James has been working on different projects for a while.

I was afraid of that, but I went to this page (the top tag on this task) and he is the only member of the VisualEditor-CopyPaste tag with the title of "Lead Product Manager". Sorry for the confusion.

@osorio-juan-microsoft, This is the sort of bug I'd love to work on, but I have a lot of work piled up. Maybe I can convince a client that they need this fixed.

No worries, I'll take a look to see if this is an easy bug to fix, and if so I'll submit a patch

Change 487893 had a related patch set uploaded (by Juan Osorio (Microsoft); owner: Juan Osorio (Microsoft)):
[VisualEditor/VisualEditor@master] ve.ce.Surface: Handles font weight bold

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

Esanders moved this task from Incoming to QA on the VisualEditor (Current work) board.

Change 487893 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] ve.ce.Surface: Handles font weight bold

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

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

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

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

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

Thank you so much, @osorio-juan-microsoft ! (and you gave me enough hint on how to solve similar issues.)

Esanders moved this task from Inbox to Low Priority on the Editing QA board.Feb 7 2019, 7:06 PM
ppelberg closed this task as Resolved.May 10 2019, 1:28 AM