mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-16 01:49:25 +08:00
feat(uitls): 只是自定义dsl与dom el的关联关系函数
This commit is contained in:
parent
39e68bd33a
commit
9494ed79a3
@ -46,7 +46,6 @@ const popoverVisible = ref(false);
|
|||||||
const visibleWatch = watch(
|
const visibleWatch = watch(
|
||||||
() => props.visible,
|
() => props.visible,
|
||||||
(visible) => {
|
(visible) => {
|
||||||
console.log(visible);
|
|
||||||
if (typeof visible === 'undefined') {
|
if (typeof visible === 'undefined') {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
visibleWatch();
|
visibleWatch();
|
||||||
|
@ -123,11 +123,26 @@ export const calcValueByFontsize = (doc: Document | undefined, value: number) =>
|
|||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getIdFromEl = () => (el?: HTMLElement | SVGElement | null) => el?.dataset?.tmagicId;
|
const dslDomRelateConfig = {
|
||||||
|
getIdFromEl: (el?: HTMLElement | SVGElement | null) => el?.dataset?.tmagicId,
|
||||||
export const getElById = () => (doc?: Document, id?: string | number) =>
|
getElById: (doc?: Document, id?: string | number) => doc?.querySelector(`[data-tmagic-id="${id}"]`) as HTMLElement,
|
||||||
doc?.querySelector(`[data-tmagic-id=${id}]`) as HTMLElement;
|
setIdToEl: (el: HTMLElement | SVGElement, id: string | number) => {
|
||||||
|
el.dataset.tmagicId = `${id}`;
|
||||||
export const setIdToEl = () => (el: HTMLElement | SVGElement, id: string | number) => {
|
},
|
||||||
el.dataset.tmagicId = `${id}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setDslDomRelateConfig = <
|
||||||
|
K extends keyof typeof dslDomRelateConfig,
|
||||||
|
T extends (typeof dslDomRelateConfig)[K],
|
||||||
|
>(
|
||||||
|
name: K,
|
||||||
|
value: T,
|
||||||
|
) => {
|
||||||
|
dslDomRelateConfig[name] = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getIdFromEl = () => dslDomRelateConfig.getIdFromEl;
|
||||||
|
|
||||||
|
export const getElById = () => dslDomRelateConfig.getElById;
|
||||||
|
|
||||||
|
export const setIdToEl = () => dslDomRelateConfig.setIdToEl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user