1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 19:01:54 +02:00

fix: Slate editor props (#3359)

* fix: Slate editor props

 TS2322: Type 'Editor' is not assignable to type 'ReactEditor'.

* revert

* generic type

* generic type

* generic type

* extends Editor

* extends Editor

* infer

* infer
This commit is contained in:
Ziad Beyens
2019-12-20 18:17:00 +01:00
committed by Ian Storm Taylor
parent e1f4ff1f6c
commit 101661ee27
2 changed files with 4 additions and 4 deletions

View File

@@ -7,8 +7,8 @@ import { HistoryEditor } from './history-editor'
* editor as operations are applied to it, using undo and redo stacks.
*/
export const withHistory = (editor: Editor): HistoryEditor => {
const e = editor as HistoryEditor
export const withHistory = <T extends Editor>(editor: T) => {
const e = editor as T & HistoryEditor
const { apply } = e
e.history = { undos: [], redos: [] }

View File

@@ -9,8 +9,8 @@ import { EDITOR_TO_ON_CHANGE, NODE_TO_KEY } from '../utils/weak-maps'
* `withReact` adds React and DOM specific behaviors to the editor.
*/
export const withReact = (editor: Editor): ReactEditor => {
const e = editor as ReactEditor
export const withReact = <T extends Editor>(editor: T) => {
const e = editor as T & ReactEditor
const { apply, onChange } = e
e.apply = (op: Operation) => {