forked from draft-js-plugins/draft-js-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
21 changed files
with
429 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ lib/** | |
draft-js-*/lib/** | ||
scripts/** | ||
docs/build/** | ||
*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AnchorHTMLAttributes<HTMLAnchorElement>>; | ||
linkTarget?: string; | ||
} | ||
|
||
declare const createAnchorPlugin: (config: AnchorPluginConfig) => EditorPlugin; | ||
|
||
export default createAnchorPlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DraftJsStyleButtonProps>; | ||
|
||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>; | ||
}) => CSSProperties; | ||
priorityList?: { [k: string]: string | undefined }; | ||
selectGroups?: EmojiSelectGroup[]; | ||
selectButtonContent?: string; | ||
toneSelectOpenDelay?: number; | ||
useNativeArt?: boolean; | ||
} | ||
|
||
type EmojiEditorPlugin = EditorPlugin & { | ||
EmojiSuggestions: ComponentType<unknown>; | ||
EmojiSelect: ComponentType<unknown>; | ||
} | ||
|
||
declare const createEmojiPlugin: (config?: EmojiPluginConfig) => EmojiEditorPlugin; | ||
|
||
export default createEmojiPlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ImgHTMLAttributes<HTMLImageElement>>; | ||
} | ||
|
||
export type ImageEditorPlugin = EditorPlugin & { | ||
addImage: ( | ||
editorState: EditorState, | ||
url: string, | ||
extraData?: object | ||
) => EditorState; | ||
}; | ||
|
||
declare const createImagePlugin: ( | ||
config?: ImagePluginConfig | ||
) => ImageEditorPlugin; | ||
|
||
export default createImagePlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ToolbarChildrenProps>) => void; | ||
} | ||
|
||
export interface ToolbarProps { | ||
children(externalProps: ToolbarChildrenProps): ReactNode; | ||
} | ||
|
||
export type InlineToolBarPlugin = EditorPlugin & { | ||
InlineToolbar: ComponentType<ToolbarProps>; | ||
}; | ||
|
||
declare const createInlineToolbarPlugin: ( | ||
config?: InlineToolbarPluginConfig | ||
) => InlineToolBarPlugin; | ||
|
||
export default createInlineToolbarPlugin; |
Oops, something went wrong.