Add view classes

This commit is contained in:
Misode
2020-05-25 13:22:36 +02:00
parent 1bef36a713
commit 79a5742dad
9 changed files with 83 additions and 53 deletions

View File

@@ -3,7 +3,8 @@ import { EnumNode } from '../nodes/EnumNode'
import { ObjectNode } from '../nodes/ObjectNode'
import { StringNode } from '../nodes/StringNode'
import { DataModel } from '../model/DataModel'
import { TreeView } from '../view/TreeView'
import { SourceView } from '../view/SourceView'
const EntityCollection = ['sheep', 'pig']
@@ -12,7 +13,7 @@ const predicateTree = new RootNode('predicate', {
transform: (s: string) => (s === 'foo') ? {test: 'baz'} : s
}),
predicate: new ObjectNode({
type: new EnumNode(EntityCollection, {}),
type: new EnumNode(EntityCollection),
nbt: new StringNode()
})
}, {
@@ -20,7 +21,8 @@ const predicateTree = new RootNode('predicate', {
});
const model = new DataModel(predicateTree)
const treeView = new TreeView(model)
const sourceView = new SourceView(model)
model.render(document!.getElementById('view')!)
// document!.getElementById('source')!.textContent = predicateTree.transform(dummyData)
treeView.render(document!.getElementById('view')!)
sourceView.render(document!.getElementById('source')!)