Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1017 B
TypeScript
37 lines
1017 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
|
|
}
|
|
})
|
|
}
|