mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-01 05:16:10 +01:00
tweak maximum schema iterations logic, addresses #2118
This commit is contained in:
parent
8358d3777f
commit
8409e490c9
@ -155,7 +155,11 @@ function normalizeNodeAndChildren(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
|
||||
|
||||
function iterate(c, n) {
|
||||
|
@ -90,8 +90,13 @@ describe('slate', () => {
|
||||
})
|
||||
|
||||
fixtures(__dirname, 'schema', ({ module }) => {
|
||||
const { input, output, schema } = module
|
||||
let { input, output, schema } = module
|
||||
const s = Schema.create(schema)
|
||||
|
||||
if (!Value.isValue(input)) {
|
||||
input = Value.fromJSON(input)
|
||||
}
|
||||
|
||||
let expected = output
|
||||
let actual = input
|
||||
.change()
|
||||
|
@ -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: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user