How to use the @sanity/block-tools.blocksToSlateState function in @sanity/block-tools

To help you get started, we’ve selected a few @sanity/block-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanity-io / sanity / packages / @sanity / form-builder / src / inputs / BlockEditor-slate / Syncer.js View on Github external
function deserialize(value, type) {
  return State.fromJSON(blockTools.blocksToSlateState(value, type))
}
github sanity-io / sanity / packages / @sanity / form-builder / src / inputs / BlockEditor-slate / plugins / onPasteHtml.js View on Github external
function onPaste(event, data, change) {
    if (data.type != 'html') {
      return null
    }
    if (data.isShift) {
      return null
    }
    const blockContentType = blockEditor.props.type
    const blocks = blockTools.htmlToBlocks(data.html, {blockContentType})
    const {document} = blockTools.blocksToSlateState(blocks, blockContentType)
    return change.insertFragment(Document.fromJSON(document))
  }