mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-24 10:56:21 -05:00
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
34 lines
941 B
TypeScript
34 lines
941 B
TypeScript
import {Extensions} from '@tiptap/core'
|
|
import {NodeViewWrapper, ReactNodeViewRenderer} from '@tiptap/react'
|
|
import clsx from 'clsx'
|
|
|
|
import {getField} from './utils'
|
|
|
|
export const nodeViewMiddleware = (extensions: Extensions) => {
|
|
return extensions.map((e) => {
|
|
const renderReact = getField(e, 'renderReact')
|
|
if (renderReact) {
|
|
return e
|
|
.extend({
|
|
addNodeView: () =>
|
|
ReactNodeViewRenderer((props: any) => (
|
|
<NodeViewWrapper
|
|
className={clsx(e.name, 'contents', props.selected && '[&>*]:outline-dotted')}
|
|
>
|
|
{renderReact(
|
|
{
|
|
...props.node.attrs,
|
|
deleteNode: props.deleteNode,
|
|
},
|
|
props.children,
|
|
)}
|
|
</NodeViewWrapper>
|
|
)),
|
|
})
|
|
.configure(e.options)
|
|
} else {
|
|
return e
|
|
}
|
|
})
|
|
}
|