UNPKG

3.11 kBTypeScriptView Raw
1import * as React from 'react';
2import { IEvents } from '../Events';
3import { ScriptItem } from '../ScriptLoader2';
4import { IEditorPropTypes } from './EditorPropTypes';
5import { Editor as TinyMCEEditor, TinyMCE } from 'tinymce';
6type OmitStringIndexSignature<T> = {
7 [K in keyof T as string extends K ? never : K]: T[K];
8};
9interface DoNotUse<T extends string> {
10 __brand: T;
11}
12type OmittedInitProps = 'selector' | 'target' | 'readonly' | 'license_key';
13type EditorOptions = Parameters<TinyMCE['init']>[0];
14export type InitOptions = Omit<OmitStringIndexSignature<EditorOptions>, OmittedInitProps> & {
15 selector?: DoNotUse<'selector prop is handled internally by the component'>;
16 target?: DoNotUse<'target prop is handled internally by the component'>;
17 readonly?: DoNotUse<'readonly prop is overridden by the component, use the `disabled` prop instead'>;
18 license_key?: DoNotUse<'license_key prop is overridden by the integration, use the `licenseKey` prop instead'>;
19} & {
20 [key: string]: unknown;
21};
22export type Version = `${'4' | '5' | '6' | '7'}${'' | '-dev' | '-testing' | `.${number}` | `.${number}.${number}`}`;
23export interface IProps {
24 apiKey: string;
25 id: string;
26 inline: boolean;
27 initialValue: string;
28 onEditorChange: (a: string, editor: TinyMCEEditor) => void;
29 value: string;
30 init: InitOptions;
31 tagName: string;
32 tabIndex: number;
33 cloudChannel: Version;
34 plugins: NonNullable<EditorOptions['plugins']>;
35 toolbar: NonNullable<EditorOptions['toolbar']>;
36 disabled: boolean;
37 textareaName: string;
38 tinymceScriptSrc: string | string[] | ScriptItem[];
39 rollback: number | false;
40 scriptLoading: {
41 async?: boolean;
42 defer?: boolean;
43 delay?: number;
44 };
45 licenseKey: string;
46}
47export interface IAllProps extends Partial<IProps>, Partial<IEvents> {
48}
49/**
50 * @see {@link https://www.tiny.cloud/docs/tinymce/7/react-ref/} for the TinyMCE React Technical Reference
51 */
52export declare class Editor extends React.Component<IAllProps> {
53 static propTypes: IEditorPropTypes;
54 static defaultProps: Partial<IAllProps>;
55 editor?: TinyMCEEditor;
56 private id;
57 private elementRef;
58 private inline;
59 private currentContent?;
60 private boundHandlers;
61 private rollbackTimer;
62 private valueCursor;
63 constructor(props: Partial<IAllProps>);
64 private get view();
65 componentDidUpdate(prevProps: Partial<IAllProps>): void;
66 componentDidMount(): void;
67 componentWillUnmount(): void;
68 render(): React.ReactElement<{
69 ref: React.RefObject<HTMLElement>;
70 id: string;
71 tabIndex: number | undefined;
72 }, string | React.JSXElementConstructor<any>>;
73 private changeEvents;
74 private beforeInputEvent;
75 private renderInline;
76 private renderIframe;
77 private getScriptSources;
78 private getInitialValue;
79 private bindHandlers;
80 private rollbackChange;
81 private handleBeforeInput;
82 private handleBeforeInputSpecial;
83 private handleEditorChange;
84 private handleEditorChangeSpecial;
85 private initialise;
86}
87export {};
88
\No newline at end of file