@visactor/vrender 0.22.0-vstory.5 → 0.22.0-vstory.7
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 +103 -91
- package/dist/index.js +103 -91
- 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 +5 -5
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 {
|
|
@@ -13245,7 +13245,7 @@
|
|
|
13245
13245
|
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
13246
13246
|
}
|
|
13247
13247
|
drawWithClipRange(ctx, size, x, y, clipRange, z, cb) {
|
|
13248
|
-
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
13248
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
13249
13249
|
item.path.drawWithClipRange(ctx, size, x, y, clipRange), cb && cb(item.path, item.attribute);
|
|
13250
13250
|
}), !1) : (this.path.drawWithClipRange(ctx, size, x, y, clipRange), !1);
|
|
13251
13251
|
}
|
|
@@ -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 {
|
|
@@ -14390,7 +14386,13 @@
|
|
|
14390
14386
|
}
|
|
14391
14387
|
return cache.every(item => item.isComposing || !(item.text && isString$1(item.text) && RichText.splitText(item.text).length > 1));
|
|
14392
14388
|
}
|
|
14389
|
+
static splitEmoji(text) {
|
|
14390
|
+
return [...new Intl.Segmenter().segment(text)].map(x => x.segment);
|
|
14391
|
+
}
|
|
14393
14392
|
static splitText(text) {
|
|
14393
|
+
try {
|
|
14394
|
+
return this.splitEmoji(text);
|
|
14395
|
+
} catch (e) {}
|
|
14394
14396
|
return Array.from(text);
|
|
14395
14397
|
}
|
|
14396
14398
|
static TransformTextConfig2SingleCharacter(textConfig) {
|
|
@@ -18436,7 +18438,7 @@
|
|
|
18436
18438
|
renderGroup(group, drawContext, parentMatrix, skipSort) {
|
|
18437
18439
|
if (drawContext.break || !1 === group.attribute.visibleAll) return;
|
|
18438
18440
|
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;
|
|
18441
|
+
if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, !1) && "empty" !== group.attribute.boundsMode) return;
|
|
18440
18442
|
let tempBounds,
|
|
18441
18443
|
nextM = parentMatrix;
|
|
18442
18444
|
if (this.useDirtyBounds) {
|
|
@@ -20431,9 +20433,9 @@
|
|
|
20431
20433
|
textConfig.splice(configIdx, 1);
|
|
20432
20434
|
const text = lastConfig.text,
|
|
20433
20435
|
textList = text ? Array.from(text.toString()) : [];
|
|
20434
|
-
for (let i = 0; i < textList.length; i++) textConfig.splice(i + configIdx, 0, Object.assign(Object.assign({
|
|
20436
|
+
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
20437
|
fill: "black"
|
|
20436
|
-
}, lastConfig), {
|
|
20438
|
+
}), lastConfig), {
|
|
20437
20439
|
isComposing: !1,
|
|
20438
20440
|
text: textList[i]
|
|
20439
20441
|
}));
|
|
@@ -20633,9 +20635,11 @@
|
|
|
20633
20635
|
const cache = currRt.getFrameCache();
|
|
20634
20636
|
if (!cache) return;
|
|
20635
20637
|
const {
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20638
|
+
lines: lines
|
|
20639
|
+
} = cache;
|
|
20640
|
+
if (0 === lines.length) return;
|
|
20641
|
+
if (!lines[0].paragraphs || 0 === lines[0].paragraphs.length) return;
|
|
20642
|
+
const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
|
|
20639
20643
|
return this.selectionRange(-.1, totalCursorCount + .1), e.preventDefault(), !0;
|
|
20640
20644
|
}
|
|
20641
20645
|
return !1;
|
|
@@ -20703,18 +20707,19 @@
|
|
|
20703
20707
|
placeholderFontFamily: placeholderFontFamily,
|
|
20704
20708
|
placeholderFontSize: placeholderFontSize
|
|
20705
20709
|
} = editOptions,
|
|
20706
|
-
shadow = this.
|
|
20707
|
-
|
|
20710
|
+
shadow = this.getShadow(this.currRt),
|
|
20711
|
+
textConfigItem = Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), {
|
|
20712
|
+
text: placeholder
|
|
20713
|
+
});
|
|
20714
|
+
placeholderColor && (textConfigItem.fill = placeholderColor), placeholderFontFamily && (textConfigItem.fontFamily = placeholderFontFamily), placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
|
|
20708
20715
|
x: 0,
|
|
20709
20716
|
y: 0,
|
|
20717
|
+
pickable: !1,
|
|
20718
|
+
editable: !1,
|
|
20719
|
+
editOptions: null,
|
|
20710
20720
|
angle: 0,
|
|
20711
20721
|
_debug_bounds: !1,
|
|
20712
|
-
textConfig: [
|
|
20713
|
-
text: placeholder,
|
|
20714
|
-
fill: placeholderColor,
|
|
20715
|
-
fontFamily: placeholderFontFamily,
|
|
20716
|
-
fontSize: placeholderFontSize
|
|
20717
|
-
}]
|
|
20722
|
+
textConfig: [textConfigItem]
|
|
20718
20723
|
})), shadow.add(this.shadowPlaceHolder);
|
|
20719
20724
|
}
|
|
20720
20725
|
tryShowInputBounds() {
|
|
@@ -20727,15 +20732,15 @@
|
|
|
20727
20732
|
} = editOptions;
|
|
20728
20733
|
if (!editOptions || !boundsStrokeWhenInput) return;
|
|
20729
20734
|
const {
|
|
20730
|
-
|
|
20731
|
-
|
|
20732
|
-
|
|
20733
|
-
|
|
20735
|
+
attribute: attribute
|
|
20736
|
+
} = this.currRt;
|
|
20737
|
+
let b = this.currRt.AABBBounds,
|
|
20738
|
+
h = b.height();
|
|
20734
20739
|
if (!attribute.textConfig.length && this.editLine) {
|
|
20735
20740
|
const {
|
|
20736
20741
|
points: points
|
|
20737
20742
|
} = this.editLine.attribute;
|
|
20738
|
-
h = points[1].y - points[0].y;
|
|
20743
|
+
h = points[1].y - points[0].y, b = getRichTextBounds(Object.assign({}, this.shadowPlaceHolder.attribute));
|
|
20739
20744
|
}
|
|
20740
20745
|
this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
|
|
20741
20746
|
x: 0,
|
|
@@ -20745,10 +20750,9 @@
|
|
|
20745
20750
|
fill: !1,
|
|
20746
20751
|
stroke: boundsStrokeWhenInput,
|
|
20747
20752
|
lineWidth: 1,
|
|
20748
|
-
boundsMode: "empty",
|
|
20749
20753
|
zIndex: -1
|
|
20750
20754
|
});
|
|
20751
|
-
|
|
20755
|
+
this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
|
|
20752
20756
|
}
|
|
20753
20757
|
trySyncPlaceholderToTextConfig() {
|
|
20754
20758
|
if (!this.currRt) return;
|
|
@@ -20757,7 +20761,7 @@
|
|
|
20757
20761
|
editOptions: editOptions
|
|
20758
20762
|
} = this.currRt.attribute;
|
|
20759
20763
|
if (textConfig && textConfig.length) return;
|
|
20760
|
-
if (!editOptions
|
|
20764
|
+
if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceHolderToTextConfig)) return;
|
|
20761
20765
|
const {
|
|
20762
20766
|
placeholder: placeholder
|
|
20763
20767
|
} = editOptions;
|
|
@@ -20771,11 +20775,11 @@
|
|
|
20771
20775
|
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
20776
|
}
|
|
20773
20777
|
onFocus(e, data) {
|
|
20774
|
-
this.deFocus(!1), this.focusing = !0;
|
|
20778
|
+
this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
|
|
20775
20779
|
const target = e.target;
|
|
20776
20780
|
if (!target || "richtext" !== target.type) return;
|
|
20777
20781
|
this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
|
|
20778
|
-
const shadowRoot =
|
|
20782
|
+
const shadowRoot = this.getShadow(target),
|
|
20779
20783
|
cache = target.getFrameCache();
|
|
20780
20784
|
if (cache) {
|
|
20781
20785
|
if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
|
|
@@ -20788,16 +20792,14 @@
|
|
|
20788
20792
|
x: 0,
|
|
20789
20793
|
y: 0,
|
|
20790
20794
|
lineWidth: 1,
|
|
20791
|
-
stroke: "black"
|
|
20792
|
-
boundsMode: "empty"
|
|
20795
|
+
stroke: "black"
|
|
20793
20796
|
});
|
|
20794
20797
|
this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
|
|
20795
20798
|
const g = createGroup({
|
|
20796
20799
|
x: 0,
|
|
20797
20800
|
y: 0,
|
|
20798
20801
|
width: 0,
|
|
20799
|
-
height: 0
|
|
20800
|
-
boundsMode: "empty"
|
|
20802
|
+
height: 0
|
|
20801
20803
|
});
|
|
20802
20804
|
this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
|
|
20803
20805
|
}
|
|
@@ -20852,7 +20854,9 @@
|
|
|
20852
20854
|
let trulyDeFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
|
|
20853
20855
|
const target = this.currRt;
|
|
20854
20856
|
if (!target) return;
|
|
20855
|
-
|
|
20857
|
+
this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
|
|
20858
|
+
trulyDeFocus: trulyDeFocus
|
|
20859
|
+
})), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
|
|
20856
20860
|
const currRt = this.currRt;
|
|
20857
20861
|
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
20862
|
const textConfig = currRt.attribute.textConfig;
|
|
@@ -20909,67 +20913,75 @@
|
|
|
20909
20913
|
},
|
|
20910
20914
|
line0Info = this.getLineByPoint(cache, startCursorPos),
|
|
20911
20915
|
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,
|
|
20916
|
+
if (line0Info && line1Info) {
|
|
20917
|
+
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({
|
|
20918
|
+
x: startCursorPos.x,
|
|
20922
20919
|
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
|
-
|
|
20920
|
+
width: endCursorPos.x - startCursorPos.x,
|
|
20921
|
+
height: line0Info.height,
|
|
20922
|
+
fill: "#336df4",
|
|
20923
|
+
fillOpacity: .2
|
|
20924
|
+
});else {
|
|
20925
|
+
this.editBg.setAttributes({
|
|
20926
|
+
x: 0,
|
|
20927
|
+
y: line0Info.top,
|
|
20928
|
+
width: 0,
|
|
20929
|
+
height: 0
|
|
20930
|
+
});
|
|
20931
|
+
const startIdx = cache.lines.findIndex(item => item === line0Info),
|
|
20932
|
+
endIdx = cache.lines.findIndex(item => item === line1Info);
|
|
20933
|
+
let y = 0;
|
|
20934
|
+
for (let i = startIdx; i <= endIdx; i++) {
|
|
20935
|
+
const line = cache.lines[i];
|
|
20936
|
+
if (i === startIdx) {
|
|
20937
|
+
const p = line.paragraphs[line.paragraphs.length - 1];
|
|
20938
|
+
this.editBg.add(createRect({
|
|
20939
|
+
x: startCursorPos.x,
|
|
20940
|
+
y: y,
|
|
20941
|
+
width: p.left + p.width - startCursorPos.x,
|
|
20942
|
+
height: line.height,
|
|
20943
|
+
fill: "#336df4",
|
|
20944
|
+
fillOpacity: .2
|
|
20945
|
+
}));
|
|
20946
|
+
} else if (i === endIdx) {
|
|
20947
|
+
const p = line.paragraphs[0];
|
|
20948
|
+
this.editBg.add(createRect({
|
|
20949
|
+
x: p.left,
|
|
20950
|
+
y: y,
|
|
20951
|
+
width: endCursorPos.x - p.left,
|
|
20952
|
+
height: line.height,
|
|
20953
|
+
fill: "#336df4",
|
|
20954
|
+
fillOpacity: .2
|
|
20955
|
+
}));
|
|
20956
|
+
} else {
|
|
20957
|
+
const p0 = line.paragraphs[0],
|
|
20958
|
+
p1 = line.paragraphs[line.paragraphs.length - 1];
|
|
20959
|
+
this.editBg.add(createRect({
|
|
20960
|
+
x: p0.left,
|
|
20961
|
+
y: y,
|
|
20962
|
+
width: p1.left + p1.width - p0.left,
|
|
20963
|
+
height: line.height,
|
|
20964
|
+
fill: "#336df4",
|
|
20965
|
+
fillOpacity: .2
|
|
20966
|
+
}));
|
|
20967
|
+
}
|
|
20968
|
+
y += line.height;
|
|
20962
20969
|
}
|
|
20963
|
-
y += line.height;
|
|
20964
20970
|
}
|
|
20971
|
+
this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt), this.triggerRender(), this.updateCbs.forEach(cb => cb("selection", this));
|
|
20965
20972
|
}
|
|
20966
|
-
this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt), this.triggerRender(), this.updateCbs.forEach(cb => cb("selection", this));
|
|
20967
20973
|
}
|
|
20968
20974
|
hideSelection() {
|
|
20969
20975
|
this.editBg && (this.editBg.removeAllChild(), this.editBg.setAttributes({
|
|
20970
20976
|
fill: "transparent"
|
|
20971
20977
|
}));
|
|
20972
20978
|
}
|
|
20979
|
+
getShadow(rt) {
|
|
20980
|
+
const sr = rt.shadowRoot || rt.attachShadow();
|
|
20981
|
+
return sr.setAttributes({
|
|
20982
|
+
boundsMode: "empty"
|
|
20983
|
+
}), sr;
|
|
20984
|
+
}
|
|
20973
20985
|
getLineByPoint(cache, p1) {
|
|
20974
20986
|
let lineInfo = cache.lines[0];
|
|
20975
20987
|
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 +30477,7 @@
|
|
|
30465
30477
|
|
|
30466
30478
|
const roughModule = _roughModule;
|
|
30467
30479
|
|
|
30468
|
-
const version = "0.22.0-vstory.
|
|
30480
|
+
const version = "0.22.0-vstory.7";
|
|
30469
30481
|
preLoadAllModule();
|
|
30470
30482
|
if (isBrowserEnv()) {
|
|
30471
30483
|
loadBrowserEnv(container);
|