-
GlobalScroll: {{globalScroll}}
+
+ GlobalScroll: {{ globalScroll }}
- ScreenScroll: {{screenScroll}}
-
+ ScreenScroll: {{ screenScroll }}
-
+
SECTION 1
-
{{animation}}
+
{{ animation }}
SECTION 2
diff --git a/playground/pages/image_test.vue b/playground/pages/image_test.vue
deleted file mode 100644
index 1aafab9..0000000
--- a/playground/pages/image_test.vue
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
Custom Image Test
-
-
-
-
-
-
-
-
-
-
-
diff --git a/playground/pages/index.vue b/playground/pages/index.vue
index a18e1aa..50f3488 100644
--- a/playground/pages/index.vue
+++ b/playground/pages/index.vue
@@ -8,10 +8,19 @@ const buttonText = useKatzeText({ key: 'button_text', default: 'The text on this
const richTextExample = useKatzeRichText({ key: 'rich_text_example',
default: '
This is a rich text example. You can edit this text add italics and boldness and more. ',
})
+
+const customImage = useKatzeImage({ key: 'custom_image', default: { src: '/images/test.svg', alt: 'Placeholder Image' }})
+
+ Go to CMS
+
Katze CMS Playground
@@ -22,12 +31,13 @@ const richTextExample = useKatzeRichText({ key: 'rich_text_example',
>
{{ editableText }}
-
- {{ buttonText }}
-
+ Hardcoded Text and {{ buttonText }}
+
+
+
+
+
diff --git a/playground/public/images/test.png b/playground/public/images/test.png
deleted file mode 100644
index 0f24a1b..0000000
Binary files a/playground/public/images/test.png and /dev/null differ
diff --git a/playground/public/images/test.svg b/playground/public/images/test.svg
new file mode 100644
index 0000000..9e92352
--- /dev/null
+++ b/playground/public/images/test.svg
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/runtime/components/views/EditView.vue b/src/runtime/components/views/EditView.vue
index a55b411..0e91dfa 100644
--- a/src/runtime/components/views/EditView.vue
+++ b/src/runtime/components/views/EditView.vue
@@ -101,12 +101,19 @@ onMounted(
element.addEventListener('mouseleave', () => {
hoveredElement.value = null
})
+ element.removeAttribute('href')
+ element.removeAttribute('target')
element.addEventListener('click', (event) => {
if (selectedElement.value === element) {
return
}
selectedElement.value = element
+ //cancel click event
+ event.preventDefault()
+ event.stopPropagation()
+ event.stopImmediatePropagation()
+
const attribute = selectedElement.value.getAttribute('kat-e')
if (attribute) {
const component = uiStore.getComponents(attribute)
diff --git a/src/runtime/composables/useUiComponents.ts b/src/runtime/composables/useUiComponents.ts
index 773a491..b9a5a24 100644
--- a/src/runtime/composables/useUiComponents.ts
+++ b/src/runtime/composables/useUiComponents.ts
@@ -1,7 +1,7 @@
import { storeToRefs } from 'pinia'
import { ref, watch } from 'vue'
import { ComponentType, useUiStore } from '../stores/UiStore'
-import type { KatzenUIComponent, KatzenUIOptions } from '~/src/runtime/stores/UiStore'
+import type { KatzenUIComponent } from '../stores/UiStore'
import { useRuntimeConfig } from '#imports'
export interface ImageContent {
@@ -9,6 +9,11 @@ export interface ImageContent {
alt: string
}
+export interface KatzenUIOptions {
+ key: string
+ default?: string | ImageContent
+}
+
let fetchedContent: Record
| undefined
export const setFetchedContent = (content: Record) => {
@@ -22,7 +27,7 @@ export const getContent = () => {
return useRuntimeConfig().public.content as Record || {}
}
-export const getContentByKey = (key: string, defaultValue: string = '') => {
+export const getContentByKey = (key: string, defaultValue: string|ImageContent = '') => {
const content = getContent()
if (content[key]) {
return content[key] as T || defaultValue
@@ -39,7 +44,7 @@ export const useKatzeRichText = (options: KatzenUIOptions) => {
export const useKatzeImage = (options: KatzenUIOptions) => {
const uiStore = useUiStore()
- const component: KatzenUIComponent = { type: ComponentType.Image, options, content: getContentByKey(options.key) }
+ const component: KatzenUIComponent = { type: ComponentType.Image, options, content: getContentByKey(options.key, options.default) }
uiStore.addToContextStack(component)
return reactiveProperty(options.key)
}
diff --git a/src/runtime/stores/UiStore.ts b/src/runtime/stores/UiStore.ts
index 57a9e54..897bb2f 100644
--- a/src/runtime/stores/UiStore.ts
+++ b/src/runtime/stores/UiStore.ts
@@ -1,9 +1,5 @@
import { defineStore } from 'pinia'
-
-export interface KatzenUIOptions {
- key: string
- default?: string
-}
+import type {KatzenUIOptions} from '../composables/useUiComponents';
export enum ComponentType {
Text = 'text',