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

Refactor postEditor#insertPost to handle more situations #267

Merged
merged 1 commit into from
Dec 16, 2015

Conversation

bantic
Copy link
Collaborator

@bantic bantic commented Dec 15, 2015

Ready to start getting feedback on this. There are some todos and fixmes I intend to address before this should be merged, though.

  • refactor postEditor#insertPost to handle a larger number of situations
  • fix bug in post#cloneRange when range starts in list item
  • add assert.isPostSimilar, assert.isRenderTreeEqual, assert.isPositionEqual
  • add test for ListSection#clone

Fix #249 #259

@@ -754,8 +754,7 @@ class Editor {
let pastedPost = parsePostFromPaste(event, this.builder, this._parserPlugins);

this.run(postEditor => {
let nextPosition = postEditor.insertPost(position, pastedPost);
postEditor.setRange(new Range(nextPosition));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be left outside insertPost?

We discussed the range stuff in detail but I don't remember if we talked about moving cursor changes into postEditor methods. Am I forgetting a reason this must be done?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what you mean by "outside", but this can still use the position-returning semantics...I switched it back to the way it was. postEditor.insertPost now returns a Position

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. I'm not sure if we had the discussion or not. I know having mutation methods with the side effect of changing cursor position is something we've avoided until now. However the arguments against it are fewer now that we have setRange, a safe way to set the position and read it back without the DOM.

@mixonic
Copy link
Contributor

mixonic commented Dec 15, 2015

Some pretty great stuff!!!

@bantic bantic changed the title WIP Refactor postEditor#insertPost to handle more situations Refactor postEditor#insertPost to handle more situations Dec 16, 2015
@bantic
Copy link
Collaborator Author

bantic commented Dec 16, 2015

@mixonic I've added some additional test coverage for new methods and addressed the first round of feedback. This is ready for a final review now. If all looks good, I'll squash and merge.

  * fix bug in post#cloneRange when range starts in list item
  * add assert.isPostSimilar, assert.isRenderTreeEqual, assert.isPositionEqual
  * fix ListSection#clone to use the same tagName for the clonee as the cloner
  * add PostEditor#insertMarkers method
  * add private/intimate methods for splitting list items and lists in postEditor

Fix #249 #259
@bantic bantic force-pushed the copy-paste-refactor-259 branch from be66fd7 to cda1e7e Compare December 16, 2015 16:52
bantic added a commit that referenced this pull request Dec 16, 2015
Refactor postEditor#insertPost to handle more situations
@bantic bantic merged commit e687d3d into master Dec 16, 2015
@bantic bantic deleted the copy-paste-refactor-259 branch December 16, 2015 17:01
@bantic bantic mentioned this pull request Dec 16, 2015
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.

Copying/pasting inside list elements doesn't work
2 participants