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

Accept non-text nodes in insertTextByKey #784

Closed
wants to merge 11 commits into from

Conversation

oyeanuj
Copy link
Contributor

@oyeanuj oyeanuj commented May 4, 2017

Hi @ianstormtaylor, as per your comments in #775, this function now accepts a non-text node and calculates the leaf text node at the offset, and then proceeds to insert text.

oyeanuj and others added 6 commits January 27, 2017 20:20
* ianstormtaylor/master:
  Clarifying insertTextByKey description (ianstormtaylor#778)
  Documenting node's 'getFirstText' & 'getLastText' (ianstormtaylor#779)
  0.19.22
  fix selection handling for changing tabs, and inside embedded inputs, closes ianstormtaylor#749
  fix to restrict window blur/focus handling, closes ianstormtaylor#773
  remove warn throwing since console.warn includes callsites now
  Update defining-custom-block-nodes.md (ianstormtaylor#776)
  0.19.21
  update table example to make scope clearer
  Fixed the link to comparisons, which was broken (ianstormtaylor#769)
  fix error when dragging void nodes without selection, closes ianstormtaylor#757
  fix to depend on prop-types for react 15.5
  fix to maintain focus on switching tabs, closes ianstormtaylor#756
  update issue template
  Add "data-key" to root div for the whole document (ianstormtaylor#759)
  add an issue template
@ianstormtaylor
Copy link
Owner

Yay! Great work @oyeanuj. Can you add a test case that covers it and then I'm super down to merge?

@oyeanuj
Copy link
Contributor Author

oyeanuj commented May 4, 2017

@ianstormtaylor Thanks! Added a test, let me know if it looks good?

@ianstormtaylor
Copy link
Owner

Hey @oyeanuj looks like a good start. I think we need to edit the test though to handle the more complex case.

Right now, since the text node being inserted into is the first and only node, the offset won't change when the new key is computed. But we should change the test case to be a block with text, inline, text and inserting into the last text node. Then i think we'll end up with a failing test case, since the offset will need to be recomputed to be relative to the new key. (Which you should be able to do adjust using the return value from block.getOffset(textKey) I think.

Let me know how that goes!

@oyeanuj
Copy link
Contributor Author

oyeanuj commented May 4, 2017

@ianstormtaylor I added a set up for a test case like you suggested. Can you take a look to make sure it (block-complex) reflects what you were thinking? If the test case looks good, I'll do the rest of testing it and fixing the failing case.

@ianstormtaylor
Copy link
Owner

@oyeanuj Looks good!

I think we should also change the tests to not use insertBlock. Instead, they can use document.getBlocks().first() or similar to get the block they need, and insert text into it. That way they are doing less.

@oyeanuj
Copy link
Contributor Author

oyeanuj commented May 7, 2017

Hey Ian, so I added the test case that we discussed and it didn't fail. So clearly I misunderstood your comment above - can you take a look and tell me what were you expecting instead?

@ianstormtaylor
Copy link
Owner

Hey @oyeanuj I'm not sure what I was talking about.

I'm sorry for the slowness on this. Since this has been opened, it seems like we've had other issues where using offsets isn't the most robust, so I think I'd like to wait to merge this until we get those figured out. Right now we'd been trying to remove all offset-use-across-depths from the codebase I believe, so I'd rather not reintroduce one yet.

@oyeanuj
Copy link
Contributor Author

oyeanuj commented Sep 5, 2017

@ianstormtaylor That makes sense, happy to wait!

@ianstormtaylor
Copy link
Owner

As of #3093 (which was just merged), I believe this issue is no longer applicable, because a lot has changed. I'm going through and closing out any potential issues that are not out of date with the overhaul. Thanks for understanding.

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