@worm-print-platform/canvas 1.5.0 → 1.5.2

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.
Files changed (55) hide show
  1. package/README.md +112 -359
  2. package/dist/browser-bundle.d.ts +1 -1
  3. package/dist/canvas.css +1 -1
  4. package/dist/canvas.js +84 -81
  5. package/dist/core/default-template.d.ts +1 -1
  6. package/dist/core/element-definitions.d.ts +1 -1
  7. package/dist/core/format.d.ts +1 -1
  8. package/dist/core/h.d.ts +1 -1
  9. package/dist/core/icons.d.ts +1 -1
  10. package/dist/core/plugin.d.ts +1 -1
  11. package/dist/core/store.d.ts +1 -1
  12. package/dist/host-contract.d.ts +7 -3
  13. package/dist/index.cjs +14 -11
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +1289 -1242
  16. package/dist/print-designer.d.ts +7 -3
  17. package/dist/shell/binding.d.ts +1 -1
  18. package/dist/shell/canvas.d.ts +1 -1
  19. package/dist/shell/code.d.ts +1 -1
  20. package/dist/shell/color-picker.d.ts +1 -1
  21. package/dist/shell/controls.d.ts +4 -1
  22. package/dist/shell/crop-anchor.d.ts +1 -1
  23. package/dist/shell/elements.d.ts +1 -1
  24. package/dist/shell/expression-editor.d.ts +1 -1
  25. package/dist/shell/flow-list.d.ts +1 -1
  26. package/dist/shell/font-select.d.ts +1 -1
  27. package/dist/shell/format-bar.d.ts +1 -1
  28. package/dist/shell/help-content/advanced-settings.d.ts +1 -1
  29. package/dist/shell/help-content/changelog.d.ts +1 -1
  30. package/dist/shell/help-content/faq.d.ts +1 -1
  31. package/dist/shell/help-content/features.d.ts +1 -1
  32. package/dist/shell/help-content/getting-started.d.ts +1 -1
  33. package/dist/shell/help-content/index.d.ts +1 -1
  34. package/dist/shell/help-content/shortcuts.d.ts +1 -1
  35. package/dist/shell/help-modal.d.ts +1 -1
  36. package/dist/shell/page-extras.d.ts +1 -1
  37. package/dist/shell/panels.d.ts +1 -1
  38. package/dist/shell/plugin-ui.d.ts +1 -1
  39. package/dist/shell/prop-group.d.ts +1 -1
  40. package/dist/shell/property-panel.d.ts +1 -1
  41. package/dist/shell/property-search.d.ts +1 -1
  42. package/dist/shell/ruler.d.ts +1 -1
  43. package/dist/shell/table-props.d.ts +1 -1
  44. package/dist/shell/table.d.ts +2 -2
  45. package/dist/shell/toolbar-overflow.d.ts +1 -1
  46. package/dist/shell/toolbar.d.ts +1 -1
  47. package/dist/shell/watermark.d.ts +1 -1
  48. package/dist/vue3/PrintDesigner.d.ts +23 -1
  49. package/dist/vue3/PrintHtmlPreview.d.ts +1 -1
  50. package/dist/vue3/index.cjs +2 -2
  51. package/dist/vue3/index.d.ts +1 -1
  52. package/dist/vue3/index.js +121 -111
  53. package/dist/vue3/previewStyle.d.ts +1 -1
  54. package/dist/vue3/toolbarOverflow.d.ts +1 -1
  55. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -88,11 +88,15 @@ export declare class PrintDesignerElement extends HTMLElement {
88
88
  set isEdit(v: boolean);
89
89
  /** Vue 3 轨口径:showHelp 控制「帮助入口 + 弹窗」,关闭时强制收起已打开的弹窗 */
90
90
  set showHelp(v: boolean);
91
+ /** 工具栏「预览」按钮显隐;默认显示,隐藏只影响按钮出图,preview 事件旁路不受影响 */
92
+ set showPreview(v: boolean);
93
+ /** 工具栏「保存」按钮显隐;默认显示,隐藏只影响按钮出图,save() 与 save 事件不受影响 */
94
+ set showSave(v: boolean);
91
95
  /**
92
96
  * 宿主契约版本(机器可读);宿主可在挂载前用 `PrintDesignerElement.contractVersion`
93
97
  * 判断是否需要降级或提示升级,避免把版本号埋在文档里。
94
98
  */
95
- static readonly contractVersion = "1.0.0";
99
+ static readonly contractVersion = "1.1.0";
96
100
  /** 返回完整契约快照(attributes / properties / methods / 事件 / parts / 主题令牌) */
97
101
  static getHostContract(): PrintDesignerHostContract;
98
102
  /** 实例侧同款读取入口,便于 `document.querySelector('print-designer').getHostContract()` */
@@ -126,7 +130,7 @@ export declare class PrintDesignerElement extends HTMLElement {
126
130
  validateTemplate(): import("@worm-print-platform/core").TilingIssue[];
127
131
  /**
128
132
  * 出纸裁切提示(旋转外接盒顶越页首、元素超出纸面左右缘),与 Vue 3 轨同名同口径。
129
- * 预估口径:编辑期无实测高,自适应行高按设计盒估算 ⇒ 只提示、不阻断保存。
133
+ * 预估口径:编辑期无实测高,自适应行高按设计盒估算;保存时由用户确认是否接受裁切。
130
134
  */
131
135
  getGeometryWarnings(): string[];
132
136
  private applyTemplate;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -49,6 +49,9 @@ export interface ShellCtx {
49
49
  fire: (action: string, arg?: unknown) => void;
50
50
  /** 宿主能力开关 */
51
51
  showHelp: boolean;
52
+ /** 工具栏「预览 / 保存」按钮显隐:缺省显示,显式 false 才隐藏(与布尔 attribute 的 'false' 判定同口径) */
53
+ showPreview?: boolean;
54
+ showSave?: boolean;
52
55
  isEdit: boolean;
53
56
  /** 宿主注入能力(图片上传、设计背景上传、字体清单),未注入时相关入口置灰 */
54
57
  host: {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -19,4 +19,4 @@ export interface TableMenuState {
19
19
  export declare function renderTableContextMenu(store: DesignerStore, fire: TableFire, menu: TableMenuState): El | '';
20
20
  /** 强制解除列宽拖拽监听(宿主 disconnectedCallback 可用) */
21
21
  export declare function abortTableColResize(): void;
22
- export declare function renderTable(el: RuntimeElement, store: DesignerStore, fire: TableFire): El;
22
+ export declare function renderTable(el: RuntimeElement, store: DesignerStore, fire: TableFire, designData?: readonly Record<string, unknown>[]): El;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -46,6 +46,16 @@ declare const component: import("vue").DefineComponent<import("vue").ExtractProp
46
46
  type: BooleanConstructor;
47
47
  default: undefined;
48
48
  };
49
+ /** 是否展示工具栏「预览」按钮;不传时保持元素默认(展示) */
50
+ showPreview: {
51
+ type: BooleanConstructor;
52
+ default: undefined;
53
+ };
54
+ /** 是否展示工具栏「保存」按钮;不传时保持元素默认(展示) */
55
+ showSave: {
56
+ type: BooleanConstructor;
57
+ default: undefined;
58
+ };
49
59
  /** 模板级字体声明,保存 / 导出时写入模板 JSON */
50
60
  fonts: {
51
61
  type: PropType<readonly PrintFontDeclaration[]>;
@@ -93,6 +103,16 @@ declare const component: import("vue").DefineComponent<import("vue").ExtractProp
93
103
  type: BooleanConstructor;
94
104
  default: undefined;
95
105
  };
106
+ /** 是否展示工具栏「预览」按钮;不传时保持元素默认(展示) */
107
+ showPreview: {
108
+ type: BooleanConstructor;
109
+ default: undefined;
110
+ };
111
+ /** 是否展示工具栏「保存」按钮;不传时保持元素默认(展示) */
112
+ showSave: {
113
+ type: BooleanConstructor;
114
+ default: undefined;
115
+ };
96
116
  /** 模板级字体声明,保存 / 导出时写入模板 JSON */
97
117
  fonts: {
98
118
  type: PropType<readonly PrintFontDeclaration[]>;
@@ -112,6 +132,8 @@ declare const component: import("vue").DefineComponent<import("vue").ExtractProp
112
132
  designData: Record<string, unknown> | readonly Record<string, unknown>[];
113
133
  isEdit: boolean;
114
134
  showHelp: boolean;
135
+ showPreview: boolean;
136
+ showSave: boolean;
115
137
  uploadImage: UploadImageFn;
116
138
  uploadDesignBackground: UploadDesignBackgroundFn;
117
139
  initialTemplate: TemplateData | MultiPageTemplateData;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),S=require("@worm-print-platform/canvas"),j=require("@worm-print-platform/core"),A=require("@worm-print-platform/core/browser"),g=require("@worm-print-platform/core/designer"),H=require("@worm-print-platform/plugin-kit");function M(e,l){const v=l.map(u=>({...u,options:{...u.options},printElementType:{...u.printElementType}})),i=e.pages;return Array.isArray(i)?{...e,pages:i.map((u,a)=>a===0?{...u,elements:v}:u)}:{...e,elements:v}}const _=t.defineComponent({name:"PrintDesigner",props:{initialTemplate:{type:Object,default:void 0},initialElements:{type:Array,default:void 0},fields:{type:Array,default:void 0},isEdit:{type:Boolean,default:void 0},uploadImage:{type:Function,default:void 0},uploadDesignBackground:{type:Function,default:void 0},showHelp:{type:Boolean,default:void 0},fonts:{type:Array,default:void 0},designData:{type:[Object,Array],default:void 0}},emits:{preview:()=>!0,save:e=>typeof e=="string"},setup(e,{emit:l,expose:v}){const i=t.ref(null);let u=null,a=null;typeof customElements<"u"&&S.definePrintDesigner();function f(n){if(e.initialTemplate!==void 0){n.template=e.initialTemplate;return}if(e.initialElements===void 0)return;const o=n.getTemplateJson(),p=JSON.parse(o);n.template=M(p,e.initialElements)}function y(){const n=i.value;n&&(f(n),e.fields!==void 0&&(n.fields=e.fields),e.fonts!==void 0&&(n.fonts=e.fonts),e.designData!==void 0&&(n.designData=e.designData),n.uploadImage=e.uploadImage,n.uploadDesignBackground=e.uploadDesignBackground,e.isEdit!==void 0&&(n.isEdit=e.isEdit),e.showHelp!==void 0&&(n.showHelp=e.showHelp))}return t.onMounted(()=>{const n=i.value;n&&(u=o=>l("save",o.detail),a=()=>l("preview"),n.addEventListener("save",u),n.addEventListener("preview",a),y())}),t.onBeforeUnmount(()=>{const n=i.value;u&&n?.removeEventListener("save",u),a&&n?.removeEventListener("preview",a),u=null,a=null}),t.watch(()=>e.initialTemplate,()=>{const n=i.value;n&&f(n)}),t.watch(()=>e.initialElements,()=>{const n=i.value;n&&f(n)}),t.watch(()=>e.fields,n=>{const o=i.value;o&&(o.fields=n??[])}),t.watch(()=>e.fonts,n=>{const o=i.value;o&&(o.fonts=n)}),t.watch(()=>e.designData,n=>{const o=i.value;o&&(o.designData=n)}),t.watch(()=>e.uploadImage,n=>{const o=i.value;o&&(o.uploadImage=n)}),t.watch(()=>e.uploadDesignBackground,n=>{const o=i.value;o&&(o.uploadDesignBackground=n)}),t.watch(()=>e.isEdit,n=>{const o=i.value;o&&n!==void 0&&(o.isEdit=n)}),t.watch(()=>e.showHelp,n=>{const o=i.value;o&&n!==void 0&&(o.showHelp=n)}),v({getTemplateJson(){const n=i.value?.getTemplateJson();return n?JSON.parse(n):void 0},validateTemplate(){return i.value?.validateTemplate()??[]},getGeometryWarnings(){return i.value?.getGeometryWarnings()??[]}}),()=>t.h("print-designer",{ref:i})}}),C=_,L="worm-print-canvas-vue3-preview",F=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue"),U=require("@worm-print-platform/canvas"),j=require("@worm-print-platform/core"),S=require("@worm-print-platform/core/browser"),g=require("@worm-print-platform/core/designer"),H=require("@worm-print-platform/plugin-kit");function M(e,l){const v=l.map(u=>({...u,options:{...u.options},printElementType:{...u.printElementType}})),r=e.pages;return Array.isArray(r)?{...e,pages:r.map((u,a)=>a===0?{...u,elements:v}:u)}:{...e,elements:v}}const _=n.defineComponent({name:"PrintDesigner",props:{initialTemplate:{type:Object,default:void 0},initialElements:{type:Array,default:void 0},fields:{type:Array,default:void 0},isEdit:{type:Boolean,default:void 0},uploadImage:{type:Function,default:void 0},uploadDesignBackground:{type:Function,default:void 0},showHelp:{type:Boolean,default:void 0},showPreview:{type:Boolean,default:void 0},showSave:{type:Boolean,default:void 0},fonts:{type:Array,default:void 0},designData:{type:[Object,Array],default:void 0}},emits:{preview:()=>!0,save:e=>typeof e=="string"},setup(e,{emit:l,expose:v}){const r=n.ref(null);let u=null,a=null;typeof customElements<"u"&&U.definePrintDesigner();function f(t){if(e.initialTemplate!==void 0){t.template=e.initialTemplate;return}if(e.initialElements===void 0)return;const o=t.getTemplateJson(),p=JSON.parse(o);t.template=M(p,e.initialElements)}function y(){const t=r.value;t&&(f(t),e.fields!==void 0&&(t.fields=e.fields),e.fonts!==void 0&&(t.fonts=e.fonts),e.designData!==void 0&&(t.designData=e.designData),t.uploadImage=e.uploadImage,t.uploadDesignBackground=e.uploadDesignBackground,e.isEdit!==void 0&&(t.isEdit=e.isEdit),e.showHelp!==void 0&&(t.showHelp=e.showHelp),e.showPreview!==void 0&&(t.showPreview=e.showPreview),e.showSave!==void 0&&(t.showSave=e.showSave))}return n.onMounted(()=>{const t=r.value;t&&(u=o=>l("save",o.detail),a=()=>l("preview"),t.addEventListener("save",u),t.addEventListener("preview",a),y())}),n.onBeforeUnmount(()=>{const t=r.value;u&&t?.removeEventListener("save",u),a&&t?.removeEventListener("preview",a),u=null,a=null}),n.watch(()=>e.initialTemplate,()=>{const t=r.value;t&&f(t)}),n.watch(()=>e.initialElements,()=>{const t=r.value;t&&f(t)}),n.watch(()=>e.fields,t=>{const o=r.value;o&&(o.fields=t??[])}),n.watch(()=>e.fonts,t=>{const o=r.value;o&&(o.fonts=t)}),n.watch(()=>e.designData,t=>{const o=r.value;o&&(o.designData=t)}),n.watch(()=>e.uploadImage,t=>{const o=r.value;o&&(o.uploadImage=t)}),n.watch(()=>e.uploadDesignBackground,t=>{const o=r.value;o&&(o.uploadDesignBackground=t)}),n.watch(()=>e.isEdit,t=>{const o=r.value;o&&t!==void 0&&(o.isEdit=t)}),n.watch(()=>e.showHelp,t=>{const o=r.value;o&&t!==void 0&&(o.showHelp=t)}),n.watch(()=>e.showPreview,t=>{const o=r.value;o&&t!==void 0&&(o.showPreview=t)}),n.watch(()=>e.showSave,t=>{const o=r.value;o&&t!==void 0&&(o.showSave=t)}),v({getTemplateJson(){const t=r.value?.getTemplateJson();return t?JSON.parse(t):void 0},validateTemplate(){return r.value?.validateTemplate()??[]},getGeometryWarnings(){return r.value?.getGeometryWarnings()??[]}}),()=>n.h("print-designer",{ref:r})}}),C=_,I="worm-print-canvas-vue3-preview",F=`
2
2
  .pcv3-preview.print-html-preview {
3
3
  width: 100%;
4
4
  height: 100%;
@@ -79,4 +79,4 @@
79
79
  color: #b88230;
80
80
  font-size: 11px;
81
81
  }
82
- `;function J(){if(typeof document>"u"||document.getElementById(L))return;const e=document.createElement("style");e.id=L,e.textContent=F,document.head.appendChild(e)}const q=t.defineComponent({name:"PrintHtmlPreview",props:{templateJson:{type:Object,default:void 0},printData:{type:[Object,Array],default:void 0},baseUrl:{type:String,default:void 0},fontBaseUrl:{type:String,default:void 0},renderers:{type:Object,default:void 0}},emits:{rendered:(e,l)=>typeof e=="number"&&typeof l=="number",error:e=>typeof e=="string"},setup(e,{emit:l,expose:v}){const i=t.ref(),u=t.ref(),a=t.ref(!1),f=t.ref(""),y=t.ref([]);let O=0;const n=t.computed(()=>g.resolvePrinterDpi(e.templateJson)),o=t.ref(0),p=t.computed(()=>g.zoomPresets(n.value,o.value,g.paperWidthPx(e.templateJson))),m=t.ref(g.defaultZoomKey(n.value)),P=t.computed(()=>g.zoomValueOf(p.value,m.value)),T=t.computed(()=>g.viewZoomHint(n.value,m.value));function x(){o.value=u.value?.clientWidth??0}function R(){m.value=g.resolveZoomKey(p.value,m.value,n.value)}function D(){g.applyPreviewViewZoom(i.value?.contentWindow?.document,P.value)}function k(){x(),D()}async function r(){if(!e.templateJson){f.value="",a.value=!1;return}const s=++O;a.value=!0,f.value="",y.value=[];try{const{html:d,pageCount:b,copies:c,pageLayouts:z}=await A.renderHtmlPages(e.templateJson,e.printData,e.baseUrl,A.browserCodeRenderer,{fontBaseUrl:e.fontBaseUrl,renderers:e.renderers});if(s!==O)return;y.value=j.collectLayoutWarnings(z??[]);const h=i.value?.contentWindow?.document;h&&(h.open(),h.write(d),h.close()),x(),R(),D(),l("rendered",b,c)}catch(d){if(s!==O)return;f.value=d instanceof Error?d.message:"未知错误",l("error",f.value)}finally{s===O&&(a.value=!1)}}function w(){const s=i.value?.contentWindow;s&&(s.focus(),s.print())}function E(s){p.value.some(d=>d.key===s)&&(m.value=s)}return t.watch(()=>[e.templateJson,e.printData,e.baseUrl,e.fontBaseUrl,e.renderers],()=>{r()},{deep:!0}),t.watch(P,()=>D()),t.onMounted(()=>{J(),x(),R(),window.addEventListener("resize",k),r()}),t.onBeforeUnmount(()=>{O++,window.removeEventListener("resize",k)}),v({print:w,rerender:r,setViewZoom:E,zoomKey:m,presets:p,viewHint:T}),()=>{const s=a.value||!!f.value,d=[];if(f.value?d.push(t.h("div",{key:"error",class:"print-html-preview-error"},[t.h("span",null,`预览渲染失败:${f.value}`)])):a.value&&d.push(t.h("div",{key:"loading",class:"print-html-preview-loading"},"预览渲染中…")),d.push(t.h("iframe",{key:"iframe",ref:i,class:"print-html-preview-iframe",title:"打印预览",style:{display:s?"none":""}})),y.value.length&&!s&&d.push(t.h("div",{key:"warn",class:"print-html-preview-warn",role:"status"},[t.h("span",null,`出纸提示:${y.value.join(";")}`)])),e.templateJson&&!s){const b=p.value.map(c=>t.h("button",{key:c.key,type:"button",class:{"print-html-preview-zoom-btn":!0,active:c.key===m.value},title:c.tip,onClick:()=>{m.value=c.key}},c.label));T.value&&b.push(t.h("span",{class:"print-html-preview-zoom-hint"},T.value)),b.push(t.h("span",{class:"print-html-preview-zoom-note"},"仅屏幕缩放,打印不受影响")),d.push(t.h("div",{key:"zoom",class:"print-html-preview-zoom"},b))}return t.h("div",{ref:u,class:"print-html-preview pcv3-preview"},d)}}}),V=q;function Z(e){return`tb-more-slot-${e}`}const I=H.TOOLBAR_OVERFLOW_KEY,U=2,K=74;function W(){const e=t.shallowRef(null),l=new Map,v=t.reactive(new Map),i=new Map;let u=0;const a=t.ref(new Set),f=t.ref(!1),y=t.computed(()=>[...v.values()].sort((r,w)=>r.order-w.order)),O=t.computed(()=>a.value.size>0);function n(){for(const[r,w]of l){const E=w.offsetWidth;E>0&&i.set(r,E)}}function o(r){const w=getComputedStyle(r),E=Number.parseFloat(w.gap)||U,s=Number.parseFloat(w.paddingLeft)||0,d=Number.parseFloat(w.paddingRight)||0;let b=0;for(const c of Array.from(r.children)){if(c.hasAttribute("data-overflow-more")||c.hasAttribute("data-overflow-spacer"))continue;const z=Math.max(c.offsetWidth,c.scrollWidth);z<=0||(b+=z+E)}return{available:r.clientWidth-s-d,natural:b}}function p(){const r=e.value;if(!r)return;const{available:w,natural:E}=o(r),s=a.value.size>0;s||(u=E,n());const d=y.value.map(h=>({id:h.id,order:h.order,width:i.get(h.id)??0})),b=d.reduce((h,B)=>h-B.width-U,u),c=g.resolveToolbarOverflow({available:w,pinned:b,moreTriggerWidth:K,gap:U,units:d});c.movedIds.length===a.value.size&&c.movedIds.every(h=>a.value.has(h))||(a.value=new Set(c.movedIds)),f.value=c.overflowRemains,s&&a.value.size===0&&t.nextTick(p)}let m=null;function P(r){r!==e.value&&(m?.disconnect(),e.value=r,r&&typeof ResizeObserver<"u"&&(m=new ResizeObserver(()=>p()),m.observe(r)),t.nextTick(p))}function T(r,w){v.set(r.id,r),l.set(r.id,w),t.nextTick(p)}function x(r){l.delete(r),v.delete(r),i.delete(r),t.nextTick(p)}const R=document.createElement("div");function D(r){return a.value.has(r)}function k(r){return a.value,e.value?.querySelector(`[data-overflow-slot="${r}"]`)??R}return t.onUnmounted(()=>m?.disconnect()),{attachRoot:P,registerUnit:T,unregisterUnit:x,refresh:p,movedIds:a,overflowRemains:f,hasMoved:O,chain:y,moved:D,slotEl:k}}function G(){const e=W();return t.provide(I,e),e}function N(){return t.inject(I,null)}function $(){const e=t.ref(new Set),l=document.createElement("div");return{attachRoot:()=>{},registerUnit:()=>{},unregisterUnit:()=>{},refresh:()=>{},movedIds:e,overflowRemains:t.ref(!1),hasMoved:t.computed(()=>!1),chain:t.computed(()=>[]),moved:()=>!1,slotEl:()=>l}}function Y(e){return{mounted(l,v){l.dataset.unit=v.value.id,e.registerUnit(v.value,l)},unmounted(l,v){e.unregisterUnit(v.value.id)}}}Object.defineProperty(exports,"createDefaultTemplate",{enumerable:!0,get:()=>S.createDefaultTemplate});Object.defineProperty(exports,"toRuntimePool",{enumerable:!0,get:()=>S.toRuntimePool});Object.defineProperty(exports,"browserCodeRenderer",{enumerable:!0,get:()=>A.browserCodeRenderer});Object.defineProperty(exports,"renderHtmlPages",{enumerable:!0,get:()=>A.renderHtmlPages});Object.defineProperty(exports,"DEFAULT_DEMO_DATA",{enumerable:!0,get:()=>g.DEFAULT_DEMO_DATA});Object.defineProperty(exports,"getDemoData",{enumerable:!0,get:()=>g.getDemoData});exports.PrintDesigner=C;exports.PrintHtmlPreview=V;exports.TOOLBAR_OVERFLOW=I;exports.createOverflowUnitDirective=Y;exports.createToolbarOverflow=W;exports.emptyToolbarOverflow=$;exports.moreSlotId=Z;exports.provideToolbarOverflow=G;exports.useToolbarOverflow=N;
82
+ `;function J(){if(typeof document>"u"||document.getElementById(I))return;const e=document.createElement("style");e.id=I,e.textContent=F,document.head.appendChild(e)}const q=n.defineComponent({name:"PrintHtmlPreview",props:{templateJson:{type:Object,default:void 0},printData:{type:[Object,Array],default:void 0},baseUrl:{type:String,default:void 0},fontBaseUrl:{type:String,default:void 0},renderers:{type:Object,default:void 0}},emits:{rendered:(e,l)=>typeof e=="number"&&typeof l=="number",error:e=>typeof e=="string"},setup(e,{emit:l,expose:v}){const r=n.ref(),u=n.ref(),a=n.ref(!1),f=n.ref(""),y=n.ref([]);let O=0;const t=n.computed(()=>g.resolvePrinterDpi(e.templateJson)),o=n.ref(0),p=n.computed(()=>g.zoomPresets(t.value,o.value,g.paperWidthPx(e.templateJson))),m=n.ref(g.defaultZoomKey(t.value)),z=n.computed(()=>g.zoomValueOf(p.value,m.value)),T=n.computed(()=>g.viewZoomHint(t.value,m.value));function x(){o.value=u.value?.clientWidth??0}function R(){m.value=g.resolveZoomKey(p.value,m.value,t.value)}function D(){g.applyPreviewViewZoom(r.value?.contentWindow?.document,z.value)}function k(){x(),D()}async function i(){if(!e.templateJson){f.value="",a.value=!1;return}const s=++O;a.value=!0,f.value="",y.value=[];try{const{html:d,pageCount:b,copies:c,pageLayouts:P}=await S.renderHtmlPages(e.templateJson,e.printData,e.baseUrl,S.browserCodeRenderer,{fontBaseUrl:e.fontBaseUrl,renderers:e.renderers});if(s!==O)return;y.value=j.collectLayoutWarnings(P??[]);const h=r.value?.contentWindow?.document;h&&(h.open(),h.write(d),h.close()),x(),R(),D(),l("rendered",b,c)}catch(d){if(s!==O)return;f.value=d instanceof Error?d.message:"未知错误",l("error",f.value)}finally{s===O&&(a.value=!1)}}function w(){const s=r.value?.contentWindow;s&&(s.focus(),s.print())}function E(s){p.value.some(d=>d.key===s)&&(m.value=s)}return n.watch(()=>[e.templateJson,e.printData,e.baseUrl,e.fontBaseUrl,e.renderers],()=>{i()},{deep:!0}),n.watch(z,()=>D()),n.onMounted(()=>{J(),x(),R(),window.addEventListener("resize",k),i()}),n.onBeforeUnmount(()=>{O++,window.removeEventListener("resize",k)}),v({print:w,rerender:i,setViewZoom:E,zoomKey:m,presets:p,viewHint:T}),()=>{const s=a.value||!!f.value,d=[];if(f.value?d.push(n.h("div",{key:"error",class:"print-html-preview-error"},[n.h("span",null,`预览渲染失败:${f.value}`)])):a.value&&d.push(n.h("div",{key:"loading",class:"print-html-preview-loading"},"预览渲染中…")),d.push(n.h("iframe",{key:"iframe",ref:r,class:"print-html-preview-iframe",title:"打印预览",style:{display:s?"none":""}})),y.value.length&&!s&&d.push(n.h("div",{key:"warn",class:"print-html-preview-warn",role:"status"},[n.h("span",null,`出纸提示:${y.value.join(";")}`)])),e.templateJson&&!s){const b=p.value.map(c=>n.h("button",{key:c.key,type:"button",class:{"print-html-preview-zoom-btn":!0,active:c.key===m.value},title:c.tip,onClick:()=>{m.value=c.key}},c.label));T.value&&b.push(n.h("span",{class:"print-html-preview-zoom-hint"},T.value)),b.push(n.h("span",{class:"print-html-preview-zoom-note"},"仅屏幕缩放,打印不受影响")),d.push(n.h("div",{key:"zoom",class:"print-html-preview-zoom"},b))}return n.h("div",{ref:u,class:"print-html-preview pcv3-preview"},d)}}}),V=q;function Z(e){return`tb-more-slot-${e}`}const B=H.TOOLBAR_OVERFLOW_KEY,A=2,K=74;function L(){const e=n.shallowRef(null),l=new Map,v=n.reactive(new Map),r=new Map;let u=0;const a=n.ref(new Set),f=n.ref(!1),y=n.computed(()=>[...v.values()].sort((i,w)=>i.order-w.order)),O=n.computed(()=>a.value.size>0);function t(){for(const[i,w]of l){const E=w.offsetWidth;E>0&&r.set(i,E)}}function o(i){const w=getComputedStyle(i),E=Number.parseFloat(w.gap)||A,s=Number.parseFloat(w.paddingLeft)||0,d=Number.parseFloat(w.paddingRight)||0;let b=0;for(const c of Array.from(i.children)){if(c.hasAttribute("data-overflow-more")||c.hasAttribute("data-overflow-spacer"))continue;const P=Math.max(c.offsetWidth,c.scrollWidth);P<=0||(b+=P+E)}return{available:i.clientWidth-s-d,natural:b}}function p(){const i=e.value;if(!i)return;const{available:w,natural:E}=o(i),s=a.value.size>0;s||(u=E,t());const d=y.value.map(h=>({id:h.id,order:h.order,width:r.get(h.id)??0})),b=d.reduce((h,W)=>h-W.width-A,u),c=g.resolveToolbarOverflow({available:w,pinned:b,moreTriggerWidth:K,gap:A,units:d});c.movedIds.length===a.value.size&&c.movedIds.every(h=>a.value.has(h))||(a.value=new Set(c.movedIds)),f.value=c.overflowRemains,s&&a.value.size===0&&n.nextTick(p)}let m=null;function z(i){i!==e.value&&(m?.disconnect(),e.value=i,i&&typeof ResizeObserver<"u"&&(m=new ResizeObserver(()=>p()),m.observe(i)),n.nextTick(p))}function T(i,w){v.set(i.id,i),l.set(i.id,w),n.nextTick(p)}function x(i){l.delete(i),v.delete(i),r.delete(i),n.nextTick(p)}const R=document.createElement("div");function D(i){return a.value.has(i)}function k(i){return a.value,e.value?.querySelector(`[data-overflow-slot="${i}"]`)??R}return n.onUnmounted(()=>m?.disconnect()),{attachRoot:z,registerUnit:T,unregisterUnit:x,refresh:p,movedIds:a,overflowRemains:f,hasMoved:O,chain:y,moved:D,slotEl:k}}function G(){const e=L();return n.provide(B,e),e}function N(){return n.inject(B,null)}function $(){const e=n.ref(new Set),l=document.createElement("div");return{attachRoot:()=>{},registerUnit:()=>{},unregisterUnit:()=>{},refresh:()=>{},movedIds:e,overflowRemains:n.ref(!1),hasMoved:n.computed(()=>!1),chain:n.computed(()=>[]),moved:()=>!1,slotEl:()=>l}}function Y(e){return{mounted(l,v){l.dataset.unit=v.value.id,e.registerUnit(v.value,l)},unmounted(l,v){e.unregisterUnit(v.value.id)}}}Object.defineProperty(exports,"createDefaultTemplate",{enumerable:!0,get:()=>U.createDefaultTemplate});Object.defineProperty(exports,"toRuntimePool",{enumerable:!0,get:()=>U.toRuntimePool});Object.defineProperty(exports,"browserCodeRenderer",{enumerable:!0,get:()=>S.browserCodeRenderer});Object.defineProperty(exports,"renderHtmlPages",{enumerable:!0,get:()=>S.renderHtmlPages});Object.defineProperty(exports,"DEFAULT_DEMO_DATA",{enumerable:!0,get:()=>g.DEFAULT_DEMO_DATA});Object.defineProperty(exports,"getDemoData",{enumerable:!0,get:()=>g.getDemoData});exports.PrintDesigner=C;exports.PrintHtmlPreview=V;exports.TOOLBAR_OVERFLOW=B;exports.createOverflowUnitDirective=Y;exports.createToolbarOverflow=L;exports.emptyToolbarOverflow=$;exports.moreSlotId=Z;exports.provideToolbarOverflow=G;exports.useToolbarOverflow=N;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/canvas v1.5.0
2
+ * @worm-print-platform/canvas v1.5.2
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT