How to use the slate.Block.create 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 howtocards / frontend / src / lib / rich-text / extensions / hot-keys / code-block / on-paste-code-block.js View on Github external
const deserializeCode = (opts, text) => {
  const sep = detectNewline(text) || DEFAULT_NEWLINE

  const lines = List(text.split(sep)).map((line) =>
    Block.create({
      type: opts.line,
      nodes: [Text.create(line)],
    }),
  )

  const code = Block.create({
    type: opts.block,
    nodes: lines,
  })

  return code
}
github howtocards / frontend / src / lib / rich-text / extensions / hot-keys / code-block / on-paste-code-block.js View on Github external
const lines = List(text.split(sep)).map((line) =>
    Block.create({
      type: opts.line,
      nodes: [Text.create(line)],
    }),
  )
github olymp / olymp / packages / slate / add-block.es6 View on Github external
const createBlock = (block) => {
  let { type } = block;
  const { isVoid, key, kind, data } = block;
  if (!type) {
    type = key;
  }
  if (kind === 'inline' || (!kind && isVoid)) {
    return Inline.create({
      type,
      isVoid,
      kind,
      data: data || {},
    });
  }
  return Block.create({
    type,
    isVoid,
    kind,
    data: data || {},
  });
};
export default addBlock;
github GitbookIO / slate-edit-table / lib / schema / validateNode.js View on Github external
function makeEmptyRow(opts: Options): Block {
    return Block.create({
        type: opts.typeRow,
        nodes: List([makeEmptyCell(opts)])
    });
}
github netlify / netlify-cms / packages / netlify-cms-widget-markdown / src / MarkdownControl / VisualEditor.js View on Github external
const createEmptyRawDoc = () => {
  const emptyText = Text.create('');
  const emptyBlock = Block.create({ object: 'block', type: 'paragraph', nodes: [emptyText] });
  return { nodes: [emptyBlock] };
};
github orbiting / publikator-frontend / components / editor / modules / article / collection.js View on Github external
return () =>
    Block.create({
      kind: 'block',
      type: options.TYPE,
      nodes: [
        Block.create({
          kind: 'block',
          type: headerModule.TYPE,
        }),
        articleGroupModule.helpers.newItem(),
      ],
    })
}
github orbiting / publikator-frontend / components / editor / modules / infobox / ui.js View on Github external
const infoBoxButtonClickHandler = (value, onChange) => event => {
    event.preventDefault()
    return onChange(
      value
        .change()
        .call(
          injectBlock,
          Block.create({
            type: TYPE,
            nodes: [
              Block.create(titleModule.TYPE),
              Block.create(paragraphModule.TYPE)
            ]
          })
        )
    )
  }
  const insertTypes = editorOptions.insertTypes || []
github withspectrum / spectrum / src / components / editor / image-plugin.js View on Github external
normalize: (transform, document) => {
          const block = Block.create(DEFAULT_BLOCK);
          transform.insertNodeByKey(document.key, document.nodes.size, block);
        },
      },
github orbiting / publikator-frontend / components / editor / modules / article / group.js View on Github external
export const getNewBlock = options => () => {
  const [teaserModule] = options.subModules

  return Block.create({
    type: options.TYPE,
    nodes: [
      teaserModule.helpers.newItem(),
      teaserModule.helpers.newItem(),
      teaserModule.helpers.newItem()
    ]
  })
}