@visactor/vrender 0.22.0-vstory.14 → 0.22.0-vstory.16
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/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +140 -88
- package/dist/index.js +140 -88
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2500,6 +2500,8 @@
|
|
|
2500
2500
|
return color.getLuminance2();
|
|
2501
2501
|
case "lum3":
|
|
2502
2502
|
return color.getLuminance3();
|
|
2503
|
+
case "wcag":
|
|
2504
|
+
return color.getLuminanceWCAG();
|
|
2503
2505
|
}
|
|
2504
2506
|
}
|
|
2505
2507
|
static parseColorString(value) {
|
|
@@ -2601,6 +2603,14 @@
|
|
|
2601
2603
|
getLuminance3() {
|
|
2602
2604
|
return (.299 * this.color.r + .587 * this.color.g + .114 * this.color.b) / 255;
|
|
2603
2605
|
}
|
|
2606
|
+
getLuminanceWCAG() {
|
|
2607
|
+
const RsRGB = this.color.r / 255,
|
|
2608
|
+
GsRGB = this.color.g / 255,
|
|
2609
|
+
BsRGB = this.color.b / 255;
|
|
2610
|
+
let R, G, B;
|
|
2611
|
+
R = RsRGB <= .03928 ? RsRGB / 12.92 : Math.pow((RsRGB + .055) / 1.055, 2.4), G = GsRGB <= .03928 ? GsRGB / 12.92 : Math.pow((GsRGB + .055) / 1.055, 2.4), B = BsRGB <= .03928 ? BsRGB / 12.92 : Math.pow((BsRGB + .055) / 1.055, 2.4);
|
|
2612
|
+
return .2126 * R + .7152 * G + .0722 * B;
|
|
2613
|
+
}
|
|
2604
2614
|
clone() {
|
|
2605
2615
|
return new Color(this.color.toString());
|
|
2606
2616
|
}
|
|
@@ -3914,10 +3924,10 @@
|
|
|
3914
3924
|
x = current[5], y = current[6], controlX = current[3], controlY = current[4], this.bezierCurveTo(current[1] + l, current[2] + t, controlX + l, controlY + t, x + l, y + t);
|
|
3915
3925
|
break;
|
|
3916
3926
|
case "s":
|
|
3917
|
-
tempX = x + current[3], tempY = y + current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t,
|
|
3927
|
+
tempX = x + current[3], tempY = y + current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x, controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = x + current[1], tempControlY = y + current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t), controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
|
|
3918
3928
|
break;
|
|
3919
3929
|
case "S":
|
|
3920
|
-
tempX = current[3], tempY = current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t,
|
|
3930
|
+
tempX = current[3], tempY = current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x, controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = current[1], tempControlY = current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t), controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
|
|
3921
3931
|
break;
|
|
3922
3932
|
case "q":
|
|
3923
3933
|
tempX = x + current[3], tempY = y + current[4], controlX = x + current[1], controlY = y + current[2], this.quadraticCurveTo(controlX + l, controlY + t, tempX + l, tempY + t), x = tempX, y = tempY;
|
|
@@ -4308,6 +4318,7 @@
|
|
|
4308
4318
|
keepDirIn3d: !0
|
|
4309
4319
|
});
|
|
4310
4320
|
const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), {
|
|
4321
|
+
upgradeAttrs: null,
|
|
4311
4322
|
editable: !1,
|
|
4312
4323
|
editOptions: null,
|
|
4313
4324
|
ascentDescentMode: "actual",
|
|
@@ -10144,7 +10155,7 @@
|
|
|
10144
10155
|
null != onStart && animate.onStart(onStart), null != onFrame && animate.onFrame(onFrame), null != onEnd && animate.onEnd(onEnd), null != onRemove && animate.onRemove(onRemove), animate.interpolateFunc = params.interpolate;
|
|
10145
10156
|
}
|
|
10146
10157
|
return this.animates.set(animate.id, animate), animate.onRemove(() => {
|
|
10147
|
-
this.animates.delete(animate.id);
|
|
10158
|
+
animate.stop(), this.animates.delete(animate.id);
|
|
10148
10159
|
}), animate;
|
|
10149
10160
|
}
|
|
10150
10161
|
onAttributeUpdate(context) {
|
|
@@ -10348,7 +10359,7 @@
|
|
|
10348
10359
|
if (this.stage = stage, this.layer = layer, this.setStageToShadowRoot(stage, layer), this.animates && this.animates.size) {
|
|
10349
10360
|
const timeline = stage.getTimeline();
|
|
10350
10361
|
this.animates.forEach(a => {
|
|
10351
|
-
a.setTimeline(timeline);
|
|
10362
|
+
a.timeline === defaultTimeline && a.setTimeline(timeline);
|
|
10352
10363
|
});
|
|
10353
10364
|
}
|
|
10354
10365
|
this._onSetStage && this._onSetStage(this, stage, layer), application.graphicService.onSetStage(this, stage);
|
|
@@ -10452,7 +10463,7 @@
|
|
|
10452
10463
|
return shadowRoot && (shadowRoot.shadowHost = this), this.shadowRoot = null != shadowRoot ? shadowRoot : application.graphicService.creator.shadowRoot(this), this.addUpdateBoundTag(), this.shadowRoot.setStage(this.stage, this.layer), this.shadowRoot;
|
|
10453
10464
|
}
|
|
10454
10465
|
detachShadow() {
|
|
10455
|
-
this.shadowRoot && (this.addUpdateBoundTag(), this.shadowRoot = null);
|
|
10466
|
+
this.shadowRoot && (this.addUpdateBoundTag(), this.shadowRoot.release(!0), this.shadowRoot = null);
|
|
10456
10467
|
}
|
|
10457
10468
|
toJson() {
|
|
10458
10469
|
return {
|
|
@@ -10504,7 +10515,7 @@
|
|
|
10504
10515
|
});
|
|
10505
10516
|
}
|
|
10506
10517
|
release() {
|
|
10507
|
-
this.releaseStatus = "released", application.graphicService.onRelease(this);
|
|
10518
|
+
this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this);
|
|
10508
10519
|
}
|
|
10509
10520
|
_emitCustomEvent(type, context) {
|
|
10510
10521
|
var _a, _b;
|
|
@@ -11080,6 +11091,11 @@
|
|
|
11080
11091
|
getNoWorkAnimateAttr() {
|
|
11081
11092
|
return Group.NOWORK_ANIMATE_ATTR;
|
|
11082
11093
|
}
|
|
11094
|
+
release(all) {
|
|
11095
|
+
all && this.forEachChildren(g => {
|
|
11096
|
+
g.release(all);
|
|
11097
|
+
}), super.release();
|
|
11098
|
+
}
|
|
11083
11099
|
}
|
|
11084
11100
|
Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
11085
11101
|
function createGroup(attributes) {
|
|
@@ -13947,7 +13963,7 @@
|
|
|
13947
13963
|
this.width = width, "vertical" === this.direction && (this.widthOrigin = this.width, this.width = this.heightOrigin, this.height = this.widthOrigin);
|
|
13948
13964
|
}
|
|
13949
13965
|
drawBackground(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
|
|
13950
|
-
if (!this.character.background || this.character.backgroundOpacity && !(this.character.backgroundOpacity > 0)) return;
|
|
13966
|
+
if ("" === this.text || "\n" === this.text || !this.character.background || this.character.backgroundOpacity && !(this.character.backgroundOpacity > 0)) return;
|
|
13951
13967
|
let baseline = top + ascent,
|
|
13952
13968
|
text = this.text,
|
|
13953
13969
|
left = this.left + deltaLeft;
|
|
@@ -13965,19 +13981,11 @@
|
|
|
13965
13981
|
}
|
|
13966
13982
|
}
|
|
13967
13983
|
}
|
|
13968
|
-
switch (this.character.script) {
|
|
13969
|
-
case "super":
|
|
13970
|
-
baseline -= this.ascent * (1 / 3);
|
|
13971
|
-
break;
|
|
13972
|
-
case "sub":
|
|
13973
|
-
baseline += this.descent / 2;
|
|
13974
|
-
}
|
|
13975
|
-
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
|
|
13976
|
-
const fillStyle = ctx.fillStyle,
|
|
13977
|
-
globalAlpha = ctx.globalAlpha;
|
|
13978
|
-
ctx.fillStyle = this.character.background, void 0 !== this.character.backgroundOpacity && (ctx.globalAlpha = this.character.backgroundOpacity);
|
|
13979
13984
|
const lrtb = getFixedLRTB(left, left + (this.widthOrigin || this.width), top, top + lineHeight);
|
|
13980
|
-
|
|
13985
|
+
return Object.assign(Object.assign({}, lrtb), {
|
|
13986
|
+
fillStyle: this.character.background,
|
|
13987
|
+
globalAlpha: this.character.backgroundOpacity
|
|
13988
|
+
});
|
|
13981
13989
|
}
|
|
13982
13990
|
draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
|
|
13983
13991
|
let baseline = top + ascent,
|
|
@@ -14251,8 +14259,19 @@
|
|
|
14251
14259
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
14252
14260
|
}
|
|
14253
14261
|
}
|
|
14262
|
+
let fillStyle = "",
|
|
14263
|
+
globalAlpha = -1,
|
|
14264
|
+
currBgList = [];
|
|
14265
|
+
const bgList = [currBgList];
|
|
14254
14266
|
this.paragraphs.forEach((paragraph, index) => {
|
|
14255
|
-
paragraph instanceof RichTextIcon
|
|
14267
|
+
if (paragraph instanceof RichTextIcon) return;
|
|
14268
|
+
const data = paragraph.drawBackground(ctx, y, this.ascent, x, 0 === index, this.textAlign, this.height);
|
|
14269
|
+
data && (fillStyle === data.fillStyle && globalAlpha === data.globalAlpha || (currBgList = [], bgList.push(currBgList), fillStyle = data.fillStyle, globalAlpha = data.globalAlpha), currBgList.push(data));
|
|
14270
|
+
}), bgList.forEach(bg => {
|
|
14271
|
+
if (0 === bg.length) return;
|
|
14272
|
+
const data = bg[0],
|
|
14273
|
+
end = bg[bg.length - 1];
|
|
14274
|
+
ctx.fillStyle = data.fillStyle, ctx.globalAlpha = data.globalAlpha, ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
|
|
14256
14275
|
}), this.paragraphs.forEach((paragraph, index) => {
|
|
14257
14276
|
if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
|
|
14258
14277
|
x: x + paragraph._x,
|
|
@@ -14490,7 +14509,7 @@
|
|
|
14490
14509
|
case "right":
|
|
14491
14510
|
deltaX = -aabbBounds.width();
|
|
14492
14511
|
}
|
|
14493
|
-
return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), aabbBounds;
|
|
14512
|
+
return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
|
|
14494
14513
|
}
|
|
14495
14514
|
needUpdateTags(keys) {
|
|
14496
14515
|
return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
|
|
@@ -14518,48 +14537,53 @@
|
|
|
14518
14537
|
}
|
|
14519
14538
|
combinedStyleToCharacter(config) {
|
|
14520
14539
|
const {
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14539
|
-
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14540
|
+
fill: fill,
|
|
14541
|
+
stroke: stroke,
|
|
14542
|
+
fontSize: fontSize,
|
|
14543
|
+
fontFamily: fontFamily,
|
|
14544
|
+
fontStyle: fontStyle,
|
|
14545
|
+
fontWeight: fontWeight,
|
|
14546
|
+
lineWidth: lineWidth,
|
|
14547
|
+
opacity: opacity,
|
|
14548
|
+
fillOpacity: fillOpacity,
|
|
14549
|
+
lineHeight: lineHeight,
|
|
14550
|
+
strokeOpacity: strokeOpacity,
|
|
14551
|
+
upgradeAttrs: upgradeAttrs
|
|
14552
|
+
} = this.attribute,
|
|
14553
|
+
out = Object.assign({
|
|
14554
|
+
fill: fill,
|
|
14555
|
+
stroke: stroke,
|
|
14556
|
+
fontSize: fontSize,
|
|
14557
|
+
fontFamily: fontFamily,
|
|
14558
|
+
fontStyle: fontStyle,
|
|
14559
|
+
fontWeight: fontWeight,
|
|
14560
|
+
lineWidth: lineWidth,
|
|
14561
|
+
opacity: opacity,
|
|
14562
|
+
fillOpacity: fillOpacity,
|
|
14563
|
+
strokeOpacity: strokeOpacity
|
|
14564
|
+
}, config);
|
|
14565
|
+
return (null == upgradeAttrs ? void 0 : upgradeAttrs.lineHeight) && (out.lineHeight = lineHeight), out;
|
|
14544
14566
|
}
|
|
14545
14567
|
doUpdateFrameCache(tc) {
|
|
14546
14568
|
var _a;
|
|
14547
14569
|
const {
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
|
|
14557
|
-
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
|
|
14570
|
+
maxWidth: maxWidth,
|
|
14571
|
+
maxHeight: maxHeight,
|
|
14572
|
+
width: width,
|
|
14573
|
+
height: height,
|
|
14574
|
+
ellipsis: ellipsis,
|
|
14575
|
+
wordBreak: wordBreak,
|
|
14576
|
+
verticalDirection: verticalDirection,
|
|
14577
|
+
textAlign: textAlign,
|
|
14578
|
+
textBaseline: textBaseline,
|
|
14579
|
+
layoutDirection: layoutDirection,
|
|
14580
|
+
singleLine: singleLine,
|
|
14581
|
+
disableAutoWrapLine: disableAutoWrapLine,
|
|
14582
|
+
editable: editable,
|
|
14583
|
+
ascentDescentMode: ascentDescentMode,
|
|
14584
|
+
upgradeAttrs: upgradeAttrs
|
|
14585
|
+
} = this.attribute,
|
|
14586
|
+
enableMultiBreakLine = upgradeAttrs && upgradeAttrs.multiBreakLine;
|
|
14563
14587
|
let {
|
|
14564
14588
|
textConfig: _tc = []
|
|
14565
14589
|
} = this.attribute;
|
|
@@ -14581,7 +14605,10 @@
|
|
|
14581
14605
|
const richTextConfig = this.combinedStyleToCharacter(textConfig[i]);
|
|
14582
14606
|
if (isNumber$1(richTextConfig.text) && (richTextConfig.text = `${richTextConfig.text}`), richTextConfig.text && richTextConfig.text.includes("\n")) {
|
|
14583
14607
|
const textParts = richTextConfig.text.split("\n");
|
|
14584
|
-
for (let j = 0; j < textParts.length; j++) paragraphs.push(new Paragraph(textParts[j],
|
|
14608
|
+
for (let j = 0; j < textParts.length; j++) if (0 === j) paragraphs.push(new Paragraph(textParts[j], !1, richTextConfig, ascentDescentMode));else if (textParts[j] || i === textConfig.length - 1) paragraphs.push(new Paragraph(textParts[j], !0, richTextConfig, ascentDescentMode));else {
|
|
14609
|
+
const nextRichTextConfig = this.combinedStyleToCharacter(textConfig[i + 1]);
|
|
14610
|
+
paragraphs.push(new Paragraph(textParts[j], !0, nextRichTextConfig, ascentDescentMode));
|
|
14611
|
+
}
|
|
14585
14612
|
} else richTextConfig.text && paragraphs.push(new Paragraph(richTextConfig.text, !1, richTextConfig, ascentDescentMode));
|
|
14586
14613
|
}
|
|
14587
14614
|
const maxWidthFinite = "number" == typeof maxWidth && Number.isFinite(maxWidth) && maxWidth > 0,
|
|
@@ -14590,7 +14617,7 @@
|
|
|
14590
14617
|
richTextHeightEnable = "number" == typeof height && Number.isFinite(height) && height > 0 && (!maxHeightFinite || height <= maxHeight),
|
|
14591
14618
|
frame = new Frame(0, 0, (richTextWidthEnable ? width : maxWidthFinite ? maxWidth : 0) || 0, (richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0) || 0, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection || "horizontal", !richTextWidthEnable && maxWidthFinite, !richTextHeightEnable && maxHeightFinite, singleLine || !1, null === (_a = this._frameCache) || void 0 === _a ? void 0 : _a.icons),
|
|
14592
14619
|
wrapper = new Wrapper(frame);
|
|
14593
|
-
if (wrapper.newLine =
|
|
14620
|
+
if (wrapper.newLine = enableMultiBreakLine, disableAutoWrapLine) {
|
|
14594
14621
|
let lineCount = 0,
|
|
14595
14622
|
skip = !1;
|
|
14596
14623
|
for (let i = 0; i < paragraphs.length; i++) {
|
|
@@ -14606,7 +14633,7 @@
|
|
|
14606
14633
|
l.calcOffset(offsetSize, !1);
|
|
14607
14634
|
});
|
|
14608
14635
|
}
|
|
14609
|
-
|
|
14636
|
+
enableMultiBreakLine && frame.lines.forEach(item => {
|
|
14610
14637
|
const lastParagraphs = item.paragraphs;
|
|
14611
14638
|
item.paragraphs = item.paragraphs.filter(p => "" !== p.text), 0 === item.paragraphs.length && lastParagraphs.length && (lastParagraphs[0].text = "\n", item.paragraphs.push(lastParagraphs[0]));
|
|
14612
14639
|
}), this._frameCache = frame;
|
|
@@ -20264,6 +20291,7 @@
|
|
|
20264
20291
|
fill = "black",
|
|
20265
20292
|
stroke = !1,
|
|
20266
20293
|
fontWeight = "normal",
|
|
20294
|
+
lineHeight: lineHeight,
|
|
20267
20295
|
fontFamily = "Arial"
|
|
20268
20296
|
} = attribute;
|
|
20269
20297
|
let {
|
|
@@ -20274,7 +20302,8 @@
|
|
|
20274
20302
|
stroke: stroke,
|
|
20275
20303
|
fontSize: fontSize,
|
|
20276
20304
|
fontWeight: fontWeight,
|
|
20277
|
-
fontFamily: fontFamily
|
|
20305
|
+
fontFamily: fontFamily,
|
|
20306
|
+
lineHeight: lineHeight
|
|
20278
20307
|
};
|
|
20279
20308
|
}
|
|
20280
20309
|
function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
|
|
@@ -20523,15 +20552,15 @@
|
|
|
20523
20552
|
}, this.handleFocusOut = () => {
|
|
20524
20553
|
throw new Error("不会走到这里 handleFocusOut");
|
|
20525
20554
|
}, this.handleMove = e => {
|
|
20526
|
-
this.
|
|
20555
|
+
this.currRt && !this.currRt.attribute.editable && this.deFocus(!0), this.isEditableRichtext(e) ? (this.handleEnter(), e.target.once("pointerleave", this.handleLeave, {
|
|
20527
20556
|
capture: !0
|
|
20528
|
-
}), this.tryShowSelection(e, !1));
|
|
20529
|
-
}, this.handleEnter =
|
|
20557
|
+
}), this.tryShowSelection(e, !1)) : this.handleLeave();
|
|
20558
|
+
}, this.handleEnter = () => {
|
|
20530
20559
|
this.editing = !0, this.pluginService.stage.setCursor("text");
|
|
20531
|
-
}, this.handleLeave =
|
|
20560
|
+
}, this.handleLeave = () => {
|
|
20532
20561
|
this.editing = !1, this.pluginService.stage.setCursor("default");
|
|
20533
20562
|
}, this.handlePointerDown = e => {
|
|
20534
|
-
this.editing ? this.onFocus(e) : this.deFocus(!0), this.triggerRender(), this.pointerDown = !0, this.updateCbs.forEach(cb => cb(this.editing ? "onfocus" : "defocus", this));
|
|
20563
|
+
this.editing && this.isEditableRichtext(e) ? this.onFocus(e) : this.deFocus(!0), this.triggerRender(), this.pointerDown = !0, this.updateCbs.forEach(cb => cb(this.editing ? "onfocus" : "defocus", this));
|
|
20535
20564
|
}, this.handlePointerUp = e => {
|
|
20536
20565
|
this.pointerDown = !1;
|
|
20537
20566
|
}, this.handleDBLClick = e => {
|
|
@@ -20639,7 +20668,7 @@
|
|
|
20639
20668
|
} = cache,
|
|
20640
20669
|
totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
|
|
20641
20670
|
if (x) {
|
|
20642
|
-
x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x, this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1);
|
|
20671
|
+
x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x, this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1), this.selectionStartCursorIdx = this.curCursorIdx;
|
|
20643
20672
|
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
|
|
20644
20673
|
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this.hideSelection();
|
|
20645
20674
|
}
|
|
@@ -20732,7 +20761,8 @@
|
|
|
20732
20761
|
lineWidth: 1,
|
|
20733
20762
|
zIndex: -1
|
|
20734
20763
|
});
|
|
20735
|
-
this.getShadow(this.currRt)
|
|
20764
|
+
const shadow = this.getShadow(this.currRt);
|
|
20765
|
+
this.addEditLineOrBgOrBounds(this.shadowBounds, shadow), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
|
|
20736
20766
|
}
|
|
20737
20767
|
trySyncPlaceholderToTextConfig() {
|
|
20738
20768
|
if (!this.currRt) return;
|
|
@@ -20767,8 +20797,22 @@
|
|
|
20767
20797
|
stopPropagation(e) {
|
|
20768
20798
|
e.stopPropagation();
|
|
20769
20799
|
}
|
|
20800
|
+
addEditLineOrBgOrBounds(graphic, shadowRoot) {
|
|
20801
|
+
let group = shadowRoot.getElementById("emptyBoundsContainer");
|
|
20802
|
+
group || (group = createGroup({
|
|
20803
|
+
x: 0,
|
|
20804
|
+
y: 0,
|
|
20805
|
+
width: 0,
|
|
20806
|
+
height: 0,
|
|
20807
|
+
boundsMode: "empty"
|
|
20808
|
+
}), group.id = "emptyBoundsContainer", shadowRoot.add(group)), group.add(graphic);
|
|
20809
|
+
}
|
|
20810
|
+
removeEditLineOrBgOrBounds(graphic, shadowRoot) {
|
|
20811
|
+
const group = shadowRoot.getElementById("emptyBoundsContainer");
|
|
20812
|
+
group && group.removeChild(graphic);
|
|
20813
|
+
}
|
|
20770
20814
|
onFocus(e, data) {
|
|
20771
|
-
this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
|
|
20815
|
+
this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0, this.editing = !0;
|
|
20772
20816
|
const target = e.target;
|
|
20773
20817
|
if (!target || "richtext" !== target.type) return;
|
|
20774
20818
|
this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
|
|
@@ -20792,7 +20836,7 @@
|
|
|
20792
20836
|
width: 0,
|
|
20793
20837
|
height: 0
|
|
20794
20838
|
});
|
|
20795
|
-
this.editBg = g,
|
|
20839
|
+
this.editBg = g, this.addEditLineOrBgOrBounds(this.editLine, shadowRoot), this.addEditLineOrBgOrBounds(this.editBg, shadowRoot);
|
|
20796
20840
|
}
|
|
20797
20841
|
if (data = data || this.computedCursorPosByEvent(e, cache)) {
|
|
20798
20842
|
const {
|
|
@@ -20857,27 +20901,29 @@
|
|
|
20857
20901
|
}
|
|
20858
20902
|
deFocus() {
|
|
20859
20903
|
let trulyDeFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
|
|
20860
|
-
this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
|
|
20904
|
+
this.editing = !1, this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
|
|
20861
20905
|
trulyDeFocus: trulyDeFocus
|
|
20862
20906
|
}));
|
|
20863
|
-
const
|
|
20864
|
-
if (!
|
|
20907
|
+
const currRt = this.currRt;
|
|
20908
|
+
if (!currRt) return;
|
|
20865
20909
|
const {
|
|
20866
20910
|
editOptions = {}
|
|
20867
|
-
} =
|
|
20868
|
-
editOptions.stopPropagation &&
|
|
20869
|
-
const
|
|
20870
|
-
this.
|
|
20911
|
+
} = currRt.attribute;
|
|
20912
|
+
editOptions.stopPropagation && currRt.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()), this.currRt = null;
|
|
20913
|
+
const shadowRoot = this.getShadow(currRt);
|
|
20914
|
+
this.editLine && (this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot), this.editLine.release(), this.editLine = null, this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot), this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder), this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1;
|
|
20871
20915
|
const textConfig = currRt.attribute.textConfig;
|
|
20872
20916
|
let lastConfig = textConfig[textConfig.length - 1],
|
|
20873
20917
|
cleared = !1;
|
|
20874
20918
|
for (; lastConfig && "\n" === lastConfig.text;) textConfig.pop(), lastConfig = textConfig[textConfig.length - 1], cleared = !0;
|
|
20875
20919
|
cleared && currRt.setAttributes({
|
|
20876
20920
|
textConfig: textConfig
|
|
20877
|
-
});
|
|
20921
|
+
}), currRt.removeEventListener("pointerleave", this.handleLeave);
|
|
20878
20922
|
}
|
|
20879
20923
|
addAnimateToLine(line) {
|
|
20880
|
-
line.
|
|
20924
|
+
line.setAttributes({
|
|
20925
|
+
opacity: 1
|
|
20926
|
+
}), line.animates && line.animates.forEach(animate => {
|
|
20881
20927
|
animate.stop(), animate.release();
|
|
20882
20928
|
});
|
|
20883
20929
|
line.animate({
|
|
@@ -20986,7 +21032,8 @@
|
|
|
20986
21032
|
getShadow(rt) {
|
|
20987
21033
|
const sr = rt.shadowRoot || rt.attachShadow();
|
|
20988
21034
|
return sr.setAttributes({
|
|
20989
|
-
|
|
21035
|
+
width: 1,
|
|
21036
|
+
height: 1
|
|
20990
21037
|
}), sr;
|
|
20991
21038
|
}
|
|
20992
21039
|
getLineByPoint(cache, p1) {
|
|
@@ -21020,7 +21067,10 @@
|
|
|
21020
21067
|
return -1;
|
|
21021
21068
|
}
|
|
21022
21069
|
isRichtext(e) {
|
|
21023
|
-
return !(!e.target || "richtext" !== e.target.type
|
|
21070
|
+
return !(!e.target || "richtext" !== e.target.type);
|
|
21071
|
+
}
|
|
21072
|
+
isEditableRichtext(e) {
|
|
21073
|
+
return this.isRichtext(e) && !!e.target.attribute.editable;
|
|
21024
21074
|
}
|
|
21025
21075
|
triggerRender() {
|
|
21026
21076
|
this.pluginService.stage.renderNextFrame();
|
|
@@ -21166,7 +21216,7 @@
|
|
|
21166
21216
|
target && (this.currRt = target, e ? this._forceFocusByEvent(e) : this._forceFocusByCursorIndex(null != cursorIndex ? cursorIndex : -.1));
|
|
21167
21217
|
}
|
|
21168
21218
|
_forceFocusByEvent(e) {
|
|
21169
|
-
this.handleEnter(
|
|
21219
|
+
this.handleEnter(), this.handlePointerDown(e), this.handlePointerUp(e);
|
|
21170
21220
|
}
|
|
21171
21221
|
_forceFocusByCursorIndex(cursorIndex) {
|
|
21172
21222
|
const richtext = this.currRt;
|
|
@@ -27487,13 +27537,15 @@
|
|
|
27487
27537
|
this.canvas = new NodeCanvas(options);
|
|
27488
27538
|
}
|
|
27489
27539
|
createWindowByCanvas(params) {
|
|
27490
|
-
|
|
27540
|
+
var _a;
|
|
27541
|
+
const canvas = params.canvas,
|
|
27542
|
+
dpr = null !== (_a = params.dpr) && void 0 !== _a ? _a : 1;
|
|
27491
27543
|
let width = params.width,
|
|
27492
27544
|
height = params.height;
|
|
27493
|
-
null != width && null != height && params.canvasControled || (width = canvas.width, height = canvas.height), this.canvas = new NodeCanvas({
|
|
27545
|
+
null != width && null != height && params.canvasControled || (width = canvas.width / dpr, height = canvas.height / dpr), this.canvas = new NodeCanvas({
|
|
27494
27546
|
width: width,
|
|
27495
27547
|
height: height,
|
|
27496
|
-
dpr:
|
|
27548
|
+
dpr: dpr,
|
|
27497
27549
|
nativeCanvas: canvas,
|
|
27498
27550
|
canvasControled: params.canvasControled
|
|
27499
27551
|
});
|
|
@@ -31233,7 +31285,7 @@
|
|
|
31233
31285
|
|
|
31234
31286
|
const roughModule = _roughModule;
|
|
31235
31287
|
|
|
31236
|
-
const version = "0.22.0-vstory.
|
|
31288
|
+
const version = "0.22.0-vstory.16";
|
|
31237
31289
|
preLoadAllModule();
|
|
31238
31290
|
if (isBrowserEnv()) {
|
|
31239
31291
|
loadBrowserEnv(container);
|