print-canvas-designer 0.1.1
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/COMMERCIAL_LICENSE.md +47 -0
- package/LICENSE +37 -0
- package/README.md +147 -0
- package/THIRD_PARTY_NOTICES.md +20 -0
- package/dist/components/PrintDesigner.vue.d.ts +49 -0
- package/dist/components/PrintPreview.vue.d.ts +8 -0
- package/dist/editor/canvas/CanvasBarcodeElement.vue.d.ts +8 -0
- package/dist/editor/canvas/CanvasElement.vue.d.ts +10 -0
- package/dist/editor/canvas/CanvasPage.vue.d.ts +7 -0
- package/dist/editor/canvas/CanvasQrElement.vue.d.ts +6 -0
- package/dist/editor/canvas/CanvasTextElement.vue.d.ts +8 -0
- package/dist/editor/canvas/MoveableLayer.vue.d.ts +6 -0
- package/dist/editor/canvas/PrintCanvas.vue.d.ts +10 -0
- package/dist/editor/canvas/events.d.ts +9 -0
- package/dist/editor/core/defaults.d.ts +12 -0
- package/dist/editor/core/geometry.d.ts +7 -0
- package/dist/editor/core/history.d.ts +13 -0
- package/dist/editor/core/pluginOptions.d.ts +3 -0
- package/dist/editor/core/schema.d.ts +162 -0
- package/dist/editor/core/text.d.ts +17 -0
- package/dist/editor/core/units.d.ts +9 -0
- package/dist/editor/panels/ComponentShelf.vue.d.ts +2 -0
- package/dist/editor/panels/DesignerToolbar.vue.d.ts +2 -0
- package/dist/editor/panels/InspectorPanel.vue.d.ts +2 -0
- package/dist/editor/properties/AppearanceSection.vue.d.ts +6 -0
- package/dist/editor/properties/BaseSection.vue.d.ts +8 -0
- package/dist/editor/properties/CodeSection.vue.d.ts +6 -0
- package/dist/editor/properties/ComponentPropertySection.vue.d.ts +6 -0
- package/dist/editor/properties/GeometrySection.vue.d.ts +6 -0
- package/dist/editor/properties/TextSection.vue.d.ts +6 -0
- package/dist/editor/registry/components.d.ts +2 -0
- package/dist/editor/render/PrintElementContent.vue.d.ts +12 -0
- package/dist/editor/render/styles.d.ts +63 -0
- package/dist/editor/store/usePrintDesigner.d.ts +186 -0
- package/dist/editor/ui/BaseButton.vue.d.ts +21 -0
- package/dist/editor/ui/BaseColor.vue.d.ts +12 -0
- package/dist/editor/ui/BaseIconButton.vue.d.ts +8 -0
- package/dist/editor/ui/BaseIconGroup.vue.d.ts +14 -0
- package/dist/editor/ui/BaseInput.vue.d.ts +13 -0
- package/dist/editor/ui/BaseNumberInput.vue.d.ts +15 -0
- package/dist/editor/ui/BaseSegmented.vue.d.ts +14 -0
- package/dist/editor/ui/BaseSelect.vue.d.ts +14 -0
- package/dist/editor/ui/PropertyRow.vue.d.ts +20 -0
- package/dist/editor/ui/PropertySection.vue.d.ts +20 -0
- package/dist/favicon.ico +0 -0
- package/dist/favicon.svg +12 -0
- package/dist/html2canvas.esm-C4Mnoizn.cjs +22 -0
- package/dist/html2canvas.esm-dgT_1dIT.js +4871 -0
- package/dist/index-BEReyC5k.cjs +364 -0
- package/dist/index-DGkMLEeJ.js +18125 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.es-DGu5dqeR.js +6693 -0
- package/dist/index.es-Di9HyGPO.cjs +18 -0
- package/dist/index.mjs +21 -0
- package/dist/jspdf.es.min-BOsuRURv.js +10006 -0
- package/dist/jspdf.es.min-Cc_0fodg.cjs +217 -0
- package/dist/og-image.svg +56 -0
- package/dist/plugin.d.ts +9 -0
- package/dist/print-C0Dx8UZT.cjs +1 -0
- package/dist/print-CBevAO3L.js +705 -0
- package/dist/purify.es-BUDLCglq.cjs +3 -0
- package/dist/purify.es-CiEWEeUM.js +605 -0
- package/dist/robots.txt +4 -0
- package/dist/sitemap.xml +13 -0
- package/dist/style.css +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Commercial License
|
|
2
|
+
|
|
3
|
+
`print-canvas-designer` can be used for evaluation, learning, and non-commercial use under the repository `LICENSE`.
|
|
4
|
+
|
|
5
|
+
Commercial use requires a separate written commercial license from the author.
|
|
6
|
+
|
|
7
|
+
## When You Need a Commercial License
|
|
8
|
+
|
|
9
|
+
You need a commercial license if you use this package in any of the following scenarios:
|
|
10
|
+
|
|
11
|
+
- commercial products;
|
|
12
|
+
- internal business systems;
|
|
13
|
+
- SaaS platforms;
|
|
14
|
+
- customer delivery projects;
|
|
15
|
+
- production environments related to business operations;
|
|
16
|
+
- paid development, outsourcing, or implementation projects.
|
|
17
|
+
|
|
18
|
+
## What a Commercial License Can Allow
|
|
19
|
+
|
|
20
|
+
A commercial license may allow the authorized party to:
|
|
21
|
+
|
|
22
|
+
- integrate `print-canvas-designer` into authorized commercial projects;
|
|
23
|
+
- use it in production environments within the agreed scope;
|
|
24
|
+
- create custom components, custom inspectors, and business-specific rendering logic;
|
|
25
|
+
- customize styles, layouts, and interactions for the authorized project;
|
|
26
|
+
- make necessary source modifications for internal use within the authorized scope;
|
|
27
|
+
- receive updates and technical support within the agreed period.
|
|
28
|
+
|
|
29
|
+
## Restrictions
|
|
30
|
+
|
|
31
|
+
Unless explicitly permitted in a separate written agreement, the authorized party may not:
|
|
32
|
+
|
|
33
|
+
- redistribute, resell, rent, sublicense, or repackage this project or modified versions as a component library, SDK, low-code platform, print designer, template designer, or competing product;
|
|
34
|
+
- publish the source code, modified source code, build artifacts, or commercial feature packages to public npm registries, public repositories, or other public channels;
|
|
35
|
+
- remove, hide, or modify copyright, license, or attribution notices;
|
|
36
|
+
- share a single-project license across unrelated projects or organizations;
|
|
37
|
+
- transfer the license to another company, team, or project without written permission.
|
|
38
|
+
|
|
39
|
+
## License Scope
|
|
40
|
+
|
|
41
|
+
Commercial authorization can be granted by project, company, deployment scope, support period, and source access scope. The final scope is determined by the signed commercial agreement or written authorization.
|
|
42
|
+
|
|
43
|
+
## Contact
|
|
44
|
+
|
|
45
|
+
For commercial authorization, integration support, or source licensing, contact the author through the project website or GitHub repository.
|
|
46
|
+
|
|
47
|
+
This document is a commercial license outline. The final commercial license terms are subject to the written agreement between the author and the authorized party.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
print-canvas-designer Non-Commercial Evaluation License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 junjie-zeng
|
|
4
|
+
|
|
5
|
+
This software and its documentation are provided for evaluation, learning,
|
|
6
|
+
research, and other non-commercial use only.
|
|
7
|
+
|
|
8
|
+
You may:
|
|
9
|
+
- install and use the software for evaluation, learning, and non-commercial projects;
|
|
10
|
+
- build prototypes and proof-of-concept integrations;
|
|
11
|
+
- create custom components, custom inspectors, and business-specific examples for evaluation;
|
|
12
|
+
- make local modifications for evaluation and non-commercial use.
|
|
13
|
+
|
|
14
|
+
You may not, without a separate written commercial license:
|
|
15
|
+
- use the software in commercial products, internal business systems, SaaS platforms,
|
|
16
|
+
customer delivery projects, or production environments related to business operations;
|
|
17
|
+
- redistribute, resell, rent, sublicense, or repackage the software or modified versions
|
|
18
|
+
as a component library, SDK, low-code platform, print designer, template designer, or
|
|
19
|
+
competing product;
|
|
20
|
+
- publish the source code, modified source code, build artifacts, or commercial feature
|
|
21
|
+
packages to public npm registries, public repositories, or other public channels;
|
|
22
|
+
- remove, hide, or modify copyright, license, or attribution notices;
|
|
23
|
+
- use the software outside the scope of this license.
|
|
24
|
+
|
|
25
|
+
Commercial use requires a paid commercial license. See COMMERCIAL_LICENSE.md for the
|
|
26
|
+
commercial license outline and contact the author for written authorization.
|
|
27
|
+
|
|
28
|
+
This software is provided "as is", without warranty of any kind, express or implied,
|
|
29
|
+
including but not limited to the warranties of merchantability, fitness for a particular
|
|
30
|
+
purpose, and noninfringement. In no event shall the author or copyright holder be liable
|
|
31
|
+
for any claim, damages, or other liability arising from the software or the use of the
|
|
32
|
+
software.
|
|
33
|
+
|
|
34
|
+
The author shall not be responsible for any business interruption, data loss, printing
|
|
35
|
+
errors, label errors, lost profits, or other direct, indirect, incidental, special, or
|
|
36
|
+
consequential losses caused by the use of, inability to use, or integration of the
|
|
37
|
+
software.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# print-canvas-designer
|
|
2
|
+
|
|
3
|
+
Vue 3 打印模板画布 SDK,用于在业务系统中搭建标签、单据、鞋盒标、物流面单等打印模板。它既可以作为完整编辑器使用,也可以只接入画布,由业务自己实现组件面板、属性面板和数据保存逻辑。
|
|
4
|
+
|
|
5
|
+
- 在线演示:https://junjie-zeng.github.io/projects/print-canvas-designer/
|
|
6
|
+
- Playground:https://junjie-zeng.github.io/projects/print-canvas-designer/playground.html
|
|
7
|
+
- GitHub Demo:https://github.com/junjie-zeng/print-canvas-designer
|
|
8
|
+
|
|
9
|
+
## 能做什么
|
|
10
|
+
|
|
11
|
+
- 搭建打印模板:支持文本、图片、矩形、横线、二维码、条形码等基础组件。
|
|
12
|
+
- 调整画布元素:支持选中、拖拽、缩放、旋转、复制、删除、锁定、隐藏和层级调整。
|
|
13
|
+
- 设置纸张:支持 A4、100 x 60、自定义纸张,以及裁切模式下的纸张区域展示。
|
|
14
|
+
- 辅助排版:支持标尺、网格、参考线、边距线、安全区和元素间距辅助线。
|
|
15
|
+
- 渲染业务数据:支持文本字段、运行时数据填充和文本换行策略。
|
|
16
|
+
- 处理图片:支持图片地址,也支持通过 `uploadImage` 接入业务自己的上传接口。
|
|
17
|
+
- 扩展组件:支持注册自定义业务组件,并为组件提供自己的右侧属性面板。
|
|
18
|
+
- 单独接入画布:可以只使用 `PrintCanvas`,把画布能力嵌入到已有业务系统中。
|
|
19
|
+
|
|
20
|
+
## 快速开始
|
|
21
|
+
|
|
22
|
+
### 1. 安装
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add print-canvas-designer
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
也可以使用 npm:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install print-canvas-designer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. 引入样式
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import 'print-canvas-designer/style.css'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3. 使用完整编辑器
|
|
41
|
+
|
|
42
|
+
```vue
|
|
43
|
+
<template>
|
|
44
|
+
<PrintDesigner
|
|
45
|
+
v-model="document"
|
|
46
|
+
:upload-image="uploadImage"
|
|
47
|
+
@save="handleSave"
|
|
48
|
+
@change="handleChange"
|
|
49
|
+
@select="handleSelect"
|
|
50
|
+
/>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup lang="ts">
|
|
54
|
+
import { ref } from 'vue'
|
|
55
|
+
import { PrintDesigner, createDefaultDocument, type PrintDocument, type PrintElement } from 'print-canvas-designer'
|
|
56
|
+
|
|
57
|
+
const document = ref<PrintDocument>(createDefaultDocument())
|
|
58
|
+
|
|
59
|
+
const uploadImage = async (file: File) => {
|
|
60
|
+
const form = new FormData()
|
|
61
|
+
form.append('file', file)
|
|
62
|
+
const response = await fetch('/api/upload', { method: 'POST', body: form })
|
|
63
|
+
const result = await response.json()
|
|
64
|
+
return result.url
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const handleSave = (value: PrintDocument) => {
|
|
68
|
+
console.log('save', value)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const handleChange = (value: PrintDocument) => {
|
|
72
|
+
console.log('change', value)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const handleSelect = (value: PrintElement | null) => {
|
|
76
|
+
console.log('select', value)
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 4. 只接入画布
|
|
82
|
+
|
|
83
|
+
如果业务系统只需要画布,可以使用 `PrintCanvas`,左侧组件面板和右侧属性面板由业务自己实现。
|
|
84
|
+
|
|
85
|
+
```vue
|
|
86
|
+
<template>
|
|
87
|
+
<PrintCanvas :designer="designer" />
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<script setup lang="ts">
|
|
91
|
+
import {
|
|
92
|
+
PrintCanvas,
|
|
93
|
+
createDefaultDocument,
|
|
94
|
+
createPrintDesigner,
|
|
95
|
+
providePrintDesigner
|
|
96
|
+
} from 'print-canvas-designer'
|
|
97
|
+
|
|
98
|
+
const designer = createPrintDesigner({
|
|
99
|
+
modelValue: createDefaultDocument(),
|
|
100
|
+
onChange(value) {
|
|
101
|
+
saveDraft(value)
|
|
102
|
+
},
|
|
103
|
+
onSave(value) {
|
|
104
|
+
saveTemplate(value)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
providePrintDesigner(designer)
|
|
109
|
+
</script>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
业务面板可以通过同一个 `designer` 操作画布:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
designer.addElement('text', { x: 24, y: 24 })
|
|
116
|
+
designer.updateElement(activeId, { field: 'styleColorSize' })
|
|
117
|
+
designer.updateElementStyle(activeId, { width: 180, height: 42 })
|
|
118
|
+
designer.removeElement(activeId)
|
|
119
|
+
designer.save()
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 打开演示
|
|
123
|
+
|
|
124
|
+
预设的线上演示地址:
|
|
125
|
+
|
|
126
|
+
- 官网:https://junjie-zeng.github.io/projects/print-canvas-designer/
|
|
127
|
+
- 画布演示:https://junjie-zeng.github.io/projects/print-canvas-designer/playground.html
|
|
128
|
+
- GitHub Demo:https://github.com/junjie-zeng/print-canvas-designer
|
|
129
|
+
|
|
130
|
+
## 版本要求
|
|
131
|
+
|
|
132
|
+
- Vue:`^3.4.0 || ^3.5.0`
|
|
133
|
+
- Node.js:建议 18 及以上
|
|
134
|
+
|
|
135
|
+
## 授权说明
|
|
136
|
+
|
|
137
|
+
本包可用于学习、评估和非商业场景。商业项目、企业内部系统、SaaS 平台、客户交付项目、生产环境使用,需要先获得商业授权。
|
|
138
|
+
|
|
139
|
+
商业授权允许在授权范围内集成到业务系统中,也允许编写自定义组件、自定义属性面板和业务渲染逻辑。未经额外书面授权,不允许将本项目或其衍生版本作为组件库、SDK、低代码平台、打印设计器、模板设计器或同类竞争产品进行转售、转授权、公开发布。
|
|
140
|
+
|
|
141
|
+
具体规则见包内 `LICENSE` 和 `COMMERCIAL_LICENSE.md`。第三方依赖声明见 `THIRD_PARTY_NOTICES.md`。
|
|
142
|
+
|
|
143
|
+
如中文说明与包内英文授权文件存在差异,以英文授权文件为准。
|
|
144
|
+
|
|
145
|
+
## 说明
|
|
146
|
+
|
|
147
|
+
这个包聚焦打印模板编辑和画布能力,不绑定具体业务数据来源。实际项目中,模板保存、图片上传、字段拼接、打印渲染数据都应该接入自己的业务接口。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
`print-canvas-designer` includes or depends on third-party open source software. These third-party packages are licensed under their own license terms.
|
|
4
|
+
|
|
5
|
+
The commercial license for `print-canvas-designer` does not replace or remove the license terms of these third-party packages.
|
|
6
|
+
|
|
7
|
+
## Runtime Dependencies
|
|
8
|
+
|
|
9
|
+
| Package | Version | License | Copyright / Author | Project |
|
|
10
|
+
| --- | --- | --- | --- | --- |
|
|
11
|
+
| `vue` | 3.5.34 | MIT | Evan You | https://vuejs.org/ |
|
|
12
|
+
| `jsbarcode` | 3.12.3 | MIT | Johan Lindell | https://github.com/lindell/JsBarcode |
|
|
13
|
+
| `moveable` | 0.53.0 | MIT | Daybrush | https://daybrush.com/moveable/ |
|
|
14
|
+
| `qrcode` | 1.5.4 | MIT | Ryan Day | https://github.com/soldair/node-qrcode |
|
|
15
|
+
|
|
16
|
+
## License Notes
|
|
17
|
+
|
|
18
|
+
MIT licensed packages generally allow use, modification, distribution, and commercial use, provided that the copyright notice and permission notice are included in copies or substantial portions of the software.
|
|
19
|
+
|
|
20
|
+
For exact terms, refer to each package's published license file.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PrintDesignerProps, PrintDocument, PrintElement } from '../editor/core/schema';
|
|
2
|
+
declare function __VLS_template(): {
|
|
3
|
+
attrs: Partial<{}>;
|
|
4
|
+
slots: {
|
|
5
|
+
toolbar?(_: {
|
|
6
|
+
designer: import('..').PrintDesignerContext;
|
|
7
|
+
}): any;
|
|
8
|
+
left?(_: {
|
|
9
|
+
designer: import('..').PrintDesignerContext;
|
|
10
|
+
}): any;
|
|
11
|
+
canvas?(_: {
|
|
12
|
+
designer: import('..').PrintDesignerContext;
|
|
13
|
+
}): any;
|
|
14
|
+
right?(_: {
|
|
15
|
+
designer: import('..').PrintDesignerContext;
|
|
16
|
+
}): any;
|
|
17
|
+
};
|
|
18
|
+
refs: {};
|
|
19
|
+
rootEl: HTMLDivElement;
|
|
20
|
+
};
|
|
21
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
22
|
+
declare const __VLS_component: import('vue').DefineComponent<PrintDesignerProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
23
|
+
select: (value: PrintElement<Record<string, unknown>> | null) => any;
|
|
24
|
+
"update:modelValue": (value: PrintDocument) => any;
|
|
25
|
+
save: (value: PrintDocument) => any;
|
|
26
|
+
preview: (value: PrintDocument) => any;
|
|
27
|
+
print: (value: PrintDocument) => any;
|
|
28
|
+
"export-pdf": (value: PrintDocument) => any;
|
|
29
|
+
change: (value: PrintDocument) => any;
|
|
30
|
+
}, string, import('vue').PublicProps, Readonly<PrintDesignerProps> & Readonly<{
|
|
31
|
+
onSelect?: ((value: PrintElement<Record<string, unknown>> | null) => any) | undefined;
|
|
32
|
+
"onUpdate:modelValue"?: ((value: PrintDocument) => any) | undefined;
|
|
33
|
+
onSave?: ((value: PrintDocument) => any) | undefined;
|
|
34
|
+
onPreview?: ((value: PrintDocument) => any) | undefined;
|
|
35
|
+
onPrint?: ((value: PrintDocument) => any) | undefined;
|
|
36
|
+
"onExport-pdf"?: ((value: PrintDocument) => any) | undefined;
|
|
37
|
+
onChange?: ((value: PrintDocument) => any) | undefined;
|
|
38
|
+
}>, {
|
|
39
|
+
height: string | number;
|
|
40
|
+
readonly: boolean;
|
|
41
|
+
initialZoom: number;
|
|
42
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
43
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
44
|
+
export default _default;
|
|
45
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
46
|
+
new (): {
|
|
47
|
+
$slots: S;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PrintComponentDefinition, PrintDocument } from '../editor/core/schema';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
document: PrintDocument;
|
|
4
|
+
components?: PrintComponentDefinition[];
|
|
5
|
+
data?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PrintElement } from '../core/schema';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
element: PrintElement;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
6
|
+
svgRef: SVGSVGElement;
|
|
7
|
+
}, HTMLDivElement>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PrintElement } from '../core/schema';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
element: PrintElement;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
6
|
+
"context-menu": (event: MouseEvent, id: string) => any;
|
|
7
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
"onContext-menu"?: ((event: MouseEvent, id: string) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
viewportRef?: HTMLElement;
|
|
3
|
+
};
|
|
4
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
5
|
+
pageRef: HTMLDivElement;
|
|
6
|
+
}, HTMLDivElement>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PrintElement } from '../core/schema';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
element: PrintElement;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PrintElement } from '../core/schema';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
element: PrintElement;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
6
|
+
editableRef: HTMLDivElement;
|
|
7
|
+
}, HTMLDivElement>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
pageRef?: HTMLDivElement;
|
|
3
|
+
viewportRef?: HTMLElement;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PrintDesignerContext } from '../store/usePrintDesigner';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
designer?: PrintDesignerContext;
|
|
4
|
+
data?: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
7
|
+
viewportRef: HTMLElement;
|
|
8
|
+
zoomSpaceRef: HTMLDivElement;
|
|
9
|
+
}, HTMLElement>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const elementPointerDownEvent = "pcd:element-pointer-down";
|
|
2
|
+
export declare const locateElementEvent = "pcd:locate-element";
|
|
3
|
+
export interface ElementPointerDownDetail {
|
|
4
|
+
id: string;
|
|
5
|
+
inputEvent: MouseEvent;
|
|
6
|
+
}
|
|
7
|
+
export interface LocateElementDetail {
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CanvasPoint, BuiltinElementType, PrintDocument, PrintElement, PrintElementStyle, PrintPage, PrintPageOptions, PrintPaperType } from './schema';
|
|
2
|
+
export declare const DEFAULT_PAGE_MARGIN = 24;
|
|
3
|
+
export declare const A4_PAGE: PrintPageOptions;
|
|
4
|
+
export declare const LABEL_100X60_PAGE: PrintPageOptions;
|
|
5
|
+
export declare const PAPER_PRESETS: Record<Exclude<PrintPaperType, 'custom'>, PrintPageOptions & {
|
|
6
|
+
label: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const createId: (prefix?: string) => string;
|
|
9
|
+
export declare const createDefaultPage: (options?: Partial<PrintPageOptions>) => PrintPage;
|
|
10
|
+
export declare const createDefaultDocument: (options?: Partial<PrintPageOptions>) => PrintDocument;
|
|
11
|
+
export declare const baseElementStyle: (point: CanvasPoint) => PrintElementStyle;
|
|
12
|
+
export declare const createDefaultElement: (type: BuiltinElementType, point?: CanvasPoint) => PrintElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CanvasPoint, PrintElementStyle } from './schema';
|
|
2
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
3
|
+
export declare const roundLayoutValue: (value: number) => number;
|
|
4
|
+
export declare const clientPointToCanvasPoint: (event: DragEvent | MouseEvent, canvasRect: DOMRect, zoomRatio: number) => CanvasPoint;
|
|
5
|
+
export declare const normalizeElementStyle: (style: PrintElementStyle, pageWidth: number, pageHeight: number) => PrintElementStyle;
|
|
6
|
+
export declare const fitElementStyleIntoPage: (style: PrintElementStyle, pageWidth: number, pageHeight: number, minWidth?: number, minHeight?: number) => PrintElementStyle;
|
|
7
|
+
export declare const toCssPixel: (value?: string | number) => string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class HistoryStack<T> {
|
|
2
|
+
private readonly clone;
|
|
3
|
+
private past;
|
|
4
|
+
private future;
|
|
5
|
+
constructor(clone: (value: T) => T);
|
|
6
|
+
get canUndo(): boolean;
|
|
7
|
+
get canRedo(): boolean;
|
|
8
|
+
capture(value: T): void;
|
|
9
|
+
undo(current: T): T | null;
|
|
10
|
+
redo(current: T): T | null;
|
|
11
|
+
reset(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const cloneJson: <T>(value: T) => T;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
export type BuiltinElementType = 'text' | 'image' | 'rect' | 'line' | 'qrcode' | 'barcode';
|
|
3
|
+
export type CustomElementType = string & {};
|
|
4
|
+
export type PrintElementType = BuiltinElementType | CustomElementType;
|
|
5
|
+
export type PrintPaperType = 'a4' | 'label-100x60' | 'custom';
|
|
6
|
+
export type PrintPageOrientation = 'portrait' | 'landscape';
|
|
7
|
+
export type PrintSizeUnit = 'px' | 'mm' | 'pt';
|
|
8
|
+
export type PrintTextWrapMode = 'wrap' | 'nowrap' | 'ellipsis' | 'clip';
|
|
9
|
+
export type QrcodeErrorCorrectionLevel = 'L' | 'M' | 'Q' | 'H';
|
|
10
|
+
export type PrintRuntimeData = Record<string, unknown>;
|
|
11
|
+
export type PrintPropSchemaType = 'text' | 'number' | 'boolean' | 'select' | 'color';
|
|
12
|
+
export interface CanvasPoint {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}
|
|
16
|
+
export interface PrintDocument {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
page: PrintPage;
|
|
20
|
+
}
|
|
21
|
+
export interface PrintPage {
|
|
22
|
+
id: string;
|
|
23
|
+
type: 'page';
|
|
24
|
+
paperType?: PrintPaperType;
|
|
25
|
+
orientation?: PrintPageOrientation;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
margin?: {
|
|
29
|
+
top: number;
|
|
30
|
+
right: number;
|
|
31
|
+
bottom: number;
|
|
32
|
+
left: number;
|
|
33
|
+
};
|
|
34
|
+
backgroundColor: string;
|
|
35
|
+
items: PrintElement[];
|
|
36
|
+
}
|
|
37
|
+
export interface PrintElement<TProps = Record<string, unknown>> {
|
|
38
|
+
id: string;
|
|
39
|
+
type: PrintElementType;
|
|
40
|
+
name: string;
|
|
41
|
+
field?: string;
|
|
42
|
+
props?: TProps;
|
|
43
|
+
text?: string;
|
|
44
|
+
src?: string;
|
|
45
|
+
value?: string;
|
|
46
|
+
barcodeFormat?: string;
|
|
47
|
+
showBarcodeText?: boolean;
|
|
48
|
+
barcodeTextFontSize?: number;
|
|
49
|
+
barcodeTextPosition?: 'top' | 'bottom';
|
|
50
|
+
barcodeTextAlign?: 'left' | 'center' | 'right';
|
|
51
|
+
barcodeTextMargin?: number;
|
|
52
|
+
barcodeMargin?: number;
|
|
53
|
+
qrcodeErrorCorrectionLevel?: QrcodeErrorCorrectionLevel;
|
|
54
|
+
qrcodeMargin?: number;
|
|
55
|
+
barcodeLineWidth?: number;
|
|
56
|
+
barcodeHeight?: number;
|
|
57
|
+
locked?: boolean;
|
|
58
|
+
hidden?: boolean;
|
|
59
|
+
style: PrintElementStyle;
|
|
60
|
+
}
|
|
61
|
+
export interface PrintElementStyle {
|
|
62
|
+
position: 'absolute';
|
|
63
|
+
left: number;
|
|
64
|
+
top: number;
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
rotate?: number;
|
|
68
|
+
color?: string;
|
|
69
|
+
backgroundColor?: string;
|
|
70
|
+
fontSize?: number;
|
|
71
|
+
fontWeight?: string | number;
|
|
72
|
+
fontStyle?: string;
|
|
73
|
+
textDecoration?: string;
|
|
74
|
+
justifyContent?: string;
|
|
75
|
+
alignItems?: string;
|
|
76
|
+
textAlign?: string;
|
|
77
|
+
textWrapMode?: PrintTextWrapMode;
|
|
78
|
+
whiteSpace?: string;
|
|
79
|
+
textOverflow?: string;
|
|
80
|
+
wordBreak?: string;
|
|
81
|
+
overflowWrap?: string;
|
|
82
|
+
letterSpacing?: number;
|
|
83
|
+
borderColor?: string;
|
|
84
|
+
borderWidth?: number;
|
|
85
|
+
borderStyle?: string;
|
|
86
|
+
borderRadius?: number;
|
|
87
|
+
lineHeight?: string | number;
|
|
88
|
+
objectFit?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface PrintPageOptions {
|
|
91
|
+
width: number;
|
|
92
|
+
height: number;
|
|
93
|
+
orientation: PrintPageOrientation;
|
|
94
|
+
margin: PrintPage['margin'];
|
|
95
|
+
backgroundColor: string;
|
|
96
|
+
}
|
|
97
|
+
export interface PrintPropSchemaOption {
|
|
98
|
+
label: string;
|
|
99
|
+
value: string | number;
|
|
100
|
+
}
|
|
101
|
+
export interface PrintPropSchema {
|
|
102
|
+
key: string;
|
|
103
|
+
label: string;
|
|
104
|
+
type: PrintPropSchemaType;
|
|
105
|
+
defaultValue?: unknown;
|
|
106
|
+
placeholder?: string;
|
|
107
|
+
min?: number;
|
|
108
|
+
max?: number;
|
|
109
|
+
step?: number;
|
|
110
|
+
options?: PrintPropSchemaOption[];
|
|
111
|
+
}
|
|
112
|
+
export type PrintComponentUpdateElement<TProps = Record<string, unknown>> = (patch: Partial<PrintElement<TProps>>, capture?: boolean, emit?: boolean) => void;
|
|
113
|
+
export type PrintComponentUpdateElementStyle = (patch: Partial<PrintElementStyle>, capture?: boolean, keepInPage?: boolean, emit?: boolean) => void;
|
|
114
|
+
export interface PrintComponentRenderProps<TProps = Record<string, unknown>, TDesigner = unknown> {
|
|
115
|
+
element: PrintElement<TProps>;
|
|
116
|
+
readonly: boolean;
|
|
117
|
+
selected: boolean;
|
|
118
|
+
editable: boolean;
|
|
119
|
+
data?: PrintRuntimeData;
|
|
120
|
+
designer?: TDesigner;
|
|
121
|
+
}
|
|
122
|
+
export interface PrintComponentInspectorProps<TProps = Record<string, unknown>, TDesigner = unknown> {
|
|
123
|
+
element: PrintElement<TProps>;
|
|
124
|
+
designer: TDesigner;
|
|
125
|
+
updateElement: PrintComponentUpdateElement<TProps>;
|
|
126
|
+
updateElementStyle: PrintComponentUpdateElementStyle;
|
|
127
|
+
}
|
|
128
|
+
export interface PrintComponentDefinition<TProps = Record<string, unknown>, TDesigner = unknown> {
|
|
129
|
+
type: PrintElementType;
|
|
130
|
+
label: string;
|
|
131
|
+
icon?: string;
|
|
132
|
+
createElement: (point: CanvasPoint) => PrintElement<TProps>;
|
|
133
|
+
render?: Component<PrintComponentRenderProps<TProps, TDesigner>>;
|
|
134
|
+
inspector?: Component<PrintComponentInspectorProps<TProps, TDesigner>>;
|
|
135
|
+
propSchema?: PrintPropSchema[];
|
|
136
|
+
defaultProps?: TProps;
|
|
137
|
+
}
|
|
138
|
+
export interface PrintDesignerPluginOptions {
|
|
139
|
+
components?: PrintComponentDefinition[];
|
|
140
|
+
uploadImage?: (file: File) => Promise<string>;
|
|
141
|
+
data?: PrintRuntimeData;
|
|
142
|
+
}
|
|
143
|
+
export interface PrintDesignerProps {
|
|
144
|
+
modelValue?: PrintDocument;
|
|
145
|
+
readonly?: boolean;
|
|
146
|
+
height?: string | number;
|
|
147
|
+
initialZoom?: number;
|
|
148
|
+
components?: PrintComponentDefinition[];
|
|
149
|
+
disabledComponents?: PrintElementType[];
|
|
150
|
+
pageOptions?: Partial<PrintPageOptions>;
|
|
151
|
+
uploadImage?: (file: File) => Promise<string>;
|
|
152
|
+
data?: PrintRuntimeData;
|
|
153
|
+
}
|
|
154
|
+
export interface PrintDesignerEmits {
|
|
155
|
+
(event: 'update:modelValue', value: PrintDocument): void;
|
|
156
|
+
(event: 'save', value: PrintDocument): void;
|
|
157
|
+
(event: 'preview', value: PrintDocument): void;
|
|
158
|
+
(event: 'print', value: PrintDocument): void;
|
|
159
|
+
(event: 'export-pdf', value: PrintDocument): void;
|
|
160
|
+
(event: 'change', value: PrintDocument): void;
|
|
161
|
+
(event: 'select', value: PrintElement | null): void;
|
|
162
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PrintTextWrapMode } from './schema';
|
|
2
|
+
export declare const getTextWrapStyle: (mode?: PrintTextWrapMode) => {
|
|
3
|
+
readonly whiteSpace: "nowrap";
|
|
4
|
+
readonly textOverflow: "clip";
|
|
5
|
+
readonly wordBreak: "normal";
|
|
6
|
+
readonly overflowWrap: "normal";
|
|
7
|
+
} | {
|
|
8
|
+
readonly whiteSpace: "nowrap";
|
|
9
|
+
readonly textOverflow: "ellipsis";
|
|
10
|
+
readonly wordBreak: "normal";
|
|
11
|
+
readonly overflowWrap: "normal";
|
|
12
|
+
} | {
|
|
13
|
+
readonly whiteSpace: "pre-wrap";
|
|
14
|
+
readonly textOverflow: "clip";
|
|
15
|
+
readonly wordBreak: "break-word";
|
|
16
|
+
readonly overflowWrap: "anywhere";
|
|
17
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PrintSizeUnit } from './schema';
|
|
2
|
+
export declare const mmToPx: (value: number) => number;
|
|
3
|
+
export declare const ptToPx: (value: number) => number;
|
|
4
|
+
export declare const pxToMm: (value: number) => number;
|
|
5
|
+
export declare const pxToPt: (value: number) => number;
|
|
6
|
+
export declare const roundUnitValue: (value: number, unit: PrintSizeUnit) => number;
|
|
7
|
+
export declare const pxToUnit: (value: number, unit: PrintSizeUnit) => number;
|
|
8
|
+
export declare const formatUnitText: (pxValue: number, unit: PrintSizeUnit) => string;
|
|
9
|
+
export declare const unitToPx: (value: number, unit: PrintSizeUnit) => number;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLElement>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLElement>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLElement>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PrintElement } from '../core/schema';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
element: PrintElement;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLElement>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PrintElement } from '../core/schema';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
element: PrintElement;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
6
|
+
fileInputRef: HTMLInputElement;
|
|
7
|
+
}, HTMLElement>;
|
|
8
|
+
export default _default;
|