@shaonq/hiprint 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +68 -15
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export declare class defaultElementTypeProvider {
|
|
2
2
|
constructor();
|
|
3
3
|
}
|
|
4
|
+
type Obj = Record<string, any>;
|
|
5
|
+
/** 纸张定义 */
|
|
6
|
+
interface Paper extends Obj {}
|
|
7
|
+
/** 节点定义 */
|
|
8
|
+
interface PrintElementType extends Obj {}
|
|
9
|
+
/** 纸张数据 */
|
|
10
|
+
interface PaperData extends Obj {}
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* hiprint 打印引擎主类,提供打印模板设计、打印数据生成及打印控制功能。
|
|
6
14
|
*/
|
|
@@ -92,12 +100,15 @@ export declare class hiprint {
|
|
|
92
100
|
* @returns HTML 字符串。
|
|
93
101
|
*/
|
|
94
102
|
static getHtml(templateId: string, data: any): string;
|
|
103
|
+
|
|
104
|
+
// fix: PrintElementTypeGroup
|
|
105
|
+
static PrintElementTypeGroup: new (providerName: string, list: any) => any;
|
|
95
106
|
}
|
|
96
107
|
|
|
97
108
|
/**
|
|
98
109
|
* hiprint 初始化配置选项。
|
|
99
110
|
*/
|
|
100
|
-
interface HiprintInitOptions {
|
|
111
|
+
interface HiprintInitOptions extends Record<string, any> {
|
|
101
112
|
fontFamily?: string; // 默认字体
|
|
102
113
|
fontSize?: number; // 默认字体大小
|
|
103
114
|
debug?: boolean; // 是否启用调试模式
|
|
@@ -105,6 +116,7 @@ interface HiprintInitOptions {
|
|
|
105
116
|
orient?: "portrait" | "landscape"; // 纸张方向,默认 'portrait'
|
|
106
117
|
watermarkOptions?: WatermarkOptions; // 水印配置
|
|
107
118
|
paperList?: PaperData[]; // 自定义纸张配置列表
|
|
119
|
+
providers: Record<string, any>[];
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
/**
|
|
@@ -130,9 +142,8 @@ interface PrinterInfo {
|
|
|
130
142
|
* 元素类型管理器接口。
|
|
131
143
|
*/
|
|
132
144
|
interface PrintElementTypeManager {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
add(type: string, config: PrintElementType): void; // 添加新类型
|
|
145
|
+
buildByHtml(el: any): void;
|
|
146
|
+
build(el: any, type: string): void;
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
/**
|
|
@@ -173,23 +184,23 @@ export declare class PrintTemplate {
|
|
|
173
184
|
historyPos: number;
|
|
174
185
|
|
|
175
186
|
/** 历史记录数组。 */
|
|
176
|
-
historyList:
|
|
187
|
+
historyList: PrintTemplateHistoryItem[];
|
|
177
188
|
|
|
178
189
|
/** 容器 DOM 元素。 */
|
|
179
190
|
container: HTMLElement;
|
|
180
191
|
|
|
181
192
|
/** 编辑面板集合。 */
|
|
182
|
-
editingPanel:
|
|
193
|
+
editingPanel: any[];
|
|
183
194
|
|
|
184
195
|
/** 打印面板集合(每张纸对应一个 Paper 对象)。 */
|
|
185
|
-
printPanels:
|
|
196
|
+
printPanels: Paper[];
|
|
186
197
|
|
|
187
198
|
/**
|
|
188
199
|
* 在指定容器中设计模板(可视化编辑模式)。
|
|
189
200
|
* @param container 容器 DOM 元素。
|
|
190
201
|
* @param data 数据源(可选)。
|
|
191
202
|
*/
|
|
192
|
-
design(container:
|
|
203
|
+
design(container: any, data?: { grid?: boolean; ruler?: boolean }): void;
|
|
193
204
|
|
|
194
205
|
/**
|
|
195
206
|
* 更新模板内容(从 JSON 数据恢复)。
|
|
@@ -286,7 +297,7 @@ export declare class PrintTemplate {
|
|
|
286
297
|
* 获取当前选中的所有 DOM 元素。
|
|
287
298
|
* @returns HTMLElement 数组。
|
|
288
299
|
*/
|
|
289
|
-
getSelectEls():
|
|
300
|
+
getSelectEls(): Record<string, any>[];
|
|
290
301
|
|
|
291
302
|
/**
|
|
292
303
|
* 更新指定配置项。
|
|
@@ -299,13 +310,14 @@ export declare class PrintTemplate {
|
|
|
299
310
|
* 对齐多个选中元素。
|
|
300
311
|
* @param align 对齐方式(left/center/right/top/middle/bottom)。
|
|
301
312
|
*/
|
|
302
|
-
setElsAlign(align: "left" | "
|
|
313
|
+
setElsAlign(align: "left" | "vertical" | "right" | "top" | "horizontal" | "bottom" | "distributeHor" | "distributeVer"): void;
|
|
303
314
|
|
|
304
315
|
/**
|
|
305
316
|
* 设置多个选中元素之间的间距(像素)。
|
|
306
|
-
* @param space 间距值。
|
|
317
|
+
* @param space 间距值。 *
|
|
318
|
+
* @param h - 是否水平间距,默认为 true(水平间距)
|
|
307
319
|
*/
|
|
308
|
-
setElsSpace(space: number): void;
|
|
320
|
+
setElsSpace(space: number, type: boolean): void;
|
|
309
321
|
|
|
310
322
|
/**
|
|
311
323
|
* 获取当前模板的完整 JSON 数据。
|
|
@@ -365,7 +377,8 @@ export declare class PrintTemplate {
|
|
|
365
377
|
/**
|
|
366
378
|
* 打印模板初始化配置选项。
|
|
367
379
|
*/
|
|
368
|
-
interface PrintTemplateOptions {
|
|
380
|
+
interface PrintTemplateOptions extends Record<string, any> {
|
|
381
|
+
template?: any;
|
|
369
382
|
history?: boolean; // 是否启用历史记录
|
|
370
383
|
fontFamily?: string; // 默认字体
|
|
371
384
|
fontSize?: number; // 默认字体大小
|
|
@@ -390,7 +403,7 @@ interface PrintTemplateHistoryItem {
|
|
|
390
403
|
* @param {Object} res[].data - 打印数据
|
|
391
404
|
* @returns {void}
|
|
392
405
|
*/
|
|
393
|
-
export function hiprintPrintMulti(res:
|
|
406
|
+
export function hiprintPrintMulti(res: { template?: string; data?: Obj }[]): void;
|
|
394
407
|
|
|
395
408
|
/*
|
|
396
409
|
* 使用 hiprint 打印模板
|
|
@@ -400,4 +413,44 @@ export function hiprintPrintMulti(res: Array<{ template?: string; data: any }>):
|
|
|
400
413
|
* @param {boolean} [isPrint=true] - 是否直接打印,默认为 true
|
|
401
414
|
* @returns {string|undefined} 如果 isPrint 为 false,则返回 HTML 字符串,否则返回 undefined
|
|
402
415
|
*/
|
|
403
|
-
export function hiprintPrint(res: { template: string; data
|
|
416
|
+
export function hiprintPrint(res: { template: string; data?: Obj }, isPrint?: boolean): string | undefined;
|
|
417
|
+
|
|
418
|
+
export interface Hinnn {
|
|
419
|
+
event: {
|
|
420
|
+
on(eventName: string, callback: (...args: any[]) => void): void;
|
|
421
|
+
off(eventName: string, callback: (...args: any[]) => void): void;
|
|
422
|
+
trigger(eventName: string, ...args: any[]): void;
|
|
423
|
+
clear(eventName: string): void;
|
|
424
|
+
getId(): number;
|
|
425
|
+
getNameWithId(prefix: string): string;
|
|
426
|
+
id: number;
|
|
427
|
+
};
|
|
428
|
+
form: {
|
|
429
|
+
serialize(formElement: any): any;
|
|
430
|
+
};
|
|
431
|
+
pt: {
|
|
432
|
+
toPx(pt: number): number;
|
|
433
|
+
toMm(pt: number): number;
|
|
434
|
+
dpi: number;
|
|
435
|
+
getDpi(): number;
|
|
436
|
+
};
|
|
437
|
+
px: {
|
|
438
|
+
toPt(px: number): number;
|
|
439
|
+
toMm(px: number): number;
|
|
440
|
+
dpi: number;
|
|
441
|
+
getDpi(): number;
|
|
442
|
+
};
|
|
443
|
+
mm: {
|
|
444
|
+
toPt(mm: number): number;
|
|
445
|
+
toPx(mm: number): number;
|
|
446
|
+
};
|
|
447
|
+
throttle(func: (...args: any[]) => void, wait: number, options?: any): (...args: any[]) => void;
|
|
448
|
+
debounce(func: (...args: any[]) => void, wait: number, immediate?: boolean): (...args: any[]) => void;
|
|
449
|
+
toUtf8(str: string): string;
|
|
450
|
+
groupBy(array: any[], keys: string[], selector: (item: any) => any): any[];
|
|
451
|
+
orderBy(array: any[], comparator: (item: any) => any): any[];
|
|
452
|
+
dateFormat(date: Date | string, formatStr: string): string;
|
|
453
|
+
numFormat(value: string | number, precision: number): string | number;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export declare const hinnn: Hinnn;
|