How to use the slate.createEditor 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 ianstormtaylor / slate / packages / slate-hyperscript / src / creators.ts View on Github external
children: any[]
): Editor {
  const otherChildren: any[] = []
  let selectionChild: Range | undefined

  for (const child of children) {
    if (Range.isRange(child)) {
      selectionChild = child
    } else {
      otherChildren.push(child)
    }
  }

  const descendants = resolveDescendants(otherChildren)
  const selection: Partial = {}
  const editor = makeEditor()
  Object.assign(editor, attributes)
  editor.children = descendants

  // Search the document's texts to see if any of them have tokens associated
  // that need incorporated into the selection.
  for (const [node, path] of Node.texts(editor)) {
    const anchor = getAnchorOffset(node)
    const focus = getFocusOffset(node)

    if (anchor != null) {
      const [offset] = anchor
      selection.anchor = { path, offset }
    }

    if (focus != null) {
      const [offset] = focus
github ianstormtaylor / slate / site / examples / forced-layout.js View on Github external
    () => withLayout(withHistory(withReact(createEditor()))),
    []
github ianstormtaylor / slate / site / examples / tables.js View on Github external
    () => withTables(withHistory(withReact(createEditor()))),
    []
github ianstormtaylor / slate / site / examples / hovering-toolbar.js View on Github external
  const editor = useMemo(() => withHistory(withReact(createEditor())), [])
github ianstormtaylor / slate / site / examples / markdown-preview.js View on Github external
  const editor = useMemo(() => withHistory(withReact(createEditor())), [])
  const decorate = useCallback(([node, path]) => {
github ianstormtaylor / slate / site / examples / richtext.js View on Github external
  const editor = useMemo(() => withHistory(withReact(createEditor())), [])
github ianstormtaylor / slate / site / examples / paste-html.js View on Github external
    () => withHtml(withReact(withHistory(createEditor()))),
    []
github ianstormtaylor / slate / site / examples / images.js View on Github external
    () => withImages(withHistory(withReact(createEditor()))),
    []
github ianstormtaylor / slate / site / examples / markdown-shortcuts.js View on Github external
    () => withShortcuts(withReact(withHistory(createEditor()))),
    []
github ianstormtaylor / slate / site / examples / read-only.js View on Github external
  const editor = useMemo(() => withReact(createEditor()), [])
  return (