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