x4js 1.4.30 → 1.4.33
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/lib/component.js +8 -0
- package/lib/drawtext.d.ts +1 -0
- package/lib/drawtext.js +9 -3
- package/package.json +1 -1
- package/src/component.ts +10 -0
- package/src/drawtext.ts +12 -3
- package/tsconfig.json +2 -2
package/lib/component.js
CHANGED
|
@@ -1664,6 +1664,11 @@ class Container extends Component {
|
|
|
1664
1664
|
seq = seq.replace(/CTRL/i, '');
|
|
1665
1665
|
reseq += 'ctrl+';
|
|
1666
1666
|
}
|
|
1667
|
+
let cmd = seq.match(/CMD/i);
|
|
1668
|
+
if (cmd) {
|
|
1669
|
+
seq = seq.replace(/CMD/i, '');
|
|
1670
|
+
reseq += 'cmd+';
|
|
1671
|
+
}
|
|
1667
1672
|
let alt = seq.match(/ALT/i);
|
|
1668
1673
|
if (alt) {
|
|
1669
1674
|
seq = seq.replace(/ALT/i, '');
|
|
@@ -1698,6 +1703,9 @@ class Container extends Component {
|
|
|
1698
1703
|
if (e.ctrlKey) {
|
|
1699
1704
|
seq += 'ctrl+';
|
|
1700
1705
|
}
|
|
1706
|
+
if (e.metaKey) {
|
|
1707
|
+
seq += 'cmd+';
|
|
1708
|
+
}
|
|
1701
1709
|
if (e.altKey) {
|
|
1702
1710
|
seq += 'alt+';
|
|
1703
1711
|
}
|
package/lib/drawtext.d.ts
CHANGED
package/lib/drawtext.js
CHANGED
|
@@ -200,7 +200,8 @@ function drawText(ctx, input_Text, rc, drawStyle) {
|
|
|
200
200
|
break;
|
|
201
201
|
}
|
|
202
202
|
//print all lines of text
|
|
203
|
-
let idx = 1, yy = 0;
|
|
203
|
+
//let idx = 1, yy = 0;
|
|
204
|
+
let maxw = 0;
|
|
204
205
|
textarray.some(line => {
|
|
205
206
|
//console.log( idx++, yy );
|
|
206
207
|
line.space = spaceW;
|
|
@@ -208,6 +209,7 @@ function drawText(ctx, input_Text, rc, drawStyle) {
|
|
|
208
209
|
_justify(line, col_width, spaceW);
|
|
209
210
|
}
|
|
210
211
|
let x = col_left;
|
|
212
|
+
let cw = 0;
|
|
211
213
|
if (align == 1) {
|
|
212
214
|
x += col_width - line.width;
|
|
213
215
|
}
|
|
@@ -234,9 +236,13 @@ function drawText(ctx, input_Text, rc, drawStyle) {
|
|
|
234
236
|
ctx.stroke( );*/
|
|
235
237
|
ctx.fillText(w.text, x, y);
|
|
236
238
|
x += w.width + line.space;
|
|
239
|
+
cw += w.width + line.space;
|
|
237
240
|
});
|
|
238
241
|
y += lineHeight;
|
|
239
|
-
yy += lineHeight;
|
|
242
|
+
//yy += lineHeight;
|
|
243
|
+
if (maxw < cw) {
|
|
244
|
+
maxw = cw;
|
|
245
|
+
}
|
|
240
246
|
if (y > (rc.bottom + lineHeight)) {
|
|
241
247
|
y = col_top;
|
|
242
248
|
col_left += col_width + gap;
|
|
@@ -248,7 +254,7 @@ function drawText(ctx, input_Text, rc, drawStyle) {
|
|
|
248
254
|
ctx.restore();
|
|
249
255
|
//console.timeEnd( 'drawtext' );
|
|
250
256
|
// todo autogrow + multi-columns
|
|
251
|
-
return { height: (textarray.length + 0.3) * lineHeight };
|
|
257
|
+
return { width: maxw, height: (textarray.length + 0.3) * lineHeight };
|
|
252
258
|
}
|
|
253
259
|
exports.drawText = drawText;
|
|
254
260
|
// Calculate Height of the font
|
package/package.json
CHANGED
package/src/component.ts
CHANGED
|
@@ -2251,6 +2251,12 @@ export class Container<P extends ContainerProps = ContainerProps, E extends Cont
|
|
|
2251
2251
|
reseq += 'ctrl+';
|
|
2252
2252
|
}
|
|
2253
2253
|
|
|
2254
|
+
let cmd = seq.match(/CMD/i);
|
|
2255
|
+
if (cmd) {
|
|
2256
|
+
seq = seq.replace(/CMD/i, '');
|
|
2257
|
+
reseq += 'cmd+';
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2254
2260
|
let alt = seq.match(/ALT/i);
|
|
2255
2261
|
if (alt) {
|
|
2256
2262
|
seq = seq.replace(/ALT/i, '');
|
|
@@ -2295,6 +2301,10 @@ export class Container<P extends ContainerProps = ContainerProps, E extends Cont
|
|
|
2295
2301
|
seq += 'ctrl+';
|
|
2296
2302
|
}
|
|
2297
2303
|
|
|
2304
|
+
if (e.metaKey) {
|
|
2305
|
+
seq += 'cmd+';
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2298
2308
|
if (e.altKey) {
|
|
2299
2309
|
seq += 'alt+';
|
|
2300
2310
|
}
|
package/src/drawtext.ts
CHANGED
|
@@ -261,7 +261,9 @@ export function drawText(ctx: CanvasRenderingContext2D, input_Text: string, rc:
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
//print all lines of text
|
|
264
|
-
let idx = 1, yy = 0;
|
|
264
|
+
//let idx = 1, yy = 0;
|
|
265
|
+
|
|
266
|
+
let maxw = 0;
|
|
265
267
|
textarray.some( line => {
|
|
266
268
|
|
|
267
269
|
//console.log( idx++, yy );
|
|
@@ -272,6 +274,8 @@ export function drawText(ctx: CanvasRenderingContext2D, input_Text: string, rc:
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
let x = col_left;
|
|
277
|
+
let cw = 0;
|
|
278
|
+
|
|
275
279
|
if (align == 1) {
|
|
276
280
|
x += col_width - line.width;
|
|
277
281
|
}
|
|
@@ -302,10 +306,15 @@ export function drawText(ctx: CanvasRenderingContext2D, input_Text: string, rc:
|
|
|
302
306
|
|
|
303
307
|
ctx.fillText(w.text, x, y);
|
|
304
308
|
x += w.width + line.space;
|
|
309
|
+
cw += w.width + line.space;
|
|
305
310
|
});
|
|
306
311
|
|
|
307
312
|
y += lineHeight;
|
|
308
|
-
yy += lineHeight;
|
|
313
|
+
//yy += lineHeight;
|
|
314
|
+
|
|
315
|
+
if( maxw<cw ) {
|
|
316
|
+
maxw = cw;
|
|
317
|
+
}
|
|
309
318
|
|
|
310
319
|
if (y > (rc.bottom+lineHeight) ) {
|
|
311
320
|
y = col_top;
|
|
@@ -321,7 +330,7 @@ export function drawText(ctx: CanvasRenderingContext2D, input_Text: string, rc:
|
|
|
321
330
|
//console.timeEnd( 'drawtext' );
|
|
322
331
|
|
|
323
332
|
// todo autogrow + multi-columns
|
|
324
|
-
return { height: (textarray.length+0.3) * lineHeight };
|
|
333
|
+
return { width: maxw, height: (textarray.length+0.3) * lineHeight };
|
|
325
334
|
}
|
|
326
335
|
|
|
327
336
|
// Calculate Height of the font
|