mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-25 17:53:37 +01:00
* fold Stack into Editor * switch Change objects to be tied to editors, not values * introduce controller * add the "commands" concept * convert history into commands on `value.data` * add the ability to not normalize on editor creation/setting * convert schema to a mutable constructor * add editor.command method * convert plugin handlers to receive `next` * switch commands to use the onCommand middleware * add queries support, convert schema to queries * split out browser plugin * remove noop util * fixes * fixes * start fixing tests, refactor hyperscript to be more literal * fix slate-html-serializer tests * fix schema tests with hyperscript * fix text model tests with hyperscript * fix more tests * get all tests passing * fix lint * undo decorations example update * update examples * small changes to the api to make it nicer * update docs * update commands/queries plugin logic * change normalizeNode and validateNode to be middleware * fix decoration removal * rename commands tests * add useful errors to existing APIs * update changelogs * cleanup * fixes * update docs * add editor docs
1.6 KiB
1.6 KiB
slate-hyperscript
import h from 'slate-hyperscript'
import { createHyperscript } from 'slate-hyperscript'
A hyperscript helper for writing Slate documents with JSX!
Example
/** @jsx h */
import h from 'slate-hyperscript'
const value = (
<value>
<document>
<block type="paragraph">
A string of <mark type="bold">bold</mark> in a{' '}
<inline type="link" data={{ src: 'http://slatejs.org' }}>
Slate
</inline>{' '}
editor!
</block>
<block type="image" data={{ src: 'https://...' }} />
</document>
</value>
)
/** @jsx h */
import { createHyperscript } from 'slate-hyperscript'
const h = createHyperscript({
blocks: {
paragraph: 'paragraph',
image: 'image',
},
inlines: {
link: 'link',
},
marks: {
b: 'bold',
},
})
const value = (
<value>
<document>
<paragraph>
A string of <b>bold</b> in a <link src="http://slatejs.org">Slate</link>{' '}
editor!
</paragraph>
<image src="https://..." />
</document>
</value>
)
Exports
h
Function
The default export of slate-hyperscript
is a barebones hyperscript helper that you can immediately start using to create Slate objects.
createHyperscript
createHyperscript(options: Object) => Function
The other export is a createHyperscript
helper that you can use to create your own, smarter, schema-aware hyperscript helper. You can pass it options
that tell it about your schema to make creating objects much terser.
{
blocks: Object,
inlines: Object,
marks: Object,
decorations: Object,
creators: Object,
}