[slate] Fix ObjectAndType interface: types -> type (#30388)

* Fix ObjectAndType interface: `types` -> `type`

* Fix slate tests: use SchemaProperties

The `Schema` class no longer exists, so `Schema.create` would not work.
This commit is contained in:
Spencer Elliott
2018-11-14 11:34:55 -08:00
committed by Pranav Senthilnathan
parent 72061aed07
commit a7dfc6c9a8
2 changed files with 35 additions and 2 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ export interface RulesByNodeType {
export interface ObjectAndType {
object?: string;
types?: string;
type?: string;
}
export interface Rules {
+34 -1
View File
@@ -1,4 +1,4 @@
import { Value, Data, BlockJSON, Document, Editor, KeyUtils, Range, Point, Inline, Mark } from "slate";
import { Block, Value, Data, BlockJSON, Document, Editor, KeyUtils, Range, Point, Inline, Mark, SchemaProperties } from "slate";
const data = Data.create({ foo: "bar " });
const value = Value.create({ data });
@@ -282,3 +282,36 @@ editor
KeyUtils.setGenerator(() => "Test");
KeyUtils.create();
KeyUtils.resetGenerator();
const schema: SchemaProperties = {
document: {
nodes: [
{
match: [
{ type: 'block-quote' },
{ type: 'heading-one' },
{ type: 'heading-two' },
{ type: 'image' },
{ type: 'paragraph' },
{ type: 'bulleted-list' },
{ type: 'numbered-list' },
{ type: 'list-item' },
],
},
],
last: { type: 'paragraph' },
normalize: (editor: Editor, { code, node }: any) => {
switch (code) {
case 'last_child_type_invalid': {
const paragraph = Block.create('paragraph');
return editor.insertNodeByKey(node.key, node.nodes.size, paragraph);
}
}
},
},
blocks: {
image: {
isVoid: true,
},
},
};