@node-projects/web-component-designer-zpl 0.1.10 → 0.1.12
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.
|
@@ -5,6 +5,7 @@ import { ZplGraphicDiagonalLine } from "../widgets/zpl-graphic-diagonal-line.js"
|
|
|
5
5
|
import { ZplGraphicCircle } from "../widgets/zpl-graphic-circle.js";
|
|
6
6
|
import { ZplText } from "../widgets/zpl-text.js";
|
|
7
7
|
import { ZplImage } from "../widgets/zpl-image.js";
|
|
8
|
+
import { ZplComment } from "../widgets/zpl-comment.js";
|
|
8
9
|
function getSetValue(...args) {
|
|
9
10
|
for (let a of args)
|
|
10
11
|
if (a != '' && a != null && a != "NaN")
|
|
@@ -47,11 +48,19 @@ export class ZplParserService {
|
|
|
47
48
|
p = p.replaceAll("\n", "");
|
|
48
49
|
p = p.replaceAll("\r", "");
|
|
49
50
|
let command = p.substring(0, 2);
|
|
50
|
-
let
|
|
51
|
+
let fieldString = p.substring(2);
|
|
52
|
+
let fields = fieldString.split(",");
|
|
51
53
|
switch (command) {
|
|
52
54
|
case "XA":
|
|
53
55
|
case "XZ":
|
|
56
|
+
break;
|
|
54
57
|
case "FX":
|
|
58
|
+
let comment = new ZplComment();
|
|
59
|
+
comment.style.position = "absolute";
|
|
60
|
+
comment.style.left = x + "px";
|
|
61
|
+
comment.style.top = y + "px";
|
|
62
|
+
comment.setAttribute("content", fieldString);
|
|
63
|
+
designItems.push(DesignItem.createDesignItemFromInstance(comment, serviceContainer, instanceServiceContainer));
|
|
55
64
|
break;
|
|
56
65
|
case "CF":
|
|
57
66
|
fontName = fields[0];
|
|
@@ -143,9 +152,9 @@ export class ZplParserService {
|
|
|
143
152
|
case "FD":
|
|
144
153
|
if (bc) {
|
|
145
154
|
if (qr)
|
|
146
|
-
barcode.setAttribute("content",
|
|
155
|
+
barcode.setAttribute("content", fieldString.substring(3));
|
|
147
156
|
else
|
|
148
|
-
barcode.setAttribute("content",
|
|
157
|
+
barcode.setAttribute("content", fieldString);
|
|
149
158
|
designItems.push(DesignItem.createDesignItemFromInstance(barcode, serviceContainer, instanceServiceContainer));
|
|
150
159
|
bc = false;
|
|
151
160
|
qr = false;
|
|
@@ -158,7 +167,7 @@ export class ZplParserService {
|
|
|
158
167
|
text.setAttribute("font-name", fontName);
|
|
159
168
|
text.setAttribute("font-height", fontHeight.toString());
|
|
160
169
|
text.setAttribute("font-width", fontWidth.toString());
|
|
161
|
-
text.setAttribute("content",
|
|
170
|
+
text.setAttribute("content", fieldString);
|
|
162
171
|
designItems.push(DesignItem.createDesignItemFromInstance(text, serviceContainer, instanceServiceContainer));
|
|
163
172
|
}
|
|
164
173
|
break;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
export declare class ZplComment extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
+
static readonly style: CSSStyleSheet;
|
|
4
|
+
static readonly template: HTMLTemplateElement;
|
|
5
|
+
static readonly is = "zpl-comment";
|
|
6
|
+
content: string;
|
|
7
|
+
static readonly properties: {
|
|
8
|
+
content: StringConstructor;
|
|
9
|
+
};
|
|
10
|
+
constructor();
|
|
11
|
+
ready(): Promise<void>;
|
|
12
|
+
createZpl(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
export class ZplComment extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
+
static style = css `
|
|
4
|
+
:host {
|
|
5
|
+
display: none;
|
|
6
|
+
}`;
|
|
7
|
+
static template = html ``;
|
|
8
|
+
static is = 'zpl-comment';
|
|
9
|
+
content;
|
|
10
|
+
static properties = {
|
|
11
|
+
content: String
|
|
12
|
+
};
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this._restoreCachedInititalValues();
|
|
16
|
+
}
|
|
17
|
+
async ready() {
|
|
18
|
+
this._parseAttributesToProperties();
|
|
19
|
+
}
|
|
20
|
+
createZpl() {
|
|
21
|
+
let zpl = "";
|
|
22
|
+
zpl += "^FX" + this.content;
|
|
23
|
+
return zpl;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
customElements.define(ZplComment.is, ZplComment);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
declare enum FontNames {
|
|
3
|
+
Font_0 = "0",
|
|
4
|
+
Font_A = "A"
|
|
5
|
+
}
|
|
6
|
+
export declare class ZplText extends BaseCustomWebComponentConstructorAppend {
|
|
7
|
+
static readonly style: CSSStyleSheet;
|
|
8
|
+
static readonly template: HTMLTemplateElement;
|
|
9
|
+
static readonly is = "zpl-text";
|
|
10
|
+
content: string;
|
|
11
|
+
fontName: string;
|
|
12
|
+
fontHeight: number;
|
|
13
|
+
fontWidth: number;
|
|
14
|
+
private _text;
|
|
15
|
+
static readonly properties: {
|
|
16
|
+
content: StringConstructor;
|
|
17
|
+
fontName: typeof FontNames;
|
|
18
|
+
fontHeight: NumberConstructor;
|
|
19
|
+
fontWidth: NumberConstructor;
|
|
20
|
+
};
|
|
21
|
+
constructor();
|
|
22
|
+
ready(): Promise<void>;
|
|
23
|
+
createZpl(): string;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { getZplCoordinates } from "../zplHelper.js";
|
|
3
|
+
var FontNames;
|
|
4
|
+
(function (FontNames) {
|
|
5
|
+
FontNames["Font_0"] = "0";
|
|
6
|
+
FontNames["Font_A"] = "A";
|
|
7
|
+
})(FontNames || (FontNames = {}));
|
|
8
|
+
export class ZplText extends BaseCustomWebComponentConstructorAppend {
|
|
9
|
+
static style = css `
|
|
10
|
+
*{
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
static template = html `
|
|
15
|
+
<div id="text-div" style="width: 100%; height: 100%; pointer-events: none">
|
|
16
|
+
</div>
|
|
17
|
+
`;
|
|
18
|
+
static is = 'zpl-text';
|
|
19
|
+
content;
|
|
20
|
+
fontName;
|
|
21
|
+
fontHeight;
|
|
22
|
+
fontWidth;
|
|
23
|
+
_text;
|
|
24
|
+
static properties = {
|
|
25
|
+
content: String,
|
|
26
|
+
fontName: FontNames,
|
|
27
|
+
fontHeight: Number,
|
|
28
|
+
fontWidth: Number
|
|
29
|
+
};
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this._restoreCachedInititalValues();
|
|
33
|
+
this._text = this._getDomElement("text-div");
|
|
34
|
+
}
|
|
35
|
+
async ready() {
|
|
36
|
+
this._parseAttributesToProperties();
|
|
37
|
+
this._text.innerHTML = this.content;
|
|
38
|
+
this._text.style.transformOrigin = "0 0";
|
|
39
|
+
switch (this.fontName) {
|
|
40
|
+
case FontNames.Font_0:
|
|
41
|
+
this._text.style.fontSize = "9px";
|
|
42
|
+
this._text.style.fontFamily = "RobotoCn, Verdana";
|
|
43
|
+
this._text.style.fontKerning = "none";
|
|
44
|
+
this._text.style.transform = "scaleX(" + this.fontWidth / 9 + ") scaleY(" + this.fontHeight / 9 + ") translate(0px, -3px)";
|
|
45
|
+
break;
|
|
46
|
+
case FontNames.Font_A:
|
|
47
|
+
this._text.style.fontSize = "9px";
|
|
48
|
+
this._text.style.fontFamily = "monospace";
|
|
49
|
+
this._text.style.transform = "scaleX(" + this.fontWidth / 5 + ") scaleY(" + this.fontHeight / 8 + ") translate(0px, -3px)";
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
this.style.width = '';
|
|
53
|
+
this.style.height = '';
|
|
54
|
+
requestAnimationFrame(() => {
|
|
55
|
+
let rect = this._text.getBoundingClientRect();
|
|
56
|
+
this.style.width = rect.width + 'px';
|
|
57
|
+
this.style.height = rect.height / 2 + 'px';
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
createZpl() {
|
|
61
|
+
let zpl = "";
|
|
62
|
+
zpl += getZplCoordinates(this, 0);
|
|
63
|
+
zpl += "^CF" + this.fontName + "," + this.fontHeight + "," + this.fontWidth;
|
|
64
|
+
zpl += "^FD" + this.content;
|
|
65
|
+
zpl += "^FS";
|
|
66
|
+
return zpl;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
customElements.define(ZplText.is, ZplText);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "web-component-designer addon: Widgets and Services for creating a ZPL Designer",
|
|
3
3
|
"name": "@node-projects/web-component-designer-zpl",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.12",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|