How to use the draft-js-plugins-utils.createLinkAtSelection function in draft-js-plugins-utils

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();
  };

draft-js-plugins-utils

Plugin utilities for draft js

MIT
Latest version published 6 years ago

Package Health Score

72 / 100
Full package analysis