mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
[@types/slate-react] Support nested plugin stacks on the "plugins" property of the Editor React component (#36350)
* fix: react editor takes a recursively nested plugin stack as property * refactor: remove obsolete list type. naming. inline with feedback on #36349 * fix: enforce a list as root data type. See also #36349
This commit is contained in:
committed by
Benjamin Lichtman
parent
587afaa16c
commit
01bb26d2c0
Vendored
+5
-2
@@ -111,14 +111,17 @@ export interface Plugin extends CorePlugin {
|
||||
onSelect?: EventHook;
|
||||
}
|
||||
|
||||
export type PluginOrPlugins = Plugin | Plugins;
|
||||
export interface Plugins extends Array<PluginOrPlugins> {}
|
||||
|
||||
export interface BasicEditorProps {
|
||||
value: Value;
|
||||
autoCorrect?: boolean;
|
||||
autoFocus?: boolean;
|
||||
className?: string;
|
||||
onChange?: (change: { operations: Immutable.List<Operation>, value: Value }) => any;
|
||||
onChange?: (change: { operations: Immutable.List<Operation>; value: Value }) => any;
|
||||
placeholder?: any;
|
||||
plugins?: Plugin[];
|
||||
plugins?: Plugins;
|
||||
readOnly?: boolean;
|
||||
role?: string;
|
||||
schema?: SchemaProperties;
|
||||
|
||||
@@ -32,6 +32,7 @@ class MyPlugin implements Plugin {
|
||||
}
|
||||
|
||||
const myPlugin = new MyPlugin();
|
||||
const plugins = [myPlugin, [myPlugin, [myPlugin]]];
|
||||
|
||||
interface MyEditorState {
|
||||
value: Value;
|
||||
@@ -47,11 +48,15 @@ class MyEditor extends React.Component<EditorProps, MyEditorState> {
|
||||
};
|
||||
}
|
||||
render() {
|
||||
return <Editor
|
||||
value={this.state.value}
|
||||
renderBlock={ myPlugin.renderBlock }
|
||||
renderInline={ myPlugin.renderInline }
|
||||
onChange={ myPlugin.onChange }/>;
|
||||
return (
|
||||
<Editor
|
||||
plugins={plugins}
|
||||
value={this.state.value}
|
||||
renderBlock={myPlugin.renderBlock}
|
||||
renderInline={myPlugin.renderInline}
|
||||
onChange={myPlugin.onChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user