Commit 03c60b43 authored by rockyl's avatar rockyl

init

parent 2a777ad9
# Created by .ignore support plugin (hsz.mobi)
dist
*.log
/dist
/types
*.log
\ No newline at end of file
......@@ -2,7 +2,9 @@
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/dist" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
......
......@@ -2,7 +2,7 @@
"name": "html-shot",
"version": "1.0.19",
"main": "dist/index.js",
"types": "types/index.d.ts",
"types": "dist/index.d.ts",
"license": "MIT",
"scripts": {
"dev": "tsc -w",
......
......@@ -4,7 +4,6 @@
"target": "ES5",
"outDir": "dist",
"declaration": true,
"declarationDir": "types",
"lib": [
"DOM",
"ES2015"
......
/**
* Created by rockyl on 2021/1/26.
*/
export declare const debugMode: any;
export declare function parseDom(el?: HTMLElement): {
width: number;
height: number;
nodes: any[];
};
/**
* Created by rockyl on 2021/1/11.
*/
import { RenderOptions } from "./toCanvas.js";
/**
* HTML截图
* @param {HTMLElement} [el] html节点
* @param options 配置
* @param {Function} [callback] 回调方法
* @return Promise<string|HTMLCanvasElement> 如果是字符串则为图片的base64
*/
export declare function htmlShot(el?: HTMLElement, options?: RenderOptions, callback?: (HTMLCanvasElement: any) => void): Promise<HTMLCanvasElement | string>;
/**
* 转换接口数据
*/
interface ICData {
width: number;
height: number;
nodes: INodeData[];
}
/**
* 节点类型
*/
declare enum NodeType {
ANY = 0,
TEXT = 1,
IMAGE = 2,
CANVAS = 3
}
/**
* 节点数据
*/
interface INodeData {
type: NodeType;
x: number;
y: number;
width: number;
height: number;
src?: string;
borderRadius?: string;
img?: HTMLImageElement;
imgBg?: HTMLImageElement;
text?: string;
color?: string;
fontSize?: string;
fontWeight?: string;
wordWrap?: "break-word" | null;
textAlign?: "center" | "left" | "right";
fontStyle?: "normal" | "italic" | "oblique";
'backgroundColor'?: any;
'backgroundImage'?: any;
'borderColor'?: any;
'borderWidth'?: any;
}
export interface RenderOptions {
scale?: number;
type?: 'canvas' | 'jpeg' | 'png';
quality?: number;
}
/**
* 渲染
* @param data
* @param options
* @param callback
* @return Promise<HTMLCanvasElement | string>
*/
export declare function toCanvas(data: ICData, options?: RenderOptions, callback?: (canvas: HTMLCanvasElement) => void): Promise<HTMLCanvasElement | string>;
export {};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment