fix type of SchemaProperties.document.text (#35245)

according to docs at https://docs.slatejs.org/slate-core/schema#text
can be either a RegExp or a function taking a string
and returning a boolean
This commit is contained in:
Tim Whitbeck
2019-05-13 16:33:25 -07:00
committed by Nathan Shively-Sanders
parent 6bde72cd87
commit 967388ba23
2 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ export interface Rules {
}>;
normalize?: (editor: Editor, error: SlateError) => void;
parent?: ObjectAndType | ObjectAndType[];
text?: RegExp;
text?: RegExp | ((text: string) => boolean);
}
export interface SchemaProperties {
+10 -1
View File
@@ -74,7 +74,8 @@ const schema: SchemaProperties = {
}
}
},
marks: [{ type: 'bold' }, { type: t => ['bold', 'underline'].indexOf(t) !== -1 }]
marks: [{ type: 'bold' }, { type: t => ['bold', 'underline'].indexOf(t) !== -1 }],
text: /^Test$/
},
blocks: {
image: {
@@ -84,6 +85,14 @@ const schema: SchemaProperties = {
},
};
const schema2: SchemaProperties = {
document: {
text(text) {
return true;
}
}
};
const pluginCommandName = 'plugin_command';
const pluginQueryName = 'plugin_query';