mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add ExternalObjects (Embeds) to editor
This commit is contained in:
parent
b1d05168b6
commit
d8be321021
7 changed files with 279 additions and 2 deletions
|
|
@ -0,0 +1,49 @@
|
|||
import { mergeAttributes, Node } from '@tiptap/core'
|
||||
import { ReactNodeViewRenderer } from '@tiptap/react'
|
||||
import EmbedObjectsComponent from './EmbedObjectsComponent'
|
||||
|
||||
|
||||
export default Node.create({
|
||||
name: 'blockEmbed',
|
||||
group: 'block',
|
||||
|
||||
addAttributes() {
|
||||
return {
|
||||
embedUrl: {
|
||||
default: null,
|
||||
},
|
||||
embedCode: {
|
||||
default: null,
|
||||
},
|
||||
embedType: {
|
||||
default: null,
|
||||
},
|
||||
embedHeight: {
|
||||
default: 300,
|
||||
},
|
||||
embedWidth: {
|
||||
default: '100%',
|
||||
},
|
||||
alignment: {
|
||||
default: 'left',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
{
|
||||
tag: 'block-embed',
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return ['block-embed', mergeAttributes(HTMLAttributes), 0]
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
return ReactNodeViewRenderer(EmbedObjectsComponent)
|
||||
},
|
||||
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue