1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-03-07 14:30:04 +01:00
Ian Storm Taylor 7a71de387c
Add controller ()
* 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
2018-10-09 14:03:27 -07:00

56 lines
1.0 KiB
JavaScript

/** @jsx h */
import h from '../helpers/h'
export const config = {
rules: [
{
deserialize(el, next) {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
object: 'mark',
type: 'bold',
nodes: next(el.childNodes),
}
}
case 'em': {
return {
object: 'mark',
type: 'italic',
nodes: next(el.childNodes),
}
}
}
},
},
],
}
export const input = `
<p>o<strong>n</strong><strong>e</strong></p>
`.trim()
export const output = (
<value>
<document>
<paragraph>
<text>o</text>
<text>
<b>n</b>
</text>
<text>
<b>e</b>
</text>
</paragraph>
</document>
</value>
)