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