mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-13 21:23:16 +08:00
fix(core): respect the editor's parseOptions (#5742)
Co-authored-by: guarmo <armando.guarino@tiptap.dev>
This commit is contained in:
parent
ae711abe32
commit
ffb51d3b7e
5
.changeset/blue-poems-camp.md
Normal file
5
.changeset/blue-poems-camp.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tiptap/core": patch
|
||||
---
|
||||
|
||||
insertContentAt, setContent, and insertContent commands now respect the editor's pre-defined parseOptions configuration if the command does not specify it's own parseOptions
|
@ -91,4 +91,28 @@ context('/src/Commands/InsertContent/React/', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('should respect editor.options.parseOptions if defined to be `false`', () => {
|
||||
cy.get('.tiptap').then(([{ editor }]) => {
|
||||
editor.options.parseOptions = { preserveWhitespace: false }
|
||||
editor.commands.insertContent('\n<h1>Tiptap</h1><p><strong>Hello\n World</strong>\n</p>\n')
|
||||
cy.get('.tiptap').should('contain.html', '<h1>Tiptap</h1><p><strong>Hello World</strong></p>')
|
||||
})
|
||||
})
|
||||
|
||||
it('should respect editor.options.parseOptions if defined to be `full`', () => {
|
||||
cy.get('.tiptap').then(([{ editor }]) => {
|
||||
editor.options.parseOptions = { preserveWhitespace: 'full' }
|
||||
editor.commands.insertContent('\n<h1>Tiptap</h1><p><strong>Hello\n World</strong>\n</p>\n')
|
||||
cy.get('.tiptap').should('contain.html', '<h1>Tiptap</h1><p><strong>Hello\n World</strong></p>')
|
||||
})
|
||||
})
|
||||
|
||||
it('should respect editor.options.parseOptions if defined to be `true`', () => {
|
||||
cy.get('.tiptap').then(([{ editor }]) => {
|
||||
editor.options.parseOptions = { preserveWhitespace: true }
|
||||
editor.commands.insertContent('<h1>Tiptap</h1><p><strong>Hello\n World</strong>\n</p>')
|
||||
cy.get('.tiptap').should('contain.html', '<h1>Tiptap</h1><p><strong>Hello World</strong></p>')
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -63,7 +63,7 @@ const isFragment = (nodeOrFragment: ProseMirrorNode | Fragment): nodeOrFragment
|
||||
export const insertContentAt: RawCommands['insertContentAt'] = (position, value, options) => ({ tr, dispatch, editor }) => {
|
||||
if (dispatch) {
|
||||
options = {
|
||||
parseOptions: {},
|
||||
parseOptions: editor.options.parseOptions,
|
||||
updateSelection: true,
|
||||
applyInputRules: false,
|
||||
applyPasteRules: false,
|
||||
|
Loading…
Reference in New Issue
Block a user