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(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
console.log(visible);
|
||||
if (typeof visible === 'undefined') {
|
||||
nextTick(() => {
|
||||
visibleWatch();
|
||||
|
@ -123,11 +123,26 @@ export const calcValueByFontsize = (doc: Document | undefined, value: number) =>
|
||||
return value;
|
||||
};
|
||||
|
||||
export const getIdFromEl = () => (el?: HTMLElement | SVGElement | null) => el?.dataset?.tmagicId;
|
||||
|
||||
export const getElById = () => (doc?: Document, id?: string | number) =>
|
||||
doc?.querySelector(`[data-tmagic-id=${id}]`) as HTMLElement;
|
||||
|
||||
export const setIdToEl = () => (el: HTMLElement | SVGElement, id: string | number) => {
|
||||
const dslDomRelateConfig = {
|
||||
getIdFromEl: (el?: HTMLElement | SVGElement | null) => el?.dataset?.tmagicId,
|
||||
getElById: (doc?: Document, id?: string | number) => doc?.querySelector(`[data-tmagic-id="${id}"]`) as HTMLElement,
|
||||
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