-
+ >
@@ -20,7 +23,7 @@ import { computed } from 'vue';
import { Edit } from '@element-plus/icons-vue';
import { Id, NodeType } from '@tmagic/core';
-import { FieldProps, type PageFragmentSelectConfig } from '@tmagic/form';
+import { FieldProps, MSelect, type PageFragmentSelectConfig, type SelectConfig } from '@tmagic/form';
import Icon from '@editor/components/Icon.vue';
import { useServices } from '@editor/hooks/use-services';
@@ -32,16 +35,16 @@ defineOptions({
const { editorService } = useServices();
const emit = defineEmits(['change']);
-const props = withDefaults(defineProps
>(), {
+withDefaults(defineProps>(), {
disabled: false,
});
+
const pageList = computed(() =>
editorService.get('root')?.items.filter((item) => item.type === NodeType.PAGE_FRAGMENT),
);
-const selectConfig = {
+const selectConfig: SelectConfig = {
type: 'select',
- name: props.name,
options: () => {
if (pageList.value) {
return pageList.value.map((item) => ({
@@ -53,8 +56,8 @@ const selectConfig = {
return [];
},
};
-const changeHandler = async () => {
- emit('change', props.model[props.name]);
+const changeHandler = (v: Id) => {
+ emit('change', v);
};
const editPageFragment = (id: Id) => {
diff --git a/packages/editor/src/fields/UISelect.vue b/packages/editor/src/fields/UISelect.vue
index 6dae68d6..bcb75dad 100644
--- a/packages/editor/src/fields/UISelect.vue
+++ b/packages/editor/src/fields/UISelect.vue
@@ -79,7 +79,6 @@ const clickHandler = ({ detail }: Event & { detail: HTMLElement | MNode }) => {
id = getIdFromEl()(detail as HTMLElement) || id;
}
if (id) {
- props.model[props.name] = id;
emit('change', id);
mForm?.$emit('field-change', props.prop, id);
}
@@ -102,7 +101,6 @@ const startSelect = () => {
const deleteHandler = () => {
if (props.model) {
- props.model[props.name] = '';
emit('change', '');
mForm?.$emit('field-change', props.prop, '');
}