1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-20 14:11:35 +02:00

tweak maximum schema iterations logic, addresses #2118

This commit is contained in:
Ian Storm Taylor
2018-08-23 13:53:29 -07:00
parent 8358d3777f
commit 8409e490c9
3 changed files with 64 additions and 2 deletions

View File

@@ -155,7 +155,11 @@ function normalizeNodeAndChildren(change, node, schema) {
*/ */
function normalizeNode(change, node, schema) { function normalizeNode(change, node, schema) {
const max = schema.stack.plugins.length + schema.rules.length + 1 const max =
schema.stack.plugins.length +
schema.rules.length +
(node.object === 'text' ? 1 : node.nodes.size)
let iterations = 0 let iterations = 0
function iterate(c, n) { function iterate(c, n) {

View File

@@ -90,8 +90,13 @@ describe('slate', () => {
}) })
fixtures(__dirname, 'schema', ({ module }) => { fixtures(__dirname, 'schema', ({ module }) => {
const { input, output, schema } = module let { input, output, schema } = module
const s = Schema.create(schema) const s = Schema.create(schema)
if (!Value.isValue(input)) {
input = Value.fromJSON(input)
}
let expected = output let expected = output
let actual = input let actual = input
.change() .change()

View File

@@ -0,0 +1,53 @@
export const schema = {}
export const input = {
object: 'value',
document: {
object: 'document',
data: {},
nodes: [
{
object: 'block',
type: 'paragraph',
data: {},
nodes: Array.from({ length: 100 }).map(() => ({
object: 'text',
leaves: [
{
object: 'leaf',
text: 'a',
marks: [],
},
],
})),
},
],
},
}
export const output = {
object: 'value',
document: {
object: 'document',
data: {},
nodes: [
{
object: 'block',
type: 'paragraph',
data: {},
nodes: [
{
object: 'text',
leaves: [
{
object: 'leaf',
text: 'a'.repeat(100),
marks: [],
},
],
},
],
},
],
},
}