///
Example Text
' const fragment = createNodeFromContent(content, getSchemaByResolvedExtensions([Document, Paragraph, Text])) expect(fragment.toJSON()).to.deep.eq([ { type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], }, ]) }) it('if `errorOnInvalidContent` is true, creates a fragment from a schema and HTML content', () => { const content = 'Example Text
' const fragment = createNodeFromContent(content, getSchemaByResolvedExtensions([Document, Paragraph, Text]), { errorOnInvalidContent: true, }) expect(fragment.toJSON()).to.deep.eq([ { type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], }, ]) }) it('creates a fragment from a schema and JSON content', () => { const content = { type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], } const fragment = createNodeFromContent(content, getSchemaByResolvedExtensions([Document, Paragraph, Text])) expect(fragment.toJSON()).to.deep.eq({ type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], }) }) it('if `errorOnInvalidContent` is true, creates a fragment from a schema and JSON content', () => { const content = { type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], } const fragment = createNodeFromContent(content, getSchemaByResolvedExtensions([Document, Paragraph, Text]), { errorOnInvalidContent: true, }) expect(fragment.toJSON()).to.deep.eq({ type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], }) }) it('creates a fragment from a schema and JSON array of content', () => { const content = [ { type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], }, { type: 'paragraph', content: [ { type: 'text', text: 'More Text', }, ], }, ] const fragment = createNodeFromContent(content, getSchemaByResolvedExtensions([Document, Paragraph, Text])) expect(fragment.toJSON()).to.deep.eq([ { type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], }, { type: 'paragraph', content: [ { type: 'text', text: 'More Text', }, ], }, ]) }) it('if `errorOnInvalidContent` is true, creates a fragment from a schema and JSON array of content', () => { const content = [ { type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], }, { type: 'paragraph', content: [ { type: 'text', text: 'More Text', }, ], }, ] const fragment = createNodeFromContent(content, getSchemaByResolvedExtensions([Document, Paragraph, Text]), { errorOnInvalidContent: true, }) expect(fragment.toJSON()).to.deep.eq([ { type: 'paragraph', content: [ { type: 'text', text: 'Example Text', }, ], }, { type: 'paragraph', content: [ { type: 'text', text: 'More Text', }, ], }, ]) }) it('returns empty content when a schema does not have matching node types for JSON content', () => { const content = { type: 'non-existing-node-type', content: [ { type: 'text', text: 'Example Text', }, ], } const fragment = createNodeFromContent(content, getSchemaByResolvedExtensions([Document, Paragraph, Text])) expect(fragment.toJSON()).to.deep.eq(null) }) it('returns empty content when a schema does not have matching node types for HTML content', () => { const content = '