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

Fix error when pasting HTML that parses to a blank doc #620

Merged
merged 1 commit into from Jun 20, 2018

Conversation

kevinansfield
Copy link
Collaborator

@kevinansfield kevinansfield commented May 21, 2018

closes #619

  • it's possible to paste HTML that parses into a blank doc, if the paste results in a section being replaced then the post-inserter would throw an error because it expects the new post to have sections
  • adds a guard in the paste event handler to avoid inserting a blank post

QUESTIONS:

  • do we want to keep the guard in the paste event or should the fix actually be in post-inserter.js?
  • are we happy that a paste which results in a blank doc still performs the deletion and empty markup section creation? (I'm assuming a paste that parses to a blank doc was not intentional so may be confusing if the user only sees content being deleted)

@jasonbekolay
Copy link

We have had this issue pop up a couple times in our app at Yapp and I believe this PR would improve the current experience. The second question does concern me a bit, but I'm not sure what would be better behavior. Having the editor do nothing in that case would not be a better experience in my opinion.

kevinansfield added a commit to TryGhost/Admin that referenced this pull request Jun 18, 2018
…raphs

refs TryGhost/Ghost#9623
- switch to custom `mobiledoc-kit` build
  - fixes top-level elements not being run through parser plugins (bustle/mobiledoc-kit#627)
  - fixes <kbd>Alt</kbd> getting stuck and causing <kbd>Backspace</kbd> to delete whole words (bustle/mobiledoc-kit#626)
  - fixes error that can occur when a paste results in blank insert (bustle/mobiledoc-kit#620)
- add new `figureToImageCard` parser
  - replaces hacky workaround to detect an image+figcaption inside the `imgToCard` parser plugin
- remove wrapping of html in a `<div>...</div>` when pasting
  - no longer necessary now that top-level elements are parsed
  - fixes rich-text pastes where multiple paragraphs would be collapsed into a single paragraph
});
if (!pastedPost.isBlank) {
editor.run(postEditor => {
let nextPosition = postEditor.insertPost(position, pastedPost);
Copy link
Contributor

Choose a reason for hiding this comment

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

@kevinansfield I think we should have insertPost be able to insert a blank post. That seems valid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

closes bustle#619
- it's possible to paste HTML that parses into a blank doc, if the paste results in a section being replaced then the `post-inserter` would throw an error because it expects the new post to have sections
- adds a guard in the paste event to avoid inserting a blank post
@mixonic
Copy link
Contributor

mixonic commented Jun 20, 2018

Awesome, thanks @kevinansfield!

@mixonic mixonic merged commit 3b110e6 into bustle:master Jun 20, 2018
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

Successfully merging this pull request may close these issues.

Paste with certain HTML throws Cannot read property 'tailPosition' of undefined
3 participants