New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

draft-js-link-detection-plugin

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draft-js-link-detection-plugin - npm Package Compare versions

Comparing version 0.0.1-0 to 0.0.1-1

29

lib/plugin/draft-js-link-detection-plugin.d.ts

@@ -1,13 +0,22 @@

import { EditorState } from 'draft-js';
export declare function editorStateSettingExplicitLink(editorState: any, urlOrNull: any): EditorState;
export declare function editorStateSettingLink(editorState: EditorState, selection: any, data: any): EditorState;
export declare function getCurrentLinkEntityKey(editorState: any): any;
export declare function getCurrentLink(editorState: any): any;
declare const createLinkifyPlugin: () => {
import * as React from 'react';
import { EditorState, SelectionState, ContentState, ContentBlock } from 'draft-js';
declare type LinkData = {
explicit: boolean;
url: string | null;
};
export declare function editorStateSettingLink(editorState: EditorState, selection: SelectionState, data: LinkData): EditorState;
export declare function getCurrentLinkEntityKey(editorState: EditorState): string | null;
export declare function getCurrentLink(editorState: EditorState): any;
interface LinkProps {
contentState: ContentState;
entityKey: string;
}
declare function findLinkEntities(contentBlock: ContentBlock, callback: (start: number, end: number) => void, contentState: ContentState): void;
declare const createLinkDetectionPlugin: () => {
decorators: {
strategy: (contentBlock: any, callback: any, contentState: any) => void;
component: (props: any) => JSX.Element;
strategy: typeof findLinkEntities;
component: React.FC<LinkProps>;
}[];
onChange: (editorState: any) => any;
onChange: (editorState: EditorState) => EditorState;
};
export default createLinkifyPlugin;
export default createLinkDetectionPlugin;

@@ -25,3 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getCurrentLink = exports.getCurrentLinkEntityKey = exports.editorStateSettingLink = exports.editorStateSettingExplicitLink = void 0;
exports.getCurrentLink = exports.getCurrentLinkEntityKey = exports.editorStateSettingLink = void 0;
var React = __importStar(require("react"));

@@ -31,9 +31,2 @@ var draft_js_1 = require("draft-js");

var getUrlFromString_1 = __importDefault(require("../utils/getUrlFromString"));
function editorStateSettingExplicitLink(editorState, urlOrNull) {
return editorStateSettingLink(editorState, editorState.getSelection(), {
url: urlOrNull,
explicit: true,
});
}
exports.editorStateSettingExplicitLink = editorStateSettingExplicitLink;
function editorStateSettingLink(editorState, selection, data) {

@@ -67,3 +60,3 @@ var contentState = editorState.getCurrentContent();

var block = contentState.getBlockForKey(startKey);
var linkKey = block.getEntityAt(Math.min(block.text.length - 1, startOffset));
var linkKey = block.getEntityAt(Math.min(block.getText().length - 1, startOffset));
if (linkKey) {

@@ -87,20 +80,20 @@ var linkInstance = contentState.getEntity(linkKey);

exports.getCurrentLink = getCurrentLink;
var createLinkifyPlugin = function () {
var Link = function (props) {
var data = props.data || props.contentState.getEntity(props.entityKey).getData();
var url = data.url;
if (!url) {
return React.createElement("span", null, props.children);
}
return (React.createElement("a", { href: url, title: url }, props.children));
};
function findLinkEntities(contentBlock, callback, contentState) {
contentBlock.findEntityRanges(function (character) {
var entityKey = character.getEntity();
if (!entityKey)
return;
var entity = contentState.getEntity(entityKey);
return entity.getType() === 'LINK' && entity.getData().url;
}, callback);
var Link = function (props) {
var data = props.contentState.getEntity(props.entityKey).getData();
var url = data.url;
if (!url) {
return React.createElement("span", null, props.children);
}
return (React.createElement("a", { href: url, title: url }, props.children));
};
function findLinkEntities(contentBlock, callback, contentState) {
contentBlock.findEntityRanges(function (character) {
var entityKey = character.getEntity();
if (!entityKey)
return;
var entity = contentState.getEntity(entityKey);
return entity.getType() === 'LINK' && entity.getData().url;
}, callback);
}
var createLinkDetectionPlugin = function () {
return {

@@ -122,6 +115,6 @@ decorators: [

var cursorBlock = contentState.getBlockForKey(cursorBlockKey);
if (cursorBlock.type !== 'unstyled') {
if (cursorBlock.getType() !== 'unstyled') {
return editorState;
}
var text = cursorBlock.text;
var text = cursorBlock.getText();
var currentWordStart = text.lastIndexOf(' ', cursorOffset) + 1;

@@ -137,3 +130,3 @@ var currentWordEnd = text.indexOf(' ', cursorOffset);

if (inst && inst.getType() !== 'LINK') {
currentLinkEntityKey = null;
currentLinkEntityKey = '';
}

@@ -190,2 +183,2 @@ if (currentLinkEntityKey) {

};
exports.default = createLinkifyPlugin;
exports.default = createLinkDetectionPlugin;
{
"name": "draft-js-link-detection-plugin",
"version": "0.0.1-0",
"version": "0.0.1-1",
"description": "draft-js-link-detection-plugin",
"keywords": [
"draft-js",
"draft-js-plugin",
"react",
"typescript",
"draft-js",
"draft-js-plugin"
"typescript"
],

@@ -24,11 +24,11 @@ "homepage": "https://github.com/fedorovsky/draft-js-link-detection-plugin",

"scripts": {
"build": "npm-run-all clean tsc",
"clean": "rimraf ./lib",
"lint": "eslint \"src/**/**.{ts,tsx}\"",
"prepublishOnly": "npm run build",
"prettier": "prettier --write \"**/*.{ts,tsx}\"",
"storybook": "start-storybook --port 5000",
"test": "jest --coverage --verbose",
"tsc": "tsc",
"tsc:watch": "tsc -w",
"build": "npm-run-all clean tsc",
"storybook": "start-storybook --port 5000",
"prettier": "prettier --write \"**/*.{ts,tsx}\"",
"lint": "eslint \"src/**/**.{ts,tsx}\"",
"clean": "rimraf ./lib",
"prepublishOnly": "npm run build"
"tsc:watch": "tsc -w"
},

@@ -35,0 +35,0 @@ "dependencies": {

@@ -23,3 +23,3 @@ {

"emitDecoratorMetadata": true,
"noImplicitAny": false
"noImplicitAny": true
},

@@ -26,0 +26,0 @@ "include": ["src/**/*", "*.d.ts"],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc