@bluechaine/print-designer 0.1.0 → 0.1.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.
- package/README.en.md +104 -1
- package/README.md +118 -1
- package/dist/print-client/index.cjs +1071 -0
- package/dist/print-client/index.cjs.map +1 -0
- package/dist/print-client/index.mjs +1055 -0
- package/dist/print-client/index.mjs.map +1 -0
- package/dist/types/src/components/Designer.vue.d.ts +35 -4
- package/dist/types/src/components/Preview.vue.d.ts +33 -2
- package/dist/types/src/core/batch-print.d.ts +30 -0
- package/dist/types/src/core/designer-utils.d.ts +13 -3
- package/dist/types/src/core/hiprint-bridge.d.ts +4 -6
- package/dist/types/src/core/print-client.d.ts +30 -0
- package/dist/types/src/i18n/en-US.d.ts +12 -0
- package/dist/types/src/i18n/zh-CN.d.ts +12 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/print-client-entry.d.ts +5 -0
- package/dist/types/src/types.d.ts +51 -0
- package/dist/vue2/index.cjs +1061 -340
- package/dist/vue2/index.cjs.map +1 -1
- package/dist/vue2/index.mjs +1038 -328
- package/dist/vue2/index.mjs.map +1 -1
- package/dist/vue2/index.umd.cjs +1061 -340
- package/dist/vue2/index.umd.cjs.map +1 -1
- package/dist/vue2/style.css +55 -1
- package/dist/vue3/index.cjs +1065 -344
- package/dist/vue3/index.cjs.map +1 -1
- package/dist/vue3/index.mjs +1042 -332
- package/dist/vue3/index.mjs.map +1 -1
- package/dist/vue3/index.umd.cjs +1065 -344
- package/dist/vue3/index.umd.cjs.map +1 -1
- package/dist/vue3/style.css +55 -1
- package/package.json +15 -5
package/dist/vue3/index.umd.cjs
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue-demi"), require("vue-plugin-hiprint"), require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue-demi", "vue-plugin-hiprint", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.Vue3PrintDesigner = {}, global.VueDemi, global.vuePluginHiprint, global.Vue));
|
|
3
|
-
})(this, function(exports2, vueDemi,
|
|
3
|
+
})(this, function(exports2, vueDemi, VuePluginHiprint, vue) {
|
|
4
4
|
"use strict";
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const VuePluginHiprint__namespace = /* @__PURE__ */ _interopNamespaceDefault(VuePluginHiprint);
|
|
5
23
|
/**
|
|
6
24
|
* (c) Iconify
|
|
7
25
|
*
|
|
@@ -2667,10 +2685,10 @@
|
|
|
2667
2685
|
return !!value && !value.trim().startsWith("<");
|
|
2668
2686
|
}
|
|
2669
2687
|
function elementTypeKey(item) {
|
|
2670
|
-
var
|
|
2671
|
-
const type = String(((
|
|
2688
|
+
var _a2, _b2;
|
|
2689
|
+
const type = String(((_a2 = item == null ? void 0 : item.printElementType) == null ? void 0 : _a2.type) || "");
|
|
2672
2690
|
if (type && ELEMENT_ICON_NAMES[type]) return type;
|
|
2673
|
-
const tid = String(((
|
|
2691
|
+
const tid = String(((_b2 = item == null ? void 0 : item.printElementType) == null ? void 0 : _b2.tid) || "");
|
|
2674
2692
|
const short = tid.split(".").pop() || type;
|
|
2675
2693
|
return short && ELEMENT_ICON_NAMES[short] ? short : "text";
|
|
2676
2694
|
}
|
|
@@ -2799,12 +2817,12 @@
|
|
|
2799
2817
|
return (match == null ? void 0 : match.type) || "自定义";
|
|
2800
2818
|
}
|
|
2801
2819
|
function resolveTemplate(tplId) {
|
|
2802
|
-
var
|
|
2820
|
+
var _a2;
|
|
2803
2821
|
const cached = templateRegistry.get(tplId);
|
|
2804
2822
|
if (cached) return cached;
|
|
2805
2823
|
try {
|
|
2806
|
-
const lib = (
|
|
2807
|
-
return ((
|
|
2824
|
+
const lib = (hiprint == null ? void 0 : hiprint.instance) ?? hiprint;
|
|
2825
|
+
return ((_a2 = lib == null ? void 0 : lib.getPrintTemplateById) == null ? void 0 : _a2.call(lib, tplId)) ?? null;
|
|
2808
2826
|
} catch {
|
|
2809
2827
|
return null;
|
|
2810
2828
|
}
|
|
@@ -2894,11 +2912,11 @@
|
|
|
2894
2912
|
return wrapper;
|
|
2895
2913
|
};
|
|
2896
2914
|
PaperListOptionItem.prototype.getValue = function() {
|
|
2897
|
-
var
|
|
2915
|
+
var _a2, _b2, _c2;
|
|
2898
2916
|
return {
|
|
2899
|
-
type: String(((
|
|
2900
|
-
width: Number((
|
|
2901
|
-
height: Number((
|
|
2917
|
+
type: String(((_a2 = this.typeSelect) == null ? void 0 : _a2.val()) || "自定义"),
|
|
2918
|
+
width: Number((_b2 = this.widthInput) == null ? void 0 : _b2.val()) || 0,
|
|
2919
|
+
height: Number((_c2 = this.heightInput) == null ? void 0 : _c2.val()) || 0
|
|
2902
2920
|
};
|
|
2903
2921
|
};
|
|
2904
2922
|
PaperListOptionItem.prototype.setValue = function(value) {
|
|
@@ -2916,8 +2934,8 @@
|
|
|
2916
2934
|
this.heightInput.val(value.height || "");
|
|
2917
2935
|
};
|
|
2918
2936
|
PaperListOptionItem.prototype.destroy = function() {
|
|
2919
|
-
var
|
|
2920
|
-
(
|
|
2937
|
+
var _a2, _b2;
|
|
2938
|
+
(_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
|
|
2921
2939
|
};
|
|
2922
2940
|
function OrientOptionItem() {
|
|
2923
2941
|
this.name = "orient";
|
|
@@ -2945,18 +2963,18 @@
|
|
|
2945
2963
|
return this.target;
|
|
2946
2964
|
};
|
|
2947
2965
|
OrientOptionItem.prototype.getValue = function() {
|
|
2948
|
-
var
|
|
2949
|
-
const val = (
|
|
2966
|
+
var _a2, _b2, _c2, _d2;
|
|
2967
|
+
const val = (_d2 = (_c2 = (_b2 = (_a2 = this.target) == null ? void 0 : _a2.find) == null ? void 0 : _b2.call(_a2, "select")) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2);
|
|
2950
2968
|
if (val === "" || val == null) return void 0;
|
|
2951
2969
|
return parseFloat(String(val));
|
|
2952
2970
|
};
|
|
2953
2971
|
OrientOptionItem.prototype.setValue = function(value) {
|
|
2954
|
-
var
|
|
2955
|
-
(
|
|
2972
|
+
var _a2, _b2, _c2, _d2;
|
|
2973
|
+
(_d2 = (_c2 = (_b2 = (_a2 = this.target) == null ? void 0 : _a2.find) == null ? void 0 : _b2.call(_a2, "select")) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value ?? "");
|
|
2956
2974
|
};
|
|
2957
2975
|
OrientOptionItem.prototype.destroy = function() {
|
|
2958
|
-
var
|
|
2959
|
-
(
|
|
2976
|
+
var _a2, _b2;
|
|
2977
|
+
(_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
|
|
2960
2978
|
};
|
|
2961
2979
|
const WATERMARK_TIME_FORMATS = [
|
|
2962
2980
|
"YYYY-MM-DD HH:mm:ss",
|
|
@@ -3050,10 +3068,10 @@
|
|
|
3050
3068
|
return this.target;
|
|
3051
3069
|
};
|
|
3052
3070
|
WatermarkOptionItem.prototype.getValue = function() {
|
|
3053
|
-
var
|
|
3054
|
-
const format = (
|
|
3071
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3072
|
+
const format = (_b2 = (_a2 = this.format) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2);
|
|
3055
3073
|
return {
|
|
3056
|
-
content: ((
|
|
3074
|
+
content: ((_d2 = (_c2 = this.content) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2)) || "",
|
|
3057
3075
|
fillStyle: ((_f = (_e = this.fillStyle) == null ? void 0 : _e.val) == null ? void 0 : _f.call(_e)) || "rgba(184, 184, 184, 0.3)",
|
|
3058
3076
|
fontSize: `${parseInt(String(((_h = (_g = this.fontSize) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g)) || "14"), 10)}px`,
|
|
3059
3077
|
rotate: parseInt(String(((_j = (_i = this.rotate) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i)) || "25"), 10),
|
|
@@ -3064,10 +3082,10 @@
|
|
|
3064
3082
|
};
|
|
3065
3083
|
};
|
|
3066
3084
|
WatermarkOptionItem.prototype.setValue = function(value) {
|
|
3067
|
-
var
|
|
3085
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3068
3086
|
if (!value) value = {};
|
|
3069
|
-
(
|
|
3070
|
-
(
|
|
3087
|
+
(_b2 = (_a2 = this.content) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2, value.content || "");
|
|
3088
|
+
(_d2 = (_c2 = this.fillStyle) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value.fillStyle || "rgba(184, 184, 184, 0.3)");
|
|
3071
3089
|
try {
|
|
3072
3090
|
(_f = (_e = this.fillStyle) == null ? void 0 : _e.minicolors) == null ? void 0 : _f.call(_e, {
|
|
3073
3091
|
format: "rgb",
|
|
@@ -3085,8 +3103,8 @@
|
|
|
3085
3103
|
(_r = (_q = this.format) == null ? void 0 : _q.val) == null ? void 0 : _r.call(_q, value.format || "YYYY-MM-DD HH:mm");
|
|
3086
3104
|
};
|
|
3087
3105
|
WatermarkOptionItem.prototype.destroy = function() {
|
|
3088
|
-
var
|
|
3089
|
-
(
|
|
3106
|
+
var _a2, _b2;
|
|
3107
|
+
(_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
|
|
3090
3108
|
};
|
|
3091
3109
|
function PanelBackgroundColorOptionItem() {
|
|
3092
3110
|
this.name = "backgroundColor";
|
|
@@ -3105,21 +3123,21 @@
|
|
|
3105
3123
|
return this.target;
|
|
3106
3124
|
};
|
|
3107
3125
|
PanelBackgroundColorOptionItem.prototype.getValue = function() {
|
|
3108
|
-
var
|
|
3109
|
-
const val = (
|
|
3126
|
+
var _a2, _b2;
|
|
3127
|
+
const val = (_b2 = (_a2 = this.input) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2);
|
|
3110
3128
|
return val ? String(val) : void 0;
|
|
3111
3129
|
};
|
|
3112
3130
|
PanelBackgroundColorOptionItem.prototype.setValue = function(value) {
|
|
3113
|
-
var
|
|
3131
|
+
var _a2, _b2, _c2, _d2;
|
|
3114
3132
|
const color = value || "#ffffff";
|
|
3115
3133
|
try {
|
|
3116
|
-
(
|
|
3134
|
+
(_b2 = (_a2 = this.input) == null ? void 0 : _a2.minicolors) == null ? void 0 : _b2.call(_a2, {
|
|
3117
3135
|
defaultValue: color,
|
|
3118
3136
|
theme: "bootstrap"
|
|
3119
3137
|
});
|
|
3120
3138
|
} catch {
|
|
3121
3139
|
}
|
|
3122
|
-
(
|
|
3140
|
+
(_d2 = (_c2 = this.input) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, color);
|
|
3123
3141
|
};
|
|
3124
3142
|
PanelBackgroundColorOptionItem.prototype.css = function(target, value) {
|
|
3125
3143
|
const $ = getJQuery();
|
|
@@ -3132,19 +3150,19 @@
|
|
|
3132
3150
|
return null;
|
|
3133
3151
|
};
|
|
3134
3152
|
PanelBackgroundColorOptionItem.prototype.destroy = function() {
|
|
3135
|
-
var
|
|
3136
|
-
(
|
|
3153
|
+
var _a2, _b2;
|
|
3154
|
+
(_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
|
|
3137
3155
|
};
|
|
3138
3156
|
function applyPanelBackgroundColor(panel, color) {
|
|
3139
|
-
var
|
|
3157
|
+
var _a2, _b2, _c2, _d2;
|
|
3140
3158
|
if (!panel) return;
|
|
3141
3159
|
const value = color || "#ffffff";
|
|
3142
3160
|
panel.backgroundColor = value;
|
|
3143
3161
|
const $ = getJQuery();
|
|
3144
|
-
const paper = ((
|
|
3162
|
+
const paper = ((_a2 = panel.designPaper) == null ? void 0 : _a2.target) || ((_c2 = (_b2 = panel.target) == null ? void 0 : _b2.find) == null ? void 0 : _c2.call(_b2, ".hiprint-printPaper")) || ($ && panel.target ? $(panel.target).find(".hiprint-printPaper") : null);
|
|
3145
3163
|
if (paper == null ? void 0 : paper.css) {
|
|
3146
3164
|
paper.css("background-color", value);
|
|
3147
|
-
} else if ((paper == null ? void 0 : paper.length) && ((
|
|
3165
|
+
} else if ((paper == null ? void 0 : paper.length) && ((_d2 = paper[0]) == null ? void 0 : _d2.style)) {
|
|
3148
3166
|
paper[0].style.backgroundColor = value;
|
|
3149
3167
|
}
|
|
3150
3168
|
}
|
|
@@ -3216,33 +3234,33 @@
|
|
|
3216
3234
|
return this.target;
|
|
3217
3235
|
};
|
|
3218
3236
|
PanelLayoutOptionItem.prototype.getValue = function() {
|
|
3219
|
-
var
|
|
3237
|
+
var _a2, _b2, _c2, _d2;
|
|
3220
3238
|
const num = (el) => {
|
|
3221
|
-
var
|
|
3222
|
-
return parseInt(String(((
|
|
3239
|
+
var _a3;
|
|
3240
|
+
return parseInt(String(((_a3 = el == null ? void 0 : el.val) == null ? void 0 : _a3.call(el)) || 0), 10) || 0;
|
|
3223
3241
|
};
|
|
3224
3242
|
return {
|
|
3225
|
-
layoutType: ((
|
|
3243
|
+
layoutType: ((_b2 = (_a2 = this.layoutType) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2)) || "column",
|
|
3226
3244
|
layoutRowGap: num(this.layoutRowGap),
|
|
3227
3245
|
layoutColumnGap: num(this.layoutColumnGap),
|
|
3228
3246
|
paperWidth: num(this.paperWidth),
|
|
3229
3247
|
paperHeight: num(this.paperHeight),
|
|
3230
|
-
paperStyle: ((
|
|
3248
|
+
paperStyle: ((_d2 = (_c2 = this.paperStyle) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2)) || ""
|
|
3231
3249
|
};
|
|
3232
3250
|
};
|
|
3233
3251
|
PanelLayoutOptionItem.prototype.setValue = function(value) {
|
|
3234
|
-
var
|
|
3252
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
3235
3253
|
if (!value) return;
|
|
3236
|
-
(
|
|
3237
|
-
(
|
|
3254
|
+
(_b2 = (_a2 = this.layoutType) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2, value.layoutType || "column");
|
|
3255
|
+
(_d2 = (_c2 = this.layoutRowGap) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value.layoutRowGap ?? "");
|
|
3238
3256
|
(_f = (_e = this.layoutColumnGap) == null ? void 0 : _e.val) == null ? void 0 : _f.call(_e, value.layoutColumnGap ?? "");
|
|
3239
3257
|
(_h = (_g = this.paperWidth) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g, value.paperWidth ?? "");
|
|
3240
3258
|
(_j = (_i = this.paperHeight) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i, value.paperHeight ?? "");
|
|
3241
3259
|
(_l = (_k = this.paperStyle) == null ? void 0 : _k.val) == null ? void 0 : _l.call(_k, value.paperStyle ?? "");
|
|
3242
3260
|
};
|
|
3243
3261
|
PanelLayoutOptionItem.prototype.destroy = function() {
|
|
3244
|
-
var
|
|
3245
|
-
(
|
|
3262
|
+
var _a2, _b2;
|
|
3263
|
+
(_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
|
|
3246
3264
|
};
|
|
3247
3265
|
function reorderPanelSettingOptions(options, panel, paperList) {
|
|
3248
3266
|
const {
|
|
@@ -3261,11 +3279,11 @@
|
|
|
3261
3279
|
};
|
|
3262
3280
|
}
|
|
3263
3281
|
function ensurePaperListSupportOptionsFirst() {
|
|
3264
|
-
var
|
|
3282
|
+
var _a2, _b2, _c2;
|
|
3265
3283
|
try {
|
|
3266
3284
|
const cfg = window.HIPRINT_CONFIG;
|
|
3267
|
-
const instanceOpts = (
|
|
3268
|
-
const cfgOpts = (
|
|
3285
|
+
const instanceOpts = (_b2 = (_a2 = hiprint == null ? void 0 : hiprint.instance) == null ? void 0 : _a2.panel) == null ? void 0 : _b2.supportOptions;
|
|
3286
|
+
const cfgOpts = (_c2 = cfg == null ? void 0 : cfg.panel) == null ? void 0 : _c2.supportOptions;
|
|
3269
3287
|
const opts = instanceOpts || cfgOpts;
|
|
3270
3288
|
if (!Array.isArray(opts)) return;
|
|
3271
3289
|
const idx = opts.findIndex((o) => o.name === "paperList");
|
|
@@ -3285,8 +3303,8 @@
|
|
|
3285
3303
|
}
|
|
3286
3304
|
}
|
|
3287
3305
|
function patchPrintTemplatePaperList() {
|
|
3288
|
-
var
|
|
3289
|
-
const proto = (
|
|
3306
|
+
var _a2;
|
|
3307
|
+
const proto = (_a2 = hiprint.PrintTemplate) == null ? void 0 : _a2.prototype;
|
|
3290
3308
|
if (!proto || proto.__svpPaperListPatched) return;
|
|
3291
3309
|
proto.setPaperList = function(list) {
|
|
3292
3310
|
this._paperList = Array.isArray(list) && list.length ? list : defaultPaperList;
|
|
@@ -3297,13 +3315,13 @@
|
|
|
3297
3315
|
proto.__svpPaperListPatched = true;
|
|
3298
3316
|
}
|
|
3299
3317
|
function patchPanelSettingTrigger(onPaperApplied) {
|
|
3300
|
-
var
|
|
3301
|
-
const bus = (
|
|
3318
|
+
var _a2;
|
|
3319
|
+
const bus = (_a2 = window.hinnn) == null ? void 0 : _a2.event;
|
|
3302
3320
|
if (!bus || bus.__svpPaperListTriggerPatch) return;
|
|
3303
3321
|
const origTrigger = bus.trigger.bind(bus);
|
|
3304
3322
|
bus.trigger = function(key, ...args) {
|
|
3305
|
-
var
|
|
3306
|
-
if (typeof key === "string" && key.startsWith("BuildCustomOptionSettingEventKey_") && ((
|
|
3323
|
+
var _a3;
|
|
3324
|
+
if (typeof key === "string" && key.startsWith("BuildCustomOptionSettingEventKey_") && ((_a3 = args[0]) == null ? void 0 : _a3.options)) {
|
|
3307
3325
|
const tplId = key.slice("BuildCustomOptionSettingEventKey_".length);
|
|
3308
3326
|
const tpl = resolveTemplate(tplId);
|
|
3309
3327
|
const panel = tpl == null ? void 0 : tpl.editingPanel;
|
|
@@ -3334,7 +3352,7 @@
|
|
|
3334
3352
|
patchPrintTemplatePaperList();
|
|
3335
3353
|
patchPanelSettingTrigger(onPaperApplied);
|
|
3336
3354
|
try {
|
|
3337
|
-
|
|
3355
|
+
hiprint.setConfig({
|
|
3338
3356
|
optionItems: [
|
|
3339
3357
|
PaperListOptionItem,
|
|
3340
3358
|
OrientOptionItem,
|
|
@@ -3511,13 +3529,13 @@
|
|
|
3511
3529
|
}
|
|
3512
3530
|
class SvpElementTypeProvider extends Provider {
|
|
3513
3531
|
addElementTypes(context) {
|
|
3514
|
-
var
|
|
3515
|
-
new
|
|
3532
|
+
var _a2;
|
|
3533
|
+
new VuePluginHiprint.defaultElementTypeProvider().addElementTypes(context);
|
|
3516
3534
|
if (typeof context.updateElementType === "function") {
|
|
3517
3535
|
context.updateElementType(TABLE_TID, applyCustomTableType);
|
|
3518
3536
|
return;
|
|
3519
3537
|
}
|
|
3520
|
-
const current = (
|
|
3538
|
+
const current = (_a2 = context.getElementType) == null ? void 0 : _a2.call(context, TABLE_TID);
|
|
3521
3539
|
if (current) applyCustomTableType(current);
|
|
3522
3540
|
}
|
|
3523
3541
|
}
|
|
@@ -3529,13 +3547,18 @@
|
|
|
3529
3547
|
if (!map) return [];
|
|
3530
3548
|
return Array.isArray(map) ? map : [map];
|
|
3531
3549
|
}
|
|
3550
|
+
const plugin = VuePluginHiprint__namespace;
|
|
3551
|
+
const hiprint = plugin.hiprint ?? ((_a = plugin.default) == null ? void 0 : _a.hiprint);
|
|
3552
|
+
const defaultElementTypeProvider = plugin.defaultElementTypeProvider ?? ((_b = plugin.default) == null ? void 0 : _b.defaultElementTypeProvider);
|
|
3553
|
+
const autoConnect = plugin.autoConnect ?? ((_c = plugin.default) == null ? void 0 : _c.autoConnect);
|
|
3554
|
+
const disAutoConnect = plugin.disAutoConnect ?? ((_d = plugin.default) == null ? void 0 : _d.disAutoConnect);
|
|
3532
3555
|
let initialized = false;
|
|
3533
3556
|
function initHiprint(options = {}) {
|
|
3534
|
-
var
|
|
3557
|
+
var _a2;
|
|
3535
3558
|
const providers = ensureProviders(options.providers);
|
|
3536
3559
|
if (!initialized) {
|
|
3537
3560
|
try {
|
|
3538
|
-
|
|
3561
|
+
hiprint.init({ providers, ...options.config ?? {} });
|
|
3539
3562
|
setupHiprintPaperList(
|
|
3540
3563
|
options.paperList ?? DEFAULT_PAPER_LIST,
|
|
3541
3564
|
options.onPaperApplied
|
|
@@ -3544,12 +3567,12 @@
|
|
|
3544
3567
|
console.error("[vue3-print-designer] hiprint.init failed", e);
|
|
3545
3568
|
}
|
|
3546
3569
|
initialized = true;
|
|
3547
|
-
} else if ((
|
|
3570
|
+
} else if ((_a2 = options.providers) == null ? void 0 : _a2.length) {
|
|
3548
3571
|
try {
|
|
3549
3572
|
options.providers.forEach(
|
|
3550
3573
|
(p) => {
|
|
3551
|
-
var
|
|
3552
|
-
return (
|
|
3574
|
+
var _a3, _b2;
|
|
3575
|
+
return (_b2 = (_a3 = hiprint.PrintElementTypeManager) == null ? void 0 : _a3.build) == null ? void 0 : _b2.call(_a3, [p]);
|
|
3553
3576
|
}
|
|
3554
3577
|
);
|
|
3555
3578
|
} catch (e) {
|
|
@@ -3558,11 +3581,11 @@
|
|
|
3558
3581
|
}
|
|
3559
3582
|
if (options.autoConnect === false) {
|
|
3560
3583
|
try {
|
|
3561
|
-
|
|
3584
|
+
disAutoConnect();
|
|
3562
3585
|
} catch (_) {
|
|
3563
3586
|
}
|
|
3564
3587
|
}
|
|
3565
|
-
return
|
|
3588
|
+
return hiprint;
|
|
3566
3589
|
}
|
|
3567
3590
|
function buildByHtml(selectors) {
|
|
3568
3591
|
if (typeof window === "undefined") return;
|
|
@@ -3576,13 +3599,474 @@
|
|
|
3576
3599
|
const $els = $(sel);
|
|
3577
3600
|
if ($els.length) {
|
|
3578
3601
|
try {
|
|
3579
|
-
|
|
3602
|
+
hiprint.PrintElementTypeManager.buildByHtml($els);
|
|
3580
3603
|
} catch (e) {
|
|
3581
3604
|
console.warn("[vue3-print-designer] buildByHtml failed", sel, e);
|
|
3582
3605
|
}
|
|
3583
3606
|
}
|
|
3584
3607
|
});
|
|
3585
3608
|
}
|
|
3609
|
+
function normalizePrinterList(raw) {
|
|
3610
|
+
if (!Array.isArray(raw)) return [];
|
|
3611
|
+
return raw.map((item) => {
|
|
3612
|
+
if (typeof item === "string") {
|
|
3613
|
+
return { name: item, displayName: item };
|
|
3614
|
+
}
|
|
3615
|
+
if (!item || typeof item !== "object") return null;
|
|
3616
|
+
const record = item;
|
|
3617
|
+
const name = String(record.name ?? record.Name ?? "");
|
|
3618
|
+
if (!name) return null;
|
|
3619
|
+
return {
|
|
3620
|
+
...record,
|
|
3621
|
+
name,
|
|
3622
|
+
displayName: String(record.displayName ?? record.DisplayName ?? name),
|
|
3623
|
+
isDefault: Boolean(record.isDefault ?? record.IsDefault ?? record.default)
|
|
3624
|
+
};
|
|
3625
|
+
}).filter((item) => item != null);
|
|
3626
|
+
}
|
|
3627
|
+
function normalizeClientList(raw) {
|
|
3628
|
+
if (!Array.isArray(raw)) return [];
|
|
3629
|
+
return raw.filter((item) => item && typeof item === "object");
|
|
3630
|
+
}
|
|
3631
|
+
function buildPrint2Payload(options) {
|
|
3632
|
+
if (!options) {
|
|
3633
|
+
return { printer: "", title: "print" };
|
|
3634
|
+
}
|
|
3635
|
+
const {
|
|
3636
|
+
printer,
|
|
3637
|
+
title,
|
|
3638
|
+
client,
|
|
3639
|
+
printByFragments,
|
|
3640
|
+
generateHTMLInterval,
|
|
3641
|
+
fragmentSize,
|
|
3642
|
+
sendInterval,
|
|
3643
|
+
...rest
|
|
3644
|
+
} = options;
|
|
3645
|
+
return {
|
|
3646
|
+
printer: printer ?? "",
|
|
3647
|
+
title: title ?? "print",
|
|
3648
|
+
...client != null ? { client } : {},
|
|
3649
|
+
...printByFragments != null ? { printByFragments } : {},
|
|
3650
|
+
...generateHTMLInterval != null ? { generateHTMLInterval } : {},
|
|
3651
|
+
...fragmentSize != null ? { fragmentSize } : {},
|
|
3652
|
+
...sendInterval != null ? { sendInterval } : {},
|
|
3653
|
+
...rest
|
|
3654
|
+
};
|
|
3655
|
+
}
|
|
3656
|
+
function readSocketConnected() {
|
|
3657
|
+
try {
|
|
3658
|
+
const ws = hiprint.hiwebSocket;
|
|
3659
|
+
if (!ws) return false;
|
|
3660
|
+
if (ws.opened === true || ws.connected === true) return true;
|
|
3661
|
+
if (typeof ws.isConnected === "function" && ws.isConnected()) return true;
|
|
3662
|
+
return false;
|
|
3663
|
+
} catch {
|
|
3664
|
+
return false;
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
const _PrintClient = class _PrintClient {
|
|
3668
|
+
constructor() {
|
|
3669
|
+
this.status = { connected: false };
|
|
3670
|
+
this.initConfig = {};
|
|
3671
|
+
this.connectPromise = null;
|
|
3672
|
+
this.connectionCallbacks = /* @__PURE__ */ new Set();
|
|
3673
|
+
this.printSuccessCallbacks = /* @__PURE__ */ new Set();
|
|
3674
|
+
this.printErrorCallbacks = /* @__PURE__ */ new Set();
|
|
3675
|
+
}
|
|
3676
|
+
static getInstance() {
|
|
3677
|
+
if (!_PrintClient.instance) _PrintClient.instance = new _PrintClient();
|
|
3678
|
+
return _PrintClient.instance;
|
|
3679
|
+
}
|
|
3680
|
+
connect(options = {}) {
|
|
3681
|
+
if (typeof window === "undefined") {
|
|
3682
|
+
const status = { connected: false, message: "PrintClient requires a browser environment." };
|
|
3683
|
+
this.updateStatus(status);
|
|
3684
|
+
return Promise.resolve(status);
|
|
3685
|
+
}
|
|
3686
|
+
if (this.getStatus().connected) {
|
|
3687
|
+
return Promise.resolve(this.getStatus());
|
|
3688
|
+
}
|
|
3689
|
+
if (this.connectPromise) return this.connectPromise;
|
|
3690
|
+
this.connectPromise = new Promise((resolve) => {
|
|
3691
|
+
var _a2;
|
|
3692
|
+
const timeoutMs = options.timeout ?? 1e4;
|
|
3693
|
+
let settled = false;
|
|
3694
|
+
const finish = (status) => {
|
|
3695
|
+
if (settled) return;
|
|
3696
|
+
settled = true;
|
|
3697
|
+
window.clearTimeout(timer);
|
|
3698
|
+
this.connectPromise = null;
|
|
3699
|
+
this.updateStatus(status);
|
|
3700
|
+
resolve(status);
|
|
3701
|
+
};
|
|
3702
|
+
const timer = window.setTimeout(() => {
|
|
3703
|
+
finish({
|
|
3704
|
+
connected: false,
|
|
3705
|
+
message: "Connection timeout. Is electron-hiprint running?"
|
|
3706
|
+
});
|
|
3707
|
+
}, timeoutMs);
|
|
3708
|
+
const config = { ...this.initConfig };
|
|
3709
|
+
if (options.host) config.host = options.host;
|
|
3710
|
+
if (options.token) config.token = options.token;
|
|
3711
|
+
this.initConfig = config;
|
|
3712
|
+
initHiprint({
|
|
3713
|
+
providers: ensureProviders(),
|
|
3714
|
+
autoConnect: false,
|
|
3715
|
+
config
|
|
3716
|
+
});
|
|
3717
|
+
try {
|
|
3718
|
+
if (options.host && typeof ((_a2 = hiprint.hiwebSocket) == null ? void 0 : _a2.setHost) === "function") {
|
|
3719
|
+
hiprint.hiwebSocket.setHost(options.host, options.token);
|
|
3720
|
+
}
|
|
3721
|
+
} catch (e) {
|
|
3722
|
+
console.warn("[print-designer] hiwebSocket.setHost failed", e);
|
|
3723
|
+
}
|
|
3724
|
+
try {
|
|
3725
|
+
autoConnect((status, msg) => {
|
|
3726
|
+
const message = typeof msg === "string" ? msg : msg != null ? String(msg) : status ? void 0 : "Failed to connect to print client.";
|
|
3727
|
+
finish({ connected: !!status, message });
|
|
3728
|
+
});
|
|
3729
|
+
} catch (e) {
|
|
3730
|
+
finish({
|
|
3731
|
+
connected: false,
|
|
3732
|
+
message: e instanceof Error ? e.message : String(e)
|
|
3733
|
+
});
|
|
3734
|
+
}
|
|
3735
|
+
});
|
|
3736
|
+
return this.connectPromise;
|
|
3737
|
+
}
|
|
3738
|
+
disconnect() {
|
|
3739
|
+
try {
|
|
3740
|
+
disAutoConnect();
|
|
3741
|
+
} catch {
|
|
3742
|
+
}
|
|
3743
|
+
this.connectPromise = null;
|
|
3744
|
+
this.updateStatus({ connected: false, message: "Disconnected." });
|
|
3745
|
+
}
|
|
3746
|
+
getStatus() {
|
|
3747
|
+
const socketConnected = readSocketConnected();
|
|
3748
|
+
if (socketConnected && !this.status.connected) {
|
|
3749
|
+
this.status = { connected: true };
|
|
3750
|
+
}
|
|
3751
|
+
if (!socketConnected && this.status.connected) {
|
|
3752
|
+
this.status = { connected: false, message: this.status.message ?? "Disconnected." };
|
|
3753
|
+
}
|
|
3754
|
+
return { ...this.status };
|
|
3755
|
+
}
|
|
3756
|
+
getPrinterList() {
|
|
3757
|
+
var _a2, _b2;
|
|
3758
|
+
try {
|
|
3759
|
+
const list = (_b2 = (_a2 = hiprint.hiwebSocket) == null ? void 0 : _a2.getPrinterList) == null ? void 0 : _b2.call(_a2);
|
|
3760
|
+
return normalizePrinterList(list);
|
|
3761
|
+
} catch {
|
|
3762
|
+
return [];
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
getClients() {
|
|
3766
|
+
try {
|
|
3767
|
+
const ws = hiprint.hiwebSocket;
|
|
3768
|
+
if (!ws) return [];
|
|
3769
|
+
if (Array.isArray(ws.clients)) return normalizeClientList(ws.clients);
|
|
3770
|
+
if (typeof ws.getClients === "function") {
|
|
3771
|
+
return normalizeClientList(ws.getClients());
|
|
3772
|
+
}
|
|
3773
|
+
return [];
|
|
3774
|
+
} catch {
|
|
3775
|
+
return [];
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
async printByTemplate(template, printData, options) {
|
|
3779
|
+
initHiprint({
|
|
3780
|
+
providers: ensureProviders(),
|
|
3781
|
+
autoConnect: false,
|
|
3782
|
+
config: this.initConfig
|
|
3783
|
+
});
|
|
3784
|
+
const instance = new hiprint.PrintTemplate({ template });
|
|
3785
|
+
return this.printByInstance(instance, printData, options);
|
|
3786
|
+
}
|
|
3787
|
+
async printByInstance(printTemplate, printData, options) {
|
|
3788
|
+
if (!this.getStatus().connected) {
|
|
3789
|
+
throw new Error("[print-designer] Print client is not connected. Call connect() first.");
|
|
3790
|
+
}
|
|
3791
|
+
if (typeof (printTemplate == null ? void 0 : printTemplate.print2) !== "function") {
|
|
3792
|
+
throw new Error("[print-designer] print2 is not available on the template instance.");
|
|
3793
|
+
}
|
|
3794
|
+
return new Promise((resolve, reject) => {
|
|
3795
|
+
var _a2, _b2;
|
|
3796
|
+
const onSuccess = (data2) => {
|
|
3797
|
+
cleanup();
|
|
3798
|
+
this.notifyPrintSuccess(data2);
|
|
3799
|
+
resolve();
|
|
3800
|
+
};
|
|
3801
|
+
const onError = (data2) => {
|
|
3802
|
+
cleanup();
|
|
3803
|
+
this.notifyPrintError(data2);
|
|
3804
|
+
reject(data2 instanceof Error ? data2 : new Error(String(data2 ?? "Print failed")));
|
|
3805
|
+
};
|
|
3806
|
+
const cleanup = () => {
|
|
3807
|
+
var _a3, _b3;
|
|
3808
|
+
try {
|
|
3809
|
+
(_a3 = printTemplate.off) == null ? void 0 : _a3.call(printTemplate, "printSuccess", onSuccess);
|
|
3810
|
+
} catch {
|
|
3811
|
+
}
|
|
3812
|
+
try {
|
|
3813
|
+
(_b3 = printTemplate.off) == null ? void 0 : _b3.call(printTemplate, "printError", onError);
|
|
3814
|
+
} catch {
|
|
3815
|
+
}
|
|
3816
|
+
};
|
|
3817
|
+
try {
|
|
3818
|
+
(_a2 = printTemplate.on) == null ? void 0 : _a2.call(printTemplate, "printSuccess", onSuccess);
|
|
3819
|
+
(_b2 = printTemplate.on) == null ? void 0 : _b2.call(printTemplate, "printError", onError);
|
|
3820
|
+
printTemplate.print2(printData, buildPrint2Payload(options));
|
|
3821
|
+
} catch (e) {
|
|
3822
|
+
cleanup();
|
|
3823
|
+
reject(e);
|
|
3824
|
+
}
|
|
3825
|
+
});
|
|
3826
|
+
}
|
|
3827
|
+
onConnectionChange(callback2) {
|
|
3828
|
+
this.connectionCallbacks.add(callback2);
|
|
3829
|
+
return () => {
|
|
3830
|
+
this.connectionCallbacks.delete(callback2);
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
onPrintSuccess(callback2) {
|
|
3834
|
+
this.printSuccessCallbacks.add(callback2);
|
|
3835
|
+
return () => {
|
|
3836
|
+
this.printSuccessCallbacks.delete(callback2);
|
|
3837
|
+
};
|
|
3838
|
+
}
|
|
3839
|
+
onPrintError(callback2) {
|
|
3840
|
+
this.printErrorCallbacks.add(callback2);
|
|
3841
|
+
return () => {
|
|
3842
|
+
this.printErrorCallbacks.delete(callback2);
|
|
3843
|
+
};
|
|
3844
|
+
}
|
|
3845
|
+
updateStatus(status) {
|
|
3846
|
+
this.status = status;
|
|
3847
|
+
this.notifyConnectionChange(status);
|
|
3848
|
+
}
|
|
3849
|
+
notifyConnectionChange(status) {
|
|
3850
|
+
this.connectionCallbacks.forEach((cb) => {
|
|
3851
|
+
try {
|
|
3852
|
+
cb(status);
|
|
3853
|
+
} catch (e) {
|
|
3854
|
+
console.error("[print-designer] connection listener failed", e);
|
|
3855
|
+
}
|
|
3856
|
+
});
|
|
3857
|
+
}
|
|
3858
|
+
notifyPrintSuccess(data2) {
|
|
3859
|
+
this.printSuccessCallbacks.forEach((cb) => {
|
|
3860
|
+
try {
|
|
3861
|
+
cb(data2);
|
|
3862
|
+
} catch (e) {
|
|
3863
|
+
console.error("[print-designer] printSuccess listener failed", e);
|
|
3864
|
+
}
|
|
3865
|
+
});
|
|
3866
|
+
}
|
|
3867
|
+
notifyPrintError(data2) {
|
|
3868
|
+
this.printErrorCallbacks.forEach((cb) => {
|
|
3869
|
+
try {
|
|
3870
|
+
cb(data2);
|
|
3871
|
+
} catch (e) {
|
|
3872
|
+
console.error("[print-designer] printError listener failed", e);
|
|
3873
|
+
}
|
|
3874
|
+
});
|
|
3875
|
+
}
|
|
3876
|
+
};
|
|
3877
|
+
_PrintClient.instance = null;
|
|
3878
|
+
let PrintClient = _PrintClient;
|
|
3879
|
+
function getPrintClient() {
|
|
3880
|
+
return PrintClient.getInstance();
|
|
3881
|
+
}
|
|
3882
|
+
function resolvePreviewHtml(value) {
|
|
3883
|
+
if (value == null || value === false) return "";
|
|
3884
|
+
if (typeof value === "string") return value;
|
|
3885
|
+
const any = value;
|
|
3886
|
+
if (typeof any.html === "function") {
|
|
3887
|
+
try {
|
|
3888
|
+
const html = any.html();
|
|
3889
|
+
if (typeof html === "string") return html;
|
|
3890
|
+
} catch {
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
if (Array.isArray(value)) {
|
|
3894
|
+
return value.map((item) => resolvePreviewHtml(item)).join("");
|
|
3895
|
+
}
|
|
3896
|
+
if (typeof any.length === "number" && any.length > 0 && any[0] != null) {
|
|
3897
|
+
return resolvePreviewHtml(any[0]);
|
|
3898
|
+
}
|
|
3899
|
+
if (any.target != null) {
|
|
3900
|
+
return resolvePreviewHtml(any.target);
|
|
3901
|
+
}
|
|
3902
|
+
return "";
|
|
3903
|
+
}
|
|
3904
|
+
function collectHostStyles() {
|
|
3905
|
+
if (typeof document === "undefined") return "";
|
|
3906
|
+
const parts = [];
|
|
3907
|
+
document.querySelectorAll('link[rel="stylesheet"]').forEach((el) => {
|
|
3908
|
+
const href = el.getAttribute("href");
|
|
3909
|
+
if (!href) return;
|
|
3910
|
+
const media = el.getAttribute("media");
|
|
3911
|
+
const mediaAttr = media ? ` media="${media}"` : "";
|
|
3912
|
+
parts.push(`<link rel="stylesheet" href="${href}"${mediaAttr}>`);
|
|
3913
|
+
if (media && /print/i.test(media) && href.includes("print-lock.css")) {
|
|
3914
|
+
parts.push(`<link rel="stylesheet" href="${href}">`);
|
|
3915
|
+
}
|
|
3916
|
+
});
|
|
3917
|
+
document.querySelectorAll("style").forEach((el) => {
|
|
3918
|
+
parts.push(`<style>${el.textContent ?? ""}</style>`);
|
|
3919
|
+
});
|
|
3920
|
+
return parts.join("\n");
|
|
3921
|
+
}
|
|
3922
|
+
function buildIframeDocument(args) {
|
|
3923
|
+
const handlerStyles = args.styleHandler ? args.styleHandler() : "";
|
|
3924
|
+
const hostStyles = args.importCss ? collectHostStyles() : "";
|
|
3925
|
+
return `<!DOCTYPE html>
|
|
3926
|
+
<html>
|
|
3927
|
+
<head>
|
|
3928
|
+
<meta charset="UTF-8">
|
|
3929
|
+
<title>${args.title}</title>
|
|
3930
|
+
${hostStyles}
|
|
3931
|
+
${handlerStyles}
|
|
3932
|
+
</head>
|
|
3933
|
+
<body>${args.html}</body>
|
|
3934
|
+
</html>`;
|
|
3935
|
+
}
|
|
3936
|
+
function printIframe(args) {
|
|
3937
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
3938
|
+
return Promise.resolve();
|
|
3939
|
+
}
|
|
3940
|
+
const previous = document.getElementById("svp_batch_print_iframe");
|
|
3941
|
+
if (previous == null ? void 0 : previous.parentNode) previous.parentNode.removeChild(previous);
|
|
3942
|
+
const iframe = document.createElement("iframe");
|
|
3943
|
+
iframe.id = "svp_batch_print_iframe";
|
|
3944
|
+
iframe.setAttribute(
|
|
3945
|
+
"style",
|
|
3946
|
+
"visibility: hidden; height: 0; width: 0; position: absolute; border: 0;"
|
|
3947
|
+
);
|
|
3948
|
+
document.body.appendChild(iframe);
|
|
3949
|
+
const cleanup = () => {
|
|
3950
|
+
try {
|
|
3951
|
+
if (iframe.parentNode) iframe.parentNode.removeChild(iframe);
|
|
3952
|
+
} catch {
|
|
3953
|
+
}
|
|
3954
|
+
};
|
|
3955
|
+
return new Promise((resolve) => {
|
|
3956
|
+
let triggered = false;
|
|
3957
|
+
const trigger = () => {
|
|
3958
|
+
if (triggered) return;
|
|
3959
|
+
triggered = true;
|
|
3960
|
+
try {
|
|
3961
|
+
const win = iframe.contentWindow;
|
|
3962
|
+
if (!win) {
|
|
3963
|
+
cleanup();
|
|
3964
|
+
resolve();
|
|
3965
|
+
return;
|
|
3966
|
+
}
|
|
3967
|
+
const finish = () => {
|
|
3968
|
+
var _a2;
|
|
3969
|
+
(_a2 = args.callback) == null ? void 0 : _a2.call(args);
|
|
3970
|
+
setTimeout(() => {
|
|
3971
|
+
cleanup();
|
|
3972
|
+
resolve();
|
|
3973
|
+
}, 500);
|
|
3974
|
+
};
|
|
3975
|
+
const onAfterPrint = () => {
|
|
3976
|
+
win.removeEventListener("afterprint", onAfterPrint);
|
|
3977
|
+
finish();
|
|
3978
|
+
};
|
|
3979
|
+
win.addEventListener("afterprint", onAfterPrint);
|
|
3980
|
+
try {
|
|
3981
|
+
win.focus();
|
|
3982
|
+
win.print();
|
|
3983
|
+
} catch (e) {
|
|
3984
|
+
console.error("[batch-print] window.print failed", e);
|
|
3985
|
+
finish();
|
|
3986
|
+
}
|
|
3987
|
+
setTimeout(finish, 6e4);
|
|
3988
|
+
} catch (e) {
|
|
3989
|
+
console.error("[batch-print] trigger failed", e);
|
|
3990
|
+
cleanup();
|
|
3991
|
+
resolve();
|
|
3992
|
+
}
|
|
3993
|
+
};
|
|
3994
|
+
iframe.onload = () => {
|
|
3995
|
+
waitForImages(iframe.contentDocument, trigger);
|
|
3996
|
+
};
|
|
3997
|
+
setTimeout(() => {
|
|
3998
|
+
if (!triggered) trigger();
|
|
3999
|
+
}, args.timeout);
|
|
4000
|
+
const doc = iframe.contentDocument;
|
|
4001
|
+
const docString = buildIframeDocument(args);
|
|
4002
|
+
if (doc) {
|
|
4003
|
+
doc.open();
|
|
4004
|
+
doc.write(docString);
|
|
4005
|
+
doc.close();
|
|
4006
|
+
} else {
|
|
4007
|
+
iframe.srcdoc = docString;
|
|
4008
|
+
}
|
|
4009
|
+
});
|
|
4010
|
+
}
|
|
4011
|
+
function waitForImages(doc, done, attempt = 0) {
|
|
4012
|
+
if (!doc) {
|
|
4013
|
+
done();
|
|
4014
|
+
return;
|
|
4015
|
+
}
|
|
4016
|
+
const imgs = doc.getElementsByTagName("img");
|
|
4017
|
+
let ready = true;
|
|
4018
|
+
for (let i = 0; i < imgs.length; i++) {
|
|
4019
|
+
const img = imgs[i];
|
|
4020
|
+
if (!img.src || img.src.indexOf("base64") >= 0) continue;
|
|
4021
|
+
if (img.complete && (img.naturalWidth ?? 1) > 0) continue;
|
|
4022
|
+
ready = false;
|
|
4023
|
+
break;
|
|
4024
|
+
}
|
|
4025
|
+
if (ready || attempt >= 10) {
|
|
4026
|
+
done();
|
|
4027
|
+
return;
|
|
4028
|
+
}
|
|
4029
|
+
setTimeout(() => waitForImages(doc, done, attempt + 1), 500);
|
|
4030
|
+
}
|
|
4031
|
+
function pageWrap(html, withBreak) {
|
|
4032
|
+
const breakStyle = withBreak ? ' style="page-break-after: always; break-after: page;"' : "";
|
|
4033
|
+
return `<div class="svp-batch-page"${breakStyle}>${html}</div>`;
|
|
4034
|
+
}
|
|
4035
|
+
async function batchPrint(printTemplate, printDataList, options = {}) {
|
|
4036
|
+
if (!printTemplate || typeof printTemplate.getHtml !== "function") {
|
|
4037
|
+
throw new Error("[batch-print] printTemplate.getHtml is required.");
|
|
4038
|
+
}
|
|
4039
|
+
const list = Array.isArray(printDataList) ? printDataList : [printDataList];
|
|
4040
|
+
if (!list.length) {
|
|
4041
|
+
throw new Error("[batch-print] printDataList is empty.");
|
|
4042
|
+
}
|
|
4043
|
+
const copies = Math.max(1, Math.floor(options.copies ?? 1));
|
|
4044
|
+
const pageBreak = options.pageBreak !== false;
|
|
4045
|
+
const title = options.title ?? "print";
|
|
4046
|
+
const expanded = [];
|
|
4047
|
+
for (const item of list) {
|
|
4048
|
+
for (let i = 0; i < copies; i++) expanded.push(item);
|
|
4049
|
+
}
|
|
4050
|
+
const fragments = [];
|
|
4051
|
+
for (let i = 0; i < expanded.length; i++) {
|
|
4052
|
+
const raw = printTemplate.getHtml(expanded[i]);
|
|
4053
|
+
const html = resolvePreviewHtml(raw);
|
|
4054
|
+
if (!html) continue;
|
|
4055
|
+
const isLast = i === expanded.length - 1;
|
|
4056
|
+
fragments.push(pageWrap(html, pageBreak && !isLast));
|
|
4057
|
+
}
|
|
4058
|
+
if (!fragments.length) {
|
|
4059
|
+
throw new Error("[batch-print] No HTML produced from print data.");
|
|
4060
|
+
}
|
|
4061
|
+
await printIframe({
|
|
4062
|
+
html: fragments.join("\n"),
|
|
4063
|
+
title,
|
|
4064
|
+
styleHandler: options.styleHandler,
|
|
4065
|
+
importCss: options.importCss !== false,
|
|
4066
|
+
callback: options.callback,
|
|
4067
|
+
timeout: Math.max(500, options.timeout ?? 1500)
|
|
4068
|
+
});
|
|
4069
|
+
}
|
|
3586
4070
|
class PluginManager {
|
|
3587
4071
|
constructor() {
|
|
3588
4072
|
this.hooks = /* @__PURE__ */ new Map();
|
|
@@ -3593,12 +4077,12 @@
|
|
|
3593
4077
|
this.plugins = [];
|
|
3594
4078
|
plugins.forEach((p) => this.register(p));
|
|
3595
4079
|
}
|
|
3596
|
-
register(
|
|
3597
|
-
var
|
|
3598
|
-
if (!
|
|
3599
|
-
this.plugins.push(
|
|
3600
|
-
(
|
|
3601
|
-
|
|
4080
|
+
register(plugin2) {
|
|
4081
|
+
var _a2;
|
|
4082
|
+
if (!plugin2 || !Array.isArray(plugin2.hooks)) return;
|
|
4083
|
+
this.plugins.push(plugin2);
|
|
4084
|
+
(_a2 = plugin2.init) == null ? void 0 : _a2.call(plugin2, plugin2.config ?? {});
|
|
4085
|
+
plugin2.hooks.forEach((h) => {
|
|
3602
4086
|
const arr = this.hooks.get(h.hook) ?? [];
|
|
3603
4087
|
arr.push(h);
|
|
3604
4088
|
arr.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
|
|
@@ -3609,8 +4093,8 @@
|
|
|
3609
4093
|
return this.plugins.slice();
|
|
3610
4094
|
}
|
|
3611
4095
|
has(hook) {
|
|
3612
|
-
var
|
|
3613
|
-
return (((
|
|
4096
|
+
var _a2;
|
|
4097
|
+
return (((_a2 = this.hooks.get(hook)) == null ? void 0 : _a2.length) ?? 0) > 0;
|
|
3614
4098
|
}
|
|
3615
4099
|
/** Run all callbacks sequentially. Returns the array of results. */
|
|
3616
4100
|
async run(hook, ...args) {
|
|
@@ -3735,9 +4219,9 @@
|
|
|
3735
4219
|
this.onChanged = onChanged;
|
|
3736
4220
|
}
|
|
3737
4221
|
applySnapshot(tpl, json, panelIndex) {
|
|
3738
|
-
var
|
|
4222
|
+
var _a2, _b2, _c2;
|
|
3739
4223
|
if (!(tpl == null ? void 0 : tpl.update) || json == null) return;
|
|
3740
|
-
const index2 = panelIndex ?? ((
|
|
4224
|
+
const index2 = panelIndex ?? ((_a2 = tpl.editingPanel) == null ? void 0 : _a2.index) ?? ((_c2 = (_b2 = tpl.printPanels) == null ? void 0 : _b2[0]) == null ? void 0 : _c2.index) ?? 0;
|
|
3741
4225
|
tpl.update(json, index2);
|
|
3742
4226
|
}
|
|
3743
4227
|
refreshFromTemplate() {
|
|
@@ -3792,9 +4276,9 @@
|
|
|
3792
4276
|
this.finishChange();
|
|
3793
4277
|
}
|
|
3794
4278
|
jump(index2) {
|
|
3795
|
-
var
|
|
4279
|
+
var _a2;
|
|
3796
4280
|
const tpl = this.getTpl();
|
|
3797
|
-
if (!(tpl == null ? void 0 : tpl.history) || !((
|
|
4281
|
+
if (!(tpl == null ? void 0 : tpl.history) || !((_a2 = tpl.historyList) == null ? void 0 : _a2[index2])) return;
|
|
3798
4282
|
tpl.historyPos = index2;
|
|
3799
4283
|
const entry = tpl.historyList[index2];
|
|
3800
4284
|
this.applySnapshot(tpl, entry == null ? void 0 : entry.json);
|
|
@@ -3827,9 +4311,9 @@
|
|
|
3827
4311
|
this.finishChange();
|
|
3828
4312
|
}
|
|
3829
4313
|
finishChange() {
|
|
3830
|
-
var
|
|
4314
|
+
var _a2;
|
|
3831
4315
|
this.refreshFromTemplate();
|
|
3832
|
-
(
|
|
4316
|
+
(_a2 = this.onChanged) == null ? void 0 : _a2.call(this);
|
|
3833
4317
|
}
|
|
3834
4318
|
}
|
|
3835
4319
|
function normalize(e) {
|
|
@@ -3860,8 +4344,8 @@
|
|
|
3860
4344
|
mount() {
|
|
3861
4345
|
if (typeof window === "undefined" || this.handler) return;
|
|
3862
4346
|
this.handler = (e) => {
|
|
3863
|
-
var
|
|
3864
|
-
if (((
|
|
4347
|
+
var _a2, _b2;
|
|
4348
|
+
if (((_b2 = (_a2 = this.options).beforeDispatch) == null ? void 0 : _b2.call(_a2, e)) === false) return;
|
|
3865
4349
|
const t = e.target;
|
|
3866
4350
|
if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable)) {
|
|
3867
4351
|
const combo2 = normalize(e);
|
|
@@ -4011,7 +4495,7 @@
|
|
|
4011
4495
|
});
|
|
4012
4496
|
ta.addEventListener("scroll", syncScroll);
|
|
4013
4497
|
modal.addEventListener("click", (e) => {
|
|
4014
|
-
var
|
|
4498
|
+
var _a2;
|
|
4015
4499
|
const act = e.target.dataset.act;
|
|
4016
4500
|
if (act === "cancel") close(null);
|
|
4017
4501
|
else if (act === "clear") {
|
|
@@ -4020,7 +4504,7 @@
|
|
|
4020
4504
|
syncLines();
|
|
4021
4505
|
ta.focus();
|
|
4022
4506
|
} else if (act === "copy") {
|
|
4023
|
-
(
|
|
4507
|
+
(_a2 = navigator.clipboard) == null ? void 0 : _a2.writeText(ta.value).catch(() => {
|
|
4024
4508
|
ta.focus();
|
|
4025
4509
|
ta.select();
|
|
4026
4510
|
try {
|
|
@@ -4214,7 +4698,19 @@
|
|
|
4214
4698
|
printDataAddRow: "添加一行",
|
|
4215
4699
|
printDataDeleteRow: "删除",
|
|
4216
4700
|
printDataFieldKey: "字段",
|
|
4217
|
-
paper: "纸张"
|
|
4701
|
+
paper: "纸张",
|
|
4702
|
+
browserPrint: "浏览器打印",
|
|
4703
|
+
silentPrint: "静默打印",
|
|
4704
|
+
batchPrint: "批量打印",
|
|
4705
|
+
batchPrinting: "正在准备…",
|
|
4706
|
+
batchCopies: "每条份数",
|
|
4707
|
+
batchHint: "共 {rows} 条数据 × 每条份数 = 合计 {total} 页(无需客户端)",
|
|
4708
|
+
printClientConnected: "打印客户端已连接",
|
|
4709
|
+
printClientDisconnected: "打印客户端未连接",
|
|
4710
|
+
printClientConnect: "连接客户端",
|
|
4711
|
+
printClientDisconnect: "断开连接",
|
|
4712
|
+
printClientNoPrinters: "未检测到打印机",
|
|
4713
|
+
defaultPrinter: "默认"
|
|
4218
4714
|
},
|
|
4219
4715
|
header: {
|
|
4220
4716
|
title: "打印设计器"
|
|
@@ -4317,7 +4813,19 @@
|
|
|
4317
4813
|
printDataAddRow: "Add row",
|
|
4318
4814
|
printDataDeleteRow: "Delete",
|
|
4319
4815
|
printDataFieldKey: "Field",
|
|
4320
|
-
paper: "Paper"
|
|
4816
|
+
paper: "Paper",
|
|
4817
|
+
browserPrint: "Browser Print",
|
|
4818
|
+
silentPrint: "Silent Print",
|
|
4819
|
+
batchPrint: "Batch Print",
|
|
4820
|
+
batchPrinting: "Preparing…",
|
|
4821
|
+
batchCopies: "Copies per record",
|
|
4822
|
+
batchHint: "{rows} records × copies = {total} pages (no client required)",
|
|
4823
|
+
printClientConnected: "Print client connected",
|
|
4824
|
+
printClientDisconnected: "Print client disconnected",
|
|
4825
|
+
printClientConnect: "Connect Client",
|
|
4826
|
+
printClientDisconnect: "Disconnect",
|
|
4827
|
+
printClientNoPrinters: "No printers found",
|
|
4828
|
+
defaultPrinter: "Default"
|
|
4321
4829
|
},
|
|
4322
4830
|
header: {
|
|
4323
4831
|
title: "Print Designer"
|
|
@@ -4555,8 +5063,21 @@
|
|
|
4555
5063
|
setConfig(config) {
|
|
4556
5064
|
if (config) Object.assign(this.options, { config });
|
|
4557
5065
|
}
|
|
4558
|
-
setConnect(connect,
|
|
5066
|
+
setConnect(connect, callback2) {
|
|
5067
|
+
var _a2, _b2;
|
|
4559
5068
|
this.options.connect = connect;
|
|
5069
|
+
const client = getPrintClient();
|
|
5070
|
+
if (connect) {
|
|
5071
|
+
void client.connect({
|
|
5072
|
+
host: (_a2 = this.options.config) == null ? void 0 : _a2.host,
|
|
5073
|
+
token: (_b2 = this.options.config) == null ? void 0 : _b2.token
|
|
5074
|
+
}).then((status) => {
|
|
5075
|
+
callback2 == null ? void 0 : callback2(status.connected, status.message);
|
|
5076
|
+
});
|
|
5077
|
+
return;
|
|
5078
|
+
}
|
|
5079
|
+
client.disconnect();
|
|
5080
|
+
callback2 == null ? void 0 : callback2(false);
|
|
4560
5081
|
}
|
|
4561
5082
|
initProviders(providers) {
|
|
4562
5083
|
initHiprint({
|
|
@@ -4565,9 +5086,9 @@
|
|
|
4565
5086
|
config: this.options.config,
|
|
4566
5087
|
paperList: this.options.paperList,
|
|
4567
5088
|
onPaperApplied: () => {
|
|
4568
|
-
var
|
|
5089
|
+
var _a2, _b2;
|
|
4569
5090
|
try {
|
|
4570
|
-
(
|
|
5091
|
+
(_b2 = (_a2 = this.ruler) == null ? void 0 : _a2.redraw) == null ? void 0 : _b2.call(_a2);
|
|
4571
5092
|
} catch {
|
|
4572
5093
|
}
|
|
4573
5094
|
}
|
|
@@ -4582,7 +5103,7 @@
|
|
|
4582
5103
|
list.forEach((m) => {
|
|
4583
5104
|
try {
|
|
4584
5105
|
const $els = $(m.container);
|
|
4585
|
-
if ($els.length)
|
|
5106
|
+
if ($els.length) hiprint.PrintElementTypeManager.buildByHtml($els);
|
|
4586
5107
|
} catch (e) {
|
|
4587
5108
|
console.warn("buildByProvider", e);
|
|
4588
5109
|
}
|
|
@@ -4595,20 +5116,20 @@
|
|
|
4595
5116
|
// PrintTemplate lifecycle
|
|
4596
5117
|
// -------------------------------------------------------------------------
|
|
4597
5118
|
newPrintTemplate(template) {
|
|
4598
|
-
const tpl = new
|
|
5119
|
+
const tpl = new hiprint.PrintTemplate({ template });
|
|
4599
5120
|
return tpl;
|
|
4600
5121
|
}
|
|
4601
5122
|
newDesigner(options, designOptions = {}) {
|
|
4602
|
-
var
|
|
5123
|
+
var _a2, _b2;
|
|
4603
5124
|
if (this.printTemplate) {
|
|
4604
5125
|
this.unbindSelectionEvents();
|
|
4605
5126
|
this.unbindZoomEvents();
|
|
4606
5127
|
try {
|
|
4607
|
-
(
|
|
5128
|
+
(_b2 = (_a2 = this.printTemplate).clear) == null ? void 0 : _b2.call(_a2);
|
|
4608
5129
|
} catch (_) {
|
|
4609
5130
|
}
|
|
4610
5131
|
}
|
|
4611
|
-
const tpl = new
|
|
5132
|
+
const tpl = new hiprint.PrintTemplate({
|
|
4612
5133
|
template: options.template,
|
|
4613
5134
|
settingContainer: options.settingContainer ? options.settingContainer : `#${SETTING_CONTAINER_ID}`,
|
|
4614
5135
|
paginationContainer: options.paginationContainer,
|
|
@@ -4616,19 +5137,19 @@
|
|
|
4616
5137
|
history: options.history ?? true,
|
|
4617
5138
|
onImageChooseClick: options.onImageChooseClick,
|
|
4618
5139
|
onZoomChange: (scale) => {
|
|
4619
|
-
var
|
|
5140
|
+
var _a3;
|
|
4620
5141
|
setZoom(scale);
|
|
4621
|
-
(
|
|
5142
|
+
(_a3 = options.onZoomChange) == null ? void 0 : _a3.call(options, scale);
|
|
4622
5143
|
},
|
|
4623
5144
|
onPanelAddClick: options.onPanelAddClick,
|
|
4624
5145
|
onFunctionClick: options.onFunctionClick,
|
|
4625
5146
|
onDataChanged: (type, json) => {
|
|
4626
|
-
var
|
|
5147
|
+
var _a3;
|
|
4627
5148
|
this.history.refreshFromTemplate();
|
|
4628
5149
|
this.refreshSelection();
|
|
4629
5150
|
this.reapplyElementTransforms();
|
|
4630
5151
|
designerStore.uiPulse += 1;
|
|
4631
|
-
(
|
|
5152
|
+
(_a3 = options.onDataChanged) == null ? void 0 : _a3.call(options, type, json);
|
|
4632
5153
|
},
|
|
4633
5154
|
onUpdateError: options.onUpdateError
|
|
4634
5155
|
});
|
|
@@ -4661,28 +5182,28 @@
|
|
|
4661
5182
|
return tpl;
|
|
4662
5183
|
}
|
|
4663
5184
|
unbindSelectionEvents() {
|
|
4664
|
-
var
|
|
4665
|
-
(
|
|
5185
|
+
var _a2;
|
|
5186
|
+
(_a2 = this.selectionEventCleanup) == null ? void 0 : _a2.call(this);
|
|
4666
5187
|
this.selectionEventCleanup = null;
|
|
4667
5188
|
}
|
|
4668
5189
|
unbindZoomEvents() {
|
|
4669
|
-
var
|
|
4670
|
-
(
|
|
5190
|
+
var _a2;
|
|
5191
|
+
(_a2 = this.zoomEventCleanup) == null ? void 0 : _a2.call(this);
|
|
4671
5192
|
this.zoomEventCleanup = null;
|
|
4672
5193
|
}
|
|
4673
5194
|
/** Keep store/ruler in sync when hiprint paper scale changes (e.g. zoom toolbar). */
|
|
4674
5195
|
bindZoomEvents(tpl) {
|
|
4675
|
-
var
|
|
5196
|
+
var _a2;
|
|
4676
5197
|
this.unbindZoomEvents();
|
|
4677
|
-
const paper = (
|
|
5198
|
+
const paper = (_a2 = tpl == null ? void 0 : tpl.editingPanel) == null ? void 0 : _a2.designPaper;
|
|
4678
5199
|
if (!(paper == null ? void 0 : paper.subscribePaperBaseInfoChanged)) return;
|
|
4679
5200
|
const onPaperInfo = (info) => {
|
|
4680
|
-
var
|
|
5201
|
+
var _a3, _b2;
|
|
4681
5202
|
if (typeof (info == null ? void 0 : info.scale) !== "number" || !(info.scale > 0)) return;
|
|
4682
5203
|
const next = Math.max(ZOOM_MIN, Math.min(ZOOM_MAX, info.scale));
|
|
4683
5204
|
if (Math.abs(next - this.state.zoom) < 1e-3) return;
|
|
4684
5205
|
setZoom(next);
|
|
4685
|
-
(
|
|
5206
|
+
(_b2 = (_a3 = this.ruler) == null ? void 0 : _a3.redraw) == null ? void 0 : _b2.call(_a3);
|
|
4686
5207
|
};
|
|
4687
5208
|
paper.subscribePaperBaseInfoChanged(onPaperInfo);
|
|
4688
5209
|
this.zoomEventCleanup = () => {
|
|
@@ -4693,23 +5214,23 @@
|
|
|
4693
5214
|
};
|
|
4694
5215
|
}
|
|
4695
5216
|
syncZoomFromTemplate() {
|
|
4696
|
-
var
|
|
5217
|
+
var _a2, _b2;
|
|
4697
5218
|
setZoom(this.getZoom());
|
|
4698
|
-
(
|
|
5219
|
+
(_b2 = (_a2 = this.ruler) == null ? void 0 : _a2.redraw) == null ? void 0 : _b2.call(_a2);
|
|
4699
5220
|
}
|
|
4700
5221
|
readTemplateScale() {
|
|
4701
|
-
var
|
|
5222
|
+
var _a2, _b2, _c2;
|
|
4702
5223
|
const tpl = this.printTemplate;
|
|
4703
5224
|
if (!tpl) return null;
|
|
4704
|
-
const scale = ((
|
|
5225
|
+
const scale = ((_b2 = (_a2 = tpl.editingPanel) == null ? void 0 : _a2.designPaper) == null ? void 0 : _b2.scale) ?? ((_c2 = tpl.editingPanel) == null ? void 0 : _c2.scale) ?? tpl.scale;
|
|
4705
5226
|
return typeof scale === "number" && scale > 0 ? scale : null;
|
|
4706
5227
|
}
|
|
4707
5228
|
/** Sync Vue selection state when hiprint selects / deselects print elements. */
|
|
4708
5229
|
bindSelectionEvents(tpl) {
|
|
4709
|
-
var
|
|
5230
|
+
var _a2;
|
|
4710
5231
|
this.unbindSelectionEvents();
|
|
4711
5232
|
if (typeof window === "undefined" || !tpl) return;
|
|
4712
|
-
const eventBus = (
|
|
5233
|
+
const eventBus = (_a2 = window.hinnn) == null ? void 0 : _a2.event;
|
|
4713
5234
|
const tplId = tpl.id ?? tpl.templateId;
|
|
4714
5235
|
if (!eventBus || tplId == null) return;
|
|
4715
5236
|
const selectKey = `PrintElementSelectEventKey_${tplId}`;
|
|
@@ -4751,9 +5272,9 @@
|
|
|
4751
5272
|
};
|
|
4752
5273
|
}
|
|
4753
5274
|
refreshPrintTemplate() {
|
|
4754
|
-
var
|
|
5275
|
+
var _a2, _b2;
|
|
4755
5276
|
try {
|
|
4756
|
-
(
|
|
5277
|
+
(_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.refresh) == null ? void 0 : _b2.call(_a2);
|
|
4757
5278
|
} catch (_) {
|
|
4758
5279
|
}
|
|
4759
5280
|
this.reapplyElementTransforms();
|
|
@@ -4800,7 +5321,7 @@
|
|
|
4800
5321
|
});
|
|
4801
5322
|
}
|
|
4802
5323
|
refreshSelection() {
|
|
4803
|
-
var
|
|
5324
|
+
var _a2, _b2, _c2, _d2;
|
|
4804
5325
|
const tpl = this.printTemplate;
|
|
4805
5326
|
if (!tpl) {
|
|
4806
5327
|
setSelection({ count: 0, ids: [], elements: [] });
|
|
@@ -4808,15 +5329,15 @@
|
|
|
4808
5329
|
}
|
|
4809
5330
|
let els = [];
|
|
4810
5331
|
try {
|
|
4811
|
-
els = ((
|
|
5332
|
+
els = ((_a2 = tpl.getSelectEls) == null ? void 0 : _a2.call(tpl)) ?? [];
|
|
4812
5333
|
} catch {
|
|
4813
5334
|
}
|
|
4814
5335
|
if (!els.length) {
|
|
4815
|
-
els = ((
|
|
4816
|
-
var
|
|
5336
|
+
els = ((_d2 = (_c2 = (_b2 = tpl.editingPanel) == null ? void 0 : _b2.printElements) == null ? void 0 : _c2.filter) == null ? void 0 : _d2.call(_c2, (e) => {
|
|
5337
|
+
var _a3, _b3, _c3, _d3;
|
|
4817
5338
|
if (e == null ? void 0 : e.selected) return true;
|
|
4818
5339
|
try {
|
|
4819
|
-
return !!((
|
|
5340
|
+
return !!((_b3 = (_a3 = e == null ? void 0 : e.designTarget) == null ? void 0 : _a3.hasClass) == null ? void 0 : _b3.call(_a3, "hiprint-printElement-selected")) || !!((_d3 = (_c3 = e == null ? void 0 : e.designTarget) == null ? void 0 : _c3.hasClass) == null ? void 0 : _d3.call(_c3, "selected"));
|
|
4820
5341
|
} catch {
|
|
4821
5342
|
return false;
|
|
4822
5343
|
}
|
|
@@ -4830,25 +5351,25 @@
|
|
|
4830
5351
|
}
|
|
4831
5352
|
/** Select a print element from auxiliary panels (page structure, etc.). */
|
|
4832
5353
|
selectPrintElement(item) {
|
|
4833
|
-
var
|
|
5354
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g;
|
|
4834
5355
|
const tpl = this.printTemplate;
|
|
4835
5356
|
if (!tpl || !item) return;
|
|
4836
5357
|
const $ = typeof window !== "undefined" ? window.$ || window.jQuery : null;
|
|
4837
5358
|
const dt = $ == null ? void 0 : $(item.designTarget);
|
|
4838
5359
|
if ($ && (dt == null ? void 0 : dt.length)) {
|
|
4839
|
-
(
|
|
5360
|
+
(_b2 = (_a2 = tpl.editingPanel) == null ? void 0 : _a2.printElements) == null ? void 0 : _b2.forEach((el) => {
|
|
4840
5361
|
if (el === item) return;
|
|
4841
5362
|
const target = $(el.designTarget);
|
|
4842
5363
|
if (!(target == null ? void 0 : target.length)) return;
|
|
4843
5364
|
target.children("div[panelindex]").removeClass("selected").css({ display: "none" });
|
|
4844
5365
|
});
|
|
4845
|
-
const type = String(((
|
|
5366
|
+
const type = String(((_c2 = item.printElementType) == null ? void 0 : _c2.type) || "");
|
|
4846
5367
|
if (type.includes("table")) {
|
|
4847
5368
|
dt.find("tr:first td:first").trigger("click");
|
|
4848
5369
|
} else {
|
|
4849
5370
|
dt.children("div[panelindex]").addClass("selected").css({ display: "block" });
|
|
4850
5371
|
try {
|
|
4851
|
-
(_f = (_e = (
|
|
5372
|
+
(_f = (_e = (_d2 = dt.data("hidraggable")) == null ? void 0 : _d2.options) == null ? void 0 : _e.onBeforeSelectAllDrag) == null ? void 0 : _f.call(dt[0], {});
|
|
4852
5373
|
} catch {
|
|
4853
5374
|
}
|
|
4854
5375
|
}
|
|
@@ -4871,10 +5392,10 @@
|
|
|
4871
5392
|
const $ = typeof window !== "undefined" ? window.$ || window.jQuery : null;
|
|
4872
5393
|
if (!$) return;
|
|
4873
5394
|
items.forEach((item) => {
|
|
4874
|
-
var
|
|
5395
|
+
var _a2, _b2, _c2, _d2;
|
|
4875
5396
|
const dt = $(item.designTarget);
|
|
4876
5397
|
if (!(dt == null ? void 0 : dt.length)) return;
|
|
4877
|
-
const type = String(((
|
|
5398
|
+
const type = String(((_a2 = item.printElementType) == null ? void 0 : _a2.type) || "");
|
|
4878
5399
|
if (type.includes("table")) {
|
|
4879
5400
|
dt.find("tr:first td:first").trigger("click");
|
|
4880
5401
|
return;
|
|
@@ -4882,7 +5403,7 @@
|
|
|
4882
5403
|
dt.children("div[panelindex]").addClass("selected").css({ display: "block" });
|
|
4883
5404
|
try {
|
|
4884
5405
|
const dom = dt[0];
|
|
4885
|
-
(
|
|
5406
|
+
(_d2 = (_c2 = (_b2 = dt.data("hidraggable")) == null ? void 0 : _b2.options) == null ? void 0 : _c2.onBeforeSelectAllDrag) == null ? void 0 : _d2.call(dom, {});
|
|
4886
5407
|
} catch {
|
|
4887
5408
|
}
|
|
4888
5409
|
});
|
|
@@ -4896,9 +5417,9 @@
|
|
|
4896
5417
|
// Persistence / IO
|
|
4897
5418
|
// -------------------------------------------------------------------------
|
|
4898
5419
|
getTemplateJson() {
|
|
4899
|
-
var
|
|
5420
|
+
var _a2, _b2;
|
|
4900
5421
|
try {
|
|
4901
|
-
return ((
|
|
5422
|
+
return ((_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.getJson) == null ? void 0 : _b2.call(_a2)) ?? null;
|
|
4902
5423
|
} catch {
|
|
4903
5424
|
return null;
|
|
4904
5425
|
}
|
|
@@ -4907,11 +5428,11 @@
|
|
|
4907
5428
|
return `tpl:${this.options.templateKey || "default"}`;
|
|
4908
5429
|
}
|
|
4909
5430
|
save() {
|
|
4910
|
-
var
|
|
5431
|
+
var _a2, _b2;
|
|
4911
5432
|
const json = this.getTemplateJson();
|
|
4912
5433
|
if (!json) return;
|
|
4913
5434
|
const key = this.options.templateKey || "default";
|
|
4914
|
-
const blocked = ((
|
|
5435
|
+
const blocked = ((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onSave) == null ? void 0 : _b2.call(_a2, key, json)) === false;
|
|
4915
5436
|
if (blocked) return;
|
|
4916
5437
|
writeJSON(this.templateStorageKey(), json);
|
|
4917
5438
|
}
|
|
@@ -4924,9 +5445,9 @@
|
|
|
4924
5445
|
return openJsonEditorModal(options);
|
|
4925
5446
|
}
|
|
4926
5447
|
async edit() {
|
|
4927
|
-
var
|
|
5448
|
+
var _a2, _b2;
|
|
4928
5449
|
const json = this.getTemplateJson();
|
|
4929
|
-
if (((
|
|
5450
|
+
if (((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onEdit) == null ? void 0 : _b2.call(_a2, json)) === false) return;
|
|
4930
5451
|
try {
|
|
4931
5452
|
const next = await this.openJsonEditor({
|
|
4932
5453
|
title: translate("designer.editTemplate"),
|
|
@@ -4946,8 +5467,8 @@
|
|
|
4946
5467
|
}
|
|
4947
5468
|
}
|
|
4948
5469
|
async editData() {
|
|
4949
|
-
var
|
|
4950
|
-
if (((
|
|
5470
|
+
var _a2, _b2, _c2;
|
|
5471
|
+
if (((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onEditData) == null ? void 0 : _b2.call(_a2, this.printData)) === false) return;
|
|
4951
5472
|
try {
|
|
4952
5473
|
const schema = extractTemplateFields(this.getTemplateJson());
|
|
4953
5474
|
const host = this.printDataEditor;
|
|
@@ -4972,7 +5493,7 @@
|
|
|
4972
5493
|
});
|
|
4973
5494
|
if (next == null) return;
|
|
4974
5495
|
this.setPrintData(next);
|
|
4975
|
-
(
|
|
5496
|
+
(_c2 = this.onPrintDataChange) == null ? void 0 : _c2.call(this, next);
|
|
4976
5497
|
} catch (e) {
|
|
4977
5498
|
console.error("[vue3-print-designer] edit print data failed", e);
|
|
4978
5499
|
}
|
|
@@ -4997,8 +5518,8 @@
|
|
|
4997
5518
|
input.type = "file";
|
|
4998
5519
|
input.accept = ".json,application/json";
|
|
4999
5520
|
input.onchange = () => {
|
|
5000
|
-
var
|
|
5001
|
-
const file = (
|
|
5521
|
+
var _a2;
|
|
5522
|
+
const file = (_a2 = input.files) == null ? void 0 : _a2[0];
|
|
5002
5523
|
if (!file) return;
|
|
5003
5524
|
const reader = new FileReader();
|
|
5004
5525
|
reader.onload = () => {
|
|
@@ -5015,15 +5536,15 @@
|
|
|
5015
5536
|
}
|
|
5016
5537
|
/** Import onto existing paper(s) without creating extra panels. */
|
|
5017
5538
|
applyImportTemplateJson(json) {
|
|
5018
|
-
var
|
|
5539
|
+
var _a2, _b2, _c2, _d2, _e;
|
|
5019
5540
|
const tpl = this.printTemplate;
|
|
5020
5541
|
const currentJson = this.getTemplateJson();
|
|
5021
|
-
if (!(tpl == null ? void 0 : tpl.update) || !((
|
|
5542
|
+
if (!(tpl == null ? void 0 : tpl.update) || !((_a2 = currentJson == null ? void 0 : currentJson.panels) == null ? void 0 : _a2.length)) {
|
|
5022
5543
|
this.applyTemplateJson(json);
|
|
5023
5544
|
return;
|
|
5024
5545
|
}
|
|
5025
5546
|
const merged = mergeImportOntoCurrentPanels(currentJson, json);
|
|
5026
|
-
const activeIndex = ((
|
|
5547
|
+
const activeIndex = ((_b2 = tpl.editingPanel) == null ? void 0 : _b2.index) ?? ((_d2 = (_c2 = tpl.printPanels) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.index) ?? 0;
|
|
5027
5548
|
try {
|
|
5028
5549
|
tpl.update(merged, activeIndex);
|
|
5029
5550
|
} catch (e) {
|
|
@@ -5038,33 +5559,53 @@
|
|
|
5038
5559
|
if (nextJson) (_e = this.onTemplateChange) == null ? void 0 : _e.call(this, nextJson);
|
|
5039
5560
|
}
|
|
5040
5561
|
applyTemplateJson(json) {
|
|
5041
|
-
var
|
|
5562
|
+
var _a2;
|
|
5042
5563
|
this.newDesigner(
|
|
5043
5564
|
{ template: json, history: true, dataMode: 1 },
|
|
5044
5565
|
this.options.designOptions || {}
|
|
5045
5566
|
);
|
|
5046
|
-
(
|
|
5567
|
+
(_a2 = this.onTemplateChange) == null ? void 0 : _a2.call(this, json);
|
|
5047
5568
|
}
|
|
5048
5569
|
getPrinterList() {
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5570
|
+
return getPrintClient().getPrinterList();
|
|
5571
|
+
}
|
|
5572
|
+
getPrintClientStatus() {
|
|
5573
|
+
return getPrintClient().getStatus();
|
|
5574
|
+
}
|
|
5575
|
+
/**
|
|
5576
|
+
* Browser-side batch print. Combines records into a single print job —
|
|
5577
|
+
* works without electron-hiprint. `printDataList` can be a single
|
|
5578
|
+
* object or an array; each record can also be printed multiple times
|
|
5579
|
+
* via `options.copies`.
|
|
5580
|
+
*/
|
|
5581
|
+
async batchPrint(printDataList, options) {
|
|
5582
|
+
if (!this.printTemplate) {
|
|
5583
|
+
throw new Error("[print-designer] No active print template.");
|
|
5584
|
+
}
|
|
5585
|
+
const data2 = printDataList ?? this.printData ?? {};
|
|
5586
|
+
const list = Array.isArray(data2) ? data2 : [data2];
|
|
5587
|
+
await this.plugins.run("beforePrint", this.printTemplate, this);
|
|
5588
|
+
await batchPrint(this.printTemplate, list, options);
|
|
5589
|
+
}
|
|
5590
|
+
async print2(printData, options) {
|
|
5591
|
+
const data2 = printData ?? this.printData;
|
|
5592
|
+
if (!this.printTemplate) {
|
|
5593
|
+
throw new Error("[print-designer] No active print template.");
|
|
5054
5594
|
}
|
|
5595
|
+
return getPrintClient().printByInstance(this.printTemplate, data2, options);
|
|
5055
5596
|
}
|
|
5056
5597
|
// -------------------------------------------------------------------------
|
|
5057
5598
|
// Zoom / view-port helpers
|
|
5058
5599
|
// -------------------------------------------------------------------------
|
|
5059
5600
|
setZoom(value) {
|
|
5060
|
-
var
|
|
5601
|
+
var _a2, _b2, _c2, _d2;
|
|
5061
5602
|
const scale = Math.max(ZOOM_MIN, Math.min(ZOOM_MAX, Number.isFinite(value) ? value : 1));
|
|
5062
5603
|
setZoom(scale);
|
|
5063
5604
|
try {
|
|
5064
|
-
(
|
|
5605
|
+
(_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.zoom) == null ? void 0 : _b2.call(_a2, scale);
|
|
5065
5606
|
} catch (_) {
|
|
5066
5607
|
}
|
|
5067
|
-
(
|
|
5608
|
+
(_d2 = (_c2 = this.ruler) == null ? void 0 : _c2.redraw) == null ? void 0 : _d2.call(_c2);
|
|
5068
5609
|
}
|
|
5069
5610
|
getZoom() {
|
|
5070
5611
|
const scale = this.readTemplateScale();
|
|
@@ -5086,10 +5627,10 @@
|
|
|
5086
5627
|
return this.getZoom() > ZOOM_MIN + 1e-3;
|
|
5087
5628
|
}
|
|
5088
5629
|
adaptToSize() {
|
|
5089
|
-
var
|
|
5630
|
+
var _a2;
|
|
5090
5631
|
if (typeof window === "undefined") return;
|
|
5091
5632
|
const host = document.getElementById(DESIGN_CONTAINER_ID);
|
|
5092
|
-
const paper = (
|
|
5633
|
+
const paper = (_a2 = host == null ? void 0 : host.querySelector) == null ? void 0 : _a2.call(host, ".hiprint-printPanel, .hiprint-printPaper");
|
|
5093
5634
|
if (!host || !paper) return;
|
|
5094
5635
|
const hostRect = host.getBoundingClientRect();
|
|
5095
5636
|
const zoom = Math.max(ZOOM_MIN, this.getZoom());
|
|
@@ -5108,24 +5649,24 @@
|
|
|
5108
5649
|
return [...this.getPanelElements()];
|
|
5109
5650
|
}
|
|
5110
5651
|
getSelectedElements() {
|
|
5111
|
-
var
|
|
5652
|
+
var _a2;
|
|
5112
5653
|
const tpl = this.printTemplate;
|
|
5113
5654
|
if (!tpl) return [];
|
|
5114
5655
|
let els = [];
|
|
5115
5656
|
try {
|
|
5116
|
-
els = ((
|
|
5657
|
+
els = ((_a2 = tpl.getSelectEls) == null ? void 0 : _a2.call(tpl)) ?? [];
|
|
5117
5658
|
} catch {
|
|
5118
5659
|
}
|
|
5119
5660
|
if (!els.length) els = this.state.selection.elements;
|
|
5120
5661
|
return els.filter(Boolean);
|
|
5121
5662
|
}
|
|
5122
5663
|
getPanelElements() {
|
|
5123
|
-
var
|
|
5124
|
-
return ((
|
|
5664
|
+
var _a2, _b2;
|
|
5665
|
+
return ((_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel) == null ? void 0 : _b2.printElements) ?? [];
|
|
5125
5666
|
}
|
|
5126
5667
|
getExplicitZIndex(el) {
|
|
5127
|
-
var
|
|
5128
|
-
const raw = (
|
|
5668
|
+
var _a2;
|
|
5669
|
+
const raw = (_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.zIndex;
|
|
5129
5670
|
if (raw != null && raw !== "" && Number.isFinite(Number(raw))) return Number(raw);
|
|
5130
5671
|
return null;
|
|
5131
5672
|
}
|
|
@@ -5133,7 +5674,7 @@
|
|
|
5133
5674
|
this.updateElementOption(el, "zIndex", zIndex, true);
|
|
5134
5675
|
}
|
|
5135
5676
|
updateElementOption(el, name, value, silent = true) {
|
|
5136
|
-
var
|
|
5677
|
+
var _a2;
|
|
5137
5678
|
try {
|
|
5138
5679
|
if (typeof (el == null ? void 0 : el.updateOption) === "function") {
|
|
5139
5680
|
el.updateOption(name, value, silent);
|
|
@@ -5143,34 +5684,34 @@
|
|
|
5143
5684
|
}
|
|
5144
5685
|
try {
|
|
5145
5686
|
el.options[name] = value;
|
|
5146
|
-
(
|
|
5687
|
+
(_a2 = el.updateDesignViewFromOptions) == null ? void 0 : _a2.call(el);
|
|
5147
5688
|
return true;
|
|
5148
5689
|
} catch {
|
|
5149
5690
|
}
|
|
5150
5691
|
return false;
|
|
5151
5692
|
}
|
|
5152
5693
|
getElementFontSize(el) {
|
|
5153
|
-
var
|
|
5154
|
-
const raw = (
|
|
5694
|
+
var _a2, _b2;
|
|
5695
|
+
const raw = (_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.fontSize;
|
|
5155
5696
|
const size = Number(raw);
|
|
5156
5697
|
if (Number.isFinite(size) && size > 0) return size;
|
|
5157
|
-
const typeDefault = Number((
|
|
5698
|
+
const typeDefault = Number((_b2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _b2.fontSize);
|
|
5158
5699
|
return Number.isFinite(typeDefault) && typeDefault > 0 ? typeDefault : 12;
|
|
5159
5700
|
}
|
|
5160
5701
|
resolveElementTid(el) {
|
|
5161
|
-
var
|
|
5162
|
-
const tid = ((
|
|
5702
|
+
var _a2, _b2;
|
|
5703
|
+
const tid = ((_a2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _a2.tid) ?? (el == null ? void 0 : el.tid);
|
|
5163
5704
|
if (tid) return String(tid);
|
|
5164
|
-
const type = String(((
|
|
5705
|
+
const type = String(((_b2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _b2.type) || "");
|
|
5165
5706
|
if (!type) return null;
|
|
5166
5707
|
return `defaultModule.${type}`;
|
|
5167
5708
|
}
|
|
5168
5709
|
serializeElement(el) {
|
|
5169
|
-
var
|
|
5710
|
+
var _a2, _b2;
|
|
5170
5711
|
if (!el) return null;
|
|
5171
5712
|
try {
|
|
5172
5713
|
const tid = this.resolveElementTid(el);
|
|
5173
|
-
const optionsSource = ((
|
|
5714
|
+
const optionsSource = ((_b2 = (_a2 = el.options) == null ? void 0 : _a2.getPrintElementOptionEntity) == null ? void 0 : _b2.call(_a2)) ?? el.options ?? {};
|
|
5174
5715
|
const options = JSON.parse(JSON.stringify(optionsSource));
|
|
5175
5716
|
const printElementType = el.printElementType ? JSON.parse(JSON.stringify(el.printElementType)) : void 0;
|
|
5176
5717
|
if (!tid && !(printElementType == null ? void 0 : printElementType.type)) return null;
|
|
@@ -5187,15 +5728,15 @@
|
|
|
5187
5728
|
return copy;
|
|
5188
5729
|
}
|
|
5189
5730
|
insertElementEntity(entity, initSizeByHtml = false) {
|
|
5190
|
-
var
|
|
5191
|
-
const panel = (
|
|
5731
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
|
|
5732
|
+
const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
|
|
5192
5733
|
const tpl = this.printTemplate;
|
|
5193
|
-
if (!panel || !(entity == null ? void 0 : entity.tid) && !((
|
|
5734
|
+
if (!panel || !(entity == null ? void 0 : entity.tid) && !((_b2 = entity == null ? void 0 : entity.printElementType) == null ? void 0 : _b2.type)) return null;
|
|
5194
5735
|
try {
|
|
5195
|
-
const type = (
|
|
5736
|
+
const type = (_c2 = panel.getPrintElementTypeByEntity) == null ? void 0 : _c2.call(panel, entity);
|
|
5196
5737
|
if (!(type == null ? void 0 : type.createPrintElement)) return null;
|
|
5197
5738
|
const el = type.createPrintElement(entity.options);
|
|
5198
|
-
(
|
|
5739
|
+
(_d2 = el.setTemplateId) == null ? void 0 : _d2.call(el, tpl.id ?? tpl.templateId);
|
|
5199
5740
|
(_e = el.setPanel) == null ? void 0 : _e.call(el, panel);
|
|
5200
5741
|
(_f = panel.appendDesignPrintElement) == null ? void 0 : _f.call(panel, panel.designPaper, el, initSizeByHtml);
|
|
5201
5742
|
panel.printElements.push(el);
|
|
@@ -5211,7 +5752,7 @@
|
|
|
5211
5752
|
}
|
|
5212
5753
|
/** Insert a new canvas element by hiprint `tid` (e.g. `defaultModule.text`). */
|
|
5213
5754
|
addElementByTid(tid, options = {}) {
|
|
5214
|
-
var
|
|
5755
|
+
var _a2;
|
|
5215
5756
|
const left = Number.isFinite(options.left) ? Number(options.left) : 60;
|
|
5216
5757
|
const top = Number.isFinite(options.top) ? Number(options.top) : 60;
|
|
5217
5758
|
const el = this.insertElementEntity({ tid, options: { left, top } }, true);
|
|
@@ -5219,20 +5760,20 @@
|
|
|
5219
5760
|
this.markTemplateChanged("新增元素");
|
|
5220
5761
|
this.selectPrintElement(el);
|
|
5221
5762
|
const json = this.getTemplateJson();
|
|
5222
|
-
if (json) (
|
|
5763
|
+
if (json) (_a2 = this.onTemplateChange) == null ? void 0 : _a2.call(this, json);
|
|
5223
5764
|
return el;
|
|
5224
5765
|
}
|
|
5225
5766
|
/** Clone a live print element using hiprint's native clone path. */
|
|
5226
5767
|
duplicateElement(el, delta = 10) {
|
|
5227
|
-
var
|
|
5228
|
-
const panel = (
|
|
5768
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g;
|
|
5769
|
+
const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
|
|
5229
5770
|
const tpl = this.printTemplate;
|
|
5230
5771
|
if (!panel || !tpl || !el) return null;
|
|
5231
5772
|
try {
|
|
5232
5773
|
let copy = null;
|
|
5233
5774
|
if (typeof el.clone === "function") {
|
|
5234
5775
|
copy = el.clone();
|
|
5235
|
-
} else if ((
|
|
5776
|
+
} else if ((_b2 = el.printElementType) == null ? void 0 : _b2.createPrintElement) {
|
|
5236
5777
|
copy = el.printElementType.createPrintElement();
|
|
5237
5778
|
Object.keys(el.options || {}).forEach((key) => {
|
|
5238
5779
|
copy.options[key] = el.options[key];
|
|
@@ -5245,8 +5786,8 @@
|
|
|
5245
5786
|
else copy.options.left = left;
|
|
5246
5787
|
if (typeof copy.options.setTop === "function") copy.options.setTop(top);
|
|
5247
5788
|
else copy.options.top = top;
|
|
5248
|
-
(
|
|
5249
|
-
(
|
|
5789
|
+
(_c2 = copy.setTemplateId) == null ? void 0 : _c2.call(copy, tpl.id ?? tpl.templateId);
|
|
5790
|
+
(_d2 = copy.setPanel) == null ? void 0 : _d2.call(copy, panel);
|
|
5250
5791
|
(_e = panel.appendDesignPrintElement) == null ? void 0 : _e.call(panel, panel.designPaper, copy, false);
|
|
5251
5792
|
panel.printElements.push(copy);
|
|
5252
5793
|
(_f = copy.design) == null ? void 0 : _f.call(copy, void 0, panel.designPaper);
|
|
@@ -5260,15 +5801,15 @@
|
|
|
5260
5801
|
}
|
|
5261
5802
|
}
|
|
5262
5803
|
setElementDraggable(el, draggable) {
|
|
5263
|
-
var
|
|
5804
|
+
var _a2, _b2, _c2, _d2;
|
|
5264
5805
|
if (!(el == null ? void 0 : el.options)) return;
|
|
5265
5806
|
el.options.draggable = draggable;
|
|
5266
5807
|
try {
|
|
5267
|
-
(
|
|
5808
|
+
(_b2 = (_a2 = el.designTarget) == null ? void 0 : _a2.hidraggable) == null ? void 0 : _b2.call(_a2, "update", { draggable });
|
|
5268
5809
|
} catch {
|
|
5269
5810
|
}
|
|
5270
5811
|
try {
|
|
5271
|
-
(
|
|
5812
|
+
(_d2 = (_c2 = el.designTarget) == null ? void 0 : _c2.hireizeable) == null ? void 0 : _d2.call(_c2, "update", { draggable });
|
|
5272
5813
|
} catch {
|
|
5273
5814
|
}
|
|
5274
5815
|
}
|
|
@@ -5289,13 +5830,13 @@
|
|
|
5289
5830
|
];
|
|
5290
5831
|
}
|
|
5291
5832
|
syncPanelElementOrder(ordered) {
|
|
5292
|
-
var
|
|
5293
|
-
const panel = (
|
|
5833
|
+
var _a2, _b2;
|
|
5834
|
+
const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
|
|
5294
5835
|
if (!panel) return;
|
|
5295
5836
|
panel.printElements = ordered;
|
|
5296
5837
|
try {
|
|
5297
5838
|
const $ = window.jQuery || window.$;
|
|
5298
|
-
const container = ((
|
|
5839
|
+
const container = ((_b2 = panel.designPaper) == null ? void 0 : _b2.target) ?? panel.target;
|
|
5299
5840
|
if ($ && (container == null ? void 0 : container.length)) {
|
|
5300
5841
|
ordered.forEach((el) => {
|
|
5301
5842
|
if (el == null ? void 0 : el.designTarget) $(el.designTarget).appendTo(container);
|
|
@@ -5305,37 +5846,37 @@
|
|
|
5305
5846
|
}
|
|
5306
5847
|
}
|
|
5307
5848
|
getPanelSizePt(panel) {
|
|
5308
|
-
var
|
|
5849
|
+
var _a2;
|
|
5309
5850
|
const hinnn = window.hinnn;
|
|
5310
5851
|
const mmW = Number((panel == null ? void 0 : panel.width) ?? (panel == null ? void 0 : panel.mmwidth) ?? 0);
|
|
5311
5852
|
const mmH = Number((panel == null ? void 0 : panel.height) ?? (panel == null ? void 0 : panel.mmheight) ?? 0);
|
|
5312
|
-
if ((
|
|
5853
|
+
if ((_a2 = hinnn == null ? void 0 : hinnn.mm) == null ? void 0 : _a2.toPt) {
|
|
5313
5854
|
return { width: hinnn.mm.toPt(mmW), height: hinnn.mm.toPt(mmH) };
|
|
5314
5855
|
}
|
|
5315
5856
|
return { width: mmW, height: mmH };
|
|
5316
5857
|
}
|
|
5317
5858
|
getElementRect(el) {
|
|
5318
|
-
var
|
|
5859
|
+
var _a2, _b2, _c2, _d2;
|
|
5319
5860
|
const opts = el == null ? void 0 : el.options;
|
|
5320
5861
|
if (!opts) return null;
|
|
5321
|
-
const left = Number(((
|
|
5322
|
-
const top = Number(((
|
|
5323
|
-
const width = Number(((
|
|
5324
|
-
const height = Number(((
|
|
5862
|
+
const left = Number(((_a2 = opts.getLeft) == null ? void 0 : _a2.call(opts)) ?? opts.left ?? 0);
|
|
5863
|
+
const top = Number(((_b2 = opts.getTop) == null ? void 0 : _b2.call(opts)) ?? opts.top ?? 0);
|
|
5864
|
+
const width = Number(((_c2 = opts.getWidth) == null ? void 0 : _c2.call(opts)) ?? opts.width ?? 0);
|
|
5865
|
+
const height = Number(((_d2 = opts.getHeight) == null ? void 0 : _d2.call(opts)) ?? opts.height ?? 0);
|
|
5325
5866
|
return { el, left, top, width, height, right: left + width, bottom: top + height };
|
|
5326
5867
|
}
|
|
5327
5868
|
applyElementPosition(el, left, top) {
|
|
5328
|
-
var
|
|
5869
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
|
|
5329
5870
|
const opts = el == null ? void 0 : el.options;
|
|
5330
5871
|
if (!opts) return;
|
|
5331
|
-
const width = Number(((
|
|
5332
|
-
const height = Number(((
|
|
5872
|
+
const width = Number(((_a2 = opts.getWidth) == null ? void 0 : _a2.call(opts)) ?? opts.width ?? 0);
|
|
5873
|
+
const height = Number(((_b2 = opts.getHeight) == null ? void 0 : _b2.call(opts)) ?? opts.height ?? 0);
|
|
5333
5874
|
try {
|
|
5334
5875
|
if (typeof el.updateSizeAndPositionOptions === "function") {
|
|
5335
5876
|
el.updateSizeAndPositionOptions(left, top, width, height);
|
|
5336
5877
|
} else {
|
|
5337
|
-
(
|
|
5338
|
-
(
|
|
5878
|
+
(_c2 = opts.setLeft) == null ? void 0 : _c2.call(opts, left);
|
|
5879
|
+
(_d2 = opts.setTop) == null ? void 0 : _d2.call(opts, top);
|
|
5339
5880
|
(_e = opts.copyDesignTopFromTop) == null ? void 0 : _e.call(opts);
|
|
5340
5881
|
}
|
|
5341
5882
|
} catch {
|
|
@@ -5351,14 +5892,14 @@
|
|
|
5351
5892
|
}
|
|
5352
5893
|
}
|
|
5353
5894
|
markTemplateChanged(label = HISTORY_PARAM) {
|
|
5354
|
-
var
|
|
5895
|
+
var _a2, _b2;
|
|
5355
5896
|
const tpl = this.printTemplate;
|
|
5356
5897
|
if (!tpl) return;
|
|
5357
5898
|
try {
|
|
5358
|
-
const lib = (
|
|
5899
|
+
const lib = (hiprint == null ? void 0 : hiprint.instance) ?? ((_a2 = window.HiPrintlib) == null ? void 0 : _a2.instance);
|
|
5359
5900
|
if (lib) lib.changed = true;
|
|
5360
5901
|
const tplId = tpl.id ?? tpl.templateId;
|
|
5361
|
-
const bus = (
|
|
5902
|
+
const bus = (_b2 = window.hinnn) == null ? void 0 : _b2.event;
|
|
5362
5903
|
if (bus && tplId != null) bus.trigger(`hiprintTemplateDataChanged_${tplId}`, label);
|
|
5363
5904
|
} catch {
|
|
5364
5905
|
}
|
|
@@ -5366,7 +5907,7 @@
|
|
|
5366
5907
|
this.history.refreshFromTemplate();
|
|
5367
5908
|
}
|
|
5368
5909
|
align(side) {
|
|
5369
|
-
var
|
|
5910
|
+
var _a2;
|
|
5370
5911
|
const tpl = this.printTemplate;
|
|
5371
5912
|
if (!tpl) return;
|
|
5372
5913
|
const rects = this.getSelectedElements().map((el) => this.getElementRect(el)).filter(Boolean);
|
|
@@ -5376,7 +5917,7 @@
|
|
|
5376
5917
|
let refRight;
|
|
5377
5918
|
let refBottom;
|
|
5378
5919
|
if (rects.length === 1) {
|
|
5379
|
-
const panel = tpl.editingPanel ?? ((
|
|
5920
|
+
const panel = tpl.editingPanel ?? ((_a2 = rects[0].el) == null ? void 0 : _a2.panel);
|
|
5380
5921
|
const { width, height } = this.getPanelSizePt(panel);
|
|
5381
5922
|
refLeft = 0;
|
|
5382
5923
|
refTop = 0;
|
|
@@ -5422,9 +5963,9 @@
|
|
|
5422
5963
|
callOnSelection(method, ...args) {
|
|
5423
5964
|
const els = this.state.selection.elements;
|
|
5424
5965
|
els.forEach((el) => {
|
|
5425
|
-
var
|
|
5966
|
+
var _a2;
|
|
5426
5967
|
try {
|
|
5427
|
-
(
|
|
5968
|
+
(_a2 = el == null ? void 0 : el[method]) == null ? void 0 : _a2.call(el, ...args);
|
|
5428
5969
|
} catch (_) {
|
|
5429
5970
|
}
|
|
5430
5971
|
});
|
|
@@ -5489,15 +6030,15 @@
|
|
|
5489
6030
|
isSelectionLocked() {
|
|
5490
6031
|
const selected = this.getSelectedElements();
|
|
5491
6032
|
return selected.length > 0 && selected.every((el) => {
|
|
5492
|
-
var
|
|
5493
|
-
return ((
|
|
6033
|
+
var _a2;
|
|
6034
|
+
return ((_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.draggable) === false;
|
|
5494
6035
|
});
|
|
5495
6036
|
}
|
|
5496
6037
|
isSelectionUnlocked() {
|
|
5497
6038
|
const selected = this.getSelectedElements();
|
|
5498
6039
|
return selected.length > 0 && selected.every((el) => {
|
|
5499
|
-
var
|
|
5500
|
-
return ((
|
|
6040
|
+
var _a2;
|
|
6041
|
+
return ((_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.draggable) !== false;
|
|
5501
6042
|
});
|
|
5502
6043
|
}
|
|
5503
6044
|
setLock(locked) {
|
|
@@ -5548,17 +6089,17 @@
|
|
|
5548
6089
|
designerStore.uiPulse += 1;
|
|
5549
6090
|
}
|
|
5550
6091
|
delete() {
|
|
5551
|
-
var
|
|
6092
|
+
var _a2;
|
|
5552
6093
|
const selected = this.getSelectedElements();
|
|
5553
|
-
const panel = (
|
|
6094
|
+
const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
|
|
5554
6095
|
if (!panel || !selected.length) return;
|
|
5555
6096
|
selected.forEach((el) => {
|
|
5556
|
-
var
|
|
6097
|
+
var _a3, _b2;
|
|
5557
6098
|
try {
|
|
5558
|
-
(
|
|
6099
|
+
(_a3 = panel.deletePrintElement) == null ? void 0 : _a3.call(panel, el);
|
|
5559
6100
|
} catch {
|
|
5560
6101
|
try {
|
|
5561
|
-
(
|
|
6102
|
+
(_b2 = el == null ? void 0 : el.delete) == null ? void 0 : _b2.call(el);
|
|
5562
6103
|
} catch {
|
|
5563
6104
|
}
|
|
5564
6105
|
}
|
|
@@ -5568,15 +6109,15 @@
|
|
|
5568
6109
|
}
|
|
5569
6110
|
/** Delete a single element from the structure panel or other auxiliary UI. */
|
|
5570
6111
|
deletePrintElement(item) {
|
|
5571
|
-
var
|
|
6112
|
+
var _a2, _b2, _c2;
|
|
5572
6113
|
if (!item) return;
|
|
5573
|
-
const panel = (
|
|
6114
|
+
const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
|
|
5574
6115
|
if (!panel) return;
|
|
5575
6116
|
try {
|
|
5576
|
-
(
|
|
6117
|
+
(_b2 = panel.deletePrintElement) == null ? void 0 : _b2.call(panel, item);
|
|
5577
6118
|
} catch {
|
|
5578
6119
|
try {
|
|
5579
|
-
(
|
|
6120
|
+
(_c2 = item == null ? void 0 : item.delete) == null ? void 0 : _c2.call(item);
|
|
5580
6121
|
} catch {
|
|
5581
6122
|
}
|
|
5582
6123
|
}
|
|
@@ -5601,14 +6142,14 @@
|
|
|
5601
6142
|
this.markTemplateChanged(HISTORY_ALIGN);
|
|
5602
6143
|
}
|
|
5603
6144
|
clearPanel() {
|
|
5604
|
-
var
|
|
5605
|
-
const panel = (
|
|
6145
|
+
var _a2;
|
|
6146
|
+
const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
|
|
5606
6147
|
if (!panel) return;
|
|
5607
6148
|
const list = (panel.printElements ?? []).slice();
|
|
5608
6149
|
list.forEach((el) => {
|
|
5609
|
-
var
|
|
6150
|
+
var _a3;
|
|
5610
6151
|
try {
|
|
5611
|
-
(
|
|
6152
|
+
(_a3 = panel.deletePrintElement) == null ? void 0 : _a3.call(panel, el);
|
|
5612
6153
|
} catch (_) {
|
|
5613
6154
|
}
|
|
5614
6155
|
});
|
|
@@ -5860,14 +6401,14 @@
|
|
|
5860
6401
|
});
|
|
5861
6402
|
}
|
|
5862
6403
|
vueDemi.onMounted(() => {
|
|
5863
|
-
var
|
|
6404
|
+
var _a2;
|
|
5864
6405
|
const scroller = opts.scrollerEl();
|
|
5865
6406
|
scrollHandler = () => schedule();
|
|
5866
6407
|
scroller == null ? void 0 : scroller.addEventListener("scroll", scrollHandler, { passive: true });
|
|
5867
6408
|
if (typeof ResizeObserver !== "undefined") {
|
|
5868
6409
|
resizeObserver = new ResizeObserver(() => schedule());
|
|
5869
6410
|
if (scroller) resizeObserver.observe(scroller);
|
|
5870
|
-
const workspace = (
|
|
6411
|
+
const workspace = (_a2 = opts.workspaceEl) == null ? void 0 : _a2.call(opts);
|
|
5871
6412
|
if (workspace) resizeObserver.observe(workspace);
|
|
5872
6413
|
const host = document.getElementById(DESIGN_CONTAINER_ID);
|
|
5873
6414
|
if (host) resizeObserver.observe(host);
|
|
@@ -7335,9 +7876,9 @@ ${lines.join("\n")}
|
|
|
7335
7876
|
const Icon = vue.defineComponent((props, { emit }) => {
|
|
7336
7877
|
const loader = vue.ref(null);
|
|
7337
7878
|
function abortLoading() {
|
|
7338
|
-
var
|
|
7879
|
+
var _a2, _b2;
|
|
7339
7880
|
if (loader.value) {
|
|
7340
|
-
(
|
|
7881
|
+
(_b2 = (_a2 = loader.value).abort) == null ? void 0 : _b2.call(_a2);
|
|
7341
7882
|
loader.value = null;
|
|
7342
7883
|
}
|
|
7343
7884
|
}
|
|
@@ -7398,11 +7939,11 @@ ${lines.join("\n")}
|
|
|
7398
7939
|
return { data: data2, classes };
|
|
7399
7940
|
}
|
|
7400
7941
|
function updateIconData() {
|
|
7401
|
-
var
|
|
7942
|
+
var _a2;
|
|
7402
7943
|
const icon = getIcon2();
|
|
7403
7944
|
if (!icon) {
|
|
7404
7945
|
iconData.value = null;
|
|
7405
|
-
} else if (icon.data !== ((
|
|
7946
|
+
} else if (icon.data !== ((_a2 = iconData.value) == null ? void 0 : _a2.data)) {
|
|
7406
7947
|
iconData.value = icon;
|
|
7407
7948
|
}
|
|
7408
7949
|
}
|
|
@@ -7552,12 +8093,12 @@ ${lines.join("\n")}
|
|
|
7552
8093
|
const _hoisted_5$a = { class: "svp-header__center" };
|
|
7553
8094
|
const _hoisted_6$6 = ["title"];
|
|
7554
8095
|
const _hoisted_7$6 = ["title"];
|
|
7555
|
-
const _hoisted_8$
|
|
7556
|
-
const _hoisted_9$
|
|
7557
|
-
const _hoisted_10$
|
|
7558
|
-
const _hoisted_11$
|
|
7559
|
-
const _hoisted_12$
|
|
7560
|
-
const _hoisted_13$
|
|
8096
|
+
const _hoisted_8$5 = ["title"];
|
|
8097
|
+
const _hoisted_9$4 = ["title"];
|
|
8098
|
+
const _hoisted_10$3 = ["title"];
|
|
8099
|
+
const _hoisted_11$2 = ["title"];
|
|
8100
|
+
const _hoisted_12$2 = ["title", "onClick"];
|
|
8101
|
+
const _hoisted_13$2 = { class: "svp-header__aside svp-header__aside--right" };
|
|
7561
8102
|
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
7562
8103
|
const _component_SvpIcon = vue.resolveComponent("SvpIcon");
|
|
7563
8104
|
return vue.openBlock(), vue.createElementBlock("header", _hoisted_1$c, [
|
|
@@ -7608,7 +8149,7 @@ ${lines.join("\n")}
|
|
|
7608
8149
|
size: 22
|
|
7609
8150
|
}, null, 8, ["icon"]),
|
|
7610
8151
|
vue.createElementVNode("span", null, vue.toDisplayString(_ctx.t("designer.exportFile")), 1)
|
|
7611
|
-
], 8, _hoisted_8$
|
|
8152
|
+
], 8, _hoisted_8$5),
|
|
7612
8153
|
vue.createElementVNode("button", {
|
|
7613
8154
|
type: "button",
|
|
7614
8155
|
class: "svp-header__menu",
|
|
@@ -7620,7 +8161,7 @@ ${lines.join("\n")}
|
|
|
7620
8161
|
size: 22
|
|
7621
8162
|
}, null, 8, ["icon"]),
|
|
7622
8163
|
vue.createElementVNode("span", null, vue.toDisplayString(_ctx.t("designer.importFile")), 1)
|
|
7623
|
-
], 8, _hoisted_9$
|
|
8164
|
+
], 8, _hoisted_9$4),
|
|
7624
8165
|
vue.createElementVNode("button", {
|
|
7625
8166
|
type: "button",
|
|
7626
8167
|
class: "svp-header__menu",
|
|
@@ -7632,7 +8173,7 @@ ${lines.join("\n")}
|
|
|
7632
8173
|
size: 22
|
|
7633
8174
|
}, null, 8, ["icon"]),
|
|
7634
8175
|
vue.createElementVNode("span", null, vue.toDisplayString(_ctx.t("designer.save")), 1)
|
|
7635
|
-
], 8, _hoisted_10$
|
|
8176
|
+
], 8, _hoisted_10$3),
|
|
7636
8177
|
vue.createElementVNode("button", {
|
|
7637
8178
|
type: "button",
|
|
7638
8179
|
class: "svp-header__menu",
|
|
@@ -7644,7 +8185,7 @@ ${lines.join("\n")}
|
|
|
7644
8185
|
size: 22
|
|
7645
8186
|
}, null, 8, ["icon"]),
|
|
7646
8187
|
vue.createElementVNode("span", null, vue.toDisplayString(_ctx.t("designer.preview")), 1)
|
|
7647
|
-
], 8, _hoisted_11$
|
|
8188
|
+
], 8, _hoisted_11$2),
|
|
7648
8189
|
_ctx.showElementBar ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
7649
8190
|
_cache[6] || (_cache[6] = vue.createElementVNode("span", {
|
|
7650
8191
|
class: "svp-header__divider",
|
|
@@ -7664,12 +8205,12 @@ ${lines.join("\n")}
|
|
|
7664
8205
|
size: 18
|
|
7665
8206
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
7666
8207
|
vue.createElementVNode("span", null, vue.toDisplayString(item.label), 1)
|
|
7667
|
-
], 8, _hoisted_12$
|
|
8208
|
+
], 8, _hoisted_12$2);
|
|
7668
8209
|
}), 128))
|
|
7669
8210
|
], 64)) : vue.createCommentVNode("", true)
|
|
7670
8211
|
])
|
|
7671
8212
|
]),
|
|
7672
|
-
vue.createElementVNode("div", _hoisted_13$
|
|
8213
|
+
vue.createElementVNode("div", _hoisted_13$2, [
|
|
7673
8214
|
vue.renderSlot(_ctx.$slots, "right")
|
|
7674
8215
|
])
|
|
7675
8216
|
]);
|
|
@@ -7713,8 +8254,8 @@ ${lines.join("\n")}
|
|
|
7713
8254
|
designerStore.lang = next;
|
|
7714
8255
|
}
|
|
7715
8256
|
function onToolbarMouseDown(e) {
|
|
7716
|
-
var
|
|
7717
|
-
if ((
|
|
8257
|
+
var _a2;
|
|
8258
|
+
if ((_a2 = e.target) == null ? void 0 : _a2.closest("button")) {
|
|
7718
8259
|
e.preventDefault();
|
|
7719
8260
|
}
|
|
7720
8261
|
}
|
|
@@ -7924,105 +8465,210 @@ ${lines.join("\n")}
|
|
|
7924
8465
|
], 32);
|
|
7925
8466
|
}
|
|
7926
8467
|
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
7927
|
-
function resolvePreviewHtml(value) {
|
|
7928
|
-
if (value == null || value === false) return "";
|
|
7929
|
-
if (typeof value === "string") return value;
|
|
7930
|
-
const any = value;
|
|
7931
|
-
if (typeof any.html === "function") {
|
|
7932
|
-
try {
|
|
7933
|
-
const html = any.html();
|
|
7934
|
-
if (typeof html === "string") return html;
|
|
7935
|
-
} catch {
|
|
7936
|
-
}
|
|
7937
|
-
}
|
|
7938
|
-
if (Array.isArray(value)) {
|
|
7939
|
-
return value.map((item) => resolvePreviewHtml(item)).join("");
|
|
7940
|
-
}
|
|
7941
|
-
if (typeof any.length === "number" && any.length > 0 && any[0] != null) {
|
|
7942
|
-
return resolvePreviewHtml(any[0]);
|
|
7943
|
-
}
|
|
7944
|
-
if (any.target != null) {
|
|
7945
|
-
return resolvePreviewHtml(any.target);
|
|
7946
|
-
}
|
|
7947
|
-
return "";
|
|
7948
|
-
}
|
|
7949
8468
|
const _sfc_main$a = vueDemi.defineComponent({
|
|
7950
8469
|
name: "SvpPreview",
|
|
7951
8470
|
props: {
|
|
7952
8471
|
options: { type: Object, default: () => ({}) }
|
|
7953
8472
|
},
|
|
7954
8473
|
setup(props, { expose }) {
|
|
8474
|
+
var _a2;
|
|
7955
8475
|
const { t } = useI18n();
|
|
7956
8476
|
const utils = useDesigner();
|
|
7957
8477
|
const visible = vueDemi.ref(false);
|
|
7958
8478
|
const html = vueDemi.ref("");
|
|
7959
|
-
const opts = vueDemi.reactive({
|
|
8479
|
+
const opts = vueDemi.reactive({
|
|
8480
|
+
showPdf: true,
|
|
8481
|
+
showImg: true,
|
|
8482
|
+
showBrowserPrint: true,
|
|
8483
|
+
showPrint2: false,
|
|
8484
|
+
showBatchPrint: true,
|
|
8485
|
+
showPrintClient: false,
|
|
8486
|
+
...props.options
|
|
8487
|
+
});
|
|
8488
|
+
const clientStatus = vueDemi.ref({ connected: false });
|
|
8489
|
+
const printers = vueDemi.ref([]);
|
|
8490
|
+
const selectedPrinter = vueDemi.ref("");
|
|
8491
|
+
const connecting = vueDemi.ref(false);
|
|
8492
|
+
const batchCopies = vueDemi.ref(Math.max(1, Math.floor(((_a2 = props.options) == null ? void 0 : _a2.defaultCopies) ?? 1)));
|
|
8493
|
+
const batchPrinting = vueDemi.ref(false);
|
|
7960
8494
|
const tpl = vueDemi.computed(() => utils.printTemplate);
|
|
7961
8495
|
const canExportPdf = vueDemi.computed(() => {
|
|
7962
|
-
var
|
|
8496
|
+
var _a3;
|
|
7963
8497
|
if (opts.showPdf === false) return false;
|
|
7964
|
-
return typeof ((
|
|
8498
|
+
return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toPdf) === "function";
|
|
7965
8499
|
});
|
|
7966
8500
|
const canExportImage = vueDemi.computed(() => {
|
|
7967
|
-
var
|
|
8501
|
+
var _a3;
|
|
7968
8502
|
if (opts.showImg === false) return false;
|
|
7969
|
-
return typeof ((
|
|
8503
|
+
return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toImage) === "function";
|
|
8504
|
+
});
|
|
8505
|
+
const canBrowserPrint = vueDemi.computed(() => {
|
|
8506
|
+
var _a3;
|
|
8507
|
+
if (opts.showBrowserPrint === false) return false;
|
|
8508
|
+
return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.print) === "function";
|
|
8509
|
+
});
|
|
8510
|
+
const canSilentPrint = vueDemi.computed(() => {
|
|
8511
|
+
var _a3;
|
|
8512
|
+
if (opts.showPrint2 === false || opts.showSilentPrint === false) return false;
|
|
8513
|
+
return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.print2) === "function";
|
|
8514
|
+
});
|
|
8515
|
+
const showPrintClientBar = vueDemi.computed(() => {
|
|
8516
|
+
if (opts.showPrintClient === true) return true;
|
|
8517
|
+
return canSilentPrint.value;
|
|
8518
|
+
});
|
|
8519
|
+
const canBatchPrint = vueDemi.computed(() => {
|
|
8520
|
+
var _a3;
|
|
8521
|
+
if (opts.showBatchPrint === false) return false;
|
|
8522
|
+
return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.getHtml) === "function";
|
|
7970
8523
|
});
|
|
7971
|
-
const
|
|
7972
|
-
|
|
7973
|
-
if (
|
|
7974
|
-
return
|
|
8524
|
+
const batchDataRows = vueDemi.computed(() => {
|
|
8525
|
+
const data2 = utils.printData;
|
|
8526
|
+
if (Array.isArray(data2)) return data2.length;
|
|
8527
|
+
return data2 == null ? 0 : 1;
|
|
7975
8528
|
});
|
|
8529
|
+
const batchTotalPages = vueDemi.computed(() => {
|
|
8530
|
+
const copies = Math.max(1, Math.floor(batchCopies.value || 1));
|
|
8531
|
+
return batchDataRows.value * copies;
|
|
8532
|
+
});
|
|
8533
|
+
const batchHintText = vueDemi.computed(() => {
|
|
8534
|
+
const template = t("designer.batchHint");
|
|
8535
|
+
return template.replace("{rows}", String(batchDataRows.value)).replace("{total}", String(batchTotalPages.value));
|
|
8536
|
+
});
|
|
8537
|
+
function formatPrinterLabel(printer) {
|
|
8538
|
+
const label = printer.displayName || printer.name;
|
|
8539
|
+
return printer.isDefault ? `${label} (${t("designer.defaultPrinter")})` : label;
|
|
8540
|
+
}
|
|
8541
|
+
function syncDefaultPrinter(list) {
|
|
8542
|
+
if (!list.length) {
|
|
8543
|
+
selectedPrinter.value = "";
|
|
8544
|
+
return;
|
|
8545
|
+
}
|
|
8546
|
+
if (selectedPrinter.value && list.some((item) => item.name === selectedPrinter.value)) {
|
|
8547
|
+
return;
|
|
8548
|
+
}
|
|
8549
|
+
const fallback = list.find((item) => item.isDefault) ?? list[0];
|
|
8550
|
+
selectedPrinter.value = (fallback == null ? void 0 : fallback.name) ?? "";
|
|
8551
|
+
}
|
|
8552
|
+
function refreshClientState() {
|
|
8553
|
+
clientStatus.value = utils.getPrintClientStatus();
|
|
8554
|
+
if (!clientStatus.value.connected) {
|
|
8555
|
+
printers.value = [];
|
|
8556
|
+
return;
|
|
8557
|
+
}
|
|
8558
|
+
printers.value = utils.getPrinterList();
|
|
8559
|
+
syncDefaultPrinter(printers.value);
|
|
8560
|
+
}
|
|
7976
8561
|
function open(content) {
|
|
7977
|
-
var
|
|
7978
|
-
const raw = content !== void 0 ? content : (
|
|
8562
|
+
var _a3, _b2;
|
|
8563
|
+
const raw = content !== void 0 ? content : (_b2 = (_a3 = tpl.value) == null ? void 0 : _a3.getHtml) == null ? void 0 : _b2.call(_a3, utils.printData);
|
|
7979
8564
|
html.value = resolvePreviewHtml(raw);
|
|
7980
8565
|
visible.value = true;
|
|
8566
|
+
refreshClientState();
|
|
7981
8567
|
utils.plugins.run("onPreview", html.value, utils).catch(() => {
|
|
7982
8568
|
});
|
|
7983
8569
|
}
|
|
7984
8570
|
function close() {
|
|
7985
8571
|
visible.value = false;
|
|
7986
8572
|
}
|
|
8573
|
+
async function toggleConnect() {
|
|
8574
|
+
if (connecting.value) return;
|
|
8575
|
+
connecting.value = true;
|
|
8576
|
+
try {
|
|
8577
|
+
if (clientStatus.value.connected) {
|
|
8578
|
+
await new Promise((resolve) => {
|
|
8579
|
+
utils.setConnect(false, () => resolve());
|
|
8580
|
+
});
|
|
8581
|
+
} else {
|
|
8582
|
+
await new Promise((resolve) => {
|
|
8583
|
+
utils.setConnect(true, () => resolve());
|
|
8584
|
+
});
|
|
8585
|
+
}
|
|
8586
|
+
refreshClientState();
|
|
8587
|
+
} finally {
|
|
8588
|
+
connecting.value = false;
|
|
8589
|
+
}
|
|
8590
|
+
}
|
|
7987
8591
|
async function onPrint() {
|
|
7988
|
-
var
|
|
8592
|
+
var _a3, _b2;
|
|
7989
8593
|
await utils.plugins.run("beforePrint", tpl.value, utils);
|
|
7990
8594
|
try {
|
|
7991
|
-
(
|
|
8595
|
+
(_b2 = (_a3 = tpl.value) == null ? void 0 : _a3.print) == null ? void 0 : _b2.call(_a3, utils.printData);
|
|
8596
|
+
} catch (e) {
|
|
8597
|
+
console.error(e);
|
|
8598
|
+
}
|
|
8599
|
+
}
|
|
8600
|
+
async function onSilentPrint() {
|
|
8601
|
+
const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "silent");
|
|
8602
|
+
if (results.some((r) => r === false)) return;
|
|
8603
|
+
try {
|
|
8604
|
+
await utils.print2(utils.printData, {
|
|
8605
|
+
printer: selectedPrinter.value,
|
|
8606
|
+
title: t("designer.silentPrint")
|
|
8607
|
+
});
|
|
7992
8608
|
} catch (e) {
|
|
7993
8609
|
console.error(e);
|
|
7994
8610
|
}
|
|
7995
8611
|
}
|
|
7996
8612
|
async function onPdf() {
|
|
7997
|
-
var
|
|
8613
|
+
var _a3;
|
|
7998
8614
|
const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "pdf");
|
|
7999
8615
|
if (results.some((r) => r === false)) return;
|
|
8000
8616
|
try {
|
|
8001
|
-
if (typeof ((
|
|
8617
|
+
if (typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toPdf) === "function") tpl.value.toPdf(utils.printData);
|
|
8002
8618
|
} catch (e) {
|
|
8003
8619
|
console.error(e);
|
|
8004
8620
|
}
|
|
8005
8621
|
}
|
|
8006
8622
|
async function onImage() {
|
|
8007
|
-
var
|
|
8623
|
+
var _a3;
|
|
8008
8624
|
const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "image");
|
|
8009
8625
|
if (results.some((r) => r === false)) return;
|
|
8010
8626
|
try {
|
|
8011
|
-
if (typeof ((
|
|
8627
|
+
if (typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toImage) === "function") tpl.value.toImage(utils.printData);
|
|
8012
8628
|
} catch (e) {
|
|
8013
8629
|
console.error(e);
|
|
8014
8630
|
}
|
|
8015
8631
|
}
|
|
8632
|
+
async function onBatchPrint() {
|
|
8633
|
+
if (batchPrinting.value) return;
|
|
8634
|
+
const data2 = utils.printData;
|
|
8635
|
+
const list = Array.isArray(data2) ? data2 : [data2];
|
|
8636
|
+
if (!list.length) return;
|
|
8637
|
+
const copies = Math.max(1, Math.floor(batchCopies.value || 1));
|
|
8638
|
+
batchPrinting.value = true;
|
|
8639
|
+
try {
|
|
8640
|
+
await utils.batchPrint(list, { copies, title: t("designer.batchPrint") });
|
|
8641
|
+
} catch (e) {
|
|
8642
|
+
console.error(e);
|
|
8643
|
+
} finally {
|
|
8644
|
+
batchPrinting.value = false;
|
|
8645
|
+
}
|
|
8646
|
+
}
|
|
8016
8647
|
expose({ open, close });
|
|
8017
8648
|
return {
|
|
8018
8649
|
t,
|
|
8019
8650
|
visible,
|
|
8020
8651
|
html,
|
|
8652
|
+
clientStatus,
|
|
8653
|
+
printers,
|
|
8654
|
+
selectedPrinter,
|
|
8655
|
+
batchCopies,
|
|
8656
|
+
batchPrinting,
|
|
8657
|
+
batchDataRows,
|
|
8658
|
+
batchTotalPages,
|
|
8659
|
+
batchHintText,
|
|
8021
8660
|
canExportPdf,
|
|
8022
8661
|
canExportImage,
|
|
8023
|
-
|
|
8662
|
+
canBrowserPrint,
|
|
8663
|
+
canSilentPrint,
|
|
8664
|
+
canBatchPrint,
|
|
8665
|
+
showPrintClientBar,
|
|
8666
|
+
formatPrinterLabel,
|
|
8024
8667
|
close,
|
|
8668
|
+
toggleConnect,
|
|
8025
8669
|
onPrint,
|
|
8670
|
+
onSilentPrint,
|
|
8671
|
+
onBatchPrint,
|
|
8026
8672
|
onPdf,
|
|
8027
8673
|
onImage
|
|
8028
8674
|
};
|
|
@@ -8037,12 +8683,28 @@ ${lines.join("\n")}
|
|
|
8037
8683
|
key: 1,
|
|
8038
8684
|
class: "svp-preview__empty"
|
|
8039
8685
|
};
|
|
8040
|
-
const _hoisted_7$4 = {
|
|
8686
|
+
const _hoisted_7$4 = {
|
|
8687
|
+
key: 0,
|
|
8688
|
+
class: "svp-preview__print-bar"
|
|
8689
|
+
};
|
|
8690
|
+
const _hoisted_8$4 = ["value"];
|
|
8691
|
+
const _hoisted_9$3 = {
|
|
8692
|
+
key: 1,
|
|
8693
|
+
class: "svp-preview__printer-empty"
|
|
8694
|
+
};
|
|
8695
|
+
const _hoisted_10$2 = {
|
|
8696
|
+
key: 1,
|
|
8697
|
+
class: "svp-preview__print-bar svp-preview__batch-bar"
|
|
8698
|
+
};
|
|
8699
|
+
const _hoisted_11$1 = { class: "svp-preview__batch-label" };
|
|
8700
|
+
const _hoisted_12$1 = { class: "svp-preview__batch-hint" };
|
|
8701
|
+
const _hoisted_13$1 = { class: "svp-dialog__footer svp-preview__footer" };
|
|
8702
|
+
const _hoisted_14$1 = ["disabled"];
|
|
8041
8703
|
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
8042
8704
|
return _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
8043
8705
|
key: 0,
|
|
8044
8706
|
class: "svp-dialog-mask",
|
|
8045
|
-
onClick: _cache[
|
|
8707
|
+
onClick: _cache[10] || (_cache[10] = vue.withModifiers((...args) => _ctx.close && _ctx.close(...args), ["self"]))
|
|
8046
8708
|
}, [
|
|
8047
8709
|
vue.createElementVNode("div", _hoisted_1$a, [
|
|
8048
8710
|
vue.createElementVNode("div", _hoisted_2$9, [
|
|
@@ -8061,29 +8723,86 @@ ${lines.join("\n")}
|
|
|
8061
8723
|
innerHTML: _ctx.html
|
|
8062
8724
|
}, null, 8, _hoisted_5$8)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$4, vue.toDisplayString(_ctx.t("panel.empty")), 1))
|
|
8063
8725
|
]),
|
|
8064
|
-
vue.
|
|
8065
|
-
|
|
8726
|
+
_ctx.showPrintClientBar ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7$4, [
|
|
8727
|
+
vue.createElementVNode("span", {
|
|
8728
|
+
class: vue.normalizeClass(["svp-preview__status", { "is-connected": _ctx.clientStatus.connected }])
|
|
8729
|
+
}, vue.toDisplayString(_ctx.clientStatus.connected ? _ctx.t("designer.printClientConnected") : _ctx.t("designer.printClientDisconnected")), 3),
|
|
8730
|
+
vue.createElementVNode("button", {
|
|
8731
|
+
type: "button",
|
|
8732
|
+
class: "svp-btn",
|
|
8733
|
+
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.toggleConnect && _ctx.toggleConnect(...args))
|
|
8734
|
+
}, vue.toDisplayString(_ctx.clientStatus.connected ? _ctx.t("designer.printClientDisconnect") : _ctx.t("designer.printClientConnect")), 1),
|
|
8735
|
+
_ctx.clientStatus.connected && _ctx.printers.length ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("select", {
|
|
8736
|
+
key: 0,
|
|
8737
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.selectedPrinter = $event),
|
|
8738
|
+
class: "svp-preview__printer-select"
|
|
8739
|
+
}, [
|
|
8740
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.printers, (printer) => {
|
|
8741
|
+
return vue.openBlock(), vue.createElementBlock("option", {
|
|
8742
|
+
key: printer.name,
|
|
8743
|
+
value: printer.name
|
|
8744
|
+
}, vue.toDisplayString(_ctx.formatPrinterLabel(printer)), 9, _hoisted_8$4);
|
|
8745
|
+
}), 128))
|
|
8746
|
+
], 512)), [
|
|
8747
|
+
[vue.vModelSelect, _ctx.selectedPrinter]
|
|
8748
|
+
]) : _ctx.clientStatus.connected ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_9$3, vue.toDisplayString(_ctx.t("designer.printClientNoPrinters")), 1)) : vue.createCommentVNode("", true)
|
|
8749
|
+
])) : vue.createCommentVNode("", true),
|
|
8750
|
+
_ctx.canBatchPrint ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_10$2, [
|
|
8751
|
+
vue.createElementVNode("label", _hoisted_11$1, [
|
|
8752
|
+
vue.createTextVNode(vue.toDisplayString(_ctx.t("designer.batchCopies")) + " ", 1),
|
|
8753
|
+
vue.withDirectives(vue.createElementVNode("input", {
|
|
8754
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.batchCopies = $event),
|
|
8755
|
+
type: "number",
|
|
8756
|
+
min: "1",
|
|
8757
|
+
max: "999",
|
|
8758
|
+
class: "svp-preview__batch-input"
|
|
8759
|
+
}, null, 512), [
|
|
8760
|
+
[
|
|
8761
|
+
vue.vModelText,
|
|
8762
|
+
_ctx.batchCopies,
|
|
8763
|
+
void 0,
|
|
8764
|
+
{ number: true }
|
|
8765
|
+
]
|
|
8766
|
+
])
|
|
8767
|
+
]),
|
|
8768
|
+
vue.createElementVNode("span", _hoisted_12$1, vue.toDisplayString(_ctx.batchHintText), 1)
|
|
8769
|
+
])) : vue.createCommentVNode("", true),
|
|
8770
|
+
vue.createElementVNode("div", _hoisted_13$1, [
|
|
8771
|
+
_ctx.canBatchPrint ? (vue.openBlock(), vue.createElementBlock("button", {
|
|
8066
8772
|
key: 0,
|
|
8067
8773
|
type: "button",
|
|
8774
|
+
class: "svp-btn is-primary",
|
|
8775
|
+
disabled: _ctx.batchPrinting,
|
|
8776
|
+
onClick: _cache[4] || (_cache[4] = (...args) => _ctx.onBatchPrint && _ctx.onBatchPrint(...args))
|
|
8777
|
+
}, vue.toDisplayString(_ctx.batchPrinting ? _ctx.t("designer.batchPrinting") : _ctx.t("designer.batchPrint")), 9, _hoisted_14$1)) : vue.createCommentVNode("", true),
|
|
8778
|
+
_ctx.canSilentPrint ? (vue.openBlock(), vue.createElementBlock("button", {
|
|
8779
|
+
key: 1,
|
|
8780
|
+
type: "button",
|
|
8068
8781
|
class: "svp-btn",
|
|
8069
|
-
onClick: _cache[
|
|
8782
|
+
onClick: _cache[5] || (_cache[5] = (...args) => _ctx.onSilentPrint && _ctx.onSilentPrint(...args))
|
|
8783
|
+
}, vue.toDisplayString(_ctx.t("designer.silentPrint")), 1)) : vue.createCommentVNode("", true),
|
|
8784
|
+
_ctx.canBrowserPrint ? (vue.openBlock(), vue.createElementBlock("button", {
|
|
8785
|
+
key: 2,
|
|
8786
|
+
type: "button",
|
|
8787
|
+
class: "svp-btn",
|
|
8788
|
+
onClick: _cache[6] || (_cache[6] = (...args) => _ctx.onPrint && _ctx.onPrint(...args))
|
|
8789
|
+
}, vue.toDisplayString(_ctx.t("designer.browserPrint")), 1)) : vue.createCommentVNode("", true),
|
|
8790
|
+
_ctx.canExportPdf ? (vue.openBlock(), vue.createElementBlock("button", {
|
|
8791
|
+
key: 3,
|
|
8792
|
+
type: "button",
|
|
8793
|
+
class: "svp-btn",
|
|
8794
|
+
onClick: _cache[7] || (_cache[7] = (...args) => _ctx.onPdf && _ctx.onPdf(...args))
|
|
8070
8795
|
}, vue.toDisplayString(_ctx.t("designer.pdf")), 1)) : vue.createCommentVNode("", true),
|
|
8071
8796
|
_ctx.canExportImage ? (vue.openBlock(), vue.createElementBlock("button", {
|
|
8072
|
-
key:
|
|
8797
|
+
key: 4,
|
|
8073
8798
|
type: "button",
|
|
8074
8799
|
class: "svp-btn",
|
|
8075
|
-
onClick: _cache[
|
|
8800
|
+
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.onImage && _ctx.onImage(...args))
|
|
8076
8801
|
}, vue.toDisplayString(_ctx.t("designer.image")), 1)) : vue.createCommentVNode("", true),
|
|
8077
|
-
_ctx.canPrint ? (vue.openBlock(), vue.createElementBlock("button", {
|
|
8078
|
-
key: 2,
|
|
8079
|
-
type: "button",
|
|
8080
|
-
class: "svp-btn is-primary",
|
|
8081
|
-
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.onPrint && _ctx.onPrint(...args))
|
|
8082
|
-
}, vue.toDisplayString(_ctx.t("designer.print")), 1)) : vue.createCommentVNode("", true),
|
|
8083
8802
|
vue.createElementVNode("button", {
|
|
8084
8803
|
type: "button",
|
|
8085
8804
|
class: "svp-btn",
|
|
8086
|
-
onClick: _cache[
|
|
8805
|
+
onClick: _cache[9] || (_cache[9] = (...args) => _ctx.close && _ctx.close(...args))
|
|
8087
8806
|
}, vue.toDisplayString(_ctx.t("designer.cancel")), 1)
|
|
8088
8807
|
])
|
|
8089
8808
|
])
|
|
@@ -8176,10 +8895,10 @@ ${lines.join("\n")}
|
|
|
8176
8895
|
if (ta && lines) lines.scrollTop = ta.scrollTop;
|
|
8177
8896
|
}
|
|
8178
8897
|
function doClear() {
|
|
8179
|
-
var
|
|
8898
|
+
var _a2;
|
|
8180
8899
|
text.value = variant.value === "template" ? JSON.stringify(EMPTY_TEMPLATE_JSON, null, 2) : "{}";
|
|
8181
8900
|
error.value = "";
|
|
8182
|
-
(
|
|
8901
|
+
(_a2 = textareaRef.value) == null ? void 0 : _a2.focus();
|
|
8183
8902
|
}
|
|
8184
8903
|
async function doCopy() {
|
|
8185
8904
|
try {
|
|
@@ -8730,25 +9449,25 @@ ${lines.join("\n")}
|
|
|
8730
9449
|
},
|
|
8731
9450
|
emits: ["update:visible", "close"],
|
|
8732
9451
|
setup(props, { emit }) {
|
|
8733
|
-
var
|
|
9452
|
+
var _a2, _b2;
|
|
8734
9453
|
const boxRef = vueDemi.ref(null);
|
|
8735
9454
|
const { t } = useI18n();
|
|
8736
9455
|
const designerUi = useDesignerUi();
|
|
8737
9456
|
const styleOverrides = vueDemi.computed(() => props.styleOptionKey ? resolvePanelDragBoxOptions(props.styleOptionKey, designerUi == null ? void 0 : designerUi.styleOption.value) : null);
|
|
8738
9457
|
const resolvedTitle = vueDemi.computed(() => {
|
|
8739
|
-
var
|
|
8740
|
-
return ((
|
|
9458
|
+
var _a3;
|
|
9459
|
+
return ((_a3 = styleOverrides.value) == null ? void 0 : _a3.title) || props.title;
|
|
8741
9460
|
});
|
|
8742
9461
|
const draggable = vueDemi.computed(() => {
|
|
8743
|
-
var
|
|
8744
|
-
return ((
|
|
9462
|
+
var _a3;
|
|
9463
|
+
return ((_a3 = styleOverrides.value) == null ? void 0 : _a3.draggable) ?? true;
|
|
8745
9464
|
});
|
|
8746
9465
|
const showFold = vueDemi.computed(() => props.foldable);
|
|
8747
9466
|
const showClose = vueDemi.computed(() => props.closable ?? !!props.panelKey);
|
|
8748
9467
|
const dragBoxOptions = vueDemi.reactive({
|
|
8749
9468
|
key: props.storageKey || void 0,
|
|
8750
|
-
layoutKey: ((
|
|
8751
|
-
layoutSpec: (
|
|
9469
|
+
layoutKey: ((_a2 = styleOverrides.value) == null ? void 0 : _a2.layoutKey) || props.layoutKey || void 0,
|
|
9470
|
+
layoutSpec: (_b2 = styleOverrides.value) == null ? void 0 : _b2.layoutSpec,
|
|
8752
9471
|
defaultX: props.defaultX,
|
|
8753
9472
|
defaultY: props.defaultY,
|
|
8754
9473
|
defaultWidth: props.width,
|
|
@@ -8765,8 +9484,8 @@ ${lines.join("\n")}
|
|
|
8765
9484
|
}, { immediate: true });
|
|
8766
9485
|
vueDemi.watch(
|
|
8767
9486
|
() => {
|
|
8768
|
-
var
|
|
8769
|
-
return (
|
|
9487
|
+
var _a3;
|
|
9488
|
+
return (_a3 = styleOverrides.value) == null ? void 0 : _a3.layoutSpec;
|
|
8770
9489
|
},
|
|
8771
9490
|
(spec) => {
|
|
8772
9491
|
dragBoxOptions.layoutSpec = spec;
|
|
@@ -8774,8 +9493,8 @@ ${lines.join("\n")}
|
|
|
8774
9493
|
);
|
|
8775
9494
|
vueDemi.watch(
|
|
8776
9495
|
() => {
|
|
8777
|
-
var
|
|
8778
|
-
return (
|
|
9496
|
+
var _a3;
|
|
9497
|
+
return (_a3 = styleOverrides.value) == null ? void 0 : _a3.layoutKey;
|
|
8779
9498
|
},
|
|
8780
9499
|
(key) => {
|
|
8781
9500
|
dragBoxOptions.layoutKey = key || props.layoutKey || void 0;
|
|
@@ -8799,8 +9518,8 @@ ${lines.join("\n")}
|
|
|
8799
9518
|
}
|
|
8800
9519
|
);
|
|
8801
9520
|
const boxStyle = vueDemi.computed(() => {
|
|
8802
|
-
var
|
|
8803
|
-
const extra = { ...((
|
|
9521
|
+
var _a3;
|
|
9522
|
+
const extra = { ...((_a3 = styleOverrides.value) == null ? void 0 : _a3.boxStyleExtra) ?? {} };
|
|
8804
9523
|
const isFixed = extra.position === "fixed";
|
|
8805
9524
|
if (!isFixed) {
|
|
8806
9525
|
delete extra.left;
|
|
@@ -8817,11 +9536,11 @@ ${lines.join("\n")}
|
|
|
8817
9536
|
};
|
|
8818
9537
|
});
|
|
8819
9538
|
const bodyStyle = vueDemi.computed(() => {
|
|
8820
|
-
var
|
|
9539
|
+
var _a3;
|
|
8821
9540
|
return {
|
|
8822
9541
|
padding: props.bodyPadding || void 0,
|
|
8823
9542
|
...props.bodyStyleExtra,
|
|
8824
|
-
...(
|
|
9543
|
+
...(_a3 = styleOverrides.value) == null ? void 0 : _a3.bodyStyleExtra
|
|
8825
9544
|
};
|
|
8826
9545
|
});
|
|
8827
9546
|
function onClose() {
|
|
@@ -9044,11 +9763,11 @@ ${lines.join("\n")}
|
|
|
9044
9763
|
});
|
|
9045
9764
|
}
|
|
9046
9765
|
function refresh() {
|
|
9047
|
-
var
|
|
9766
|
+
var _a2;
|
|
9048
9767
|
const map = miniMapRef.value;
|
|
9049
9768
|
const host = document.getElementById(DESIGN_CONTAINER_ID);
|
|
9050
9769
|
const scroller = host == null ? void 0 : host.parentElement;
|
|
9051
|
-
const paper = (
|
|
9770
|
+
const paper = (_a2 = host == null ? void 0 : host.querySelector) == null ? void 0 : _a2.call(host, ".hiprint-printPaper");
|
|
9052
9771
|
if (!map || !scroller || !paper) return;
|
|
9053
9772
|
const mapW = map.clientWidth;
|
|
9054
9773
|
const mapH = map.clientHeight;
|
|
@@ -9528,10 +10247,10 @@ ${lines.join("\n")}
|
|
|
9528
10247
|
}
|
|
9529
10248
|
};
|
|
9530
10249
|
const activeTheme = vueDemi.computed(() => {
|
|
9531
|
-
var
|
|
10250
|
+
var _a2, _b2;
|
|
9532
10251
|
if (typeof props.theme === "string") return props.theme;
|
|
9533
|
-
if (Array.isArray(props.theme)) return ((
|
|
9534
|
-
return ((
|
|
10252
|
+
if (Array.isArray(props.theme)) return ((_a2 = props.theme[0]) == null ? void 0 : _a2.theme) || "svpLight";
|
|
10253
|
+
return ((_b2 = props.theme) == null ? void 0 : _b2.theme) || "svpLight";
|
|
9535
10254
|
});
|
|
9536
10255
|
const { redraw: redrawRuler } = useRuler({
|
|
9537
10256
|
canvasX: () => rulerXRef.value,
|
|
@@ -9548,9 +10267,9 @@ ${lines.join("\n")}
|
|
|
9548
10267
|
return Array.isArray(json) && json.length > 0;
|
|
9549
10268
|
}
|
|
9550
10269
|
function resolveInitialTemplate() {
|
|
9551
|
-
var
|
|
10270
|
+
var _a2;
|
|
9552
10271
|
if (templateHasPanels(props.template)) return props.template;
|
|
9553
|
-
const saved = (
|
|
10272
|
+
const saved = (_a2 = utils.loadSaved) == null ? void 0 : _a2.call(utils);
|
|
9554
10273
|
if (saved && templateHasPanels(saved)) return saved;
|
|
9555
10274
|
return props.template;
|
|
9556
10275
|
}
|
|
@@ -9577,7 +10296,7 @@ ${lines.join("\n")}
|
|
|
9577
10296
|
applyStyleOption(props.styleOption);
|
|
9578
10297
|
}
|
|
9579
10298
|
function buildDesigner() {
|
|
9580
|
-
var
|
|
10299
|
+
var _a2;
|
|
9581
10300
|
utils.newDesigner(
|
|
9582
10301
|
{
|
|
9583
10302
|
template: resolveInitialTemplate(),
|
|
@@ -9594,13 +10313,13 @@ ${lines.join("\n")}
|
|
|
9594
10313
|
utils.plugins.run("onDesigned", payload).catch(() => {
|
|
9595
10314
|
});
|
|
9596
10315
|
utils.setPreview(previewRef.value);
|
|
9597
|
-
if ((
|
|
10316
|
+
if ((_a2 = props.designOptions) == null ? void 0 : _a2.adaptToSize) {
|
|
9598
10317
|
requestAnimationFrame(() => utils.adaptToSize());
|
|
9599
10318
|
}
|
|
9600
10319
|
}
|
|
9601
10320
|
let resizeHandler = null;
|
|
9602
10321
|
vueDemi.onMounted(async () => {
|
|
9603
|
-
var
|
|
10322
|
+
var _a2;
|
|
9604
10323
|
setLocale(props.lang);
|
|
9605
10324
|
designerStore.lang = props.lang;
|
|
9606
10325
|
designerStore.theme = activeTheme.value;
|
|
@@ -9616,10 +10335,13 @@ ${lines.join("\n")}
|
|
|
9616
10335
|
utils.buildByHtml();
|
|
9617
10336
|
} catch {
|
|
9618
10337
|
}
|
|
9619
|
-
if ((
|
|
10338
|
+
if ((_a2 = props.designOptions) == null ? void 0 : _a2.adaptToSize) {
|
|
9620
10339
|
resizeHandler = () => utils.adaptToSize();
|
|
9621
10340
|
window.addEventListener("resize", resizeHandler);
|
|
9622
10341
|
}
|
|
10342
|
+
if (props.autoConnect) {
|
|
10343
|
+
utils.setConnect(true);
|
|
10344
|
+
}
|
|
9623
10345
|
});
|
|
9624
10346
|
vueDemi.onBeforeUnmount(() => {
|
|
9625
10347
|
utils.shortcuts.unmount();
|
|
@@ -9658,8 +10380,8 @@ ${lines.join("\n")}
|
|
|
9658
10380
|
utils.import();
|
|
9659
10381
|
}
|
|
9660
10382
|
function handlePreview() {
|
|
9661
|
-
var
|
|
9662
|
-
(
|
|
10383
|
+
var _a2, _b2;
|
|
10384
|
+
(_b2 = (_a2 = previewRef.value) == null ? void 0 : _a2.open) == null ? void 0 : _b2.call(_a2);
|
|
9663
10385
|
}
|
|
9664
10386
|
return {
|
|
9665
10387
|
DESIGN_CONTAINER_ID,
|
|
@@ -9827,7 +10549,7 @@ ${lines.join("\n")}
|
|
|
9827
10549
|
}
|
|
9828
10550
|
const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
9829
10551
|
const pluginApiPdf = (opts = {}) => {
|
|
9830
|
-
const
|
|
10552
|
+
const plugin2 = {
|
|
9831
10553
|
name: "plugin-api-pdf",
|
|
9832
10554
|
description: "Exports the current template as a PDF document.",
|
|
9833
10555
|
config: { ...opts },
|
|
@@ -9861,10 +10583,10 @@ ${lines.join("\n")}
|
|
|
9861
10583
|
}
|
|
9862
10584
|
]
|
|
9863
10585
|
};
|
|
9864
|
-
return
|
|
10586
|
+
return plugin2;
|
|
9865
10587
|
};
|
|
9866
10588
|
const pluginApiImage = (opts = {}) => {
|
|
9867
|
-
const
|
|
10589
|
+
const plugin2 = {
|
|
9868
10590
|
name: "plugin-api-image",
|
|
9869
10591
|
description: "Exports the current template as PNG / JPEG.",
|
|
9870
10592
|
config: { type: "png", ...opts },
|
|
@@ -9891,7 +10613,7 @@ ${lines.join("\n")}
|
|
|
9891
10613
|
}
|
|
9892
10614
|
]
|
|
9893
10615
|
};
|
|
9894
|
-
return
|
|
10616
|
+
return plugin2;
|
|
9895
10617
|
};
|
|
9896
10618
|
function defaultEditor(source, ctx) {
|
|
9897
10619
|
return new Promise((resolve) => {
|
|
@@ -9932,7 +10654,7 @@ ${lines.join("\n")}
|
|
|
9932
10654
|
}
|
|
9933
10655
|
const pluginViewCodeEdit = (opts = {}) => {
|
|
9934
10656
|
const editor = opts.editor ?? defaultEditor;
|
|
9935
|
-
const
|
|
10657
|
+
const plugin2 = {
|
|
9936
10658
|
name: "plugin-view-code-edit",
|
|
9937
10659
|
description: "Provides a small in-browser editor for `function` options.",
|
|
9938
10660
|
config: { ...opts },
|
|
@@ -9942,18 +10664,18 @@ ${lines.join("\n")}
|
|
|
9942
10664
|
name: "editor-create-print-element",
|
|
9943
10665
|
priority: 100,
|
|
9944
10666
|
run: async (option, _printElement, _ev) => {
|
|
9945
|
-
var
|
|
10667
|
+
var _a2;
|
|
9946
10668
|
if (!option || typeof option !== "object") return;
|
|
9947
10669
|
if (option.type !== "function" && option.editor !== "code") return;
|
|
9948
10670
|
const next = await editor(String(option.value ?? ""), { name: option.name ?? "function" });
|
|
9949
10671
|
if (next == null) return;
|
|
9950
10672
|
option.value = next;
|
|
9951
|
-
(
|
|
10673
|
+
(_a2 = option == null ? void 0 : option.onChange) == null ? void 0 : _a2.call(option, next);
|
|
9952
10674
|
}
|
|
9953
10675
|
}
|
|
9954
10676
|
]
|
|
9955
10677
|
};
|
|
9956
|
-
return
|
|
10678
|
+
return plugin2;
|
|
9957
10679
|
};
|
|
9958
10680
|
const index = {
|
|
9959
10681
|
install(app) {
|
|
@@ -9964,14 +10686,6 @@ ${lines.join("\n")}
|
|
|
9964
10686
|
app.component("SvpDragBox", DragBox);
|
|
9965
10687
|
}
|
|
9966
10688
|
};
|
|
9967
|
-
Object.defineProperty(exports2, "defaultElementTypeProvider", {
|
|
9968
|
-
enumerable: true,
|
|
9969
|
-
get: () => vuePluginHiprint.defaultElementTypeProvider
|
|
9970
|
-
});
|
|
9971
|
-
Object.defineProperty(exports2, "hiprint", {
|
|
9972
|
-
enumerable: true,
|
|
9973
|
-
get: () => vuePluginHiprint.hiprint
|
|
9974
|
-
});
|
|
9975
10689
|
exports2.DEFAULT_ELEMENT_CATALOGUE = DEFAULT_ELEMENT_CATALOGUE;
|
|
9976
10690
|
exports2.DEFAULT_FONT_LIST = DEFAULT_FONT_LIST;
|
|
9977
10691
|
exports2.DEFAULT_PAPER_LIST = DEFAULT_PAPER_LIST;
|
|
@@ -10006,6 +10720,7 @@ ${lines.join("\n")}
|
|
|
10006
10720
|
exports2.PageStructurePanel = PageStructurePanel;
|
|
10007
10721
|
exports2.PluginManager = PluginManager;
|
|
10008
10722
|
exports2.Preview = Preview;
|
|
10723
|
+
exports2.PrintClient = PrintClient;
|
|
10009
10724
|
exports2.PropertiesPanel = PropertiesPanel;
|
|
10010
10725
|
exports2.Provider = Provider;
|
|
10011
10726
|
exports2.Ruler = Ruler;
|
|
@@ -10021,16 +10736,22 @@ ${lines.join("\n")}
|
|
|
10021
10736
|
exports2.ZOOM_MIN = ZOOM_MIN;
|
|
10022
10737
|
exports2.ZOOM_STEP = ZOOM_STEP;
|
|
10023
10738
|
exports2.applyStyleOption = applyStyleOption;
|
|
10739
|
+
exports2.autoConnect = autoConnect;
|
|
10740
|
+
exports2.batchPrint = batchPrint;
|
|
10024
10741
|
exports2.buildByHtml = buildByHtml;
|
|
10025
10742
|
exports2.buildPrintDataFromForm = buildPrintDataFromForm;
|
|
10026
10743
|
exports2.createPrintDataFormState = createPrintDataFormState;
|
|
10027
10744
|
exports2.default = index;
|
|
10745
|
+
exports2.defaultElementTypeProvider = defaultElementTypeProvider;
|
|
10028
10746
|
exports2.designerStore = designerStore;
|
|
10747
|
+
exports2.disAutoConnect = disAutoConnect;
|
|
10029
10748
|
exports2.elementTypeKey = elementTypeKey;
|
|
10030
10749
|
exports2.enUS = enUS;
|
|
10031
10750
|
exports2.extractTemplateFields = extractTemplateFields;
|
|
10032
10751
|
exports2.getLocaleList = getLocaleList;
|
|
10752
|
+
exports2.getPrintClient = getPrintClient;
|
|
10033
10753
|
exports2.headerElementsFromCatalogue = headerElementsFromCatalogue;
|
|
10754
|
+
exports2.hiprint = hiprint;
|
|
10034
10755
|
exports2.iconForElement = iconForElement;
|
|
10035
10756
|
exports2.iconForElementKey = iconForElementKey;
|
|
10036
10757
|
exports2.iconForHeaderTab = iconForHeaderTab;
|