mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
slate-react: Separated type for onChange function (#36789)
* slate-react: Separated type for onChange function * slate-react: Auto-fixes from the linter * slate-react: Union duplicated imports * slate-react: Removed an extra semicolon
This commit is contained in:
parent
919b9cddd5
commit
dbf8b45905
8
types/slate-react/index.d.ts
vendored
8
types/slate-react/index.d.ts
vendored
@ -114,12 +114,18 @@ export interface Plugin extends CorePlugin {
|
||||
export type PluginOrPlugins = Plugin | Plugins;
|
||||
export interface Plugins extends Array<PluginOrPlugins> {}
|
||||
|
||||
export interface OnChangeParam {
|
||||
operations: Immutable.List<Operation>;
|
||||
value: Value;
|
||||
}
|
||||
export type OnChangeFn = (change: OnChangeParam) => any;
|
||||
|
||||
export interface BasicEditorProps {
|
||||
value: Value;
|
||||
autoCorrect?: boolean;
|
||||
autoFocus?: boolean;
|
||||
className?: string;
|
||||
onChange?: (change: { operations: Immutable.List<Operation>; value: Value }) => any;
|
||||
onChange?: OnChangeFn;
|
||||
placeholder?: any;
|
||||
plugins?: Plugins;
|
||||
readOnly?: boolean;
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
import { Editor, Plugin, EditorProps, RenderBlockProps, RenderInlineProps } from "slate-react";
|
||||
import { Value, Editor as Controller, Operation, Point, Range, Inline, Mark, Document, Decoration } from "slate";
|
||||
import { Editor, Plugin, EditorProps, OnChangeFn, RenderBlockProps, RenderInlineProps } from 'slate-react';
|
||||
import { Value, Editor as Controller, Point, Range, Inline, Mark, Document, Decoration } from 'slate';
|
||||
import * as React from "react";
|
||||
import * as Immutable from "immutable";
|
||||
|
||||
class MyPlugin implements Plugin {
|
||||
renderBlock(props: RenderBlockProps, editor: Controller, next: () => void) {
|
||||
const { node } = props;
|
||||
if (node) {
|
||||
switch (node.object) {
|
||||
case "block":
|
||||
return <div id="slate-block-test"/>;
|
||||
case 'block':
|
||||
return <div id="slate-block-test" />;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
@ -19,15 +18,15 @@ class MyPlugin implements Plugin {
|
||||
const { node } = props;
|
||||
if (node) {
|
||||
switch (node.object) {
|
||||
case "inline":
|
||||
case 'inline':
|
||||
return <span id="slate-inline-test">Hello world</span>;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
onChange = (change: {operations: Immutable.List<Operation>, value: Value}) => {
|
||||
console.log(change.value);
|
||||
onChange: OnChangeFn = ({ operations, value }) => {
|
||||
console.log(operations, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user