Skip to content
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

Remove src from package #241

Merged
merged 4 commits into from
Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import React, { FunctionComponent } from 'react';
import { WithStyles, Theme } from '@material-ui/core/styles';
import { EditorState, DraftHandleValue, SelectionState } from 'draft-js';

// Autocomplete

export declare type TAutocompleteItem = {
keys: string[];
value: any;
content: string | JSX.Element;
};
interface TAutocompleteProps extends WithStyles<typeof AutocompleteStyles> {
items: TAutocompleteItem[];
top: number;
left: number;
selectedIndex: number;
onClick: (selectedIndex: number) => void;
}
declare const AutocompleteStyles: () => Record<"container" | "item", import("@material-ui/styles").CSSProperties | import("@material-ui/styles").CreateCSSProperties<{}> | import("@material-ui/styles").PropsFunc<{}, import("@material-ui/styles").CreateCSSProperties<{}>>>;
export declare const Autocomplete: React.ComponentType<Pick<React.PropsWithChildren<TAutocompleteProps>, "left" | "top" | "children" | "onClick" | "items" | "selectedIndex"> & import("@material-ui/core/styles").StyledComponentProps<"container" | "item">>;

// ToolbarButton

interface IToolbarButtonProps {
id?: string;
editorId?: string;
label: string;
style: string;
type: string;
active?: boolean;
icon?: JSX.Element;
onClick?: any;
inlineMode?: boolean;
disabled?: boolean;
size?: TToolbarButtonSize;
component?: FunctionComponent<TToolbarComponentProps>;
}
export declare const ToolbarButton: FunctionComponent<IToolbarButtonProps>;

// Toolbar

export declare type TToolbarControl = "title" | "bold" | "italic" | "underline" | "link" | "numberList" | "bulletList" | "quote" | "code" | "clear" | "save" | "media" | "strikethrough" | "highlight" | string;
export declare type TControlType = "inline" | "block" | "callback" | "atomic";
export declare type TToolbarButtonSize = "small" | "medium";
export declare type TToolbarComponentProps = {
id: string;
onMouseDown: (e: React.MouseEvent) => void;
active: boolean;
disabled: boolean;
};
export declare type TCustomControl = {
id?: string;
name: string;
icon?: JSX.Element;
type: TControlType;
component?: FunctionComponent<TToolbarComponentProps>;
inlineStyle?: React.CSSProperties;
blockWrapper?: React.ReactElement;
atomicComponent?: FunctionComponent;
onClick?: (editorState: EditorState, name: string, anchor: HTMLElement | null) => EditorState | void;
};
declare type TToolbarProps = {
id: string;
editorState: EditorState;
controls?: Array<TToolbarControl>;
customControls?: TCustomControl[];
onClick: (style: string, type: string, id: string, inlineMode?: boolean) => void;
inlineMode?: boolean;
className?: string;
disabled?: boolean;
size?: TToolbarButtonSize;
isActive: boolean;
};
export declare const Toolbar: FunctionComponent<TToolbarProps>;

// MUIRichTextEditor

export declare type TDecorator = {
component: FunctionComponent;
regex: RegExp;
};
export declare type TAutocompleteStrategy = {
triggerChar: string;
items: TAutocompleteItem[];
insertSpaceAfter?: boolean;
atomicBlockName?: string;
};
export declare type TAutocomplete = {
strategies: TAutocompleteStrategy[];
suggestLimit?: number;
};
export declare type TAsyncAtomicBlockResponse = {
data: any;
};
export declare type TMUIRichTextEditorRef = {
focus: () => void;
save: () => void;
/**
* @deprecated Use `insertAtomicBlockSync` instead.
*/
insertAtomicBlock: (name: string, data: any) => void;
insertAtomicBlockSync: (name: string, data: any) => void;
insertAtomicBlockAsync: (name: string, promise: Promise<TAsyncAtomicBlockResponse>, placeholder?: string) => void;
};
export declare type TDraftEditorProps = {
spellCheck?: boolean;
stripPastedStyles?: boolean;
handleDroppedFiles?: (selectionState: SelectionState, files: Blob[]) => DraftHandleValue;
};
export declare type TKeyCommand = {
key: number;
name: string;
callback: (state: EditorState) => EditorState;
};
export declare type TMUIRichTextEditorProps = {
id?: string;
/**
* @deprecated Use `defaultValue` instead.
*/
value?: any;
defaultValue?: any;
label?: string;
readOnly?: boolean;
inheritFontSize?: boolean;
error?: boolean;
controls?: Array<TToolbarControl>;
customControls?: TCustomControl[];
decorators?: TDecorator[];
toolbar?: boolean;
toolbarButtonSize?: TToolbarButtonSize;
inlineToolbar?: boolean;
inlineToolbarControls?: Array<TToolbarControl>;
draftEditorProps?: TDraftEditorProps;
keyCommands?: TKeyCommand[];
maxLength?: number;
autocomplete?: TAutocomplete;
onSave?: (data: string) => void;
onChange?: (state: EditorState) => void;
onFocus?: () => void;
onBlur?: () => void;
};
interface IMUIRichTextEditorProps extends TMUIRichTextEditorProps, WithStyles<typeof MUIRichTextEditorStyles> {
}
declare const MUIRichTextEditorStyles: ({ spacing, typography, palette }: Theme) => Record<"error" | "toolbar" | "root" | "container" | "linkPopover" | "linkTextField" | "inheritFontSize" | "editor" | "editorContainer" | "editorReadOnly" | "hidePlaceholder" | "placeHolder" | "anchorLink" | "inlineToolbar", import("@material-ui/styles").CSSProperties | import("@material-ui/styles").CreateCSSProperties<{}> | import("@material-ui/styles").PropsFunc<{}, import("@material-ui/styles").CreateCSSProperties<{}>>>;
declare const MUIRichTextEditor: React.ComponentType<Pick<IMUIRichTextEditorProps & React.RefAttributes<TMUIRichTextEditorRef>, "error" | "label" | "toolbar" | "ref" | "key" | "defaultValue" | "id" | "onFocus" | "onBlur" | "onChange" | "value" | "readOnly" | "maxLength" | "controls" | "inheritFontSize" | "inlineToolbar" | "customControls" | "decorators" | "toolbarButtonSize" | "inlineToolbarControls" | "draftEditorProps" | "keyCommands" | "autocomplete" | "onSave"> & import("@material-ui/core/styles").StyledComponentProps<"error" | "toolbar" | "root" | "container" | "linkPopover" | "linkTextField" | "inheritFontSize" | "editor" | "editorContainer" | "editorReadOnly" | "hidePlaceholder" | "placeHolder" | "anchorLink" | "inlineToolbar">>;
export default MUIRichTextEditor;
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default} from './dist'
1 change: 0 additions & 1 deletion index.ts

This file was deleted.

12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mui-rte",
"version": "1.27.0",
"version": "1.28.0",
"description": "Material-UI Rich Text Editor and Viewer",
"keywords": [
"material-ui",
Expand Down Expand Up @@ -75,10 +75,8 @@
},
"files": [
"dist",
"src",
"*.js",
"*.json",
"*.ts",
"*.tsx"
]
"index.js",
"index.d.ts"
],
"types": "index.d.ts"
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import commonjs from 'rollup-plugin-commonjs';
import { uglify } from 'rollup-plugin-uglify';

export default {
input: './index.ts',
input: './src/MUIRichTextEditor.tsx',
plugins: [
typescript(),
commonjs({
Expand Down