mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-21 06:31:28 +02:00
tweak maximum schema iterations logic, addresses #2118
This commit is contained in:
@@ -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) {
|
||||||
|
@@ -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()
|
||||||
|
@@ -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: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
Reference in New Issue
Block a user