@visactor/vrender-core 0.22.0-vstory.11 → 0.22.0-vstory.14
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/graphic.js +4 -4
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.d.ts +0 -1
- package/cjs/graphic/group.js +0 -5
- package/cjs/graphic/group.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 +190 -159
- 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 +328 -501
- 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/graphic.js +5 -5
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.d.ts +0 -1
- package/es/graphic/group.js +0 -5
- package/es/graphic/group.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 +190 -159
- 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 +1 -1
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);
|
|
@@ -12385,7 +12412,6 @@ class Graphic extends Node {
|
|
|
12385
12412
|
}
|
|
12386
12413
|
this.animates.set(animate.id, animate);
|
|
12387
12414
|
animate.onRemove(() => {
|
|
12388
|
-
animate.stop();
|
|
12389
12415
|
this.animates.delete(animate.id);
|
|
12390
12416
|
});
|
|
12391
12417
|
return animate;
|
|
@@ -12686,9 +12712,7 @@ class Graphic extends Node {
|
|
|
12686
12712
|
if (this.animates && this.animates.size) {
|
|
12687
12713
|
const timeline = stage.getTimeline();
|
|
12688
12714
|
this.animates.forEach(a => {
|
|
12689
|
-
|
|
12690
|
-
a.setTimeline(timeline);
|
|
12691
|
-
}
|
|
12715
|
+
a.setTimeline(timeline);
|
|
12692
12716
|
});
|
|
12693
12717
|
}
|
|
12694
12718
|
this._onSetStage && this._onSetStage(this, stage, layer);
|
|
@@ -12862,7 +12886,6 @@ class Graphic extends Node {
|
|
|
12862
12886
|
detachShadow() {
|
|
12863
12887
|
if (this.shadowRoot) {
|
|
12864
12888
|
this.addUpdateBoundTag();
|
|
12865
|
-
this.shadowRoot.release(true);
|
|
12866
12889
|
this.shadowRoot = null;
|
|
12867
12890
|
}
|
|
12868
12891
|
}
|
|
@@ -12970,7 +12993,6 @@ class Graphic extends Node {
|
|
|
12970
12993
|
}
|
|
12971
12994
|
release() {
|
|
12972
12995
|
this.releaseStatus = 'released';
|
|
12973
|
-
this.stopAnimates();
|
|
12974
12996
|
application.graphicService.onRelease(this);
|
|
12975
12997
|
}
|
|
12976
12998
|
_emitCustomEvent(type, context) {
|
|
@@ -13785,14 +13807,6 @@ class Group extends Graphic {
|
|
|
13785
13807
|
getNoWorkAnimateAttr() {
|
|
13786
13808
|
return Group.NOWORK_ANIMATE_ATTR;
|
|
13787
13809
|
}
|
|
13788
|
-
release(all) {
|
|
13789
|
-
if (all) {
|
|
13790
|
-
this.forEachChildren((g) => {
|
|
13791
|
-
g.release(all);
|
|
13792
|
-
});
|
|
13793
|
-
}
|
|
13794
|
-
super.release();
|
|
13795
|
-
}
|
|
13796
13810
|
}
|
|
13797
13811
|
Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
13798
13812
|
function createGroup(attributes) {
|
|
@@ -17211,7 +17225,7 @@ let Line$1 = class Line extends Graphic {
|
|
|
17211
17225
|
const { points = lineTheme.points, connectedType } = attribute;
|
|
17212
17226
|
const b = aabbBounds;
|
|
17213
17227
|
points.forEach(p => {
|
|
17214
|
-
if (p.defined !== false || connectedType === '
|
|
17228
|
+
if (p.defined !== false || connectedType === 'connect') {
|
|
17215
17229
|
b.add(p.x, p.y);
|
|
17216
17230
|
}
|
|
17217
17231
|
});
|
|
@@ -17222,7 +17236,7 @@ let Line$1 = class Line extends Graphic {
|
|
|
17222
17236
|
const b = aabbBounds;
|
|
17223
17237
|
segments.forEach(s => {
|
|
17224
17238
|
s.points.forEach(p => {
|
|
17225
|
-
if (p.defined !== false || connectedType === '
|
|
17239
|
+
if (p.defined !== false || connectedType === 'connect') {
|
|
17226
17240
|
b.add(p.x, p.y);
|
|
17227
17241
|
}
|
|
17228
17242
|
});
|
|
@@ -17857,17 +17871,22 @@ function getFixedLRTB(left, right, top, bottom) {
|
|
|
17857
17871
|
const topInt = Math.round(top);
|
|
17858
17872
|
const rightInt = Math.round(right);
|
|
17859
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;
|
|
17860
17878
|
return {
|
|
17861
|
-
left:
|
|
17862
|
-
top:
|
|
17863
|
-
right:
|
|
17864
|
-
bottom:
|
|
17879
|
+
left: _left,
|
|
17880
|
+
top: _top,
|
|
17881
|
+
right: _right,
|
|
17882
|
+
bottom: _bottom
|
|
17865
17883
|
};
|
|
17866
17884
|
}
|
|
17867
17885
|
class Paragraph {
|
|
17868
|
-
constructor(text, newLine, character) {
|
|
17886
|
+
constructor(text, newLine, character, ascentDescentMode) {
|
|
17869
17887
|
this.fontSize = character.fontSize || 16;
|
|
17870
17888
|
this.textBaseline = character.textBaseline || 'alphabetic';
|
|
17889
|
+
this.ascentDescentMode = ascentDescentMode;
|
|
17871
17890
|
const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
|
|
17872
17891
|
if (typeof lineHeight === 'number') {
|
|
17873
17892
|
this.lineHeight = lineHeight > this.fontSize ? lineHeight : this.fontSize;
|
|
@@ -17876,7 +17895,7 @@ class Paragraph {
|
|
|
17876
17895
|
this.lineHeight = Math.floor(1.2 * this.fontSize);
|
|
17877
17896
|
}
|
|
17878
17897
|
this.height = this.lineHeight;
|
|
17879
|
-
const { ascent, height, descent, width } = measureTextCanvas(text, character);
|
|
17898
|
+
const { ascent, height, descent, width } = measureTextCanvas(text, character, this.ascentDescentMode);
|
|
17880
17899
|
let halfDetaHeight = 0;
|
|
17881
17900
|
let deltaAscent = 0;
|
|
17882
17901
|
let deltaDescent = 0;
|
|
@@ -17922,7 +17941,7 @@ class Paragraph {
|
|
|
17922
17941
|
this.ellipsisStr = '...';
|
|
17923
17942
|
}
|
|
17924
17943
|
updateWidth() {
|
|
17925
|
-
const { width } = measureTextCanvas(this.text, this.character);
|
|
17944
|
+
const { width } = measureTextCanvas(this.text, this.character, this.ascentDescentMode);
|
|
17926
17945
|
this.width = width;
|
|
17927
17946
|
if (this.direction === 'vertical') {
|
|
17928
17947
|
this.widthOrigin = this.width;
|
|
@@ -17958,17 +17977,41 @@ class Paragraph {
|
|
|
17958
17977
|
text = text.slice(0, index);
|
|
17959
17978
|
text += this.ellipsisStr;
|
|
17960
17979
|
if (textAlign === 'right' || textAlign === 'end') {
|
|
17961
|
-
const { width } = measureTextCanvas(this.text.slice(index), this.character);
|
|
17980
|
+
const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
|
|
17962
17981
|
if (direction === 'vertical') ;
|
|
17963
17982
|
else {
|
|
17964
17983
|
left -= this.ellipsisWidth - width;
|
|
17965
17984
|
}
|
|
17966
17985
|
}
|
|
17967
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
|
+
}
|
|
17968
18009
|
const right = left + (this.widthOrigin || this.width);
|
|
17969
18010
|
const bottom = top + lineHeight;
|
|
17970
18011
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
17971
|
-
|
|
18012
|
+
ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);
|
|
18013
|
+
ctx.fillStyle = fillStyle;
|
|
18014
|
+
ctx.globalAlpha = globalAlpha;
|
|
17972
18015
|
}
|
|
17973
18016
|
draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
|
|
17974
18017
|
let baseline = top + ascent;
|
|
@@ -17995,7 +18038,7 @@ class Paragraph {
|
|
|
17995
18038
|
text = text.slice(0, index);
|
|
17996
18039
|
text += this.ellipsisStr;
|
|
17997
18040
|
if (textAlign === 'right' || textAlign === 'end') {
|
|
17998
|
-
const { width } = measureTextCanvas(this.text.slice(index), this.character);
|
|
18041
|
+
const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
|
|
17999
18042
|
if (direction === 'vertical') ;
|
|
18000
18043
|
else {
|
|
18001
18044
|
left -= this.ellipsisWidth - width;
|
|
@@ -18032,14 +18075,14 @@ class Paragraph {
|
|
|
18032
18075
|
const right = left + (this.widthOrigin || this.width);
|
|
18033
18076
|
const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18034
18077
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18035
|
-
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);
|
|
18036
18079
|
}
|
|
18037
18080
|
if (this.character.lineThrough) {
|
|
18038
18081
|
const top = 1 + baseline - this.ascent / 2;
|
|
18039
18082
|
const right = left + (this.widthOrigin || this.width);
|
|
18040
18083
|
const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18041
18084
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18042
|
-
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);
|
|
18043
18086
|
}
|
|
18044
18087
|
}
|
|
18045
18088
|
else if (this.character.textDecoration === 'underline') {
|
|
@@ -18047,14 +18090,14 @@ class Paragraph {
|
|
|
18047
18090
|
const right = left + (this.widthOrigin || this.width);
|
|
18048
18091
|
const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18049
18092
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18050
|
-
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);
|
|
18051
18094
|
}
|
|
18052
18095
|
else if (this.character.textDecoration === 'line-through') {
|
|
18053
18096
|
const top = 1 + baseline - this.ascent / 2;
|
|
18054
18097
|
const right = left + (this.widthOrigin || this.width);
|
|
18055
18098
|
const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
|
|
18056
18099
|
const lrtb = getFixedLRTB(left, right, top, bottom);
|
|
18057
|
-
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);
|
|
18058
18101
|
}
|
|
18059
18102
|
}
|
|
18060
18103
|
if (direction === 'vertical') {
|
|
@@ -18074,7 +18117,7 @@ class Paragraph {
|
|
|
18074
18117
|
const index = getStrByWithCanvas(text, width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
|
|
18075
18118
|
text = text.slice(0, index);
|
|
18076
18119
|
text += this.ellipsisStr;
|
|
18077
|
-
const { width: measureWidth } = measureTextCanvas(this.text.slice(index), this.character);
|
|
18120
|
+
const { width: measureWidth } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
|
|
18078
18121
|
return width + this.ellipsisWidth - measureWidth;
|
|
18079
18122
|
}
|
|
18080
18123
|
return width;
|
|
@@ -18083,8 +18126,8 @@ class Paragraph {
|
|
|
18083
18126
|
function seperateParagraph(paragraph, index) {
|
|
18084
18127
|
const text1 = paragraph.text.slice(0, index);
|
|
18085
18128
|
const text2 = paragraph.text.slice(index);
|
|
18086
|
-
const p1 = new Paragraph(text1, paragraph.newLine, paragraph.character);
|
|
18087
|
-
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);
|
|
18088
18131
|
return [p1, p2];
|
|
18089
18132
|
}
|
|
18090
18133
|
|
|
@@ -18374,7 +18417,7 @@ class Line {
|
|
|
18374
18417
|
}
|
|
18375
18418
|
const ellipsis = drawEllipsis === true ? '...' : drawEllipsis || '';
|
|
18376
18419
|
paragraph.ellipsisStr = ellipsis;
|
|
18377
|
-
const { width } = measureTextCanvas(ellipsis, paragraph.character);
|
|
18420
|
+
const { width } = measureTextCanvas(ellipsis, paragraph.character, paragraph.ascentDescentMode);
|
|
18378
18421
|
const ellipsisWidth = width || 0;
|
|
18379
18422
|
if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) {
|
|
18380
18423
|
lastLine && (paragraph.ellipsis = 'add');
|
|
@@ -18393,35 +18436,11 @@ class Line {
|
|
|
18393
18436
|
}
|
|
18394
18437
|
}
|
|
18395
18438
|
}
|
|
18396
|
-
let fillStyle = '';
|
|
18397
|
-
let globalAlpha = -1;
|
|
18398
|
-
let currBgList = [];
|
|
18399
|
-
const bgList = [currBgList];
|
|
18400
18439
|
this.paragraphs.forEach((paragraph, index) => {
|
|
18401
18440
|
if (paragraph instanceof RichTextIcon) {
|
|
18402
18441
|
return;
|
|
18403
18442
|
}
|
|
18404
|
-
|
|
18405
|
-
if (!data) {
|
|
18406
|
-
return;
|
|
18407
|
-
}
|
|
18408
|
-
if (!(fillStyle === data.fillStyle && globalAlpha === data.globalAlpha)) {
|
|
18409
|
-
currBgList = [];
|
|
18410
|
-
bgList.push(currBgList);
|
|
18411
|
-
fillStyle = data.fillStyle;
|
|
18412
|
-
globalAlpha = data.globalAlpha;
|
|
18413
|
-
}
|
|
18414
|
-
currBgList.push(data);
|
|
18415
|
-
});
|
|
18416
|
-
bgList.forEach(bg => {
|
|
18417
|
-
if (bg.length === 0) {
|
|
18418
|
-
return;
|
|
18419
|
-
}
|
|
18420
|
-
const data = bg[0];
|
|
18421
|
-
const end = bg[bg.length - 1];
|
|
18422
|
-
ctx.fillStyle = data.fillStyle;
|
|
18423
|
-
ctx.globalAlpha = data.globalAlpha;
|
|
18424
|
-
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);
|
|
18425
18444
|
});
|
|
18426
18445
|
this.paragraphs.forEach((paragraph, index) => {
|
|
18427
18446
|
if (paragraph instanceof RichTextIcon) {
|
|
@@ -18450,7 +18469,7 @@ class Line {
|
|
|
18450
18469
|
if (paragraph instanceof RichTextIcon) {
|
|
18451
18470
|
break;
|
|
18452
18471
|
}
|
|
18453
|
-
const { width } = measureTextCanvas(ellipsis, paragraph.character);
|
|
18472
|
+
const { width } = measureTextCanvas(ellipsis, paragraph.character, paragraph.ascentDescentMode);
|
|
18454
18473
|
const ellipsisWidth = width || 0;
|
|
18455
18474
|
if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) {
|
|
18456
18475
|
paragraph.ellipsis = 'add';
|
|
@@ -18611,6 +18630,13 @@ class Wrapper {
|
|
|
18611
18630
|
}
|
|
18612
18631
|
}
|
|
18613
18632
|
|
|
18633
|
+
let supportIntl = false;
|
|
18634
|
+
try {
|
|
18635
|
+
supportIntl = Intl && typeof Intl.Segmenter === 'function';
|
|
18636
|
+
}
|
|
18637
|
+
catch (e) {
|
|
18638
|
+
supportIntl = false;
|
|
18639
|
+
}
|
|
18614
18640
|
const RICHTEXT_UPDATE_TAG_KEY = [
|
|
18615
18641
|
'width',
|
|
18616
18642
|
'height',
|
|
@@ -18770,15 +18796,14 @@ class RichText extends Graphic {
|
|
|
18770
18796
|
return tc.every(item => item.isComposing ||
|
|
18771
18797
|
!(item.text && isString(item.text) && RichText.splitText(item.text).length > 1));
|
|
18772
18798
|
}
|
|
18773
|
-
static splitEmoji(text) {
|
|
18774
|
-
return [...new Intl.Segmenter().segment(text)].map(x => x.segment);
|
|
18775
|
-
}
|
|
18776
18799
|
static splitText(text) {
|
|
18777
|
-
|
|
18778
|
-
const
|
|
18779
|
-
|
|
18780
|
-
|
|
18781
|
-
|
|
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;
|
|
18782
18807
|
}
|
|
18783
18808
|
return Array.from(text);
|
|
18784
18809
|
}
|
|
@@ -18799,8 +18824,8 @@ class RichText extends Graphic {
|
|
|
18799
18824
|
return tc;
|
|
18800
18825
|
}
|
|
18801
18826
|
updateAABBBounds(attribute, richtextTheme, aabbBounds) {
|
|
18802
|
-
var _a, _b;
|
|
18803
|
-
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;
|
|
18804
18829
|
if (width > 0 && height > 0) {
|
|
18805
18830
|
aabbBounds.set(0, 0, width, height);
|
|
18806
18831
|
}
|
|
@@ -18813,12 +18838,12 @@ class RichText extends Graphic {
|
|
|
18813
18838
|
contentWidth = typeof maxWidth === 'number' && contentWidth > maxWidth ? maxWidth : contentWidth || 0;
|
|
18814
18839
|
aabbBounds.set(0, 0, contentWidth, contentHeight);
|
|
18815
18840
|
}
|
|
18816
|
-
if (editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !((
|
|
18817
|
-
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);
|
|
18818
18843
|
aabbBounds.x2 = aabbBounds.x1 + 2;
|
|
18819
18844
|
}
|
|
18820
18845
|
let deltaY = 0;
|
|
18821
|
-
switch (
|
|
18846
|
+
switch (verticalDirection) {
|
|
18822
18847
|
case 'top':
|
|
18823
18848
|
deltaY = 0;
|
|
18824
18849
|
break;
|
|
@@ -18896,7 +18921,7 @@ class RichText extends Graphic {
|
|
|
18896
18921
|
}
|
|
18897
18922
|
doUpdateFrameCache(tc) {
|
|
18898
18923
|
var _a;
|
|
18899
|
-
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;
|
|
18900
18925
|
let { textConfig: _tc = [] } = this.attribute;
|
|
18901
18926
|
if (editable && _tc.length > 0 && !RichText.AllSingleCharacter(_tc)) {
|
|
18902
18927
|
_tc = RichText.TransformTextConfig2SingleCharacter(_tc);
|
|
@@ -18931,11 +18956,11 @@ class RichText extends Graphic {
|
|
|
18931
18956
|
if (richTextConfig.text && richTextConfig.text.includes('\n')) {
|
|
18932
18957
|
const textParts = richTextConfig.text.split('\n');
|
|
18933
18958
|
for (let j = 0; j < textParts.length; j++) {
|
|
18934
|
-
paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig));
|
|
18959
|
+
paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));
|
|
18935
18960
|
}
|
|
18936
18961
|
}
|
|
18937
18962
|
else if (richTextConfig.text) {
|
|
18938
|
-
paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig));
|
|
18963
|
+
paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig, ascentDescentMode));
|
|
18939
18964
|
}
|
|
18940
18965
|
}
|
|
18941
18966
|
}
|
|
@@ -20107,7 +20132,7 @@ class DefaultBaseBackgroundRenderContribution {
|
|
|
20107
20132
|
}
|
|
20108
20133
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
|
|
20109
20134
|
var _a;
|
|
20110
|
-
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;
|
|
20111
20136
|
if (!background) {
|
|
20112
20137
|
return;
|
|
20113
20138
|
}
|
|
@@ -20130,6 +20155,7 @@ class DefaultBaseBackgroundRenderContribution {
|
|
|
20130
20155
|
this.doDrawImage(context, res.data, b, {
|
|
20131
20156
|
backgroundMode,
|
|
20132
20157
|
backgroundFit,
|
|
20158
|
+
backgroundKeepAspectRatio,
|
|
20133
20159
|
backgroundScale,
|
|
20134
20160
|
backgroundOffsetX,
|
|
20135
20161
|
backgroundOffsetY
|
|
@@ -20149,14 +20175,20 @@ class DefaultBaseBackgroundRenderContribution {
|
|
|
20149
20175
|
}
|
|
20150
20176
|
}
|
|
20151
20177
|
doDrawImage(context, data, b, params) {
|
|
20152
|
-
const { backgroundMode, backgroundFit, backgroundScale = 1, backgroundOffsetX = 0, backgroundOffsetY = 0 } = params;
|
|
20178
|
+
const { backgroundMode, backgroundFit, backgroundKeepAspectRatio, backgroundScale = 1, backgroundOffsetX = 0, backgroundOffsetY = 0 } = params;
|
|
20153
20179
|
const targetW = b.width();
|
|
20154
20180
|
const targetH = b.height();
|
|
20155
20181
|
let w = targetW;
|
|
20156
20182
|
let h = targetH;
|
|
20157
20183
|
if (backgroundMode === 'no-repeat') {
|
|
20158
20184
|
if (backgroundFit) {
|
|
20159
|
-
|
|
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
|
+
}
|
|
20160
20192
|
}
|
|
20161
20193
|
else {
|
|
20162
20194
|
const resW = data.width * backgroundScale;
|
|
@@ -20525,7 +20557,7 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
|
|
|
20525
20557
|
this.time = BaseRenderContributionTime.beforeFillStroke;
|
|
20526
20558
|
}
|
|
20527
20559
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
20528
|
-
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;
|
|
20529
20561
|
if (!background) {
|
|
20530
20562
|
return;
|
|
20531
20563
|
}
|
|
@@ -20540,6 +20572,7 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
|
|
|
20540
20572
|
this.doDrawImage(context, res.data, b, {
|
|
20541
20573
|
backgroundMode,
|
|
20542
20574
|
backgroundFit,
|
|
20575
|
+
backgroundKeepAspectRatio,
|
|
20543
20576
|
backgroundScale,
|
|
20544
20577
|
backgroundOffsetX,
|
|
20545
20578
|
backgroundOffsetY
|
|
@@ -20838,8 +20871,8 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
|
|
|
20838
20871
|
this.useStyle = true;
|
|
20839
20872
|
this.order = 0;
|
|
20840
20873
|
}
|
|
20841
|
-
drawShape(
|
|
20842
|
-
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);
|
|
20843
20876
|
}
|
|
20844
20877
|
}
|
|
20845
20878
|
const defaultImageRenderContribution = new DefaultImageRenderContribution();
|
|
@@ -21437,7 +21470,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21437
21470
|
this._draw(line, lineAttribute, false, drawContext, params);
|
|
21438
21471
|
}
|
|
21439
21472
|
drawSegmentItem(context, cache, fill, stroke, fillOpacity, strokeOpacity, attribute, defaultAttribute, clipRange, clipRangeByDimension, offsetX, offsetY, line, fillCb, strokeCb) {
|
|
21440
|
-
var _a
|
|
21473
|
+
var _a;
|
|
21441
21474
|
if (!cache) {
|
|
21442
21475
|
return;
|
|
21443
21476
|
}
|
|
@@ -21476,60 +21509,6 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21476
21509
|
context.stroke();
|
|
21477
21510
|
}
|
|
21478
21511
|
}
|
|
21479
|
-
let { connectedType, connectedX, connectedY, connectedStyle } = attribute;
|
|
21480
|
-
if (isArray(defaultAttribute)) {
|
|
21481
|
-
connectedType = (_b = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute[0].connectedType) !== null && _b !== void 0 ? _b : defaultAttribute[1].connectedType;
|
|
21482
|
-
connectedX = (_c = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute[0].connectedX) !== null && _c !== void 0 ? _c : defaultAttribute[1].connectedX;
|
|
21483
|
-
connectedY = (_d = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute[0].connectedY) !== null && _d !== void 0 ? _d : defaultAttribute[1].connectedY;
|
|
21484
|
-
connectedStyle = (_e = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute[0].connectedStyle) !== null && _e !== void 0 ? _e : defaultAttribute[1].connectedStyle;
|
|
21485
|
-
}
|
|
21486
|
-
else {
|
|
21487
|
-
connectedType = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute.connectedType;
|
|
21488
|
-
connectedX = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute.connectedX;
|
|
21489
|
-
connectedY = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute.connectedY;
|
|
21490
|
-
connectedStyle = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute.connectedStyle;
|
|
21491
|
-
}
|
|
21492
|
-
if (connectedType !== 'connect' && connectedType !== 'zero') {
|
|
21493
|
-
connectedType = 'none';
|
|
21494
|
-
}
|
|
21495
|
-
if (connectedType !== 'none') {
|
|
21496
|
-
context.beginPath();
|
|
21497
|
-
drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {
|
|
21498
|
-
offsetX,
|
|
21499
|
-
offsetY,
|
|
21500
|
-
offsetZ: z,
|
|
21501
|
-
drawConnect: true,
|
|
21502
|
-
mode: connectedType,
|
|
21503
|
-
zeroX: connectedX,
|
|
21504
|
-
zeroY: connectedY
|
|
21505
|
-
});
|
|
21506
|
-
const da = [];
|
|
21507
|
-
if (isArray(defaultAttribute)) {
|
|
21508
|
-
defaultAttribute.forEach(i => da.push(i));
|
|
21509
|
-
}
|
|
21510
|
-
else {
|
|
21511
|
-
da.push(defaultAttribute);
|
|
21512
|
-
}
|
|
21513
|
-
da.push(attribute);
|
|
21514
|
-
if (fill !== false) {
|
|
21515
|
-
if (fillCb) {
|
|
21516
|
-
fillCb(context, attribute, defaultAttribute);
|
|
21517
|
-
}
|
|
21518
|
-
else if (fillOpacity) {
|
|
21519
|
-
context.setCommonStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);
|
|
21520
|
-
context.fill();
|
|
21521
|
-
}
|
|
21522
|
-
}
|
|
21523
|
-
if (stroke !== false) {
|
|
21524
|
-
if (strokeCb) {
|
|
21525
|
-
strokeCb(context, attribute, defaultAttribute);
|
|
21526
|
-
}
|
|
21527
|
-
else if (strokeOpacity) {
|
|
21528
|
-
context.setStrokeStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);
|
|
21529
|
-
context.stroke();
|
|
21530
|
-
}
|
|
21531
|
-
}
|
|
21532
|
-
}
|
|
21533
21512
|
return !!ret;
|
|
21534
21513
|
}
|
|
21535
21514
|
drawLinearLineHighPerformance(line, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, lineAttribute, drawContext, params, fillCb, strokeCb) {
|
|
@@ -21566,7 +21545,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21566
21545
|
}
|
|
21567
21546
|
drawShape(line, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
21568
21547
|
const lineAttribute = getTheme(line, params === null || params === void 0 ? void 0 : params.theme).line;
|
|
21569
|
-
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;
|
|
21570
21549
|
const data = this.valid(line, lineAttribute, fillCb, strokeCb);
|
|
21571
21550
|
if (!data) {
|
|
21572
21551
|
return;
|
|
@@ -21579,6 +21558,12 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21579
21558
|
if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
|
|
21580
21559
|
return this.drawLinearLineHighPerformance(line, context, !!fill, !!stroke, fillOpacity, strokeOpacity, x, y, lineAttribute, drawContext, params, fillCb, strokeCb);
|
|
21581
21560
|
}
|
|
21561
|
+
function parsePoint(points, connectedType) {
|
|
21562
|
+
if (connectedType === 'none') {
|
|
21563
|
+
return points;
|
|
21564
|
+
}
|
|
21565
|
+
return points.filter(p => p.defined !== false);
|
|
21566
|
+
}
|
|
21582
21567
|
if (line.shouldUpdateShape()) {
|
|
21583
21568
|
const { points, segments } = line.attribute;
|
|
21584
21569
|
const _points = points;
|
|
@@ -21610,7 +21595,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21610
21595
|
startPoint.y = lastSeg.endY;
|
|
21611
21596
|
startPoint.defined = lastSeg.curves[lastSeg.curves.length - 1].defined;
|
|
21612
21597
|
}
|
|
21613
|
-
const data = calcLineCache(seg.points, curveType, {
|
|
21598
|
+
const data = calcLineCache(parsePoint(seg.points, connectedType), curveType, {
|
|
21614
21599
|
startPoint,
|
|
21615
21600
|
curveTension
|
|
21616
21601
|
});
|
|
@@ -21636,7 +21621,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
|
|
|
21636
21621
|
}
|
|
21637
21622
|
}
|
|
21638
21623
|
else if (points && points.length) {
|
|
21639
|
-
line.cache = calcLineCache(_points, curveType, { curveTension });
|
|
21624
|
+
line.cache = calcLineCache(parsePoint(_points, connectedType), curveType, { curveTension });
|
|
21640
21625
|
}
|
|
21641
21626
|
else {
|
|
21642
21627
|
line.cache = null;
|
|
@@ -21688,10 +21673,6 @@ DefaultCanvasLineRender = __decorate([
|
|
|
21688
21673
|
|
|
21689
21674
|
function drawAreaSegments(path, segPath, percent, params) {
|
|
21690
21675
|
var _a;
|
|
21691
|
-
const { drawConnect = false, mode = 'none' } = params || {};
|
|
21692
|
-
if (drawConnect && mode === 'none') {
|
|
21693
|
-
return;
|
|
21694
|
-
}
|
|
21695
21676
|
const { top, bottom } = segPath;
|
|
21696
21677
|
if (top.curves.length !== bottom.curves.length) {
|
|
21697
21678
|
return;
|
|
@@ -21700,90 +21681,28 @@ function drawAreaSegments(path, segPath, percent, params) {
|
|
|
21700
21681
|
const topList = [];
|
|
21701
21682
|
const bottomList = [];
|
|
21702
21683
|
let lastDefined = true;
|
|
21703
|
-
|
|
21704
|
-
|
|
21705
|
-
|
|
21706
|
-
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
let currentTopCurve = curve;
|
|
21711
|
-
let currentBottomCurve = bototmCurve;
|
|
21712
|
-
if (curve.originP1 === curve.originP2) {
|
|
21713
|
-
lastCurve = curve;
|
|
21714
|
-
lastBottomCurve = bototmCurve;
|
|
21715
|
-
return;
|
|
21716
|
-
}
|
|
21717
|
-
if (lastCurve && lastCurve.originP1 === lastCurve.originP2) {
|
|
21718
|
-
currentTopCurve = lastCurve;
|
|
21719
|
-
currentBottomCurve = lastBottomCurve;
|
|
21720
|
-
}
|
|
21721
|
-
if (curve.defined) {
|
|
21722
|
-
if (!defined0) {
|
|
21723
|
-
topList.push(currentTopCurve);
|
|
21724
|
-
bottomList.push(currentBottomCurve);
|
|
21725
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21726
|
-
topList.length = 0;
|
|
21727
|
-
bottomList.length = 0;
|
|
21728
|
-
defined0 = !defined0;
|
|
21729
|
-
}
|
|
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;
|
|
21730
21691
|
}
|
|
21731
21692
|
else {
|
|
21732
|
-
|
|
21733
|
-
|
|
21734
|
-
let validBottomCurve;
|
|
21735
|
-
if (originP1 && originP1.defined !== false) {
|
|
21736
|
-
validTopCurve = currentTopCurve;
|
|
21737
|
-
validBottomCurve = currentBottomCurve;
|
|
21738
|
-
}
|
|
21739
|
-
else if (originP1 && originP2.defined !== false) {
|
|
21740
|
-
validTopCurve = curve;
|
|
21741
|
-
validBottomCurve = bototmCurve;
|
|
21742
|
-
}
|
|
21743
|
-
if (defined0) {
|
|
21744
|
-
defined0 = !defined0;
|
|
21745
|
-
topList.push(validTopCurve || curve);
|
|
21746
|
-
bottomList.push(validBottomCurve || bototmCurve);
|
|
21747
|
-
}
|
|
21748
|
-
else {
|
|
21749
|
-
if (validTopCurve) {
|
|
21750
|
-
defined0 = !defined0;
|
|
21751
|
-
topList.push(validTopCurve || curve);
|
|
21752
|
-
bottomList.push(validBottomCurve || bototmCurve);
|
|
21753
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21754
|
-
topList.length = 0;
|
|
21755
|
-
bottomList.length = 0;
|
|
21756
|
-
}
|
|
21757
|
-
}
|
|
21693
|
+
topList.push(topCurve);
|
|
21694
|
+
bottomList.push(bottom.curves[n - i - 1]);
|
|
21758
21695
|
}
|
|
21759
|
-
|
|
21760
|
-
}
|
|
21761
|
-
|
|
21762
|
-
|
|
21763
|
-
|
|
21764
|
-
|
|
21765
|
-
const topCurve = top.curves[i];
|
|
21766
|
-
if (lastDefined !== topCurve.defined) {
|
|
21767
|
-
if (lastDefined) {
|
|
21768
|
-
drawAreaBlock(path, topList, bottomList, params);
|
|
21769
|
-
topList.length = 0;
|
|
21770
|
-
bottomList.length = 0;
|
|
21771
|
-
}
|
|
21772
|
-
else {
|
|
21773
|
-
topList.push(topCurve);
|
|
21774
|
-
bottomList.push(bottom.curves[n - i - 1]);
|
|
21775
|
-
}
|
|
21776
|
-
lastDefined = !lastDefined;
|
|
21777
|
-
}
|
|
21778
|
-
else {
|
|
21779
|
-
if (lastDefined) {
|
|
21780
|
-
topList.push(topCurve);
|
|
21781
|
-
bottomList.push(bottom.curves[n - i - 1]);
|
|
21782
|
-
}
|
|
21696
|
+
lastDefined = !lastDefined;
|
|
21697
|
+
}
|
|
21698
|
+
else {
|
|
21699
|
+
if (lastDefined) {
|
|
21700
|
+
topList.push(topCurve);
|
|
21701
|
+
bottomList.push(bottom.curves[n - i - 1]);
|
|
21783
21702
|
}
|
|
21784
21703
|
}
|
|
21785
|
-
drawAreaBlock(path, topList, bottomList, params);
|
|
21786
21704
|
}
|
|
21705
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
21787
21706
|
return;
|
|
21788
21707
|
}
|
|
21789
21708
|
if (percent <= 0) {
|
|
@@ -21807,9 +21726,6 @@ function drawAreaSegments(path, segPath, percent, params) {
|
|
|
21807
21726
|
let lastDefined = true;
|
|
21808
21727
|
const topList = [];
|
|
21809
21728
|
const bottomList = [];
|
|
21810
|
-
let defined0 = true;
|
|
21811
|
-
let lastTopCurve;
|
|
21812
|
-
let lastBottomCurve;
|
|
21813
21729
|
for (let i = 0, n = top.curves.length; i < n; i++) {
|
|
21814
21730
|
const topCurve = top.curves[i];
|
|
21815
21731
|
const curCurveLength = topCurve.getLength(direction);
|
|
@@ -21818,127 +21734,50 @@ function drawAreaSegments(path, segPath, percent, params) {
|
|
|
21818
21734
|
break;
|
|
21819
21735
|
}
|
|
21820
21736
|
drawedLengthUntilLast += curCurveLength;
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
|
|
21828
|
-
continue;
|
|
21829
|
-
}
|
|
21830
|
-
if (lastTopCurve && lastTopCurve.originP1 === lastTopCurve.originP2) {
|
|
21831
|
-
currentTopCurve = lastTopCurve;
|
|
21832
|
-
currentBottomCurve = lastBottomCurve;
|
|
21833
|
-
}
|
|
21834
|
-
if (topCurve.defined) {
|
|
21835
|
-
if (!defined0) {
|
|
21836
|
-
topList.push(currentTopCurve);
|
|
21837
|
-
bottomList.push(currentBottomCurve);
|
|
21838
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21839
|
-
topList.length = 0;
|
|
21840
|
-
bottomList.length = 0;
|
|
21841
|
-
defined0 = !defined0;
|
|
21842
|
-
}
|
|
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;
|
|
21843
21744
|
}
|
|
21844
21745
|
else {
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
let validBottomCurve;
|
|
21848
|
-
if (originP1 && originP1.defined !== false) {
|
|
21849
|
-
validTopCurve = currentTopCurve;
|
|
21850
|
-
validBottomCurve = currentBottomCurve;
|
|
21851
|
-
}
|
|
21852
|
-
else if (originP1 && originP2.defined !== false) {
|
|
21853
|
-
validTopCurve = topCurve;
|
|
21854
|
-
validBottomCurve = bototmCurve;
|
|
21855
|
-
}
|
|
21856
|
-
if (defined0) {
|
|
21857
|
-
defined0 = !defined0;
|
|
21858
|
-
topList.push(validTopCurve || topCurve);
|
|
21859
|
-
bottomList.push(validBottomCurve || bototmCurve);
|
|
21860
|
-
}
|
|
21861
|
-
else {
|
|
21862
|
-
if (validTopCurve) {
|
|
21863
|
-
defined0 = !defined0;
|
|
21864
|
-
topList.push(validTopCurve || topCurve);
|
|
21865
|
-
bottomList.push(validBottomCurve || bototmCurve);
|
|
21866
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21867
|
-
topList.length = 0;
|
|
21868
|
-
bottomList.length = 0;
|
|
21869
|
-
}
|
|
21870
|
-
}
|
|
21746
|
+
tc = topCurve;
|
|
21747
|
+
bc = bottom.curves[n - i - 1];
|
|
21871
21748
|
}
|
|
21872
|
-
|
|
21749
|
+
lastDefined = !lastDefined;
|
|
21873
21750
|
}
|
|
21874
21751
|
else {
|
|
21875
|
-
|
|
21876
|
-
|
|
21877
|
-
|
|
21878
|
-
|
|
21879
|
-
|
|
21880
|
-
|
|
21881
|
-
|
|
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];
|
|
21882
21761
|
}
|
|
21883
21762
|
else {
|
|
21884
|
-
tc =
|
|
21885
|
-
bc = bottom.curves[n - i - 1];
|
|
21763
|
+
tc = divideLinear(tc, percent)[0];
|
|
21886
21764
|
}
|
|
21887
|
-
|
|
21888
|
-
|
|
21889
|
-
else {
|
|
21890
|
-
if (lastDefined) {
|
|
21891
|
-
tc = topCurve;
|
|
21892
|
-
bc = bottom.curves[n - i - 1];
|
|
21765
|
+
if (bc.p2 && bc.p3) {
|
|
21766
|
+
bc = divideCubic(bc, 1 - percent)[1];
|
|
21893
21767
|
}
|
|
21894
|
-
|
|
21895
|
-
|
|
21896
|
-
if (percent < 1) {
|
|
21897
|
-
if (tc.p2 && tc.p3) {
|
|
21898
|
-
tc = divideCubic(tc, percent)[0];
|
|
21899
|
-
}
|
|
21900
|
-
else {
|
|
21901
|
-
tc = divideLinear(tc, percent)[0];
|
|
21902
|
-
}
|
|
21903
|
-
if (bc.p2 && bc.p3) {
|
|
21904
|
-
bc = divideCubic(bc, 1 - percent)[1];
|
|
21905
|
-
}
|
|
21906
|
-
else {
|
|
21907
|
-
bc = divideLinear(bc, 1 - percent)[1];
|
|
21908
|
-
}
|
|
21768
|
+
else {
|
|
21769
|
+
bc = divideLinear(bc, 1 - percent)[1];
|
|
21909
21770
|
}
|
|
21910
|
-
tc.defined = lastDefined;
|
|
21911
|
-
bc.defined = lastDefined;
|
|
21912
|
-
topList.push(tc);
|
|
21913
|
-
bottomList.push(bc);
|
|
21914
21771
|
}
|
|
21915
|
-
tc =
|
|
21916
|
-
bc =
|
|
21772
|
+
tc.defined = lastDefined;
|
|
21773
|
+
bc.defined = lastDefined;
|
|
21774
|
+
topList.push(tc);
|
|
21775
|
+
bottomList.push(bc);
|
|
21917
21776
|
}
|
|
21777
|
+
tc = null;
|
|
21778
|
+
bc = null;
|
|
21918
21779
|
}
|
|
21919
|
-
|
|
21920
|
-
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
21921
|
-
}
|
|
21922
|
-
else {
|
|
21923
|
-
drawAreaBlock(path, topList, bottomList, params);
|
|
21924
|
-
}
|
|
21925
|
-
}
|
|
21926
|
-
function drawAreaConnectBlock(path, topList, bottomList, params) {
|
|
21927
|
-
if (topList.length < 2) {
|
|
21928
|
-
return;
|
|
21929
|
-
}
|
|
21930
|
-
const { offsetX = 0, offsetY = 0, offsetZ = 0, mode } = params || {};
|
|
21931
|
-
let curve = topList[0];
|
|
21932
|
-
path.moveTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
21933
|
-
curve = topList[topList.length - 1];
|
|
21934
|
-
let end = curve.p3 || curve.p1;
|
|
21935
|
-
path.lineTo(end.x + offsetX, end.y + offsetY, offsetZ);
|
|
21936
|
-
curve = bottomList[bottomList.length - 1];
|
|
21937
|
-
path.lineTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
21938
|
-
curve = bottomList[0];
|
|
21939
|
-
end = curve.p3 || curve.p1;
|
|
21940
|
-
path.lineTo(end.x + offsetX, end.y + offsetY, offsetZ);
|
|
21941
|
-
path.closePath();
|
|
21780
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
21942
21781
|
}
|
|
21943
21782
|
function drawAreaBlock(path, topList, bottomList, params) {
|
|
21944
21783
|
const { offsetX = 0, offsetY = 0, offsetZ = 0 } = params || {};
|
|
@@ -22052,7 +21891,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22052
21891
|
drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
22053
21892
|
var _a, _b, _c, _d, _e, _f;
|
|
22054
21893
|
const areaAttribute = getTheme(area, params === null || params === void 0 ? void 0 : params.theme).area;
|
|
22055
|
-
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;
|
|
22056
21895
|
const data = this.valid(area, areaAttribute, fillCb, strokeCb);
|
|
22057
21896
|
if (!data) {
|
|
22058
21897
|
return;
|
|
@@ -22064,6 +21903,12 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22064
21903
|
if (closePath && curveType === 'linear') {
|
|
22065
21904
|
curveType = 'linearClosed';
|
|
22066
21905
|
}
|
|
21906
|
+
function parsePoint(points, connectedType) {
|
|
21907
|
+
if (connectedType !== 'connect') {
|
|
21908
|
+
return points;
|
|
21909
|
+
}
|
|
21910
|
+
return points.filter(p => p.defined !== false);
|
|
21911
|
+
}
|
|
22067
21912
|
if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
|
|
22068
21913
|
return this.drawLinearAreaHighPerformance(area, context, !!fill, doStroke, fillOpacity, strokeOpacity, x, y, areaAttribute, drawContext, params, fillCb, strokeCb);
|
|
22069
21914
|
}
|
|
@@ -22086,7 +21931,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22086
21931
|
startPoint.x = lastTopSeg.endX;
|
|
22087
21932
|
startPoint.y = lastTopSeg.endY;
|
|
22088
21933
|
}
|
|
22089
|
-
const data = calcLineCache(seg.points, curveType, {
|
|
21934
|
+
const data = calcLineCache(parsePoint(seg.points, connectedType), curveType, {
|
|
22090
21935
|
startPoint,
|
|
22091
21936
|
curveTension
|
|
22092
21937
|
});
|
|
@@ -22115,7 +21960,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22115
21960
|
});
|
|
22116
21961
|
}
|
|
22117
21962
|
if (bottomPoints.length > 1) {
|
|
22118
|
-
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 });
|
|
22119
21964
|
bottomCaches.unshift(lastBottomSeg);
|
|
22120
21965
|
}
|
|
22121
21966
|
}
|
|
@@ -22125,12 +21970,12 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22125
21970
|
}));
|
|
22126
21971
|
}
|
|
22127
21972
|
else if (points && points.length) {
|
|
22128
|
-
const topPoints = points;
|
|
21973
|
+
const topPoints = parsePoint(points, connectedType);
|
|
22129
21974
|
const bottomPoints = [];
|
|
22130
|
-
for (let i =
|
|
21975
|
+
for (let i = topPoints.length - 1; i >= 0; i--) {
|
|
22131
21976
|
bottomPoints.push({
|
|
22132
|
-
x: (_e =
|
|
22133
|
-
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
|
|
22134
21979
|
});
|
|
22135
21980
|
}
|
|
22136
21981
|
const topCache = calcLineCache(topPoints, curveType, { curveTension });
|
|
@@ -22185,17 +22030,9 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22185
22030
|
this._draw(area, areaAttribute, false, drawContext, params);
|
|
22186
22031
|
}
|
|
22187
22032
|
drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
|
|
22188
|
-
|
|
22189
|
-
ret =
|
|
22190
|
-
ret ||
|
|
22191
|
-
this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, false, fillCb, strokeCb);
|
|
22192
|
-
ret =
|
|
22193
|
-
ret ||
|
|
22194
|
-
this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, true, fillCb, strokeCb);
|
|
22195
|
-
return ret;
|
|
22033
|
+
return this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb);
|
|
22196
22034
|
}
|
|
22197
|
-
_drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext,
|
|
22198
|
-
var _a, _b, _c, _d;
|
|
22035
|
+
_drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
|
|
22199
22036
|
if (!(cache &&
|
|
22200
22037
|
cache.top &&
|
|
22201
22038
|
cache.bottom &&
|
|
@@ -22205,35 +22042,6 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22205
22042
|
cache.bottom.curves.length)) {
|
|
22206
22043
|
return;
|
|
22207
22044
|
}
|
|
22208
|
-
let { connectedType, connectedX, connectedY, connectedStyle } = attribute;
|
|
22209
|
-
const da = [];
|
|
22210
|
-
if (connect) {
|
|
22211
|
-
if (isArray(defaultAttribute)) {
|
|
22212
|
-
connectedType = (_a = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute[0].connectedType) !== null && _a !== void 0 ? _a : defaultAttribute[1].connectedType;
|
|
22213
|
-
connectedX = (_b = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute[0].connectedX) !== null && _b !== void 0 ? _b : defaultAttribute[1].connectedX;
|
|
22214
|
-
connectedY = (_c = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute[0].connectedY) !== null && _c !== void 0 ? _c : defaultAttribute[1].connectedY;
|
|
22215
|
-
connectedStyle = (_d = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute[0].connectedStyle) !== null && _d !== void 0 ? _d : defaultAttribute[1].connectedStyle;
|
|
22216
|
-
}
|
|
22217
|
-
else {
|
|
22218
|
-
connectedType = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute.connectedType;
|
|
22219
|
-
connectedX = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute.connectedX;
|
|
22220
|
-
connectedY = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute.connectedY;
|
|
22221
|
-
connectedStyle = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute.connectedStyle;
|
|
22222
|
-
}
|
|
22223
|
-
if (connectedType !== 'connect' && connectedType !== 'zero') {
|
|
22224
|
-
connectedType = 'none';
|
|
22225
|
-
}
|
|
22226
|
-
if (isArray(defaultAttribute)) {
|
|
22227
|
-
defaultAttribute.forEach(i => da.push(i));
|
|
22228
|
-
}
|
|
22229
|
-
else {
|
|
22230
|
-
da.push(defaultAttribute);
|
|
22231
|
-
}
|
|
22232
|
-
da.push(attribute);
|
|
22233
|
-
}
|
|
22234
|
-
if (connect && connectedType === 'none') {
|
|
22235
|
-
return false;
|
|
22236
|
-
}
|
|
22237
22045
|
context.beginPath();
|
|
22238
22046
|
const ret = false;
|
|
22239
22047
|
const { points, segments } = area.attribute;
|
|
@@ -22268,11 +22076,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22268
22076
|
offsetX,
|
|
22269
22077
|
offsetY,
|
|
22270
22078
|
offsetZ,
|
|
22271
|
-
direction
|
|
22272
|
-
drawConnect: connect,
|
|
22273
|
-
mode: connectedType,
|
|
22274
|
-
zeroX: connectedX,
|
|
22275
|
-
zeroY: connectedY
|
|
22079
|
+
direction
|
|
22276
22080
|
});
|
|
22277
22081
|
this.beforeRenderStep(area, context, offsetX, offsetY, !!fillOpacity, false, fill, false, defaultAttribute, drawContext, fillCb, null, { attribute });
|
|
22278
22082
|
context.setShadowBlendStyle && context.setShadowBlendStyle(area, attribute, defaultAttribute);
|
|
@@ -22283,7 +22087,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22283
22087
|
fillCb(context, attribute, defaultAttribute);
|
|
22284
22088
|
}
|
|
22285
22089
|
else if (fillOpacity) {
|
|
22286
|
-
context.setCommonStyle(area,
|
|
22090
|
+
context.setCommonStyle(area, attribute, originX - offsetX, originY - offsetY, defaultAttribute);
|
|
22287
22091
|
context.fill();
|
|
22288
22092
|
}
|
|
22289
22093
|
}
|
|
@@ -22300,14 +22104,10 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
22300
22104
|
drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? 'x' : 'y', {
|
|
22301
22105
|
offsetX,
|
|
22302
22106
|
offsetY,
|
|
22303
|
-
offsetZ
|
|
22304
|
-
drawConnect: connect,
|
|
22305
|
-
mode: connectedType,
|
|
22306
|
-
zeroX: connectedX,
|
|
22307
|
-
zeroY: connectedY
|
|
22107
|
+
offsetZ
|
|
22308
22108
|
});
|
|
22309
22109
|
}
|
|
22310
|
-
context.setStrokeStyle(area,
|
|
22110
|
+
context.setStrokeStyle(area, attribute, originX - offsetX, originY - offsetY, defaultAttribute);
|
|
22311
22111
|
context.stroke();
|
|
22312
22112
|
}
|
|
22313
22113
|
}
|
|
@@ -22676,7 +22476,7 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
|
|
|
22676
22476
|
}
|
|
22677
22477
|
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
22678
22478
|
var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
22679
|
-
const { backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit } = graphic.attribute;
|
|
22479
|
+
const { backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit, backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio } = graphic.attribute;
|
|
22680
22480
|
let { background } = graphic.attribute;
|
|
22681
22481
|
if (!background) {
|
|
22682
22482
|
return;
|
|
@@ -22733,7 +22533,7 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
|
|
|
22733
22533
|
context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);
|
|
22734
22534
|
}
|
|
22735
22535
|
context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);
|
|
22736
|
-
this.doDrawImage(context, res.data, b, { backgroundMode, backgroundFit });
|
|
22536
|
+
this.doDrawImage(context, res.data, b, { backgroundMode, backgroundFit, backgroundKeepAspectRatio });
|
|
22737
22537
|
context.highPerformanceRestore();
|
|
22738
22538
|
context.setTransformForCurrent();
|
|
22739
22539
|
}
|
|
@@ -24331,6 +24131,9 @@ let DefaultDrawContribution = class DefaultDrawContribution {
|
|
|
24331
24131
|
this.backupDirtyBounds = new Bounds();
|
|
24332
24132
|
this.global = application.global;
|
|
24333
24133
|
this.layerService = application.layerService;
|
|
24134
|
+
if (!isArray(this.contributions)) {
|
|
24135
|
+
this.contributions = [this.contributions];
|
|
24136
|
+
}
|
|
24334
24137
|
this.init();
|
|
24335
24138
|
}
|
|
24336
24139
|
init() {
|
|
@@ -27146,12 +26949,12 @@ class EditModule {
|
|
|
27146
26949
|
this.composingConfigIdx = this.cursorIndex < 0 ? 0 : findConfigIndexByCursorIdx(textConfig, this.cursorIndex);
|
|
27147
26950
|
if (this.cursorIndex < 0) {
|
|
27148
26951
|
const config = textConfig[0];
|
|
27149
|
-
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: '' }));
|
|
27150
26953
|
}
|
|
27151
26954
|
else {
|
|
27152
26955
|
const configIdx = this.composingConfigIdx;
|
|
27153
26956
|
const lastConfig = textConfig[configIdx] || textConfig[configIdx - 1];
|
|
27154
|
-
textConfig.splice(configIdx, 0, Object.assign(Object.assign({}, lastConfig), { text: '' }));
|
|
26957
|
+
textConfig.splice(configIdx, 0, Object.assign(Object.assign({ fill: 'black' }, lastConfig), { text: '' }));
|
|
27155
26958
|
}
|
|
27156
26959
|
};
|
|
27157
26960
|
this.handleCompositionEnd = () => {
|
|
@@ -27275,13 +27078,14 @@ class EditModule {
|
|
|
27275
27078
|
application.global.addEventListener('keydown', this.handleKeyDown);
|
|
27276
27079
|
}
|
|
27277
27080
|
parseCompositionStr(configIdx) {
|
|
27081
|
+
var _a;
|
|
27278
27082
|
const { textConfig = [] } = this.currRt.attribute;
|
|
27279
|
-
const lastConfig = textConfig[configIdx];
|
|
27083
|
+
const lastConfig = (_a = textConfig[configIdx]) !== null && _a !== void 0 ? _a : {};
|
|
27280
27084
|
textConfig.splice(configIdx, 1);
|
|
27281
27085
|
const text = lastConfig.text;
|
|
27282
27086
|
const textList = text ? Array.from(text.toString()) : [];
|
|
27283
27087
|
for (let i = 0; i < textList.length; i++) {
|
|
27284
|
-
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] }));
|
|
27285
27089
|
}
|
|
27286
27090
|
this.currRt.setAttributes({ textConfig });
|
|
27287
27091
|
const nextConfigIdx = configIdx + textList.length;
|
|
@@ -27356,24 +27160,24 @@ class Selection {
|
|
|
27356
27160
|
}
|
|
27357
27161
|
return (_a = config[Math.min(idx, config.length - 1)][key]) !== null && _a !== void 0 ? _a : this.rt.attribute[key];
|
|
27358
27162
|
}
|
|
27359
|
-
getFormat(key) {
|
|
27360
|
-
return this.getAllFormat(key)[0];
|
|
27163
|
+
getFormat(key, supportOutAttr = false) {
|
|
27164
|
+
return this.getAllFormat(key, supportOutAttr)[0];
|
|
27361
27165
|
}
|
|
27362
|
-
getAllFormat(key,
|
|
27166
|
+
getAllFormat(key, supportOutAttr = false) {
|
|
27167
|
+
var _a, _b, _c, _d;
|
|
27363
27168
|
const valSet = new Set();
|
|
27364
27169
|
const minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx);
|
|
27365
27170
|
const maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
|
|
27366
27171
|
if (minCursorIdx === maxCursorIdx) {
|
|
27367
|
-
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)];
|
|
27368
27175
|
}
|
|
27369
27176
|
for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
|
|
27370
|
-
const val =
|
|
27371
|
-
|
|
27372
|
-
|
|
27373
|
-
|
|
27374
|
-
else {
|
|
27375
|
-
val !== undefined && valSet.add(val);
|
|
27376
|
-
}
|
|
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);
|
|
27180
|
+
val && valSet.add(val);
|
|
27377
27181
|
}
|
|
27378
27182
|
return Array.from(valSet.values());
|
|
27379
27183
|
}
|
|
@@ -27437,10 +27241,10 @@ class RichTextEditPlugin {
|
|
|
27437
27241
|
if (this.copyToClipboard(e)) {
|
|
27438
27242
|
return;
|
|
27439
27243
|
}
|
|
27440
|
-
if (this.
|
|
27244
|
+
if (this.fullSelectionKeyHandler(e)) {
|
|
27441
27245
|
return;
|
|
27442
27246
|
}
|
|
27443
|
-
if (this.
|
|
27247
|
+
if (this.directKeyHandler(e)) {
|
|
27444
27248
|
return;
|
|
27445
27249
|
}
|
|
27446
27250
|
};
|
|
@@ -27473,31 +27277,28 @@ class RichTextEditPlugin {
|
|
|
27473
27277
|
throw new Error('不会走到这里 handleFocusOut');
|
|
27474
27278
|
};
|
|
27475
27279
|
this.handleMove = (e) => {
|
|
27476
|
-
if (
|
|
27477
|
-
this.deFocus(true);
|
|
27478
|
-
}
|
|
27479
|
-
if (!this.isEditableRichtext(e)) {
|
|
27480
|
-
this.handleLeave();
|
|
27280
|
+
if (!this.isRichtext(e)) {
|
|
27481
27281
|
return;
|
|
27482
27282
|
}
|
|
27483
|
-
this.
|
|
27484
|
-
|
|
27283
|
+
this.currRt = e.target;
|
|
27284
|
+
this.handleEnter(e);
|
|
27285
|
+
e.target.once('pointerleave', this.handleLeave, { capture: true });
|
|
27485
27286
|
this.tryShowSelection(e, false);
|
|
27486
27287
|
};
|
|
27487
|
-
this.handleEnter = () => {
|
|
27288
|
+
this.handleEnter = (e) => {
|
|
27488
27289
|
this.editing = true;
|
|
27489
27290
|
this.pluginService.stage.setCursor('text');
|
|
27490
27291
|
};
|
|
27491
|
-
this.handleLeave = () => {
|
|
27292
|
+
this.handleLeave = (e) => {
|
|
27492
27293
|
this.editing = false;
|
|
27493
27294
|
this.pluginService.stage.setCursor('default');
|
|
27494
27295
|
};
|
|
27495
27296
|
this.handlePointerDown = (e) => {
|
|
27496
|
-
if (
|
|
27497
|
-
this.
|
|
27297
|
+
if (this.editing) {
|
|
27298
|
+
this.onFocus(e);
|
|
27498
27299
|
}
|
|
27499
27300
|
else {
|
|
27500
|
-
this.
|
|
27301
|
+
this.deFocus(true);
|
|
27501
27302
|
}
|
|
27502
27303
|
this.triggerRender();
|
|
27503
27304
|
this.pointerDown = true;
|
|
@@ -27575,11 +27376,11 @@ class RichTextEditPlugin {
|
|
|
27575
27376
|
activate(context) {
|
|
27576
27377
|
this.pluginService = context;
|
|
27577
27378
|
this.editModule = new EditModule();
|
|
27578
|
-
context.stage.on('pointermove', this.handleMove);
|
|
27579
|
-
context.stage.on('pointerdown', this.handlePointerDown);
|
|
27580
|
-
context.stage.on('pointerup', this.handlePointerUp);
|
|
27581
|
-
context.stage.on('pointerleave', this.handlePointerUp);
|
|
27582
|
-
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 });
|
|
27583
27384
|
application.global.addEventListener('keydown', this.handleKeyDown);
|
|
27584
27385
|
this.editModule.onInput(this.handleInput);
|
|
27585
27386
|
this.editModule.onChange(this.handleChange);
|
|
@@ -27623,32 +27424,32 @@ class RichTextEditPlugin {
|
|
|
27623
27424
|
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt);
|
|
27624
27425
|
this._tryShowSelection(pos, cache);
|
|
27625
27426
|
}
|
|
27626
|
-
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) {
|
|
27627
27444
|
if ((application.global.isMacOS() && e.metaKey && e.key === 'a') ||
|
|
27628
27445
|
(!application.global.isMacOS() && e.ctrlKey && e.key === 'a')) {
|
|
27629
|
-
|
|
27630
|
-
if (!currRt) {
|
|
27631
|
-
return;
|
|
27632
|
-
}
|
|
27633
|
-
const cache = currRt.getFrameCache();
|
|
27634
|
-
if (!cache) {
|
|
27635
|
-
return;
|
|
27636
|
-
}
|
|
27637
|
-
const { lines } = cache;
|
|
27638
|
-
if (lines.length === 0) {
|
|
27639
|
-
return;
|
|
27640
|
-
}
|
|
27641
|
-
if (!lines[0].paragraphs || lines[0].paragraphs.length === 0) {
|
|
27642
|
-
return;
|
|
27643
|
-
}
|
|
27644
|
-
const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
|
|
27645
|
-
this.selectionRange(-0.1, totalCursorCount + 0.1);
|
|
27446
|
+
this.fullSelection();
|
|
27646
27447
|
e.preventDefault();
|
|
27647
27448
|
return true;
|
|
27648
27449
|
}
|
|
27649
27450
|
return false;
|
|
27650
27451
|
}
|
|
27651
|
-
|
|
27452
|
+
directKeyHandler(e) {
|
|
27652
27453
|
if (!(e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'ArrowLeft' || e.key === 'ArrowRight')) {
|
|
27653
27454
|
return false;
|
|
27654
27455
|
}
|
|
@@ -27699,7 +27500,6 @@ class RichTextEditPlugin {
|
|
|
27699
27500
|
else if (this.curCursorIdx > totalCursorCount + 0.1) {
|
|
27700
27501
|
this.curCursorIdx = totalCursorCount + 0.1;
|
|
27701
27502
|
}
|
|
27702
|
-
this.selectionStartCursorIdx = this.curCursorIdx;
|
|
27703
27503
|
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
|
|
27704
27504
|
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt);
|
|
27705
27505
|
this.hideSelection();
|
|
@@ -27747,7 +27547,7 @@ class RichTextEditPlugin {
|
|
|
27747
27547
|
const placeholder = shadowRoot.getElementsByType('richtext')[0];
|
|
27748
27548
|
placeholder && shadowRoot.removeChild(placeholder);
|
|
27749
27549
|
}
|
|
27750
|
-
const { textConfig, editOptions } = this.currRt.attribute;
|
|
27550
|
+
const { textConfig, editOptions = {} } = this.currRt.attribute;
|
|
27751
27551
|
if (textConfig && textConfig.length) {
|
|
27752
27552
|
return;
|
|
27753
27553
|
}
|
|
@@ -27766,9 +27566,16 @@ class RichTextEditPlugin {
|
|
|
27766
27566
|
if (placeholderFontSize) {
|
|
27767
27567
|
textConfigItem.fontSize = placeholderFontSize;
|
|
27768
27568
|
}
|
|
27769
|
-
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] }));
|
|
27770
27570
|
shadow.add(this.shadowPlaceHolder);
|
|
27771
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
|
+
}
|
|
27772
27579
|
tryShowInputBounds() {
|
|
27773
27580
|
if (!(this.currRt && this.focusing)) {
|
|
27774
27581
|
return;
|
|
@@ -27778,20 +27585,15 @@ class RichTextEditPlugin {
|
|
|
27778
27585
|
if (!editOptions || !boundsStrokeWhenInput) {
|
|
27779
27586
|
return;
|
|
27780
27587
|
}
|
|
27781
|
-
const
|
|
27782
|
-
|
|
27783
|
-
|
|
27784
|
-
if (!attribute.textConfig.length && this.editLine) {
|
|
27785
|
-
const { points } = this.editLine.attribute;
|
|
27786
|
-
h = points[1].y - points[0].y;
|
|
27787
|
-
b = getRichTextBounds(Object.assign({}, this.shadowPlaceHolder.attribute));
|
|
27788
|
-
}
|
|
27588
|
+
const b = this.getRichTextAABBBounds(this.currRt);
|
|
27589
|
+
const height = b.height();
|
|
27590
|
+
const width = b.width();
|
|
27789
27591
|
this.shadowBounds = this.shadowBounds || createRect({});
|
|
27790
27592
|
this.shadowBounds.setAttributes({
|
|
27791
27593
|
x: 0,
|
|
27792
27594
|
y: 0,
|
|
27793
|
-
width
|
|
27794
|
-
height
|
|
27595
|
+
width,
|
|
27596
|
+
height,
|
|
27795
27597
|
fill: false,
|
|
27796
27598
|
stroke: boundsStrokeWhenInput,
|
|
27797
27599
|
lineWidth: 1,
|
|
@@ -27800,6 +27602,7 @@ class RichTextEditPlugin {
|
|
|
27800
27602
|
const shadow = this.getShadow(this.currRt);
|
|
27801
27603
|
shadow.add(this.shadowBounds);
|
|
27802
27604
|
this.offsetLineBgAndShadowBounds();
|
|
27605
|
+
this.offsetShadowRoot();
|
|
27803
27606
|
}
|
|
27804
27607
|
trySyncPlaceholderToTextConfig() {
|
|
27805
27608
|
if (!this.currRt) {
|
|
@@ -27809,7 +27612,7 @@ class RichTextEditPlugin {
|
|
|
27809
27612
|
if (textConfig && textConfig.length) {
|
|
27810
27613
|
return;
|
|
27811
27614
|
}
|
|
27812
|
-
if (!(editOptions && editOptions.placeholder && editOptions.
|
|
27615
|
+
if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceholderToTextConfig)) {
|
|
27813
27616
|
return;
|
|
27814
27617
|
}
|
|
27815
27618
|
const { placeholder } = editOptions;
|
|
@@ -27820,13 +27623,16 @@ class RichTextEditPlugin {
|
|
|
27820
27623
|
});
|
|
27821
27624
|
}
|
|
27822
27625
|
deactivate(context) {
|
|
27823
|
-
context.stage.off('pointermove', this.handleMove);
|
|
27824
|
-
context.stage.off('pointerdown', this.handlePointerDown);
|
|
27825
|
-
context.stage.off('pointerup', this.handlePointerUp);
|
|
27826
|
-
context.stage.off('pointerleave', this.handlePointerUp);
|
|
27827
|
-
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 });
|
|
27828
27631
|
application.global.addEventListener('keydown', this.handleKeyDown);
|
|
27829
27632
|
}
|
|
27633
|
+
stopPropagation(e) {
|
|
27634
|
+
e.stopPropagation();
|
|
27635
|
+
}
|
|
27830
27636
|
onFocus(e, data) {
|
|
27831
27637
|
this.updateCbs && this.updateCbs.forEach(cb => cb('beforeOnfocus', this));
|
|
27832
27638
|
this.deFocus(false);
|
|
@@ -27842,8 +27648,11 @@ class RichTextEditPlugin {
|
|
|
27842
27648
|
if (!cache) {
|
|
27843
27649
|
return;
|
|
27844
27650
|
}
|
|
27845
|
-
this.
|
|
27846
|
-
|
|
27651
|
+
const { editOptions = {} } = this.currRt.attribute;
|
|
27652
|
+
if (editOptions.stopPropagation) {
|
|
27653
|
+
target.addEventListener('*', this.stopPropagation);
|
|
27654
|
+
}
|
|
27655
|
+
this.offsetShadowRoot(target);
|
|
27847
27656
|
if (!this.editLine) {
|
|
27848
27657
|
const line = createLine({ x: 0, y: 0, lineWidth: 1, stroke: 'black' });
|
|
27849
27658
|
this.addAnimateToLine(line);
|
|
@@ -27875,6 +27684,23 @@ class RichTextEditPlugin {
|
|
|
27875
27684
|
this.tryShowInputBounds();
|
|
27876
27685
|
this.currRt.addUpdateBoundTag();
|
|
27877
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
|
+
}
|
|
27878
27704
|
offsetLineBgAndShadowBounds() {
|
|
27879
27705
|
const rt = this.currRt;
|
|
27880
27706
|
const { textBaseline } = rt.attribute;
|
|
@@ -27900,15 +27726,20 @@ class RichTextEditPlugin {
|
|
|
27900
27726
|
}
|
|
27901
27727
|
}
|
|
27902
27728
|
deFocus(trulyDeFocus = false) {
|
|
27903
|
-
|
|
27904
|
-
|
|
27729
|
+
this.updateCbs && this.updateCbs.forEach(cb => cb('beforeDefocus', this, { trulyDeFocus }));
|
|
27730
|
+
const target = this.currRt;
|
|
27731
|
+
if (!target) {
|
|
27905
27732
|
return;
|
|
27906
27733
|
}
|
|
27907
|
-
|
|
27734
|
+
const { editOptions = {} } = target.attribute;
|
|
27735
|
+
if (editOptions.stopPropagation) {
|
|
27736
|
+
target.removeEventListener('*', this.stopPropagation);
|
|
27737
|
+
}
|
|
27908
27738
|
if (trulyDeFocus) {
|
|
27909
27739
|
this.trySyncPlaceholderToTextConfig();
|
|
27910
|
-
|
|
27740
|
+
target.detachShadow();
|
|
27911
27741
|
}
|
|
27742
|
+
const currRt = this.currRt;
|
|
27912
27743
|
this.currRt = null;
|
|
27913
27744
|
if (this.editLine) {
|
|
27914
27745
|
this.editLine.parent && this.editLine.parent.removeChild(this.editLine);
|
|
@@ -27940,10 +27771,8 @@ class RichTextEditPlugin {
|
|
|
27940
27771
|
cleared = true;
|
|
27941
27772
|
}
|
|
27942
27773
|
cleared && currRt.setAttributes({ textConfig });
|
|
27943
|
-
currRt.removeEventListener('pointerleave', this.handleLeave);
|
|
27944
27774
|
}
|
|
27945
27775
|
addAnimateToLine(line) {
|
|
27946
|
-
line.setAttributes({ opacity: 1 });
|
|
27947
27776
|
line.animates &&
|
|
27948
27777
|
line.animates.forEach(animate => {
|
|
27949
27778
|
animate.stop();
|
|
@@ -28002,9 +27831,6 @@ class RichTextEditPlugin {
|
|
|
28002
27831
|
};
|
|
28003
27832
|
let line0Info = this.getLineByPoint(cache, startCursorPos);
|
|
28004
27833
|
let line1Info = this.getLineByPoint(cache, endCursorPos);
|
|
28005
|
-
if (!line0Info || !line1Info) {
|
|
28006
|
-
return;
|
|
28007
|
-
}
|
|
28008
27834
|
if (startCursorPos.y > endCursorPos.y ||
|
|
28009
27835
|
(startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x)) {
|
|
28010
27836
|
[startCursorPos, endCursorPos] = [endCursorPos, startCursorPos];
|
|
@@ -28138,10 +27964,7 @@ class RichTextEditPlugin {
|
|
|
28138
27964
|
return -1;
|
|
28139
27965
|
}
|
|
28140
27966
|
isRichtext(e) {
|
|
28141
|
-
return !!(e.target && e.target.type === 'richtext');
|
|
28142
|
-
}
|
|
28143
|
-
isEditableRichtext(e) {
|
|
28144
|
-
return this.isRichtext(e) && !!e.target.attribute.editable;
|
|
27967
|
+
return !!(e.target && e.target.type === 'richtext' && e.target.attribute.editable);
|
|
28145
27968
|
}
|
|
28146
27969
|
triggerRender() {
|
|
28147
27970
|
this.pluginService.stage.renderNextFrame();
|
|
@@ -28149,6 +27972,9 @@ class RichTextEditPlugin {
|
|
|
28149
27972
|
computeGlobalDelta(cache) {
|
|
28150
27973
|
this.deltaX = 0;
|
|
28151
27974
|
this.deltaY = 0;
|
|
27975
|
+
if (cache.lines.length === 0 && this.shadowPlaceHolder) {
|
|
27976
|
+
cache = this.shadowPlaceHolder.getFrameCache();
|
|
27977
|
+
}
|
|
28152
27978
|
const height = cache.height;
|
|
28153
27979
|
const actualHeight = cache.actualHeight;
|
|
28154
27980
|
const width = cache.lines.reduce((w, item) => Math.max(w, item.actualWidth), 0);
|
|
@@ -28199,6 +28025,7 @@ class RichTextEditPlugin {
|
|
|
28199
28025
|
out.x += left;
|
|
28200
28026
|
out.y += top;
|
|
28201
28027
|
this.offsetLineBgAndShadowBounds();
|
|
28028
|
+
this.offsetShadowRoot();
|
|
28202
28029
|
this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
|
|
28203
28030
|
}
|
|
28204
28031
|
computedCursorPosByEvent(e, cache) {
|
|
@@ -28300,7 +28127,7 @@ class RichTextEditPlugin {
|
|
|
28300
28127
|
}
|
|
28301
28128
|
}
|
|
28302
28129
|
_forceFocusByEvent(e) {
|
|
28303
|
-
this.handleEnter();
|
|
28130
|
+
this.handleEnter(e);
|
|
28304
28131
|
this.handlePointerDown(e);
|
|
28305
28132
|
this.handlePointerUp(e);
|
|
28306
28133
|
}
|