diff --git a/README.md b/README.md index 391fba8..5b8c8b1 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,6 @@ The import will provide global type augmentations for the `window.panel` object. ## API -Da der Arbeitsbereich-Index noch erstellt wird, kann die Antwort weniger genau sein. - -Here's the documentation for the composables in your workspace: - ### useApi Returns Kirby's Panel API for making HTTP requests to the backend. diff --git a/src/composables/content.ts b/src/composables/content.ts index d8d6072..adf3240 100644 --- a/src/composables/content.ts +++ b/src/composables/content.ts @@ -17,21 +17,32 @@ export function useContent() { const _isKirby5 = isKirby5(); const currentContent = _isKirby5 - ? computed(() => panel.view.props.content) - : computed(() => store.getters["content/values"]()); + ? computed>(() => panel.view.props.content) + : computed>(() => store.getters["content/values"]()); const contentChanges = _isKirby5 - ? computed(() => panel.content.changes()) - : computed(() => store.getters["content/changes"]()); + ? computed>(() => panel.content.changes()) + : computed>(() => store.getters["content/changes"]()); const hasChanges = _isKirby5 - ? computed(() => store.getters["content/hasChanges"]()) - : computed(() => Object.keys(contentChanges.value).length > 0); - - const content = _isKirby5 ? panel.content : ({} as PanelContent); + ? computed(() => Object.keys(contentChanges.value).length > 0) + : computed(() => store.getters["content/hasChanges"]()); + const content = _isKirby5 + ? panel.content + : new Proxy({} as PanelContent, { + get() { + return () => { + throw new Error( + 'The "window.panel.content" API is not available in Kirby 4.', + ); + }; + }, + }); /** * Updates the form values of the current view without saving them. */ - const update = (values?: Record) => { + const update = ( + values?: Record, + ): Record | undefined => { if (!values || Object.keys(values).length === 0) { return; }