mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-02-19 04:43:51 +00:00
34 lines
761 B
Vue
34 lines
761 B
Vue
<template>
|
|
<p @click="clickHandler" v-html="config.text"></p>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { inject } from 'vue';
|
|
|
|
import type TMagicApp from '@tmagic/core';
|
|
import { COMMON_EVENT_PREFIX, type Id, type MComponent } from '@tmagic/core';
|
|
import { type ComponentProps, registerNodeHooks, useNode } from '@tmagic/vue-runtime-help';
|
|
|
|
interface TextSchema extends Omit<MComponent, 'id'> {
|
|
id?: Id;
|
|
type?: 'text';
|
|
text: string;
|
|
}
|
|
|
|
defineOptions({
|
|
name: 'tmagic-text',
|
|
});
|
|
|
|
const props = defineProps<ComponentProps<TextSchema>>();
|
|
|
|
const app = inject<TMagicApp>('app');
|
|
const node = useNode(props);
|
|
registerNodeHooks(node);
|
|
|
|
const clickHandler = () => {
|
|
if (app && node) {
|
|
app.emit(`${COMMON_EVENT_PREFIX}click`, node);
|
|
}
|
|
};
|
|
</script>
|