How to use the slate-react.useSlate function in slate-react

To help you get started, we’ve selected a few slate-react 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 / site / examples / richtext.js View on Github external
const BlockButton = ({ format, icon }) => {
  const editor = useSlate()
  return (
    <button> {
        event.preventDefault()
        toggleBlock(editor, format)
      }}
    &gt;
      {icon}
    </button>
  )
}
github compute-tooling / compute-studio / src / Simulation / editor.tsx View on Github external
const LinkButton: React.FC&lt;{ icon: IconDefinition }&gt; = ({ icon }) =&gt; {
  const editor = useSlate();
  const active = Controller.isBlockActive(editor, "link");
  return (
    <button style="{{" size="sm"> {
        event.preventDefault()
        const url = window.prompt('Enter the URL of the link:')
        if (!url) return
        Controller.insertLink(editor, url);
      }}
    &gt;
      
    </button>
  )
github ianstormtaylor / slate / site / examples / richtext.js View on Github external
const MarkButton = ({ format, icon }) =&gt; {
  const editor = useSlate()
  return (
    <button> {
        event.preventDefault()
        toggleMark(editor, format)
      }}
    &gt;
      {icon}
    </button>
  )
}
github ianstormtaylor / slate / site / examples / hovering-toolbar.js View on Github external
const FormatButton = ({ format, icon }) =&gt; {
  const editor = useSlate()
  return (
    <button reversed=""> {
        event.preventDefault()
        toggleFormat(editor, format)
      }}
    &gt;
      {icon}
    </button>
  )
}
github redwood / redwood / demos / desktop-chat-app / frontend / src / components / TextBox / Toolbar.jsx View on Github external
const FormatButton = ({ format, icon, toggleFormat, isFormatActive }) =&gt; {
  const editor = useSlate()
  return (
     {
        event.preventDefault()
        toggleFormat(editor, format)
      }}
    &gt;
      {icon}
    
  )
}
github edtr-io / edtr-io / packages / plugins / text / src / helpers.ts View on Github external
export function useEditor(): Editor {
  return useSlate() as Editor
}
github ianstormtaylor / slate / site / examples / links.js View on Github external
const LinkButton = () =&gt; {
  const editor = useSlate()
  return (
    <button> {
        event.preventDefault()
        const url = window.prompt('Enter the URL of the link:')
        if (!url) return
        insertLink(editor, url)
      }}
    &gt;
      link
    </button>
  )
}
github compute-tooling / compute-studio / src / Simulation / editor.tsx View on Github external
const MarkButton: React.FC&lt;{ mark: Mark, icon: IconDefinition }&gt; = ({ mark, icon }) =&gt; {
  const editor = useSlate();
  const active = Controller.isMarkActive(editor, mark);
  return (
    <button style="{{" size="sm"> {
        event.preventDefault();
        Controller.toggleMark(editor, mark);
      }}
    &gt;
      
    </button>
  )
}
github Sefaria / Sefaria-Project / static / js / Editor.jsx View on Github external
const FormatButton = ({format}) =&gt; {
    const editor = useSlate()

    const isActive = isFormatActive(editor, format);
    const iconName = "fa-" + format;
    const classes = {fa: 1, active: isActive};
    classes[iconName] = 1;

    return (
        <span> {
                  event.preventDefault();
                  toggleFormat(editor, format);
              }}
        &gt;
      <i>
    </i></span><i>
    )</i>
github compute-tooling / compute-studio / src / Simulation / editor.tsx View on Github external
const BlockButton: React.FC&lt;{ block: Block, icon: IconDefinition }&gt; = ({ block, icon }) =&gt; {
  const editor = useSlate();
  const active = Controller.isBlockActive(editor, block);
  return (
    <button style="{{" size="sm"> {
        event.preventDefault();
        Controller.toggleBlock(editor, block);
      }}
    &gt;
      
    </button>
  )
}