diff --git a/packages/slate-hyperscript/src/creators.ts b/packages/slate-hyperscript/src/creators.ts index d0ef89e3e87..e93d2e11337 100644 --- a/packages/slate-hyperscript/src/creators.ts +++ b/packages/slate-hyperscript/src/creators.ts @@ -217,11 +217,11 @@ export function createText( * Create a top-level `Editor` object. */ -export function createEditor( +export const createEditor = (makeEditor: () => Editor) => ( tagName: string, attributes: { [key: string]: any }, children: any[] -): Editor { +): Editor => { const otherChildren: any[] = [] let selectionChild: Range | undefined diff --git a/packages/slate-hyperscript/src/hyperscript.ts b/packages/slate-hyperscript/src/hyperscript.ts index b460c89c3db..d5217213281 100644 --- a/packages/slate-hyperscript/src/hyperscript.ts +++ b/packages/slate-hyperscript/src/hyperscript.ts @@ -1,5 +1,5 @@ import { isPlainObject } from 'is-plain-object' -import { Element } from 'slate' +import { Element, createEditor as makeEditor } from 'slate' import { createAnchor, createCursor, @@ -18,7 +18,7 @@ import { const DEFAULT_CREATORS = { anchor: createAnchor, cursor: createCursor, - editor: createEditor, + editor: createEditor(makeEditor), element: createElement, focus: createFocus, fragment: createFragment, diff --git a/packages/slate-hyperscript/src/index.ts b/packages/slate-hyperscript/src/index.ts index a8c38762372..bb870c554ee 100644 --- a/packages/slate-hyperscript/src/index.ts +++ b/packages/slate-hyperscript/src/index.ts @@ -3,6 +3,9 @@ import { HyperscriptCreators, HyperscriptShorthands, } from './hyperscript' +import { + createEditor +} from './creators' /** * The default hyperscript factory that ships with Slate, without custom tags. @@ -11,3 +14,4 @@ import { const jsx = createHyperscript() export { jsx, createHyperscript, HyperscriptCreators, HyperscriptShorthands } +export { createEditor }