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

moveToRangeOfNode not working after updating to 0.42.2 #2289

Closed
crisward opened this issue Oct 21, 2018 · 4 comments
Closed

moveToRangeOfNode not working after updating to 0.42.2 #2289

crisward opened this issue Oct 21, 2018 · 4 comments

Comments

@crisward
Copy link
Contributor

Current Behaviour (0.42.2)

https://jsfiddle.net/fj9dvhom/2524/

   this.editor.change((change)=>{
      var node = change.value.startBlock;
      change.replaceNodeByKey(node.key,insertblock).moveToRangeOfNode(insertblock)
    })

moveToRangeOfNode causes a node.getFirstText is not a function error

Previous Behaviour (0.41.2)

Previous version would work. However I used to get change from the value, and there was no wrapping function. But the below added the new node and selected it.

  var node = change.value.startBlock;
  var change = this.props.value.change();
  change.replaceNodeByKey(node.key,insertblock).moveToRangeOfNode(insertblock);       

Not sure if it makes any difference, but the insertblock in my production code comes from the html-parser.

@ericedem
Copy link
Contributor

ericedem commented Oct 22, 2018

I can repro this with a test case:

/** @jsx h */

import h from '../../../helpers/h'

export default function(change) {
  change.replaceNodeByKey('a', { object: 'block', type: 'quote' })
}

export const input = (
  <value>
    <document>
      <paragraph key="a">one</paragraph>
    </document>
  </value>
)

export const output = (
  <value>
    <document>
      <quote />
    </document>
  </value>
)

Looks related to: #2279

@crisward
Copy link
Contributor Author

Just to clarify, in my code, it works when just using replaceNodeByKey, it's the moveToRangeOfNode which causes the error.

@ianstormtaylor
Copy link
Owner

If the insertBlock doesn't have any text nodes this might throw.

One solution would be to change moveToRangeOfNode-type commands to act on keys instead of node objects, since in this case the node object is out of date, which is why there is still no text node to select.

@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

No branches or pull requests

3 participants