|
@@ -1,40 +1,53 @@
|
|
|
<template>
|
|
|
- <div :id="componentId" class="p-4 element-exists">
|
|
|
- <div class="flex items-center mb-2">
|
|
|
- <div
|
|
|
- :class="block.category.color"
|
|
|
- class="inline-block text-sm mr-4 p-2 rounded-lg"
|
|
|
- >
|
|
|
- <v-remixicon
|
|
|
- :path="icons.riFocus3Line"
|
|
|
- size="20"
|
|
|
- class="inline-block mr-1"
|
|
|
- />
|
|
|
- <span>Element exists</span>
|
|
|
- </div>
|
|
|
- <div class="flex-grow"></div>
|
|
|
+ <block-base
|
|
|
+ :id="componentId"
|
|
|
+ class="element-exists"
|
|
|
+ @edit="editBlock"
|
|
|
+ @delete="editor.removeNodeId(`node-${block.id}`)"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ :class="block.category.color"
|
|
|
+ class="inline-block text-sm mb-2 p-2 rounded-lg"
|
|
|
+ >
|
|
|
<v-remixicon
|
|
|
- :path="icons.riDeleteBin7Line"
|
|
|
- class="cursor-pointer"
|
|
|
- @click="editor.removeNodeId(`node-${block.id}`)"
|
|
|
+ :path="icons.riFocus3Line"
|
|
|
+ size="20"
|
|
|
+ class="inline-block mr-1"
|
|
|
/>
|
|
|
+ <span>Element exists</span>
|
|
|
</div>
|
|
|
- <input
|
|
|
- :value="block.data.selector"
|
|
|
- class="px-4 py-2 rounded-lg w-48 mb-2 bg-input"
|
|
|
- placeholder="Element selector"
|
|
|
- required
|
|
|
- @input="handleInput"
|
|
|
- />
|
|
|
+ <p
|
|
|
+ title="Element selector"
|
|
|
+ class="
|
|
|
+ text-overflow
|
|
|
+ p-2
|
|
|
+ rounded-lg
|
|
|
+ bg-box-transparent
|
|
|
+ text-sm
|
|
|
+ font-mono
|
|
|
+ text-right
|
|
|
+ mb-2
|
|
|
+ "
|
|
|
+ style="max-width: 200px"
|
|
|
+ >
|
|
|
+ {{ block.data.selector || 'Element selector' }}
|
|
|
+ </p>
|
|
|
<p class="text-right text-gray-600">
|
|
|
<span title="Execute when element doesn't exists"> ⓘ </span>
|
|
|
Fallback
|
|
|
</p>
|
|
|
- </div>
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ class="hidden trigger"
|
|
|
+ disabled="true"
|
|
|
+ @change="handleDataChanged"
|
|
|
+ />
|
|
|
+ </block-base>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { VRemixIcon as VRemixicon } from 'v-remixicon';
|
|
|
import emitter from 'tiny-emitter/instance';
|
|
|
+import BlockBase from './BlockBase.vue';
|
|
|
import { icons } from '@/lib/v-remixicon';
|
|
|
import { useComponentId } from '@/composable/componentId';
|
|
|
import { useEditorBlock } from '@/composable/editorBlock';
|
|
@@ -49,16 +62,22 @@ const props = defineProps({
|
|
|
const componentId = useComponentId('block-delay');
|
|
|
const block = useEditorBlock(`#${componentId}`, props.editor);
|
|
|
|
|
|
-function handleInput({ target }) {
|
|
|
- target.reportValidity();
|
|
|
+function editBlock() {
|
|
|
+ emitter.emit('editor:edit-block', {
|
|
|
+ ...block.details,
|
|
|
+ data: block.data,
|
|
|
+ blockId: block.id,
|
|
|
+ });
|
|
|
+}
|
|
|
+function handleDataChanged() {
|
|
|
+ const { data } = props.editor.getNodeFromId(block.id);
|
|
|
|
|
|
- props.editor.updateNodeDataFromId(block.id, { selector: target.value });
|
|
|
- emitter.emit('editor:data-changed', block.id);
|
|
|
+ block.data = data;
|
|
|
}
|
|
|
</script>
|
|
|
<style>
|
|
|
.drawflow .element-exists .outputs {
|
|
|
- top: 74px !important;
|
|
|
+ top: 70px !important;
|
|
|
transform: none !important;
|
|
|
}
|
|
|
.drawflow .element-exists .output {
|