Skip to content

Commit

Permalink
fix: do not apply paste rules for ProseMirror HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
philippkuehn committed Oct 10, 2021
1 parent a2e5346 commit 9d281e9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/core/src/PasteRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 9d281e9

Please sign in to comment.