-
Notifications
You must be signed in to change notification settings - Fork 67
Adding Typescript Definitions #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,115 @@ | ||
| declare module 'draftail' { | ||
| import { EditorState, RawDraftContentState } from 'draft-js'; | ||
| import * as React from 'react'; | ||
|
|
||
| export interface DrafTailEditorProps { | ||
| // Initial content of the editor. Use this to edit pre-existing content. | ||
| rawContentState: RawDraftContentState | null; | ||
| // Called when changes occured. Use this to persist editor content. | ||
| onSave: (rawContent: RawDraftContentState | null) => void; | ||
| // Content of the editor; when using the editor as a controlled component. Incompatible with `rawContentState` and `onSave`. | ||
| editorState: EditorState; | ||
| // Called whenever the editor state is updated. Use this to manage the content of a controlled editor. Incompatible with `rawContentState` and `onSave`. | ||
| onChange: (editorState: EditorState) => void; | ||
| // Called when the editor receives focus. | ||
| onFocus: () => {}; | ||
| // Called when the editor loses focus. | ||
| onBlur: () => {}; | ||
| // Displayed when the editor is empty. Hidden if the user changes styling. | ||
| placeholder: string; | ||
| // Enable the use of horizontal rules in the editor. | ||
| enableHorizontalRule: boolean; | ||
| // Enable the use of line breaks in the editor. | ||
| enableLineBreak: boolean; | ||
| // Show undo control in the toolbar. | ||
| showUndoControl: boolean; | ||
| // Show redo control in the toolbar. | ||
| showRedoControl: boolean; | ||
| // Disable copy/paste of rich text in the editor. | ||
| stripPastedStyles: boolean; | ||
| // Set whether spellcheck is turned on for your editor. | ||
| // See https://draftjs.org/docs/api-reference-editor.html#spellcheck. | ||
| spellCheck: boolean; | ||
| // Set whether the editor should be rendered in readOnly mode. | ||
| // See https://draftjs.org/docs/api-reference-editor.html#readonly | ||
| readOnly: boolean; | ||
| // Optionally set the overriding text alignment for this editor. | ||
| // See https://draftjs.org/docs/api-reference-editor.html#textalignment. | ||
| textAlignment: 'left' | 'center' | 'right'; | ||
| // Optionally set the overriding text directionality for this editor. | ||
| // See https://draftjs.org/docs/api-reference-editor.html#textdirectionality. | ||
| textDirectionality: 'left' | 'center' | 'right'; | ||
| // Set if auto capitalization is turned on and how it behaves. | ||
| // See https://draftjs.org/docs/api-reference-editor.html#autocapitalize-string. | ||
| autoCapitalize: boolean; | ||
| // Set if auto complete is turned on and how it behaves. | ||
| // See https://draftjs.org/docs/api-reference-editor.html#autocomplete-string. | ||
| autoComplete: boolean; | ||
| // Set if auto correct is turned on and how it behaves. | ||
| // See https://draftjs.org/docs/api-reference-editor.html#autocorrect-string. | ||
| autoCorrect: boolean; | ||
| // See https://draftjs.org/docs/api-reference-editor.html#aria-props. | ||
| ariaDescribedBy: null; | ||
| // List of the available block types. | ||
| blockTypes: any[]; | ||
| // List of the available inline styles. | ||
| inlineStyles: any[]; | ||
| // List of the available entity types. | ||
| entityTypes: any[]; | ||
| // List of active decorators. | ||
| decorators: any[]; | ||
| // Additional React components to render in the toolbar. | ||
| controls: any[]; | ||
| // List of plugins of the draft-js-plugins architecture. | ||
| plugins: any[]; | ||
| // Optionally override the default Draftail toolbar; removing or replacing it. | ||
| topToolbar: Toolbar; | ||
| // Optionally add a custom toolbar underneath the editor; e.g. for metrics. | ||
| bottomToolbar: Toolbar; | ||
| // Max level of nesting for list items. 0 = no nesting. Maximum = 10. | ||
| maxListNesting: number; | ||
| // Frequency at which to call the save callback (ms). | ||
| stateSaveInterval: number; | ||
| } | ||
|
|
||
| export const BLOCK_TYPE = { | ||
| // This is used to represent a normal text block (paragraph). | ||
| UNSTYLED: 'unstyled', | ||
| HEADER_ONE: 'header-one', | ||
| HEADER_TWO: 'header-two', | ||
| HEADER_THREE: 'header-three', | ||
| HEADER_FOUR: 'header-four', | ||
| HEADER_FIVE: 'header-five', | ||
| HEADER_SIX: 'header-six', | ||
| UNORDERED_LIST_ITEM: 'unordered-list-item', | ||
| ORDERED_LIST_ITEM: 'ordered-list-item', | ||
| BLOCKQUOTE: 'blockquote', | ||
| CODE: 'code-block', | ||
| // This represents a "custom" block, not for rich text, with arbitrary content. | ||
| ATOMIC: 'atomic', | ||
| }; | ||
| export const ENTITY_TYPE = { | ||
| LINK: 'LINK', | ||
| IMAGE: 'IMAGE', | ||
| HORIZONTAL_RULE: 'HORIZONTAL_RULE', | ||
| }; | ||
|
|
||
| export const INLINE_STYLE = { | ||
| BOLD: 'BOLD', | ||
| ITALIC: 'ITALIC', | ||
| CODE: 'CODE', | ||
| UNDERLINE: 'UNDERLINE', | ||
| STRIKETHROUGH: 'STRIKETHROUGH', | ||
| MARK: 'MARK', | ||
| QUOTATION: 'QUOTATION', | ||
| SMALL: 'SMALL', | ||
| SAMPLE: 'SAMPLE', | ||
| INSERT: 'INSERT', | ||
| DELETE: 'DELETE', | ||
| KEYBOARD: 'KEYBOARD', | ||
| SUPERSCRIPT: 'SUPERSCRIPT', | ||
| SUBSCRIPT: 'SUBSCRIPT', | ||
| }; | ||
|
|
||
| export class DraftailEditor extends React.PureComponent<Partial<DrafTailEditorProps>> {} | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.