Pass snippets from builder to client when inside the builder preview to ensure new snippets can be evaluated

This commit is contained in:
Andrew Kingston 2024-03-07 08:25:31 +00:00
parent ccb32af078
commit d4a657bbfe
4 changed files with 12 additions and 4 deletions

View File

@ -42,6 +42,7 @@ const loadBudibase = async () => {
hiddenComponentIds: window["##BUDIBASE_HIDDEN_COMPONENT_IDS##"],
usedPlugins: window["##BUDIBASE_USED_PLUGINS##"],
location: window["##BUDIBASE_LOCATION##"],
snippets: window["##BUDIBASE_SNIPPETS##"],
})
// Set app ID - this window flag is set by both the preview and the real

View File

@ -18,6 +18,7 @@ const createBuilderStore = () => {
usedPlugins: null,
eventResolvers: {},
metadata: null,
snippets: null,
// Legacy - allow the builder to specify a layout
layout: null,

View File

@ -1,6 +1,10 @@
import { derived } from "svelte/store"
import { appStore } from "../app.js"
import { builderStore } from "../builder.js"
export const snippets = derived(appStore, $appStore => {
return $appStore?.application?.snippets || []
})
export const snippets = derived(
[appStore, builderStore],
([$appStore, $builderStore]) => {
return $builderStore?.snippets || $appStore?.application?.snippets || []
}
)

View File

@ -72,7 +72,8 @@
navigation,
hiddenComponentIds,
usedPlugins,
location
location,
snippets
} = parsed
// Set some flags so the app knows we're in the builder
@ -89,6 +90,7 @@
window["##BUDIBASE_HIDDEN_COMPONENT_IDS##"] = hiddenComponentIds
window["##BUDIBASE_USED_PLUGINS##"] = usedPlugins
window["##BUDIBASE_LOCATION##"] = location
window["##BUDIBASE_SNIPPETS##"] = snippets
// Initialise app
try {