mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add WebPreviews blocks
This commit is contained in:
parent
b1c4ddd0b7
commit
8d3ede1486
11 changed files with 482 additions and 0 deletions
|
|
@ -0,0 +1,40 @@
|
|||
import { mergeAttributes, Node } from '@tiptap/core'
|
||||
import { ReactNodeViewRenderer } from '@tiptap/react'
|
||||
import WebPreviewComponent from './WebPreviewComponent'
|
||||
|
||||
const WebPreview = Node.create({
|
||||
name: 'blockWebPreview',
|
||||
group: 'block',
|
||||
atom: true,
|
||||
|
||||
addAttributes() {
|
||||
return {
|
||||
url: { default: null },
|
||||
title: { default: null },
|
||||
description: { default: null },
|
||||
og_image: { default: null },
|
||||
favicon: { default: null },
|
||||
og_type: { default: null },
|
||||
og_url: { default: null },
|
||||
alignment: { default: 'left' },
|
||||
buttonLabel: { default: 'Visit Site' },
|
||||
showButton: { default: false },
|
||||
}
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
{ tag: 'web-preview' },
|
||||
]
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return ['web-preview', mergeAttributes(HTMLAttributes), 0]
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
return ReactNodeViewRenderer(WebPreviewComponent)
|
||||
},
|
||||
})
|
||||
|
||||
export default WebPreview;
|
||||
Loading…
Add table
Add a link
Reference in a new issue