dascom-le-editor 0.0.46 → 0.0.47
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/README.md +303 -165
- package/dist/Caladea-Regular.ttf +0 -0
- package/dist/LXGWWenKai-Regular.ttf +0 -0
- package/dist/LiberationSans-Regular.ttf +0 -0
- package/dist/SourceHanSansSC-Regular.otf +0 -0
- package/dist/SourceHanSerifSC-Regular.otf +0 -0
- package/dist/editor.css +1 -1
- package/dist/editor.js +1 -1
- package/dist/editor.umd.cjs +162 -162
- package/dist/{main-BSjahTJB.js → main-CLtXiyRH.js} +25056 -24616
- package/dist/{pdf-Cgs0gxwI.js → pdf-CJxxnGgk.js} +1 -1
- package/package.json +8 -1
package/README.md
CHANGED
|
@@ -37,46 +37,65 @@ npm install dascom-le-editor
|
|
|
37
37
|
## 使用
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
|
-
import 'dascom-le-editor/dist/editor.css'
|
|
41
|
-
import LabelEditor from 'dascom-le-editor'
|
|
40
|
+
import 'dascom-le-editor/dist/editor.css';
|
|
41
|
+
import LabelEditor from 'dascom-le-editor';
|
|
42
42
|
|
|
43
43
|
// 实例化,传入 html dom + 可选配置参数
|
|
44
44
|
const editorInstance = new LabelEditor(dom, {
|
|
45
45
|
// --- 画布 & 模板 ---
|
|
46
|
-
width: 85.6,
|
|
47
|
-
height: 54,
|
|
48
|
-
dpi: 203,
|
|
49
|
-
maxSize: 1,
|
|
46
|
+
width: 85.6, // 标签宽度 (mm),默认 85.6
|
|
47
|
+
height: 54, // 标签高度 (mm),默认 54
|
|
48
|
+
dpi: 203, // 画布渲染 DPI,默认 600
|
|
49
|
+
maxSize: 1, // 导出 JSON 最大大小 (MB),默认 10
|
|
50
50
|
|
|
51
51
|
// --- 功能开关 ---
|
|
52
|
-
showVarnish: true,
|
|
53
|
-
showLaser: 15,
|
|
54
|
-
showBusinessType: true,
|
|
55
|
-
locale: 'zh-CN',
|
|
52
|
+
showVarnish: true, // 是否显示光油配置面板,默认 false
|
|
53
|
+
showLaser: 15, // 激光配置最大预设数量。>0 开启;0 / false 不显示(默认 0)
|
|
54
|
+
showBusinessType: true, // 是否显示业务类型配置(businessType 下拉,适用所有控件),默认 false
|
|
55
|
+
locale: 'zh-CN', // 编辑器语言,默认跟随浏览器
|
|
56
56
|
// messages: { // 自定义翻译文案,深度合并到内置翻译(详见「语言」章节)
|
|
57
57
|
// 'zh-CN': { editor: { shell: { print: '发送到打印机' } } },
|
|
58
58
|
// },
|
|
59
|
-
layerMaxCount: 2,
|
|
60
|
-
separateLayerMode: false,
|
|
61
|
-
separateLayerCount: 2,
|
|
59
|
+
layerMaxCount: 2, // 最大图层数 (>1 才展示多图层编辑),默认 1;文件 JSON 内配置优先
|
|
60
|
+
separateLayerMode: false, // 是否启用分联图层模式,默认 false
|
|
61
|
+
separateLayerCount: 2, // 分联图层数,默认 2
|
|
62
62
|
separateLayerNames: ['上联', '下联'], // 分联图层名称,按图层顺序配置
|
|
63
|
-
layerStyleIndependent: false,
|
|
64
|
-
enableLayerType: true,
|
|
63
|
+
layerStyleIndependent: false, // 图层背景和描边是否独立,默认 false
|
|
64
|
+
enableLayerType: true, // 开启「新建图层选择类型」功能(卡机正/反、激光正/反)。默认 false,不需要的系统勿开启
|
|
65
65
|
|
|
66
66
|
// --- 菜单 & 工具栏 ---
|
|
67
67
|
visibleMenus: ['edit', 'view', 'tool'], // 顶部菜单栏分区,不传则全部显示
|
|
68
|
-
enabledTools: [
|
|
69
|
-
|
|
70
|
-
'
|
|
68
|
+
enabledTools: [
|
|
69
|
+
// 启用的工具栏组件(白名单),不传则全部启用
|
|
70
|
+
'rect',
|
|
71
|
+
'circle',
|
|
72
|
+
'line',
|
|
73
|
+
'text',
|
|
74
|
+
'barcode',
|
|
75
|
+
'barcode2d',
|
|
76
|
+
'image',
|
|
77
|
+
'counter',
|
|
78
|
+
'json',
|
|
79
|
+
'table',
|
|
71
80
|
],
|
|
72
|
-
disabledTools: ['textname'],
|
|
81
|
+
disabledTools: ['textname'], // 禁用的工具栏组件(黑名单)
|
|
73
82
|
disabledMenuItems: ['edit:tagSettings'], // 隐藏指定二级菜单项(黑名单)
|
|
74
|
-
enabledMenuItems: [
|
|
75
|
-
|
|
76
|
-
'edit:
|
|
77
|
-
'
|
|
83
|
+
enabledMenuItems: [
|
|
84
|
+
// 启用的二级菜单项(白名单),白名单优先
|
|
85
|
+
'edit:undo',
|
|
86
|
+
'edit:redo',
|
|
87
|
+
'edit:copy',
|
|
88
|
+
'edit:paste',
|
|
89
|
+
'edit:cut',
|
|
90
|
+
'edit:delete',
|
|
91
|
+
'edit:exportImage',
|
|
92
|
+
'edit:tagSettings',
|
|
93
|
+
'view:objectProps',
|
|
94
|
+
'view:zoom',
|
|
95
|
+
'view:ruler',
|
|
96
|
+
'view:grid',
|
|
78
97
|
],
|
|
79
|
-
})
|
|
98
|
+
});
|
|
80
99
|
```
|
|
81
100
|
|
|
82
101
|
## API 参考
|
|
@@ -85,35 +104,36 @@ const editorInstance = new LabelEditor(dom, {
|
|
|
85
104
|
|
|
86
105
|
`new LabelEditor(el: HTMLElement, options?: EditorConfigOptions)`
|
|
87
106
|
|
|
88
|
-
| 参数
|
|
89
|
-
|
|
|
90
|
-
| `width`
|
|
91
|
-
| `height`
|
|
92
|
-
| `dpi`
|
|
93
|
-
| `pageShape`
|
|
94
|
-
| `maxSize`
|
|
95
|
-
| `showVarnish`
|
|
96
|
-
| `showLaser`
|
|
97
|
-
| `showBusinessType`
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
107
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
108
|
+
| ----------------------- | ------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
109
|
+
| `width` | `number` | 85.6 | 标签宽度 (mm) |
|
|
110
|
+
| `height` | `number` | 54 | 标签高度 (mm) |
|
|
111
|
+
| `dpi` | `number` | 203 | 画布渲染 DPI |
|
|
112
|
+
| `pageShape` | `'Rectangle' \| 'RoundedRectangle' \| 'Ellipse'` | `'Rectangle'` | 新建模板的页面形状默认值;文件 JSON 内已保存的 pageShape 优先于本参数 |
|
|
113
|
+
| `maxSize` | `number` | 0 | 导出 JSON 最大大小 (MB), 0不限制 |
|
|
114
|
+
| `showVarnish` | `boolean` | false | 是否显示光油配置面板 |
|
|
115
|
+
| `showLaser` | `number \| boolean` | 0 | 激光配置最大预设数量。>0 开启,true → 16,0/false 不显示 |
|
|
116
|
+
| `showBusinessType` | `boolean` | false | 是否显示「业务类型」配置(businessType 下拉,适用所有控件);默认关闭,未接入则不显示 |
|
|
117
|
+
| `showRibbonPattern` | `boolean` | false | 是否启用「描边图案」配置。关闭时不显示配置入口,且画布/预览/导出均不应用图案;**只抑制显示,不改写模板里已保存的 ribbonBorder**,重新开启后仍能恢复 |
|
|
118
|
+
| `locale` | `string` | 浏览器语言 | 编辑器语言。支持 `'zh-CN'` / `'en-US'`,其余降级为 `zh-CN` |
|
|
119
|
+
| `messages` | `Record<'zh-CN' \| 'en-US', MessageTree>` | - | 自定义翻译文案,深度合并到内置翻译中(仅需传入要覆盖的 key) |
|
|
120
|
+
| `layerMaxCount` | `number \| string` | 1 | 最大图层数,文件 JSON 内配置优先 |
|
|
121
|
+
| `separateLayerMode` | `boolean` | false | 分联图层模式 |
|
|
122
|
+
| `separateLayerCount` | `number \| string` | 2 | 分联图层数 |
|
|
123
|
+
| `separateLayerNames` | `string[]` | - | 分联图层名称 |
|
|
124
|
+
| `layerStyleIndependent` | `boolean` | false | 图层背景和描边是否独立 |
|
|
125
|
+
| `enableLayerType` | `boolean` | false | 开启新建图层类型选择(卡机正面/卡机反面/激光正面/激光反面,对应稳定 id `Layer-FrontSide`/`Layer-BackSide`/`Laser-FrontSide`/`Laser-BackSide`);默认关闭,对不需要此功能的系统零侵入 |
|
|
126
|
+
| `visibleMenus` | `string[]` | 全部 | 菜单栏分区白名单 |
|
|
127
|
+
| `enabledTools` | `string[]` | 全部 | 工具栏组件白名单 |
|
|
128
|
+
| `disabledTools` | `string[]` | [] | 工具栏组件黑名单 |
|
|
129
|
+
| `enabledMenuItems` | `string[]` | 全部 | 二级菜单项白名单,与黑名单同时存在时此优先 |
|
|
130
|
+
| `disabledMenuItems` | `string[]` | [] | 二级菜单项黑名单 |
|
|
111
131
|
|
|
112
132
|
### 实例属性
|
|
113
133
|
|
|
114
134
|
```js
|
|
115
135
|
// 当前已加载的自定义字体名 Set
|
|
116
|
-
editorInstance.loadedFonts
|
|
136
|
+
editorInstance.loadedFonts; // Set<string>
|
|
117
137
|
```
|
|
118
138
|
|
|
119
139
|
### 实例方法
|
|
@@ -122,7 +142,7 @@ editorInstance.loadedFonts // Set<string>
|
|
|
122
142
|
|
|
123
143
|
```js
|
|
124
144
|
// 销毁编辑器实例。页面卸载 / 重新创建前必须调用,避免内存泄漏和幽灵回调。
|
|
125
|
-
editorInstance.destroy()
|
|
145
|
+
editorInstance.destroy();
|
|
126
146
|
```
|
|
127
147
|
|
|
128
148
|
#### 文件操作
|
|
@@ -154,7 +174,7 @@ editorInstance.openAutoSave((json: string) => {
|
|
|
154
174
|
```js
|
|
155
175
|
// 插入当前文件的字段 JSON,供文本/条码/二维码绑定 JSON Key 使用。
|
|
156
176
|
// 支持传入对象或合法 JSON 字符串。返回 true 表示写入成功或已排队。
|
|
157
|
-
const ok = editorInstance.insertFileFieldJson({ name: '张三', code: 'A001' })
|
|
177
|
+
const ok = editorInstance.insertFileFieldJson({ name: '张三', code: 'A001' });
|
|
158
178
|
```
|
|
159
179
|
|
|
160
180
|
#### 图片导出
|
|
@@ -184,10 +204,10 @@ const separate = await editorInstance.exportImage({
|
|
|
184
204
|
|
|
185
205
|
```js
|
|
186
206
|
// 设置语言
|
|
187
|
-
editorInstance.setLocale('en-US')
|
|
207
|
+
editorInstance.setLocale('en-US');
|
|
188
208
|
|
|
189
209
|
// 获取当前语言
|
|
190
|
-
editorInstance.getLocale()
|
|
210
|
+
editorInstance.getLocale(); // 'en-US'
|
|
191
211
|
|
|
192
212
|
// 动态注入或覆盖翻译文案
|
|
193
213
|
editorInstance.setMessages({
|
|
@@ -202,7 +222,7 @@ editorInstance.setMessages({
|
|
|
202
222
|
label: 'Label',
|
|
203
223
|
},
|
|
204
224
|
},
|
|
205
|
-
})
|
|
225
|
+
});
|
|
206
226
|
```
|
|
207
227
|
|
|
208
228
|
**支持的语言**: `'zh-CN'` | `'en-US'`。传入其他值会降级为 `'zh-CN'` 并在控制台给出 warning。
|
|
@@ -211,15 +231,15 @@ editorInstance.setMessages({
|
|
|
211
231
|
|
|
212
232
|
翻译按命名空间组织,与内置 JSON 文件的层级一致。键名——即你在 UI 中看到的文案——可以通过 `setMessages` 覆盖或扩展。可用的命名空间:
|
|
213
233
|
|
|
214
|
-
| 命名空间
|
|
215
|
-
|
|
|
216
|
-
| `editor`
|
|
217
|
-
| `menu`
|
|
218
|
-
| `common`
|
|
219
|
-
| `print`
|
|
220
|
-
| `database` | `database.json`
|
|
221
|
-
| `rfid`
|
|
222
|
-
| `errors`
|
|
234
|
+
| 命名空间 | 对应 JSON 文件 | 覆盖范围 |
|
|
235
|
+
| ---------- | ---------------------------------------------- | ------------------------------------------------------------------ |
|
|
236
|
+
| `editor` | `packages/i18n/src/locales/{lang}/editor.json` | 画布、工具栏、属性面板、表格、图片、打印、激光等所有编辑器核心文案 |
|
|
237
|
+
| `menu` | `menu.json` | 顶部菜单栏(编辑、视图、工具) |
|
|
238
|
+
| `common` | `common.json` | 通用 UI 文案(按钮、提示) |
|
|
239
|
+
| `print` | `print.json` | 打印相关文案 |
|
|
240
|
+
| `database` | `database.json` | 数据库视图相关文案 |
|
|
241
|
+
| `rfid` | `rfid.json` | RFID 配置相关文案 |
|
|
242
|
+
| `errors` | `errors.json` | 错误信息文案 |
|
|
223
243
|
|
|
224
244
|
**三种传入时机:**
|
|
225
245
|
|
|
@@ -242,15 +262,15 @@ const editorInstance = new LabelEditor(dom, {
|
|
|
242
262
|
},
|
|
243
263
|
},
|
|
244
264
|
},
|
|
245
|
-
})
|
|
265
|
+
});
|
|
246
266
|
```
|
|
247
267
|
|
|
248
268
|
2. **运行时动态调用 `setMessages()`** —— 适合从服务端拉取翻译后注入:
|
|
249
269
|
|
|
250
270
|
```js
|
|
251
271
|
fetch('/api/locales/editor-zh-CN.json')
|
|
252
|
-
.then(res => res.json())
|
|
253
|
-
.then(data => editorInstance.setMessages({ 'zh-CN': data }))
|
|
272
|
+
.then((res) => res.json())
|
|
273
|
+
.then((data) => editorInstance.setMessages({ 'zh-CN': data }));
|
|
254
274
|
```
|
|
255
275
|
|
|
256
276
|
3. **`setMessages` 与内置文案的关系** —— **深度合并**,不会丢失未覆盖的 key:
|
|
@@ -264,44 +284,70 @@ editorInstance.setMessages({
|
|
|
264
284
|
shell: { print: '发送到打印机' },
|
|
265
285
|
},
|
|
266
286
|
},
|
|
267
|
-
})
|
|
287
|
+
});
|
|
268
288
|
// "发送到打印机" 替换 "打印",其余内置文案不变
|
|
269
289
|
```
|
|
270
290
|
|
|
271
|
-
|
|
272
291
|
#### 图层控制
|
|
273
292
|
|
|
274
293
|
```js
|
|
275
294
|
// 启用/禁用多图层编辑
|
|
276
|
-
editorInstance.setMultiLayerEnabled(true)
|
|
277
|
-
editorInstance.toggleMultiLayer(true)
|
|
295
|
+
editorInstance.setMultiLayerEnabled(true);
|
|
296
|
+
editorInstance.toggleMultiLayer(true); // 别名,相同功能
|
|
278
297
|
|
|
279
298
|
// 设置图层最大数量(非分联模式下生效)
|
|
280
|
-
editorInstance.setLayerMaxCount(3)
|
|
299
|
+
editorInstance.setLayerMaxCount(3);
|
|
281
300
|
|
|
282
301
|
// 设置分联图层模式
|
|
283
|
-
editorInstance.setSeparateLayerMode(true)
|
|
302
|
+
editorInstance.setSeparateLayerMode(true);
|
|
284
303
|
|
|
285
304
|
// 快速进入双联模式(图层名称默认为「上联」「下联」)
|
|
286
|
-
editorInstance.enterDoubleRibbons()
|
|
305
|
+
editorInstance.enterDoubleRibbons();
|
|
287
306
|
|
|
288
307
|
// 更新分联图层配置,仅在分联模式开启时同步到已打开的 tab
|
|
289
|
-
editorInstance.setSeparateLayerConfig({ count: 2, names: ['上联', '下联'] })
|
|
308
|
+
editorInstance.setSeparateLayerConfig({ count: 2, names: ['上联', '下联'] });
|
|
290
309
|
|
|
291
310
|
// 开启/关闭独立图层样式(每个图层可单独设置背景色、背景图、描边)
|
|
292
|
-
await editorInstance.setLayerStyleIndependent(true)
|
|
311
|
+
await editorInstance.setLayerStyleIndependent(true);
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### 描边图案开关
|
|
315
|
+
|
|
316
|
+
```js
|
|
317
|
+
// 运行期切换「描边图案」功能(也可通过构造参数 showRibbonPattern 设定初值)
|
|
318
|
+
editorInstance.setShowRibbonPattern(true); // 显示配置入口 + 按已保存数据恢复图案
|
|
319
|
+
editorInstance.setShowRibbonPattern(false); // 隐藏入口 + 立即摘掉画布上的图案
|
|
293
320
|
```
|
|
294
321
|
|
|
322
|
+
> 关闭时**只抑制显示,不改写模板数据**:模板里已保存的 `ribbonBorder` 原样保留,
|
|
323
|
+
> 重新开启后图案会恢复。与 `enableLayerType`「数据保留不删」的处理取向一致。
|
|
324
|
+
|
|
295
325
|
#### UI 控制
|
|
296
326
|
|
|
297
327
|
```js
|
|
298
328
|
// 显示/隐藏文件 Tab 栏
|
|
299
|
-
editorInstance.toggleEditTabs(false)
|
|
329
|
+
editorInstance.toggleEditTabs(false);
|
|
300
330
|
```
|
|
301
331
|
|
|
302
332
|
#### 字体
|
|
303
333
|
|
|
304
334
|
```js
|
|
335
|
+
const editorInstance = new LabelEditor(container)
|
|
336
|
+
|
|
337
|
+
// Source Han Sans SC 已随插件发布,并在创建编辑器时自动加载。
|
|
338
|
+
// 在加载模板、导出图片或打印预览前等待它完成,保证文字度量一致。
|
|
339
|
+
await editorInstance.ready()
|
|
340
|
+
|
|
341
|
+
// 其余内置字体也随插件发布,但由宿主按模板需要按需加载。
|
|
342
|
+
await editorInstance.loadBuiltinFonts([
|
|
343
|
+
'Source Han Serif SC',
|
|
344
|
+
'LXGW WenKai',
|
|
345
|
+
])
|
|
346
|
+
await editorInstance.loadBuiltinFont('Caladea')
|
|
347
|
+
|
|
348
|
+
// 内置字体加载完成后再加载引用这些字体的模板。
|
|
349
|
+
editorInstance.loadJson(fileJson)
|
|
350
|
+
|
|
305
351
|
// 添加自定义字体列表。fontItem 含 url 时自动加载到页面。
|
|
306
352
|
editorInstance.addCustomFontList([
|
|
307
353
|
{ name: 'HanSans', url: 'https://example.com/HanSans.otf' },
|
|
@@ -321,6 +367,9 @@ editorInstance.selectFontCallback((fontNameList: string[]) => {
|
|
|
321
367
|
await editorInstance.loadFontFile({ fontName: 'HanSans', blob: fontBlob })
|
|
322
368
|
```
|
|
323
369
|
|
|
370
|
+
内置字体只保证浏览器编辑器、Canvas 预览和浏览器图片导出的字体一致性。
|
|
371
|
+
如果打印服务或驱动根据操作系统的 `FontName` 渲染,仍需在打印端安装或嵌入同一字体。
|
|
372
|
+
|
|
324
373
|
#### 激光配置
|
|
325
374
|
|
|
326
375
|
```js
|
|
@@ -335,51 +384,51 @@ editorInstance.setLaserConfigList([...])
|
|
|
335
384
|
const base64 = await LabelEditor.loadJsonToImageBase64(fileJson, {
|
|
336
385
|
cmds: [{ cmd: 'ReplaceContent', name: '姓名', content: '张三' }],
|
|
337
386
|
timeout: 5000,
|
|
338
|
-
})
|
|
387
|
+
});
|
|
339
388
|
|
|
340
389
|
// 静态导出方法,与实例 exportImage 相同但需要传入 data 字段
|
|
341
390
|
const result = await LabelEditor.exportImage({
|
|
342
391
|
data: fileJson,
|
|
343
392
|
mode: 'separate',
|
|
344
393
|
layout: 'doubleRibbons',
|
|
345
|
-
})
|
|
394
|
+
});
|
|
346
395
|
```
|
|
347
396
|
|
|
348
397
|
### 类型定义
|
|
349
398
|
|
|
350
399
|
```ts
|
|
351
|
-
type ExportImageMode = 'merged' | 'separate'
|
|
352
|
-
type ExportImageLayout = 'auto' | 'doubleRibbons'
|
|
400
|
+
type ExportImageMode = 'merged' | 'separate';
|
|
401
|
+
type ExportImageLayout = 'auto' | 'doubleRibbons';
|
|
353
402
|
|
|
354
403
|
type ExportImageSeparateResult = {
|
|
355
|
-
images: string[]
|
|
356
|
-
composedImage: string
|
|
357
|
-
}
|
|
404
|
+
images: string[];
|
|
405
|
+
composedImage: string;
|
|
406
|
+
};
|
|
358
407
|
|
|
359
|
-
type ExportImageResult = string | ExportImageSeparateResult
|
|
408
|
+
type ExportImageResult = string | ExportImageSeparateResult;
|
|
360
409
|
|
|
361
410
|
type ExportImageOptions = {
|
|
362
411
|
/** 静态导出时必传,实例方法无需传入 */
|
|
363
|
-
data?: any
|
|
412
|
+
data?: any;
|
|
364
413
|
/** 导出前替换 canvas 内容的命令 */
|
|
365
|
-
cmds?: Array<{ cmd: string; name: string; content: string }
|
|
414
|
+
cmds?: Array<{ cmd: string; name: string; content: string }>;
|
|
366
415
|
/** 超时时间 (ms),默认 5000 */
|
|
367
|
-
timeout?: number
|
|
416
|
+
timeout?: number;
|
|
368
417
|
/** 是否返回完整 dataURL,默认 false(返回纯 base64) */
|
|
369
|
-
returnDataUrl?: boolean
|
|
418
|
+
returnDataUrl?: boolean;
|
|
370
419
|
/** 画布 DPI,不传则用文件内的 DPI */
|
|
371
|
-
dpi?: number
|
|
420
|
+
dpi?: number;
|
|
372
421
|
/** 标签宽度 (mm) */
|
|
373
|
-
width?: number
|
|
422
|
+
width?: number;
|
|
374
423
|
/** 标签高度 (mm) */
|
|
375
|
-
height?: number
|
|
424
|
+
height?: number;
|
|
376
425
|
/** 多图层导出模式 */
|
|
377
|
-
mode?: ExportImageMode
|
|
426
|
+
mode?: ExportImageMode;
|
|
378
427
|
/** separate 时 composedImage 使用横向拼接 */
|
|
379
|
-
layout?: ExportImageLayout
|
|
428
|
+
layout?: ExportImageLayout;
|
|
380
429
|
/** 横向拼接间距,默认 50px */
|
|
381
|
-
gap?: number
|
|
382
|
-
}
|
|
430
|
+
gap?: number;
|
|
431
|
+
};
|
|
383
432
|
```
|
|
384
433
|
|
|
385
434
|
---
|
|
@@ -388,20 +437,20 @@ type ExportImageOptions = {
|
|
|
388
437
|
|
|
389
438
|
通过 `enabledMenuItems`(白名单)或 `disabledMenuItems`(黑名单)控制二级菜单项的显示/隐藏,两者同时存在时白名单优先。工具(T) 菜单下的二级菜单项由 `enabledTools` / `disabledTools` 控制,无需在此重复配置。
|
|
390
439
|
|
|
391
|
-
| 分区 | key
|
|
392
|
-
| ---- |
|
|
393
|
-
| 编辑 | `edit:undo`
|
|
394
|
-
| 编辑 | `edit:redo`
|
|
395
|
-
| 编辑 | `edit:copy`
|
|
396
|
-
| 编辑 | `edit:paste`
|
|
397
|
-
| 编辑 | `edit:cut`
|
|
398
|
-
| 编辑 | `edit:delete`
|
|
399
|
-
| 编辑 | `edit:exportImage` | 导出图片
|
|
400
|
-
| 编辑 | `edit:tagSettings` | 标签属性设置
|
|
401
|
-
| 视图 | `view:objectProps` | 对象属性
|
|
402
|
-
| 视图 | `view:zoom`
|
|
403
|
-
| 视图 | `view:ruler`
|
|
404
|
-
| 视图 | `view:grid`
|
|
440
|
+
| 分区 | key | 菜单项 |
|
|
441
|
+
| ---- | ------------------ | ------------------------------------ |
|
|
442
|
+
| 编辑 | `edit:undo` | 撤销 |
|
|
443
|
+
| 编辑 | `edit:redo` | 恢复 |
|
|
444
|
+
| 编辑 | `edit:copy` | 复制 |
|
|
445
|
+
| 编辑 | `edit:paste` | 粘贴 |
|
|
446
|
+
| 编辑 | `edit:cut` | 剪切 |
|
|
447
|
+
| 编辑 | `edit:delete` | 删除 |
|
|
448
|
+
| 编辑 | `edit:exportImage` | 导出图片 |
|
|
449
|
+
| 编辑 | `edit:tagSettings` | 标签属性设置 |
|
|
450
|
+
| 视图 | `view:objectProps` | 对象属性 |
|
|
451
|
+
| 视图 | `view:zoom` | 缩放(含子菜单:放大/缩小/自动缩放) |
|
|
452
|
+
| 视图 | `view:ruler` | 标尺(含子菜单:可见) |
|
|
453
|
+
| 视图 | `view:grid` | 网格(含子菜单:可见) |
|
|
405
454
|
|
|
406
455
|
---
|
|
407
456
|
|
|
@@ -416,7 +465,7 @@ type ExportImageOptions = {
|
|
|
416
465
|
```js
|
|
417
466
|
new LabelEditor(dom, {
|
|
418
467
|
showLaser: 15, // >0:开启且为最大可选预设数量;0 / false:不显示(默认 0)
|
|
419
|
-
})
|
|
468
|
+
});
|
|
420
469
|
```
|
|
421
470
|
|
|
422
471
|
### 设置预设列表(外部传入)
|
|
@@ -429,20 +478,108 @@ editorInstance.setLaserConfigList([
|
|
|
429
478
|
configId: 'preset_001',
|
|
430
479
|
configName: '默认参数',
|
|
431
480
|
params: [
|
|
432
|
-
{
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
{
|
|
442
|
-
|
|
481
|
+
{
|
|
482
|
+
key: 'repeatTimes',
|
|
483
|
+
label: '打标次数',
|
|
484
|
+
min: 0,
|
|
485
|
+
max: 10000,
|
|
486
|
+
unit: '',
|
|
487
|
+
defaultValue: 1,
|
|
488
|
+
status: 0,
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
key: 'scanSpeed',
|
|
492
|
+
label: '激光速度',
|
|
493
|
+
min: 0,
|
|
494
|
+
max: 65535,
|
|
495
|
+
unit: 'mm/s',
|
|
496
|
+
defaultValue: 3000,
|
|
497
|
+
status: 0,
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
key: 'jumpSpeed',
|
|
501
|
+
label: '跳转速度',
|
|
502
|
+
min: 0,
|
|
503
|
+
max: 65535,
|
|
504
|
+
unit: 'mm/s',
|
|
505
|
+
defaultValue: 3000,
|
|
506
|
+
status: 0,
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
key: 'power',
|
|
510
|
+
label: '功率',
|
|
511
|
+
min: 0,
|
|
512
|
+
max: 100,
|
|
513
|
+
unit: '%',
|
|
514
|
+
defaultValue: 20,
|
|
515
|
+
status: 1,
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
key: 'frequence',
|
|
519
|
+
label: '频率',
|
|
520
|
+
min: 0,
|
|
521
|
+
max: 4000,
|
|
522
|
+
unit: 'khz',
|
|
523
|
+
defaultValue: 200,
|
|
524
|
+
status: 0,
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
key: 'pulseWidth',
|
|
528
|
+
label: '脉宽',
|
|
529
|
+
min: 0,
|
|
530
|
+
max: 500,
|
|
531
|
+
unit: 'ns',
|
|
532
|
+
defaultValue: 50,
|
|
533
|
+
status: 0,
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
key: 'openLightDelay',
|
|
537
|
+
label: '开光延迟',
|
|
538
|
+
min: -1000,
|
|
539
|
+
max: 2000,
|
|
540
|
+
unit: 'us',
|
|
541
|
+
defaultValue: 0,
|
|
542
|
+
status: 0,
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
key: 'closeLightDelay',
|
|
546
|
+
label: '关光延迟',
|
|
547
|
+
min: -1000,
|
|
548
|
+
max: 2000,
|
|
549
|
+
unit: 'us',
|
|
550
|
+
defaultValue: 0,
|
|
551
|
+
status: 0,
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
key: 'endDelay',
|
|
555
|
+
label: '结束延迟',
|
|
556
|
+
min: 0,
|
|
557
|
+
max: 2000,
|
|
558
|
+
unit: 'us',
|
|
559
|
+
defaultValue: 0,
|
|
560
|
+
status: 0,
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
key: 'trunDelay',
|
|
564
|
+
label: '转角延时',
|
|
565
|
+
min: 0,
|
|
566
|
+
max: 2000,
|
|
567
|
+
unit: 'us',
|
|
568
|
+
defaultValue: 0,
|
|
569
|
+
status: 0,
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
key: 'jumpDelay',
|
|
573
|
+
label: '跳转延时',
|
|
574
|
+
min: 0,
|
|
575
|
+
max: 2000,
|
|
576
|
+
unit: 'us',
|
|
577
|
+
defaultValue: 0,
|
|
578
|
+
status: 0,
|
|
579
|
+
},
|
|
443
580
|
],
|
|
444
581
|
},
|
|
445
|
-
])
|
|
582
|
+
]);
|
|
446
583
|
```
|
|
447
584
|
|
|
448
585
|
> 以上 11 个字段为编辑器内置字段(`builtInFields`)。`setLaserConfigList` 可只传入部分字段,未传入的字段不会显示;传入的字段若未带 `status`,会回退到内置默认值(见下表)。
|
|
@@ -451,33 +588,33 @@ editorInstance.setLaserConfigList([
|
|
|
451
588
|
|
|
452
589
|
`status`:`1` 表示可编辑,`0` 或缺失表示禁用(输入框置灰)。
|
|
453
590
|
|
|
454
|
-
| key
|
|
455
|
-
|
|
|
456
|
-
| `repeatTimes`
|
|
457
|
-
| `scanSpeed`
|
|
458
|
-
| `jumpSpeed`
|
|
459
|
-
| `power`
|
|
460
|
-
| `frequence`
|
|
461
|
-
| `pulseWidth`
|
|
462
|
-
| `openLightDelay`
|
|
463
|
-
| `closeLightDelay` | 关光延迟 | -1000 | 2000
|
|
464
|
-
| `endDelay`
|
|
465
|
-
| `trunDelay`
|
|
466
|
-
| `jumpDelay`
|
|
591
|
+
| key | label | min | max | unit | defaultValue | status |
|
|
592
|
+
| ----------------- | -------- | ----- | ----- | ---- | ------------ | ------ |
|
|
593
|
+
| `repeatTimes` | 打标次数 | 0 | 10000 | - | 1 | 0 |
|
|
594
|
+
| `scanSpeed` | 激光速度 | 0 | 65535 | mm/s | 3000 | 0 |
|
|
595
|
+
| `jumpSpeed` | 跳转速度 | 0 | 65535 | mm/s | 3000 | 0 |
|
|
596
|
+
| `power` | 功率 | 0 | 100 | % | 20 | 1 |
|
|
597
|
+
| `frequence` | 频率 | 0 | 4000 | khz | 200 | 0 |
|
|
598
|
+
| `pulseWidth` | 脉宽 | 0 | 500 | ns | 50 | 0 |
|
|
599
|
+
| `openLightDelay` | 开光延迟 | -1000 | 2000 | us | 0 | 0 |
|
|
600
|
+
| `closeLightDelay` | 关光延迟 | -1000 | 2000 | us | 0 | 0 |
|
|
601
|
+
| `endDelay` | 结束延迟 | 0 | 2000 | us | 0 | 0 |
|
|
602
|
+
| `trunDelay` | 转角延时 | 0 | 2000 | us | 0 | 0 |
|
|
603
|
+
| `jumpDelay` | 跳转延时 | 0 | 2000 | us | 0 | 0 |
|
|
467
604
|
|
|
468
605
|
### 参数对象(FieldDef)字段说明
|
|
469
606
|
|
|
470
|
-
| 字段
|
|
471
|
-
|
|
|
472
|
-
| `configId`
|
|
473
|
-
| `configName`
|
|
474
|
-
| `params`
|
|
475
|
-
| `key`
|
|
476
|
-
| `label`
|
|
477
|
-
| `min` / `max`
|
|
478
|
-
| `unit`
|
|
479
|
-
| `defaultValue` | `number`
|
|
480
|
-
| `status`
|
|
607
|
+
| 字段 | 类型 | 必填 | 说明 |
|
|
608
|
+
| -------------- | ------------ | ---- | ---------------------------------------------------------------------------------- |
|
|
609
|
+
| `configId` | `string` | 是 | 预设唯一标识,用于外部与模板预设匹配 |
|
|
610
|
+
| `configName` | `string` | 是 | 预设显示名称 |
|
|
611
|
+
| `params` | `FieldDef[]` | 是 | 参数定义数组 |
|
|
612
|
+
| `key` | `string` | 是 | 字段标识,需与内置字段 key 对应(`power` 等)。非内置 key 也能显示,但不回退默认值 |
|
|
613
|
+
| `label` | `string` | 否 | 显示名称。若同时存在 `labelKey` 则优先走 i18n 翻译 |
|
|
614
|
+
| `min` / `max` | `number` | 是 | 数值范围,作用于输入框上下限 |
|
|
615
|
+
| `unit` | `string` | 否 | 单位后缀(`mm/s`、`%` 等),空则不显示 |
|
|
616
|
+
| `defaultValue` | `number` | 是 | 选中该预设时回填到输入框的初始值 |
|
|
617
|
+
| `status` | `number` | 否 | `1` 可编辑;`0` 或缺失则禁用,缺失时回退到内置 `status` |
|
|
481
618
|
|
|
482
619
|
### 数据流
|
|
483
620
|
|
|
@@ -498,8 +635,8 @@ editorInstance.setLaserConfigList([
|
|
|
498
635
|
|
|
499
636
|
```js
|
|
500
637
|
new LabelEditor(dom, {
|
|
501
|
-
enableLayerType: true,
|
|
502
|
-
})
|
|
638
|
+
enableLayerType: true, // 开启「新建图层选择类型」功能;默认 false
|
|
639
|
+
});
|
|
503
640
|
```
|
|
504
641
|
|
|
505
642
|
开启后行为:
|
|
@@ -516,12 +653,12 @@ new LabelEditor(dom, {
|
|
|
516
653
|
|
|
517
654
|
### 标准类型与唯一性
|
|
518
655
|
|
|
519
|
-
| 类型 id
|
|
520
|
-
|
|
|
521
|
-
| `Layer-FrontSide` | 卡机正面 | Card Front
|
|
522
|
-
| `Layer-BackSide`
|
|
656
|
+
| 类型 id | 中文案 | 英文案 |
|
|
657
|
+
| ----------------- | -------- | ----------- |
|
|
658
|
+
| `Layer-FrontSide` | 卡机正面 | Card Front |
|
|
659
|
+
| `Layer-BackSide` | 卡机反面 | Card Back |
|
|
523
660
|
| `Laser-FrontSide` | 激光正面 | Laser Front |
|
|
524
|
-
| `Laser-BackSide`
|
|
661
|
+
| `Laser-BackSide` | 激光反面 | Laser Back |
|
|
525
662
|
|
|
526
663
|
- 每种标准类型在**整个文档中最多出现一次**(全文档唯一);已被占用的类型在新建弹窗中自动置灰。
|
|
527
664
|
- 类型仅在**新建图层时**可选,建好后锁定不可改。
|
|
@@ -552,12 +689,12 @@ new LabelEditor(dom, {
|
|
|
552
689
|
|
|
553
690
|
打印设置相关的四个概念分为两层:
|
|
554
691
|
|
|
555
|
-
| 层
|
|
556
|
-
|
|
|
557
|
-
| 功能开关(主系统配置)
|
|
558
|
-
| 功能开关(主系统配置)
|
|
559
|
-
| 功能开关(主系统配置)
|
|
560
|
-
| 元素级数据(`customExportFields`) | `businessType`
|
|
692
|
+
| 层 | 概念 | 类型 | 说明 |
|
|
693
|
+
| ---------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
694
|
+
| 功能开关(主系统配置) | `showVarnish` | `boolean` | 控制「光油配置」块是否显示 |
|
|
695
|
+
| 功能开关(主系统配置) | `showLaser` | `number \| boolean` | 控制「激光配置」块是否显示(>0 或 `true` 开启) |
|
|
696
|
+
| 功能开关(主系统配置) | `showBusinessType` | `boolean` | 控制「业务类型」块(businessType 下拉)是否显示,适用于所有控件 |
|
|
697
|
+
| 元素级数据(`customExportFields`) | `businessType` | `'Normal' \| 'Mrz' \| 'MLI-Left-View' \| 'MLI-Right-View' \| 'CLI-Top-View' \| 'CLI-Bottom-View' \| 'Position'` | 业务类型,默认 `'Normal'`(常规)。**值为对外协议值,大小写/连字符按接口约定,勿改写** |
|
|
561
698
|
|
|
562
699
|
### 功能开关(主系统配置)
|
|
563
700
|
|
|
@@ -565,10 +702,10 @@ new LabelEditor(dom, {
|
|
|
565
702
|
|
|
566
703
|
```js
|
|
567
704
|
new LabelEditor(dom, {
|
|
568
|
-
showVarnish: true,
|
|
569
|
-
showLaser: 15,
|
|
570
|
-
showBusinessType: true,
|
|
571
|
-
})
|
|
705
|
+
showVarnish: true, // 显示光油配置块
|
|
706
|
+
showLaser: 15, // 显示激光配置块,并限制最大预设数量
|
|
707
|
+
showBusinessType: true, // 显示业务类型块(适用所有控件)
|
|
708
|
+
});
|
|
572
709
|
```
|
|
573
710
|
|
|
574
711
|
### 元素级数据(customExportFields)
|
|
@@ -578,14 +715,15 @@ new LabelEditor(dom, {
|
|
|
578
715
|
```json
|
|
579
716
|
{
|
|
580
717
|
"customExportFields": {
|
|
581
|
-
"businessType": "
|
|
718
|
+
"businessType": "Normal"
|
|
582
719
|
}
|
|
583
720
|
}
|
|
584
721
|
```
|
|
585
722
|
|
|
723
|
+
- 可选值(7 项,**值为对外协议值,请勿改写大小写与连字符**):`Normal`(常规)/ `Mrz` / `MLI-Left-View`(MLI左视图)/ `MLI-Right-View`(MLI右视图)/ `CLI-Top-View`(CLI上视图)/ `CLI-Bottom-View`(CLI下视图)/ `Position`(定位)
|
|
586
724
|
- 仅当 `showBusinessType` 开启且选中非 group 元素时,「业务类型」块才会出现并写入该字段;
|
|
587
725
|
- 主系统读取时直接从元素 `customExportFields` 中取 `businessType` 即可,无需新增接口;
|
|
588
|
-
- 当 `showBusinessType`
|
|
726
|
+
- 当 `showBusinessType` 关闭时,元素不会写入该字段(保持默认语义:常规)。
|
|
589
727
|
|
|
590
728
|
### 显隐规则
|
|
591
729
|
|
|
@@ -594,6 +732,6 @@ new LabelEditor(dom, {
|
|
|
594
732
|
- **tab 整体**:仅当 `showLaser` / `showVarnish` / `showBusinessType` 任一开启时才显示;三者全关时 tab 完全隐藏。
|
|
595
733
|
- **激光块**:`showLaser` 开启 且 当前选中元素非 `group` 时显示。
|
|
596
734
|
- **光油块**:`showVarnish` 开启 且 当前选中元素为文本或图片时显示。
|
|
597
|
-
- **业务类型块**:`showBusinessType` 开启 且 当前选中元素非 `group`、非空时显示(适用所有控件,下拉含
|
|
735
|
+
- **业务类型块**:`showBusinessType` 开启 且 当前选中元素非 `group`、非空时显示(适用所有控件,下拉含 常规 / MRZ / MLI左视图 / MLI右视图 / CLI上视图 / CLI下视图 / 定位 共 7 个选项)。
|
|
598
736
|
|
|
599
737
|
> 即:某主系统若未接入任何打印能力,右侧栏不会出现「打印设置」tab;接入了哪些能力,就只显示哪些。
|