Skip to content

Instantly share code, notes, and snippets.

View elvhack's full-sized avatar

Eroglu Elvan elvhack

  • Paris
View GitHub Profile
@bengotow
bengotow / linkify-plugin.js
Last active December 23, 2022 15:33
A Linkify plugin for DraftJS that creates / syncs entities on the fly
import React from 'react';
import { RichUtils, Modifier, EditorState, SelectionState } from 'draft-js';
function isURL(text) {
return text.startsWith('http://'); // insert your favorite library here
}
/*
Function you can call from your toolbar or "link button" to manually linkify
the selected text with an "explicit" flag that prevents autolinking from
changing the URL if the user changes the link text.