@node-projects/web-component-designer-zpl 0.2.1 → 0.3.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.md +16 -2
- package/THIRD-PARTY-LICENSES.md +432 -0
- package/dist/assets/fonts/LICENSE-APACHE-2.0.txt +202 -0
- package/dist/assets/fonts/NOTICE.md +27 -0
- package/dist/assets/fonts/OCRA-NOTICE.md +27 -0
- package/dist/assets/fonts/OCRA.ttf +0 -0
- package/dist/assets/fonts/OCRB-NOTICE.md +21 -0
- package/dist/assets/fonts/OCRB.ttf +0 -0
- package/dist/assets/fonts/PrintLabMono-NOTICE.md +24 -0
- package/dist/assets/fonts/PrintLabMono.ttf +0 -0
- package/dist/assets/fonts/PrintLabZPL-Bold.ttf +0 -0
- package/dist/assets/fonts/PrintLabZPL-Bold.woff2 +0 -0
- package/dist/assets/fonts/VeraMono-Bold.ttf +0 -0
- package/dist/assets/fonts/VeraMono-NOTICE.md +57 -0
- package/dist/assets/fonts/VeraMono.ttf +0 -0
- package/dist/assets/licenses/BWIP-JS-LICENSE.txt +23 -0
- package/dist/assets/licenses/ZPLab-LICENSE.txt +21 -0
- package/dist/barcodes/barcodeRegistry.d.ts +124 -0
- package/dist/barcodes/barcodeRegistry.js +357 -0
- package/dist/barcodes/bwipRenderer.d.ts +90 -0
- package/dist/barcodes/bwipRenderer.js +630 -0
- package/dist/fonts/zplFonts.d.ts +27 -0
- package/dist/fonts/zplFonts.js +85 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +10 -3
- package/dist/services/ZplBarcodeElementsService.d.ts +5 -0
- package/dist/services/ZplBarcodeElementsService.js +16 -0
- package/dist/services/ZplBarcodePropertiesService.d.ts +10 -0
- package/dist/services/ZplBarcodePropertiesService.js +59 -0
- package/dist/services/ZplDiagonalLineExtension.d.ts +46 -0
- package/dist/services/ZplDiagonalLineExtension.js +255 -0
- package/dist/services/ZplElementResizeStrategy.d.ts +20 -0
- package/dist/services/ZplElementResizeStrategy.js +182 -0
- package/dist/services/ZplGraphicResizeStrategy.d.ts +18 -0
- package/dist/services/ZplGraphicResizeStrategy.js +81 -0
- package/dist/services/ZplIncludeInOutputPropertiesService.d.ts +12 -0
- package/dist/services/ZplIncludeInOutputPropertiesService.js +50 -0
- package/dist/services/ZplParserService.d.ts +7 -4
- package/dist/services/ZplParserService.js +214 -249
- package/dist/services/ZplSelectionExtensionProvider.d.ts +9 -0
- package/dist/services/ZplSelectionExtensionProvider.js +15 -0
- package/dist/services/ZplTextEditExtension.d.ts +20 -0
- package/dist/services/ZplTextEditExtension.js +80 -0
- package/dist/services/ZplTextPropertiesService.d.ts +8 -0
- package/dist/services/ZplTextPropertiesService.js +24 -0
- package/dist/services/hiddenMetadata.d.ts +17 -0
- package/dist/services/hiddenMetadata.js +95 -0
- package/dist/services/zplResizeGeometry.d.ts +6 -0
- package/dist/services/zplResizeGeometry.js +8 -0
- package/dist/setupZplServiceContainer.js +22 -4
- package/dist/widgets/elements.json +0 -24
- package/dist/widgets/views/zpl-demo-view.js +27 -2
- package/dist/widgets/zpl-barcode.d.ts +68 -14
- package/dist/widgets/zpl-barcode.js +189 -74
- package/dist/widgets/zpl-comment.d.ts +2 -0
- package/dist/widgets/zpl-comment.js +6 -3
- package/dist/widgets/zpl-graphic-box.d.ts +12 -0
- package/dist/widgets/zpl-graphic-box.js +49 -15
- package/dist/widgets/zpl-graphic-circle.d.ts +2 -0
- package/dist/widgets/zpl-graphic-circle.js +7 -0
- package/dist/widgets/zpl-graphic-diagonal-line.d.ts +2 -0
- package/dist/widgets/zpl-graphic-diagonal-line.js +7 -0
- package/dist/widgets/zpl-image.d.ts +4 -1
- package/dist/widgets/zpl-image.js +17 -14
- package/dist/widgets/zpl-text.d.ts +38 -8
- package/dist/widgets/zpl-text.js +183 -49
- package/dist/zplHelper.d.ts +1 -1
- package/dist/zplHelper.js +5 -1
- package/package.json +9 -4
- package/dist/extensions/ZplLayoutResizeExtensionProvider.d.ts +0 -4
- package/dist/extensions/ZplLayoutResizeExtensionProvider.js +0 -16
- package/dist/jsBarcodeOptions.d.ts +0 -27
- package/dist/jsBarcodeOptions.js +0 -14
- package/dist/qr.d.ts +0 -11
- package/dist/qr.js +0 -759
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { getBarcodeDefinition } from '../barcodes/barcodeRegistry.js';
|
|
2
|
+
import { ZplBarcode } from '../widgets/zpl-barcode.js';
|
|
3
|
+
import { ZplText } from '../widgets/zpl-text.js';
|
|
4
|
+
import { getDeviceFontMagnification } from '../fonts/zplFonts.js';
|
|
5
|
+
import { quantizeZplValue, zplAxisScales } from './zplResizeGeometry.js';
|
|
6
|
+
export { quantizeZplValue, zplAxisScales } from './zplResizeGeometry.js';
|
|
7
|
+
const allHandles = ['nw-resize', 'n-resize', 'ne-resize', 'w-resize', 'sw-resize', 's-resize', 'e-resize', 'se-resize'];
|
|
8
|
+
const edgeHandles = ['n-resize', 'w-resize', 's-resize', 'e-resize'];
|
|
9
|
+
const cornerHandles = ['nw-resize', 'ne-resize', 'sw-resize', 'se-resize'];
|
|
10
|
+
const clamp = quantizeZplValue;
|
|
11
|
+
export class ZplElementResizeStrategy {
|
|
12
|
+
isHandledElement(designItem) {
|
|
13
|
+
return designItem.element instanceof ZplText || designItem.element instanceof ZplBarcode;
|
|
14
|
+
}
|
|
15
|
+
getEnabledHandles(designItem) {
|
|
16
|
+
if (designItem.element instanceof ZplText)
|
|
17
|
+
return allHandles;
|
|
18
|
+
const definition = getBarcodeDefinition(designItem.getAttribute('type'));
|
|
19
|
+
if (definition.resizeKind === 'intrinsic')
|
|
20
|
+
return [];
|
|
21
|
+
if (definition.resizeKind === 'uniform-2d')
|
|
22
|
+
return cornerHandles;
|
|
23
|
+
if (definition.resizeKind === 'linear')
|
|
24
|
+
return edgeHandles;
|
|
25
|
+
return allHandles;
|
|
26
|
+
}
|
|
27
|
+
begin(context) {
|
|
28
|
+
const element = context.designItem.element;
|
|
29
|
+
return {
|
|
30
|
+
originalAttributes: new Map(),
|
|
31
|
+
previewAttributes: new Map(),
|
|
32
|
+
originalWidth: element.style.width,
|
|
33
|
+
originalHeight: element.style.height
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
preview(context, rawState) {
|
|
37
|
+
const state = rawState;
|
|
38
|
+
const element = context.designItem.element;
|
|
39
|
+
const attributes = element instanceof ZplText
|
|
40
|
+
? this._textAttributes(element, context, state)
|
|
41
|
+
: this._barcodeAttributes(element, context, state);
|
|
42
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
43
|
+
if (!state.originalAttributes.has(name))
|
|
44
|
+
state.originalAttributes.set(name, element.getAttribute(name));
|
|
45
|
+
state.previewAttributes.set(name, value);
|
|
46
|
+
element.setAttribute(name, value);
|
|
47
|
+
}
|
|
48
|
+
// ResizeExtension writes a temporary CSS box before invoking the ZPL
|
|
49
|
+
// strategy. When quantization keeps every attribute unchanged, native
|
|
50
|
+
// attribute callbacks do not fire and that temporary box would survive
|
|
51
|
+
// until the next device-font/barcode threshold, causing a large jump.
|
|
52
|
+
if (element instanceof ZplText)
|
|
53
|
+
element.renderText();
|
|
54
|
+
else
|
|
55
|
+
element.renderBarcode();
|
|
56
|
+
const bounds = element.getBoundingClientRect();
|
|
57
|
+
return { width: bounds.width, height: bounds.height };
|
|
58
|
+
}
|
|
59
|
+
commit(context, rawState) {
|
|
60
|
+
const state = rawState;
|
|
61
|
+
const element = context.designItem.element;
|
|
62
|
+
this._restoreRaw(element, state);
|
|
63
|
+
for (const [name, value] of state.previewAttributes)
|
|
64
|
+
context.designItem.setAttribute(name, value);
|
|
65
|
+
}
|
|
66
|
+
cancel(context, rawState) {
|
|
67
|
+
this._restoreRaw(context.designItem.element, rawState);
|
|
68
|
+
}
|
|
69
|
+
_restoreRaw(element, state) {
|
|
70
|
+
for (const [name, value] of state.originalAttributes) {
|
|
71
|
+
if (value == null)
|
|
72
|
+
element.removeAttribute(name);
|
|
73
|
+
else
|
|
74
|
+
element.setAttribute(name, value);
|
|
75
|
+
}
|
|
76
|
+
element.style.width = state.originalWidth;
|
|
77
|
+
element.style.height = state.originalHeight;
|
|
78
|
+
if (element instanceof ZplBarcode)
|
|
79
|
+
element.renderBarcode();
|
|
80
|
+
else if (element instanceof ZplText)
|
|
81
|
+
element.renderText();
|
|
82
|
+
}
|
|
83
|
+
_initialNumber(state, element, name, fallback) {
|
|
84
|
+
if (!state.originalAttributes.has(name))
|
|
85
|
+
state.originalAttributes.set(name, element.getAttribute(name));
|
|
86
|
+
const value = Number(state.originalAttributes.get(name));
|
|
87
|
+
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
88
|
+
}
|
|
89
|
+
_textAttributes(element, context, state) {
|
|
90
|
+
const scales = zplAxisScales(element.getAttribute('rotation'), context.initialSize, context.currentSize);
|
|
91
|
+
const fontWidthScale = scales.width;
|
|
92
|
+
const fontHeightScale = scales.height;
|
|
93
|
+
if (!state.originalAttributes.has('font-width'))
|
|
94
|
+
state.originalAttributes.set('font-width', element.getAttribute('font-width'));
|
|
95
|
+
const originalWidth = Number(state.originalAttributes.get('font-width'));
|
|
96
|
+
const originalHeight = this._initialNumber(state, element, 'font-height', 30);
|
|
97
|
+
const font = (element.getAttribute('font-name') || '0');
|
|
98
|
+
const deviceFont = getDeviceFontMagnification(font, originalHeight, originalWidth);
|
|
99
|
+
if (deviceFont) {
|
|
100
|
+
// Bitmap fonts A-H can only change in integer cell
|
|
101
|
+
// magnifications. Scale the magnification visible at gesture start,
|
|
102
|
+
// not the raw requested dot value: e.g. Font A height 30 renders at
|
|
103
|
+
// 3x and must not jump to 4x after a two-dot drag.
|
|
104
|
+
const heightMagnification = clamp(deviceFont.height * fontHeightScale, 1, 10);
|
|
105
|
+
const widthMagnification = clamp(deviceFont.width * fontWidthScale, 1, 10);
|
|
106
|
+
const fontHeight = heightMagnification === deviceFont.height
|
|
107
|
+
? originalHeight
|
|
108
|
+
: heightMagnification * deviceFont.heightStep;
|
|
109
|
+
let fontWidth;
|
|
110
|
+
if (!(originalWidth > 0) && widthMagnification === heightMagnification) {
|
|
111
|
+
fontWidth = 0;
|
|
112
|
+
}
|
|
113
|
+
else if (originalWidth > 0 && widthMagnification === deviceFont.width) {
|
|
114
|
+
fontWidth = originalWidth;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
fontWidth = widthMagnification * deviceFont.widthStep;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
'font-width': String(fontWidth),
|
|
121
|
+
'font-height': String(fontHeight)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const fontHeight = clamp(originalHeight * fontHeightScale, 1, 32000);
|
|
125
|
+
let fontWidth;
|
|
126
|
+
if (Number.isFinite(originalWidth) && originalWidth > 0) {
|
|
127
|
+
fontWidth = clamp(originalWidth * fontWidthScale, 1, 32000);
|
|
128
|
+
}
|
|
129
|
+
else if (Math.abs(fontWidthScale - fontHeightScale) < .01) {
|
|
130
|
+
// A proportional resize keeps Zebra's automatic-width semantics.
|
|
131
|
+
fontWidth = 0;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const residualScale = fontWidthScale / Math.max(.01, fontHeightScale);
|
|
135
|
+
fontWidth = clamp(fontHeight * residualScale, 1, 32000);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
'font-width': String(fontWidth),
|
|
139
|
+
'font-height': String(fontHeight)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
_barcodeAttributes(element, context, state) {
|
|
143
|
+
const definition = getBarcodeDefinition(element.getAttribute('type'));
|
|
144
|
+
const defaults = definition.defaults;
|
|
145
|
+
const screenWidthScale = context.currentSize.width / Math.max(1, context.initialSize.width);
|
|
146
|
+
const screenHeightScale = context.currentSize.height / Math.max(1, context.initialSize.height);
|
|
147
|
+
const scales = zplAxisScales(element.getAttribute('rotation'), context.initialSize, context.currentSize);
|
|
148
|
+
const widthScale = scales.width;
|
|
149
|
+
const heightScale = scales.height;
|
|
150
|
+
if (definition.resizeKind === 'uniform-2d') {
|
|
151
|
+
const scale = Math.min(screenWidthScale, screenHeightScale);
|
|
152
|
+
const attribute = definition.type === 'datamatrix' ? 'dimension' : 'magnification';
|
|
153
|
+
return { [attribute]: String(clamp(this._initialNumber(state, element, attribute, Number(defaults[attribute] ?? 4)) * scale, 1, definition.type === 'datamatrix' ? 12 : 10)) };
|
|
154
|
+
}
|
|
155
|
+
if (definition.resizeKind === 'stacked-2d') {
|
|
156
|
+
return {
|
|
157
|
+
'module-width': String(clamp(this._initialNumber(state, element, 'module-width', Number(defaults.moduleWidth ?? 2)) * widthScale, definition.type === 'codablock' || definition.type === 'pdf417' ? 2 : 1, 10)),
|
|
158
|
+
'row-height': String(clamp(this._initialNumber(state, element, 'row-height', Number(defaults.rowHeight ?? 2)) * heightScale, 1, 9999))
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (definition.resizeKind === 'tlc39') {
|
|
162
|
+
return {
|
|
163
|
+
'module-width': String(clamp(this._initialNumber(state, element, 'module-width', Number(defaults.moduleWidth ?? 2)) * widthScale, 1, 10)),
|
|
164
|
+
'bar-height': String(clamp(this._initialNumber(state, element, 'bar-height', Number(defaults.barHeight ?? 40)) * heightScale, 1, 32000)),
|
|
165
|
+
'micro-pdf-module-width': String(clamp(this._initialNumber(state, element, 'micro-pdf-module-width', Number(defaults.microPdfModuleWidth ?? 2)) * widthScale, 1, 10)),
|
|
166
|
+
'micro-pdf-row-height': String(clamp(this._initialNumber(state, element, 'micro-pdf-row-height', Number(defaults.microPdfRowHeight ?? 4)) * heightScale, 1, 9999))
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const initialModuleWidth = this._initialNumber(state, element, 'module-width', Number(defaults.moduleWidth ?? 2));
|
|
170
|
+
const moduleWidth = clamp(initialModuleWidth * widthScale, 1, 10);
|
|
171
|
+
let barHeight = clamp(this._initialNumber(state, element, 'bar-height', Number(defaults.barHeight ?? 100)) * heightScale, 1, 32000);
|
|
172
|
+
if (definition.type === 'code49')
|
|
173
|
+
barHeight = clamp(barHeight, moduleWidth * 8, moduleWidth * 50);
|
|
174
|
+
const attributes = { 'module-width': String(moduleWidth), 'bar-height': String(barHeight) };
|
|
175
|
+
if (definition.properties.some(property => property.attributeName === 'wide-ratio')) {
|
|
176
|
+
const residualScale = widthScale / Math.max(.1, moduleWidth / initialModuleWidth);
|
|
177
|
+
const wideRatio = Math.max(2, Math.min(3, Math.round(this._initialNumber(state, element, 'wide-ratio', Number(defaults.wideRatio ?? 3)) * residualScale * 10) / 10));
|
|
178
|
+
return { ...attributes, 'wide-ratio': String(wideRatio) };
|
|
179
|
+
}
|
|
180
|
+
return attributes;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementResizeContext, ElementResizePreview, IDesignItem, IElementResizeStrategy, ResizeHandle } from '@node-projects/web-component-designer';
|
|
2
|
+
interface GraphicResizeState {
|
|
3
|
+
originalWidth: string;
|
|
4
|
+
originalHeight: string;
|
|
5
|
+
originalLeft: string;
|
|
6
|
+
originalTop: string;
|
|
7
|
+
originalRight: string;
|
|
8
|
+
originalBottom: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ZplGraphicResizeStrategy implements IElementResizeStrategy {
|
|
11
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
12
|
+
getEnabledHandles(designItem: IDesignItem): readonly ResizeHandle[];
|
|
13
|
+
begin(context: ElementResizeContext): GraphicResizeState;
|
|
14
|
+
preview(context: ElementResizeContext, rawState: unknown): ElementResizePreview;
|
|
15
|
+
commit(context: ElementResizeContext, rawState: unknown): void;
|
|
16
|
+
cancel(context: ElementResizeContext, rawState: unknown): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ZplGraphicCircle } from '../widgets/zpl-graphic-circle.js';
|
|
2
|
+
import { ZplGraphicDiagonalLine } from '../widgets/zpl-graphic-diagonal-line.js';
|
|
3
|
+
const circleHandles = ['n-resize', 'w-resize', 's-resize', 'e-resize'];
|
|
4
|
+
function crossedHandle(handle, crossedX, crossedY) {
|
|
5
|
+
let result = handle;
|
|
6
|
+
if (crossedX) {
|
|
7
|
+
const horizontal = {
|
|
8
|
+
'nw-resize': 'ne-resize', 'ne-resize': 'nw-resize',
|
|
9
|
+
'sw-resize': 'se-resize', 'se-resize': 'sw-resize',
|
|
10
|
+
'w-resize': 'e-resize', 'e-resize': 'w-resize'
|
|
11
|
+
};
|
|
12
|
+
result = horizontal[result] ?? result;
|
|
13
|
+
}
|
|
14
|
+
if (crossedY) {
|
|
15
|
+
const vertical = {
|
|
16
|
+
'nw-resize': 'sw-resize', 'sw-resize': 'nw-resize',
|
|
17
|
+
'ne-resize': 'se-resize', 'se-resize': 'ne-resize',
|
|
18
|
+
'n-resize': 's-resize', 's-resize': 'n-resize'
|
|
19
|
+
};
|
|
20
|
+
result = vertical[result] ?? result;
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
export class ZplGraphicResizeStrategy {
|
|
25
|
+
isHandledElement(designItem) {
|
|
26
|
+
return designItem.element instanceof ZplGraphicCircle || designItem.element instanceof ZplGraphicDiagonalLine;
|
|
27
|
+
}
|
|
28
|
+
getEnabledHandles(designItem) {
|
|
29
|
+
if (designItem.element instanceof ZplGraphicCircle)
|
|
30
|
+
return circleHandles;
|
|
31
|
+
// Diagonals use ZplDiagonalLineExtension. Returning no generic resize
|
|
32
|
+
// handles keeps rectangle-based resize semantics out of endpoint editing.
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
begin(context) {
|
|
36
|
+
const element = context.designItem.element;
|
|
37
|
+
return {
|
|
38
|
+
originalWidth: element.style.width,
|
|
39
|
+
originalHeight: element.style.height,
|
|
40
|
+
originalLeft: element.style.left,
|
|
41
|
+
originalTop: element.style.top,
|
|
42
|
+
originalRight: element.style.right,
|
|
43
|
+
originalBottom: element.style.bottom
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
preview(context, rawState) {
|
|
47
|
+
void rawState;
|
|
48
|
+
const element = context.designItem.element;
|
|
49
|
+
const crossedX = context.currentSize.width < 0;
|
|
50
|
+
const crossedY = context.currentSize.height < 0;
|
|
51
|
+
const width = Math.max(1, Math.abs(context.currentSize.width));
|
|
52
|
+
const height = Math.max(1, Math.abs(context.currentSize.height));
|
|
53
|
+
element.style.width = `${width}px`;
|
|
54
|
+
element.style.height = `${height}px`;
|
|
55
|
+
return {
|
|
56
|
+
width,
|
|
57
|
+
height,
|
|
58
|
+
anchorHandle: crossedHandle(context.handle, crossedX, crossedY)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
commit(context, rawState) {
|
|
62
|
+
const state = rawState;
|
|
63
|
+
const element = context.designItem.element;
|
|
64
|
+
const width = element.style.width;
|
|
65
|
+
const height = element.style.height;
|
|
66
|
+
element.style.width = state.originalWidth;
|
|
67
|
+
element.style.height = state.originalHeight;
|
|
68
|
+
context.designItem.setStyle('width', width);
|
|
69
|
+
context.designItem.setStyle('height', height);
|
|
70
|
+
}
|
|
71
|
+
cancel(context, rawState) {
|
|
72
|
+
const state = rawState;
|
|
73
|
+
const element = context.designItem.element;
|
|
74
|
+
element.style.width = state.originalWidth;
|
|
75
|
+
element.style.height = state.originalHeight;
|
|
76
|
+
element.style.left = state.originalLeft;
|
|
77
|
+
element.style.top = state.originalTop;
|
|
78
|
+
element.style.right = state.originalRight;
|
|
79
|
+
element.style.bottom = state.originalBottom;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AbstractPropertiesService, IDesignItem, IProperty, RefreshMode, ValueType } from '@node-projects/web-component-designer';
|
|
2
|
+
export declare class ZplIncludeInOutputPropertiesService extends AbstractPropertiesService {
|
|
3
|
+
name: string;
|
|
4
|
+
getRefreshMode(): RefreshMode;
|
|
5
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
6
|
+
getProperties(): Promise<IProperty[]>;
|
|
7
|
+
getValue(designItems: IDesignItem[]): boolean;
|
|
8
|
+
getUnsetValue(): boolean;
|
|
9
|
+
isSet(): ValueType;
|
|
10
|
+
setValue(designItems: IDesignItem[], _property: IProperty, value: boolean): Promise<void>;
|
|
11
|
+
clearValue(designItems: IDesignItem[], property: IProperty): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AbstractPropertiesService, PropertyType, RefreshMode, ValueType } from '@node-projects/web-component-designer';
|
|
2
|
+
const includeProperty = {
|
|
3
|
+
name: 'includeInZplOutput',
|
|
4
|
+
displayName: 'Include in ZPL output',
|
|
5
|
+
type: 'boolean',
|
|
6
|
+
propertyType: PropertyType.attribute,
|
|
7
|
+
attributeName: 'node-projects-hide-at-run-time',
|
|
8
|
+
defaultValue: true,
|
|
9
|
+
description: 'When disabled, the item is preserved in metadata comments but omitted from printer output.'
|
|
10
|
+
};
|
|
11
|
+
export class ZplIncludeInOutputPropertiesService extends AbstractPropertiesService {
|
|
12
|
+
name = 'zplIncludeInOutput';
|
|
13
|
+
getRefreshMode() {
|
|
14
|
+
return RefreshMode.fullOnValueChange;
|
|
15
|
+
}
|
|
16
|
+
isHandledElement(designItem) {
|
|
17
|
+
return !designItem.isRootItem && designItem.element.localName.startsWith('zpl-');
|
|
18
|
+
}
|
|
19
|
+
async getProperties() {
|
|
20
|
+
return [{ ...includeProperty, service: this }];
|
|
21
|
+
}
|
|
22
|
+
getValue(designItems) {
|
|
23
|
+
return designItems.length > 0 && designItems.every(item => !item.hideAtRunTime);
|
|
24
|
+
}
|
|
25
|
+
getUnsetValue() {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
isSet() {
|
|
29
|
+
return ValueType.all;
|
|
30
|
+
}
|
|
31
|
+
async setValue(designItems, _property, value) {
|
|
32
|
+
if (designItems.length === 0)
|
|
33
|
+
return;
|
|
34
|
+
const group = designItems[0].openGroup(value ? 'Include in ZPL output' : 'Exclude from ZPL output');
|
|
35
|
+
try {
|
|
36
|
+
for (const designItem of designItems) {
|
|
37
|
+
if (this.isHandledElement(designItem))
|
|
38
|
+
designItem.hideAtRunTime = !value;
|
|
39
|
+
}
|
|
40
|
+
group.commit();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
group.abort();
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
clearValue(designItems, property) {
|
|
48
|
+
void this.setValue(designItems, property, true);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDesignItem, IHtmlParserService, IHtmlWriterOptions, IHtmlWriterService, InstanceServiceContainer, ITextWriter, ServiceContainer } from '@node-projects/web-component-designer';
|
|
2
|
+
export { createHiddenZplComments, decodeHiddenZplComments, tokenizeZpl } from './hiddenMetadata.js';
|
|
3
|
+
/** Zebra uses zero/omitted width as the natural aspect ratio. */
|
|
4
|
+
export declare const parseZplFontWidth: (value: string | undefined) => number;
|
|
2
5
|
export declare class ZplParserService implements IHtmlParserService, IHtmlWriterService {
|
|
3
6
|
options: IHtmlWriterOptions;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
write(textWriter: ITextWriter, designItems: IDesignItem[],
|
|
7
|
+
parse(source: string, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, _parseSnippet: boolean): Promise<IDesignItem[]>;
|
|
8
|
+
private _parse;
|
|
9
|
+
write(textWriter: ITextWriter, designItems: IDesignItem[], _rootContainerKeepInline: boolean, updatePositions?: boolean): void;
|
|
7
10
|
}
|