@pdfme/ui 4.2.1 → 4.2.2-dev.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/package.json
CHANGED
@@ -75,21 +75,34 @@ const DetailView = (
|
|
75
75
|
form.setValues(values);
|
76
76
|
}, [form, activeSchema]);
|
77
77
|
|
78
|
-
const handleWatch = (
|
78
|
+
const handleWatch = (formSchema: any) => {
|
79
|
+
const formAndSchemaValuesDiffer = (formValue: any, schemaValue: any): boolean => {
|
80
|
+
if (typeof formValue === 'object') {
|
81
|
+
return JSON.stringify(formValue) !== JSON.stringify(schemaValue);
|
82
|
+
}
|
83
|
+
return formValue !== schemaValue;
|
84
|
+
}
|
85
|
+
|
79
86
|
let changes: ChangeSchemaItem[] = [];
|
80
|
-
for (let key in
|
87
|
+
for (let key in formSchema) {
|
81
88
|
if (['id', 'content'].includes(key)) continue;
|
82
89
|
|
83
|
-
|
84
|
-
|
85
|
-
|
90
|
+
let value = formSchema[key];
|
91
|
+
let changed = false;
|
92
|
+
|
93
|
+
if (['x', 'y'].includes(key)) {
|
94
|
+
// [position] Return the flattened position to its original form.
|
95
|
+
changed = value !== (activeSchema as any)['position'][key];
|
96
|
+
key = 'position.' + key;
|
97
|
+
} else {
|
98
|
+
changed = formAndSchemaValuesDiffer(value, (activeSchema as any)[key]);
|
99
|
+
}
|
86
100
|
|
87
|
-
if (
|
88
|
-
let value = newSchema[key];
|
101
|
+
if (changed) {
|
89
102
|
// FIXME memo: https://github.com/pdfme/pdfme/pull/367#issuecomment-1857468274
|
90
103
|
if (value === null && ['rotate', 'opacity'].includes(key)) value = undefined;
|
91
104
|
|
92
|
-
changes.push({
|
105
|
+
changes.push({key, value, schemaId: activeSchema.id});
|
93
106
|
}
|
94
107
|
}
|
95
108
|
|
package/src/helper.ts
CHANGED
@@ -454,10 +454,15 @@ const handleTypeChange = (
|
|
454
454
|
delete schema[key as keyof typeof schema];
|
455
455
|
}
|
456
456
|
});
|
457
|
+
// Apply attributes from new defaultSchema
|
457
458
|
const propPanel = Object.values(pluginsRegistry).find(
|
458
459
|
(plugin) => plugin?.propPanel.defaultSchema.type === value
|
459
460
|
)?.propPanel;
|
460
|
-
Object.
|
461
|
+
Object.keys(propPanel?.defaultSchema || {}).forEach((key) => {
|
462
|
+
if (!schema.hasOwnProperty(key)) {
|
463
|
+
(schema as any)[key] = propPanel?.defaultSchema[key];
|
464
|
+
}
|
465
|
+
});
|
461
466
|
};
|
462
467
|
|
463
468
|
export const changeSchemas = (args: {
|