@borurio-print/print-designer 1.0.3 → 1.0.5
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-lib/core/componentRegistry.d.ts +1 -1
- package/dist-lib/core/textBoxLayout.d.ts +26 -0
- package/dist-lib/core/types.d.ts +37 -5
- package/dist-lib/{index-GDGs3f4y.js → index-DvKk7a_X.js} +4897 -4243
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/{index.es-Q3peh10r.js → index.es-BsnJetMo.js} +2 -2
- package/dist-lib/index.js +1 -1
- package/dist-lib/locales/en-US.d.ts +18 -0
- package/dist-lib/locales/zh-CN.d.ts +18 -0
- package/dist-lib/{pdfGenerator-C9f7apmx.js → pdfGenerator-CEaS2amn.js} +1 -1
- package/dist-lib/style.css +1 -1
- package/dist-lib/views/print-designer/components/TextBoxSvgElement.vue.d.ts +15 -0
- package/dist-lib/views/print-designer/components/properties/LineHeightProperty.vue.d.ts +12 -0
- package/dist-lib/views/print-designer/components/properties/MinFontSizeProperty.vue.d.ts +12 -0
- package/dist-lib/views/print-designer/components/properties/TextBoxFitModeProperty.vue.d.ts +12 -0
- package/dist-lib/views/print-designer/components/properties/TextBoxOverflowModeProperty.vue.d.ts +12 -0
- package/dist-lib/views/print-designer/components/properties/TextHorizontalAlignProperty.vue.d.ts +12 -0
- package/dist-lib/views/print-designer/components/properties/TextVerticalAlignProperty.vue.d.ts +12 -0
- package/package.json +12 -10
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TextBoxDesignerElement } from './types';
|
|
2
|
+
export declare const DEFAULT_TEXT_BOX_PADDING_MM = 0.5;
|
|
3
|
+
export interface TextBoxLayoutResult {
|
|
4
|
+
lines: string[];
|
|
5
|
+
fontSizePt: number;
|
|
6
|
+
fontSizeMm: number;
|
|
7
|
+
lineHeightMm: number;
|
|
8
|
+
truncated: boolean;
|
|
9
|
+
textAnchor: 'start' | 'middle' | 'end';
|
|
10
|
+
textXOffsetMm: number;
|
|
11
|
+
textYOffsetMm: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TextBoxInitialSize {
|
|
14
|
+
widthMm: number;
|
|
15
|
+
heightMm: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 把运行时文字排入固定毫米矩形。设计画布和 PDF 共用该结果,避免预览与打印
|
|
19
|
+
* 分别依赖 CSS/SVG 的隐式换行规则而产生差异。
|
|
20
|
+
*/
|
|
21
|
+
export declare function layoutTextBox(element: TextBoxDesignerElement, content: string): TextBoxLayoutResult;
|
|
22
|
+
/**
|
|
23
|
+
* 根据设计时可见内容计算新建文字框的初始尺寸。尺寸只在创建时计算,之后用户
|
|
24
|
+
* 调整的宽高不会因为编辑内容或替换打印数据而被覆盖。
|
|
25
|
+
*/
|
|
26
|
+
export declare function measureInitialTextBoxSize(element: Pick<TextBoxDesignerElement, 'content' | 'fontSizePt' | 'fontWeight' | 'lineHeight' | 'paddingMm'>, maximumWidthMm: number, maximumHeightMm: number): TextBoxInitialSize;
|
package/dist-lib/core/types.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface PrintResult {
|
|
|
45
45
|
error?: unknown;
|
|
46
46
|
}
|
|
47
47
|
/** 业务字段目前允许在标签中使用的三种展示方式。 */
|
|
48
|
-
export type FieldElementType = 'text' | 'qrcode' | 'barcode';
|
|
48
|
+
export type FieldElementType = 'text' | 'textBox' | 'qrcode' | 'barcode';
|
|
49
49
|
/**
|
|
50
50
|
* 由业务系统传给设计器的字段定义。
|
|
51
51
|
*
|
|
@@ -68,9 +68,9 @@ export interface BusinessFieldGroup {
|
|
|
68
68
|
* 这里保留尚未实现编辑能力的组件类型,是为了让左侧组件注册表始终使用
|
|
69
69
|
* 稳定的业务标识;后续实现方框、线条等组件时不需要修改已有模板字段。
|
|
70
70
|
*/
|
|
71
|
-
export type DesignerElementType = 'text' | 'rectangle' | 'horizontalLine' | 'verticalLine' | 'qrcode' | 'barcode' | 'image' | 'serialNumber' | 'pageNumber' | 'time' | 'table' | 'pdf';
|
|
71
|
+
export type DesignerElementType = 'text' | 'textBox' | 'rectangle' | 'horizontalLine' | 'verticalLine' | 'qrcode' | 'barcode' | 'image' | 'serialNumber' | 'pageNumber' | 'time' | 'table' | 'pdf';
|
|
72
72
|
/** 右侧属性面板中可独立组合的属性编辑器标识。 */
|
|
73
|
-
export type ElementPropertyKey = 'displayType' | 'content' | 'imageSource' | 'x' | 'y' | 'width' | 'height' | 'fontSize' | 'fontWeight' | 'strokeWidth' | 'rotation' | 'timeMode' | 'includeTime' | 'fixedTime' | 'tableConfig' | 'pdfSource' | 'pdfCropMode' | 'pdfCropRatio';
|
|
73
|
+
export type ElementPropertyKey = 'displayType' | 'content' | 'textHorizontalAlign' | 'textVerticalAlign' | 'textBoxFitMode' | 'textBoxOverflowMode' | 'lineHeight' | 'minFontSize' | 'imageSource' | 'x' | 'y' | 'width' | 'height' | 'fontSize' | 'fontWeight' | 'strokeWidth' | 'rotation' | 'timeMode' | 'includeTime' | 'fixedTime' | 'tableConfig' | 'pdfSource' | 'pdfCropMode' | 'pdfCropRatio';
|
|
74
74
|
/**
|
|
75
75
|
* 单个属性编辑器的能力与数值约束。
|
|
76
76
|
* 数值范围跟随组件类型配置,输入框和 SVG 控制点共用,避免两处规则不一致。
|
|
@@ -91,7 +91,7 @@ export interface ElementPropertyConfig {
|
|
|
91
91
|
*/
|
|
92
92
|
export interface BaseDesignerElement {
|
|
93
93
|
id: string;
|
|
94
|
-
type: 'text' | 'rectangle' | 'horizontalLine' | 'verticalLine' | 'qrcode' | 'barcode' | 'image' | 'serialNumber' | 'pageNumber' | 'time' | 'table' | 'pdf';
|
|
94
|
+
type: 'text' | 'textBox' | 'rectangle' | 'horizontalLine' | 'verticalLine' | 'qrcode' | 'barcode' | 'image' | 'serialNumber' | 'pageNumber' | 'time' | 'table' | 'pdf';
|
|
95
95
|
xMm: number;
|
|
96
96
|
yMm: number;
|
|
97
97
|
widthMm: number;
|
|
@@ -256,8 +256,40 @@ export interface TableDesignerElement extends BaseDesignerElement {
|
|
|
256
256
|
fontSizePt: number;
|
|
257
257
|
fontWeight: 400 | 700;
|
|
258
258
|
}
|
|
259
|
+
/** 文字框在固定区域内放不下内容时采用的尺寸适配方式。 */
|
|
260
|
+
export type TextBoxFitMode = 'fixed' | 'shrinkFont';
|
|
261
|
+
/** 固定区域在最小字号下仍放不下内容时采用的溢出方式。 */
|
|
262
|
+
export type TextBoxOverflowMode = 'clip' | 'ellipsis';
|
|
263
|
+
/** 文字框内容在固定区域内的水平对齐方式。 */
|
|
264
|
+
export type TextHorizontalAlign = 'left' | 'center' | 'right';
|
|
265
|
+
/** 文字框内容在固定区域内的垂直对齐方式。 */
|
|
266
|
+
export type TextVerticalAlign = 'top' | 'middle' | 'bottom';
|
|
267
|
+
/**
|
|
268
|
+
* 多行文字框使用固定毫米宽高进行排版。
|
|
269
|
+
* 与普通文字不同,拖动控制点只改变文本框,不会同步缩放字号。
|
|
270
|
+
*/
|
|
271
|
+
export interface TextBoxDesignerElement extends BaseDesignerElement {
|
|
272
|
+
type: 'textBox';
|
|
273
|
+
/** 存在 field 时,打印阶段从业务数据读取;普通固定文字框不设置该字段。 */
|
|
274
|
+
field?: string;
|
|
275
|
+
content: string;
|
|
276
|
+
fontSizePt: number;
|
|
277
|
+
fontWeight: 400 | 700;
|
|
278
|
+
/** 行高相对于字号毫米高度的倍数。 */
|
|
279
|
+
lineHeight: number;
|
|
280
|
+
fitMode: TextBoxFitMode;
|
|
281
|
+
overflowMode: TextBoxOverflowMode;
|
|
282
|
+
/** shrinkFont 模式允许缩小到的最小字号。 */
|
|
283
|
+
minFontSizePt: number;
|
|
284
|
+
/** 新建文字框使用内边距;旧模板缺少该字段时按 0 处理。 */
|
|
285
|
+
paddingMm?: number;
|
|
286
|
+
/** 旧模板缺少该字段时按左对齐处理。 */
|
|
287
|
+
horizontalAlign?: TextHorizontalAlign;
|
|
288
|
+
/** 旧模板缺少该字段时按顶部对齐处理。 */
|
|
289
|
+
verticalAlign?: TextVerticalAlign;
|
|
290
|
+
}
|
|
259
291
|
/** 当前已经具备创建、属性编辑和 SVG 渲染能力的元素集合。 */
|
|
260
|
-
export type DesignerElement = TextDesignerElement | RectangleDesignerElement | LineDesignerElement | QrcodeDesignerElement | BarcodeDesignerElement | ImageDesignerElement | SerialNumberDesignerElement | PageNumberDesignerElement | TimeDesignerElement | TableDesignerElement | PdfDesignerElement;
|
|
292
|
+
export type DesignerElement = TextDesignerElement | TextBoxDesignerElement | RectangleDesignerElement | LineDesignerElement | QrcodeDesignerElement | BarcodeDesignerElement | ImageDesignerElement | SerialNumberDesignerElement | PageNumberDesignerElement | TimeDesignerElement | TableDesignerElement | PdfDesignerElement;
|
|
261
293
|
/** 设计器运行期间保存的元素剪贴板快照。 */
|
|
262
294
|
export interface ElementClipboardItem {
|
|
263
295
|
id: string;
|