Ticket #263 (closed defect: fixed)

Opened 5 months ago

Last modified 4 months ago

Fix text copying in Chrome

Reported by: athomschke Owned by: jenslincke
Priority: major Milestone: M3 - Lively Kernel 2.1
Component: Morphic Keywords:
Cc: sebastian.stamm@…

Description

Sometimes the whole world crashes (e.g. if text from other websides is copied) and sometimes it shows the following stack trace:

Error in handleEvent when calling <lively.morphic.Text#48D53...>>>onPaste: TypeError?: Object #<Comment> has no method 'getAttribute' TypeError?: Object #<Comment> has no method 'getAttribute'

at Function.extractStylesAndApplyToRichText ( http://lively-kernel.org/repository/webwerkstatt/core/generated/combinedModules.js?5c933f641c8f5ad944312307a171f253:16061:26) at Function.pastedHTMLToRichText ( http://lively-kernel.org/repository/webwerkstatt/core/generated/combinedModules.js?5c933f641c8f5ad944312307a171f253:16040:14) at Text.onPaste ( http://lively-kernel.org/repository/webwerkstatt/core/generated/combinedModules.js?5c933f641c8f5ad944312307a171f253:14136:50) at EventHandler?.handleEvent ( http://lively-kernel.org/repository/webwerkstatt/core/generated/combinedModules.js?5c933f641c8f5ad944312307a171f253:20005:63) at HTMLDivElement.bound ( http://lively-kernel.org/repository/webwerkstatt/core/lively/bootstrap.js:814:37)

Also, copying screws the indetation.

Change History

comment:1 Changed 5 months ago by fbo

Do you have a sample page at hand that lets us reproduce the error?

comment:2 Changed 4 months ago by sstamm

  • Cc sebastian.stamm@… added
  • Milestone set to M3 - Lively Kernel 2.1

 http://lively-kernel.org/repository/webwerkstatt/issues/120120_FixTextCopyingInChrome.xhtml

Case 1: open any page, open a workspace, write "some text", copy it (without any linebreaks), paste it.

Expected: "some text" is pasted in the same line Result is: "some text" is pasted in a new line

Case 2: copy "some text" with newline, paste it. (in the new line must not be any character)

Expected: "some text" is pasted, the cursor is in a new line Result is: world crashes

comment:3 Changed 4 months ago by jenslincke

  • Owner set to jenslincke
  • Status changed from new to accepted
  • Component changed from Apps to Morphic

pasting HTML BR -> exception testPasteString('a<br>b')

pasting XHTML BR -> no exception testPasteString('a<br/>b')

comment:4 Changed 4 months ago by athomschke

  • Status changed from accepted to closed
  • Resolution set to fixed

fixed in revision 130527

comment:5 Changed 4 months ago by sstamm

  • Status changed from closed to reopened
  • Resolution fixed deleted

could not verify fix.

updated issue page, case 3: copy "some text" with newline, paste it. Result is: sometext is pasted with two new lines

comment:6 Changed 4 months ago by athomschke

  • Status changed from reopened to closed
  • Resolution set to fixed

fixed again in revision 130596

comment:7 Changed 4 months ago by mzimmerm

This is still happening on Chrome (both stable 16 and dev 18) on Linux. It can be duplicated on pretty much any text copy/paste. A one-word "bombs" highlight followed by Ctrl-C then Ctrl-V produces:

PASTE ERROR: Error: INVALID_STATE_ERR: DOM Exception 11

could not paste: <meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: rgb(0, 0, 0); font-family: Arial, sans-serif; font-size: 19px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; ">bombs</span>

please report problem on:  http://lively-kernel.org/trac

comment:8 Changed 4 months ago by huberthesse

I can reproduce mzimmerm's last error message.

comment:9 Changed 4 months ago by huberthesse

Another error dump:

PASTE ERROR: Error: INVALID_STATE_ERR: DOM Exception 11

could not paste: <span> var t1 = $morph('Touch1'), t2 = $morph('Touch2'), tmid = $morph('TouchMid?');

if(t1 && t2 && tmid){

t1.setPosition(touch1); t2.setPosition(touch2); tmid.setPosition(touch1.midPt(touch2))

}</span>

please report problem on:  http://lively-kernel.org/trac

comment:10 Changed 4 months ago by athomschke

fixed in revision 131556 (Linux copy paste error) cause: meta tag could not be parsed

comment:11 Changed 4 months ago by mzimmerm

I can confirm this is now fixed in Chrome Linux & still works on Chrome Windows. Firefox also keeps working.

comment:13 Changed 4 months ago by mzimmerm

Actually - same problem exists in Windows as well. Guessing the parsing of that link. Hope it's ok to reopen, although this makes the bug a lower priority then blocker imo.

(BTW thanks for fixing the main issue, I can now use faster Chrome again)

comment:14 Changed 4 months ago by jenslincke

  • Priority changed from blocker to major

thanks for reporting, you can reopen this bug any time you get the error message. I fixed it in such a way, that it won't break, e.g. the link contained an & which I replace with "&amp;", we do not treat the link correctly any way... that should be another ticket

comment:15 Changed 4 months ago by bsiegmund

  • Status changed from closed to reopened
  • Resolution fixed deleted

When copying '<', '>' or '&', they are converted to html entities '&lt;', '&gt;' or '&amp;'

comment:16 Changed 4 months ago by bsiegmund

  • Status changed from reopened to closed
  • Resolution set to fixed

sry, my bad, wrong ticket

comment:17 Changed 4 months ago by mzimmerm

I see how you fixed it. No need to reopen this I am happy about the copy - paste functionality. - and I see someone created http://www.lively-kernel.org/trac/ticket/293 (Pasting HyperText?) which I suppose is a generic approach to hypertext pasting from inside and outside lively.

Thanks for those quick text fixes!

Note: See TracTickets for help on using tickets.