mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 15:17:09 +00:00
Use spyglass DocAndNode to store current file data
This commit is contained in:
@@ -11,7 +11,7 @@ import type { PreviewProps } from './index.js'
|
||||
|
||||
const ANIMATION_TIME = 1000
|
||||
|
||||
export const RecipePreview = ({ model }: PreviewProps) => {
|
||||
export const RecipePreview = ({ docAndNode }: PreviewProps) => {
|
||||
const { locale } = useLocale()
|
||||
const { version } = useVersion()
|
||||
const [advancedTooltips, setAdvancedTooltips] = useState(true)
|
||||
@@ -29,11 +29,11 @@ export const RecipePreview = ({ model }: PreviewProps) => {
|
||||
return () => clearInterval(interval)
|
||||
}, [])
|
||||
|
||||
const recipe = model.data
|
||||
const state = JSON.stringify(recipe)
|
||||
const text = docAndNode.doc.getText()
|
||||
const recipe = JSON.parse(text)
|
||||
const items = useMemo<Map<Slot, ItemStack>>(() => {
|
||||
return placeItems(version, recipe, animation, itemTags ?? new Map())
|
||||
}, [state, animation, itemTags])
|
||||
}, [text, animation, itemTags])
|
||||
|
||||
const gui = useMemo(() => {
|
||||
const type = recipe.type?.replace(/^minecraft:/, '')
|
||||
@@ -46,7 +46,7 @@ export const RecipePreview = ({ model }: PreviewProps) => {
|
||||
} else {
|
||||
return '/images/crafting_table.png'
|
||||
}
|
||||
}, [state])
|
||||
}, [text])
|
||||
|
||||
return <>
|
||||
<div ref={overlay} class="preview-overlay">
|
||||
|
||||
Reference in New Issue
Block a user