@visactor/vrender-core 0.22.0-vstory.15 → 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/common/custom-path2d.js +8 -6
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/graphic/config.js +1 -0
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic.js +4 -4
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.d.ts +1 -0
- package/cjs/graphic/group.js +5 -0
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/richtext/line.js +11 -1
- package/cjs/graphic/richtext/line.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.d.ts +8 -1
- package/cjs/graphic/richtext/paragraph.js +5 -16
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/richtext.js +10 -6
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +4 -0
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.js +3 -2
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +6 -3
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +48 -24
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/dist/index.es.js +144 -70
- package/es/common/custom-path2d.js +8 -6
- package/es/common/custom-path2d.js.map +1 -1
- package/es/graphic/config.js +1 -0
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic.js +5 -5
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.d.ts +1 -0
- package/es/graphic/group.js +5 -0
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/richtext/line.js +11 -1
- package/es/graphic/richtext/line.js.map +1 -1
- package/es/graphic/richtext/paragraph.d.ts +8 -1
- package/es/graphic/richtext/paragraph.js +5 -16
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/richtext.js +10 -6
- package/es/graphic/richtext.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +4 -0
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.js +3 -2
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +6 -3
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +48 -24
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -2963,24 +2963,40 @@ class CustomPath2D extends CurvePath {
|
|
|
2963
2963
|
case 's':
|
|
2964
2964
|
tempX = x + current[3];
|
|
2965
2965
|
tempY = y + current[4];
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2966
|
+
if (previous[0].match(/[CcSs]/) === null) {
|
|
2967
|
+
controlX = x;
|
|
2968
|
+
controlY = y;
|
|
2969
|
+
}
|
|
2970
|
+
else {
|
|
2971
|
+
controlX = 2 * x - controlX;
|
|
2972
|
+
controlY = 2 * y - controlY;
|
|
2973
|
+
}
|
|
2974
|
+
tempControlX = x + current[1];
|
|
2975
|
+
tempControlY = y + current[2];
|
|
2976
|
+
this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t);
|
|
2977
|
+
controlX = tempControlX;
|
|
2978
|
+
controlY = tempControlY;
|
|
2971
2979
|
x = tempX;
|
|
2972
2980
|
y = tempY;
|
|
2973
2981
|
break;
|
|
2974
2982
|
case 'S':
|
|
2975
2983
|
tempX = current[3];
|
|
2976
2984
|
tempY = current[4];
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2985
|
+
if (previous[0].match(/[CcSs]/) === null) {
|
|
2986
|
+
controlX = x;
|
|
2987
|
+
controlY = y;
|
|
2988
|
+
}
|
|
2989
|
+
else {
|
|
2990
|
+
controlX = 2 * x - controlX;
|
|
2991
|
+
controlY = 2 * y - controlY;
|
|
2992
|
+
}
|
|
2993
|
+
tempControlX = current[1];
|
|
2994
|
+
tempControlY = current[2];
|
|
2995
|
+
this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t);
|
|
2996
|
+
controlX = tempControlX;
|
|
2997
|
+
controlY = tempControlY;
|
|
2980
2998
|
x = tempX;
|
|
2981
2999
|
y = tempY;
|
|
2982
|
-
controlX = current[1];
|
|
2983
|
-
controlY = current[2];
|
|
2984
3000
|
break;
|
|
2985
3001
|
case 'q':
|
|
2986
3002
|
tempX = x + current[3];
|
|
@@ -3321,7 +3337,7 @@ const DefaultRectAttribute = Object.assign(Object.assign({}, DefaultAttribute),
|
|
|
3321
3337
|
const DefaultRect3dAttribute = Object.assign(Object.assign({}, DefaultAttribute), { width: 0, height: 0, x1: 0, y1: 0, cornerRadius: 0, length: 0, cornerType: 'round' });
|
|
3322
3338
|
const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), { symbolType: 'circle', size: 10, keepDirIn3d: true, clipRange: 1 });
|
|
3323
3339
|
const DefaultTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { strokeBoundsBuffer: 0, keepDirIn3d: true });
|
|
3324
|
-
const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { editable: false, editOptions: null, ascentDescentMode: 'actual', width: 300, height: 300, ellipsis: true, wordBreak: 'break-word', verticalDirection: 'top', textAlign: 'left', textBaseline: 'top', layoutDirection: 'horizontal', textConfig: [], disableAutoWrapLine: false, maxHeight: undefined, maxWidth: undefined, singleLine: false });
|
|
3340
|
+
const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { upgradeAttrs: null, editable: false, editOptions: null, ascentDescentMode: 'actual', width: 300, height: 300, ellipsis: true, wordBreak: 'break-word', verticalDirection: 'top', textAlign: 'left', textBaseline: 'top', layoutDirection: 'horizontal', textConfig: [], disableAutoWrapLine: false, maxHeight: undefined, maxWidth: undefined, singleLine: false });
|
|
3325
3341
|
const DefaultImageAttribute = Object.assign(Object.assign({ repeatX: 'no-repeat', repeatY: 'no-repeat', image: '', width: 0, height: 0 }, DefaultAttribute), { fill: true, cornerRadius: 0, cornerType: 'round' });
|
|
3326
3342
|
const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImageAttribute), { backgroundShowMode: 'never', backgroundWidth: 0, backgroundHeight: 0, textAlign: 'left', textBaseline: 'middle', direction: 'horizontal', margin: 0, id: '', width: 20, height: 20, backgroundFill: 'rgba(101, 117, 168, 0.1)', backgroundFillOpacity: 1, backgroundStroke: false, backgroundStrokeOpacity: 1, backgroundRadius: 4, opacity: 1 });
|
|
3327
3343
|
|
|
@@ -12412,6 +12428,7 @@ class Graphic extends Node {
|
|
|
12412
12428
|
}
|
|
12413
12429
|
this.animates.set(animate.id, animate);
|
|
12414
12430
|
animate.onRemove(() => {
|
|
12431
|
+
animate.stop();
|
|
12415
12432
|
this.animates.delete(animate.id);
|
|
12416
12433
|
});
|
|
12417
12434
|
return animate;
|
|
@@ -12712,7 +12729,9 @@ class Graphic extends Node {
|
|
|
12712
12729
|
if (this.animates && this.animates.size) {
|
|
12713
12730
|
const timeline = stage.getTimeline();
|
|
12714
12731
|
this.animates.forEach(a => {
|
|
12715
|
-
a.
|
|
12732
|
+
if (a.timeline === defaultTimeline) {
|
|
12733
|
+
a.setTimeline(timeline);
|
|
12734
|
+
}
|
|
12716
12735
|
});
|
|
12717
12736
|
}
|
|
12718
12737
|
this._onSetStage && this._onSetStage(this, stage, layer);
|
|
@@ -12886,6 +12905,7 @@ class Graphic extends Node {
|
|
|
12886
12905
|
detachShadow() {
|
|
12887
12906
|
if (this.shadowRoot) {
|
|
12888
12907
|
this.addUpdateBoundTag();
|
|
12908
|
+
this.shadowRoot.release(true);
|
|
12889
12909
|
this.shadowRoot = null;
|
|
12890
12910
|
}
|
|
12891
12911
|
}
|
|
@@ -12993,6 +13013,7 @@ class Graphic extends Node {
|
|
|
12993
13013
|
}
|
|
12994
13014
|
release() {
|
|
12995
13015
|
this.releaseStatus = 'released';
|
|
13016
|
+
this.stopAnimates();
|
|
12996
13017
|
application.graphicService.onRelease(this);
|
|
12997
13018
|
}
|
|
12998
13019
|
_emitCustomEvent(type, context) {
|
|
@@ -13807,6 +13828,14 @@ class Group extends Graphic {
|
|
|
13807
13828
|
getNoWorkAnimateAttr() {
|
|
13808
13829
|
return Group.NOWORK_ANIMATE_ATTR;
|
|
13809
13830
|
}
|
|
13831
|
+
release(all) {
|
|
13832
|
+
if (all) {
|
|
13833
|
+
this.forEachChildren((g) => {
|
|
13834
|
+
g.release(all);
|
|
13835
|
+
});
|
|
13836
|
+
}
|
|
13837
|
+
super.release();
|
|
13838
|
+
}
|
|
13810
13839
|
}
|
|
13811
13840
|
Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
13812
13841
|
function createGroup(attributes) {
|
|
@@ -17950,7 +17979,10 @@ class Paragraph {
|
|
|
17950
17979
|
}
|
|
17951
17980
|
}
|
|
17952
17981
|
drawBackground(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
|
|
17953
|
-
if (!(this.
|
|
17982
|
+
if (!(this.text !== '' &&
|
|
17983
|
+
this.text !== '\n' &&
|
|
17984
|
+
this.character.background &&
|
|
17985
|
+
(!this.character.backgroundOpacity || this.character.backgroundOpacity > 0))) {
|
|
17954
17986
|
return;
|
|
17955
17987
|
}
|
|
17956
17988
|
let baseline = top + ascent;
|
|
@@ -17984,34 +18016,10 @@ class Paragraph {
|
|
|
17984
18016
|
}
|
|
17985
18017
|
}
|
|
17986
18018
|
}
|
|
17987
|
-
switch (this.character.script) {
|
|
17988
|
-
case 'super':
|
|
17989
|
-
baseline -= this.ascent * (1 / 3);
|
|
17990
|
-
break;
|
|
17991
|
-
case 'sub':
|
|
17992
|
-
baseline += this.descent / 2;
|
|
17993
|
-
break;
|
|
17994
|
-
}
|
|
17995
|
-
if (direction === 'vertical') {
|
|
17996
|
-
ctx.save();
|
|
17997
|
-
ctx.rotateAbout(Math.PI / 2, left, baseline);
|
|
17998
|
-
ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2);
|
|
17999
|
-
ctx.translate(left, baseline);
|
|
18000
|
-
left = 0;
|
|
18001
|
-
baseline = 0;
|
|
18002
|
-
}
|
|
18003
|
-
const fillStyle = ctx.fillStyle;
|
|
18004
|
-
const globalAlpha = ctx.globalAlpha;
|
|
18005
|
-
ctx.fillStyle = this.character.background;
|
|
18006
|
-
if (this.character.backgroundOpacity !== void 0) {
|
|
18007
|
-
ctx.globalAlpha = this.character.backgroundOpacity;
|
|
18008
|
-
}
|
|
18009
18019
|
const right = left + (this.widthOrigin || this.width);
|
|
18010
18020
|
const bottom = top + lineHeight;
|
|
18011
18021
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18012
|
-
|
|
18013
|
-
ctx.fillStyle = fillStyle;
|
|
18014
|
-
ctx.globalAlpha = globalAlpha;
|
|
18022
|
+
return Object.assign(Object.assign({}, lrtb), { fillStyle: this.character.background, globalAlpha: this.character.backgroundOpacity });
|
|
18015
18023
|
}
|
|
18016
18024
|
draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
|
|
18017
18025
|
let baseline = top + ascent;
|
|
@@ -18436,11 +18444,35 @@ class Line {
|
|
|
18436
18444
|
}
|
|
18437
18445
|
}
|
|
18438
18446
|
}
|
|
18447
|
+
let fillStyle = '';
|
|
18448
|
+
let globalAlpha = -1;
|
|
18449
|
+
let currBgList = [];
|
|
18450
|
+
const bgList = [currBgList];
|
|
18439
18451
|
this.paragraphs.forEach((paragraph, index) => {
|
|
18440
18452
|
if (paragraph instanceof RichTextIcon) {
|
|
18441
18453
|
return;
|
|
18442
18454
|
}
|
|
18443
|
-
paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
|
|
18455
|
+
const data = paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
|
|
18456
|
+
if (!data) {
|
|
18457
|
+
return;
|
|
18458
|
+
}
|
|
18459
|
+
if (!(fillStyle === data.fillStyle && globalAlpha === data.globalAlpha)) {
|
|
18460
|
+
currBgList = [];
|
|
18461
|
+
bgList.push(currBgList);
|
|
18462
|
+
fillStyle = data.fillStyle;
|
|
18463
|
+
globalAlpha = data.globalAlpha;
|
|
18464
|
+
}
|
|
18465
|
+
currBgList.push(data);
|
|
18466
|
+
});
|
|
18467
|
+
bgList.forEach(bg => {
|
|
18468
|
+
if (bg.length === 0) {
|
|
18469
|
+
return;
|
|
18470
|
+
}
|
|
18471
|
+
const data = bg[0];
|
|
18472
|
+
const end = bg[bg.length - 1];
|
|
18473
|
+
ctx.fillStyle = data.fillStyle;
|
|
18474
|
+
ctx.globalAlpha = data.globalAlpha;
|
|
18475
|
+
ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
|
|
18444
18476
|
});
|
|
18445
18477
|
this.paragraphs.forEach((paragraph, index) => {
|
|
18446
18478
|
if (paragraph instanceof RichTextIcon) {
|
|
@@ -18910,8 +18942,8 @@ class RichText extends Graphic {
|
|
|
18910
18942
|
return false;
|
|
18911
18943
|
}
|
|
18912
18944
|
combinedStyleToCharacter(config) {
|
|
18913
|
-
const { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight, lineWidth, opacity, fillOpacity, strokeOpacity } = this.attribute;
|
|
18914
|
-
|
|
18945
|
+
const { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight, lineWidth, opacity, fillOpacity, lineHeight, strokeOpacity, upgradeAttrs } = this.attribute;
|
|
18946
|
+
const out = Object.assign({ fill,
|
|
18915
18947
|
stroke,
|
|
18916
18948
|
fontSize,
|
|
18917
18949
|
fontFamily,
|
|
@@ -18921,10 +18953,15 @@ class RichText extends Graphic {
|
|
|
18921
18953
|
opacity,
|
|
18922
18954
|
fillOpacity,
|
|
18923
18955
|
strokeOpacity }, config);
|
|
18956
|
+
if (upgradeAttrs === null || upgradeAttrs === void 0 ? void 0 : upgradeAttrs.lineHeight) {
|
|
18957
|
+
out.lineHeight = lineHeight;
|
|
18958
|
+
}
|
|
18959
|
+
return out;
|
|
18924
18960
|
}
|
|
18925
18961
|
doUpdateFrameCache(tc) {
|
|
18926
18962
|
var _a;
|
|
18927
|
-
const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable, ascentDescentMode } = this.attribute;
|
|
18963
|
+
const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable, ascentDescentMode, upgradeAttrs } = this.attribute;
|
|
18964
|
+
const enableMultiBreakLine = upgradeAttrs && upgradeAttrs.multiBreakLine;
|
|
18928
18965
|
let { textConfig: _tc = [] } = this.attribute;
|
|
18929
18966
|
if (editable && _tc.length > 0 && !RichText.AllSingleCharacter(_tc)) {
|
|
18930
18967
|
_tc = RichText.TransformTextConfig2SingleCharacter(_tc);
|
|
@@ -18959,7 +18996,16 @@ class RichText extends Graphic {
|
|
|
18959
18996
|
if (richTextConfig.text && richTextConfig.text.includes('\n')) {
|
|
18960
18997
|
const textParts = richTextConfig.text.split('\n');
|
|
18961
18998
|
for (let j = 0; j < textParts.length; j++) {
|
|
18962
|
-
|
|
18999
|
+
if (j === 0) {
|
|
19000
|
+
paragraphs.push(new Paragraph(textParts[j], false, richTextConfig, ascentDescentMode));
|
|
19001
|
+
}
|
|
19002
|
+
else if (textParts[j] || i === textConfig.length - 1) {
|
|
19003
|
+
paragraphs.push(new Paragraph(textParts[j], true, richTextConfig, ascentDescentMode));
|
|
19004
|
+
}
|
|
19005
|
+
else {
|
|
19006
|
+
const nextRichTextConfig = this.combinedStyleToCharacter(textConfig[i + 1]);
|
|
19007
|
+
paragraphs.push(new Paragraph(textParts[j], true, nextRichTextConfig, ascentDescentMode));
|
|
19008
|
+
}
|
|
18963
19009
|
}
|
|
18964
19010
|
}
|
|
18965
19011
|
else if (richTextConfig.text) {
|
|
@@ -18981,7 +19027,7 @@ class RichText extends Graphic {
|
|
|
18981
19027
|
const frameHeight = richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0;
|
|
18982
19028
|
const frame = new Frame(0, 0, frameWidth || 0, frameHeight || 0, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection || 'horizontal', !richTextWidthEnable && maxWidthFinite, !richTextHeightEnable && maxHeightFinite, singleLine || false, (_a = this._frameCache) === null || _a === void 0 ? void 0 : _a.icons);
|
|
18983
19029
|
const wrapper = new Wrapper(frame);
|
|
18984
|
-
wrapper.newLine =
|
|
19030
|
+
wrapper.newLine = enableMultiBreakLine;
|
|
18985
19031
|
if (disableAutoWrapLine) {
|
|
18986
19032
|
let lineCount = 0;
|
|
18987
19033
|
let skip = false;
|
|
@@ -19029,7 +19075,7 @@ class RichText extends Graphic {
|
|
|
19029
19075
|
l.calcOffset(offsetSize, false);
|
|
19030
19076
|
});
|
|
19031
19077
|
}
|
|
19032
|
-
if (
|
|
19078
|
+
if (enableMultiBreakLine) {
|
|
19033
19079
|
frame.lines.forEach(item => {
|
|
19034
19080
|
const lastParagraphs = item.paragraphs;
|
|
19035
19081
|
item.paragraphs = item.paragraphs.filter(p => p.text !== '');
|
|
@@ -26858,7 +26904,7 @@ function flatten_simplify(points, tolerance, highestQuality) {
|
|
|
26858
26904
|
}
|
|
26859
26905
|
|
|
26860
26906
|
function getDefaultCharacterConfig(attribute) {
|
|
26861
|
-
const { fill = 'black', stroke = false, fontWeight = 'normal', fontFamily = 'Arial' } = attribute;
|
|
26907
|
+
const { fill = 'black', stroke = false, fontWeight = 'normal', lineHeight, fontFamily = 'Arial' } = attribute;
|
|
26862
26908
|
let { fontSize = 12 } = attribute;
|
|
26863
26909
|
if (!isFinite(fontSize)) {
|
|
26864
26910
|
fontSize = 12;
|
|
@@ -26868,7 +26914,8 @@ function getDefaultCharacterConfig(attribute) {
|
|
|
26868
26914
|
stroke,
|
|
26869
26915
|
fontSize,
|
|
26870
26916
|
fontWeight,
|
|
26871
|
-
fontFamily
|
|
26917
|
+
fontFamily,
|
|
26918
|
+
lineHeight
|
|
26872
26919
|
};
|
|
26873
26920
|
}
|
|
26874
26921
|
function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
|
|
@@ -27280,28 +27327,31 @@ class RichTextEditPlugin {
|
|
|
27280
27327
|
throw new Error('不会走到这里 handleFocusOut');
|
|
27281
27328
|
};
|
|
27282
27329
|
this.handleMove = (e) => {
|
|
27283
|
-
if (!this.
|
|
27330
|
+
if (this.currRt && !this.currRt.attribute.editable) {
|
|
27331
|
+
this.deFocus(true);
|
|
27332
|
+
}
|
|
27333
|
+
if (!this.isEditableRichtext(e)) {
|
|
27334
|
+
this.handleLeave();
|
|
27284
27335
|
return;
|
|
27285
27336
|
}
|
|
27286
|
-
this.
|
|
27287
|
-
this.handleEnter(e);
|
|
27337
|
+
this.handleEnter();
|
|
27288
27338
|
e.target.once('pointerleave', this.handleLeave, { capture: true });
|
|
27289
27339
|
this.tryShowSelection(e, false);
|
|
27290
27340
|
};
|
|
27291
|
-
this.handleEnter = (
|
|
27341
|
+
this.handleEnter = () => {
|
|
27292
27342
|
this.editing = true;
|
|
27293
27343
|
this.pluginService.stage.setCursor('text');
|
|
27294
27344
|
};
|
|
27295
|
-
this.handleLeave = (
|
|
27345
|
+
this.handleLeave = () => {
|
|
27296
27346
|
this.editing = false;
|
|
27297
27347
|
this.pluginService.stage.setCursor('default');
|
|
27298
27348
|
};
|
|
27299
27349
|
this.handlePointerDown = (e) => {
|
|
27300
|
-
if (this.editing) {
|
|
27301
|
-
this.
|
|
27350
|
+
if (!this.editing || !this.isEditableRichtext(e)) {
|
|
27351
|
+
this.deFocus(true);
|
|
27302
27352
|
}
|
|
27303
27353
|
else {
|
|
27304
|
-
this.
|
|
27354
|
+
this.onFocus(e);
|
|
27305
27355
|
}
|
|
27306
27356
|
this.triggerRender();
|
|
27307
27357
|
this.pointerDown = true;
|
|
@@ -27503,6 +27553,7 @@ class RichTextEditPlugin {
|
|
|
27503
27553
|
else if (this.curCursorIdx > totalCursorCount + 0.1) {
|
|
27504
27554
|
this.curCursorIdx = totalCursorCount + 0.1;
|
|
27505
27555
|
}
|
|
27556
|
+
this.selectionStartCursorIdx = this.curCursorIdx;
|
|
27506
27557
|
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
|
|
27507
27558
|
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt);
|
|
27508
27559
|
this.hideSelection();
|
|
@@ -27603,7 +27654,7 @@ class RichTextEditPlugin {
|
|
|
27603
27654
|
zIndex: -1
|
|
27604
27655
|
});
|
|
27605
27656
|
const shadow = this.getShadow(this.currRt);
|
|
27606
|
-
|
|
27657
|
+
this.addEditLineOrBgOrBounds(this.shadowBounds, shadow);
|
|
27607
27658
|
this.offsetLineBgAndShadowBounds();
|
|
27608
27659
|
this.offsetShadowRoot();
|
|
27609
27660
|
}
|
|
@@ -27636,10 +27687,27 @@ class RichTextEditPlugin {
|
|
|
27636
27687
|
stopPropagation(e) {
|
|
27637
27688
|
e.stopPropagation();
|
|
27638
27689
|
}
|
|
27690
|
+
addEditLineOrBgOrBounds(graphic, shadowRoot) {
|
|
27691
|
+
let group = shadowRoot.getElementById('emptyBoundsContainer');
|
|
27692
|
+
if (!group) {
|
|
27693
|
+
group = createGroup({ x: 0, y: 0, width: 0, height: 0, boundsMode: 'empty' });
|
|
27694
|
+
group.id = 'emptyBoundsContainer';
|
|
27695
|
+
shadowRoot.add(group);
|
|
27696
|
+
}
|
|
27697
|
+
group.add(graphic);
|
|
27698
|
+
}
|
|
27699
|
+
removeEditLineOrBgOrBounds(graphic, shadowRoot) {
|
|
27700
|
+
const group = shadowRoot.getElementById('emptyBoundsContainer');
|
|
27701
|
+
if (!group) {
|
|
27702
|
+
return;
|
|
27703
|
+
}
|
|
27704
|
+
group.removeChild(graphic);
|
|
27705
|
+
}
|
|
27639
27706
|
onFocus(e, data) {
|
|
27640
27707
|
this.updateCbs && this.updateCbs.forEach(cb => cb('beforeOnfocus', this));
|
|
27641
27708
|
this.deFocus(false);
|
|
27642
27709
|
this.focusing = true;
|
|
27710
|
+
this.editing = true;
|
|
27643
27711
|
const target = e.target;
|
|
27644
27712
|
if (!(target && target.type === 'richtext')) {
|
|
27645
27713
|
return;
|
|
@@ -27663,8 +27731,8 @@ class RichTextEditPlugin {
|
|
|
27663
27731
|
this.ticker.start(true);
|
|
27664
27732
|
const g = createGroup({ x: 0, y: 0, width: 0, height: 0 });
|
|
27665
27733
|
this.editBg = g;
|
|
27666
|
-
|
|
27667
|
-
|
|
27734
|
+
this.addEditLineOrBgOrBounds(this.editLine, shadowRoot);
|
|
27735
|
+
this.addEditLineOrBgOrBounds(this.editBg, shadowRoot);
|
|
27668
27736
|
}
|
|
27669
27737
|
data = data || this.computedCursorPosByEvent(e, cache);
|
|
27670
27738
|
if (data) {
|
|
@@ -27729,32 +27797,33 @@ class RichTextEditPlugin {
|
|
|
27729
27797
|
}
|
|
27730
27798
|
}
|
|
27731
27799
|
deFocus(trulyDeFocus = false) {
|
|
27800
|
+
this.editing = false;
|
|
27732
27801
|
this.updateCbs && this.updateCbs.forEach(cb => cb('beforeDefocus', this, { trulyDeFocus }));
|
|
27733
|
-
const
|
|
27734
|
-
if (!
|
|
27802
|
+
const currRt = this.currRt;
|
|
27803
|
+
if (!currRt) {
|
|
27735
27804
|
return;
|
|
27736
27805
|
}
|
|
27737
|
-
const { editOptions = {} } =
|
|
27806
|
+
const { editOptions = {} } = currRt.attribute;
|
|
27738
27807
|
if (editOptions.stopPropagation) {
|
|
27739
|
-
|
|
27808
|
+
currRt.removeEventListener('*', this.stopPropagation);
|
|
27740
27809
|
}
|
|
27741
27810
|
if (trulyDeFocus) {
|
|
27742
27811
|
this.trySyncPlaceholderToTextConfig();
|
|
27743
|
-
|
|
27812
|
+
currRt.detachShadow();
|
|
27744
27813
|
}
|
|
27745
|
-
const currRt = this.currRt;
|
|
27746
27814
|
this.currRt = null;
|
|
27815
|
+
const shadowRoot = this.getShadow(currRt);
|
|
27747
27816
|
if (this.editLine) {
|
|
27748
|
-
this.
|
|
27817
|
+
this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot);
|
|
27749
27818
|
this.editLine.release();
|
|
27750
27819
|
this.editLine = null;
|
|
27751
|
-
this.
|
|
27820
|
+
this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot);
|
|
27752
27821
|
this.editBg.release();
|
|
27753
27822
|
this.editBg = null;
|
|
27754
27823
|
}
|
|
27755
27824
|
if (trulyDeFocus) {
|
|
27756
27825
|
if (this.shadowBounds) {
|
|
27757
|
-
this.
|
|
27826
|
+
this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot);
|
|
27758
27827
|
this.shadowBounds.release();
|
|
27759
27828
|
this.shadowBounds = null;
|
|
27760
27829
|
}
|
|
@@ -27774,8 +27843,10 @@ class RichTextEditPlugin {
|
|
|
27774
27843
|
cleared = true;
|
|
27775
27844
|
}
|
|
27776
27845
|
cleared && currRt.setAttributes({ textConfig });
|
|
27846
|
+
currRt.removeEventListener('pointerleave', this.handleLeave);
|
|
27777
27847
|
}
|
|
27778
27848
|
addAnimateToLine(line) {
|
|
27849
|
+
line.setAttributes({ opacity: 1 });
|
|
27779
27850
|
line.animates &&
|
|
27780
27851
|
line.animates.forEach(animate => {
|
|
27781
27852
|
animate.stop();
|
|
@@ -27906,7 +27977,7 @@ class RichTextEditPlugin {
|
|
|
27906
27977
|
}
|
|
27907
27978
|
getShadow(rt) {
|
|
27908
27979
|
const sr = rt.shadowRoot || rt.attachShadow();
|
|
27909
|
-
sr.setAttributes({
|
|
27980
|
+
sr.setAttributes({ width: 1, height: 1 });
|
|
27910
27981
|
return sr;
|
|
27911
27982
|
}
|
|
27912
27983
|
getLineByPoint(cache, p1) {
|
|
@@ -27967,7 +28038,10 @@ class RichTextEditPlugin {
|
|
|
27967
28038
|
return -1;
|
|
27968
28039
|
}
|
|
27969
28040
|
isRichtext(e) {
|
|
27970
|
-
return !!(e.target && e.target.type === 'richtext'
|
|
28041
|
+
return !!(e.target && e.target.type === 'richtext');
|
|
28042
|
+
}
|
|
28043
|
+
isEditableRichtext(e) {
|
|
28044
|
+
return this.isRichtext(e) && !!e.target.attribute.editable;
|
|
27971
28045
|
}
|
|
27972
28046
|
triggerRender() {
|
|
27973
28047
|
this.pluginService.stage.renderNextFrame();
|
|
@@ -28130,7 +28204,7 @@ class RichTextEditPlugin {
|
|
|
28130
28204
|
}
|
|
28131
28205
|
}
|
|
28132
28206
|
_forceFocusByEvent(e) {
|
|
28133
|
-
this.handleEnter(
|
|
28207
|
+
this.handleEnter();
|
|
28134
28208
|
this.handlePointerDown(e);
|
|
28135
28209
|
this.handlePointerUp(e);
|
|
28136
28210
|
}
|
|
@@ -204,15 +204,17 @@ export class CustomPath2D extends CurvePath {
|
|
|
204
204
|
break;
|
|
205
205
|
|
|
206
206
|
case "s":
|
|
207
|
-
tempX = x + current[3], tempY = y + current[4],
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
tempX = x + current[3], tempY = y + current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x,
|
|
208
|
+
controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = x + current[1],
|
|
209
|
+
tempControlY = y + current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t),
|
|
210
|
+
controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
|
|
210
211
|
break;
|
|
211
212
|
|
|
212
213
|
case "S":
|
|
213
|
-
tempX = current[3], tempY = current[4],
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
tempX = current[3], tempY = current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x,
|
|
215
|
+
controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = current[1],
|
|
216
|
+
tempControlY = current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t),
|
|
217
|
+
controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
|
|
216
218
|
break;
|
|
217
219
|
|
|
218
220
|
case "q":
|