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:
committed by
Ian Storm Taylor
parent
e1f4ff1f6c
commit
101661ee27
@@ -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: [] }
|
||||
|
||||
|
@@ -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) => {
|
||||
|
Reference in New Issue
Block a user