@visactor/vrender-core 0.22.0-vstory.9 → 0.22.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/cjs/animate/animate.js +1 -1
- package/cjs/animate/animate.js.map +1 -1
- package/cjs/animate/custom-animate.js +2 -1
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/common/inversify/annotation/optional.d.ts +2 -0
- package/cjs/common/inversify/annotation/optional.js +14 -0
- package/cjs/common/inversify/annotation/optional.js.map +1 -0
- package/cjs/common/inversify/container.js +9 -6
- package/cjs/common/inversify/container.js.map +1 -1
- package/cjs/common/render-area.d.ts +0 -4
- package/cjs/common/render-area.js +16 -76
- package/cjs/common/render-area.js.map +1 -1
- package/cjs/common/render-curve.d.ts +1 -1
- package/cjs/common/render-curve.js.map +1 -1
- package/cjs/common/segment/step.js +1 -1
- package/cjs/common/segment/step.js.map +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +10 -0
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/core/global.d.ts +3 -0
- package/cjs/core/global.js +7 -1
- package/cjs/core/global.js.map +1 -1
- package/cjs/graphic/bounds.d.ts +2 -2
- package/cjs/graphic/bounds.js.map +1 -1
- package/cjs/graphic/config.js +2 -0
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/line.js +2 -2
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/graphic/richtext/line.js +3 -13
- package/cjs/graphic/richtext/line.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.d.ts +3 -9
- package/cjs/graphic/richtext/paragraph.js +33 -20
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/richtext/utils.d.ts +1 -1
- package/cjs/graphic/richtext/utils.js +6 -7
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/graphic/richtext.d.ts +0 -1
- package/cjs/graphic/richtext.js +25 -14
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/interface/color.js.map +1 -1
- package/cjs/interface/global.d.ts +1 -0
- package/cjs/interface/global.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +2 -1
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic.d.ts +3 -2
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.js +10 -5
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +10 -7
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +186 -153
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/cjs/render/contributions/render/area-render.d.ts +1 -1
- package/cjs/render/contributions/render/area-render.js +16 -36
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +1 -0
- package/cjs/render/contributions/render/contributions/base-contribution-render.js +7 -3
- package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/group-contribution-render.js +2 -1
- package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/text-contribution-render.js +3 -2
- package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.js +1 -0
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/line-render.js +9 -31
- package/cjs/render/contributions/render/line-render.js.map +1 -1
- package/cjs/resource-loader/loader.d.ts +2 -2
- package/cjs/resource-loader/loader.js +1 -1
- package/cjs/resource-loader/loader.js.map +1 -1
- package/dist/index.es.js +322 -476
- package/es/animate/animate.js +4 -3
- package/es/animate/animate.js.map +1 -1
- package/es/animate/custom-animate.js +2 -1
- package/es/animate/custom-animate.js.map +1 -1
- package/es/common/inversify/annotation/optional.d.ts +2 -0
- package/es/common/inversify/annotation/optional.js +12 -0
- package/es/common/inversify/annotation/optional.js.map +1 -0
- package/es/common/inversify/container.js +9 -6
- package/es/common/inversify/container.js.map +1 -1
- package/es/common/render-area.d.ts +0 -4
- package/es/common/render-area.js +16 -76
- package/es/common/render-area.js.map +1 -1
- package/es/common/render-curve.d.ts +1 -1
- package/es/common/render-curve.js.map +1 -1
- package/es/common/segment/step.js +1 -1
- package/es/common/segment/step.js.map +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.js +10 -0
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/core/global.d.ts +3 -0
- package/es/core/global.js +8 -1
- package/es/core/global.js.map +1 -1
- package/es/graphic/bounds.d.ts +2 -2
- package/es/graphic/bounds.js.map +1 -1
- package/es/graphic/config.js +2 -0
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/line.js +2 -2
- package/es/graphic/line.js.map +1 -1
- package/es/graphic/richtext/line.js +3 -13
- package/es/graphic/richtext/line.js.map +1 -1
- package/es/graphic/richtext/paragraph.d.ts +3 -9
- package/es/graphic/richtext/paragraph.js +33 -20
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/richtext/utils.d.ts +1 -1
- package/es/graphic/richtext/utils.js +6 -7
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/graphic/richtext.d.ts +0 -1
- package/es/graphic/richtext.js +22 -13
- package/es/graphic/richtext.js.map +1 -1
- package/es/interface/color.js.map +1 -1
- package/es/interface/global.d.ts +1 -0
- package/es/interface/global.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +2 -1
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic.d.ts +3 -2
- package/es/interface/graphic.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.js +10 -5
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +10 -7
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +186 -153
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/es/render/contributions/render/area-render.d.ts +1 -1
- package/es/render/contributions/render/area-render.js +16 -36
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-contribution-render.d.ts +1 -0
- package/es/render/contributions/render/contributions/base-contribution-render.js +7 -3
- package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/group-contribution-render.js +2 -1
- package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/text-contribution-render.js +3 -2
- package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.js +3 -2
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/line-render.js +9 -31
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/resource-loader/loader.d.ts +2 -2
- package/es/resource-loader/loader.js +1 -1
- package/es/resource-loader/loader.js.map +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -607,15 +607,17 @@ class Container {
|
|
|
607
607
|
serviceIdentifier: injectIdentifier,
|
|
608
608
|
constructorArgsMetadata
|
|
609
609
|
};
|
|
610
|
-
const bindings = this._bindingDictionary.get(injectIdentifier).filter(b => {
|
|
610
|
+
const bindings = (this._bindingDictionary.get(injectIdentifier) || []).filter(b => {
|
|
611
611
|
return b.constraint(target);
|
|
612
612
|
});
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
613
|
+
if (bindings.length) {
|
|
614
|
+
const request = {
|
|
615
|
+
injectIdentifier,
|
|
616
|
+
metadata: constructorArgsMetadata,
|
|
617
|
+
bindings: bindings
|
|
618
|
+
};
|
|
619
|
+
arr.push(request);
|
|
620
|
+
}
|
|
619
621
|
}
|
|
620
622
|
return arr;
|
|
621
623
|
}
|
|
@@ -855,6 +857,12 @@ let DefaultGlobal = class DefaultGlobal {
|
|
|
855
857
|
get env() {
|
|
856
858
|
return this._env;
|
|
857
859
|
}
|
|
860
|
+
get isImageAnonymous() {
|
|
861
|
+
return this._isImageAnonymous;
|
|
862
|
+
}
|
|
863
|
+
set isImageAnonymous(isImageAnonymous) {
|
|
864
|
+
this._isImageAnonymous = isImageAnonymous;
|
|
865
|
+
}
|
|
858
866
|
get devicePixelRatio() {
|
|
859
867
|
if (!this._env) {
|
|
860
868
|
this.setEnv(defaultEnv);
|
|
@@ -923,6 +931,7 @@ let DefaultGlobal = class DefaultGlobal {
|
|
|
923
931
|
}
|
|
924
932
|
constructor(contributions) {
|
|
925
933
|
this.contributions = contributions;
|
|
934
|
+
this._isImageAnonymous = true;
|
|
926
935
|
this.id = Generator.GenAutoIncrementId();
|
|
927
936
|
this.hooks = {
|
|
928
937
|
onSetEnv: new SyncHook(['lastEnv', 'env', 'global'])
|
|
@@ -2355,7 +2364,12 @@ let Step$1 = class Step {
|
|
|
2355
2364
|
}
|
|
2356
2365
|
else {
|
|
2357
2366
|
const x1 = this._x * (1 - this._t) + x * this._t;
|
|
2358
|
-
|
|
2367
|
+
if (this._t === 0.5) {
|
|
2368
|
+
this.context.lineTo(x1, this._y, this._lastDefined !== false, this.lastPoint);
|
|
2369
|
+
}
|
|
2370
|
+
else {
|
|
2371
|
+
this.context.lineTo(x1, this._y, this._lastDefined !== false && p.defined !== false, this.lastPoint);
|
|
2372
|
+
}
|
|
2359
2373
|
this.context.lineTo(x1, y, this._lastDefined !== false && p.defined !== false, p);
|
|
2360
2374
|
}
|
|
2361
2375
|
break;
|
|
@@ -3274,7 +3288,7 @@ const DefaultTextStyle = {
|
|
|
3274
3288
|
const DefaultPickStyle = {
|
|
3275
3289
|
pickStrokeBuffer: 0
|
|
3276
3290
|
};
|
|
3277
|
-
const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({ forceBoundsWidth: undefined, forceBoundsHeight: undefined, opacity: 1, background: null, autoAnimateTexture: false, textureRatio: 0, textureOptions: null, backgroundOpacity: 1, backgroundCornerRadius: 0, texture: null, textureColor: 'black', textureSize: 10, texturePadding: 2, backgroundMode: 'no-repeat', backgroundFit: true, backgroundClip: true, backgroundScale: 1, backgroundOffsetX: 0, backgroundOffsetY: 0, blur: 0, filter: '', cursor: null, html: null, react: null }, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout), DefaultPickStyle);
|
|
3291
|
+
const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({ forceBoundsWidth: undefined, forceBoundsHeight: undefined, opacity: 1, background: null, autoAnimateTexture: false, textureRatio: 0, textureOptions: null, backgroundOpacity: 1, backgroundCornerRadius: 0, texture: null, textureColor: 'black', textureSize: 10, texturePadding: 2, backgroundMode: 'no-repeat', backgroundFit: true, backgroundKeepAspectRatio: false, backgroundClip: true, backgroundScale: 1, backgroundOffsetX: 0, backgroundOffsetY: 0, blur: 0, filter: '', cursor: null, html: null, react: null }, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout), DefaultPickStyle);
|
|
3278
3292
|
const DefaultConnectAttribute = {
|
|
3279
3293
|
connectedType: 'none',
|
|
3280
3294
|
connectedStyle: {},
|
|
@@ -3307,7 +3321,7 @@ const DefaultRectAttribute = Object.assign(Object.assign({}, DefaultAttribute),
|
|
|
3307
3321
|
const DefaultRect3dAttribute = Object.assign(Object.assign({}, DefaultAttribute), { width: 0, height: 0, x1: 0, y1: 0, cornerRadius: 0, length: 0, cornerType: 'round' });
|
|
3308
3322
|
const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), { symbolType: 'circle', size: 10, keepDirIn3d: true, clipRange: 1 });
|
|
3309
3323
|
const DefaultTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { strokeBoundsBuffer: 0, keepDirIn3d: true });
|
|
3310
|
-
const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { editable: false, editOptions: null, 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 });
|
|
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 });
|
|
3311
3325
|
const DefaultImageAttribute = Object.assign(Object.assign({ repeatX: 'no-repeat', repeatY: 'no-repeat', image: '', width: 0, height: 0 }, DefaultAttribute), { fill: true, cornerRadius: 0, cornerType: 'round' });
|
|
3312
3326
|
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 });
|
|
3313
3327
|
|
|
@@ -3922,7 +3936,7 @@ function testLetter2(string, index) {
|
|
|
3922
3936
|
}
|
|
3923
3937
|
return i + 1;
|
|
3924
3938
|
}
|
|
3925
|
-
function measureTextCanvas(text, character) {
|
|
3939
|
+
function measureTextCanvas(text, character, mode = 'actual') {
|
|
3926
3940
|
const textMeasure = application.graphicUtil.textMeasure;
|
|
3927
3941
|
const measurement = textMeasure.measureText(text, character);
|
|
3928
3942
|
const result = {
|
|
@@ -3931,16 +3945,18 @@ function measureTextCanvas(text, character) {
|
|
|
3931
3945
|
descent: 0,
|
|
3932
3946
|
width: 0
|
|
3933
3947
|
};
|
|
3934
|
-
|
|
3935
|
-
|
|
3948
|
+
const ascent = mode === 'actual' ? measurement.actualBoundingBoxAscent : measurement.fontBoundingBoxAscent;
|
|
3949
|
+
const descent = mode === 'actual' ? measurement.actualBoundingBoxDescent : measurement.fontBoundingBoxDescent;
|
|
3950
|
+
if (typeof ascent !== 'number' || typeof descent !== 'number') {
|
|
3951
|
+
result.width = Math.floor(measurement.width);
|
|
3936
3952
|
result.height = character.fontSize || 0;
|
|
3937
3953
|
result.ascent = result.height;
|
|
3938
3954
|
result.descent = 0;
|
|
3939
3955
|
}
|
|
3940
3956
|
else {
|
|
3941
|
-
result.width = measurement.width;
|
|
3942
|
-
result.height = Math.floor(
|
|
3943
|
-
result.ascent = Math.floor(
|
|
3957
|
+
result.width = Math.floor(measurement.width);
|
|
3958
|
+
result.height = Math.floor(ascent + descent);
|
|
3959
|
+
result.ascent = Math.floor(ascent);
|
|
3944
3960
|
result.descent = result.height - result.ascent;
|
|
3945
3961
|
}
|
|
3946
3962
|
return result;
|
|
@@ -3967,6 +3983,9 @@ let ATextMeasure = class ATextMeasure {
|
|
|
3967
3983
|
metrics.actualBoundingBoxDescent == null ||
|
|
3968
3984
|
metrics.fontBoundingBoxAscent == null ||
|
|
3969
3985
|
metrics.fontBoundingBoxDescent == null) {
|
|
3986
|
+
metrics = {
|
|
3987
|
+
width: metrics.width
|
|
3988
|
+
};
|
|
3970
3989
|
const { ascent, descent } = this.measureTextBoundADscentEstimate(options);
|
|
3971
3990
|
metrics.actualBoundingBoxAscent = ascent;
|
|
3972
3991
|
metrics.actualBoundingBoxDescent = descent;
|
|
@@ -3974,6 +3993,13 @@ let ATextMeasure = class ATextMeasure {
|
|
|
3974
3993
|
metrics.fontBoundingBoxDescent = descent;
|
|
3975
3994
|
}
|
|
3976
3995
|
if (metrics.actualBoundingBoxLeft == null || metrics.actualBoundingBoxRight == null) {
|
|
3996
|
+
metrics = {
|
|
3997
|
+
width: metrics.width,
|
|
3998
|
+
actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,
|
|
3999
|
+
actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,
|
|
4000
|
+
fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
|
|
4001
|
+
fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
|
|
4002
|
+
};
|
|
3977
4003
|
const { left, right } = this.measureTextBoundLeftRightEstimate(options);
|
|
3978
4004
|
metrics.actualBoundingBoxLeft = left;
|
|
3979
4005
|
metrics.actualBoundingBoxRight = right;
|
|
@@ -8287,7 +8313,7 @@ class CbAnimate extends ACustomAnimate {
|
|
|
8287
8313
|
class Animate {
|
|
8288
8314
|
constructor(id = Generator.GenAutoIncrementId(), timeline = defaultTimeline, slience) {
|
|
8289
8315
|
this.id = id;
|
|
8290
|
-
this.timeline = timeline;
|
|
8316
|
+
this.timeline = timeline || defaultTimeline;
|
|
8291
8317
|
this.status = AnimateStatus.INITIAL;
|
|
8292
8318
|
this.tailAnimate = new SubAnimate(this);
|
|
8293
8319
|
this.subAnimates = [this.tailAnimate];
|
|
@@ -9173,11 +9199,12 @@ class IncreaseCount extends ACustomAnimate {
|
|
|
9173
9199
|
return;
|
|
9174
9200
|
}
|
|
9175
9201
|
onUpdate(end, ratio, out) {
|
|
9202
|
+
var _a;
|
|
9176
9203
|
if (this.valid === false) {
|
|
9177
9204
|
return;
|
|
9178
9205
|
}
|
|
9179
9206
|
if (end) {
|
|
9180
|
-
out.text = this.
|
|
9207
|
+
out.text = (_a = this.to) === null || _a === void 0 ? void 0 : _a.text;
|
|
9181
9208
|
}
|
|
9182
9209
|
else {
|
|
9183
9210
|
out.text = (this.fromNumber + (this.toNumber - this.fromNumber) * ratio).toFixed(this.decimalLength);
|
|
@@ -11729,10 +11756,10 @@ class ResourceLoader {
|
|
|
11729
11756
|
static GetFile(url, type) {
|
|
11730
11757
|
let data = ResourceLoader.cache.get(url);
|
|
11731
11758
|
if (data) {
|
|
11732
|
-
if (data.loadState === '
|
|
11759
|
+
if (data.loadState === 'fail') {
|
|
11733
11760
|
return Promise.reject();
|
|
11734
11761
|
}
|
|
11735
|
-
else if (data.loadState === 'loading') {
|
|
11762
|
+
else if (data.loadState === 'init' || data.loadState === 'loading') {
|
|
11736
11763
|
return data.dataPromise.then(data => data.data);
|
|
11737
11764
|
}
|
|
11738
11765
|
return Promise.resolve(data.data);
|
|
@@ -17198,7 +17225,7 @@ let Line$1 = class Line extends Graphic {
|
|
|
17198
17225
|
const { points = lineTheme.points, connectedType } = attribute;
|
|
17199
17226
|
const b = aabbBounds;
|
|
17200
17227
|
points.forEach(p => {
|
|
17201
|
-
if (p.defined !== false || connectedType === '
|
|
17228
|
+
if (p.defined !== false || connectedType === 'connect') {
|
|
17202
17229
|
b.add(p.x, p.y);
|
|
17203
17230
|
}
|
|
17204
17231
|
});
|
|
@@ -17209,7 +17236,7 @@ let Line$1 = class Line extends Graphic {
|
|
|
17209
17236
|
const b = aabbBounds;
|
|
17210
17237
|
segments.forEach(s => {
|
|
17211
17238
|
s.points.forEach(p => {
|
|
17212
|
-
if (p.defined !== false || connectedType === '
|
|
17239
|
+
if (p.defined !== false || connectedType === 'connect') {
|
|
17213
17240
|
b.add(p.x, p.y);
|
|
17214
17241
|
}
|
|
17215
17242
|
});
|
|
@@ -17844,17 +17871,22 @@ function getFixedLRTB(left, right, top, bottom) {
|
|
|
17844
17871
|
const topInt = Math.round(top);
|
|
17845
17872
|
const rightInt = Math.round(right);
|
|
17846
17873
|
const bottomInt = Math.round(bottom);
|
|
17874
|
+
const _left = left > leftInt ? leftInt : leftInt - 0.5;
|
|
17875
|
+
const _top = top > topInt ? topInt : topInt - 0.5;
|
|
17876
|
+
const _right = rightInt > right ? rightInt : rightInt + 0.5;
|
|
17877
|
+
const _bottom = bottomInt > bottom ? bottomInt : bottomInt + 0.5;
|
|
17847
17878
|
return {
|
|
17848
|
-
left:
|
|
17849
|
-
top:
|
|
17850
|
-
right:
|
|
17851
|
-
bottom:
|
|
17879
|
+
left: _left,
|
|
17880
|
+
top: _top,
|
|
17881
|
+
right: _right,
|
|
17882
|
+
bottom: _bottom
|
|
17852
17883
|
};
|
|
17853
17884
|
}
|
|
17854
17885
|
class Paragraph {
|
|
17855
|
-
constructor(text, newLine, character) {
|
|
17886
|
+
constructor(text, newLine, character, ascentDescentMode) {
|
|
17856
17887
|
this.fontSize = character.fontSize || 16;
|
|
17857
17888
|
this.textBaseline = character.textBaseline || 'alphabetic';
|
|
17889
|
+
this.ascentDescentMode = ascentDescentMode;
|
|
17858
17890
|
const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
|
|
17859
17891
|
if (typeof lineHeight === 'number') {
|
|
17860
17892
|
this.lineHeight = lineHeight > this.fontSize ? lineHeight : this.fontSize;
|
|
@@ -17863,7 +17895,7 @@ class Paragraph {
|
|
|
17863
17895
|
this.lineHeight = Math.floor(1.2 * this.fontSize);
|
|
17864
17896
|
}
|
|
17865
17897
|
this.height = this.lineHeight;
|
|
17866
|
-
const { ascent, height, descent, width } = measureTextCanvas(text, character);
|
|
17898
|
+
const { ascent, height, descent, width } = measureTextCanvas(text, character, this.ascentDescentMode);
|
|
17867
17899
|
let halfDetaHeight = 0;
|
|
17868
17900
|
let deltaAscent = 0;
|
|
17869
17901
|
let deltaDescent = 0;
|
|
@@ -17909,7 +17941,7 @@ class Paragraph {
|
|
|
17909
17941
|
this.ellipsisStr = '...';
|
|
17910
17942
|
}
|
|
17911
17943
|
updateWidth() {
|
|
17912
|
-
const { width } = measureTextCanvas(this.text, this.character);
|
|
17944
|
+
const { width } = measureTextCanvas(this.text, this.character, this.ascentDescentMode);
|
|
17913
17945
|
this.width = width;
|
|
17914
17946
|
if (this.direction === 'vertical') {
|
|
17915
17947
|
this.widthOrigin = this.width;
|
|
@@ -17945,17 +17977,41 @@ class Paragraph {
|
|
|
17945
17977
|
text = text.slice(0, index);
|
|
17946
17978
|
text += this.ellipsisStr;
|
|
17947
17979
|
if (textAlign === 'right' || textAlign === 'end') {
|
|
17948
|
-
const { width } = measureTextCanvas(this.text.slice(index), this.character);
|
|
17980
|
+
const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
|
|
17949
17981
|
if (direction === 'vertical') ;
|
|
17950
17982
|
else {
|
|
17951
17983
|
left -= this.ellipsisWidth - width;
|
|
17952
17984
|
}
|
|
17953
17985
|
}
|
|
17954
17986
|
}
|
|
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
|
+
}
|
|
17955
18009
|
const right = left + (this.widthOrigin || this.width);
|
|
17956
18010
|
const bottom = top + lineHeight;
|
|
17957
18011
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
17958
|
-
|
|
18012
|
+
ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);
|
|
18013
|
+
ctx.fillStyle = fillStyle;
|
|
18014
|
+
ctx.globalAlpha = globalAlpha;
|
|
17959
18015
|
}
|
|
17960
18016
|
draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
|
|
17961
18017
|
let baseline = top + ascent;
|
|
@@ -17982,7 +18038,7 @@ class Paragraph {
|
|
|
17982
18038
|
text = text.slice(0, index);
|
|
17983
18039
|
text += this.ellipsisStr;
|
|
17984
18040
|
if (textAlign === 'right' || textAlign === 'end') {
|
|
17985
|
-
const { width } = measureTextCanvas(this.text.slice(index), this.character);
|
|
18041
|
+
const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
|
|
17986
18042
|
if (direction === 'vertical') ;
|
|
17987
18043
|
else {
|
|
17988
18044
|
left -= this.ellipsisWidth - width;
|
|
@@ -18019,14 +18075,14 @@ class Paragraph {
|
|
|
18019
18075
|
const right = left + (this.widthOrigin || this.width);
|
|
18020
18076
|
const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18021
18077
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18022
|
-
ctx.fillRect(lrtb.left,
|
|
18078
|
+
ctx.fillRect(lrtb.left, 1 + baseline, lrtb.right - lrtb.left, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18023
18079
|
}
|
|
18024
18080
|
if (this.character.lineThrough) {
|
|
18025
18081
|
const top = 1 + baseline - this.ascent / 2;
|
|
18026
18082
|
const right = left + (this.widthOrigin || this.width);
|
|
18027
18083
|
const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18028
18084
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18029
|
-
ctx.fillRect(lrtb.left,
|
|
18085
|
+
ctx.fillRect(lrtb.left, 1 + baseline - this.ascent / 2, lrtb.right - lrtb.left, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18030
18086
|
}
|
|
18031
18087
|
}
|
|
18032
18088
|
else if (this.character.textDecoration === 'underline') {
|
|
@@ -18034,14 +18090,14 @@ class Paragraph {
|
|
|
18034
18090
|
const right = left + (this.widthOrigin || this.width);
|
|
18035
18091
|
const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18036
18092
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18037
|
-
ctx.fillRect(lrtb.left,
|
|
18093
|
+
ctx.fillRect(lrtb.left, 1 + baseline, lrtb.right - lrtb.left, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18038
18094
|
}
|
|
18039
18095
|
else if (this.character.textDecoration === 'line-through') {
|
|
18040
18096
|
const top = 1 + baseline - this.ascent / 2;
|
|
18041
18097
|
const right = left + (this.widthOrigin || this.width);
|
|
18042
18098
|
const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18043
18099
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18044
|
-
ctx.fillRect(lrtb.left,
|
|
18100
|
+
ctx.fillRect(lrtb.left, 1 + baseline - this.ascent / 2, lrtb.right - lrtb.left, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18045
18101
|
}
|
|
18046
18102
|
}
|
|
18047
18103
|
if (direction === 'vertical') {
|
|
@@ -18061,7 +18117,7 @@ class Paragraph {
|
|
|
18061
18117
|
const index = getStrByWithCanvas(text, width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
|
|
18062
18118
|
text = text.slice(0, index);
|
|
18063
18119
|
text += this.ellipsisStr;
|
|
18064
|
-
const { width: measureWidth } = measureTextCanvas(this.text.slice(index), this.character);
|
|
18120
|
+
const { width: measureWidth } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
|
|
18065
18121
|
return width + this.ellipsisWidth - measureWidth;
|
|
18066
18122
|
}
|
|
18067
18123
|
return width;
|
|
@@ -18070,8 +18126,8 @@ class Paragraph {
|
|
|
18070
18126
|
function seperateParagraph(paragraph, index) {
|
|
18071
18127
|
const text1 = paragraph.text.slice(0, index);
|
|
18072
18128
|
const text2 = paragraph.text.slice(index);
|
|
18073
|
-
const p1 = new Paragraph(text1, paragraph.newLine, paragraph.character);
|
|
18074
|
-
const p2 = new Paragraph(text2, true, paragraph.character);
|
|
18129
|
+
const p1 = new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode);
|
|
18130
|
+
const p2 = new Paragraph(text2, true, paragraph.character, paragraph.ascentDescentMode);
|
|
18075
18131
|
return [p1, p2];
|
|
18076
18132
|
}
|
|
18077
18133
|
|
|
@@ -18361,7 +18417,7 @@ class Line {
|
|
|
18361
18417
|
}
|
|
18362
18418
|
const ellipsis = drawEllipsis === true ? '...' : drawEllipsis || '';
|
|
18363
18419
|
paragraph.ellipsisStr = ellipsis;
|
|
18364
|
-
const { width } = measureTextCanvas(ellipsis, paragraph.character);
|
|
18420
|
+
const { width } = measureTextCanvas(ellipsis, paragraph.character, paragraph.ascentDescentMode);
|
|
18365
18421
|
const ellipsisWidth = width || 0;
|
|
18366
18422
|
if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) {
|
|
18367
18423
|
lastLine && (paragraph.ellipsis = 'add');
|
|
@@ -18380,35 +18436,11 @@ class Line {
|
|
|
18380
18436
|
}
|
|
18381
18437
|
}
|
|
18382
18438
|
}
|
|
18383
|
-
let fillStyle = '';
|
|
18384
|
-
let globalAlpha = -1;
|
|
18385
|
-
let currBgList = [];
|
|
18386
|
-
const bgList = [currBgList];
|
|
18387
18439
|
this.paragraphs.forEach((paragraph, index) => {
|
|
18388
18440
|
if (paragraph instanceof RichTextIcon) {
|
|
18389
18441
|
return;
|
|
18390
18442
|
}
|
|
18391
|
-
|
|
18392
|
-
if (!data) {
|
|
18393
|
-
return;
|
|
18394
|
-
}
|
|
18395
|
-
if (!(fillStyle === data.fillStyle && globalAlpha === data.globalAlpha)) {
|
|
18396
|
-
currBgList = [];
|
|
18397
|
-
bgList.push(currBgList);
|
|
18398
|
-
fillStyle = data.fillStyle;
|
|
18399
|
-
globalAlpha = data.globalAlpha;
|
|
18400
|
-
}
|
|
18401
|
-
currBgList.push(data);
|
|
18402
|
-
});
|
|
18403
|
-
bgList.forEach(bg => {
|
|
18404
|
-
if (bg.length === 0) {
|
|
18405
|
-
return;
|
|
18406
|
-
}
|
|
18407
|
-
const data = bg[0];
|
|
18408
|
-
const end = bg[bg.length - 1];
|
|
18409
|
-
ctx.fillStyle = data.fillStyle;
|
|
18410
|
-
ctx.globalAlpha = data.globalAlpha;
|
|
18411
|
-
ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
|
|
18443
|
+
paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
|
|
18412
18444
|
});
|
|
18413
18445
|
this.paragraphs.forEach((paragraph, index) => {
|
|
18414
18446
|
if (paragraph instanceof RichTextIcon) {
|
|
@@ -18437,7 +18469,7 @@ class Line {
|
|
|
18437
18469
|
if (paragraph instanceof RichTextIcon) {
|
|
18438
18470
|
break;
|
|
18439
18471
|
}
|
|
18440
|
-
const { width } = measureTextCanvas(ellipsis, paragraph.character);
|
|
18472
|
+
const { width } = measureTextCanvas(ellipsis, paragraph.character, paragraph.ascentDescentMode);
|
|
18441
18473
|
const ellipsisWidth = width || 0;
|
|
18442
18474
|
if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) {
|
|
18443
18475
|
paragraph.ellipsis = 'add';
|
|
@@ -18598,6 +18630,13 @@ class Wrapper {
|
|
|
18598
18630
|
}
|
|
18599
18631
|
}
|
|
18600
18632
|
|
|
18633
|
+
let supportIntl = false;
|
|
18634
|
+
try {
|
|
18635
|
+
supportIntl = Intl && typeof Intl.Segmenter === 'function';
|
|
18636
|
+
}
|
|
18637
|
+
catch (e) {
|
|
18638
|
+
supportIntl = false;
|
|
18639
|
+
}
|
|
18601
18640
|
const RICHTEXT_UPDATE_TAG_KEY = [
|
|
18602
18641
|
'width',
|
|
18603
18642
|
'height',
|
|
@@ -18757,15 +18796,14 @@ class RichText extends Graphic {
|
|
|
18757
18796
|
return tc.every(item => item.isComposing ||
|
|
18758
18797
|
!(item.text && isString(item.text) && RichText.splitText(item.text).length > 1));
|
|
18759
18798
|
}
|
|
18760
|
-
static splitEmoji(text) {
|
|
18761
|
-
return [...new Intl.Segmenter().segment(text)].map(x => x.segment);
|
|
18762
|
-
}
|
|
18763
18799
|
static splitText(text) {
|
|
18764
|
-
|
|
18765
|
-
const
|
|
18766
|
-
|
|
18767
|
-
|
|
18768
|
-
|
|
18800
|
+
if (supportIntl) {
|
|
18801
|
+
const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
18802
|
+
const segments = [];
|
|
18803
|
+
for (const { segment } of segmenter.segment(text)) {
|
|
18804
|
+
segments.push(segment);
|
|
18805
|
+
}
|
|
18806
|
+
return segments;
|
|
18769
18807
|
}
|
|
18770
18808
|
return Array.from(text);
|
|
18771
18809
|
}
|
|
@@ -18786,8 +18824,8 @@ class RichText extends Graphic {
|
|
|
18786
18824
|
return tc;
|
|
18787
18825
|
}
|
|
18788
18826
|
updateAABBBounds(attribute, richtextTheme, aabbBounds) {
|
|
18789
|
-
var _a, _b;
|
|
18790
|
-
const { width = richtextTheme.width, height = richtextTheme.height, maxWidth = richtextTheme.maxWidth, maxHeight = richtextTheme.maxHeight, textAlign = richtextTheme.textAlign,
|
|
18827
|
+
var _a, _b, _c, _d;
|
|
18828
|
+
const { width = richtextTheme.width, height = richtextTheme.height, maxWidth = richtextTheme.maxWidth, maxHeight = richtextTheme.maxHeight, textAlign = richtextTheme.textAlign, verticalDirection = (_b = (_a = attribute.textBaseline) !== null && _a !== void 0 ? _a : richtextTheme.textBaseline) !== null && _b !== void 0 ? _b : richtextTheme.verticalDirection, editOptions } = attribute;
|
|
18791
18829
|
if (width > 0 && height > 0) {
|
|
18792
18830
|
aabbBounds.set(0, 0, width, height);
|
|
18793
18831
|
}
|
|
@@ -18800,12 +18838,12 @@ class RichText extends Graphic {
|
|
|
18800
18838
|
contentWidth = typeof maxWidth === 'number' && contentWidth > maxWidth ? maxWidth : contentWidth || 0;
|
|
18801
18839
|
aabbBounds.set(0, 0, contentWidth, contentHeight);
|
|
18802
18840
|
}
|
|
18803
|
-
if (editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !((
|
|
18804
|
-
aabbBounds.y2 = aabbBounds.y1 + ((
|
|
18841
|
+
if (editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !((_c = attribute.textConfig) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
18842
|
+
aabbBounds.y2 = aabbBounds.y1 + ((_d = attribute.fontSize) !== null && _d !== void 0 ? _d : 12);
|
|
18805
18843
|
aabbBounds.x2 = aabbBounds.x1 + 2;
|
|
18806
18844
|
}
|
|
18807
18845
|
let deltaY = 0;
|
|
18808
|
-
switch (
|
|
18846
|
+
switch (verticalDirection) {
|
|
18809
18847
|
case 'top':
|
|
18810
18848
|
deltaY = 0;
|
|
18811
18849
|
break;
|
|
@@ -18883,7 +18921,7 @@ class RichText extends Graphic {
|
|
|
18883
18921
|
}
|
|
18884
18922
|
doUpdateFrameCache(tc) {
|
|
18885
18923
|
var _a;
|
|
18886
|
-
const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable } = this.attribute;
|
|
18924
|
+
const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable, ascentDescentMode } = this.attribute;
|
|
18887
18925
|
let { textConfig: _tc = [] } = this.attribute;
|
|
18888
18926
|
if (editable && _tc.length > 0 && !RichText.AllSingleCharacter(_tc)) {
|
|
18889
18927
|
_tc = RichText.TransformTextConfig2SingleCharacter(_tc);
|
|
@@ -18918,11 +18956,11 @@ class RichText extends Graphic {
|
|
|
18918
18956
|
if (richTextConfig.text && richTextConfig.text.includes('\n')) {
|
|
18919
18957
|
const textParts = richTextConfig.text.split('\n');
|
|
18920
18958
|
for (let j = 0; j < textParts.length; j++) {
|
|
18921
|
-
paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig));
|
|
18959
|
+
paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));
|
|
18922
18960
|
}
|
|
18923
18961
|
}
|
|
18924
18962
|
else if (richTextConfig.text) {
|
|
18925
|
-
paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig));
|
|
18963
|
+
paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig, ascentDescentMode));
|
|
18926
18964
|
}
|
|
18927
18965
|
}
|
|
18928
18966
|
}
|
|
@@ -20094,7 +20132,7 @@ class DefaultBaseBackgroundRenderContribution {
|
|
|
20094
20132
|
}
|
|
20095
20133
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
|
|
20096
20134
|
var _a;
|
|
20097
|
-
const { background, backgroundOpacity = (_a = graphic.attribute.fillOpacity) !== null && _a !== void 0 ? _a : graphicAttribute.backgroundOpacity, opacity = graphicAttribute.opacity, backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit, backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY = graphicAttribute.backgroundOffsetY, backgroundClip = graphicAttribute.backgroundClip } = graphic.attribute;
|
|
20135
|
+
const { background, backgroundOpacity = (_a = graphic.attribute.fillOpacity) !== null && _a !== void 0 ? _a : graphicAttribute.backgroundOpacity, opacity = graphicAttribute.opacity, backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit, backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio, backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY = graphicAttribute.backgroundOffsetY, backgroundClip = graphicAttribute.backgroundClip } = graphic.attribute;
|
|
20098
20136
|
if (!background) {
|
|
20099
20137
|
return;
|
|
20100
20138
|
}
|
|
@@ -20117,6 +20155,7 @@ class DefaultBaseBackgroundRenderContribution {
|
|
|
20117
20155
|
this.doDrawImage(context, res.data, b, {
|
|
20118
20156
|
backgroundMode,
|
|
20119
20157
|
backgroundFit,
|
|
20158
|
+
backgroundKeepAspectRatio,
|
|
20120
20159
|
backgroundScale,
|
|
20121
20160
|
backgroundOffsetX,
|
|
20122
20161
|
backgroundOffsetY
|
|
@@ -20136,14 +20175,20 @@ class DefaultBaseBackgroundRenderContribution {
|
|
|
20136
20175
|
}
|
|
20137
20176
|
}
|
|
20138
20177
|
doDrawImage(context, data, b, params) {
|
|
20139
|
-
const { backgroundMode, backgroundFit, backgroundScale = 1, backgroundOffsetX = 0, backgroundOffsetY = 0 } = params;
|
|
20178
|
+
const { backgroundMode, backgroundFit, backgroundKeepAspectRatio, backgroundScale = 1, backgroundOffsetX = 0, backgroundOffsetY = 0 } = params;
|
|
20140
20179
|
const targetW = b.width();
|
|
20141
20180
|
const targetH = b.height();
|
|
20142
20181
|
let w = targetW;
|
|
20143
20182
|
let h = targetH;
|
|
20144
20183
|
if (backgroundMode === 'no-repeat') {
|
|
20145
20184
|
if (backgroundFit) {
|
|
20146
|
-
|
|
20185
|
+
if (!backgroundKeepAspectRatio) {
|
|
20186
|
+
context.drawImage(data, b.x1, b.y1, b.width(), b.height());
|
|
20187
|
+
}
|
|
20188
|
+
else {
|
|
20189
|
+
const maxScale = Math.max(targetW / data.width, targetH / data.height);
|
|
20190
|
+
context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
|
|
20191
|
+
}
|
|
20147
20192
|
}
|
|
20148
20193
|
else {
|
|
20149
20194
|
const resW = data.width * backgroundScale;
|
|
@@ -20512,7 +20557,7 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
|
|
|
20512
20557
|
this.time = BaseRenderContributionTime.beforeFillStroke;
|
|
20513
20558
|
}
|
|
20514
20559
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
20515
|
-
const { background, backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit, backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY = graphicAttribute.backgroundOffsetY } = graphic.attribute;
|
|
20560
|
+
const { background, backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit, backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio, backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY = graphicAttribute.backgroundOffsetY } = graphic.attribute;
|
|
20516
20561
|
if (!background) {
|
|
20517
20562
|
return;
|
|
20518
20563
|
}
|
|
@@ -20527,6 +20572,7 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
|
|
|
20527
20572
|
this.doDrawImage(context, res.data, b, {
|
|
20528
20573
|
backgroundMode,
|
|
20529
20574
|
backgroundFit,
|
|
20575
|
+
backgroundKeepAspectRatio,
|
|
20530
20576
|
backgroundScale,
|
|
20531
20577
|
backgroundOffsetX,
|
|
20532
20578
|
backgroundOffsetY
|
|
@@ -20825,8 +20871,8 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
|
|
|
20825
20871
|
this.useStyle = true;
|
|
20826
20872
|
this.order = 0;
|
|
20827
20873
|
}
|
|
20828
|
-
drawShape(
|
|
20829
|
-
return super.drawShape(
|
|
20874
|
+
drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
|
|
20875
|
+
return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
20830
20876
|
}
|
|
20831
20877
|
}
|
|
20832
20878
|
const defaultImageRenderContribution = new DefaultImageRenderContribution();
|
|
@@ -21424,7 +21470,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21424
21470
|
this._draw(line, lineAttribute, false, drawContext, params);
|
|
21425
21471
|
}
|
|
21426
21472
|
drawSegmentItem(context, cache, fill, stroke, fillOpacity, strokeOpacity, attribute, defaultAttribute, clipRange, clipRangeByDimension, offsetX, offsetY, line, fillCb, strokeCb) {
|
|
21427
|
-
var _a
|
|
21473
|
+
var _a;
|
|
21428
21474
|
if (!cache) {
|
|
21429
21475
|
return;
|
|
21430
21476
|
}
|
|
@@ -21463,60 +21509,6 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21463
21509
|
context.stroke();
|
|
21464
21510
|
}
|
|
21465
21511
|
}
|
|
21466
|
-
let { connectedType, connectedX, connectedY, connectedStyle } = attribute;
|
|
21467
|
-
if (isArray(defaultAttribute)) {
|
|
21468
|
-
connectedType = (_b = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute[0].connectedType) !== null && _b !== void 0 ? _b : defaultAttribute[1].connectedType;
|
|
21469
|
-
connectedX = (_c = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute[0].connectedX) !== null && _c !== void 0 ? _c : defaultAttribute[1].connectedX;
|
|
21470
|
-
connectedY = (_d = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute[0].connectedY) !== null && _d !== void 0 ? _d : defaultAttribute[1].connectedY;
|
|
21471
|
-
connectedStyle = (_e = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute[0].connectedStyle) !== null && _e !== void 0 ? _e : defaultAttribute[1].connectedStyle;
|
|
21472
|
-
}
|
|
21473
|
-
else {
|
|
21474
|
-
connectedType = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute.connectedType;
|
|
21475
|
-
connectedX = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute.connectedX;
|
|
21476
|
-
connectedY = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute.connectedY;
|
|
21477
|
-
connectedStyle = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute.connectedStyle;
|
|
21478
|
-
}
|
|
21479
|
-
if (connectedType !== 'connect' && connectedType !== 'zero') {
|
|
21480
|
-
connectedType = 'none';
|
|
21481
|
-
}
|
|
21482
|
-
if (connectedType !== 'none') {
|
|
21483
|
-
context.beginPath();
|
|
21484
|
-
drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {
|
|
21485
|
-
offsetX,
|
|
21486
|
-
offsetY,
|
|
21487
|
-
offsetZ: z,
|
|
21488
|
-
drawConnect: true,
|
|
21489
|
-
mode: connectedType,
|
|
21490
|
-
zeroX: connectedX,
|
|
21491
|
-
zeroY: connectedY
|
|
21492
|
-
});
|
|
21493
|
-
const da = [];
|
|
21494
|
-
if (isArray(defaultAttribute)) {
|
|
21495
|
-
defaultAttribute.forEach(i => da.push(i));
|
|
21496
|
-
}
|
|
21497
|
-
else {
|
|
21498
|
-
da.push(defaultAttribute);
|
|
21499
|
-
}
|
|
21500
|
-
da.push(attribute);
|
|
21501
|
-
if (fill !== false) {
|
|
21502
|
-
if (fillCb) {
|
|
21503
|
-
fillCb(context, attribute, defaultAttribute);
|
|
21504
|
-
}
|
|
21505
|
-
else if (fillOpacity) {
|
|
21506
|
-
context.setCommonStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);
|
|
21507
|
-
context.fill();
|
|
21508
|
-
}
|
|
21509
|
-
}
|
|
21510
|
-
if (stroke !== false) {
|
|
21511
|
-
if (strokeCb) {
|
|
21512
|
-
strokeCb(context, attribute, defaultAttribute);
|
|
21513
|
-
}
|
|
21514
|
-
else if (strokeOpacity) {
|
|
21515
|
-
context.setStrokeStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);
|
|
21516
|
-
context.stroke();
|
|
21517
|
-
}
|
|
21518
|
-
}
|
|
21519
|
-
}
|
|
21520
21512
|
return !!ret;
|
|
21521
21513
|
}
|
|
21522
21514
|
drawLinearLineHighPerformance(line, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, lineAttribute, drawContext, params, fillCb, strokeCb) {
|
|
@@ -21553,7 +21545,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21553
21545
|
}
|
|
21554
21546
|
drawShape(line, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
21555
21547
|
const lineAttribute = getTheme(line, params === null || params === void 0 ? void 0 : params.theme).line;
|
|
21556
|
-
const { fill = lineAttribute.fill, stroke = lineAttribute.stroke, fillOpacity = lineAttribute.fillOpacity, strokeOpacity = lineAttribute.strokeOpacity, segments, points, closePath, curveTension = lineAttribute.curveTension } = line.attribute;
|
|
21548
|
+
const { fill = lineAttribute.fill, stroke = lineAttribute.stroke, fillOpacity = lineAttribute.fillOpacity, strokeOpacity = lineAttribute.strokeOpacity, segments, points, closePath, curveTension = lineAttribute.curveTension, connectedType = lineAttribute.connectedType } = line.attribute;
|
|
21557
21549
|
const data = this.valid(line, lineAttribute, fillCb, strokeCb);
|
|
21558
21550
|
if (!data) {
|
|
21559
21551
|
return;
|
|
@@ -21566,6 +21558,12 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21566
21558
|
if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
|
|
21567
21559
|
return this.drawLinearLineHighPerformance(line, context, !!fill, !!stroke, fillOpacity, strokeOpacity, x, y, lineAttribute, drawContext, params, fillCb, strokeCb);
|
|
21568
21560
|
}
|
|
21561
|
+
function parsePoint(points, connectedType) {
|
|
21562
|
+
if (connectedType === 'none') {
|
|
21563
|
+
return points;
|
|
21564
|
+
}
|
|
21565
|
+
return points.filter(p => p.defined !== false);
|
|
21566
|
+
}
|
|
21569
21567
|
if (line.shouldUpdateShape()) {
|
|
21570
21568
|
const { points, segments } = line.attribute;
|
|
21571
21569
|
const _points = points;
|
|
@@ -21597,7 +21595,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21597
21595
|
startPoint.y = lastSeg.endY;
|
|
21598
21596
|
startPoint.defined = lastSeg.curves[lastSeg.curves.length - 1].defined;
|
|
21599
21597
|
}
|
|
21600
|
-
const data = calcLineCache(seg.points, curveType, {
|
|
21598
|
+
const data = calcLineCache(parsePoint(seg.points, connectedType), curveType, {
|
|
21601
21599
|
startPoint,
|
|
21602
21600
|
curveTension
|
|
21603
21601
|
});
|
|
@@ -21623,7 +21621,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21623
21621
|
}
|
|
21624
21622
|
}
|
|
21625
21623
|
else if (points && points.length) {
|
|
21626
|
-
line.cache = calcLineCache(_points, curveType, { curveTension });
|
|
21624
|
+
line.cache = calcLineCache(parsePoint(_points, connectedType), curveType, { curveTension });
|
|
21627
21625
|
}
|
|
21628
21626
|
else {
|
|
21629
21627
|
line.cache = null;
|
|
@@ -21675,10 +21673,6 @@ DefaultCanvasLineRender = __decorate([
|
|
|
21675
21673
|
|
|
21676
21674
|
function drawAreaSegments(path, segPath, percent, params) {
|
|
21677
21675
|
var _a;
|
|
21678
|
-
const { drawConnect = false, mode = 'none' } = params || {};
|
|
21679
|
-
if (drawConnect && mode === 'none') {
|
|
21680
|
-
return;
|
|
21681
|
-
}
|
|
21682
21676
|
const { top, bottom } = segPath;
|
|
21683
21677
|
if (top.curves.length !== bottom.curves.length) {
|
|
21684
21678
|
return;
|
|
@@ -21687,90 +21681,28 @@ function drawAreaSegments(path, segPath, percent, params) {
|
|
|
21687
21681
|
const topList = [];
|
|
21688
21682
|
const bottomList = [];
|
|
21689
21683
|
let lastDefined = true;
|
|
21690
|
-
|
|
21691
|
-
|
|
21692
|
-
|
|
21693
|
-
|
|
21694
|
-
|
|
21695
|
-
|
|
21696
|
-
|
|
21697
|
-
let currentTopCurve = curve;
|
|
21698
|
-
let currentBottomCurve = bototmCurve;
|
|
21699
|
-
if (curve.originP1 === curve.originP2) {
|
|
21700
|
-
lastCurve = curve;
|
|
21701
|
-
lastBottomCurve = bototmCurve;
|
|
21702
|
-
return;
|
|
21703
|
-
}
|
|
21704
|
-
if (lastCurve && lastCurve.originP1 === lastCurve.originP2) {
|
|
21705
|
-
currentTopCurve = lastCurve;
|
|
21706
|
-
currentBottomCurve = lastBottomCurve;
|
|
21707
|
-
}
|
|
21708
|
-
if (curve.defined) {
|
|
21709
|
-
if (!defined0) {
|
|
21710
|
-
topList.push(currentTopCurve);
|
|
21711
|
-
bottomList.push(currentBottomCurve);
|
|
21712
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21713
|
-
topList.length = 0;
|
|
21714
|
-
bottomList.length = 0;
|
|
21715
|
-
defined0 = !defined0;
|
|
21716
|
-
}
|
|
21684
|
+
for (let i = 0, n = top.curves.length; i < n; i++) {
|
|
21685
|
+
const topCurve = top.curves[i];
|
|
21686
|
+
if (lastDefined !== topCurve.defined) {
|
|
21687
|
+
if (lastDefined) {
|
|
21688
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
21689
|
+
topList.length = 0;
|
|
21690
|
+
bottomList.length = 0;
|
|
21717
21691
|
}
|
|
21718
21692
|
else {
|
|
21719
|
-
|
|
21720
|
-
|
|
21721
|
-
let validBottomCurve;
|
|
21722
|
-
if (originP1 && originP1.defined !== false) {
|
|
21723
|
-
validTopCurve = currentTopCurve;
|
|
21724
|
-
validBottomCurve = currentBottomCurve;
|
|
21725
|
-
}
|
|
21726
|
-
else if (originP1 && originP2.defined !== false) {
|
|
21727
|
-
validTopCurve = curve;
|
|
21728
|
-
validBottomCurve = bototmCurve;
|
|
21729
|
-
}
|
|
21730
|
-
if (defined0) {
|
|
21731
|
-
defined0 = !defined0;
|
|
21732
|
-
topList.push(validTopCurve || curve);
|
|
21733
|
-
bottomList.push(validBottomCurve || bototmCurve);
|
|
21734
|
-
}
|
|
21735
|
-
else {
|
|
21736
|
-
if (validTopCurve) {
|
|
21737
|
-
defined0 = !defined0;
|
|
21738
|
-
topList.push(validTopCurve || curve);
|
|
21739
|
-
bottomList.push(validBottomCurve || bototmCurve);
|
|
21740
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21741
|
-
topList.length = 0;
|
|
21742
|
-
bottomList.length = 0;
|
|
21743
|
-
}
|
|
21744
|
-
}
|
|
21693
|
+
topList.push(topCurve);
|
|
21694
|
+
bottomList.push(bottom.curves[n - i - 1]);
|
|
21745
21695
|
}
|
|
21746
|
-
|
|
21747
|
-
}
|
|
21748
|
-
|
|
21749
|
-
|
|
21750
|
-
|
|
21751
|
-
|
|
21752
|
-
const topCurve = top.curves[i];
|
|
21753
|
-
if (lastDefined !== topCurve.defined) {
|
|
21754
|
-
if (lastDefined) {
|
|
21755
|
-
drawAreaBlock(path, topList, bottomList, params);
|
|
21756
|
-
topList.length = 0;
|
|
21757
|
-
bottomList.length = 0;
|
|
21758
|
-
}
|
|
21759
|
-
else {
|
|
21760
|
-
topList.push(topCurve);
|
|
21761
|
-
bottomList.push(bottom.curves[n - i - 1]);
|
|
21762
|
-
}
|
|
21763
|
-
lastDefined = !lastDefined;
|
|
21764
|
-
}
|
|
21765
|
-
else {
|
|
21766
|
-
if (lastDefined) {
|
|
21767
|
-
topList.push(topCurve);
|
|
21768
|
-
bottomList.push(bottom.curves[n - i - 1]);
|
|
21769
|
-
}
|
|
21696
|
+
lastDefined = !lastDefined;
|
|
21697
|
+
}
|
|
21698
|
+
else {
|
|
21699
|
+
if (lastDefined) {
|
|
21700
|
+
topList.push(topCurve);
|
|
21701
|
+
bottomList.push(bottom.curves[n - i - 1]);
|
|
21770
21702
|
}
|
|
21771
21703
|
}
|
|
21772
|
-
drawAreaBlock(path, topList, bottomList, params);
|
|
21773
21704
|
}
|
|
21705
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
21774
21706
|
return;
|
|
21775
21707
|
}
|
|
21776
21708
|
if (percent <= 0) {
|
|
@@ -21794,9 +21726,6 @@ function drawAreaSegments(path, segPath, percent, params) {
|
|
|
21794
21726
|
let lastDefined = true;
|
|
21795
21727
|
const topList = [];
|
|
21796
21728
|
const bottomList = [];
|
|
21797
|
-
let defined0 = true;
|
|
21798
|
-
let lastTopCurve;
|
|
21799
|
-
let lastBottomCurve;
|
|
21800
21729
|
for (let i = 0, n = top.curves.length; i < n; i++) {
|
|
21801
21730
|
const topCurve = top.curves[i];
|
|
21802
21731
|
const curCurveLength = topCurve.getLength(direction);
|
|
@@ -21805,127 +21734,50 @@ function drawAreaSegments(path, segPath, percent, params) {
|
|
|
21805
21734
|
break;
|
|
21806
21735
|
}
|
|
21807
21736
|
drawedLengthUntilLast += curCurveLength;
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
21812
|
-
|
|
21813
|
-
|
|
21814
|
-
|
|
21815
|
-
continue;
|
|
21816
|
-
}
|
|
21817
|
-
if (lastTopCurve && lastTopCurve.originP1 === lastTopCurve.originP2) {
|
|
21818
|
-
currentTopCurve = lastTopCurve;
|
|
21819
|
-
currentBottomCurve = lastBottomCurve;
|
|
21820
|
-
}
|
|
21821
|
-
if (topCurve.defined) {
|
|
21822
|
-
if (!defined0) {
|
|
21823
|
-
topList.push(currentTopCurve);
|
|
21824
|
-
bottomList.push(currentBottomCurve);
|
|
21825
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21826
|
-
topList.length = 0;
|
|
21827
|
-
bottomList.length = 0;
|
|
21828
|
-
defined0 = !defined0;
|
|
21829
|
-
}
|
|
21737
|
+
let tc = null;
|
|
21738
|
+
let bc = null;
|
|
21739
|
+
if (lastDefined !== topCurve.defined) {
|
|
21740
|
+
if (lastDefined) {
|
|
21741
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
21742
|
+
topList.length = 0;
|
|
21743
|
+
bottomList.length = 0;
|
|
21830
21744
|
}
|
|
21831
21745
|
else {
|
|
21832
|
-
|
|
21833
|
-
|
|
21834
|
-
let validBottomCurve;
|
|
21835
|
-
if (originP1 && originP1.defined !== false) {
|
|
21836
|
-
validTopCurve = currentTopCurve;
|
|
21837
|
-
validBottomCurve = currentBottomCurve;
|
|
21838
|
-
}
|
|
21839
|
-
else if (originP1 && originP2.defined !== false) {
|
|
21840
|
-
validTopCurve = topCurve;
|
|
21841
|
-
validBottomCurve = bototmCurve;
|
|
21842
|
-
}
|
|
21843
|
-
if (defined0) {
|
|
21844
|
-
defined0 = !defined0;
|
|
21845
|
-
topList.push(validTopCurve || topCurve);
|
|
21846
|
-
bottomList.push(validBottomCurve || bototmCurve);
|
|
21847
|
-
}
|
|
21848
|
-
else {
|
|
21849
|
-
if (validTopCurve) {
|
|
21850
|
-
defined0 = !defined0;
|
|
21851
|
-
topList.push(validTopCurve || topCurve);
|
|
21852
|
-
bottomList.push(validBottomCurve || bototmCurve);
|
|
21853
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21854
|
-
topList.length = 0;
|
|
21855
|
-
bottomList.length = 0;
|
|
21856
|
-
}
|
|
21857
|
-
}
|
|
21746
|
+
tc = topCurve;
|
|
21747
|
+
bc = bottom.curves[n - i - 1];
|
|
21858
21748
|
}
|
|
21859
|
-
|
|
21749
|
+
lastDefined = !lastDefined;
|
|
21860
21750
|
}
|
|
21861
21751
|
else {
|
|
21862
|
-
|
|
21863
|
-
|
|
21864
|
-
|
|
21865
|
-
|
|
21866
|
-
|
|
21867
|
-
|
|
21868
|
-
|
|
21752
|
+
if (lastDefined) {
|
|
21753
|
+
tc = topCurve;
|
|
21754
|
+
bc = bottom.curves[n - i - 1];
|
|
21755
|
+
}
|
|
21756
|
+
}
|
|
21757
|
+
if (tc && bc) {
|
|
21758
|
+
if (percent < 1) {
|
|
21759
|
+
if (tc.p2 && tc.p3) {
|
|
21760
|
+
tc = divideCubic(tc, percent)[0];
|
|
21869
21761
|
}
|
|
21870
21762
|
else {
|
|
21871
|
-
tc =
|
|
21872
|
-
bc = bottom.curves[n - i - 1];
|
|
21763
|
+
tc = divideLinear(tc, percent)[0];
|
|
21873
21764
|
}
|
|
21874
|
-
|
|
21875
|
-
|
|
21876
|
-
else {
|
|
21877
|
-
if (lastDefined) {
|
|
21878
|
-
tc = topCurve;
|
|
21879
|
-
bc = bottom.curves[n - i - 1];
|
|
21765
|
+
if (bc.p2 && bc.p3) {
|
|
21766
|
+
bc = divideCubic(bc, 1 - percent)[1];
|
|
21880
21767
|
}
|
|
21881
|
-
|
|
21882
|
-
|
|
21883
|
-
if (percent < 1) {
|
|
21884
|
-
if (tc.p2 && tc.p3) {
|
|
21885
|
-
tc = divideCubic(tc, percent)[0];
|
|
21886
|
-
}
|
|
21887
|
-
else {
|
|
21888
|
-
tc = divideLinear(tc, percent)[0];
|
|
21889
|
-
}
|
|
21890
|
-
if (bc.p2 && bc.p3) {
|
|
21891
|
-
bc = divideCubic(bc, 1 - percent)[1];
|
|
21892
|
-
}
|
|
21893
|
-
else {
|
|
21894
|
-
bc = divideLinear(bc, 1 - percent)[1];
|
|
21895
|
-
}
|
|
21768
|
+
else {
|
|
21769
|
+
bc = divideLinear(bc, 1 - percent)[1];
|
|
21896
21770
|
}
|
|
21897
|
-
tc.defined = lastDefined;
|
|
21898
|
-
bc.defined = lastDefined;
|
|
21899
|
-
topList.push(tc);
|
|
21900
|
-
bottomList.push(bc);
|
|
21901
21771
|
}
|
|
21902
|
-
tc =
|
|
21903
|
-
bc =
|
|
21772
|
+
tc.defined = lastDefined;
|
|
21773
|
+
bc.defined = lastDefined;
|
|
21774
|
+
topList.push(tc);
|
|
21775
|
+
bottomList.push(bc);
|
|
21904
21776
|
}
|
|
21777
|
+
tc = null;
|
|
21778
|
+
bc = null;
|
|
21905
21779
|
}
|
|
21906
|
-
|
|
21907
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21908
|
-
}
|
|
21909
|
-
else {
|
|
21910
|
-
drawAreaBlock(path, topList, bottomList, params);
|
|
21911
|
-
}
|
|
21912
|
-
}
|
|
21913
|
-
function drawAreaConnectBlock(path, topList, bottomList, params) {
|
|
21914
|
-
if (topList.length < 2) {
|
|
21915
|
-
return;
|
|
21916
|
-
}
|
|
21917
|
-
const { offsetX = 0, offsetY = 0, offsetZ = 0, mode } = params || {};
|
|
21918
|
-
let curve = topList[0];
|
|
21919
|
-
path.moveTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
21920
|
-
curve = topList[topList.length - 1];
|
|
21921
|
-
let end = curve.p3 || curve.p1;
|
|
21922
|
-
path.lineTo(end.x + offsetX, end.y + offsetY, offsetZ);
|
|
21923
|
-
curve = bottomList[bottomList.length - 1];
|
|
21924
|
-
path.lineTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
21925
|
-
curve = bottomList[0];
|
|
21926
|
-
end = curve.p3 || curve.p1;
|
|
21927
|
-
path.lineTo(end.x + offsetX, end.y + offsetY, offsetZ);
|
|
21928
|
-
path.closePath();
|
|
21780
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
21929
21781
|
}
|
|
21930
21782
|
function drawAreaBlock(path, topList, bottomList, params) {
|
|
21931
21783
|
const { offsetX = 0, offsetY = 0, offsetZ = 0 } = params || {};
|
|
@@ -22039,7 +21891,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22039
21891
|
drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
22040
21892
|
var _a, _b, _c, _d, _e, _f;
|
|
22041
21893
|
const areaAttribute = getTheme(area, params === null || params === void 0 ? void 0 : params.theme).area;
|
|
22042
|
-
const { fill = areaAttribute.fill, stroke = areaAttribute.stroke, fillOpacity = areaAttribute.fillOpacity, z = areaAttribute.z, strokeOpacity = areaAttribute.strokeOpacity, curveTension = areaAttribute.curveTension } = area.attribute;
|
|
21894
|
+
const { fill = areaAttribute.fill, stroke = areaAttribute.stroke, fillOpacity = areaAttribute.fillOpacity, z = areaAttribute.z, strokeOpacity = areaAttribute.strokeOpacity, curveTension = areaAttribute.curveTension, connectedType = areaAttribute.connectedType } = area.attribute;
|
|
22043
21895
|
const data = this.valid(area, areaAttribute, fillCb, strokeCb);
|
|
22044
21896
|
if (!data) {
|
|
22045
21897
|
return;
|
|
@@ -22051,6 +21903,12 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22051
21903
|
if (closePath && curveType === 'linear') {
|
|
22052
21904
|
curveType = 'linearClosed';
|
|
22053
21905
|
}
|
|
21906
|
+
function parsePoint(points, connectedType) {
|
|
21907
|
+
if (connectedType !== 'connect') {
|
|
21908
|
+
return points;
|
|
21909
|
+
}
|
|
21910
|
+
return points.filter(p => p.defined !== false);
|
|
21911
|
+
}
|
|
22054
21912
|
if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
|
|
22055
21913
|
return this.drawLinearAreaHighPerformance(area, context, !!fill, doStroke, fillOpacity, strokeOpacity, x, y, areaAttribute, drawContext, params, fillCb, strokeCb);
|
|
22056
21914
|
}
|
|
@@ -22073,7 +21931,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22073
21931
|
startPoint.x = lastTopSeg.endX;
|
|
22074
21932
|
startPoint.y = lastTopSeg.endY;
|
|
22075
21933
|
}
|
|
22076
|
-
const data = calcLineCache(seg.points, curveType, {
|
|
21934
|
+
const data = calcLineCache(parsePoint(seg.points, connectedType), curveType, {
|
|
22077
21935
|
startPoint,
|
|
22078
21936
|
curveTension
|
|
22079
21937
|
});
|
|
@@ -22102,7 +21960,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22102
21960
|
});
|
|
22103
21961
|
}
|
|
22104
21962
|
if (bottomPoints.length > 1) {
|
|
22105
|
-
lastBottomSeg = calcLineCache(bottomPoints, curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType, { curveTension });
|
|
21963
|
+
lastBottomSeg = calcLineCache(parsePoint(bottomPoints, connectedType), curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType, { curveTension });
|
|
22106
21964
|
bottomCaches.unshift(lastBottomSeg);
|
|
22107
21965
|
}
|
|
22108
21966
|
}
|
|
@@ -22112,12 +21970,12 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22112
21970
|
}));
|
|
22113
21971
|
}
|
|
22114
21972
|
else if (points && points.length) {
|
|
22115
|
-
const topPoints = points;
|
|
21973
|
+
const topPoints = parsePoint(points, connectedType);
|
|
22116
21974
|
const bottomPoints = [];
|
|
22117
|
-
for (let i =
|
|
21975
|
+
for (let i = topPoints.length - 1; i >= 0; i--) {
|
|
22118
21976
|
bottomPoints.push({
|
|
22119
|
-
x: (_e =
|
|
22120
|
-
y: (_f =
|
|
21977
|
+
x: (_e = topPoints[i].x1) !== null && _e !== void 0 ? _e : topPoints[i].x,
|
|
21978
|
+
y: (_f = topPoints[i].y1) !== null && _f !== void 0 ? _f : topPoints[i].y
|
|
22121
21979
|
});
|
|
22122
21980
|
}
|
|
22123
21981
|
const topCache = calcLineCache(topPoints, curveType, { curveTension });
|
|
@@ -22172,17 +22030,9 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22172
22030
|
this._draw(area, areaAttribute, false, drawContext, params);
|
|
22173
22031
|
}
|
|
22174
22032
|
drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
|
|
22175
|
-
|
|
22176
|
-
ret =
|
|
22177
|
-
ret ||
|
|
22178
|
-
this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, false, fillCb, strokeCb);
|
|
22179
|
-
ret =
|
|
22180
|
-
ret ||
|
|
22181
|
-
this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, true, fillCb, strokeCb);
|
|
22182
|
-
return ret;
|
|
22033
|
+
return this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb);
|
|
22183
22034
|
}
|
|
22184
|
-
_drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext,
|
|
22185
|
-
var _a, _b, _c, _d;
|
|
22035
|
+
_drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
|
|
22186
22036
|
if (!(cache &&
|
|
22187
22037
|
cache.top &&
|
|
22188
22038
|
cache.bottom &&
|
|
@@ -22192,35 +22042,6 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22192
22042
|
cache.bottom.curves.length)) {
|
|
22193
22043
|
return;
|
|
22194
22044
|
}
|
|
22195
|
-
let { connectedType, connectedX, connectedY, connectedStyle } = attribute;
|
|
22196
|
-
const da = [];
|
|
22197
|
-
if (connect) {
|
|
22198
|
-
if (isArray(defaultAttribute)) {
|
|
22199
|
-
connectedType = (_a = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute[0].connectedType) !== null && _a !== void 0 ? _a : defaultAttribute[1].connectedType;
|
|
22200
|
-
connectedX = (_b = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute[0].connectedX) !== null && _b !== void 0 ? _b : defaultAttribute[1].connectedX;
|
|
22201
|
-
connectedY = (_c = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute[0].connectedY) !== null && _c !== void 0 ? _c : defaultAttribute[1].connectedY;
|
|
22202
|
-
connectedStyle = (_d = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute[0].connectedStyle) !== null && _d !== void 0 ? _d : defaultAttribute[1].connectedStyle;
|
|
22203
|
-
}
|
|
22204
|
-
else {
|
|
22205
|
-
connectedType = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute.connectedType;
|
|
22206
|
-
connectedX = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute.connectedX;
|
|
22207
|
-
connectedY = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute.connectedY;
|
|
22208
|
-
connectedStyle = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute.connectedStyle;
|
|
22209
|
-
}
|
|
22210
|
-
if (connectedType !== 'connect' && connectedType !== 'zero') {
|
|
22211
|
-
connectedType = 'none';
|
|
22212
|
-
}
|
|
22213
|
-
if (isArray(defaultAttribute)) {
|
|
22214
|
-
defaultAttribute.forEach(i => da.push(i));
|
|
22215
|
-
}
|
|
22216
|
-
else {
|
|
22217
|
-
da.push(defaultAttribute);
|
|
22218
|
-
}
|
|
22219
|
-
da.push(attribute);
|
|
22220
|
-
}
|
|
22221
|
-
if (connect && connectedType === 'none') {
|
|
22222
|
-
return false;
|
|
22223
|
-
}
|
|
22224
22045
|
context.beginPath();
|
|
22225
22046
|
const ret = false;
|
|
22226
22047
|
const { points, segments } = area.attribute;
|
|
@@ -22255,11 +22076,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22255
22076
|
offsetX,
|
|
22256
22077
|
offsetY,
|
|
22257
22078
|
offsetZ,
|
|
22258
|
-
direction
|
|
22259
|
-
drawConnect: connect,
|
|
22260
|
-
mode: connectedType,
|
|
22261
|
-
zeroX: connectedX,
|
|
22262
|
-
zeroY: connectedY
|
|
22079
|
+
direction
|
|
22263
22080
|
});
|
|
22264
22081
|
this.beforeRenderStep(area, context, offsetX, offsetY, !!fillOpacity, false, fill, false, defaultAttribute, drawContext, fillCb, null, { attribute });
|
|
22265
22082
|
context.setShadowBlendStyle && context.setShadowBlendStyle(area, attribute, defaultAttribute);
|
|
@@ -22270,7 +22087,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22270
22087
|
fillCb(context, attribute, defaultAttribute);
|
|
22271
22088
|
}
|
|
22272
22089
|
else if (fillOpacity) {
|
|
22273
|
-
context.setCommonStyle(area,
|
|
22090
|
+
context.setCommonStyle(area, attribute, originX - offsetX, originY - offsetY, defaultAttribute);
|
|
22274
22091
|
context.fill();
|
|
22275
22092
|
}
|
|
22276
22093
|
}
|
|
@@ -22287,14 +22104,10 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22287
22104
|
drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? 'x' : 'y', {
|
|
22288
22105
|
offsetX,
|
|
22289
22106
|
offsetY,
|
|
22290
|
-
offsetZ
|
|
22291
|
-
drawConnect: connect,
|
|
22292
|
-
mode: connectedType,
|
|
22293
|
-
zeroX: connectedX,
|
|
22294
|
-
zeroY: connectedY
|
|
22107
|
+
offsetZ
|
|
22295
22108
|
});
|
|
22296
22109
|
}
|
|
22297
|
-
context.setStrokeStyle(area,
|
|
22110
|
+
context.setStrokeStyle(area, attribute, originX - offsetX, originY - offsetY, defaultAttribute);
|
|
22298
22111
|
context.stroke();
|
|
22299
22112
|
}
|
|
22300
22113
|
}
|
|
@@ -22663,7 +22476,7 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
|
|
|
22663
22476
|
}
|
|
22664
22477
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
22665
22478
|
var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
22666
|
-
const { backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit } = graphic.attribute;
|
|
22479
|
+
const { backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit, backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio } = graphic.attribute;
|
|
22667
22480
|
let { background } = graphic.attribute;
|
|
22668
22481
|
if (!background) {
|
|
22669
22482
|
return;
|
|
@@ -22720,7 +22533,7 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
|
|
|
22720
22533
|
context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);
|
|
22721
22534
|
}
|
|
22722
22535
|
context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);
|
|
22723
|
-
this.doDrawImage(context, res.data, b, { backgroundMode, backgroundFit });
|
|
22536
|
+
this.doDrawImage(context, res.data, b, { backgroundMode, backgroundFit, backgroundKeepAspectRatio });
|
|
22724
22537
|
context.highPerformanceRestore();
|
|
22725
22538
|
context.setTransformForCurrent();
|
|
22726
22539
|
}
|
|
@@ -24318,6 +24131,9 @@ let DefaultDrawContribution = class DefaultDrawContribution {
|
|
|
24318
24131
|
this.backupDirtyBounds = new Bounds();
|
|
24319
24132
|
this.global = application.global;
|
|
24320
24133
|
this.layerService = application.layerService;
|
|
24134
|
+
if (!isArray(this.contributions)) {
|
|
24135
|
+
this.contributions = [this.contributions];
|
|
24136
|
+
}
|
|
24321
24137
|
this.init();
|
|
24322
24138
|
}
|
|
24323
24139
|
init() {
|
|
@@ -27133,12 +26949,12 @@ class EditModule {
|
|
|
27133
26949
|
this.composingConfigIdx = this.cursorIndex < 0 ? 0 : findConfigIndexByCursorIdx(textConfig, this.cursorIndex);
|
|
27134
26950
|
if (this.cursorIndex < 0) {
|
|
27135
26951
|
const config = textConfig[0];
|
|
27136
|
-
textConfig.unshift(Object.assign(Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), config), { text: '' }));
|
|
26952
|
+
textConfig.unshift(Object.assign(Object.assign(Object.assign({ fill: 'black' }, getDefaultCharacterConfig(this.currRt.attribute)), config), { text: '' }));
|
|
27137
26953
|
}
|
|
27138
26954
|
else {
|
|
27139
26955
|
const configIdx = this.composingConfigIdx;
|
|
27140
26956
|
const lastConfig = textConfig[configIdx] || textConfig[configIdx - 1];
|
|
27141
|
-
textConfig.splice(configIdx, 0, Object.assign(Object.assign({}, lastConfig), { text: '' }));
|
|
26957
|
+
textConfig.splice(configIdx, 0, Object.assign(Object.assign({ fill: 'black' }, lastConfig), { text: '' }));
|
|
27142
26958
|
}
|
|
27143
26959
|
};
|
|
27144
26960
|
this.handleCompositionEnd = () => {
|
|
@@ -27262,13 +27078,14 @@ class EditModule {
|
|
|
27262
27078
|
application.global.addEventListener('keydown', this.handleKeyDown);
|
|
27263
27079
|
}
|
|
27264
27080
|
parseCompositionStr(configIdx) {
|
|
27081
|
+
var _a;
|
|
27265
27082
|
const { textConfig = [] } = this.currRt.attribute;
|
|
27266
|
-
const lastConfig = textConfig[configIdx];
|
|
27083
|
+
const lastConfig = (_a = textConfig[configIdx]) !== null && _a !== void 0 ? _a : {};
|
|
27267
27084
|
textConfig.splice(configIdx, 1);
|
|
27268
27085
|
const text = lastConfig.text;
|
|
27269
27086
|
const textList = text ? Array.from(text.toString()) : [];
|
|
27270
27087
|
for (let i = 0; i < textList.length; i++) {
|
|
27271
|
-
textConfig.splice(i + configIdx, 0, Object.assign(Object.assign(
|
|
27088
|
+
textConfig.splice(i + configIdx, 0, Object.assign(Object.assign({ fill: 'black' }, lastConfig), { isComposing: false, text: textList[i] }));
|
|
27272
27089
|
}
|
|
27273
27090
|
this.currRt.setAttributes({ textConfig });
|
|
27274
27091
|
const nextConfigIdx = configIdx + textList.length;
|
|
@@ -27343,18 +27160,23 @@ class Selection {
|
|
|
27343
27160
|
}
|
|
27344
27161
|
return (_a = config[Math.min(idx, config.length - 1)][key]) !== null && _a !== void 0 ? _a : this.rt.attribute[key];
|
|
27345
27162
|
}
|
|
27346
|
-
getFormat(key) {
|
|
27347
|
-
return this.getAllFormat(key)[0];
|
|
27163
|
+
getFormat(key, supportOutAttr = false) {
|
|
27164
|
+
return this.getAllFormat(key, supportOutAttr)[0];
|
|
27348
27165
|
}
|
|
27349
|
-
getAllFormat(key) {
|
|
27166
|
+
getAllFormat(key, supportOutAttr = false) {
|
|
27167
|
+
var _a, _b, _c, _d;
|
|
27350
27168
|
const valSet = new Set();
|
|
27351
27169
|
const minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx);
|
|
27352
27170
|
const maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
|
|
27353
27171
|
if (minCursorIdx === maxCursorIdx) {
|
|
27354
|
-
return
|
|
27172
|
+
return supportOutAttr
|
|
27173
|
+
? [(_a = this._getFormat(key, minCursorIdx)) !== null && _a !== void 0 ? _a : ((_b = this.rt) === null || _b === void 0 ? void 0 : _b.attribute)[key]]
|
|
27174
|
+
: [this._getFormat(key, minCursorIdx)];
|
|
27355
27175
|
}
|
|
27356
27176
|
for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
|
|
27357
|
-
const val =
|
|
27177
|
+
const val = supportOutAttr
|
|
27178
|
+
? (_c = this._getFormat(key, i)) !== null && _c !== void 0 ? _c : ((_d = this.rt) === null || _d === void 0 ? void 0 : _d.attribute)[key]
|
|
27179
|
+
: this._getFormat(key, i);
|
|
27358
27180
|
val && valSet.add(val);
|
|
27359
27181
|
}
|
|
27360
27182
|
return Array.from(valSet.values());
|
|
@@ -27419,10 +27241,10 @@ class RichTextEditPlugin {
|
|
|
27419
27241
|
if (this.copyToClipboard(e)) {
|
|
27420
27242
|
return;
|
|
27421
27243
|
}
|
|
27422
|
-
if (this.
|
|
27244
|
+
if (this.fullSelectionKeyHandler(e)) {
|
|
27423
27245
|
return;
|
|
27424
27246
|
}
|
|
27425
|
-
if (this.
|
|
27247
|
+
if (this.directKeyHandler(e)) {
|
|
27426
27248
|
return;
|
|
27427
27249
|
}
|
|
27428
27250
|
};
|
|
@@ -27455,31 +27277,28 @@ class RichTextEditPlugin {
|
|
|
27455
27277
|
throw new Error('不会走到这里 handleFocusOut');
|
|
27456
27278
|
};
|
|
27457
27279
|
this.handleMove = (e) => {
|
|
27458
|
-
if (
|
|
27459
|
-
this.deFocus(true);
|
|
27460
|
-
}
|
|
27461
|
-
if (!this.isEditableRichtext(e)) {
|
|
27462
|
-
this.handleLeave();
|
|
27280
|
+
if (!this.isRichtext(e)) {
|
|
27463
27281
|
return;
|
|
27464
27282
|
}
|
|
27465
|
-
this.
|
|
27466
|
-
|
|
27283
|
+
this.currRt = e.target;
|
|
27284
|
+
this.handleEnter(e);
|
|
27285
|
+
e.target.once('pointerleave', this.handleLeave, { capture: true });
|
|
27467
27286
|
this.tryShowSelection(e, false);
|
|
27468
27287
|
};
|
|
27469
|
-
this.handleEnter = () => {
|
|
27288
|
+
this.handleEnter = (e) => {
|
|
27470
27289
|
this.editing = true;
|
|
27471
27290
|
this.pluginService.stage.setCursor('text');
|
|
27472
27291
|
};
|
|
27473
|
-
this.handleLeave = () => {
|
|
27292
|
+
this.handleLeave = (e) => {
|
|
27474
27293
|
this.editing = false;
|
|
27475
27294
|
this.pluginService.stage.setCursor('default');
|
|
27476
27295
|
};
|
|
27477
27296
|
this.handlePointerDown = (e) => {
|
|
27478
|
-
if (
|
|
27479
|
-
this.
|
|
27297
|
+
if (this.editing) {
|
|
27298
|
+
this.onFocus(e);
|
|
27480
27299
|
}
|
|
27481
27300
|
else {
|
|
27482
|
-
this.
|
|
27301
|
+
this.deFocus(true);
|
|
27483
27302
|
}
|
|
27484
27303
|
this.triggerRender();
|
|
27485
27304
|
this.pointerDown = true;
|
|
@@ -27557,11 +27376,11 @@ class RichTextEditPlugin {
|
|
|
27557
27376
|
activate(context) {
|
|
27558
27377
|
this.pluginService = context;
|
|
27559
27378
|
this.editModule = new EditModule();
|
|
27560
|
-
context.stage.on('pointermove', this.handleMove);
|
|
27561
|
-
context.stage.on('pointerdown', this.handlePointerDown);
|
|
27562
|
-
context.stage.on('pointerup', this.handlePointerUp);
|
|
27563
|
-
context.stage.on('pointerleave', this.handlePointerUp);
|
|
27564
|
-
context.stage.on('dblclick', this.handleDBLClick);
|
|
27379
|
+
context.stage.on('pointermove', this.handleMove, { capture: true });
|
|
27380
|
+
context.stage.on('pointerdown', this.handlePointerDown, { capture: true });
|
|
27381
|
+
context.stage.on('pointerup', this.handlePointerUp, { capture: true });
|
|
27382
|
+
context.stage.on('pointerleave', this.handlePointerUp, { capture: true });
|
|
27383
|
+
context.stage.on('dblclick', this.handleDBLClick, { capture: true });
|
|
27565
27384
|
application.global.addEventListener('keydown', this.handleKeyDown);
|
|
27566
27385
|
this.editModule.onInput(this.handleInput);
|
|
27567
27386
|
this.editModule.onChange(this.handleChange);
|
|
@@ -27605,32 +27424,32 @@ class RichTextEditPlugin {
|
|
|
27605
27424
|
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt);
|
|
27606
27425
|
this._tryShowSelection(pos, cache);
|
|
27607
27426
|
}
|
|
27608
|
-
fullSelection(
|
|
27427
|
+
fullSelection() {
|
|
27428
|
+
const currRt = this.currRt;
|
|
27429
|
+
if (!currRt) {
|
|
27430
|
+
return;
|
|
27431
|
+
}
|
|
27432
|
+
const cache = currRt.getFrameCache();
|
|
27433
|
+
if (!cache) {
|
|
27434
|
+
return;
|
|
27435
|
+
}
|
|
27436
|
+
const { lines } = cache;
|
|
27437
|
+
if (!(lines.length && lines[0].paragraphs.length)) {
|
|
27438
|
+
return;
|
|
27439
|
+
}
|
|
27440
|
+
const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
|
|
27441
|
+
this.selectionRange(-0.1, totalCursorCount + 0.1);
|
|
27442
|
+
}
|
|
27443
|
+
fullSelectionKeyHandler(e) {
|
|
27609
27444
|
if ((application.global.isMacOS() && e.metaKey && e.key === 'a') ||
|
|
27610
27445
|
(!application.global.isMacOS() && e.ctrlKey && e.key === 'a')) {
|
|
27611
|
-
|
|
27612
|
-
if (!currRt) {
|
|
27613
|
-
return;
|
|
27614
|
-
}
|
|
27615
|
-
const cache = currRt.getFrameCache();
|
|
27616
|
-
if (!cache) {
|
|
27617
|
-
return;
|
|
27618
|
-
}
|
|
27619
|
-
const { lines } = cache;
|
|
27620
|
-
if (lines.length === 0) {
|
|
27621
|
-
return;
|
|
27622
|
-
}
|
|
27623
|
-
if (!lines[0].paragraphs || lines[0].paragraphs.length === 0) {
|
|
27624
|
-
return;
|
|
27625
|
-
}
|
|
27626
|
-
const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
|
|
27627
|
-
this.selectionRange(-0.1, totalCursorCount + 0.1);
|
|
27446
|
+
this.fullSelection();
|
|
27628
27447
|
e.preventDefault();
|
|
27629
27448
|
return true;
|
|
27630
27449
|
}
|
|
27631
27450
|
return false;
|
|
27632
27451
|
}
|
|
27633
|
-
|
|
27452
|
+
directKeyHandler(e) {
|
|
27634
27453
|
if (!(e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'ArrowLeft' || e.key === 'ArrowRight')) {
|
|
27635
27454
|
return false;
|
|
27636
27455
|
}
|
|
@@ -27728,7 +27547,7 @@ class RichTextEditPlugin {
|
|
|
27728
27547
|
const placeholder = shadowRoot.getElementsByType('richtext')[0];
|
|
27729
27548
|
placeholder && shadowRoot.removeChild(placeholder);
|
|
27730
27549
|
}
|
|
27731
|
-
const { textConfig, editOptions } = this.currRt.attribute;
|
|
27550
|
+
const { textConfig, editOptions = {} } = this.currRt.attribute;
|
|
27732
27551
|
if (textConfig && textConfig.length) {
|
|
27733
27552
|
return;
|
|
27734
27553
|
}
|
|
@@ -27747,9 +27566,16 @@ class RichTextEditPlugin {
|
|
|
27747
27566
|
if (placeholderFontSize) {
|
|
27748
27567
|
textConfigItem.fontSize = placeholderFontSize;
|
|
27749
27568
|
}
|
|
27750
|
-
this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), { x: 0, y: 0,
|
|
27569
|
+
this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), { x: 0, y: 0, dx: -this.deltaX, dy: -this.deltaY, angle: 0, textConfig: [textConfigItem] }));
|
|
27751
27570
|
shadow.add(this.shadowPlaceHolder);
|
|
27752
27571
|
}
|
|
27572
|
+
getRichTextAABBBounds(rt) {
|
|
27573
|
+
const { attribute } = rt;
|
|
27574
|
+
if (!attribute.textConfig.length) {
|
|
27575
|
+
return getRichTextBounds(Object.assign(Object.assign({}, this.shadowPlaceHolder.attribute), { x: attribute.x, y: attribute.y, textAlign: attribute.textAlign, boundsMode: 'accurate' }));
|
|
27576
|
+
}
|
|
27577
|
+
return rt.AABBBounds;
|
|
27578
|
+
}
|
|
27753
27579
|
tryShowInputBounds() {
|
|
27754
27580
|
if (!(this.currRt && this.focusing)) {
|
|
27755
27581
|
return;
|
|
@@ -27759,20 +27585,15 @@ class RichTextEditPlugin {
|
|
|
27759
27585
|
if (!editOptions || !boundsStrokeWhenInput) {
|
|
27760
27586
|
return;
|
|
27761
27587
|
}
|
|
27762
|
-
const
|
|
27763
|
-
|
|
27764
|
-
|
|
27765
|
-
if (!attribute.textConfig.length && this.editLine) {
|
|
27766
|
-
const { points } = this.editLine.attribute;
|
|
27767
|
-
h = points[1].y - points[0].y;
|
|
27768
|
-
b = getRichTextBounds(Object.assign({}, this.shadowPlaceHolder.attribute));
|
|
27769
|
-
}
|
|
27588
|
+
const b = this.getRichTextAABBBounds(this.currRt);
|
|
27589
|
+
const height = b.height();
|
|
27590
|
+
const width = b.width();
|
|
27770
27591
|
this.shadowBounds = this.shadowBounds || createRect({});
|
|
27771
27592
|
this.shadowBounds.setAttributes({
|
|
27772
27593
|
x: 0,
|
|
27773
27594
|
y: 0,
|
|
27774
|
-
width
|
|
27775
|
-
height
|
|
27595
|
+
width,
|
|
27596
|
+
height,
|
|
27776
27597
|
fill: false,
|
|
27777
27598
|
stroke: boundsStrokeWhenInput,
|
|
27778
27599
|
lineWidth: 1,
|
|
@@ -27781,6 +27602,7 @@ class RichTextEditPlugin {
|
|
|
27781
27602
|
const shadow = this.getShadow(this.currRt);
|
|
27782
27603
|
shadow.add(this.shadowBounds);
|
|
27783
27604
|
this.offsetLineBgAndShadowBounds();
|
|
27605
|
+
this.offsetShadowRoot();
|
|
27784
27606
|
}
|
|
27785
27607
|
trySyncPlaceholderToTextConfig() {
|
|
27786
27608
|
if (!this.currRt) {
|
|
@@ -27790,7 +27612,7 @@ class RichTextEditPlugin {
|
|
|
27790
27612
|
if (textConfig && textConfig.length) {
|
|
27791
27613
|
return;
|
|
27792
27614
|
}
|
|
27793
|
-
if (!(editOptions && editOptions.placeholder && editOptions.
|
|
27615
|
+
if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceholderToTextConfig)) {
|
|
27794
27616
|
return;
|
|
27795
27617
|
}
|
|
27796
27618
|
const { placeholder } = editOptions;
|
|
@@ -27801,13 +27623,16 @@ class RichTextEditPlugin {
|
|
|
27801
27623
|
});
|
|
27802
27624
|
}
|
|
27803
27625
|
deactivate(context) {
|
|
27804
|
-
context.stage.off('pointermove', this.handleMove);
|
|
27805
|
-
context.stage.off('pointerdown', this.handlePointerDown);
|
|
27806
|
-
context.stage.off('pointerup', this.handlePointerUp);
|
|
27807
|
-
context.stage.off('pointerleave', this.handlePointerUp);
|
|
27808
|
-
context.stage.off('dblclick', this.handleDBLClick);
|
|
27626
|
+
context.stage.off('pointermove', this.handleMove, { capture: true });
|
|
27627
|
+
context.stage.off('pointerdown', this.handlePointerDown, { capture: true });
|
|
27628
|
+
context.stage.off('pointerup', this.handlePointerUp, { capture: true });
|
|
27629
|
+
context.stage.off('pointerleave', this.handlePointerUp, { capture: true });
|
|
27630
|
+
context.stage.off('dblclick', this.handleDBLClick, { capture: true });
|
|
27809
27631
|
application.global.addEventListener('keydown', this.handleKeyDown);
|
|
27810
27632
|
}
|
|
27633
|
+
stopPropagation(e) {
|
|
27634
|
+
e.stopPropagation();
|
|
27635
|
+
}
|
|
27811
27636
|
onFocus(e, data) {
|
|
27812
27637
|
this.updateCbs && this.updateCbs.forEach(cb => cb('beforeOnfocus', this));
|
|
27813
27638
|
this.deFocus(false);
|
|
@@ -27823,8 +27648,11 @@ class RichTextEditPlugin {
|
|
|
27823
27648
|
if (!cache) {
|
|
27824
27649
|
return;
|
|
27825
27650
|
}
|
|
27826
|
-
this.
|
|
27827
|
-
|
|
27651
|
+
const { editOptions = {} } = this.currRt.attribute;
|
|
27652
|
+
if (editOptions.stopPropagation) {
|
|
27653
|
+
target.addEventListener('*', this.stopPropagation);
|
|
27654
|
+
}
|
|
27655
|
+
this.offsetShadowRoot(target);
|
|
27828
27656
|
if (!this.editLine) {
|
|
27829
27657
|
const line = createLine({ x: 0, y: 0, lineWidth: 1, stroke: 'black' });
|
|
27830
27658
|
this.addAnimateToLine(line);
|
|
@@ -27856,6 +27684,23 @@ class RichTextEditPlugin {
|
|
|
27856
27684
|
this.tryShowInputBounds();
|
|
27857
27685
|
this.currRt.addUpdateBoundTag();
|
|
27858
27686
|
}
|
|
27687
|
+
offsetShadowRoot(rt) {
|
|
27688
|
+
rt = rt || this.currRt;
|
|
27689
|
+
if (!rt) {
|
|
27690
|
+
return;
|
|
27691
|
+
}
|
|
27692
|
+
const shadowRoot = this.getShadow(rt);
|
|
27693
|
+
if (!shadowRoot) {
|
|
27694
|
+
return;
|
|
27695
|
+
}
|
|
27696
|
+
const cache = rt.getFrameCache();
|
|
27697
|
+
if (!cache) {
|
|
27698
|
+
return;
|
|
27699
|
+
}
|
|
27700
|
+
this.computeGlobalDelta(cache);
|
|
27701
|
+
shadowRoot.setAttributes({ shadowRootIdx: 1, pickable: false, x: this.deltaX, y: this.deltaY });
|
|
27702
|
+
this.shadowPlaceHolder && this.shadowPlaceHolder.setAttributes({ dx: -this.deltaX, dy: -this.deltaY });
|
|
27703
|
+
}
|
|
27859
27704
|
offsetLineBgAndShadowBounds() {
|
|
27860
27705
|
const rt = this.currRt;
|
|
27861
27706
|
const { textBaseline } = rt.attribute;
|
|
@@ -27881,11 +27726,15 @@ class RichTextEditPlugin {
|
|
|
27881
27726
|
}
|
|
27882
27727
|
}
|
|
27883
27728
|
deFocus(trulyDeFocus = false) {
|
|
27729
|
+
this.updateCbs && this.updateCbs.forEach(cb => cb('beforeDefocus', this, { trulyDeFocus }));
|
|
27884
27730
|
const target = this.currRt;
|
|
27885
27731
|
if (!target) {
|
|
27886
27732
|
return;
|
|
27887
27733
|
}
|
|
27888
|
-
|
|
27734
|
+
const { editOptions = {} } = target.attribute;
|
|
27735
|
+
if (editOptions.stopPropagation) {
|
|
27736
|
+
target.removeEventListener('*', this.stopPropagation);
|
|
27737
|
+
}
|
|
27889
27738
|
if (trulyDeFocus) {
|
|
27890
27739
|
this.trySyncPlaceholderToTextConfig();
|
|
27891
27740
|
target.detachShadow();
|
|
@@ -27922,7 +27771,6 @@ class RichTextEditPlugin {
|
|
|
27922
27771
|
cleared = true;
|
|
27923
27772
|
}
|
|
27924
27773
|
cleared && currRt.setAttributes({ textConfig });
|
|
27925
|
-
currRt.removeEventListener('pointerleave', this.handleLeave);
|
|
27926
27774
|
}
|
|
27927
27775
|
addAnimateToLine(line) {
|
|
27928
27776
|
line.animates &&
|
|
@@ -27983,9 +27831,6 @@ class RichTextEditPlugin {
|
|
|
27983
27831
|
};
|
|
27984
27832
|
let line0Info = this.getLineByPoint(cache, startCursorPos);
|
|
27985
27833
|
let line1Info = this.getLineByPoint(cache, endCursorPos);
|
|
27986
|
-
if (!line0Info || !line1Info) {
|
|
27987
|
-
return;
|
|
27988
|
-
}
|
|
27989
27834
|
if (startCursorPos.y > endCursorPos.y ||
|
|
27990
27835
|
(startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x)) {
|
|
27991
27836
|
[startCursorPos, endCursorPos] = [endCursorPos, startCursorPos];
|
|
@@ -28119,10 +27964,7 @@ class RichTextEditPlugin {
|
|
|
28119
27964
|
return -1;
|
|
28120
27965
|
}
|
|
28121
27966
|
isRichtext(e) {
|
|
28122
|
-
return !!(e.target && e.target.type === 'richtext');
|
|
28123
|
-
}
|
|
28124
|
-
isEditableRichtext(e) {
|
|
28125
|
-
return this.isRichtext(e) && !!e.target.attribute.editable;
|
|
27967
|
+
return !!(e.target && e.target.type === 'richtext' && e.target.attribute.editable);
|
|
28126
27968
|
}
|
|
28127
27969
|
triggerRender() {
|
|
28128
27970
|
this.pluginService.stage.renderNextFrame();
|
|
@@ -28130,6 +27972,9 @@ class RichTextEditPlugin {
|
|
|
28130
27972
|
computeGlobalDelta(cache) {
|
|
28131
27973
|
this.deltaX = 0;
|
|
28132
27974
|
this.deltaY = 0;
|
|
27975
|
+
if (cache.lines.length === 0 && this.shadowPlaceHolder) {
|
|
27976
|
+
cache = this.shadowPlaceHolder.getFrameCache();
|
|
27977
|
+
}
|
|
28133
27978
|
const height = cache.height;
|
|
28134
27979
|
const actualHeight = cache.actualHeight;
|
|
28135
27980
|
const width = cache.lines.reduce((w, item) => Math.max(w, item.actualWidth), 0);
|
|
@@ -28180,6 +28025,7 @@ class RichTextEditPlugin {
|
|
|
28180
28025
|
out.x += left;
|
|
28181
28026
|
out.y += top;
|
|
28182
28027
|
this.offsetLineBgAndShadowBounds();
|
|
28028
|
+
this.offsetShadowRoot();
|
|
28183
28029
|
this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
|
|
28184
28030
|
}
|
|
28185
28031
|
computedCursorPosByEvent(e, cache) {
|
|
@@ -28281,7 +28127,7 @@ class RichTextEditPlugin {
|
|
|
28281
28127
|
}
|
|
28282
28128
|
}
|
|
28283
28129
|
_forceFocusByEvent(e) {
|
|
28284
|
-
this.handleEnter();
|
|
28130
|
+
this.handleEnter(e);
|
|
28285
28131
|
this.handlePointerDown(e);
|
|
28286
28132
|
this.handlePointerUp(e);
|
|
28287
28133
|
}
|