UNPKG

simplyview

Version:

Library to rapidly build UI components, using declarative tools

25 lines (24 loc) 660 B
export function view(options, optionsCompat) { if (optionsCompat) { let app = options options = optionsCompat options.app = options } if (options.app) { options.app.view = options.view || {} const load = () => { const data = options.app.view const path = globalThis.editor.data.getDataPath(options.app.container || document.body) options.app.view = globalThis.editor.currentData[path] Object.assign(options.app.view, data) } if (globalThis.editor && globalThis.editor.currentData) { load() } else { document.addEventListener('simply-content-loaded', load) } return options.app.view } else { return options.view } }