mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-11 11:45:15 +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')
|
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;
|
updateSelection?: boolean;
|
||||||
applyInputRules?: boolean;
|
applyInputRules?: boolean;
|
||||||
applyPasteRules?: boolean;
|
applyPasteRules?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to use parseSlice function to parse the content.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
slice?: boolean
|
||||||
}
|
}
|
||||||
) => ReturnType;
|
) => ReturnType;
|
||||||
};
|
};
|
||||||
|
@ -50,6 +50,12 @@ declare module '@tiptap/core' {
|
|||||||
* Whether to throw an error if the content is invalid.
|
* Whether to throw an error if the content is invalid.
|
||||||
*/
|
*/
|
||||||
errorOnInvalidContent?: boolean
|
errorOnInvalidContent?: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to use parseSlice function to parse the content.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
slice?: boolean
|
||||||
},
|
},
|
||||||
) => ReturnType
|
) => ReturnType
|
||||||
}
|
}
|
||||||
@ -67,6 +73,7 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value,
|
|||||||
updateSelection: true,
|
updateSelection: true,
|
||||||
applyInputRules: false,
|
applyInputRules: false,
|
||||||
applyPasteRules: false,
|
applyPasteRules: false,
|
||||||
|
slice: true,
|
||||||
...options,
|
...options,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +81,7 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
content = createNodeFromContent(value, editor.schema, {
|
content = createNodeFromContent(value, editor.schema, {
|
||||||
|
slice: options.slice,
|
||||||
parseOptions: {
|
parseOptions: {
|
||||||
preserveWhitespace: 'full',
|
preserveWhitespace: 'full',
|
||||||
...options.parseOptions,
|
...options.parseOptions,
|
||||||
|
Loading…
Reference in New Issue
Block a user