webapp/src/components/Editor/extensions/Span.ts

32 lines
552 B
TypeScript
Raw Normal View History

import { Mark, mergeAttributes } from '@tiptap/core'
export const Span = Mark.create({
name: 'span',
parseHTML() {
return [
{
tag: 'span[class]',
getAttrs: (dom) => {
if (dom instanceof HTMLElement) {
return { class: dom.getAttribute('class') }
}
return false
2024-06-26 08:22:05 +00:00
}
}
]
},
renderHTML({ HTMLAttributes }) {
return ['span', mergeAttributes(HTMLAttributes), 0]
},
addAttributes() {
return {
class: {
2024-06-26 08:22:05 +00:00
default: null
}
}
2024-06-26 08:22:05 +00:00
}
})