How to use the slate.Raw.deserializeNode function in slate

To help you get started, we’ve selected a few slate 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 olymp / olymp / packages / slate / utils / add-block.tsx View on Github external
const createP = () =>
  Raw.deserializeNode({
    kind: 'block',
    type: 'paragraph',
    nodes: [{ kind: 'text', text: '', ranges: [] }],
  });
github olymp / olymp / src / slate / block-decorators / toolbar / toolbar.js View on Github external
toggle: ({ key }) => {
      const p = Raw.deserializeNode({ kind: 'block', type: 'line', nodes: [{ kind: 'text', text: '', ranges: [] }] });
      if (key === '+<<') {
        const parent = state.document.getParent(node.key) || node;
        editor.onChange(
          state.transform()
            .insertNodeByKey(parent.key, parent.nodes.indexOf(node), p)
            .apply()
        );
      } else if (key === '-<<') {
        editor.onChange(
          state.transform()
            .removeNodeByKey(prev.key)
            .apply()
        );
      } else if (key === '+>>') {
        const parent = state.document.getParent(node.key) || node;
        editor.onChange(
github olymp / olymp / src / cms / slate / utils / add-block.js View on Github external
const createP = () => Raw.deserializeNode({ kind: 'block', type: 'paragraph', nodes: [{ kind: 'text', text: '', ranges: [] }] });
github olymp / olymp / packages / slate / utils / create-list.tsx View on Github external
const empty = () =>
  Raw.deserializeNode({
    kind: 'block',
    type: 'paragraph',
    nodes: [{ kind: 'text', text: '', ranges: [] }],
  });
export default items =>
github olymp / olymp / packages / slate / utils / create-list.js View on Github external
const empty = () =>
  Raw.deserializeNode({
    kind: 'block',
    type: 'paragraph',
    nodes: [{ kind: 'text', text: '', ranges: [] }],
  });
export default items =>
github sanity-io / sanity / packages / @sanity / block-editor / src / SlateValueContainer.js View on Github external
setIndex(index, item) {
    const nextDocument = this.document.setIn(['nodes', index], Raw.deserializeNode(sanityBlockNodeToSlateRaw(item)))
    return new SlateValueContainer(nextDocument, this.context)
  }
github olymp / olymp / src / cms / slate / block-decorators / toolbar.js View on Github external
toggle: ({ key }) => {
      const p = Raw.deserializeNode({ kind: 'block', type: 'paragraph', nodes: [{ kind: 'text', text: '', ranges: [] }] });
      if (key === '+<<') {
        const parent = state.document.getParent(node.key) || node;
        editor.onChange(
          state.transform()
            .insertNodeByKey(parent.key, parent.nodes.indexOf(node), p)
            .apply()
        );
      } else if (key === '-<<') {
        editor.onChange(
          state.transform()
            .removeNodeByKey(prev.key)
            .apply()
        );
      } else if (key === '+>>') {
        const parent = state.document.getParent(node.key) || node;
        editor.onChange(
github sanity-io / sanity / packages / @sanity / block-editor / src / SlateValueContainer.js View on Github external
    const insertNodes = jsonNodes.map(node => Raw.deserializeNode(nodeToRaw(node)))
github olymp / olymp / src / slate / block-decorators / toolbar.js View on Github external
toggle: ({ key }) => {
      const p = Raw.deserializeNode({ kind: 'block', type: 'paragraph', nodes: [{ kind: 'text', text: '', ranges: [] }] });
      if (key === '+<<') {
        const parent = state.document.getParent(node.key) || node;
        editor.onChange(
          state.transform()
            .insertNodeByKey(parent.key, parent.nodes.indexOf(node), p)
            .apply()
        );
      } else if (key === '-<<') {
        editor.onChange(
          state.transform()
            .removeNodeByKey(prev.key)
            .apply()
        );
      } else if (key === '+>>') {
        const parent = state.document.getParent(node.key) || node;
        editor.onChange(
github sanity-io / sanity / packages / @sanity / form-builder / src / inputs / BlockEditor-slate / SlateValueContainer.js View on Github external
setIndex(index, item) {
    const nextDocument = this.document.setIn(['nodes', index], Raw.deserializeNode(sanityBlockNodeToSlateRaw(item)))
    return new SlateValueContainer(nextDocument, this.context)
  }