This commit is contained in:
Meyazhagan 2025-06-04 22:01:47 +03:00 committed by GitHub
commit 1ead1f77f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/core": minor
---
add slice option to insertContentAt and insertContent function

View File

@ -121,4 +121,20 @@ context('/src/Examples/Tables/React/', () => {
expect(elements[1].innerText).to.equal('Column 2')
})
})
it('should use parse function', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.insertContentAt(0, '<table><tr><td></td></tr></table>', {
applyInputRules: true,
slice: false, // to use parse function
})
cy.get('.tiptap table').should('exist').within(() => {
cy.get('colgroup').should('exist')
cy.get('tbody').should('exist')
cy.get('tr').should('exist')
cy.get('td').should('exist')
})
})
})
})

View File

@ -31,6 +31,12 @@ declare module '@tiptap/core' {
updateSelection?: boolean;
applyInputRules?: boolean;
applyPasteRules?: boolean;
/**
* Whether to use parseSlice function to parse the content.
* @default true
*/
slice?: boolean
}
) => ReturnType;
};

View File

@ -50,6 +50,12 @@ declare module '@tiptap/core' {
* Whether to throw an error if the content is invalid.
*/
errorOnInvalidContent?: boolean
/**
* Whether to use parseSlice function to parse the content.
* @default true
*/
slice?: boolean
},
) => ReturnType
}
@ -67,6 +73,7 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value,
updateSelection: true,
applyInputRules: false,
applyPasteRules: false,
slice: true,
...options,
}
@ -74,6 +81,7 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value,
try {
content = createNodeFromContent(value, editor.schema, {
slice: options.slice,
parseOptions: {
preserveWhitespace: 'full',
...options.parseOptions,