@hprint/plugins 0.0.1 → 0.0.3
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/dist/index.js +76 -76
- package/dist/index.mjs +7397 -7275
- package/dist/src/plugins/BarCodePlugin.d.ts +10 -0
- package/dist/src/plugins/BarCodePlugin.d.ts.map +1 -1
- package/dist/src/plugins/CreateElementPlugin.d.ts +1 -0
- package/dist/src/plugins/CreateElementPlugin.d.ts.map +1 -1
- package/dist/src/plugins/UnitPlugin.d.ts +1 -1
- package/dist/src/plugins/UnitPlugin.d.ts.map +1 -1
- package/dist/src/utils/units.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/plugins/AlignGuidLinePlugin.ts +1152 -1152
- package/src/plugins/BarCodePlugin.ts +69 -3
- package/src/plugins/CreateElementPlugin.ts +182 -16
- package/src/plugins/GroupAlignPlugin.ts +365 -365
- package/src/plugins/LockPlugin.ts +242 -242
- package/src/plugins/ResizePlugin.ts +278 -278
- package/src/plugins/RulerPlugin.ts +78 -78
- package/src/plugins/UnitPlugin.ts +348 -326
- package/src/plugins/WaterMarkPlugin.ts +257 -257
- package/src/utils/ruler/ruler.ts +936 -936
- package/src/utils/units.ts +10 -0
package/src/utils/units.ts
CHANGED
|
@@ -31,9 +31,14 @@ export function applyMmToObject(
|
|
|
31
31
|
if (strokeWidthPx !== undefined) obj.set('strokeWidth', strokeWidthPx);
|
|
32
32
|
if (fontSizePx !== undefined) (obj as any).fontSize = fontSizePx;
|
|
33
33
|
|
|
34
|
+
// Preserve ALL existing fields from _originSize.mm to prevent data loss
|
|
35
|
+
const existingMm = (obj as any)._originSize?.mm || {};
|
|
36
|
+
|
|
34
37
|
(obj as any)._originSize = {
|
|
35
38
|
...(obj as any)._originSize,
|
|
36
39
|
mm: {
|
|
40
|
+
...existingMm, // Preserve all existing fields first
|
|
41
|
+
// Then update only the provided fields
|
|
37
42
|
left: mm.left,
|
|
38
43
|
top: mm.top,
|
|
39
44
|
width: mm.width,
|
|
@@ -56,9 +61,14 @@ export function syncMmFromObject(obj: fabric.Object, dpi?: number, precision?: n
|
|
|
56
61
|
const strokeWidth = obj.strokeWidth as number | undefined;
|
|
57
62
|
const fontSize = (obj as any).fontSize as number | undefined;
|
|
58
63
|
|
|
64
|
+
// Preserve ALL existing fields from _originSize.mm to prevent data loss
|
|
65
|
+
const existingMm = (obj as any)._originSize?.mm || {};
|
|
66
|
+
|
|
59
67
|
(obj as any)._originSize = {
|
|
60
68
|
...(obj as any)._originSize,
|
|
61
69
|
mm: {
|
|
70
|
+
...existingMm, // Preserve all existing fields first
|
|
71
|
+
// Then update only the synced fields
|
|
62
72
|
left: toMm(left),
|
|
63
73
|
top: toMm(top),
|
|
64
74
|
width: toMm(width),
|