iobroker.mywebui 1.37.81 → 1.37.82
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/io-package.json
CHANGED
package/package.json
CHANGED
|
@@ -102,11 +102,21 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
102
102
|
this.applyBindings();
|
|
103
103
|
this.setWidth(this._settings.width);
|
|
104
104
|
this.setHeight(this._settings.height);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
|
|
106
|
+
// Defer zoomToFit until after layout settles (rAF x2 ensures paint cycle completes).
|
|
107
|
+
// Without this, getBoundingClientRect().height may be 0 → zoomFactor=0 → invisible canvas.
|
|
108
|
+
requestAnimationFrame(() => {
|
|
109
|
+
requestAnimationFrame(() => {
|
|
110
|
+
const cvRect = this.documentContainer.designerView.designerCanvas.getBoundingClientRect();
|
|
111
|
+
if (cvRect.height > 0) {
|
|
112
|
+
this.documentContainer.designerView.zoomToFit();
|
|
113
|
+
} else {
|
|
114
|
+
// Layout not ready yet — keep zoomFactor=1 so canvas stays visible
|
|
115
|
+
this.documentContainer.designerView.designerCanvas.zoomFactor = 1;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
110
120
|
this.documentContainer.designerView.designerCanvas.onContentChanged?.on(() => {
|
|
111
121
|
this.applyBindings();
|
|
112
122
|
});
|
|
@@ -182,11 +192,8 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
182
192
|
try {
|
|
183
193
|
if (window.appShell.controlpropertiesEditor.getProperties) {
|
|
184
194
|
prp = window.appShell.controlpropertiesEditor.getProperties();
|
|
185
|
-
console.log('✅ [Save] Got properties from editor:', prp);
|
|
186
195
|
} else {
|
|
187
|
-
// Fallback: direct access to propertiesObj
|
|
188
196
|
prp = window.appShell.controlpropertiesEditor.propertiesObj;
|
|
189
|
-
console.log('ℹ️ [Save] Got properties via propertiesObj:', prp);
|
|
190
197
|
}
|
|
191
198
|
|
|
192
199
|
// Update local copy
|
|
@@ -201,7 +208,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
201
208
|
// Final fallback
|
|
202
209
|
if (!prp || Object.keys(prp).length === 0) {
|
|
203
210
|
prp = this.properties || null;
|
|
204
|
-
console.log('ℹ️ [Save] Using fallback this.properties:', prp);
|
|
205
211
|
}
|
|
206
212
|
|
|
207
213
|
// Visibility configs are now stored as HTML attributes (data-visibility-*)
|
|
@@ -225,7 +231,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
225
231
|
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
226
232
|
|
|
227
233
|
this._settings._visibilityHash = hashHex;
|
|
228
|
-
console.log('🔐 [Security] Generated visibility settings hash');
|
|
229
234
|
}
|
|
230
235
|
|
|
231
236
|
let screen = { html, style, script, settings: this._settings, properties: prp };
|
|
@@ -234,8 +239,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
234
239
|
else {
|
|
235
240
|
let control = { html, style, script, settings: this._settings, properties: prp };
|
|
236
241
|
await iobrokerHandler.saveObject(this._type, this._name, control);
|
|
237
|
-
// Generate and save thumbnail for custom controls
|
|
238
|
-
console.log('💾 [Thumbnail] Saving custom control, generating thumbnail for:', this._name);
|
|
239
242
|
await this._generateAndSaveThumbnail();
|
|
240
243
|
}
|
|
241
244
|
}
|
|
@@ -243,13 +246,10 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
243
246
|
this.documentContainer.executeCommand(command);
|
|
244
247
|
}
|
|
245
248
|
async _generateAndSaveThumbnail() {
|
|
246
|
-
console.log('🎨 [Thumbnail] Starting thumbnail generation...');
|
|
247
249
|
try {
|
|
248
250
|
const canvas = this.documentContainer.designerView.designerCanvas;
|
|
249
251
|
const rootElement = canvas.rootDesignItem?.element;
|
|
250
|
-
console.log('📐 [Thumbnail] Canvas and root element:', { canvas, rootElement });
|
|
251
252
|
if (!rootElement) {
|
|
252
|
-
console.warn('❌ [Thumbnail] No root element found, skipping thumbnail generation');
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -258,31 +258,20 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
258
258
|
// Method 1: Try to capture using getComputedStyle and manual rendering
|
|
259
259
|
try {
|
|
260
260
|
blob = await this._captureElementManually(rootElement);
|
|
261
|
-
if (blob) {
|
|
262
|
-
console.log('✅ [Thumbnail] Manual capture successful');
|
|
263
|
-
}
|
|
264
261
|
}
|
|
265
262
|
catch (err) {
|
|
266
|
-
|
|
263
|
+
// manual capture failed, use placeholder
|
|
267
264
|
}
|
|
268
|
-
|
|
269
|
-
// Method 2: Fallback to placeholder
|
|
265
|
+
|
|
270
266
|
if (!blob) {
|
|
271
|
-
console.log('🎨 [Thumbnail] Using placeholder thumbnail');
|
|
272
267
|
blob = await this._renderToCanvas(rootElement);
|
|
273
268
|
}
|
|
274
|
-
// Save thumbnail
|
|
275
269
|
if (blob) {
|
|
276
|
-
console.log('✅ [Thumbnail] Thumbnail blob created, size:', blob.size, 'bytes');
|
|
277
270
|
await iobrokerHandler.saveThumbnail(this._name, blob);
|
|
278
|
-
console.log('💾 [Thumbnail] Thumbnail saved successfully for:', this._name);
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
console.warn('❌ [Thumbnail] Failed to create thumbnail blob');
|
|
282
271
|
}
|
|
283
272
|
}
|
|
284
273
|
catch (err) {
|
|
285
|
-
console.error('
|
|
274
|
+
console.error('Thumbnail generation failed:', err);
|
|
286
275
|
}
|
|
287
276
|
}
|
|
288
277
|
async _captureElementManually(rootElement) {
|
|
@@ -298,8 +287,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
298
287
|
if (width < 50) width = 200;
|
|
299
288
|
if (height < 50) height = 150;
|
|
300
289
|
|
|
301
|
-
console.log('📏 [Thumbnail] Element dimensions:', { width, height });
|
|
302
|
-
|
|
303
290
|
// Create canvas
|
|
304
291
|
const canvas = document.createElement('canvas');
|
|
305
292
|
const scale = Math.min(200 / width, 150 / height, 1);
|
|
@@ -314,11 +301,7 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
314
301
|
// Try to render the shadow DOM content
|
|
315
302
|
const shadowRoot = rootElement.shadowRoot;
|
|
316
303
|
if (shadowRoot) {
|
|
317
|
-
console.log('🔍 [Thumbnail] Shadow root found, rendering children...');
|
|
318
|
-
|
|
319
|
-
// Get all visible elements
|
|
320
304
|
const allElements = shadowRoot.querySelectorAll('*');
|
|
321
|
-
console.log('📦 [Thumbnail] Shadow DOM elements count:', allElements.length);
|
|
322
305
|
|
|
323
306
|
let renderedCount = 0;
|
|
324
307
|
for (const element of allElements) {
|
|
@@ -393,7 +376,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
393
376
|
}
|
|
394
377
|
}
|
|
395
378
|
|
|
396
|
-
console.log('✅ [Thumbnail] Rendered', renderedCount, 'elements');
|
|
397
379
|
}
|
|
398
380
|
|
|
399
381
|
return new Promise((resolve) => {
|
|
@@ -440,8 +422,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
440
422
|
if (width < 50) width = 200;
|
|
441
423
|
if (height < 50) height = 150;
|
|
442
424
|
|
|
443
|
-
console.log('📏 [Thumbnail] Capture dimensions:', { width, height });
|
|
444
|
-
|
|
445
425
|
// Create canvas
|
|
446
426
|
const canvas = document.createElement('canvas');
|
|
447
427
|
const scale = Math.min(200 / width, 150 / height, 1);
|
|
@@ -473,8 +453,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
473
453
|
.map(style => style.textContent)
|
|
474
454
|
.join('\n');
|
|
475
455
|
|
|
476
|
-
console.log('📦 [Thumbnail] Content HTML length:', content.length, 'Styles length:', styles.length);
|
|
477
|
-
|
|
478
456
|
if (content) {
|
|
479
457
|
const svgData = `
|
|
480
458
|
<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}">
|
|
@@ -501,7 +479,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
501
479
|
|
|
502
480
|
// If SVG method failed, return simple canvas
|
|
503
481
|
if (!blob) {
|
|
504
|
-
console.log('🎨 [Thumbnail] Using fallback rendering');
|
|
505
482
|
blob = await new Promise(resolve => {
|
|
506
483
|
canvas.toBlob(resolve, 'image/png', 0.95);
|
|
507
484
|
});
|
|
@@ -539,7 +516,6 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
539
516
|
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
540
517
|
canvas.toBlob((blob) => {
|
|
541
518
|
URL.revokeObjectURL(url);
|
|
542
|
-
console.log('✅ [Thumbnail] SVG rendered successfully');
|
|
543
519
|
resolve(blob);
|
|
544
520
|
}, 'image/png', 0.95);
|
|
545
521
|
}
|