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

Better inline paste #2497

Merged
merged 7 commits into from
Aug 22, 2017
Merged

Better inline paste #2497

merged 7 commits into from
Aug 22, 2017

Conversation

ellatrix
Copy link
Member

Fixes #2459, and inline Editable paste.

  • The pasteHandler now really handles all paste. Before, the Editable component handled block paste and inline paste.
  • We pass { inline: true } if the editable expects inline content. If so, we strip everything that is not text or inline tags.
  • Images are now seen as non inline content, so a block will be created.

To test:

  • Copy an image from the old editor (click, copy), then paste it in a paragraph. An image block should be created.
  • Copy some content that is not all inline. This can be some blocks, or some content from a site. Paste it in a caption or another single line Editable. The content should be pasted in the caption, but only as text and formatting.

@codecov
Copy link

codecov bot commented Aug 22, 2017

Codecov Report

Merging #2497 into master will increase coverage by 2.23%.
The diff coverage is 77.46%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2497      +/-   ##
==========================================
+ Coverage    27.2%   29.44%   +2.23%     
==========================================
  Files         160      167       +7     
  Lines        4914     5203     +289     
  Branches      819      876      +57     
==========================================
+ Hits         1337     1532     +195     
- Misses       3030     3108      +78     
- Partials      547      563      +16
Impacted Files Coverage Δ
blocks/api/paste/normalise-blocks.js 96.66% <100%> (-0.21%) ⬇️
blocks/api/paste/utils.js 100% <100%> (ø)
blocks/api/paste/create-unwrapper.js 100% <100%> (ø)
blocks/api/paste/is-inline-content.js 100% <100%> (ø)
blocks/api/paste/comment-remover.js 100% <100%> (ø)
blocks/api/paste/strip-attributes.js 100% <100%> (ø) ⬆️
blocks/api/paste/index.js 78.57% <57.14%> (-21.43%) ⬇️
blocks/editable/index.js 11.44% <9.09%> (+0.42%) ⬆️
blocks/library/video/index.js 25% <0%> (-5.77%) ⬇️
blocks/inspector-controls/select-control/index.js 0% <0%> (ø) ⬆️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b557701...da21d6e. Read the comment docs.

@ellatrix
Copy link
Member Author

I feel like it might be better to have one loop over all nodes and then apply filters on each node (except for normalising blocks). I'll explore that in a separate PR.

@ellatrix ellatrix force-pushed the add/better-inline-paste branch from 38cfbed to a8da893 Compare August 22, 2017 13:52
Copy link
Contributor

@georgeh georgeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -1,9 +1,7 @@
import * as keycodes from './keycodes';
import * as nodetypes from './nodetypes';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! I like the imports from window.Node better. One less piece of duplication

@ellatrix ellatrix merged commit a5f191a into master Aug 22, 2017
@ellatrix ellatrix deleted the add/better-inline-paste branch August 22, 2017 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants