12 小时以前 35722562e9e13f0504acc15b740d042ecb810199
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * 画布节点 → 质量组件定义的反查。
 * <p>
 * 单独成文件:canvas-sync 与 trait-binding 都要用它,
 * 放在任一方都会让「属性面板控件」和「画布同步」互相依赖。
 */
import type { Component } from 'grapesjs';
 
import type { QualityComponentDefinition } from './types';
 
import { QUALITY_TYPE_ATTR } from './attrs';
import { getQualityComponent } from './registry';
 
/** 按节点上的 data-quality-type 查定义;不是质量组件时返回 undefined */
export function definitionOf(component?: Component): QualityComponentDefinition | undefined {
  const attributes = component?.getAttributes() ?? {};
  return getQualityComponent(String(attributes[QUALITY_TYPE_ATTR] ?? ''));
}