@postermywall/fabricjs-2 6.0.0-pmw-4 → 6.0.0-pmw-6
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 +174 -47
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +174 -47
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +174 -47
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +174 -47
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/config.d.ts +2 -2
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.min.mjs +1 -1
- package/dist/src/config.min.mjs.map +1 -1
- package/dist/src/config.mjs +2 -2
- package/dist/src/config.mjs.map +1 -1
- package/dist/src/shapes/Group.d.ts +12 -15
- package/dist/src/shapes/Group.d.ts.map +1 -1
- package/dist/src/shapes/Group.min.mjs +1 -1
- package/dist/src/shapes/Group.min.mjs.map +1 -1
- package/dist/src/shapes/Group.mjs +6 -32
- package/dist/src/shapes/Group.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.d.ts +39 -1
- package/dist/src/shapes/Text/Text.d.ts.map +1 -1
- package/dist/src/shapes/Text/Text.min.mjs +1 -1
- package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.mjs +160 -10
- package/dist/src/shapes/Text/Text.mjs.map +1 -1
- package/dist/src/shapes/Text/constants.d.ts +3 -3
- package/dist/src/shapes/Text/constants.d.ts.map +1 -1
- package/dist/src/shapes/Text/constants.min.mjs +1 -1
- package/dist/src/shapes/Text/constants.min.mjs.map +1 -1
- package/dist/src/shapes/Text/constants.mjs +5 -2
- package/dist/src/shapes/Text/constants.mjs.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +2 -2
- package/src/shapes/Group.ts +24 -12
- package/src/shapes/Text/Text.ts +220 -24
- package/src/shapes/Text/constants.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -136,12 +136,12 @@
|
|
|
136
136
|
* @type Boolean
|
|
137
137
|
* @default
|
|
138
138
|
*/
|
|
139
|
-
_defineProperty(this, "disableGroupSelector",
|
|
139
|
+
_defineProperty(this, "disableGroupSelector", false);
|
|
140
140
|
/**
|
|
141
141
|
* *PMW* added variable to mark when canvas is being two-finger panned.
|
|
142
142
|
* @type Boolean
|
|
143
143
|
*/
|
|
144
|
-
_defineProperty(this, "isCanvasTwoFingerPanning",
|
|
144
|
+
_defineProperty(this, "isCanvasTwoFingerPanning", false);
|
|
145
145
|
/**
|
|
146
146
|
* Pixel limit for cache canvases width or height. IE fixes the maximum at 5000
|
|
147
147
|
* @since 1.7.14
|
|
@@ -440,7 +440,7 @@
|
|
|
440
440
|
}
|
|
441
441
|
const cache = new Cache();
|
|
442
442
|
|
|
443
|
-
var version = "6.0.0-pmw-
|
|
443
|
+
var version = "6.0.0-pmw-6";
|
|
444
444
|
|
|
445
445
|
// use this syntax so babel plugin see this import here
|
|
446
446
|
const VERSION = version;
|
|
@@ -11376,6 +11376,12 @@
|
|
|
11376
11376
|
const groupDefaultValues = {
|
|
11377
11377
|
strokeWidth: 0,
|
|
11378
11378
|
subTargetCheck: false,
|
|
11379
|
+
delegateProperties: true,
|
|
11380
|
+
caterCacheForTextChildren: false,
|
|
11381
|
+
leanBackground: false,
|
|
11382
|
+
leanBackgroundOffset: 0,
|
|
11383
|
+
selected: false,
|
|
11384
|
+
useSelectedFlag: false,
|
|
11379
11385
|
interactive: false
|
|
11380
11386
|
};
|
|
11381
11387
|
|
|
@@ -11406,11 +11412,6 @@
|
|
|
11406
11412
|
* @default
|
|
11407
11413
|
* @type boolean
|
|
11408
11414
|
*/
|
|
11409
|
-
/**
|
|
11410
|
-
* *PMW property added*
|
|
11411
|
-
* To delete some properties or not
|
|
11412
|
-
*/
|
|
11413
|
-
_defineProperty(this, "delegateProperties", true);
|
|
11414
11415
|
/**
|
|
11415
11416
|
* *PMW*
|
|
11416
11417
|
* Properties that are delegated to group objects when reading/writing
|
|
@@ -11429,33 +11430,6 @@
|
|
|
11429
11430
|
textDecoration: true,
|
|
11430
11431
|
textAlign: true
|
|
11431
11432
|
});
|
|
11432
|
-
/**
|
|
11433
|
-
* *PMW property added*
|
|
11434
|
-
* Whether to cater to the text children objects for caching.
|
|
11435
|
-
*/
|
|
11436
|
-
_defineProperty(this, "caterCacheForTextChildren", false);
|
|
11437
|
-
/**
|
|
11438
|
-
* *PMW property added*
|
|
11439
|
-
* Whether to render a rectangle background or a tilted background
|
|
11440
|
-
*/
|
|
11441
|
-
_defineProperty(this, "leanBackground", false);
|
|
11442
|
-
/**
|
|
11443
|
-
* *PMW property added*
|
|
11444
|
-
* Leanness of background
|
|
11445
|
-
*/
|
|
11446
|
-
_defineProperty(this, "leanBackgroundOffset", 0);
|
|
11447
|
-
/**
|
|
11448
|
-
* *PMW property added*
|
|
11449
|
-
* Whether the object is currently selected.
|
|
11450
|
-
* This is being used in GraphicItemSlideshowMediator to handle text editing.
|
|
11451
|
-
* The editing mode is entered on single click when the item is selected. So we use this flag to determine if the item is selected.
|
|
11452
|
-
*/
|
|
11453
|
-
_defineProperty(this, "selected", false);
|
|
11454
|
-
/**
|
|
11455
|
-
* *PMW property added*
|
|
11456
|
-
* Whether the PMW added selected flag should be used.
|
|
11457
|
-
*/
|
|
11458
|
-
_defineProperty(this, "useSelectedFlag", false);
|
|
11459
11433
|
/**
|
|
11460
11434
|
* Used internally to optimize performance
|
|
11461
11435
|
* Once an object is selected, instance is rendered without the selected object.
|
|
@@ -18779,7 +18753,7 @@
|
|
|
18779
18753
|
}
|
|
18780
18754
|
|
|
18781
18755
|
const fontProperties = ['fontSize', 'fontWeight', 'fontFamily', 'fontStyle'];
|
|
18782
|
-
const textDecorationProperties = ['underline', 'overline', 'linethrough'];
|
|
18756
|
+
const textDecorationProperties = ['underline', 'overline', 'linethrough', 'squigglyline'];
|
|
18783
18757
|
const textLayoutProperties = [...fontProperties, 'lineHeight', 'text', 'charSpacing', 'textAlign', 'styles', 'path', 'pathStartOffset', 'pathSide', 'pathAlign'];
|
|
18784
18758
|
const additionalProps = [...textLayoutProperties, ...textDecorationProperties, 'textBackgroundColor', 'direction'];
|
|
18785
18759
|
const styleProperties = [...fontProperties, ...textDecorationProperties, 'stroke', 'strokeWidth', 'fill', 'deltaY', 'textBackgroundColor'];
|
|
@@ -18798,6 +18772,8 @@
|
|
|
18798
18772
|
underline: false,
|
|
18799
18773
|
overline: false,
|
|
18800
18774
|
linethrough: false,
|
|
18775
|
+
squigglyline: false,
|
|
18776
|
+
squigglylineColor: '',
|
|
18801
18777
|
textAlign: LEFT,
|
|
18802
18778
|
fontStyle: 'normal',
|
|
18803
18779
|
lineHeight: 1.16,
|
|
@@ -18825,7 +18801,8 @@
|
|
|
18825
18801
|
offsets: {
|
|
18826
18802
|
underline: 0.1,
|
|
18827
18803
|
linethrough: -0.315,
|
|
18828
|
-
overline: -0.88
|
|
18804
|
+
overline: -0.88,
|
|
18805
|
+
squigglyline: 0.1
|
|
18829
18806
|
},
|
|
18830
18807
|
_fontSizeMult: 1.13,
|
|
18831
18808
|
charSpacing: 0,
|
|
@@ -19534,6 +19511,7 @@
|
|
|
19534
19511
|
this._renderText(ctx);
|
|
19535
19512
|
this._renderTextDecoration(ctx, 'overline');
|
|
19536
19513
|
this._renderTextDecoration(ctx, 'linethrough');
|
|
19514
|
+
this._renderTextDecoration(ctx, 'squigglyline'); // *PMW*
|
|
19537
19515
|
}
|
|
19538
19516
|
|
|
19539
19517
|
/**
|
|
@@ -19901,6 +19879,10 @@
|
|
|
19901
19879
|
for (let i = 0, len = this._textLines.length; i < len; i++) {
|
|
19902
19880
|
lineHeight = this.getHeightOfLine(i);
|
|
19903
19881
|
height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;
|
|
19882
|
+
// //*PMW* commenting out the code that prevent text box from applying line height on the last line. This caused line height to not work in table and menus
|
|
19883
|
+
// height += lineHeight;//(i === len - 1 ? lineHeight / this.lineHeight : lineHeight);
|
|
19884
|
+
// *PMW* preventing height to be smaller than selector size.
|
|
19885
|
+
height += i === len - 1 && this.lineHeight < 1 ? lineHeight / this.lineHeight : lineHeight;
|
|
19904
19886
|
}
|
|
19905
19887
|
return height;
|
|
19906
19888
|
}
|
|
@@ -20289,10 +20271,11 @@
|
|
|
20289
20271
|
return width;
|
|
20290
20272
|
}
|
|
20291
20273
|
_getWidthOfCharSpacing() {
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20274
|
+
//*PMW* change char spacing to be applied the same on every size
|
|
20275
|
+
// if (this.charSpacing !== 0) {
|
|
20276
|
+
// return this.fontSize * this.charSpacing / 1000;
|
|
20277
|
+
// }
|
|
20278
|
+
return this.charSpacing;
|
|
20296
20279
|
}
|
|
20297
20280
|
|
|
20298
20281
|
/**
|
|
@@ -20358,11 +20341,18 @@
|
|
|
20358
20341
|
if (this.direction === 'rtl') {
|
|
20359
20342
|
drawStart = this.width - drawStart - boxWidth;
|
|
20360
20343
|
}
|
|
20361
|
-
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
20344
|
+
// *PMW*
|
|
20345
|
+
const opts = {
|
|
20346
|
+
type: type,
|
|
20347
|
+
boxWidth: boxWidth,
|
|
20348
|
+
decoration: lastDecoration,
|
|
20349
|
+
fill: lastFill,
|
|
20350
|
+
x: drawStart,
|
|
20351
|
+
y: top + offsetY * size + dy,
|
|
20352
|
+
w: boxWidth,
|
|
20353
|
+
h: this.fontSize / 15
|
|
20354
|
+
};
|
|
20355
|
+
this._renderTextLineDecoration(ctx, opts);
|
|
20366
20356
|
boxStart = charBox.left;
|
|
20367
20357
|
boxWidth = charBox.width;
|
|
20368
20358
|
lastDecoration = currentDecoration;
|
|
@@ -20378,13 +20368,148 @@
|
|
|
20378
20368
|
drawStart = this.width - drawStart - boxWidth;
|
|
20379
20369
|
}
|
|
20380
20370
|
ctx.fillStyle = currentFill;
|
|
20381
|
-
|
|
20371
|
+
// *PMW*
|
|
20372
|
+
const opts = {
|
|
20373
|
+
type: type,
|
|
20374
|
+
boxWidth: boxWidth,
|
|
20375
|
+
decoration: currentDecoration,
|
|
20376
|
+
fill: currentFill,
|
|
20377
|
+
x: drawStart,
|
|
20378
|
+
y: top + offsetY * size + dy,
|
|
20379
|
+
w: boxWidth - charSpacing,
|
|
20380
|
+
h: this.fontSize / 15
|
|
20381
|
+
};
|
|
20382
|
+
this._renderTextLineDecoration(ctx, opts);
|
|
20382
20383
|
topOffset += heightOfLine;
|
|
20383
20384
|
}
|
|
20385
|
+
|
|
20384
20386
|
// if there is text background color no
|
|
20385
20387
|
// other shadows should be casted
|
|
20388
|
+
// *PMW* need shadow to be applied on text with styles as well,
|
|
20389
|
+
// this._removeShadow(ctx);
|
|
20390
|
+
}
|
|
20391
|
+
|
|
20392
|
+
/**
|
|
20393
|
+
* *PMW*
|
|
20394
|
+
* @private
|
|
20395
|
+
* @param {CanvasRenderingContext2D} ctx Context to render on
|
|
20396
|
+
* @param {Object} opts
|
|
20397
|
+
*/
|
|
20398
|
+
_renderTextLineDecoration(ctx, opts) {
|
|
20399
|
+
if (opts.type === 'squigglyline') {
|
|
20400
|
+
const polyPoints = [],
|
|
20401
|
+
scaleX = 0.35,
|
|
20402
|
+
scaleY = 0.45,
|
|
20403
|
+
funct = function (x) {
|
|
20404
|
+
const g = x % 6;
|
|
20405
|
+
if (g <= 3) {
|
|
20406
|
+
return g * 5;
|
|
20407
|
+
}
|
|
20408
|
+
return (6 - g) * 5;
|
|
20409
|
+
};
|
|
20410
|
+
ctx.fillStyle = this.squigglylineColor ? this.squigglylineColor : opts.fill;
|
|
20411
|
+
for (let x = 0; x < opts.boxWidth; x += 0.5) {
|
|
20412
|
+
polyPoints.push({
|
|
20413
|
+
x: x - 10,
|
|
20414
|
+
y: funct(x * scaleX) * scaleY
|
|
20415
|
+
});
|
|
20416
|
+
}
|
|
20417
|
+
for (let j = 0; j < polyPoints.length; j++) {
|
|
20418
|
+
opts.decoration && opts.fill && ctx.fillRect(opts.x + polyPoints[j].x + 8, opts.y + polyPoints[j].y, 2, 2);
|
|
20419
|
+
}
|
|
20420
|
+
} else {
|
|
20421
|
+
// *PMW* use first color of gradient instead of last fill for text styles (underline, linethrough),
|
|
20422
|
+
// Issue is fixed on updated method obj.set('textDecoration', 'underline') can use that one once
|
|
20423
|
+
// it has support for multiple styles at a time and selection styles
|
|
20424
|
+
if (opts.fill && typeof opts.fill !== 'string' && opts.fill.colorStops && opts.fill.colorStops.length) {
|
|
20425
|
+
ctx.fillStyle = opts.fill.colorStops[0].color;
|
|
20426
|
+
} else if (opts.fill && typeof opts.fill !== 'string' && opts.fill.source) {
|
|
20427
|
+
//Use pattern for underline, linethrough on text mask
|
|
20428
|
+
const pattern = ctx.createPattern(opts.fill.source, 'repeat');
|
|
20429
|
+
if (pattern) {
|
|
20430
|
+
ctx.fillStyle = pattern;
|
|
20431
|
+
}
|
|
20432
|
+
}
|
|
20433
|
+
// *PMW*
|
|
20434
|
+
opts.decoration && opts.fill && ctx.fillRect(opts.x, opts.y, opts.w, opts.h);
|
|
20435
|
+
}
|
|
20436
|
+
}
|
|
20437
|
+
|
|
20438
|
+
/**
|
|
20439
|
+
* *PMW*
|
|
20440
|
+
* Draws a background for the object big as its untrasformed dimensions
|
|
20441
|
+
* @private
|
|
20442
|
+
* @param {CanvasRenderingContext2D} ctx Context to render on
|
|
20443
|
+
*/
|
|
20444
|
+
_renderBackground(ctx) {
|
|
20445
|
+
if (!this.backgroundColor) {
|
|
20446
|
+
return;
|
|
20447
|
+
}
|
|
20448
|
+
const dim = this._getNonTransformedDimensions();
|
|
20449
|
+
let scaleX = this.scaleX,
|
|
20450
|
+
scaleY = this.scaleY;
|
|
20451
|
+
ctx.fillStyle = this.backgroundColor;
|
|
20452
|
+
if (this.group) {
|
|
20453
|
+
scaleX *= this.group.scaleX;
|
|
20454
|
+
scaleY *= this.group.scaleY;
|
|
20455
|
+
}
|
|
20456
|
+
ctx.fillRect(-dim.x / 2 - this.padding / scaleX, -dim.y / 2 - this.padding / scaleY, dim.x + this.padding / scaleX * 2, dim.y + this.padding / scaleY * 2);
|
|
20457
|
+
// if there is background color no other shadows
|
|
20458
|
+
// should be casted
|
|
20386
20459
|
this._removeShadow(ctx);
|
|
20387
20460
|
}
|
|
20461
|
+
getCharOffset(position) {
|
|
20462
|
+
let topOffset = 0,
|
|
20463
|
+
leftOffset = 0;
|
|
20464
|
+
const cursorPosition = this.get2DCursorLocation(position),
|
|
20465
|
+
charIndex = cursorPosition.charIndex,
|
|
20466
|
+
lineIndex = cursorPosition.lineIndex;
|
|
20467
|
+
for (let i = 0; i < lineIndex; i++) {
|
|
20468
|
+
topOffset += this.getHeightOfLine(i);
|
|
20469
|
+
}
|
|
20470
|
+
const lineLeftOffset = this._getLineLeftOffset(lineIndex);
|
|
20471
|
+
const bound = this.__charBounds[lineIndex][charIndex];
|
|
20472
|
+
bound && (leftOffset = bound.left);
|
|
20473
|
+
if (this.charSpacing !== 0 && charIndex === this._textLines[lineIndex].length) {
|
|
20474
|
+
leftOffset -= this._getWidthOfCharSpacing();
|
|
20475
|
+
}
|
|
20476
|
+
return {
|
|
20477
|
+
x: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),
|
|
20478
|
+
y: topOffset
|
|
20479
|
+
};
|
|
20480
|
+
}
|
|
20481
|
+
|
|
20482
|
+
/**
|
|
20483
|
+
* *PMW*
|
|
20484
|
+
* Find new selection index representing start of current word according to current selection index
|
|
20485
|
+
* @param {Number} startFrom Current selection index
|
|
20486
|
+
* @return {Number} selection start index
|
|
20487
|
+
*/
|
|
20488
|
+
findSelectedWordLeft(startFrom) {
|
|
20489
|
+
let offset = 0,
|
|
20490
|
+
index = startFrom - 1;
|
|
20491
|
+
while (/[^\n -&(-/:-@[-`{-~0-9]/.test(this._text[index]) && index > -1) {
|
|
20492
|
+
offset++;
|
|
20493
|
+
index--;
|
|
20494
|
+
}
|
|
20495
|
+
return startFrom - offset;
|
|
20496
|
+
}
|
|
20497
|
+
|
|
20498
|
+
/**
|
|
20499
|
+
* *PMW*
|
|
20500
|
+
* Find new selection index representing end of current word according to current selection index
|
|
20501
|
+
* @param {Number} startFrom Current selection index
|
|
20502
|
+
* @return {Number} selection end index
|
|
20503
|
+
*/
|
|
20504
|
+
findSelectedWordRight(startFrom) {
|
|
20505
|
+
let offset = 0,
|
|
20506
|
+
index = startFrom;
|
|
20507
|
+
while (/[^\n -&(-/:-@[-`{-~0-9]/.test(this._text[index]) && index < this._text.length) {
|
|
20508
|
+
offset++;
|
|
20509
|
+
index++;
|
|
20510
|
+
}
|
|
20511
|
+
return startFrom + offset;
|
|
20512
|
+
}
|
|
20388
20513
|
|
|
20389
20514
|
/**
|
|
20390
20515
|
* return font declaration string for canvas context
|
|
@@ -20536,6 +20661,8 @@
|
|
|
20536
20661
|
underline: textDecoration.includes('underline'),
|
|
20537
20662
|
overline: textDecoration.includes('overline'),
|
|
20538
20663
|
linethrough: textDecoration.includes('line-through'),
|
|
20664
|
+
/*PMW*/
|
|
20665
|
+
squigglyline: textDecoration.includes('squiggly-line'),
|
|
20539
20666
|
// we initialize this as 0
|
|
20540
20667
|
strokeWidth: 0,
|
|
20541
20668
|
fontSize
|