@node-projects/web-component-designer-zpl 0.2.1 → 0.3.1
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 +70 -0
- package/dist/barcodes/bwipRenderer.js +552 -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 +2 -1
- package/dist/widgets/zpl-barcode.d.ts +68 -14
- package/dist/widgets/zpl-barcode.js +162 -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 -13
- 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,9 @@
|
|
|
1
|
+
import { IDesignItem, IDesignerCanvas, IExtensionManager, SelectionDefaultExtensionProvider } from '@node-projects/web-component-designer';
|
|
2
|
+
/**
|
|
3
|
+
* Graphic circles and diagonal lines already describe their complete visual
|
|
4
|
+
* boundary. A rectangular selection outline obscures that geometry, so those
|
|
5
|
+
* widgets use resize handles without the generic selection rectangle.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ZplSelectionExtensionProvider extends SelectionDefaultExtensionProvider {
|
|
8
|
+
shouldExtend(extensionManager: IExtensionManager, designerCanvas: IDesignerCanvas, designItem: IDesignItem): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SelectionDefaultExtensionProvider } from '@node-projects/web-component-designer';
|
|
2
|
+
import { ZplGraphicCircle } from '../widgets/zpl-graphic-circle.js';
|
|
3
|
+
import { ZplGraphicDiagonalLine } from '../widgets/zpl-graphic-diagonal-line.js';
|
|
4
|
+
/**
|
|
5
|
+
* Graphic circles and diagonal lines already describe their complete visual
|
|
6
|
+
* boundary. A rectangular selection outline obscures that geometry, so those
|
|
7
|
+
* widgets use resize handles without the generic selection rectangle.
|
|
8
|
+
*/
|
|
9
|
+
export class ZplSelectionExtensionProvider extends SelectionDefaultExtensionProvider {
|
|
10
|
+
shouldExtend(extensionManager, designerCanvas, designItem) {
|
|
11
|
+
if (designItem.element instanceof ZplGraphicCircle || designItem.element instanceof ZplGraphicDiagonalLine)
|
|
12
|
+
return false;
|
|
13
|
+
return super.shouldExtend(extensionManager, designerCanvas, designItem);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractExtension, IDesignItem, IDesignerCanvas, IDesignerExtensionProvider, IExtensionManager } from '@node-projects/web-component-designer';
|
|
2
|
+
/** In-place plain-text editor for the shadow-DOM based ZPL text widget. */
|
|
3
|
+
export declare class ZplTextEditExtension extends AbstractExtension {
|
|
4
|
+
private _selectionChangedListener?;
|
|
5
|
+
private _finished;
|
|
6
|
+
private _originalContent;
|
|
7
|
+
private _previousClickOverlayPointerEvents;
|
|
8
|
+
constructor(extensionManager: IExtensionManager, designerCanvas: IDesignerCanvas, extendedItem: IDesignItem);
|
|
9
|
+
extend(): void;
|
|
10
|
+
refresh(): void;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
private _onInput;
|
|
13
|
+
private _onKeyDown;
|
|
14
|
+
private _onDocumentPointerDown;
|
|
15
|
+
private _finish;
|
|
16
|
+
}
|
|
17
|
+
export declare class ZplTextEditExtensionProvider implements IDesignerExtensionProvider {
|
|
18
|
+
shouldExtend(_extensionManager: IExtensionManager, designerCanvas: IDesignerCanvas, designItem: IDesignItem): boolean;
|
|
19
|
+
getExtension(extensionManager: IExtensionManager, designerCanvas: IDesignerCanvas, designItem: IDesignItem): ZplTextEditExtension;
|
|
20
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { AbstractExtension } from '@node-projects/web-component-designer';
|
|
2
|
+
import { ZplText } from '../widgets/zpl-text.js';
|
|
3
|
+
/** In-place plain-text editor for the shadow-DOM based ZPL text widget. */
|
|
4
|
+
export class ZplTextEditExtension extends AbstractExtension {
|
|
5
|
+
_selectionChangedListener;
|
|
6
|
+
_finished = false;
|
|
7
|
+
_originalContent = '';
|
|
8
|
+
_previousClickOverlayPointerEvents = '';
|
|
9
|
+
constructor(extensionManager, designerCanvas, extendedItem) {
|
|
10
|
+
super(extensionManager, designerCanvas, extendedItem);
|
|
11
|
+
this._onKeyDown = this._onKeyDown.bind(this);
|
|
12
|
+
this._onInput = this._onInput.bind(this);
|
|
13
|
+
this._onDocumentPointerDown = this._onDocumentPointerDown.bind(this);
|
|
14
|
+
}
|
|
15
|
+
extend() {
|
|
16
|
+
const element = this.extendedItem.element;
|
|
17
|
+
this._originalContent = this.extendedItem.getAttribute('content') ?? '';
|
|
18
|
+
// Clearing the selection removes resize/position overlays while the
|
|
19
|
+
// caret is active. Subscribe afterwards so this initial clear does not
|
|
20
|
+
// immediately close the editor.
|
|
21
|
+
this.extendedItem.instanceServiceContainer.selectionService.clearSelectedElements();
|
|
22
|
+
this._selectionChangedListener = this.extendedItem.instanceServiceContainer.selectionService.onSelectionChanged.on(() => this._finish(true));
|
|
23
|
+
this._previousClickOverlayPointerEvents = this.designerCanvas.clickOverlay.style.pointerEvents;
|
|
24
|
+
this.designerCanvas.clickOverlay.style.pointerEvents = 'none';
|
|
25
|
+
element.beginInlineEdit();
|
|
26
|
+
element.inlineEditElement.addEventListener('keydown', this._onKeyDown, true);
|
|
27
|
+
element.inlineEditElement.addEventListener('input', this._onInput);
|
|
28
|
+
element.ownerDocument.addEventListener('pointerdown', this._onDocumentPointerDown, true);
|
|
29
|
+
}
|
|
30
|
+
refresh() { }
|
|
31
|
+
dispose() {
|
|
32
|
+
const element = this.extendedItem.element;
|
|
33
|
+
element.inlineEditElement.removeEventListener('keydown', this._onKeyDown, true);
|
|
34
|
+
element.inlineEditElement.removeEventListener('input', this._onInput);
|
|
35
|
+
element.ownerDocument.removeEventListener('pointerdown', this._onDocumentPointerDown, true);
|
|
36
|
+
this._selectionChangedListener?.dispose();
|
|
37
|
+
this.designerCanvas.clickOverlay.style.pointerEvents = this._previousClickOverlayPointerEvents;
|
|
38
|
+
element.finishInlineEdit();
|
|
39
|
+
}
|
|
40
|
+
_onInput(event) {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
this.extendedItem.element.refreshInlineEditBounds();
|
|
43
|
+
}
|
|
44
|
+
_onKeyDown(event) {
|
|
45
|
+
event.stopPropagation();
|
|
46
|
+
if (event.key === 'Enter') {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
this._finish(true);
|
|
49
|
+
}
|
|
50
|
+
else if (event.key === 'Escape') {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
this._finish(false);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
_onDocumentPointerDown(event) {
|
|
56
|
+
const editor = this.extendedItem.element.inlineEditElement;
|
|
57
|
+
if (event.composedPath().includes(editor))
|
|
58
|
+
return;
|
|
59
|
+
this._finish(true);
|
|
60
|
+
}
|
|
61
|
+
_finish(commit) {
|
|
62
|
+
if (this._finished)
|
|
63
|
+
return;
|
|
64
|
+
this._finished = true;
|
|
65
|
+
const element = this.extendedItem.element;
|
|
66
|
+
const newContent = element.inlineEditContent;
|
|
67
|
+
element.finishInlineEdit();
|
|
68
|
+
if (commit && newContent !== this._originalContent)
|
|
69
|
+
this.extendedItem.setAttribute('content', newContent);
|
|
70
|
+
this.extensionManager.removeExtensionInstance(this.extendedItem, this);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class ZplTextEditExtensionProvider {
|
|
74
|
+
shouldExtend(_extensionManager, designerCanvas, designItem) {
|
|
75
|
+
return !designerCanvas.readOnly && designItem.element instanceof ZplText;
|
|
76
|
+
}
|
|
77
|
+
getExtension(extensionManager, designerCanvas, designItem) {
|
|
78
|
+
return new ZplTextEditExtension(extensionManager, designerCanvas, designItem);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AbstractPropertiesService, IDesignItem, IProperty, RefreshMode } from '@node-projects/web-component-designer';
|
|
2
|
+
export declare class ZplTextPropertiesService extends AbstractPropertiesService {
|
|
3
|
+
name: string;
|
|
4
|
+
getRefreshMode(): RefreshMode;
|
|
5
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
6
|
+
protected _notifyChangedProperty(designItem: IDesignItem): void;
|
|
7
|
+
getProperties(): Promise<IProperty[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AbstractPropertiesService, PropertyType, RefreshMode } from '@node-projects/web-component-designer';
|
|
2
|
+
import { ZplText } from '../widgets/zpl-text.js';
|
|
3
|
+
export class ZplTextPropertiesService extends AbstractPropertiesService {
|
|
4
|
+
name = 'zplText';
|
|
5
|
+
getRefreshMode() {
|
|
6
|
+
return RefreshMode.fullOnValueChange;
|
|
7
|
+
}
|
|
8
|
+
isHandledElement(designItem) {
|
|
9
|
+
return designItem.element instanceof ZplText;
|
|
10
|
+
}
|
|
11
|
+
_notifyChangedProperty(designItem) {
|
|
12
|
+
designItem.element.refreshFromAttributes();
|
|
13
|
+
}
|
|
14
|
+
async getProperties() {
|
|
15
|
+
const definitions = [
|
|
16
|
+
{ name: 'content', type: 'string', attributeName: 'content' },
|
|
17
|
+
{ name: 'fontName', displayName: 'font', type: 'enum', attributeName: 'font-name', enumValues: [...'0ABCDEFGH'].map(value => [value, value]) },
|
|
18
|
+
{ name: 'fontHeight', displayName: 'font height', type: 'number', attributeName: 'font-height', min: 1, max: 32000, step: 1 },
|
|
19
|
+
{ name: 'fontWidth', displayName: 'font width (0 = automatic)', description: 'Zero is Zebra automatic width; the selection rectangle still uses the measured printed width.', type: 'number', attributeName: 'font-width', min: 0, max: 32000, step: 1 },
|
|
20
|
+
{ name: 'rotation', type: 'enum', attributeName: 'rotation', enumValues: ['N', 'R', 'I', 'B'].map(value => [value, value]) }
|
|
21
|
+
];
|
|
22
|
+
return definitions.map(property => ({ ...property, service: this, propertyType: PropertyType.attribute }));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ZplToken {
|
|
2
|
+
prefix: '^' | '~';
|
|
3
|
+
command: string;
|
|
4
|
+
data: string;
|
|
5
|
+
}
|
|
6
|
+
export interface HiddenPayload {
|
|
7
|
+
index: number;
|
|
8
|
+
zpl: string;
|
|
9
|
+
comments: Set<string>;
|
|
10
|
+
}
|
|
11
|
+
export declare function tokenizeZpl(source: string): ZplToken[];
|
|
12
|
+
export declare function createHiddenZplComments(index: number, miniZpl: string): string[];
|
|
13
|
+
export declare function hiddenPayloads(tokens: ZplToken[]): HiddenPayload[];
|
|
14
|
+
export declare function decodeHiddenZplComments(source: string): {
|
|
15
|
+
index: number;
|
|
16
|
+
zpl: string;
|
|
17
|
+
}[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const hiddenPrefix = 'NODEPROJECTS-HIDDEN-V1:';
|
|
2
|
+
const hiddenChunkSize = 1024;
|
|
3
|
+
function findCommandStart(source, from, includeTilde = true) {
|
|
4
|
+
for (let index = from; index + 2 < source.length; index++) {
|
|
5
|
+
const prefix = source[index];
|
|
6
|
+
if (prefix !== '^' && (!includeTilde || prefix !== '~'))
|
|
7
|
+
continue;
|
|
8
|
+
if (/^[A-Za-z0-9]{2}$/.test(source.slice(index + 1, index + 3)))
|
|
9
|
+
return index;
|
|
10
|
+
}
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
export function tokenizeZpl(source) {
|
|
14
|
+
const tokens = [];
|
|
15
|
+
let index = 0;
|
|
16
|
+
while (index < source.length) {
|
|
17
|
+
const start = findCommandStart(source, index);
|
|
18
|
+
if (start < 0 || start + 2 >= source.length)
|
|
19
|
+
break;
|
|
20
|
+
const prefix = source[start];
|
|
21
|
+
const command = source.slice(start + 1, start + 3).toUpperCase();
|
|
22
|
+
// Tilde sequences such as ~1 and ~d029 are field data for ^FD, not
|
|
23
|
+
// immediate ZPL commands. Outside a field, ~DG and peers remain tokens.
|
|
24
|
+
const end = findCommandStart(source, start + 3, !(prefix === '^' && command === 'FD'));
|
|
25
|
+
const tokenEnd = end < 0 ? source.length : end;
|
|
26
|
+
tokens.push({ prefix, command, data: source.slice(start + 3, tokenEnd).replace(/[\r\n]/g, '') });
|
|
27
|
+
index = end < 0 ? source.length : end;
|
|
28
|
+
}
|
|
29
|
+
return tokens;
|
|
30
|
+
}
|
|
31
|
+
function encodeBase64Url(value) {
|
|
32
|
+
const bytes = new TextEncoder().encode(value);
|
|
33
|
+
let binary = '';
|
|
34
|
+
for (let offset = 0; offset < bytes.length; offset += 0x8000) {
|
|
35
|
+
binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000));
|
|
36
|
+
}
|
|
37
|
+
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
|
|
38
|
+
}
|
|
39
|
+
function decodeBase64Url(value) {
|
|
40
|
+
const base64 = value.replace(/-/g, '+').replace(/_/g, '/').padEnd(Math.ceil(value.length / 4) * 4, '=');
|
|
41
|
+
const binary = atob(base64);
|
|
42
|
+
const bytes = Uint8Array.from(binary, character => character.charCodeAt(0));
|
|
43
|
+
return new TextDecoder().decode(bytes);
|
|
44
|
+
}
|
|
45
|
+
export function createHiddenZplComments(index, miniZpl) {
|
|
46
|
+
const payload = encodeBase64Url(miniZpl);
|
|
47
|
+
const total = Math.max(1, Math.ceil(payload.length / hiddenChunkSize));
|
|
48
|
+
const comments = [];
|
|
49
|
+
for (let part = 0; part < total; part++) {
|
|
50
|
+
comments.push(`^FX${hiddenPrefix}${index}:${part + 1}/${total}:${payload.slice(part * hiddenChunkSize, (part + 1) * hiddenChunkSize)}^FS`);
|
|
51
|
+
}
|
|
52
|
+
return comments;
|
|
53
|
+
}
|
|
54
|
+
export function hiddenPayloads(tokens) {
|
|
55
|
+
const regex = /^NODEPROJECTS-HIDDEN-V1:(\d+):(\d+)\/(\d+):([A-Za-z0-9_-]+)$/;
|
|
56
|
+
const groups = new Map();
|
|
57
|
+
for (const token of tokens) {
|
|
58
|
+
if (token.prefix !== '^' || token.command !== 'FX')
|
|
59
|
+
continue;
|
|
60
|
+
const match = token.data.match(regex);
|
|
61
|
+
if (!match)
|
|
62
|
+
continue;
|
|
63
|
+
const index = Number(match[1]);
|
|
64
|
+
const part = Number(match[2]);
|
|
65
|
+
const total = Number(match[3]);
|
|
66
|
+
if (!Number.isInteger(index) || part < 1 || total < 1 || part > total)
|
|
67
|
+
continue;
|
|
68
|
+
const group = groups.get(index) ?? { total, parts: new Map(), comments: new Set(), invalid: false };
|
|
69
|
+
if (group.total !== total || group.parts.has(part)) {
|
|
70
|
+
group.invalid = true;
|
|
71
|
+
groups.set(index, group);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
group.parts.set(part, match[4]);
|
|
75
|
+
group.comments.add(token.data);
|
|
76
|
+
groups.set(index, group);
|
|
77
|
+
}
|
|
78
|
+
const result = [];
|
|
79
|
+
for (const [index, group] of groups) {
|
|
80
|
+
if (group.invalid || group.parts.size !== group.total)
|
|
81
|
+
continue;
|
|
82
|
+
try {
|
|
83
|
+
const encoded = Array.from({ length: group.total }, (_, part) => group.parts.get(part + 1) ?? '').join('');
|
|
84
|
+
const zpl = decodeBase64Url(encoded);
|
|
85
|
+
if (!zpl.includes('^XA') || !zpl.includes('^XZ'))
|
|
86
|
+
continue;
|
|
87
|
+
result.push({ index, zpl, comments: group.comments });
|
|
88
|
+
}
|
|
89
|
+
catch { /* malformed metadata remains an ordinary comment */ }
|
|
90
|
+
}
|
|
91
|
+
return result.sort((a, b) => a.index - b.index);
|
|
92
|
+
}
|
|
93
|
+
export function decodeHiddenZplComments(source) {
|
|
94
|
+
return hiddenPayloads(tokenizeZpl(source)).map(({ index, zpl }) => ({ index, zpl }));
|
|
95
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ISize } from '@node-projects/web-component-designer';
|
|
2
|
+
export declare const quantizeZplValue: (value: number, min: number, max: number) => number;
|
|
3
|
+
export declare const zplAxisScales: (rotation: string | null, initial: ISize, current: ISize) => {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const quantizeZplValue = (value, min, max) => Math.max(min, Math.min(max, Math.round(value)));
|
|
2
|
+
export const zplAxisScales = (rotation, initial, current) => {
|
|
3
|
+
const screenWidth = current.width / Math.max(1, initial.width);
|
|
4
|
+
const screenHeight = current.height / Math.max(1, initial.height);
|
|
5
|
+
return ['R', 'B'].includes(rotation ?? 'N')
|
|
6
|
+
? { width: screenHeight, height: screenWidth }
|
|
7
|
+
: { width: screenWidth, height: screenHeight };
|
|
8
|
+
};
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { DefaultPropertyEditorTypesService, DefaultEditorTypeService, ExtensionType, DefaultModelCommandService, DefaultHtmlParserService, JsonFileElementsService, ServiceContainer, PositionExtensionProvider,
|
|
1
|
+
import { DefaultPropertyEditorTypesService, DefaultEditorTypeService, ExtensionType, DefaultModelCommandService, DefaultHtmlParserService, JsonFileElementsService, ServiceContainer, PositionExtensionProvider, GrayOutExtensionProvider, AltToEnterContainerExtensionProvider, NamedTools, PointerTool, RectangleSelectorTool, ZoomTool, PanTool, MagicWandSelectorTool, ZMoveContextMenu, CopyPasteContextMenu, MultipleItemsSelectedContextMenu, ItemsBelowContextMenu, ElementDragTitleExtensionProvider, PointerToolButtonProvider, SeperatorToolProvider, SelectorToolButtonProvider, ZoomToolButtonProvider, HighlightElementExtensionProvider, SelectionService, UndoService, GrayOutDragOverContainerExtensionProvider, ElementAtPointService, SnaplinesProviderService, DefaultInstanceService, PropertyGroupsService, DesignItemDocumentPositionService, DragDropService, BaseCustomWebComponentPropertiesService, TransformToolButtonProvider, DesignItemService, DeletionService, ResizeExtensionProvider } from '@node-projects/web-component-designer';
|
|
2
2
|
import { ZplLayoutPlacementService } from './services/ZplLayoutPlacementService.js';
|
|
3
3
|
import { ZplParserService } from './services/ZplParserService.js';
|
|
4
4
|
import { ZplImageDrop } from './services/ZplImageDrop.js';
|
|
5
5
|
import { ZplLayoutCopyPasteService } from './services/ZplLayoutCopyPasteService.js';
|
|
6
|
-
import { ZplLayoutResizeExtensionProvider } from './extensions/ZplLayoutResizeExtensionProvider.js';
|
|
7
6
|
import { ZplDemoView } from './widgets/views/zpl-demo-view.js';
|
|
7
|
+
import { ZplBarcodePropertiesService } from './services/ZplBarcodePropertiesService.js';
|
|
8
|
+
import { ZplIncludeInOutputPropertiesService } from './services/ZplIncludeInOutputPropertiesService.js';
|
|
9
|
+
import { ZplBarcodeElementsService } from './services/ZplBarcodeElementsService.js';
|
|
10
|
+
import { ZplElementResizeStrategy } from './services/ZplElementResizeStrategy.js';
|
|
11
|
+
import { ZplTextPropertiesService } from './services/ZplTextPropertiesService.js';
|
|
12
|
+
import { ZplGraphicResizeStrategy } from './services/ZplGraphicResizeStrategy.js';
|
|
13
|
+
import { ZplSelectionExtensionProvider } from './services/ZplSelectionExtensionProvider.js';
|
|
14
|
+
import { ZplDiagonalLineExtensionProvider } from './services/ZplDiagonalLineExtension.js';
|
|
15
|
+
import { ZplTextEditExtensionProvider } from './services/ZplTextEditExtension.js';
|
|
8
16
|
export function createZplDesignerServiceContainer() {
|
|
9
17
|
let serviceContainer = new ServiceContainer();
|
|
10
18
|
serviceContainer.register("instanceService", new DefaultInstanceService());
|
|
@@ -22,6 +30,11 @@ export function createZplDesignerServiceContainer() {
|
|
|
22
30
|
serviceContainer.register("propertyEditorTypesService", new DefaultPropertyEditorTypesService());
|
|
23
31
|
serviceContainer.register("propertyGroupsService", new PropertyGroupsService());
|
|
24
32
|
serviceContainer.register("propertyService", new BaseCustomWebComponentPropertiesService(true));
|
|
33
|
+
serviceContainer.register("propertyService", new ZplBarcodePropertiesService());
|
|
34
|
+
serviceContainer.register("propertyService", new ZplTextPropertiesService());
|
|
35
|
+
serviceContainer.register("attachedPropertyService", new ZplIncludeInOutputPropertiesService());
|
|
36
|
+
serviceContainer.register("elementResizeStrategy", new ZplElementResizeStrategy());
|
|
37
|
+
serviceContainer.register("elementResizeStrategy", new ZplGraphicResizeStrategy());
|
|
25
38
|
serviceContainer.register("designItemService", new DesignItemService());
|
|
26
39
|
serviceContainer.register("deletionService", new DeletionService());
|
|
27
40
|
serviceContainer.register("undoService", (designerCanvas) => new UndoService(designerCanvas));
|
|
@@ -31,15 +44,19 @@ export function createZplDesignerServiceContainer() {
|
|
|
31
44
|
serviceContainer.designerExtensions.set(ExtensionType.PrimarySelection, [
|
|
32
45
|
new ElementDragTitleExtensionProvider(),
|
|
33
46
|
new PositionExtensionProvider(),
|
|
34
|
-
new
|
|
47
|
+
new ZplDiagonalLineExtensionProvider(),
|
|
48
|
+
new ResizeExtensionProvider(false)
|
|
35
49
|
]);
|
|
36
50
|
serviceContainer.designerExtensions.set(ExtensionType.Selection, [
|
|
37
|
-
new
|
|
51
|
+
new ZplSelectionExtensionProvider()
|
|
38
52
|
]);
|
|
39
53
|
serviceContainer.designerExtensions.set(ExtensionType.PrimarySelectionContainer, []);
|
|
40
54
|
serviceContainer.designerExtensions.set(ExtensionType.MouseOver, [
|
|
41
55
|
new HighlightElementExtensionProvider()
|
|
42
56
|
]);
|
|
57
|
+
serviceContainer.designerExtensions.set(ExtensionType.Doubleclick, [
|
|
58
|
+
new ZplTextEditExtensionProvider()
|
|
59
|
+
]);
|
|
43
60
|
serviceContainer.designerExtensions.set(ExtensionType.ContainerDrag, [
|
|
44
61
|
new GrayOutExtensionProvider()
|
|
45
62
|
]);
|
|
@@ -65,5 +82,6 @@ export function createZplDesignerServiceContainer() {
|
|
|
65
82
|
serviceContainer.designViewToolbarButtons.push(new PointerToolButtonProvider(), new SeperatorToolProvider(22), new SelectorToolButtonProvider(), new SeperatorToolProvider(22), new ZoomToolButtonProvider(), new SeperatorToolProvider(22), new TransformToolButtonProvider());
|
|
66
83
|
serviceContainer.config.demoViewWidget = ZplDemoView;
|
|
67
84
|
serviceContainer.register('elementsService', new JsonFileElementsService('zpl', new URL("./widgets/elements.json", import.meta.url)));
|
|
85
|
+
serviceContainer.register('elementsService', new ZplBarcodeElementsService());
|
|
68
86
|
return serviceContainer;
|
|
69
87
|
}
|
|
@@ -1,29 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"elements": [
|
|
3
|
-
{
|
|
4
|
-
"name": "barcode",
|
|
5
|
-
"tag": "zpl-barcode",
|
|
6
|
-
"type": "polymer",
|
|
7
|
-
"defaultAttributes": {
|
|
8
|
-
"content": "barcode",
|
|
9
|
-
"type": "CODE128",
|
|
10
|
-
"width": "2",
|
|
11
|
-
"ratio": "20",
|
|
12
|
-
"height": "200"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"name": "qr-code",
|
|
17
|
-
"tag": "zpl-barcode",
|
|
18
|
-
"type": "polymer",
|
|
19
|
-
"defaultAttributes": {
|
|
20
|
-
"content": "barcode",
|
|
21
|
-
"type": "QR",
|
|
22
|
-
"width": "0",
|
|
23
|
-
"ratio": "0",
|
|
24
|
-
"height": "5"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
3
|
{
|
|
28
4
|
"name": "graphic box",
|
|
29
5
|
"tag": "zpl-graphic-box",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseCustomWebComponentConstructorAppend, css, html } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { zplPreviewDpmm } from '../../barcodes/bwipRenderer.js';
|
|
2
3
|
export class ZplDemoView extends BaseCustomWebComponentConstructorAppend {
|
|
3
4
|
static template = html `<h2>Label generated via http://api.labelary.com/</h2><br><img id="image">`;
|
|
4
5
|
static style = css `
|
|
@@ -22,7 +23,7 @@ export class ZplDemoView extends BaseCustomWebComponentConstructorAppend {
|
|
|
22
23
|
async display(serviceContainer, instanceServiceContainer, code, style) {
|
|
23
24
|
const width = 4;
|
|
24
25
|
const height = 6;
|
|
25
|
-
const dpmm =
|
|
26
|
+
const dpmm = `${zplPreviewDpmm}dpmm`;
|
|
26
27
|
const response = await fetch(`https://api.labelary.com/v1/printers/${dpmm}/labels/${width}x${height}/${0}`, {
|
|
27
28
|
method: "POST",
|
|
28
29
|
body: code,
|
|
@@ -1,25 +1,79 @@
|
|
|
1
|
-
import { BaseCustomWebComponentConstructorAppend } from
|
|
2
|
-
import {
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { BarcodeProps, BarcodeRotation, BarcodeType } from '../barcodes/barcodeRegistry.js';
|
|
3
3
|
export declare class ZplBarcode extends BaseCustomWebComponentConstructorAppend {
|
|
4
4
|
static readonly style: CSSStyleSheet;
|
|
5
5
|
static readonly template: HTMLTemplateElement;
|
|
6
6
|
static readonly is = "zpl-barcode";
|
|
7
|
+
static get observedAttributes(): readonly string[];
|
|
7
8
|
content: string;
|
|
8
|
-
type:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
type: BarcodeType;
|
|
10
|
+
rotation: BarcodeRotation;
|
|
11
|
+
moduleWidth: number;
|
|
12
|
+
wideRatio: number;
|
|
13
|
+
barHeight: number;
|
|
14
|
+
printInterpretation: boolean;
|
|
15
|
+
printInterpretationAbove: boolean;
|
|
16
|
+
checkDigit: boolean;
|
|
17
|
+
magnification: number;
|
|
18
|
+
dimension: number;
|
|
19
|
+
rowHeight: number;
|
|
20
|
+
columns: number;
|
|
21
|
+
rows: number;
|
|
22
|
+
mode: string | number;
|
|
23
|
+
securityLevel: string | number;
|
|
24
|
+
errorCorrection: string;
|
|
25
|
+
quality: number;
|
|
26
|
+
gs1: boolean;
|
|
27
|
+
aspectRatio: number;
|
|
28
|
+
symbology: number;
|
|
29
|
+
segments: number;
|
|
30
|
+
ecLevel: number;
|
|
31
|
+
model: number;
|
|
32
|
+
symbolNumber: number;
|
|
33
|
+
symbolTotal: number;
|
|
34
|
+
microPdfModuleWidth: number;
|
|
35
|
+
microPdfRowHeight: number;
|
|
14
36
|
static readonly properties: {
|
|
15
37
|
content: StringConstructor;
|
|
16
|
-
type:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
rotation: StringConstructor;
|
|
40
|
+
moduleWidth: NumberConstructor;
|
|
41
|
+
wideRatio: NumberConstructor;
|
|
42
|
+
barHeight: NumberConstructor;
|
|
43
|
+
printInterpretation: BooleanConstructor;
|
|
44
|
+
printInterpretationAbove: BooleanConstructor;
|
|
45
|
+
checkDigit: BooleanConstructor;
|
|
46
|
+
magnification: NumberConstructor;
|
|
47
|
+
dimension: NumberConstructor;
|
|
48
|
+
rowHeight: NumberConstructor;
|
|
49
|
+
columns: NumberConstructor;
|
|
50
|
+
rows: NumberConstructor;
|
|
51
|
+
mode: StringConstructor;
|
|
52
|
+
securityLevel: StringConstructor;
|
|
53
|
+
errorCorrection: StringConstructor;
|
|
54
|
+
quality: NumberConstructor;
|
|
55
|
+
gs1: BooleanConstructor;
|
|
56
|
+
aspectRatio: NumberConstructor;
|
|
57
|
+
symbology: NumberConstructor;
|
|
58
|
+
segments: NumberConstructor;
|
|
59
|
+
ecLevel: NumberConstructor;
|
|
60
|
+
model: NumberConstructor;
|
|
61
|
+
symbolNumber: NumberConstructor;
|
|
62
|
+
symbolTotal: NumberConstructor;
|
|
63
|
+
microPdfModuleWidth: NumberConstructor;
|
|
64
|
+
microPdfRowHeight: NumberConstructor;
|
|
20
65
|
};
|
|
66
|
+
private _surface;
|
|
67
|
+
private _frame;
|
|
68
|
+
private _hri;
|
|
69
|
+
private _error;
|
|
70
|
+
private _widgetReady;
|
|
21
71
|
constructor();
|
|
22
|
-
ready():
|
|
23
|
-
|
|
72
|
+
ready(): void;
|
|
73
|
+
refreshFromAttributes(): void;
|
|
74
|
+
attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
|
|
75
|
+
get barcodeProps(): BarcodeProps;
|
|
76
|
+
renderBarcode(): void;
|
|
77
|
+
private _setRotatedBounds;
|
|
24
78
|
createZpl(): string;
|
|
25
79
|
}
|