Skip to content

Commit

Permalink
fix: recalculate formulas on initial load of document (#1395)
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson authored Aug 12, 2024
1 parent 2ffd63c commit 1062413
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions v3/src/models/document/create-document-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ export const createDocumentModel = (snapshot?: IDocumentModelSnapshot) => {
const sharedModelManager = new SharedModelDocumentManager()
const formulaManager = new FormulaManager()
const adapterApi = formulaManager.getAdapterApi()
formulaManager.addAdapters([
new AttributeFormulaAdapter(adapterApi),
new PlottedValueFormulaAdapter(adapterApi),
new PlottedFunctionFormulaAdapter(adapterApi)
])
const fullEnvironment: ITileEnvironment & {documentEnv: IDocumentEnvironment} = {
sharedModelManager,
formulaManager,
documentEnv: {}
}
try {
const document = DocumentModel.create(snapshot, fullEnvironment)

// initialize formula adapters after the document has been created
formulaManager.addAdapters([
new AttributeFormulaAdapter(adapterApi),
new PlottedValueFormulaAdapter(adapterApi),
new PlottedFunctionFormulaAdapter(adapterApi)
])

addDisposer(document, onAction(document, (call) => {
if (!document.content || !call.path?.match(/\/content\/tileMap\//)) {
return
Expand Down

0 comments on commit 1062413

Please sign in to comment.