mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-27 03:29:58 +08:00
feat(editor): 组件列表支持设置tooltip显示详情
This commit is contained in:
parent
2e5b5665ce
commit
6a5374726e
@ -1,6 +1,8 @@
|
||||
<template>
|
||||
<TMagicIcon v-if="!icon" class="magic-editor-icon"><Edit></Edit></TMagicIcon>
|
||||
<TMagicIcon v-else-if="typeof icon === 'string' && icon.startsWith('http')" class="magic-editor-icon"
|
||||
<TMagicIcon
|
||||
v-else-if="typeof icon === 'string' && (icon.startsWith('http') || isRelativePath(icon))"
|
||||
class="magic-editor-icon"
|
||||
><img :src="icon"
|
||||
/></TMagicIcon>
|
||||
<i v-else-if="typeof icon === 'string'" class="magic-editor-icon" :class="icon"></i>
|
||||
@ -20,4 +22,6 @@ defineOptions({
|
||||
defineProps<{
|
||||
icon?: any;
|
||||
}>();
|
||||
|
||||
const isRelativePath = (str: string) => /^(\.|(\.\.)?\/)/.test(str);
|
||||
</script>
|
||||
|
@ -18,8 +18,9 @@
|
||||
@drag="dragHandler"
|
||||
>
|
||||
<slot name="component-list-item" :component="item">
|
||||
<MIcon :title="item.text" :icon="item.icon"></MIcon>
|
||||
|
||||
<TMagicTooltip placement="right" :disabled="!Boolean(item.desc)" :content="item.desc">
|
||||
<MIcon :icon="item.icon"></MIcon>
|
||||
</TMagicTooltip>
|
||||
<span :title="item.text">{{ item.text }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
@ -34,7 +35,7 @@ import { computed, inject, ref } from 'vue';
|
||||
import { Grid } from '@element-plus/icons-vue';
|
||||
import serialize from 'serialize-javascript';
|
||||
|
||||
import { TMagicCollapse, TMagicCollapseItem, TMagicScrollbar } from '@tmagic/design';
|
||||
import { TMagicCollapse, TMagicCollapseItem, TMagicScrollbar, TMagicTooltip } from '@tmagic/design';
|
||||
import { removeClassNameByClassName } from '@tmagic/utils';
|
||||
|
||||
import MIcon from '@editor/components/Icon.vue';
|
||||
|
@ -334,6 +334,8 @@ export interface SideBarData {
|
||||
export interface ComponentItem {
|
||||
/** 显示文案 */
|
||||
text: string;
|
||||
/** 详情,用于tooltip */
|
||||
desc?: string;
|
||||
/** 组件类型 */
|
||||
type: string;
|
||||
/** Vue组件或url */
|
||||
|
Loading…
x
Reference in New Issue
Block a user