UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

55 lines (54 loc) 1.93 kB
/** * @description: 请严格要求 svg 的 viewBox,若设计产出的 svg 不是此规格,请叫其修改为 '0 0 1024 1024' */ import { Group, Path, PointLike, Rect, type ImageStyleProps } from '@antv/g'; import { CustomImage } from '../../engine'; export interface GuiIconCfg extends Omit<ImageStyleProps, 'fill'> { readonly name: string; readonly fill?: string | null; /** * 图标渲染策略 * @see S2BasicOptions.csp */ readonly iconStrategy?: 'blob' | 'path'; } /** * 使用 iconfont 上的 svg 来创建 Icon * 支持两种渲染模式: * 1. Path 模式 (CSP 友好): 直接使用 G.Path 绘制矢量图形 * 2. Image 模式 (兼容): 使用 Blob URL 加载 SVG 图片 */ export declare class GuiIcon extends Group { static type: string; iconImageShape?: CustomImage; iconPathShapes: (Path | Rect)[]; private cfg; private usePathMode; constructor(cfg: GuiIconCfg); getCfg(): GuiIconCfg; /** * 尝试使用 Path 模式渲染图标 (CSP 完全兼容) * @returns 是否成功使用 Path 模式 */ private tryRenderAsPath; getImage(name: string, cacheKey: string, fill?: string | null): Promise<HTMLImageElement>; /** * 1. https://xxx.svg * 2. http://xxx.svg * 3. //xxx.svg */ isOnlineLink: (src: string) => boolean; private render; reRender(cfg: GuiIconCfg): void; updatePosition(position: PointLike): void; setImageAttrs(attrs: Partial<{ name: string; fill: string | null; }>): void; /** * https://github.com/antvis/S2/issues/2772 * G 6.0 如果是多图层, 需要手动全部隐藏, 直接隐藏父容器 Group 还不行, 或者使用 icon.show() * https://github.com/antvis/G/blob/277abff24936ef6f7c43407a16c5bc9260992511/packages/g-lite/src/display-objects/DisplayObject.ts#L853 */ toggleVisibility(visible: boolean): void; }