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

Default insert behavior #21

Merged
merged 3 commits into from
Aug 8, 2013
Merged

Default insert behavior #21

merged 3 commits into from
Aug 8, 2013

Conversation

matteoagosti
Copy link
Contributor

No description provided.

According to what we have done with the split event we pass the cursor
object that could be used by implementors to move the cursor in a
different position.
Attributes are cloned. To avoid duplicates id, if an id is present a
suffix is added to it.
matteoagosti added a commit that referenced this pull request Aug 8, 2013
@matteoagosti matteoagosti merged commit f82292e into master Aug 8, 2013
@matteoagosti matteoagosti deleted the insertBehavior branch August 8, 2013 10:56
@peyerluk
Copy link
Member

peyerluk commented Aug 8, 2013

Since this is related to #20 a tip from Philipe. You can convert an issue into a pull request like so: http://opensoul.org/blog/archives/2012/11/09/convert-a-github-issue-into-a-pull-request/

@matteoagosti
Copy link
Contributor Author

  • Thanks Philipe for the hint!
  • Agree on getting rid of the id when present
  • What do you mean with last child? I tested it out adding a paragraph at the end of the editor's div (so that should be the last child) and the insertion worked.

There is actually an additional issue with the newly created block: calling cursor.isAtTheBeginning or cursor.isAtTheEnd return both false. Probably this is related to the way I set the cursor when creating the new block as I just trigger the focus event instead of placing the cursor. I'll look into that.

@matteoagosti
Copy link
Contributor Author

The additional issue I mentioned above wasn't related to the way the cursor is placed (it is actually correct when triggering focus), but to a bug in parser.isStartOffset and parser.isEndOffset. When we have a newly created block it won't contain any children, so the offset should be considered the start and the end. Check commit e42c6ed

@peyerluk
Copy link
Member

peyerluk commented Aug 9, 2013

With last child I meant what you already tested for. I wasn't sure what insertBefore() would do if the second param referenceElement is undefined.

should have checked mdn:

If referenceElement is null, newElement is inserted at the end of the list of child nodes.

@matteoagosti
Copy link
Contributor Author

Yep, I'm using MDN as well trying not to rely on jQuery :P

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.

2 participants