MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / MergeComp

Function MergeComp

app/src/components/diffHtml.tsx:93–122  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

91 before: string
92 after: string
93}> = (props) => {
94 let ref!: HTMLDivElement
95 onMount(() => {
96 const [theme] = useThemeContext()
97 const view = new MergeView({
98 parent: ref,
99 a: createConfig(props.before, theme(), props.extensions),
100 b: createConfig(props.after, theme(), props.extensions),
101 })
102 createEffect(
103 on(
104 // Only run this effect when the theme changes
105 theme,
106 (t) => {
107 view.a.setState(
108 EditorState.create(createConfig(props.before, t, props.extensions)),
109 )
110 view.b.setState(
111 EditorState.create(createConfig(props.after, t, props.extensions)),
112 )
113 },
114 { defer: true },
115 ),
116 )
117 onCleanup(() => {
118 view.destroy()
119 })
120 })
121 return <div class='max-h-[500px] resize-y overflow-auto' ref={ref} />
122}
123
124function createConfig(
125 doc: string,

Callers

nothing calls this directly

Calls 3

useThemeContextFunction · 0.90
createConfigFunction · 0.70
destroyMethod · 0.45

Tested by

no test coverage detected