以下是針對全局對象 mockplus 可以用的方法和屬性。
apiVersion: '1.0.0' [readonly]
運行此插件的DT API 版本。
editorType: 'DT' [readonly]
編輯器類型。
colorSpace: ColorSpace
顏色空間。
currentPage: Page
當前編輯頁面。
root: DocumentNode [readonly]
整個DT項目的根節(jié)點(文檔節(jié)點)。該節(jié)點內(nèi)包含其它節(jié)點, 例如: 頁面節(jié)點、圖層節(jié)點、資源、以及一些通用操作。
ui: UIAPI [readonly]
插件界面 API接口,此屬性包含創(chuàng)建和修改插件UI的方法。
currentUser: User [readonly]
當前用戶,此屬性包含有關(guān)當前用戶的詳細信息。
clientStorage: ClientStorageAPI [readonly]
客戶端緩存,此屬性包含在用戶本地計算機上存儲數(shù)據(jù)的方法。
libraries: ReadonlyArray<Library> [readonly]
資源庫。
findLayerById(id: string): Layer | null
通過圖層ID查詢圖層。
findPageById(id: string): Page | null
通過頁面ID查詢頁面。
showUI(html: string, options?: ShowUIOptions): void
顯示UI面板。
notify(message: string, options?: { timeout: number, error: boolean }): void
顯示界面通知信息。
closePlugin(message?: string): void
關(guān)閉插件。
on(type: EventType, callback: (event?: any) => void): void
監(jiān)聽事件。
once(type: EventType, callback: (event?: any) => void): void
監(jiān)聽事件。
off(type: EventType, callback: (event?: any) => void): void
監(jiān)聽事件。
createPage(): Page
創(chuàng)建頁面。
createSymbolPage(): Page
創(chuàng)建組件頁面。
createRectangle(): Path
創(chuàng)建矩形。
createTriangle(): Path
創(chuàng)建三角形。
createEllipse(): Path
創(chuàng)建圓形。
createPolygon(): Path
創(chuàng)建多邊形。
createStar(): Path
創(chuàng)建星形。
createLine(): Path
創(chuàng)建線條。
createText(): Text
創(chuàng)建文本。
createSlice(): Slice
創(chuàng)建切片。
createHotspot(): Hotspot
創(chuàng)建熱區(qū)。
createArtboard(): Artboard
創(chuàng)建畫板。
createImage(): Image
創(chuàng)建圖片。
createSymbolMaster(layers: Layer[], parent?: Page): SymbolMaster | undefined
創(chuàng)建組件。
createSymbolInstance(master: SymbolMaster | SharedSymbolStyle): SymbolInstance | undefined
創(chuàng)建組件實例。
group(layers: Layer[], parent?: Group | Frame | Page, index?: number): Group | null
編組圖層。
flatten(layers: ShapeGroup[]): (ShapeGroup | Path)[] | null
扁平化圖層。
outline(layers: (ShapeGroup | Path)[]): (ShapeGroup | Path)[] | null
輪廓化圖層。
union(layers: (ShapeGroup | Path)[], parent?: Group | Frame | Page, index?: number): ShapeGroup | null
創(chuàng)建合并復(fù)合路徑。
exclude(layers: (ShapeGroup | Path)[], parent?: Group | Frame | Page, index?: number): ShapeGroup | null
創(chuàng)建排除復(fù)合路徑。
intersect(layers: (ShapeGroup | Path)[], parent?: Group | Frame | Page, index?: number): ShapeGroup | null
創(chuàng)建相交復(fù)合路徑。
subtract(layers: (ShapeGroup | Path)[], parent?: Group | Frame | Page, index?: number): ShapeGroup | null
創(chuàng)建減去復(fù)合路徑。
commitUndo(): void
提交操作。
triggerUndo(): void
撤銷操作。
triggerRedo(): void
重做操作。
createNodeFromSvg(svg: string): Promise<Layer[]>
通過SVG創(chuàng)建圖層。
getSVGString(layer: Layer): string
獲取圖層SVG信息。
createImageData(data: Uint8Array): Promise<ImageData>
創(chuàng)建ImageData信息。
getImageDataByHash(hash: string): ImageData
通過hash獲取ImageData信息。
loadFontAsync(postscript: string): Promise<void>
加載字體。
listAvailableFonts(): FontFamily[]
加載可用字體列表。
createColorStyle(color: Color): SharedColorStyle | null
創(chuàng)建顏色資源。
createTextStyle(layer: Text): SharedTextStyle | null
創(chuàng)建文本資源。
createLayerStyle(layer: Path | ShapeGroup | Image): SharedLayerStyle | null
創(chuàng)建圖層資源。
findResourceById(resourceID: string): SharedColorStyle | SharedLayerStyle | SharedTextStyle | SharedSymbolStyle | null
通過ID查詢資源。