mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 14:27:04 +00:00
Merge pull request #21999 from petitspois/braft-editor
add braft-editor definition
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import * as React from "react";
|
||||
import * as BraftEditor from "braft-editor";
|
||||
import {
|
||||
RawDraftContentState,
|
||||
} from 'draft-js';
|
||||
class BraftEditorTest extends React.Component<BraftEditor.editorProps> {
|
||||
state = {
|
||||
content: null
|
||||
};
|
||||
render() {
|
||||
const editorProps = {
|
||||
height: 500,
|
||||
initialContent: this.state.content,
|
||||
onChange: this.handleChange,
|
||||
onHTMLChange: this.handleHTMLChange
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
<BraftEditor
|
||||
{...editorProps}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
private handleChange = (content: RawDraftContentState) => {
|
||||
console.log(content);
|
||||
}
|
||||
private handleHTMLChange = (html: string) => {
|
||||
console.log(html);
|
||||
}
|
||||
}
|
||||
Vendored
+59
@@ -0,0 +1,59 @@
|
||||
// Type definitions for braft-editor 1.1
|
||||
// Project: https://github.com/margox/braft#readme
|
||||
// Definitions by: My Self <https://github.com/me>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as React from "react";
|
||||
import { RawDraftContentState } from 'draft-js';
|
||||
export as namespace BraftEditor;
|
||||
export = BraftEditor;
|
||||
declare namespace BraftEditor {
|
||||
interface fontFamiliesRange {
|
||||
name: string;
|
||||
family: string;
|
||||
}
|
||||
interface editorProps {
|
||||
editorState?: any;
|
||||
contentFormat?: RawDraftContentState;
|
||||
initialContent?: RawDraftContentState | null;
|
||||
onChange?: (content: RawDraftContentState) => void;
|
||||
onRawChange?: (content: RawDraftContentState) => void;
|
||||
onHTMLChange?: (content: string) => void;
|
||||
controls?: string[];
|
||||
extendControls?: any[];
|
||||
height?: number;
|
||||
language?: string;
|
||||
placeholder?: string;
|
||||
viewWrapper?: string;
|
||||
colors?: string[];
|
||||
fontSizes?: number[];
|
||||
fontFamilies?: fontFamiliesRange[];
|
||||
media?: { [key: string]: any };
|
||||
getContent?: (format?: string) => RawDraftContentState;
|
||||
setContent?: (content: RawDraftContentState, format?: string) => void;
|
||||
toggleSelectionBlockType?: (blockquote: string) => any;
|
||||
toggleSelectionInlineStyle?: (style: string, stylesToBeRemoved?: string[]) => any;
|
||||
insertMedias?: (medias: Array<{ type: string, name: string, url: string }>) => void;
|
||||
insertText?: (text: string, replace?: boolean) => void;
|
||||
toggleSelectionLink?: (href: string, target: string) => void;
|
||||
toggleSelectionAlignment?: (alignment: string) => any;
|
||||
toggleSelectionColor?: (hexColor: string) => void;
|
||||
toggleSelectionBackgroundColor?: (hexColor: string) => void;
|
||||
toggleSelectionFontSize?: (fontSize: number) => void;
|
||||
toggleSelectionFontFamily?: (fontFamily: string) => void;
|
||||
selectionCollapsed?: () => boolean;
|
||||
selectionHasInlineStyle?: () => boolean;
|
||||
getSelectionBlockType?: () => string;
|
||||
getEditorState?: () => void;
|
||||
forceRender?: () => void;
|
||||
getDraftInstance?: () => any;
|
||||
getMediaLibraryInstance?: () => any;
|
||||
getSelectionInlineStyle?: () => any;
|
||||
undo?: () => any;
|
||||
redo?: () => any;
|
||||
focus?: () => void;
|
||||
blur?: () => void;
|
||||
}
|
||||
}
|
||||
declare class BraftEditor extends React.Component<BraftEditor.editorProps> { }
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"braft-editor-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user