Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't paste entites into RTE when RT mode enabled #4962

Closed
MurzNN opened this issue Sep 3, 2017 · 11 comments
Closed

Can't paste entites into RTE when RT mode enabled #4962

MurzNN opened this issue Sep 3, 2017 · 11 comments

Comments

@MurzNN
Copy link
Contributor

MurzNN commented Sep 3, 2017

After update from 0.11.x to 0.12.2 on Riot Electron in Linux (Ubuntu & KDE 4.x) - sometimes we can't paste from clipboard to message textarea, this reproduced on several computers in our company.

I have clipboard content, press shift-insert or ctrl+v, middle mouse paste and nothing happens. Even when I have plaintext content. On other app this clipboard content pastes normally.

On 0.11.x versions there was be no problems like this. Seems that Riot try to parse clipboard content before insert and fail sometimes with this.

@MurzNN
Copy link
Contributor Author

MurzNN commented Sep 4, 2017

Here is the error that shows in debugger after failed paste:

invariant.js:40 Uncaught Error: Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.
    at r (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:1:14304)
    at t.getEntity (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:39:22452)
    at file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:123:13018
    at file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:24:30559
    at file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:12:27176
    at je.__iterate (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:12:14121)
    at je.reduce (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:12:27133)
    at n (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:24:30520)
    at t.findEntityRanges (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:15:20015)
    at t.value (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:123:12941)
    at file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:91:20964
    at Array.forEach (native)
    at e.getDecorations (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:91:20873)
    at Object.generate (file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:62:4200)
    at file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:11:2235
    at file:///opt/Riot/resources/webapp/bundles/d7e43abdc20054b7b707/bundle.js:11:23587

@MurzNN
Copy link
Contributor Author

MurzNN commented Sep 4, 2017

And here is from unminified Develop web version:

Error: Unknown DraftEntity Key.  bundle.js:2936:16
	invariant https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:2936:16
	getEntity https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:44902:51
	findLinkEntities/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:130044:47
	findRangesImmutable/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:28243:12
	reduce/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:8391:24
	List.prototype.__iterate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:6174:14
	reduce https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:8386:8
	findRangesImmutable https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:28241:4
	findEntityRanges https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:17705:6
	findLinkEntities https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:130042:14
	findLinkEntities self-hosted:947:17
	getDecorations/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:148757:8
	forEach self-hosted:267:13
	getDecorations https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:148745:6
	generate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:74117:36
	regenerateTreeForNewBlocks/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:3889:13
	mapFactory/mappedSequence.__iterateUncached/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:6984:40
	filterFactory/filterSequence.__iterateUncached/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:7054:19
	ToKeyedSequence.prototype.__iterate/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:6800:36
	OrderedMap.prototype.__iterate/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:6667:44
	List.prototype.__iterate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:6174:14
	OrderedMap.prototype.__iterate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:6666:15
	ToKeyedSequence.prototype.__iterate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:6798:15
	filterFactory/filterSequence.__iterateUncached https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:7051:8
	seqIterate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:4586:13
	Seq.prototype.__iterate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:4256:15
	mapFactory/mappedSequence.__iterateUncached https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:6983:15
	seqIterate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:4586:13
	Seq.prototype.__iterate https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:4256:15
	forEach https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:8354:15
	mergeIntoCollectionWith/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:5929:10
	Map.prototype.withMutations https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:5321:8
	mergeIntoCollectionWith https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:5918:13
	mergeIntoMapWith https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:5891:13
	Map.prototype.merge https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:5272:15
	regenerateTreeForNewBlocks https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:3886:11
	set/map< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:3519:31
	Map.prototype.withMutations https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:5321:8
	set https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:3489:16
	push https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:3760:13
	onTextPasted https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:130293:35
	onTextPasted self-hosted:947:17
	editOnPaste https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:152253:56
	_buildHandler/< https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:149029:20
	<анонимная> self-hosted:987:17
	ReactErrorUtils.invokeGuardedCallback https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:58922:8
	executeDispatch https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:58455:6
	executeDispatchesInOrder https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:58478:6
	executeDispatchesAndRelease https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:24676:6
	executeDispatchesAndReleaseTopLevel https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:24687:11
	forEach self-hosted:267:13
	forEachAccumulated https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:97385:6
	processEventQueue https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:24887:8
	runEventQueueInBatch https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:238100:4
	handleTopLevel https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:238110:6
	handleTopLevelImpl https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:238191:6
	perform https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:41907:14
	batchedUpdates https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:237959:15
	batchedUpdates https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:14348:11
	dispatchEvent https://riot.im/develop/bundles/9111474d2044735d4609/bundle.js:238266:8
	dispatchEvent self-hosted:987:17

@t3chguy
Copy link
Member

t3chguy commented Sep 4, 2017

@MurzNN thanks for that second trace, should be useful for finding the bug.

@krombel
Copy link
Contributor

krombel commented Sep 28, 2017

It reproducible fails when I want to paste a message which contains emoji's while Markdown is disabled.

This is my stacktrace:

invariant.js:40 Uncaught Error: Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.
    at r (invariant.js:40)
    at t.getEntity (ContentState.js:149)
    at MessageComposerInput.js:196
    at findRangesImmutable.js:31
    at immutable.js:4411
    at je.__iterate (immutable.js:2194)
    at je.reduce (immutable.js:4406)
    at n (findRangesImmutable.js:29)
    at t.findEntityRanges (ContentBlock.js:106)
    at t.value (MessageComposerInput.js:191)
    at CompositeDraftDecorator.js:70
    at Array.forEach (<anonymous>)
    at e.getDecorations (CompositeDraftDecorator.js:58)
    at Object.generate (BlockTree.js:61)
    at EditorState.js:478
    at immutable.js:3004
    at immutable.js:3074
    at immutable.js:2820
    at immutable.js:2687
    at je.__iterate (immutable.js:2194)
    at Ze.__iterate (immutable.js:2686)
    at rt.__iterate (immutable.js:2818)
    at n.o.__iterateUncached (immutable.js:3071)
    at W (immutable.js:606)
    at n.I.__iterate (immutable.js:276)
    at n.r.__iterateUncached (immutable.js:3003)
    at W (immutable.js:606)
    at n.I.__iterate (immutable.js:276)

@lukebarnard1 lukebarnard1 removed their assignment Nov 6, 2017
@lukebarnard1
Copy link
Contributor

lukebarnard1 commented Nov 13, 2017

OK, so this happens when copying links as well as emoji, so things go wrong with new entities basically.

A more salient, filtered stack trace:

bundle.js:1422 Uncaught Error: Unknown DraftEntity Key.
    at ContentState.getEntity (https://riot.im/develop/bundles/da5e4e753da6e83256f5/bundle.js:54684:51)
    ...
    at findRangesImmutable (https://riot.im/develop/bundles/da5e4e753da6e83256f5/bundle.js:37547:13)
    ...
    at ContentBlock.findEntityRanges (https://riot.im/develop/bundles/da5e4e753da6e83256f5/bundle.js:17953:6)
    ...
    at MessageComposerInput.findPillEntities (https://riot.im/develop/bundles/da5e4e753da6e83256f5/bundle.js:148083:27)
    ...
    at CompositeDraftDecorator.getDecorations (https://riot.im/develop/bundles/da5e4e753da6e83256f5/bundle.js:196682:23)

@lukebarnard1
Copy link
Contributor

So I think this is being caused by facebookarchive/draft-js#1363 and there's no real work-around. I tried removing entities from the pasted text after it was inserted but to no avail - there are still parts of draft-js that are becoming corrupt and causing this to be thrown.

@lukebarnard1 lukebarnard1 changed the title Sometimes we can't paste from clipboard to message textarea after update from 0.11.x to 0.12.2 Can't paste entites into RTE when RT mode enabled Nov 13, 2017
@ara4n
Copy link
Member

ara4n commented Mar 14, 2018

I just had this nastily when trying to paste HTML changelog entries from github.com/matrix-org/synapse/releases into RTE in non-MD mode :(

@ara4n
Copy link
Member

ara4n commented Mar 14, 2018

invariant.js:42 Uncaught Error: Unknown DraftEntity Key.
    at invariant (invariant.js:42)
    at ContentState.getEntity (ContentState.js:149)
    at MessageComposerInput.js:195
    at findRangesImmutable.js:31
    at immutable.js:4411
    at List.__iterate (immutable.js:2194)
    at List.reduce (immutable.js:4406)
    at findRangesImmutable (findRangesImmutable.js:29)
    at ContentBlock.findEntityRanges (ContentBlock.js:106)
    at MessageComposerInput.findPillEntities (MessageComposerInput.js:189)

@MurzNN
Copy link
Contributor Author

MurzNN commented Mar 20, 2018

Maybe this way facebookarchive/draft-js#1363 (comment) can fix issue?

@lukebarnard1
Copy link
Contributor

lukebarnard1 commented Mar 20, 2018

Looking at @ara4n's stack trace, this bug happens when we findPillEntities in MessageComposerInput.js. The entityKey we get from the character argument to the function given to findEntityRages is apparently "Unknown".

The issue facebookarchive/draft-js#1363 (comment) is regarding entity creation.

@ara4n
Copy link
Member

ara4n commented Jul 16, 2018

fixed by matrix-org/matrix-react-sdk#1890

@ara4n ara4n closed this as completed Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants