mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 11:49:02 +08:00
fix: do not apply paste rules for ProseMirror HTML
This commit is contained in:
parent
a2e534607c
commit
9d281e9e99
@ -127,12 +127,23 @@ function run(config: {
|
||||
* action.
|
||||
*/
|
||||
export function pasteRulesPlugin(rules: PasteRule[]): Plugin {
|
||||
let isProseMirrorHTML = false
|
||||
|
||||
const plugin = new Plugin({
|
||||
props: {
|
||||
handlePaste: (view, event) => {
|
||||
const html = event.clipboardData?.getData('text/html')
|
||||
|
||||
isProseMirrorHTML = !!html?.includes('data-pm-slice')
|
||||
|
||||
return false
|
||||
},
|
||||
},
|
||||
appendTransaction: (transactions, oldState, state) => {
|
||||
const transaction = transactions[0]
|
||||
|
||||
// stop if there is not a paste event
|
||||
if (!transaction.getMeta('paste')) {
|
||||
if (!transaction.getMeta('paste') || isProseMirrorHTML) {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user