@idraw/core 0.4.0-alpha.6 → 0.4.0-beta.0
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/esm/index.d.ts +5 -5
- package/dist/esm/index.js +3 -4
- package/dist/esm/middleware/scroller/index.js +6 -11
- package/dist/esm/middleware/selector/config.d.ts +3 -1
- package/dist/esm/middleware/selector/config.js +3 -1
- package/dist/esm/middleware/selector/draw-wrapper.js +6 -6
- package/dist/esm/middleware/text-editor/index.js +16 -5
- package/dist/index.global.js +211 -150
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -358,21 +358,38 @@ var __privateMethod = (obj, member, method) => {
|
|
|
358
358
|
fontWeight: fontWeight$1,
|
|
359
359
|
strokeWidth
|
|
360
360
|
};
|
|
361
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
362
|
+
if (kind === "m")
|
|
363
|
+
throw new TypeError("Private method is not writable");
|
|
364
|
+
if (kind === "a" && !f)
|
|
365
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
366
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
367
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
368
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
369
|
+
};
|
|
370
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
371
|
+
if (kind === "a" && !f)
|
|
372
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
373
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
374
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
375
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
376
|
+
};
|
|
377
|
+
var _Context2D_ctx, _Context2D_opts;
|
|
361
378
|
class Context2D {
|
|
362
379
|
constructor(ctx, opts) {
|
|
363
|
-
this
|
|
364
|
-
|
|
365
|
-
this
|
|
366
|
-
this.
|
|
380
|
+
_Context2D_ctx.set(this, void 0);
|
|
381
|
+
_Context2D_opts.set(this, void 0);
|
|
382
|
+
__classPrivateFieldSet(this, _Context2D_ctx, ctx, "f");
|
|
383
|
+
__classPrivateFieldSet(this, _Context2D_opts, Object.assign({ devicePixelRatio: 1, offscreenCanvas: null }, opts), "f");
|
|
367
384
|
}
|
|
368
385
|
$undoPixelRatio(num) {
|
|
369
|
-
return num / this.
|
|
386
|
+
return num / __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio;
|
|
370
387
|
}
|
|
371
388
|
$doPixelRatio(num) {
|
|
372
|
-
return this.
|
|
389
|
+
return __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio * num;
|
|
373
390
|
}
|
|
374
391
|
$getContext() {
|
|
375
|
-
return this
|
|
392
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f");
|
|
376
393
|
}
|
|
377
394
|
$setFont(opts) {
|
|
378
395
|
const strList = [];
|
|
@@ -381,135 +398,153 @@ var __privateMethod = (obj, member, method) => {
|
|
|
381
398
|
}
|
|
382
399
|
strList.push(`${this.$doPixelRatio(opts.fontSize || 12)}px`);
|
|
383
400
|
strList.push(`${opts.fontFamily || "sans-serif"}`);
|
|
384
|
-
this.
|
|
401
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").font = `${strList.join(" ")}`;
|
|
402
|
+
}
|
|
403
|
+
$getOffscreenCanvas() {
|
|
404
|
+
return __classPrivateFieldGet(this, _Context2D_opts, "f").offscreenCanvas;
|
|
385
405
|
}
|
|
386
406
|
$resize(opts) {
|
|
387
|
-
const { width, height, devicePixelRatio } = opts;
|
|
388
|
-
const { canvas } = this
|
|
407
|
+
const { width, height, devicePixelRatio, resetStyle } = opts;
|
|
408
|
+
const { canvas } = __classPrivateFieldGet(this, _Context2D_ctx, "f");
|
|
389
409
|
canvas.width = width * devicePixelRatio;
|
|
390
410
|
canvas.height = height * devicePixelRatio;
|
|
391
|
-
this.
|
|
411
|
+
__classPrivateFieldSet(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Context2D_opts, "f")), {
|
|
412
|
+
devicePixelRatio
|
|
413
|
+
}), "f");
|
|
414
|
+
if (resetStyle === true) {
|
|
415
|
+
canvas.style.width = `${width}px`;
|
|
416
|
+
canvas.style.height = `${height}px`;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
$getSize() {
|
|
420
|
+
const { devicePixelRatio } = __classPrivateFieldGet(this, _Context2D_opts, "f");
|
|
421
|
+
const { width, height } = __classPrivateFieldGet(this, _Context2D_ctx, "f").canvas;
|
|
422
|
+
return {
|
|
423
|
+
width: width / devicePixelRatio,
|
|
424
|
+
height: height / devicePixelRatio,
|
|
425
|
+
devicePixelRatio
|
|
426
|
+
};
|
|
392
427
|
}
|
|
393
428
|
get canvas() {
|
|
394
|
-
return this.
|
|
429
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").canvas;
|
|
395
430
|
}
|
|
396
431
|
get fillStyle() {
|
|
397
|
-
return this.
|
|
432
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillStyle;
|
|
398
433
|
}
|
|
399
434
|
set fillStyle(value) {
|
|
400
|
-
this.
|
|
435
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").fillStyle = value;
|
|
401
436
|
}
|
|
402
437
|
get strokeStyle() {
|
|
403
|
-
return this.
|
|
438
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeStyle;
|
|
404
439
|
}
|
|
405
440
|
set strokeStyle(color2) {
|
|
406
|
-
this.
|
|
441
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").strokeStyle = color2;
|
|
407
442
|
}
|
|
408
443
|
get lineWidth() {
|
|
409
|
-
return this.$undoPixelRatio(this.
|
|
444
|
+
return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").lineWidth);
|
|
410
445
|
}
|
|
411
446
|
set lineWidth(w2) {
|
|
412
|
-
this.
|
|
447
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").lineWidth = this.$doPixelRatio(w2);
|
|
413
448
|
}
|
|
414
449
|
get textAlign() {
|
|
415
|
-
return this.
|
|
450
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").textAlign;
|
|
416
451
|
}
|
|
417
452
|
set textAlign(align) {
|
|
418
|
-
this.
|
|
453
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").textAlign = align;
|
|
419
454
|
}
|
|
420
455
|
get textBaseline() {
|
|
421
|
-
return this.
|
|
456
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").textBaseline;
|
|
422
457
|
}
|
|
423
458
|
set textBaseline(baseline) {
|
|
424
|
-
this.
|
|
459
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").textBaseline = baseline;
|
|
425
460
|
}
|
|
426
461
|
get globalAlpha() {
|
|
427
|
-
return this.
|
|
462
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalAlpha;
|
|
428
463
|
}
|
|
429
464
|
set globalAlpha(alpha) {
|
|
430
|
-
this.
|
|
465
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").globalAlpha = alpha;
|
|
431
466
|
}
|
|
432
467
|
get shadowColor() {
|
|
433
|
-
return this.
|
|
468
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowColor;
|
|
434
469
|
}
|
|
435
470
|
set shadowColor(color2) {
|
|
436
|
-
this.
|
|
471
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowColor = color2;
|
|
437
472
|
}
|
|
438
473
|
get shadowOffsetX() {
|
|
439
|
-
return this.$undoPixelRatio(this.
|
|
474
|
+
return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetX);
|
|
440
475
|
}
|
|
441
476
|
set shadowOffsetX(offsetX) {
|
|
442
|
-
this.
|
|
477
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetX = this.$doPixelRatio(offsetX);
|
|
443
478
|
}
|
|
444
479
|
get shadowOffsetY() {
|
|
445
|
-
return this.$undoPixelRatio(this.
|
|
480
|
+
return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetY);
|
|
446
481
|
}
|
|
447
482
|
set shadowOffsetY(offsetY) {
|
|
448
|
-
this.
|
|
483
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetY = this.$doPixelRatio(offsetY);
|
|
449
484
|
}
|
|
450
485
|
get shadowBlur() {
|
|
451
|
-
return this.$undoPixelRatio(this.
|
|
486
|
+
return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowBlur);
|
|
452
487
|
}
|
|
453
488
|
set shadowBlur(blur) {
|
|
454
|
-
this.
|
|
489
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowBlur = this.$doPixelRatio(blur);
|
|
455
490
|
}
|
|
456
491
|
get lineCap() {
|
|
457
|
-
return this.
|
|
492
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap;
|
|
458
493
|
}
|
|
459
494
|
set lineCap(lineCap) {
|
|
460
|
-
this.
|
|
495
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap = lineCap;
|
|
461
496
|
}
|
|
462
497
|
get globalCompositeOperation() {
|
|
463
|
-
return this.
|
|
498
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation;
|
|
464
499
|
}
|
|
465
500
|
set globalCompositeOperation(operations) {
|
|
466
|
-
this.
|
|
501
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
|
|
467
502
|
}
|
|
468
503
|
fill(...args) {
|
|
469
|
-
return this.
|
|
504
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fill(...args);
|
|
470
505
|
}
|
|
471
506
|
arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
472
|
-
return this.
|
|
507
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
|
|
473
508
|
}
|
|
474
509
|
rect(x2, y2, w2, h2) {
|
|
475
|
-
return this.
|
|
510
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
476
511
|
}
|
|
477
512
|
fillRect(x2, y2, w2, h2) {
|
|
478
|
-
return this.
|
|
513
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
479
514
|
}
|
|
480
515
|
clearRect(x2, y2, w2, h2) {
|
|
481
|
-
return this.
|
|
516
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
482
517
|
}
|
|
483
518
|
beginPath() {
|
|
484
|
-
return this.
|
|
519
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").beginPath();
|
|
485
520
|
}
|
|
486
521
|
closePath() {
|
|
487
|
-
return this.
|
|
522
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").closePath();
|
|
488
523
|
}
|
|
489
524
|
lineTo(x2, y2) {
|
|
490
|
-
return this.
|
|
525
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
491
526
|
}
|
|
492
527
|
moveTo(x2, y2) {
|
|
493
|
-
return this.
|
|
528
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
494
529
|
}
|
|
495
530
|
arcTo(x1, y1, x2, y2, radius) {
|
|
496
|
-
return this.
|
|
531
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
|
|
497
532
|
}
|
|
498
533
|
getLineDash() {
|
|
499
|
-
return this.
|
|
534
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").getLineDash();
|
|
500
535
|
}
|
|
501
536
|
setLineDash(nums) {
|
|
502
537
|
const dash = nums.map((n) => this.$doPixelRatio(n));
|
|
503
|
-
return this.
|
|
538
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").setLineDash(dash);
|
|
504
539
|
}
|
|
505
540
|
stroke(path) {
|
|
506
|
-
return path ? this.
|
|
541
|
+
return path ? __classPrivateFieldGet(this, _Context2D_ctx, "f").stroke(path) : __classPrivateFieldGet(this, _Context2D_ctx, "f").stroke();
|
|
507
542
|
}
|
|
508
543
|
translate(x2, y2) {
|
|
509
|
-
return this.
|
|
544
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
510
545
|
}
|
|
511
546
|
rotate(angle2) {
|
|
512
|
-
return this.
|
|
547
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").rotate(angle2);
|
|
513
548
|
}
|
|
514
549
|
drawImage(...args) {
|
|
515
550
|
const image = args[0];
|
|
@@ -522,66 +557,67 @@ var __privateMethod = (obj, member, method) => {
|
|
|
522
557
|
const dw = args[args.length - 2];
|
|
523
558
|
const dh = args[args.length - 1];
|
|
524
559
|
if (args.length === 9) {
|
|
525
|
-
return this.
|
|
560
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(sx), this.$doPixelRatio(sy), this.$doPixelRatio(sw), this.$doPixelRatio(sh), this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
|
|
526
561
|
} else {
|
|
527
|
-
return this.
|
|
562
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
|
|
528
563
|
}
|
|
529
564
|
}
|
|
530
565
|
createPattern(image, repetition) {
|
|
531
|
-
return this.
|
|
566
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").createPattern(image, repetition);
|
|
532
567
|
}
|
|
533
568
|
measureText(text2) {
|
|
534
|
-
const textMetrics = this.
|
|
569
|
+
const textMetrics = __classPrivateFieldGet(this, _Context2D_ctx, "f").measureText(text2);
|
|
535
570
|
return textMetrics;
|
|
536
571
|
}
|
|
537
572
|
fillText(text2, x2, y2, maxWidth) {
|
|
538
573
|
if (maxWidth !== void 0) {
|
|
539
|
-
return this.
|
|
574
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
|
|
540
575
|
} else {
|
|
541
|
-
return this.
|
|
576
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
542
577
|
}
|
|
543
578
|
}
|
|
544
579
|
strokeText(text2, x2, y2, maxWidth) {
|
|
545
580
|
if (maxWidth !== void 0) {
|
|
546
|
-
return this.
|
|
581
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
|
|
547
582
|
} else {
|
|
548
|
-
return this.
|
|
583
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
549
584
|
}
|
|
550
585
|
}
|
|
551
586
|
save() {
|
|
552
|
-
this.
|
|
587
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").save();
|
|
553
588
|
}
|
|
554
589
|
restore() {
|
|
555
|
-
this.
|
|
590
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").restore();
|
|
556
591
|
}
|
|
557
592
|
scale(ratioX, ratioY) {
|
|
558
|
-
this.
|
|
593
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").scale(ratioX, ratioY);
|
|
559
594
|
}
|
|
560
595
|
circle(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
561
|
-
this.
|
|
596
|
+
__classPrivateFieldGet(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
|
|
562
597
|
}
|
|
563
598
|
isPointInPath(x2, y2) {
|
|
564
|
-
return this.
|
|
599
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
565
600
|
}
|
|
566
601
|
clip(...args) {
|
|
567
|
-
return this.
|
|
602
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").clip(...args);
|
|
568
603
|
}
|
|
569
604
|
setTransform(a, b, c, d, e, f) {
|
|
570
|
-
return this.
|
|
605
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
|
|
571
606
|
}
|
|
572
607
|
getTransform() {
|
|
573
|
-
return this.
|
|
608
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").getTransform();
|
|
574
609
|
}
|
|
575
610
|
createLinearGradient(x0, y0, x1, y1) {
|
|
576
|
-
return this.
|
|
611
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
|
|
577
612
|
}
|
|
578
613
|
createRadialGradient(x0, y0, r0, x1, y1, r1) {
|
|
579
|
-
return this.
|
|
614
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").createRadialGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(r0), this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(r1));
|
|
580
615
|
}
|
|
581
616
|
createConicGradient(startAngle, x2, y2) {
|
|
582
|
-
return this.
|
|
617
|
+
return __classPrivateFieldGet(this, _Context2D_ctx, "f").createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
583
618
|
}
|
|
584
619
|
}
|
|
620
|
+
_Context2D_ctx = /* @__PURE__ */ new WeakMap(), _Context2D_opts = /* @__PURE__ */ new WeakMap();
|
|
585
621
|
function createContext2D(opts) {
|
|
586
622
|
const { width, height, ctx, devicePixelRatio } = opts;
|
|
587
623
|
let context = ctx;
|
|
@@ -594,23 +630,72 @@ var __privateMethod = (obj, member, method) => {
|
|
|
594
630
|
const context2d = new Context2D(context, opts);
|
|
595
631
|
return context2d;
|
|
596
632
|
}
|
|
597
|
-
function
|
|
633
|
+
function createOffscreenContext2D(opts) {
|
|
634
|
+
const { width, height, devicePixelRatio } = opts;
|
|
635
|
+
const offCanvas = new OffscreenCanvas(width * devicePixelRatio, height * devicePixelRatio);
|
|
636
|
+
const offRenderCtx = offCanvas.getContext("2d");
|
|
637
|
+
const offCtx = offRenderCtx.canvas.getContext("2d");
|
|
638
|
+
const context2d = new Context2D(offCtx, {
|
|
639
|
+
devicePixelRatio,
|
|
640
|
+
offscreenCanvas: offCanvas
|
|
641
|
+
});
|
|
642
|
+
return context2d;
|
|
643
|
+
}
|
|
644
|
+
function createViewContent(canvas, opts) {
|
|
645
|
+
const { width, height, devicePixelRatio, offscreen } = opts;
|
|
598
646
|
const ctxOpts = {
|
|
599
|
-
width
|
|
600
|
-
height
|
|
601
|
-
devicePixelRatio
|
|
602
|
-
};
|
|
603
|
-
const viewContext = createContext2D(ctxOpts);
|
|
604
|
-
const helperContext = createContext2D(ctxOpts);
|
|
605
|
-
const underContext = createContext2D(ctxOpts);
|
|
606
|
-
const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
|
|
607
|
-
const content = {
|
|
608
|
-
underContext,
|
|
609
|
-
viewContext,
|
|
610
|
-
helperContext,
|
|
611
|
-
boardContext
|
|
647
|
+
width,
|
|
648
|
+
height,
|
|
649
|
+
devicePixelRatio
|
|
612
650
|
};
|
|
613
|
-
|
|
651
|
+
if (offscreen === true) {
|
|
652
|
+
const ctx = canvas.getContext("2d");
|
|
653
|
+
const viewContext = createOffscreenContext2D(ctxOpts);
|
|
654
|
+
const helperContext = createOffscreenContext2D(ctxOpts);
|
|
655
|
+
const underContext = createOffscreenContext2D(ctxOpts);
|
|
656
|
+
const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
|
|
657
|
+
const drawView = () => {
|
|
658
|
+
const { width: w2, height: h2 } = viewContext.$getSize();
|
|
659
|
+
boardContext.clearRect(0, 0, w2, h2);
|
|
660
|
+
boardContext.drawImage(underContext.canvas, 0, 0, w2, h2);
|
|
661
|
+
boardContext.drawImage(viewContext.canvas, 0, 0, w2, h2);
|
|
662
|
+
boardContext.drawImage(helperContext.canvas, 0, 0, w2, h2);
|
|
663
|
+
underContext.clearRect(0, 0, w2, h2);
|
|
664
|
+
viewContext.clearRect(0, 0, w2, h2);
|
|
665
|
+
helperContext.clearRect(0, 0, w2, h2);
|
|
666
|
+
};
|
|
667
|
+
const content = {
|
|
668
|
+
underContext,
|
|
669
|
+
viewContext,
|
|
670
|
+
helperContext,
|
|
671
|
+
boardContext,
|
|
672
|
+
drawView
|
|
673
|
+
};
|
|
674
|
+
return content;
|
|
675
|
+
} else {
|
|
676
|
+
const ctx = canvas.getContext("2d");
|
|
677
|
+
const viewContext = createContext2D(ctxOpts);
|
|
678
|
+
const helperContext = createContext2D(ctxOpts);
|
|
679
|
+
const underContext = createContext2D(ctxOpts);
|
|
680
|
+
const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
|
|
681
|
+
const drawView = () => {
|
|
682
|
+
boardContext.clearRect(0, 0, width, height);
|
|
683
|
+
boardContext.drawImage(underContext.canvas, 0, 0, width, height);
|
|
684
|
+
boardContext.drawImage(viewContext.canvas, 0, 0, width, height);
|
|
685
|
+
boardContext.drawImage(helperContext.canvas, 0, 0, width, height);
|
|
686
|
+
underContext.clearRect(0, 0, width, height);
|
|
687
|
+
viewContext.clearRect(0, 0, width, height);
|
|
688
|
+
helperContext.clearRect(0, 0, width, height);
|
|
689
|
+
};
|
|
690
|
+
const content = {
|
|
691
|
+
underContext,
|
|
692
|
+
viewContext,
|
|
693
|
+
helperContext,
|
|
694
|
+
boardContext,
|
|
695
|
+
drawView
|
|
696
|
+
};
|
|
697
|
+
return content;
|
|
698
|
+
}
|
|
614
699
|
}
|
|
615
700
|
class EventEmitter {
|
|
616
701
|
constructor() {
|
|
@@ -2123,7 +2208,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2123
2208
|
break;
|
|
2124
2209
|
}
|
|
2125
2210
|
case "group": {
|
|
2126
|
-
|
|
2211
|
+
const assets = Object.assign(Object.assign({}, opts.elementAssets || {}), elem.detail.assets || {});
|
|
2212
|
+
drawGroup(ctx, elem, Object.assign(Object.assign({}, opts), { elementAssets: assets }));
|
|
2127
2213
|
break;
|
|
2128
2214
|
}
|
|
2129
2215
|
default: {
|
|
@@ -2571,10 +2657,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2571
2657
|
const deltaY = e.deltaY > 0 || e.deltaY < 0 ? e.deltaY : 0;
|
|
2572
2658
|
if (e.ctrlKey === true && this.has("wheelScale")) {
|
|
2573
2659
|
this.trigger("wheelScale", { deltaX, deltaY, point });
|
|
2574
|
-
} else if (this.has("
|
|
2575
|
-
this.trigger("
|
|
2576
|
-
} else if (this.has("wheelY") && deltaY !== 0) {
|
|
2577
|
-
this.trigger("wheelY", { deltaY, point });
|
|
2660
|
+
} else if (this.has("wheel")) {
|
|
2661
|
+
this.trigger("wheel", { deltaX, deltaY, point });
|
|
2578
2662
|
}
|
|
2579
2663
|
}, { passive: false });
|
|
2580
2664
|
container.addEventListener("click", (e) => {
|
|
@@ -2731,7 +2815,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2731
2815
|
const { renderer, viewContent, beforeDrawFrame, afterDrawFrame } = this._opts;
|
|
2732
2816
|
if (snapshot) {
|
|
2733
2817
|
const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = snapshot.activeStore;
|
|
2734
|
-
const { underContext, viewContext, helperContext, boardContext } = viewContent;
|
|
2735
2818
|
if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.activeStore.data) {
|
|
2736
2819
|
renderer.drawData(snapshot.activeStore.data, {
|
|
2737
2820
|
viewScaleInfo: {
|
|
@@ -2751,13 +2834,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2751
2834
|
});
|
|
2752
2835
|
}
|
|
2753
2836
|
beforeDrawFrame({ snapshot });
|
|
2754
|
-
|
|
2755
|
-
boardContext.drawImage(underContext.canvas, 0, 0, width, height);
|
|
2756
|
-
boardContext.drawImage(viewContext.canvas, 0, 0, width, height);
|
|
2757
|
-
boardContext.drawImage(helperContext.canvas, 0, 0, width, height);
|
|
2758
|
-
underContext.clearRect(0, 0, width, height);
|
|
2759
|
-
viewContext.clearRect(0, 0, width, height);
|
|
2760
|
-
helperContext.clearRect(0, 0, width, height);
|
|
2837
|
+
viewContent.drawView();
|
|
2761
2838
|
afterDrawFrame({ snapshot });
|
|
2762
2839
|
}
|
|
2763
2840
|
if (this._drawFrameSnapshotQueue.length === 0) {
|
|
@@ -2883,11 +2960,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2883
2960
|
this._watcher.on("hover", throttle((e) => {
|
|
2884
2961
|
this._handleHover(e);
|
|
2885
2962
|
}, throttleTime));
|
|
2886
|
-
this._watcher.on("
|
|
2887
|
-
this.
|
|
2888
|
-
}, throttleTime));
|
|
2889
|
-
this._watcher.on("wheelY", throttle((e) => {
|
|
2890
|
-
this._handleWheelY(e);
|
|
2963
|
+
this._watcher.on("wheel", throttle((e) => {
|
|
2964
|
+
this._handleWheel(e);
|
|
2891
2965
|
}, throttleTime));
|
|
2892
2966
|
this._watcher.on("wheelScale", throttle((e) => {
|
|
2893
2967
|
this._handleWheelScale(e);
|
|
@@ -2947,21 +3021,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2947
3021
|
}
|
|
2948
3022
|
}
|
|
2949
3023
|
}
|
|
2950
|
-
|
|
2951
|
-
var _a;
|
|
2952
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
2953
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
2954
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheelX) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
2955
|
-
if (result === false) {
|
|
2956
|
-
return;
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
}
|
|
2960
|
-
_handleWheelY(e) {
|
|
3024
|
+
_handleWheel(e) {
|
|
2961
3025
|
var _a;
|
|
2962
3026
|
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
2963
3027
|
const obj = this._activeMiddlewareObjs[i];
|
|
2964
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.
|
|
3028
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheel) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
2965
3029
|
if (result === false) {
|
|
2966
3030
|
return;
|
|
2967
3031
|
}
|
|
@@ -3097,9 +3161,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3097
3161
|
const { width, height, devicePixelRatio } = newViewSize;
|
|
3098
3162
|
const { viewContent } = this._opts;
|
|
3099
3163
|
viewContent.viewContext.$resize({ width, height, devicePixelRatio });
|
|
3100
|
-
const canvas = viewContent.viewContext.canvas;
|
|
3101
|
-
canvas.style.width = `${width}px`;
|
|
3102
|
-
canvas.style.height = `${height}px`;
|
|
3103
3164
|
viewContent.helperContext.$resize({ width, height, devicePixelRatio });
|
|
3104
3165
|
viewContent.boardContext.$resize({ width, height, devicePixelRatio });
|
|
3105
3166
|
this._viewer.drawFrame();
|
|
@@ -3241,7 +3302,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3241
3302
|
const keySelectedElementController = Symbol(`${key$1}_selectedElementController`);
|
|
3242
3303
|
const keyGroupQueue = Symbol(`${key$1}_groupQueue`);
|
|
3243
3304
|
const keyGroupQueueVertexesList = Symbol(`${key$1}_groupQueueVertexesList`);
|
|
3244
|
-
const
|
|
3305
|
+
const selectWrapperBorderWidth = 2;
|
|
3306
|
+
const resizeControllerBorderWidth = 4;
|
|
3307
|
+
const areaBorderWidth = 1;
|
|
3245
3308
|
const wrapperColor = "#1973ba";
|
|
3246
3309
|
function drawVertexes(ctx, vertexes, opts) {
|
|
3247
3310
|
const { borderColor: borderColor2, borderWidth: borderWidth2, background: background2, lineDash } = opts;
|
|
@@ -3271,8 +3334,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3271
3334
|
if (!controller) {
|
|
3272
3335
|
return;
|
|
3273
3336
|
}
|
|
3274
|
-
const { elementWrapper,
|
|
3275
|
-
const wrapperOpts = { borderColor: wrapperColor, borderWidth:
|
|
3337
|
+
const { elementWrapper, topLeft, topRight, bottomLeft, bottomRight } = controller;
|
|
3338
|
+
const wrapperOpts = { borderColor: wrapperColor, borderWidth: selectWrapperBorderWidth, background: "transparent", lineDash: [] };
|
|
3276
3339
|
const ctrlOpts = { ...wrapperOpts, borderWidth: resizeControllerBorderWidth, background: "#FFFFFF" };
|
|
3277
3340
|
drawVertexes(ctx, calcViewVertexes(elementWrapper, opts), wrapperOpts);
|
|
3278
3341
|
drawVertexes(ctx, calcViewVertexes(topLeft.vertexes, opts), ctrlOpts);
|
|
@@ -3283,7 +3346,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3283
3346
|
function drawArea(ctx, opts) {
|
|
3284
3347
|
const { start, end } = opts;
|
|
3285
3348
|
ctx.setLineDash([]);
|
|
3286
|
-
ctx.lineWidth =
|
|
3349
|
+
ctx.lineWidth = areaBorderWidth;
|
|
3287
3350
|
ctx.strokeStyle = wrapperColor;
|
|
3288
3351
|
ctx.fillStyle = "#1976d24f";
|
|
3289
3352
|
ctx.beginPath();
|
|
@@ -3299,7 +3362,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3299
3362
|
const { areaSize } = opts;
|
|
3300
3363
|
const { x: x2, y: y2, w: w2, h: h2 } = areaSize;
|
|
3301
3364
|
ctx.setLineDash([]);
|
|
3302
|
-
ctx.lineWidth =
|
|
3365
|
+
ctx.lineWidth = areaBorderWidth;
|
|
3303
3366
|
ctx.strokeStyle = wrapperColor;
|
|
3304
3367
|
ctx.fillStyle = "#1976d21c";
|
|
3305
3368
|
ctx.beginPath();
|
|
@@ -3314,7 +3377,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3314
3377
|
function drawGroupQueueVertexesWrappers(ctx, vertexesList, opts) {
|
|
3315
3378
|
for (let i = 0; i < vertexesList.length; i++) {
|
|
3316
3379
|
const vertexes = vertexesList[i];
|
|
3317
|
-
const wrapperOpts = { borderColor: wrapperColor, borderWidth:
|
|
3380
|
+
const wrapperOpts = { borderColor: wrapperColor, borderWidth: selectWrapperBorderWidth, background: "transparent", lineDash: [4, 4] };
|
|
3318
3381
|
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
3319
3382
|
}
|
|
3320
3383
|
}
|
|
@@ -4143,13 +4206,24 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4143
4206
|
...defaultElementDetail,
|
|
4144
4207
|
...element.detail
|
|
4145
4208
|
};
|
|
4209
|
+
let elemX = element.x * scale + offsetLeft;
|
|
4210
|
+
let elemY = element.y * scale + offsetTop;
|
|
4211
|
+
let elemW = element.w * scale;
|
|
4212
|
+
let elemH = element.h * scale;
|
|
4213
|
+
if (groupQueue.length > 0) {
|
|
4214
|
+
elemX = element.x * scale;
|
|
4215
|
+
elemY = element.y * scale;
|
|
4216
|
+
elemW = element.w * scale;
|
|
4217
|
+
elemH = element.h * scale;
|
|
4218
|
+
}
|
|
4146
4219
|
textarea.style.position = "absolute";
|
|
4147
|
-
textarea.style.left = `${
|
|
4148
|
-
textarea.style.top = `${
|
|
4149
|
-
textarea.style.width = `${
|
|
4150
|
-
textarea.style.height = `${
|
|
4220
|
+
textarea.style.left = `${elemX}px`;
|
|
4221
|
+
textarea.style.top = `${elemY}px`;
|
|
4222
|
+
textarea.style.width = `${elemW}px`;
|
|
4223
|
+
textarea.style.height = `${elemH}px`;
|
|
4151
4224
|
textarea.style.transform = `rotate(${limitAngle(element.angle || 0)}deg)`;
|
|
4152
|
-
textarea.style.
|
|
4225
|
+
textarea.style.boxSizing = "border-box";
|
|
4226
|
+
textarea.style.border = "1px solid #1973ba";
|
|
4153
4227
|
textarea.style.resize = "none";
|
|
4154
4228
|
textarea.style.overflow = "hidden";
|
|
4155
4229
|
textarea.style.wordBreak = "break-all";
|
|
@@ -4885,24 +4959,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4885
4959
|
};
|
|
4886
4960
|
return {
|
|
4887
4961
|
mode: key,
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
// },
|
|
4895
|
-
wheelX: (e) => {
|
|
4896
|
-
if (e.deltaX >= 0 || e.deltaX < 0) {
|
|
4897
|
-
viewer.scroll({ moveX: 0 - e.deltaX });
|
|
4898
|
-
viewer.drawFrame();
|
|
4899
|
-
}
|
|
4900
|
-
},
|
|
4901
|
-
wheelY: (e) => {
|
|
4902
|
-
if (e.deltaY >= 0 || e.deltaY < 0) {
|
|
4903
|
-
viewer.scroll({ moveY: 0 - e.deltaY });
|
|
4904
|
-
viewer.drawFrame();
|
|
4905
|
-
}
|
|
4962
|
+
wheel: (e) => {
|
|
4963
|
+
viewer.scroll({
|
|
4964
|
+
moveX: 0 - e.deltaX,
|
|
4965
|
+
moveY: 0 - e.deltaY
|
|
4966
|
+
});
|
|
4967
|
+
viewer.drawFrame();
|
|
4906
4968
|
},
|
|
4907
4969
|
pointStart: (e) => {
|
|
4908
4970
|
const { point } = e;
|
|
@@ -5210,8 +5272,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5210
5272
|
const canvas = document.createElement("canvas");
|
|
5211
5273
|
__privateMethod(this, _initContainer, initContainer_fn).call(this);
|
|
5212
5274
|
container.appendChild(canvas);
|
|
5213
|
-
const
|
|
5214
|
-
const viewContent = createBoardContexts(ctx, { devicePixelRatio });
|
|
5275
|
+
const viewContent = createViewContent(canvas, { width, height, devicePixelRatio, offscreen: true });
|
|
5215
5276
|
const board = new Board({ viewContent, container });
|
|
5216
5277
|
const sharer = board.getSharer();
|
|
5217
5278
|
sharer.setActiveViewSizeInfo({
|
|
@@ -5280,7 +5341,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5280
5341
|
refresh() {
|
|
5281
5342
|
__privateGet(this, _board).getViewer().drawFrame();
|
|
5282
5343
|
}
|
|
5283
|
-
|
|
5344
|
+
setViewScale(opts) {
|
|
5284
5345
|
__privateGet(this, _board).updateViewScaleInfo(opts);
|
|
5285
5346
|
}
|
|
5286
5347
|
}
|