@visactor/vrender 0.22.0-vstory.6 → 0.22.0-vstory.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +118 -103
- package/dist/index.js +118 -103
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10918,7 +10918,7 @@
|
|
|
10918
10918
|
application.graphicService.beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
|
|
10919
10919
|
const selfChange = this.shouldSelfChangeUpdateAABBBounds(),
|
|
10920
10920
|
bounds = this.doUpdateAABBBounds();
|
|
10921
|
-
return this.addUpdateLayoutTag(), application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, selfChange), bounds;
|
|
10921
|
+
return this.addUpdateLayoutTag(), application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, selfChange), "empty" === this.attribute.boundsMode && bounds.clear(), bounds;
|
|
10922
10922
|
}
|
|
10923
10923
|
doUpdateLocalMatrix() {
|
|
10924
10924
|
const {
|
|
@@ -13888,15 +13888,11 @@
|
|
|
13888
13888
|
}
|
|
13889
13889
|
|
|
13890
13890
|
function getFixedLRTB(left, right, top, bottom) {
|
|
13891
|
-
const leftInt = Math.round(left),
|
|
13892
|
-
topInt = Math.round(top),
|
|
13893
|
-
rightInt = Math.round(right),
|
|
13894
|
-
bottomInt = Math.round(bottom);
|
|
13895
13891
|
return {
|
|
13896
|
-
left: left
|
|
13897
|
-
top: top
|
|
13898
|
-
right:
|
|
13899
|
-
bottom:
|
|
13892
|
+
left: Math.round(left),
|
|
13893
|
+
top: Math.round(top),
|
|
13894
|
+
right: Math.round(right),
|
|
13895
|
+
bottom: Math.round(bottom)
|
|
13900
13896
|
};
|
|
13901
13897
|
}
|
|
13902
13898
|
class Paragraph {
|
|
@@ -13940,19 +13936,11 @@
|
|
|
13940
13936
|
}
|
|
13941
13937
|
}
|
|
13942
13938
|
}
|
|
13943
|
-
switch (this.character.script) {
|
|
13944
|
-
case "super":
|
|
13945
|
-
baseline -= this.ascent * (1 / 3);
|
|
13946
|
-
break;
|
|
13947
|
-
case "sub":
|
|
13948
|
-
baseline += this.descent / 2;
|
|
13949
|
-
}
|
|
13950
|
-
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
|
|
13951
|
-
const fillStyle = ctx.fillStyle,
|
|
13952
|
-
globalAlpha = ctx.globalAlpha;
|
|
13953
|
-
ctx.fillStyle = this.character.background, void 0 !== this.character.backgroundOpacity && (ctx.globalAlpha = this.character.backgroundOpacity);
|
|
13954
13939
|
const lrtb = getFixedLRTB(left, left + (this.widthOrigin || this.width), top, top + lineHeight);
|
|
13955
|
-
|
|
13940
|
+
return Object.assign(Object.assign({}, lrtb), {
|
|
13941
|
+
fillStyle: this.character.background,
|
|
13942
|
+
globalAlpha: this.character.backgroundOpacity
|
|
13943
|
+
});
|
|
13956
13944
|
}
|
|
13957
13945
|
draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
|
|
13958
13946
|
let baseline = top + ascent,
|
|
@@ -14226,8 +14214,19 @@
|
|
|
14226
14214
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
14227
14215
|
}
|
|
14228
14216
|
}
|
|
14217
|
+
let fillStyle = "",
|
|
14218
|
+
globalAlpha = -1,
|
|
14219
|
+
currBgList = [];
|
|
14220
|
+
const bgList = [currBgList];
|
|
14229
14221
|
this.paragraphs.forEach((paragraph, index) => {
|
|
14230
|
-
paragraph instanceof RichTextIcon
|
|
14222
|
+
if (paragraph instanceof RichTextIcon) return;
|
|
14223
|
+
const data = paragraph.drawBackground(ctx, y, this.ascent, x, 0 === index, this.textAlign, this.height);
|
|
14224
|
+
data && (fillStyle === data.fillStyle && globalAlpha === data.globalAlpha || (currBgList = [], bgList.push(currBgList), fillStyle = data.fillStyle, globalAlpha = data.globalAlpha), currBgList.push(data));
|
|
14225
|
+
}), bgList.forEach(bg => {
|
|
14226
|
+
if (0 === bg.length) return;
|
|
14227
|
+
const data = bg[0],
|
|
14228
|
+
end = bg[bg.length - 1];
|
|
14229
|
+
ctx.fillStyle = data.fillStyle, ctx.globalAlpha = data.globalAlpha, ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
|
|
14231
14230
|
}), this.paragraphs.forEach((paragraph, index) => {
|
|
14232
14231
|
if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
|
|
14233
14232
|
x: x + paragraph._x,
|
|
@@ -14390,7 +14389,13 @@
|
|
|
14390
14389
|
}
|
|
14391
14390
|
return cache.every(item => item.isComposing || !(item.text && isString$1(item.text) && RichText.splitText(item.text).length > 1));
|
|
14392
14391
|
}
|
|
14392
|
+
static splitEmoji(text) {
|
|
14393
|
+
return [...new Intl.Segmenter().segment(text)].map(x => x.segment);
|
|
14394
|
+
}
|
|
14393
14395
|
static splitText(text) {
|
|
14396
|
+
try {
|
|
14397
|
+
return this.splitEmoji(text);
|
|
14398
|
+
} catch (e) {}
|
|
14394
14399
|
return Array.from(text);
|
|
14395
14400
|
}
|
|
14396
14401
|
static TransformTextConfig2SingleCharacter(textConfig) {
|
|
@@ -18436,7 +18441,7 @@
|
|
|
18436
18441
|
renderGroup(group, drawContext, parentMatrix, skipSort) {
|
|
18437
18442
|
if (drawContext.break || !1 === group.attribute.visibleAll) return;
|
|
18438
18443
|
if (group.incremental && (null == drawContext.startAtId || drawContext.startAtId === group._uid)) return drawContext.break = !0, void this._increaseRender(group, drawContext);
|
|
18439
|
-
if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, !1)) return;
|
|
18444
|
+
if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, !1) && "empty" !== group.attribute.boundsMode) return;
|
|
18440
18445
|
let tempBounds,
|
|
18441
18446
|
nextM = parentMatrix;
|
|
18442
18447
|
if (this.useDirtyBounds) {
|
|
@@ -20431,9 +20436,9 @@
|
|
|
20431
20436
|
textConfig.splice(configIdx, 1);
|
|
20432
20437
|
const text = lastConfig.text,
|
|
20433
20438
|
textList = text ? Array.from(text.toString()) : [];
|
|
20434
|
-
for (let i = 0; i < textList.length; i++) textConfig.splice(i + configIdx, 0, Object.assign(Object.assign({
|
|
20439
|
+
for (let i = 0; i < textList.length; i++) textConfig.splice(i + configIdx, 0, Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), {
|
|
20435
20440
|
fill: "black"
|
|
20436
|
-
}, lastConfig), {
|
|
20441
|
+
}), lastConfig), {
|
|
20437
20442
|
isComposing: !1,
|
|
20438
20443
|
text: textList[i]
|
|
20439
20444
|
}));
|
|
@@ -20633,9 +20638,11 @@
|
|
|
20633
20638
|
const cache = currRt.getFrameCache();
|
|
20634
20639
|
if (!cache) return;
|
|
20635
20640
|
const {
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20641
|
+
lines: lines
|
|
20642
|
+
} = cache;
|
|
20643
|
+
if (0 === lines.length) return;
|
|
20644
|
+
if (!lines[0].paragraphs || 0 === lines[0].paragraphs.length) return;
|
|
20645
|
+
const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
|
|
20639
20646
|
return this.selectionRange(-.1, totalCursorCount + .1), e.preventDefault(), !0;
|
|
20640
20647
|
}
|
|
20641
20648
|
return !1;
|
|
@@ -20703,18 +20710,19 @@
|
|
|
20703
20710
|
placeholderFontFamily: placeholderFontFamily,
|
|
20704
20711
|
placeholderFontSize: placeholderFontSize
|
|
20705
20712
|
} = editOptions,
|
|
20706
|
-
shadow = this.
|
|
20707
|
-
|
|
20713
|
+
shadow = this.getShadow(this.currRt),
|
|
20714
|
+
textConfigItem = Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), {
|
|
20715
|
+
text: placeholder
|
|
20716
|
+
});
|
|
20717
|
+
placeholderColor && (textConfigItem.fill = placeholderColor), placeholderFontFamily && (textConfigItem.fontFamily = placeholderFontFamily), placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
|
|
20708
20718
|
x: 0,
|
|
20709
20719
|
y: 0,
|
|
20720
|
+
pickable: !1,
|
|
20721
|
+
editable: !1,
|
|
20722
|
+
editOptions: null,
|
|
20710
20723
|
angle: 0,
|
|
20711
20724
|
_debug_bounds: !1,
|
|
20712
|
-
textConfig: [
|
|
20713
|
-
text: placeholder,
|
|
20714
|
-
fill: placeholderColor,
|
|
20715
|
-
fontFamily: placeholderFontFamily,
|
|
20716
|
-
fontSize: placeholderFontSize
|
|
20717
|
-
}]
|
|
20725
|
+
textConfig: [textConfigItem]
|
|
20718
20726
|
})), shadow.add(this.shadowPlaceHolder);
|
|
20719
20727
|
}
|
|
20720
20728
|
tryShowInputBounds() {
|
|
@@ -20727,15 +20735,15 @@
|
|
|
20727
20735
|
} = editOptions;
|
|
20728
20736
|
if (!editOptions || !boundsStrokeWhenInput) return;
|
|
20729
20737
|
const {
|
|
20730
|
-
|
|
20731
|
-
|
|
20732
|
-
|
|
20733
|
-
|
|
20738
|
+
attribute: attribute
|
|
20739
|
+
} = this.currRt;
|
|
20740
|
+
let b = this.currRt.AABBBounds,
|
|
20741
|
+
h = b.height();
|
|
20734
20742
|
if (!attribute.textConfig.length && this.editLine) {
|
|
20735
20743
|
const {
|
|
20736
20744
|
points: points
|
|
20737
20745
|
} = this.editLine.attribute;
|
|
20738
|
-
h = points[1].y - points[0].y;
|
|
20746
|
+
h = points[1].y - points[0].y, b = getRichTextBounds(Object.assign({}, this.shadowPlaceHolder.attribute));
|
|
20739
20747
|
}
|
|
20740
20748
|
this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
|
|
20741
20749
|
x: 0,
|
|
@@ -20745,10 +20753,9 @@
|
|
|
20745
20753
|
fill: !1,
|
|
20746
20754
|
stroke: boundsStrokeWhenInput,
|
|
20747
20755
|
lineWidth: 1,
|
|
20748
|
-
boundsMode: "empty",
|
|
20749
20756
|
zIndex: -1
|
|
20750
20757
|
});
|
|
20751
|
-
|
|
20758
|
+
this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
|
|
20752
20759
|
}
|
|
20753
20760
|
trySyncPlaceholderToTextConfig() {
|
|
20754
20761
|
if (!this.currRt) return;
|
|
@@ -20757,7 +20764,7 @@
|
|
|
20757
20764
|
editOptions: editOptions
|
|
20758
20765
|
} = this.currRt.attribute;
|
|
20759
20766
|
if (textConfig && textConfig.length) return;
|
|
20760
|
-
if (!editOptions
|
|
20767
|
+
if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceHolderToTextConfig)) return;
|
|
20761
20768
|
const {
|
|
20762
20769
|
placeholder: placeholder
|
|
20763
20770
|
} = editOptions;
|
|
@@ -20771,11 +20778,11 @@
|
|
|
20771
20778
|
context.stage.off("pointermove", this.handleMove), context.stage.off("pointerdown", this.handlePointerDown), context.stage.off("pointerup", this.handlePointerUp), context.stage.off("pointerleave", this.handlePointerUp), context.stage.off("dblclick", this.handleDBLClick), application.global.addEventListener("keydown", this.handleKeyDown);
|
|
20772
20779
|
}
|
|
20773
20780
|
onFocus(e, data) {
|
|
20774
|
-
this.deFocus(!1), this.focusing = !0;
|
|
20781
|
+
this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
|
|
20775
20782
|
const target = e.target;
|
|
20776
20783
|
if (!target || "richtext" !== target.type) return;
|
|
20777
20784
|
this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
|
|
20778
|
-
const shadowRoot =
|
|
20785
|
+
const shadowRoot = this.getShadow(target),
|
|
20779
20786
|
cache = target.getFrameCache();
|
|
20780
20787
|
if (cache) {
|
|
20781
20788
|
if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
|
|
@@ -20788,16 +20795,14 @@
|
|
|
20788
20795
|
x: 0,
|
|
20789
20796
|
y: 0,
|
|
20790
20797
|
lineWidth: 1,
|
|
20791
|
-
stroke: "black"
|
|
20792
|
-
boundsMode: "empty"
|
|
20798
|
+
stroke: "black"
|
|
20793
20799
|
});
|
|
20794
20800
|
this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
|
|
20795
20801
|
const g = createGroup({
|
|
20796
20802
|
x: 0,
|
|
20797
20803
|
y: 0,
|
|
20798
20804
|
width: 0,
|
|
20799
|
-
height: 0
|
|
20800
|
-
boundsMode: "empty"
|
|
20805
|
+
height: 0
|
|
20801
20806
|
});
|
|
20802
20807
|
this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
|
|
20803
20808
|
}
|
|
@@ -20852,7 +20857,9 @@
|
|
|
20852
20857
|
let trulyDeFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
|
|
20853
20858
|
const target = this.currRt;
|
|
20854
20859
|
if (!target) return;
|
|
20855
|
-
|
|
20860
|
+
this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
|
|
20861
|
+
trulyDeFocus: trulyDeFocus
|
|
20862
|
+
})), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
|
|
20856
20863
|
const currRt = this.currRt;
|
|
20857
20864
|
this.currRt = null, this.editLine && (this.editLine.parent && this.editLine.parent.removeChild(this.editLine), this.editLine.release(), this.editLine = null, this.editBg.parent && this.editBg.parent.removeChild(this.editBg), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.shadowBounds.parent && this.shadowBounds.parent.removeChild(this.shadowBounds), this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder), this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1;
|
|
20858
20865
|
const textConfig = currRt.attribute.textConfig;
|
|
@@ -20909,67 +20916,75 @@
|
|
|
20909
20916
|
},
|
|
20910
20917
|
line0Info = this.getLineByPoint(cache, startCursorPos),
|
|
20911
20918
|
line1Info = this.getLineByPoint(cache, endCursorPos);
|
|
20912
|
-
if (
|
|
20913
|
-
|
|
20914
|
-
|
|
20915
|
-
width: endCursorPos.x - startCursorPos.x,
|
|
20916
|
-
height: line0Info.height,
|
|
20917
|
-
fill: "#336df4",
|
|
20918
|
-
fillOpacity: .2
|
|
20919
|
-
});else {
|
|
20920
|
-
this.editBg.setAttributes({
|
|
20921
|
-
x: 0,
|
|
20919
|
+
if (line0Info && line1Info) {
|
|
20920
|
+
if ((startCursorPos.y > endCursorPos.y || startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x) && ([startCursorPos, endCursorPos] = [endCursorPos, startCursorPos], [line1Info, line0Info] = [line0Info, line1Info]), this.hideSelection(), line0Info === line1Info) this.editBg.setAttributes({
|
|
20921
|
+
x: startCursorPos.x,
|
|
20922
20922
|
y: line0Info.top,
|
|
20923
|
-
width:
|
|
20924
|
-
height:
|
|
20925
|
-
|
|
20926
|
-
|
|
20927
|
-
|
|
20928
|
-
|
|
20929
|
-
|
|
20930
|
-
|
|
20931
|
-
|
|
20932
|
-
|
|
20933
|
-
|
|
20934
|
-
|
|
20935
|
-
|
|
20936
|
-
|
|
20937
|
-
|
|
20938
|
-
|
|
20939
|
-
|
|
20940
|
-
|
|
20941
|
-
|
|
20942
|
-
|
|
20943
|
-
|
|
20944
|
-
|
|
20945
|
-
|
|
20946
|
-
|
|
20947
|
-
|
|
20948
|
-
|
|
20949
|
-
|
|
20950
|
-
|
|
20951
|
-
|
|
20952
|
-
|
|
20953
|
-
|
|
20954
|
-
|
|
20955
|
-
|
|
20956
|
-
|
|
20957
|
-
|
|
20958
|
-
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
|
|
20923
|
+
width: endCursorPos.x - startCursorPos.x,
|
|
20924
|
+
height: line0Info.height,
|
|
20925
|
+
fill: "#336df4",
|
|
20926
|
+
fillOpacity: .2
|
|
20927
|
+
});else {
|
|
20928
|
+
this.editBg.setAttributes({
|
|
20929
|
+
x: 0,
|
|
20930
|
+
y: line0Info.top,
|
|
20931
|
+
width: 0,
|
|
20932
|
+
height: 0
|
|
20933
|
+
});
|
|
20934
|
+
const startIdx = cache.lines.findIndex(item => item === line0Info),
|
|
20935
|
+
endIdx = cache.lines.findIndex(item => item === line1Info);
|
|
20936
|
+
let y = 0;
|
|
20937
|
+
for (let i = startIdx; i <= endIdx; i++) {
|
|
20938
|
+
const line = cache.lines[i];
|
|
20939
|
+
if (i === startIdx) {
|
|
20940
|
+
const p = line.paragraphs[line.paragraphs.length - 1];
|
|
20941
|
+
this.editBg.add(createRect({
|
|
20942
|
+
x: startCursorPos.x,
|
|
20943
|
+
y: y,
|
|
20944
|
+
width: p.left + p.width - startCursorPos.x,
|
|
20945
|
+
height: line.height,
|
|
20946
|
+
fill: "#336df4",
|
|
20947
|
+
fillOpacity: .2
|
|
20948
|
+
}));
|
|
20949
|
+
} else if (i === endIdx) {
|
|
20950
|
+
const p = line.paragraphs[0];
|
|
20951
|
+
this.editBg.add(createRect({
|
|
20952
|
+
x: p.left,
|
|
20953
|
+
y: y,
|
|
20954
|
+
width: endCursorPos.x - p.left,
|
|
20955
|
+
height: line.height,
|
|
20956
|
+
fill: "#336df4",
|
|
20957
|
+
fillOpacity: .2
|
|
20958
|
+
}));
|
|
20959
|
+
} else {
|
|
20960
|
+
const p0 = line.paragraphs[0],
|
|
20961
|
+
p1 = line.paragraphs[line.paragraphs.length - 1];
|
|
20962
|
+
this.editBg.add(createRect({
|
|
20963
|
+
x: p0.left,
|
|
20964
|
+
y: y,
|
|
20965
|
+
width: p1.left + p1.width - p0.left,
|
|
20966
|
+
height: line.height,
|
|
20967
|
+
fill: "#336df4",
|
|
20968
|
+
fillOpacity: .2
|
|
20969
|
+
}));
|
|
20970
|
+
}
|
|
20971
|
+
y += line.height;
|
|
20962
20972
|
}
|
|
20963
|
-
y += line.height;
|
|
20964
20973
|
}
|
|
20974
|
+
this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt), this.triggerRender(), this.updateCbs.forEach(cb => cb("selection", this));
|
|
20965
20975
|
}
|
|
20966
|
-
this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt), this.triggerRender(), this.updateCbs.forEach(cb => cb("selection", this));
|
|
20967
20976
|
}
|
|
20968
20977
|
hideSelection() {
|
|
20969
20978
|
this.editBg && (this.editBg.removeAllChild(), this.editBg.setAttributes({
|
|
20970
20979
|
fill: "transparent"
|
|
20971
20980
|
}));
|
|
20972
20981
|
}
|
|
20982
|
+
getShadow(rt) {
|
|
20983
|
+
const sr = rt.shadowRoot || rt.attachShadow();
|
|
20984
|
+
return sr.setAttributes({
|
|
20985
|
+
boundsMode: "empty"
|
|
20986
|
+
}), sr;
|
|
20987
|
+
}
|
|
20973
20988
|
getLineByPoint(cache, p1) {
|
|
20974
20989
|
let lineInfo = cache.lines[0];
|
|
20975
20990
|
for (let i = 0; i < cache.lines.length && !(lineInfo.top <= p1.y && lineInfo.top + lineInfo.height >= p1.y); i++) lineInfo = cache.lines[i + 1];
|
|
@@ -30465,7 +30480,7 @@
|
|
|
30465
30480
|
|
|
30466
30481
|
const roughModule = _roughModule;
|
|
30467
30482
|
|
|
30468
|
-
const version = "0.22.0-vstory.
|
|
30483
|
+
const version = "0.22.0-vstory.8";
|
|
30469
30484
|
preLoadAllModule();
|
|
30470
30485
|
if (isBrowserEnv()) {
|
|
30471
30486
|
loadBrowserEnv(container);
|