How to use draft-js-plugins-utils - 10 common examples

To help you get started, we’ve selected a few draft-js-plugins-utils 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 mimecuvalo / helloworld / packages / hello-world-editor / Editor.js View on Github external
const handlePastedText = async (text, html, newEditorState) => {
    const potentialLink = text.match(/^https?:\/\//) || text.match(/^
github plone / volto / src / components / manage / AnchorPlugin / components / LinkButton / AddLinkForm.jsx View on Github external
onSubmit() {
    const { getEditorState, setEditorState } = this.props;
    let { value: url } = this.state;
    if (!URLUtils.isMail(URLUtils.normaliseMail(url))) {
      url = URLUtils.normalizeUrl(url);
      if (!URLUtils.isUrl(url)) {
        this.setState({ isInvalid: true });
        return;
      }
    } else {
      url = URLUtils.normaliseMail(url);
    }
    setEditorState(EditorUtils.createLinkAtSelection(getEditorState(), url));
    this.input.blur();
    this.onClose();
  }
github draft-js-plugins / draft-js-plugins / draft-js-anchor-plugin / src / components / LinkButton / AddLinkForm.js View on Github external
submit() {
    const { getEditorState, setEditorState } = this.props;
    let { value: url } = this.state;
    if (!URLUtils.isMail(URLUtils.normaliseMail(url))) {
      url = URLUtils.normalizeUrl(url);
      if (!URLUtils.isUrl(url)) {
        this.setState({ isInvalid: true });
        return;
      }
    } else {
      url = URLUtils.normaliseMail(url);
    }
    setEditorState(EditorUtils.createLinkAtSelection(getEditorState(), url));
    this.input.blur();
    this.onClose();
  }
github plone / volto / src / components / manage / AnchorPlugin / components / LinkButton / AddLinkForm.jsx View on Github external
onSelectItem = (e, url) => {
    e.preventDefault();
    this.setState({
      value: url,
      isInvalid: false,
    });
    this.props.resetSearchContent();
    this.props.setEditorState(
      EditorUtils.createLinkAtSelection(this.props.getEditorState(), url),
    );
    this.input.blur();
    this.onClose();
  };
github LessWrong2 / Lesswrong2 / packages / lesswrong / components / async / editor-plugins / sidenote-plugin / SidenoteButton.jsx View on Github external
isSidenoteEntityActive = () => {
    return EditorUtils.hasEntity(this.props.getEditorState(), 'SIDENOTE');
  }
github draft-js-plugins / draft-js-plugins / draft-js-anchor-plugin / src / components / LinkButton / index.js View on Github external
render() {
    const { theme, onRemoveLinkAtSelection } = this.props;
    const hasLinkSelected = EditorUtils.hasEntity(
      this.props.store.getEditorState(),
      'LINK'
    );
    const className = hasLinkSelected
      ? clsx(theme.button, theme.active)
      : theme.button;

    return (
      <div>
        <button type="button"></button></div>
github LessWrong2 / Lesswrong2 / packages / lesswrong / components / async / editor-plugins / LinkButton / index.js View on Github external
render() {
    const { theme } = this.props;
    const hasLinkSelected = EditorUtils.hasEntity(
      this.props.getEditorState(),
      'LINK'
    );
    const className = hasLinkSelected
      ? unionClassNames(theme.button, theme.active)
      : theme.button;

    return (
      <div>
        </div>
github LessWrong2 / Lesswrong2 / packages / lesswrong / components / async / editor-plugins / sidenote-plugin / index.js View on Github external
const isSidenoteSelected = (editorState) => {
  return EditorUtils.hasEntity(editorState, 'SIDENOTE');
}
github plone / volto / src / components / manage / AnchorPlugin / components / LinkButton / index.jsx View on Github external
render() {
    const { theme, onRemoveLinkAtSelection } = this.props;
    const hasLinkSelected = EditorUtils.hasEntity(
      this.props.store.getEditorState(),
      'LINK',
    );
    const className = hasLinkSelected
      ? unionClassNames(theme.button, theme.active)
      : theme.button;

    return (
      <div role="presentation">
        </div>
github LessWrong2 / Lesswrong2 / packages / lesswrong / components / async / editor-plugins / LinkButton / index.js View on Github external
onRemoveLinkAtSelection = () => this.props.setEditorState(
    EditorUtils.removeLinkAtSelection(this.props.getEditorState())
  )

draft-js-plugins-utils

Plugin utilities for draft js

MIT
Latest version published 6 years ago

Package Health Score

72 / 100
Full package analysis