From 967388ba231b408243de33fa3020e1281bbe9d2d Mon Sep 17 00:00:00 2001 From: Tim Whitbeck Date: Mon, 13 May 2019 19:33:25 -0400 Subject: [PATCH] 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 --- types/slate/index.d.ts | 2 +- types/slate/slate-tests.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index 9c6c6737a3..3af19e4671 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -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 { diff --git a/types/slate/slate-tests.ts b/types/slate/slate-tests.ts index ebf77b119c..aa4607458e 100644 --- a/types/slate/slate-tests.ts +++ b/types/slate/slate-tests.ts @@ -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';