Commit 03c60b43 authored by rockyl's avatar rockyl

init

parent 2a777ad9
# Created by .ignore support plugin (hsz.mobi) # Created by .ignore support plugin (hsz.mobi)
dist /dist
*.log /types
*.log
\ No newline at end of file
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
<module type="WEB_MODULE" version="4"> <module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true"> <component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/dist" />
</content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "html-shot", "name": "html-shot",
"version": "1.0.19", "version": "1.0.19",
"main": "dist/index.js", "main": "dist/index.js",
"types": "types/index.d.ts", "types": "dist/index.d.ts",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"dev": "tsc -w", "dev": "tsc -w",
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
"target": "ES5", "target": "ES5",
"outDir": "dist", "outDir": "dist",
"declaration": true, "declaration": true,
"declarationDir": "types",
"lib": [ "lib": [
"DOM", "DOM",
"ES2015" "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