mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-28 01:08:47 +00:00
List add button
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import type { DocAndNode } from '@spyglassmc/core'
|
||||
import { JsonFileNode } from '@spyglassmc/json'
|
||||
import { useCallback, useErrorBoundary } from 'preact/hooks'
|
||||
import { useCallback, useErrorBoundary, useMemo } from 'preact/hooks'
|
||||
import { useLocale } from '../../contexts/index.js'
|
||||
import { useDocAndNode, useSpyglass } from '../../contexts/Spyglass.jsx'
|
||||
import type { AstEdit } from '../../services/Spyglass.js'
|
||||
import type { McdocContext } from './McdocRenderer.jsx'
|
||||
import { McdocRoot } from './McdocRenderer.jsx'
|
||||
|
||||
type TreePanelProps = {
|
||||
@@ -34,7 +35,14 @@ export function Tree({ docAndNode, onError }: TreePanelProps) {
|
||||
service.applyEdit(docAndNode.doc.uri, edit)
|
||||
}, [service, docAndNode])
|
||||
|
||||
const ctx = useMemo<McdocContext | undefined>(() => {
|
||||
if (!service) {
|
||||
return undefined
|
||||
}
|
||||
return { doc: docAndNode.doc, symbols: service.getSymbols() }
|
||||
}, [docAndNode, service])
|
||||
|
||||
return <div class="tree node-root" data-cy="tree">
|
||||
<McdocRoot node={fileChild.children[0]} makeEdit={makeEdit} />
|
||||
{ctx && <McdocRoot node={fileChild.children[0]} makeEdit={makeEdit} ctx={ctx} />}
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user