mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 17:43:49 +08:00
Merge 6621e3836e
into 1577ec0d47
This commit is contained in:
commit
1ead1f77f0
5
.changeset/warm-yaks-speak.md
Normal file
5
.changeset/warm-yaks-speak.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tiptap/core": minor
|
||||
---
|
||||
|
||||
add slice option to insertContentAt and insertContent function
|
@ -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')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user