From cb00f943d4813bb5d0a43fdc581e0f984c89e582 Mon Sep 17 00:00:00 2001 From: Dobes Vandermeer Date: Fri, 19 Jul 2019 11:11:31 -0700 Subject: [PATCH] Add some typescript typings Add typescript typings for the core components and some of the plugins. This can serve as a starting point for adding types to the other plugins. --- .eslintignore | 1 + draft-js-anchor-plugin/package.json | 4 +- draft-js-anchor-plugin/src/index.d.ts | 19 +++++ draft-js-buttons/package.json | 5 +- draft-js-buttons/src/index.d.ts | 59 +++++++++++++ draft-js-drag-n-drop-plugin/package.json | 4 +- draft-js-drag-n-drop-plugin/src/index.d.ts | 9 ++ draft-js-emoji-plugin/package.json | 4 +- draft-js-emoji-plugin/src/index.d.ts | 84 +++++++++++++++++++ draft-js-focus-plugin/package.json | 4 +- draft-js-focus-plugin/src/index.d.ts | 8 ++ draft-js-image-plugin/package.json | 4 +- draft-js-image-plugin/src/index.d.ts | 26 ++++++ draft-js-inline-toolbar-plugin/package.json | 4 +- draft-js-inline-toolbar-plugin/src/index.d.ts | 42 ++++++++++ draft-js-plugins-editor/package.json | 4 +- draft-js-plugins-editor/src/index.d.ts | 68 +++++++++++++++ draft-js-resizeable-plugin/package.json | 4 +- draft-js-resizeable-plugin/src/index.d.ts | 8 ++ package.json | 1 + yarn.lock | 79 ++++++++++++++++- 21 files changed, 429 insertions(+), 12 deletions(-) create mode 100644 draft-js-anchor-plugin/src/index.d.ts create mode 100644 draft-js-buttons/src/index.d.ts create mode 100644 draft-js-drag-n-drop-plugin/src/index.d.ts create mode 100644 draft-js-emoji-plugin/src/index.d.ts create mode 100644 draft-js-focus-plugin/src/index.d.ts create mode 100644 draft-js-image-plugin/src/index.d.ts create mode 100644 draft-js-inline-toolbar-plugin/src/index.d.ts create mode 100644 draft-js-plugins-editor/src/index.d.ts create mode 100644 draft-js-resizeable-plugin/src/index.d.ts diff --git a/.eslintignore b/.eslintignore index 805901cf02..c7b8986c77 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,3 +4,4 @@ lib/** draft-js-*/lib/** scripts/** docs/build/** +*.d.ts diff --git a/draft-js-anchor-plugin/package.json b/draft-js-anchor-plugin/package.json index d519b398ac..b1f292d53d 100644 --- a/draft-js-anchor-plugin/package.json +++ b/draft-js-anchor-plugin/package.json @@ -12,6 +12,7 @@ "url": "https://github.com/draft-js-plugins/draft-js-plugins.git" }, "main": "lib/index.js", + "types": "lib/index.d.ts", "keywords": [ "editor", "wysiwyg", @@ -25,9 +26,10 @@ ], "scripts": { "clean": "../node_modules/.bin/rimraf lib", - "build": "npm run clean && npm run build:js && npm run build:css", + "build": "npm run clean && npm run build:js && npm run build:css && npm run build:ts", "build:js": "WEBPACK_CONFIG=$(pwd)/webpack.config.js BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__test__/*' src", "build:css": "node ../scripts/concatCssFiles $(pwd) && ../node_modules/.bin/rimraf lib-css", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-anchor-plugin/src/index.d.ts b/draft-js-anchor-plugin/src/index.d.ts new file mode 100644 index 0000000000..76ce5f92b7 --- /dev/null +++ b/draft-js-anchor-plugin/src/index.d.ts @@ -0,0 +1,19 @@ +import { EditorPlugin } from "draft-js-plugins-editor"; +import { AnchorHTMLAttributes, ComponentType } from "react"; + +export interface AnchorPluginTheme { + link?: string; + input?: string; + inputInvalid?: string; +} + +export interface AnchorPluginConfig { + theme?: AnchorPluginTheme; + placeholder?: string; + Link?: ComponentType>; + linkTarget?: string; +} + +declare const createAnchorPlugin: (config: AnchorPluginConfig) => EditorPlugin; + +export default createAnchorPlugin; diff --git a/draft-js-buttons/package.json b/draft-js-buttons/package.json index 9ece855ed4..46f61e5258 100644 --- a/draft-js-buttons/package.json +++ b/draft-js-buttons/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/draft-js-plugins/draft-js-plugins.git" }, "main": "lib/index.js", + "types": "lib/index.d.ts", "keywords": [ "editor", "wysiwyg", @@ -22,7 +23,9 @@ "react-component" ], "scripts": { - "build": "BABEL_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__tests__/*' src", + "build": "npm run build:js && npm run build:ts", + "build:js": "BABEL_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__tests__/*' src", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-buttons/src/index.d.ts b/draft-js-buttons/src/index.d.ts new file mode 100644 index 0000000000..c1571b57e4 --- /dev/null +++ b/draft-js-buttons/src/index.d.ts @@ -0,0 +1,59 @@ +import { EditorState } from "draft-js"; +import { ComponentType, ReactNode } from "react"; + +export interface DraftJsButtonTheme { + // CSS classes to apply + active: string; + button: string; + buttonWrapper: string; +} + +export interface DraftJsButtonProps { + theme?: DraftJsButtonTheme; +} + +export interface DraftJsBlockAlignmentButtonProps extends DraftJsButtonProps { + alignment: string; + + setAlignment(alignment: string): void; +} + +type DraftJsBlockAlignmentButtonType = ComponentType< + DraftJsBlockAlignmentButtonProps +>; + +export const AlignBlockCenterButton: DraftJsBlockAlignmentButtonType; +export const AlignBlockDefaultButton: DraftJsBlockAlignmentButtonType; +export const AlignBlockLeftButton: DraftJsBlockAlignmentButtonType; +export const AlignBlockRightButton: DraftJsBlockAlignmentButtonType; + +export interface DraftJsStyleButtonProps extends DraftJsButtonProps { + setEditorState(editorState: EditorState): void; + + getEditorState(): EditorState; +} + +type DraftJsStyleButtonType = ComponentType; + +export const createBlockStyleButton: ( + alignment: string, + children: ReactNode +) => DraftJsStyleButtonType; +export const createInlineStyleButton: ( + alignment: string, + children: ReactNode +) => DraftJsStyleButtonType; + +export const BlockquoteButton: DraftJsStyleButtonType; +export const BoldButton: DraftJsStyleButtonType; +export const CodeBlockButton: DraftJsStyleButtonType; +export const CodeButton: DraftJsStyleButtonType; +export const HeadlineOneButton: DraftJsStyleButtonType; +export const HeadlineThreeButton: DraftJsStyleButtonType; +export const HeadlineTwoButton: DraftJsStyleButtonType; +export const ItalicButton: DraftJsStyleButtonType; +export const OrderedListButton: DraftJsStyleButtonType; +export const SubButton: DraftJsStyleButtonType; +export const SupButton: DraftJsStyleButtonType; +export const UnderlineButton: DraftJsStyleButtonType; +export const UnorderedListButton: DraftJsStyleButtonType; diff --git a/draft-js-drag-n-drop-plugin/package.json b/draft-js-drag-n-drop-plugin/package.json index 22c7cb0cc9..93da70f6bd 100644 --- a/draft-js-drag-n-drop-plugin/package.json +++ b/draft-js-drag-n-drop-plugin/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/draft-js-plugins/draft-js-plugins.git" }, "main": "lib/index.js", + "types": "lib/index.d.ts", "keywords": [ "editor", "wysiwyg", @@ -23,8 +24,9 @@ ], "scripts": { "clean": "../node_modules/.bin/rimraf lib", - "build": "npm run clean && npm run build:js", + "build": "npm run clean && npm run build:js && npm run build:ts", "build:js": "WEBPACK_CONFIG=$(pwd)/webpack.config.js BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__test__/*' src", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-drag-n-drop-plugin/src/index.d.ts b/draft-js-drag-n-drop-plugin/src/index.d.ts new file mode 100644 index 0000000000..2e707df6e5 --- /dev/null +++ b/draft-js-drag-n-drop-plugin/src/index.d.ts @@ -0,0 +1,9 @@ +import { DraftDecorator } from "draft-js"; +import { EditorPlugin } from "draft-js-plugins-editor"; + +type DragNDropEditorPlugin = EditorPlugin & { + decorator: DraftDecorator; +}; + +declare const createBlockDndPlugin: () => DragNDropEditorPlugin; +export default createBlockDndPlugin; diff --git a/draft-js-emoji-plugin/package.json b/draft-js-emoji-plugin/package.json index f1968cb180..32e76a2755 100644 --- a/draft-js-emoji-plugin/package.json +++ b/draft-js-emoji-plugin/package.json @@ -12,6 +12,7 @@ "url": "https://github.com/draft-js-plugins/draft-js-plugins.git" }, "main": "lib/index.js", + "types": "lib/index.d.ts", "keywords": [ "editor", "wysiwyg", @@ -24,9 +25,10 @@ ], "scripts": { "clean": "../node_modules/.bin/rimraf lib", - "build": "npm run clean && npm run build:js && npm run build:css", + "build": "npm run clean && npm run build:js && npm run build:css && npm run build:ts", "build:js": "WEBPACK_CONFIG=$(pwd)/webpack.config.js BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__test__/*' src", "build:css": "node ../scripts/concatCssFiles $(pwd) && ../node_modules/.bin/rimraf lib-css", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-emoji-plugin/src/index.d.ts b/draft-js-emoji-plugin/src/index.d.ts new file mode 100644 index 0000000000..8b69c66236 --- /dev/null +++ b/draft-js-emoji-plugin/src/index.d.ts @@ -0,0 +1,84 @@ +import { EditorPlugin } from "draft-js-plugins-editor"; +import { List } from "immutable"; +import {ComponentType, CSSProperties, ReactNode} from "react"; + +export interface EmojiPluginTheme { + emoji?: string; + + emojiSuggestions?: string; + + emojiSuggestionsEntry?: string; + emojiSuggestionsEntryFocused?: string; + emojiSuggestionsEntryText?: string; + emojiSuggestionsEntryIcon?: string; + + emojiSelect?: string; + + emojiSelectButton?: string; + emojiSelectButtonPressed?: string; + + emojiSelectPopover?: string; + emojiSelectPopoverClosed?: string; + emojiSelectPopoverTitle?: string; + emojiSelectPopoverGroups?: string; + + emojiSelectPopoverGroup?: string; + emojiSelectPopoverGroupTitle?: string; + emojiSelectPopoverGroupList?: string; + emojiSelectPopoverGroupItem?: string; + + emojiSelectPopoverToneSelect?: string; + emojiSelectPopoverToneSelectList?: string; + emojiSelectPopoverToneSelectItem?: string; + + emojiSelectPopoverEntry?: string; + emojiSelectPopoverEntryFocused?: string; + emojiSelectPopoverEntryIcon?: string; + + emojiSelectPopoverNav?: string; + emojiSelectPopoverNavItem?: string; + emojiSelectPopoverNavEntry?: string; + emojiSelectPopoverNavEntryActive?: string; + + emojiSelectPopoverScrollbar?: string; + emojiSelectPopoverScrollbarThumb?: string; +} + +export interface EmojiSuggestionsState { + isActive?: boolean; + focusedOptionIndex: number; +} + +export interface EmojiSelectGroup { + title: string; + icon: ReactNode; + categories: string[]; +} + +export interface EmojiPluginConfig { + theme?: EmojiPluginTheme; + imagePath?: string; + imageType?: string; + allowImageCache?: boolean; + positionSuggestions?: (arg: { + decoratorRect: DOMRect; + popover: Element; + props: { suggestions: any[] }; + state: EmojiSuggestionsState; + filteredEmojis: List; + }) => CSSProperties; + priorityList?: { [k: string]: string | undefined }; + selectGroups?: EmojiSelectGroup[]; + selectButtonContent?: string; + toneSelectOpenDelay?: number; + useNativeArt?: boolean; +} + +type EmojiEditorPlugin = EditorPlugin & { + EmojiSuggestions: ComponentType; + EmojiSelect: ComponentType; +} + +declare const createEmojiPlugin: (config?: EmojiPluginConfig) => EmojiEditorPlugin; + +export default createEmojiPlugin; diff --git a/draft-js-focus-plugin/package.json b/draft-js-focus-plugin/package.json index 8bc322c8c4..463f7790d9 100644 --- a/draft-js-focus-plugin/package.json +++ b/draft-js-focus-plugin/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/draft-js-plugins/draft-js-plugins.git" }, "main": "lib/index.js", + "types": "lib/index.d.ts", "keywords": [ "editor", "wysiwyg", @@ -23,9 +24,10 @@ ], "scripts": { "clean": "../node_modules/.bin/rimraf lib", - "build": "npm run clean && npm run build:js && npm run build:css", + "build": "npm run clean && npm run build:js && npm run build:css && npm run build:ts", "build:js": "WEBPACK_CONFIG=$(pwd)/webpack.config.js BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__test__/*' src", "build:css": "node ../scripts/concatCssFiles $(pwd) && ../node_modules/.bin/rimraf lib-css", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-focus-plugin/src/index.d.ts b/draft-js-focus-plugin/src/index.d.ts new file mode 100644 index 0000000000..f3ee8d1958 --- /dev/null +++ b/draft-js-focus-plugin/src/index.d.ts @@ -0,0 +1,8 @@ +import { DraftDecorator } from "draft-js"; +import { EditorPlugin } from "draft-js-plugins-editor"; + +type FocusEditorPlugin = EditorPlugin & { decorator: DraftDecorator }; + +declare const createFocusPlugin: () => FocusEditorPlugin; + +export default createFocusPlugin; diff --git a/draft-js-image-plugin/package.json b/draft-js-image-plugin/package.json index 941ff62186..0562bb67e6 100644 --- a/draft-js-image-plugin/package.json +++ b/draft-js-image-plugin/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/draft-js-plugins/draft-js-plugins.git" }, "main": "lib/index.js", + "types": "lib/index.d.ts", "keywords": [ "editor", "wysiwyg", @@ -23,9 +24,10 @@ ], "scripts": { "clean": "../node_modules/.bin/rimraf lib", - "build": "npm run clean && npm run build:js && npm run build:css", + "build": "npm run clean && npm run build:js && npm run build:css && npm run build:ts", "build:js": "WEBPACK_CONFIG=$(pwd)/webpack.config.js BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__test__/*' src", "build:css": "node ../scripts/concatCssFiles $(pwd) && ../node_modules/.bin/rimraf lib-css", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-image-plugin/src/index.d.ts b/draft-js-image-plugin/src/index.d.ts new file mode 100644 index 0000000000..d9e7a4dbde --- /dev/null +++ b/draft-js-image-plugin/src/index.d.ts @@ -0,0 +1,26 @@ +import { EditorState } from "draft-js"; +import { EditorPlugin } from "draft-js-plugins-editor"; +import { ComponentType, ImgHTMLAttributes } from "react"; + +export interface ImagePluginTheme { + image: string; +} + +export interface ImagePluginConfig { + theme?: ImagePluginTheme; + imageComponent?: ComponentType>; +} + +export type ImageEditorPlugin = EditorPlugin & { + addImage: ( + editorState: EditorState, + url: string, + extraData?: object + ) => EditorState; +}; + +declare const createImagePlugin: ( + config?: ImagePluginConfig +) => ImageEditorPlugin; + +export default createImagePlugin; diff --git a/draft-js-inline-toolbar-plugin/package.json b/draft-js-inline-toolbar-plugin/package.json index d7bfd31424..06fa97327e 100644 --- a/draft-js-inline-toolbar-plugin/package.json +++ b/draft-js-inline-toolbar-plugin/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/draft-js-plugins/draft-js-plugins.git" }, "main": "lib/index.js", + "types": "lib/index.d.ts", "keywords": [ "editor", "wysiwyg", @@ -23,9 +24,10 @@ ], "scripts": { "clean": "../node_modules/.bin/rimraf lib", - "build": "npm run clean && npm run build:js && npm run build:css", + "build": "npm run clean && npm run build:js && npm run build:css && npm run build:ts", "build:js": "WEBPACK_CONFIG=$(pwd)/webpack.config.js BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__test__/*' src", "build:css": "node ../scripts/concatCssFiles $(pwd) && ../node_modules/.bin/rimraf lib-css", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-inline-toolbar-plugin/src/index.d.ts b/draft-js-inline-toolbar-plugin/src/index.d.ts new file mode 100644 index 0000000000..3b07d53ed4 --- /dev/null +++ b/draft-js-inline-toolbar-plugin/src/index.d.ts @@ -0,0 +1,42 @@ +import { EditorPlugin } from "draft-js-plugins-editor"; +import { ComponentType, ReactNode } from "react"; +import { EditorState } from "draft-js"; + +export interface InlineToolbarPluginTheme { + buttonStyles?: { + buttonWrapper?: string; + button?: string; + active?: string; + }; + toolbarStyles?: { + toolbar?: string; + }; + separatorStyles?: { + separator?: string; + }; +} + +export interface InlineToolbarPluginConfig { + theme: InlineToolbarPluginTheme; +} + +export interface ToolbarChildrenProps { + theme: InlineToolbarPluginTheme["buttonStyles"]; + getEditorState: () => EditorState; + setEditorState: (editorState: EditorState) => void; + onOverrideContent: (content: ComponentType) => void; +} + +export interface ToolbarProps { + children(externalProps: ToolbarChildrenProps): ReactNode; +} + +export type InlineToolBarPlugin = EditorPlugin & { + InlineToolbar: ComponentType; +}; + +declare const createInlineToolbarPlugin: ( + config?: InlineToolbarPluginConfig +) => InlineToolBarPlugin; + +export default createInlineToolbarPlugin; diff --git a/draft-js-plugins-editor/package.json b/draft-js-plugins-editor/package.json index 9aa3c55525..965117f7b7 100644 --- a/draft-js-plugins-editor/package.json +++ b/draft-js-plugins-editor/package.json @@ -23,7 +23,9 @@ "react-component" ], "scripts": { - "build": "BABEL_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__tests__/*' src", + "build": "npm run build:js && npm run build:ts", + "build:js": "BABEL_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__tests__/*' src ", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-plugins-editor/src/index.d.ts b/draft-js-plugins-editor/src/index.d.ts new file mode 100644 index 0000000000..674d936a6f --- /dev/null +++ b/draft-js-plugins-editor/src/index.d.ts @@ -0,0 +1,68 @@ +import { DraftDecorator, Editor, EditorProps, EditorState } from "draft-js"; +import { Component, Ref } from "react"; + +export interface PluginFunctions { + getPlugins(): EditorPlugin[]; // a function returning a list of all the plugins + getProps(): any; // a function returning a list of all the props pass into the Editor + setEditorState(editorState: EditorState): void; // a function to update the EditorState + getEditorState(): EditorState; // a function to get the current EditorState + getReadOnly(): boolean; // a function returning of the Editor is set to readOnly + setReadOnly(readOnly: boolean): void; // a function which allows to set the Editor to readOnly + getEditorRef(): Ref; // a function to get the editor reference +} + +// Plugins can define methods with the same name as props from EditorProps +type EditorMappedFunctions = { + [K in Exclude< + keyof EditorProps, + "onChange" | "decorators" + >]: EditorProps[K] extends ((a: infer A, b: infer B, c: infer C) => infer R) + ? (a: A, b: B, c: C, pluginFunctions: PluginFunctions) => R + : EditorProps[K] extends ((a: infer A, b: infer B) => infer R) + ? (a: A, b: B, pluginFunctions: PluginFunctions) => R + : EditorProps[K] extends ((a: infer A) => infer R) + ? (a: A, pluginFunctions: PluginFunctions) => R + : EditorProps[K] extends (() => infer R) + ? (pluginFunctions: PluginFunctions) => R + : never; +}; + +export interface EditorPluginProps { + decorators?: DraftDecorator[]; + getAccessibilityProps?: () => { + ariaHasPopup: string; + ariaExpanded: string; + }; + initialize?: (pluginFunctions: PluginFunctions) => void; + onChange?: ( + editorState: EditorState, + pluginFunctions: PluginFunctions + ) => EditorState; + willUnmount?: (funcs: PluginFunctions) => void; +} + +export type EditorPlugin = EditorMappedFunctions & EditorPluginProps; + +export const composeDecorators: ( + ...decorators: DraftDecorator[] +) => DraftDecorator; + +export interface PluginEditorProps extends EditorProps { + plugins?: EditorPlugin[]; + defaultKeyBindings?: boolean; + defaultKeyCommands?: boolean; + defaultBlockRenderMap?: boolean; + + // eslint-disable-next-line react/no-unused-prop-types + decorators?: DraftDecorator[]; +} + +declare class PluginEditor extends Component { + focus(): void; + blur(): void; + getPlugins(): EditorPlugin[]; + getPluginMethods(): PluginFunctions; + getEditorRef(): Editor | undefined; +} + +export default PluginEditor; diff --git a/draft-js-resizeable-plugin/package.json b/draft-js-resizeable-plugin/package.json index a47ea291b9..79fb0c9b93 100644 --- a/draft-js-resizeable-plugin/package.json +++ b/draft-js-resizeable-plugin/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/draft-js-plugins/draft-js-plugins.git" }, "main": "lib/index.js", + "types": "lib/index.d.ts", "keywords": [ "editor", "wysiwyg", @@ -23,8 +24,9 @@ ], "scripts": { "clean": "../node_modules/.bin/rimraf lib", - "build": "npm run clean && npm run build:js", + "build": "npm run clean && npm run build:js && npm run build:ts", "build:js": "WEBPACK_CONFIG=$(pwd)/webpack.config.js BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production ../node_modules/.bin/babel --out-dir='lib' --ignore='__test__/*' src", + "build:ts": "../node_modules/.bin/cpx src/*.d.ts lib/", "prepublish": "npm run build" }, "license": "MIT", diff --git a/draft-js-resizeable-plugin/src/index.d.ts b/draft-js-resizeable-plugin/src/index.d.ts new file mode 100644 index 0000000000..2b78e92ee8 --- /dev/null +++ b/draft-js-resizeable-plugin/src/index.d.ts @@ -0,0 +1,8 @@ +import { DraftDecorator } from "draft-js"; +import { EditorPlugin } from "draft-js-plugins-editor"; + +type ResizeableEditorPlugin = EditorPlugin & { decorator: DraftDecorator }; + +declare const createResizeablePlugin: () => ResizeableEditorPlugin; + +export default createResizeablePlugin; diff --git a/package.json b/package.json index c01fcebf65..ab459d4dbb 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "chai": "^3.5.0", "chai-enzyme": "^0.6.1", "cheerio": "^0.22.0", + "cpx": "^1.5.0", "css-loader": "^0.26.2", "css-modules-require-hook": "^4.0.2", "dirty-chai": "^1.2.2", diff --git a/yarn.lock b/yarn.lock index 21e272be29..ef748a9d39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -380,6 +380,11 @@ array-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" +array-filter@~0.0.0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-0.0.1.tgz#7da8cf2e26628ed732803581fd21f67cacd2eeec" + integrity sha1-fajPLiZijtcygDWB/SH2fKzS7uw= + array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" @@ -403,6 +408,16 @@ array-iterate@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/array-iterate/-/array-iterate-1.1.1.tgz#865bf7f8af39d6b0982c60902914ac76bc0108f6" +array-map@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/array-map/-/array-map-0.0.0.tgz#88a2bab73d1cf7bcd5c1b118a003f66f665fa662" + integrity sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI= + +array-reduce@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b" + integrity sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys= + array-union@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" @@ -1978,7 +1993,7 @@ cheerio@^0.22.0: lodash.reject "^4.4.0" lodash.some "^4.4.0" -chokidar@^1.6.1, chokidar@^1.7.0: +chokidar@^1.6.0, chokidar@^1.6.1, chokidar@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: @@ -2283,6 +2298,23 @@ cosmiconfig@^2.1.0, cosmiconfig@^2.1.1: parse-json "^2.2.0" require-from-string "^1.1.0" +cpx@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/cpx/-/cpx-1.5.0.tgz#185be018511d87270dedccc293171e37655ab88f" + integrity sha1-GFvgGFEdhycN7czCkxceN2VauI8= + dependencies: + babel-runtime "^6.9.2" + chokidar "^1.6.0" + duplexer "^0.1.1" + glob "^7.0.5" + glob2base "^0.0.12" + minimatch "^3.0.2" + mkdirp "^0.5.1" + resolve "^1.1.7" + safe-buffer "^5.0.1" + shell-quote "^1.6.1" + subarg "^1.0.0" + create-ecdh@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.0.tgz#888c723596cdf7612f6498233eebd7a35301737d" @@ -2779,7 +2811,7 @@ duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" -duplexer@~0.1.1: +duplexer@^0.1.1, duplexer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" @@ -3409,6 +3441,11 @@ find-cache-dir@^1.0.0: make-dir "^1.0.0" pkg-dir "^2.0.0" +find-index@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" + integrity sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ= + find-up@^1.0.0, find-up@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -3657,6 +3694,13 @@ glob-to-regexp@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" +glob2base@^0.0.12: + version "0.0.12" + resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" + integrity sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY= + dependencies: + find-index "^0.1.1" + glob@7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" @@ -5350,7 +5394,7 @@ minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: +minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -5891,6 +5935,11 @@ path-parse@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + path-to-regexp@0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" @@ -7079,6 +7128,13 @@ resolve@^1.1.6, resolve@^1.2.0: dependencies: path-parse "^1.0.5" +resolve@^1.1.7: + version "1.11.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e" + integrity sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw== + dependencies: + path-parse "^1.0.6" + restore-cursor@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" @@ -7285,6 +7341,16 @@ shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" +shell-quote@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767" + integrity sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c= + dependencies: + array-filter "~0.0.0" + array-map "~0.0.0" + array-reduce "~0.0.0" + jsonify "~0.0.0" + shelljs@^0.7.5, shelljs@^0.7.8: version "0.7.8" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" @@ -7612,6 +7678,13 @@ style-loader@^0.18.2: loader-utils "^1.0.2" schema-utils "^0.3.0" +subarg@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/subarg/-/subarg-1.0.0.tgz#f62cf17581e996b48fc965699f54c06ae268b8d2" + integrity sha1-9izxdYHplrSPyWVpn1TAauJouNI= + dependencies: + minimist "^1.1.0" + superagent@^3.5.0: version "3.8.1" resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.1.tgz#2571fd921f3fcdba43ac68c3b35c91951532701f"