braft-editor: Provides its own types (#39646)

This commit is contained in:
Alexander T
2019-11-04 13:06:19 -08:00
committed by Nathan Shively-Sanders
parent 10d0bff71c
commit 9b973c41eb
5 changed files with 6 additions and 138 deletions
+6
View File
@@ -348,6 +348,12 @@
"sourceRepoURL": "https://github.com/sindresorhus/boxen",
"asOfVersion": "3.0.1"
},
{
"libraryName": "braft-editor",
"typingsPackageName": "braft-editor",
"sourceRepoURL": "https://github.com/margox/braft#readme",
"asOfVersion": "2.2.0"
},
{
"libraryName": "broccoli-plugin",
"typingsPackageName": "broccoli-plugin",
-31
View File
@@ -1,31 +0,0 @@
import * as React from "react";
import BraftEditor = require("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 readonly handleChange = (content: RawDraftContentState) => {
console.log(content);
}
private readonly handleHTMLChange = (html: string) => {
console.log(html);
}
}
-81
View File
@@ -1,81 +0,0 @@
// Type definitions for braft-editor 1.9
// Project: https://github.com/margox/braft#readme
// Definitions by: Jonny Yao <https://github.com/petitspois>
// Munif Tanjim <https://github.com/MunifTanjim>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
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?: 'raw' | 'html';
initialContent?: string | null;
contentId?: string | number;
onChange?: (content: RawDraftContentState) => void;
onRawChange?: (content: RawDraftContentState) => void;
onHTMLChange?: (content: string) => void;
onTab?: (event: Event) => void;
onSave?: () => void;
onFocus?: () => void;
onBlur?: () => void;
controls?: string[];
excludeControls?: string[];
extendControls?: any[];
extendAtomics?: any[];
disabled?: boolean;
height?: number;
language?: string;
placeholder?: string;
viewWrapper?: string;
tabIndents?: number;
forceNewLine?: boolean;
textAlignOptions?: string[];
colors?: string[];
allowSetTextBackgroundColor?: boolean;
fontSizes?: number[];
lineHeights?: number[];
letterSpacings?: number[];
indents?: number[];
fontFamilies?: fontFamiliesRange[];
emojis?: string[];
pasteMode?: 'text' | '';
media?: { [key: string]: any };
imageControls?: 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 }>) => any;
insertText?: (text: string, replace?: boolean) => any;
insertHTML?: (htmlString: string) => any;
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;
isEmpty?: () => boolean;
clear?: () => any;
undo?: () => any;
redo?: () => any;
focus?: () => any;
blur?: () => any;
}
}
declare class BraftEditor extends React.Component<BraftEditor.editorProps> { }
-25
View File
@@ -1,25 +0,0 @@
{
"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"
]
}
-1
View File
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }