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

Copying formulas copies text, rather than object / element #35

Open
tony opened this issue Apr 28, 2021 · 4 comments
Open

Copying formulas copies text, rather than object / element #35

tony opened this issue Apr 28, 2021 · 4 comments

Comments

@tony
Copy link
Collaborator

tony commented Apr 28, 2021

Example (+ drag and drop issue with #34)

00:00 - 00:14:

2021-05-04.09-08-33.-.ckeditor5-math.PR.34.35.-.with.PR.mp4

Possibly relevant / fixable with #34

We speak about autoformat and pasting in the README, but we strip \ from equations on pasting, so those aren't copyable.

Reproducible on the demos: https://jsfiddle.net/isaul32/qktj9h7x/, https://jsfiddle.net/isaul32/3wjrkLdv/, https://jsfiddle.net/isaul32/q01mu8kp/

Recreation steps

  • git clone https://github.com/isaul32/ckeditor5-math.git
  • cd ckeditor5-math
  • yarn
  • yarn start
  • http://localhost:8080
  • Copy a formula
  • Paste formula: It pastes as text
@Jules-Bertholet
Copy link
Contributor

I think I found the root cause of this. At https://github.com/ckeditor/ckeditor5/blob/6e44d34449a95c93c01170a079bdd3c75c3eab5f/packages/ckeditor5-engine/src/dataprocessor/htmldataprocessor.js#L119:

_toDom( data ) {
	const document = this._domParser.parseFromString( data, 'text/html' );
		const fragment = document.createDocumentFragment();
		const nodes = document.body.childNodes;
		...

When DOMParser encounters a lone <script> tag, it assumes that the tag belongs in <head> and not <body>. Therefore, document.body ends up not containing the <script> tag that stores the equation.

@tony
Copy link
Collaborator Author

tony commented May 10, 2021

@Jules-Bertholet Excellent! Incredible

Would you like to make an issue there?

Do you also think this has to do with #34 (drag and drop?)

@Jules-Bertholet
Copy link
Contributor

Jules-Bertholet commented May 10, 2021

Yes, I think that this is very likely the cause of #34. Note that the problem I found causes nothing to be pasted when the extension is configured to use <script> tags and equations are copied without surrounding text. The video at the top of this issue also demonstrates something different, where copying text from the equation input box results in raw text being copied instead of the equation HTML; that is unrelated, and in fact I'm not sure that it should really be considered a bug at all.

@tony
Copy link
Collaborator Author

tony commented May 11, 2021

Thanks for letting me know this could be related to #34 (the drag and dropping of formulas). That is the more urgent of the existing ckeditor5-math issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants