From dfa2186ee914044b323b8e5a97501f9d941c0710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Barfleur?= <39409397+kevinbarfleur@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:59:29 +0100 Subject: [PATCH 1/8] Add element-event to use this element in ww-select-input-search --- src/wwElement.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wwElement.vue b/src/wwElement.vue index 8fd5a17..e58b257 100644 --- a/src/wwElement.vue +++ b/src/wwElement.vue @@ -59,7 +59,7 @@ export default { uid: { type: String, required: true }, wwElementState: { type: Object, required: true }, }, - emits: ['trigger-event', 'add-state', 'remove-state', 'update:content:effect'], + emits: ['element-event', 'trigger-event', 'add-state', 'remove-state', 'update:content:effect'], setup(props) { const type = computed(() => { if (Object.keys(props.wwElementState.props).includes('type')) { @@ -258,10 +258,14 @@ export default { name: 'change', event: { domEvent: event, value: newValue }, }); + // element-event is useful when using inputs inside other coded components. + // See ww-select-input-search => https://github.com/weweb-assets/ww-input-select-search + this.$emit('element-event', { type: 'change', value: { domEvent: event, value: newValue } }); this.isDebouncing = false; }, this.delay); } else { this.$emit('trigger-event', { name: 'change', event: { domEvent: event, value: newValue } }); + this.$emit('element-event', { type: 'change', value: { domEvent: event, value: newValue } }); } }, onKeyEnter(event) { From 57dc6f07329d978a6b4e1675e7b59cbad05c4c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Barfleur?= <39409397+kevinbarfleur@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:31:46 +0100 Subject: [PATCH 2/8] Parent selection --- src/wwElement.vue | 35 ++++++++++++++++++++++++++++++++--- ww-config.js | 21 +++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/wwElement.vue b/src/wwElement.vue index e58b257..e63f767 100644 --- a/src/wwElement.vue +++ b/src/wwElement.vue @@ -47,7 +47,7 @@ diff --git a/ww-config.js b/ww-config.js index 72f869e..934c8c4 100644 --- a/ww-config.js +++ b/ww-config.js @@ -29,6 +29,21 @@ export default { 'resize', ], ], + hint: (_, sidePanelContent) => { + if (!sidePanelContent.parentSelection) return null; + const { header, text, button, args } = sidePanelContent.parentSelection; + const sections = ['style', 'settings']; + return sections.map(section => ({ + section, + header: header, + text: text, + button: { + text: button, + action: 'selectParentElement', + args, + }, + })); + }, }, states: ['focus', 'readonly'], actions: [{ label: 'Focus element', action: 'focusInput' }], @@ -340,5 +355,11 @@ export default { }, /* wwEditor:end */ }, + /* wwEditor:start */ + parentSelection: { + editorOnly: true, + defaultValue: false, + }, + /* wwEditor:end */ }, }; From 807ad7eefe24a37857efe384db7793c459f5b573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Barfleur?= <39409397+kevinbarfleur@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:21:30 +0100 Subject: [PATCH 3/8] Refactor --- src/editor/useParentSelection.js | 23 +++++++++++++++++++++++ src/wwElement.vue | 24 ++++++++---------------- ww-config.js | 2 +- 3 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 src/editor/useParentSelection.js diff --git a/src/editor/useParentSelection.js b/src/editor/useParentSelection.js new file mode 100644 index 0000000..ebcb641 --- /dev/null +++ b/src/editor/useParentSelection.js @@ -0,0 +1,23 @@ +import { computed, watch } from 'vue'; + +export default function useParentSelection(props, emit) { + const parentSelection = computed(() => props.parentSelection); + + function selectParentElement(el, ...args) { + wwLib.selectParentByFlag(el, ...args); + } + + watch( + parentSelection, + parentSelection => { + if (parentSelection.allow && parentSelection.info) { + emit('update:sidepanel-content', { path: 'parentSelection', value: parentSelection.info }); + } else { + emit('update:sidepanel-content', { path: 'parentSelection', value: null }); + } + }, + { immediate: true, deep: true } + ); + + return { selectParentElement }; +} diff --git a/src/wwElement.vue b/src/wwElement.vue index e63f767..cdaeb99 100644 --- a/src/wwElement.vue +++ b/src/wwElement.vue @@ -47,7 +47,10 @@ - - diff --git a/src/wwElement_InputBasic.vue b/src/wwElement_InputBasic.vue new file mode 100644 index 0000000..bb134ea --- /dev/null +++ b/src/wwElement_InputBasic.vue @@ -0,0 +1,201 @@ +