import { Extension, Plugin } from 'tiptap' // import { Slice, Fragment } from 'prosemirror-model' export default class EventHandler extends Extension { get name() { return 'event_handler' } get plugins() { return [ new Plugin({ props: { transformPastedText(text) { // console.log('#### transformPastedText', text) return text.trim() }, transformPastedHTML(html) { html = html // remove all tags with "space only" .replace(/<[a-z-]+>[\s]+<\/[a-z-]+>/gim, '') // remove all iframes .replace( /(
'
)
// remove additional linebreaks inside p tags
.replace(
/<[a-z-]+>(<[a-z-]+>)*\s*(
\s*)+\s*(<\/[a-z-]+>)*<\/[a-z-]+>/gim,
''
)
// remove additional linebreaks when first child inside p tags
.replace(/
(\s*
\s*)+/gim, '
')
// remove additional linebreaks when last child inside p tags
.replace(/(\s*
\s*)+<\/p>/gim, '