@visactor/vrender-core 0.22.0-vstory.9 → 0.22.1
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/allocator/bounds-allocate.js +1 -1
- package/cjs/allocator/canvas-allocate.js +1 -1
- package/cjs/allocator/constants.js +1 -1
- package/cjs/allocator/graphic-allocate.js +1 -1
- package/cjs/allocator/matrix-allocate.js +1 -1
- package/cjs/animate/animate.js +1 -1
- package/cjs/animate/animate.js.map +1 -1
- package/cjs/animate/custom-animate.js +4 -2
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/animate/index.js +1 -2
- package/cjs/color-string/store.js +2 -1
- package/cjs/common/custom-path2d.js +8 -6
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/common/enums.js +1 -2
- 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 +17 -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/common/store.js +1 -1
- package/cjs/common/text.js +1 -2
- package/cjs/common/utils.js +1 -1
- package/cjs/core/application.js +1 -1
- package/cjs/core/camera.js +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 +4 -1
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +1 -1
- package/cjs/graphic/graphic.js +7 -7
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.d.ts +1 -0
- package/cjs/graphic/group.js +5 -0
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/line.js +2 -2
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/graphic/richtext/line.js +2 -2
- package/cjs/graphic/richtext/line.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.d.ts +2 -1
- package/cjs/graphic/richtext/paragraph.js +19 -17
- 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 +34 -19
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/graphic/symbol.d.ts +1 -0
- package/cjs/graphic/symbol.js +11 -0
- package/cjs/graphic/symbol.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/arc.js.map +1 -1
- package/cjs/interface/graphic/area.js.map +1 -1
- package/cjs/interface/graphic/circle.js.map +1 -1
- package/cjs/interface/graphic/group.js.map +1 -1
- package/cjs/interface/graphic/image.js.map +1 -1
- package/cjs/interface/graphic/line.js.map +1 -1
- package/cjs/interface/graphic/polygon.js.map +1 -1
- package/cjs/interface/graphic/rect.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +6 -1
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic/symbol.d.ts +1 -0
- package/cjs/interface/graphic/symbol.js.map +1 -1
- package/cjs/interface/graphic/text.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 +13 -7
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +11 -5
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +209 -158
- 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/base-texture-contribution-render.d.ts +2 -1
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +20 -3
- package/cjs/render/contributions/render/contributions/base-texture-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 +445 -476
- package/es/allocator/bounds-allocate.js +1 -1
- package/es/allocator/canvas-allocate.js +1 -1
- package/es/allocator/constants.js +1 -1
- package/es/allocator/graphic-allocate.js +1 -1
- package/es/allocator/matrix-allocate.js +1 -1
- package/es/animate/animate.js +4 -3
- package/es/animate/animate.js.map +1 -1
- package/es/animate/custom-animate.js +4 -2
- package/es/animate/custom-animate.js.map +1 -1
- package/es/animate/index.js +1 -2
- package/es/color-string/store.js +2 -1
- package/es/common/custom-path2d.js +8 -6
- package/es/common/custom-path2d.js.map +1 -1
- package/es/common/enums.js +1 -2
- 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 +18 -77
- 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/common/store.js +1 -1
- package/es/common/text.js +1 -2
- package/es/common/utils.js +1 -1
- package/es/core/application.js +1 -1
- package/es/core/camera.js +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 +4 -1
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic.d.ts +1 -1
- package/es/graphic/graphic.js +9 -9
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.d.ts +1 -0
- package/es/graphic/group.js +5 -0
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/line.js +2 -2
- package/es/graphic/line.js.map +1 -1
- package/es/graphic/richtext/line.js +2 -2
- package/es/graphic/richtext/line.js.map +1 -1
- package/es/graphic/richtext/paragraph.d.ts +2 -1
- package/es/graphic/richtext/paragraph.js +19 -17
- 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 +31 -18
- package/es/graphic/richtext.js.map +1 -1
- package/es/graphic/symbol.d.ts +1 -0
- package/es/graphic/symbol.js +11 -0
- package/es/graphic/symbol.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/arc.js.map +1 -1
- package/es/interface/graphic/area.js.map +1 -1
- package/es/interface/graphic/circle.js.map +1 -1
- package/es/interface/graphic/group.js.map +1 -1
- package/es/interface/graphic/image.js.map +1 -1
- package/es/interface/graphic/line.js.map +1 -1
- package/es/interface/graphic/polygon.js.map +1 -1
- package/es/interface/graphic/rect.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +6 -1
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic/symbol.d.ts +1 -0
- package/es/interface/graphic/symbol.js.map +1 -1
- package/es/interface/graphic/text.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 +13 -7
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +11 -5
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +209 -158
- 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/base-texture-contribution-render.d.ts +2 -1
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js +22 -2
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/group-contribution-render.js +2 -1
- package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/text-contribution-render.js +3 -2
- package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.js +3 -2
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/line-render.js +9 -31
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/resource-loader/loader.d.ts +2 -2
- package/es/resource-loader/loader.js +1 -1
- package/es/resource-loader/loader.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IPointLike } from '@visactor/vutils';
|
|
2
|
-
import type { IGroup, ILine, IPlugin, IPluginService, IRect, IRichText, IRichTextCharacter, IRichTextFrame, IRichTextIcon, IRichTextLine, IRichTextParagraph, ITicker, ITimeline } from '../../interface';
|
|
2
|
+
import type { IGraphic, IGroup, ILine, IPlugin, IPluginService, IRect, IRichText, IRichTextCharacter, IRichTextFrame, IRichTextIcon, IRichTextLine, IRichTextParagraph, ITicker, ITimeline } from '../../interface';
|
|
3
3
|
import { EditModule } from './edit-module';
|
|
4
4
|
type UpdateType = 'input' | 'change' | 'onfocus' | 'beforeOnfocus' | 'defocus' | 'beforeDefocus' | 'selection' | 'dispatch';
|
|
5
5
|
declare class Selection {
|
|
@@ -11,8 +11,8 @@ declare class Selection {
|
|
|
11
11
|
getSelectionPureText(): string;
|
|
12
12
|
hasFormat(key: string): boolean;
|
|
13
13
|
_getFormat(key: string, cursorIdx: number): any;
|
|
14
|
-
getFormat(key: string): any;
|
|
15
|
-
getAllFormat(key: string): any;
|
|
14
|
+
getFormat(key: string, supportOutAttr?: boolean): any;
|
|
15
|
+
getAllFormat(key: string, supportOutAttr?: boolean): any;
|
|
16
16
|
}
|
|
17
17
|
export declare const FORMAT_TEXT_COMMAND = "FORMAT_TEXT_COMMAND";
|
|
18
18
|
export declare const FORMAT_ALL_TEXT_COMMAND = "FORMAT_ALL_TEXT_COMMAND";
|
|
@@ -56,12 +56,14 @@ export declare class RichTextEditPlugin implements IPlugin {
|
|
|
56
56
|
copyToClipboard(e: KeyboardEvent): boolean;
|
|
57
57
|
selectionRange(startIdx: number, endIdx: number): void;
|
|
58
58
|
selectionRangeByCursorIdx(startCursorIdx: number, endCursorIdx: number, cache: IRichTextFrame): void;
|
|
59
|
-
fullSelection(
|
|
60
|
-
|
|
59
|
+
fullSelection(): void;
|
|
60
|
+
protected fullSelectionKeyHandler(e: KeyboardEvent): boolean;
|
|
61
|
+
directKeyHandler(e: KeyboardEvent): boolean;
|
|
61
62
|
handleKeyDown: (e: KeyboardEvent) => void;
|
|
62
63
|
handleInput: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void;
|
|
63
64
|
handleChange: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void;
|
|
64
65
|
tryShowShadowPlaceholder(): void;
|
|
66
|
+
getRichTextAABBBounds(rt: IRichText): any;
|
|
65
67
|
tryShowInputBounds(): void;
|
|
66
68
|
trySyncPlaceholderToTextConfig(): void;
|
|
67
69
|
handleFocusIn: () => never;
|
|
@@ -73,7 +75,11 @@ export declare class RichTextEditPlugin implements IPlugin {
|
|
|
73
75
|
handlePointerDown: (e: PointerEvent) => void;
|
|
74
76
|
handlePointerUp: (e: PointerEvent) => void;
|
|
75
77
|
handleDBLClick: (e: PointerEvent) => void;
|
|
78
|
+
protected stopPropagation(e: Event): void;
|
|
79
|
+
addEditLineOrBgOrBounds(graphic: IGraphic, shadowRoot: IGroup): void;
|
|
80
|
+
removeEditLineOrBgOrBounds(graphic: IGraphic, shadowRoot: IGroup): void;
|
|
76
81
|
onFocus(e: PointerEvent, data?: any): void;
|
|
82
|
+
offsetShadowRoot(rt?: IRichText): void;
|
|
77
83
|
protected offsetLineBgAndShadowBounds(): void;
|
|
78
84
|
protected deFocus(trulyDeFocus?: boolean): void;
|
|
79
85
|
protected addAnimateToLine(line: ILine): void;
|
|
@@ -40,14 +40,15 @@ class Selection {
|
|
|
40
40
|
for (let i = 0; i < config.length; i++) if ("\n" !== config[i].text && (idx--, idx < 0)) return config[i][key];
|
|
41
41
|
return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
|
|
42
42
|
}
|
|
43
|
-
getFormat(key) {
|
|
44
|
-
return this.getAllFormat(key)[0];
|
|
43
|
+
getFormat(key, supportOutAttr = !1) {
|
|
44
|
+
return this.getAllFormat(key, supportOutAttr)[0];
|
|
45
45
|
}
|
|
46
|
-
getAllFormat(key) {
|
|
46
|
+
getAllFormat(key, supportOutAttr = !1) {
|
|
47
|
+
var _a, _b, _c, _d;
|
|
47
48
|
const valSet = new Set, minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx), maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
|
|
48
|
-
if (minCursorIdx === maxCursorIdx) return [ this._getFormat(key, minCursorIdx) ];
|
|
49
|
+
if (minCursorIdx === maxCursorIdx) return supportOutAttr ? [ null !== (_a = this._getFormat(key, minCursorIdx)) && void 0 !== _a ? _a : (null === (_b = this.rt) || void 0 === _b ? void 0 : _b.attribute)[key] ] : [ this._getFormat(key, minCursorIdx) ];
|
|
49
50
|
for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
|
|
50
|
-
const val = this._getFormat(key, i);
|
|
51
|
+
const val = supportOutAttr ? null !== (_c = this._getFormat(key, i)) && void 0 !== _c ? _c : (null === (_d = this.rt) || void 0 === _d ? void 0 : _d.attribute)[key] : this._getFormat(key, i);
|
|
51
52
|
val && valSet.add(val);
|
|
52
53
|
}
|
|
53
54
|
return Array.from(valSet.values());
|
|
@@ -91,7 +92,7 @@ export class RichTextEditPlugin {
|
|
|
91
92
|
const config = rt.attribute.textConfig;
|
|
92
93
|
this._formatTextCommand(payload, config, rt);
|
|
93
94
|
}, this.handleKeyDown = e => {
|
|
94
|
-
this.currRt && this.editing && (this.copyToClipboard(e) || this.
|
|
95
|
+
this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelectionKeyHandler(e) || this.directKeyHandler(e));
|
|
95
96
|
}, this.handleInput = (text, isComposing, cursorIdx, rt) => {
|
|
96
97
|
this.currRt && (this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.hideSelection(),
|
|
97
98
|
this.updateCbs.forEach((cb => cb("input", this))));
|
|
@@ -107,7 +108,9 @@ export class RichTextEditPlugin {
|
|
|
107
108
|
throw new Error("不会走到这里 handleFocusOut");
|
|
108
109
|
}, this.handleMove = e => {
|
|
109
110
|
this.currRt && !this.currRt.attribute.editable && this.deFocus(!0), this.isEditableRichtext(e) ? (this.handleEnter(),
|
|
110
|
-
e.target.once("pointerleave", this.handleLeave
|
|
111
|
+
e.target.once("pointerleave", this.handleLeave, {
|
|
112
|
+
capture: !0
|
|
113
|
+
}), this.tryShowSelection(e, !1)) : this.handleLeave();
|
|
111
114
|
}, this.handleEnter = () => {
|
|
112
115
|
this.editing = !0, this.pluginService.stage.setCursor("text");
|
|
113
116
|
}, this.handleLeave = () => {
|
|
@@ -150,10 +153,17 @@ export class RichTextEditPlugin {
|
|
|
150
153
|
idx > -1 && cbs.splice(idx, 1);
|
|
151
154
|
}
|
|
152
155
|
activate(context) {
|
|
153
|
-
this.pluginService = context, this.editModule = new EditModule, context.stage.on("pointermove", this.handleMove
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
this.pluginService = context, this.editModule = new EditModule, context.stage.on("pointermove", this.handleMove, {
|
|
157
|
+
capture: !0
|
|
158
|
+
}), context.stage.on("pointerdown", this.handlePointerDown, {
|
|
159
|
+
capture: !0
|
|
160
|
+
}), context.stage.on("pointerup", this.handlePointerUp, {
|
|
161
|
+
capture: !0
|
|
162
|
+
}), context.stage.on("pointerleave", this.handlePointerUp, {
|
|
163
|
+
capture: !0
|
|
164
|
+
}), context.stage.on("dblclick", this.handleDBLClick, {
|
|
165
|
+
capture: !0
|
|
166
|
+
}), application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput),
|
|
157
167
|
this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
|
|
158
168
|
}
|
|
159
169
|
copyToClipboard(e) {
|
|
@@ -182,21 +192,21 @@ export class RichTextEditPlugin {
|
|
|
182
192
|
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
|
|
183
193
|
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this._tryShowSelection(pos, cache);
|
|
184
194
|
}
|
|
185
|
-
fullSelection(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
fullSelection() {
|
|
196
|
+
const currRt = this.currRt;
|
|
197
|
+
if (!currRt) return;
|
|
198
|
+
const cache = currRt.getFrameCache();
|
|
199
|
+
if (!cache) return;
|
|
200
|
+
const {lines: lines} = cache;
|
|
201
|
+
if (!lines.length || !lines[0].paragraphs.length) return;
|
|
202
|
+
const totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
|
|
203
|
+
this.selectionRange(-.1, totalCursorCount + .1);
|
|
204
|
+
}
|
|
205
|
+
fullSelectionKeyHandler(e) {
|
|
206
|
+
return !!(application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) && (this.fullSelection(),
|
|
207
|
+
e.preventDefault(), !0);
|
|
198
208
|
}
|
|
199
|
-
|
|
209
|
+
directKeyHandler(e) {
|
|
200
210
|
if ("ArrowUp" !== e.key && "ArrowDown" !== e.key && "ArrowLeft" !== e.key && "ArrowRight" !== e.key) return !1;
|
|
201
211
|
const cache = this.currRt.getFrameCache();
|
|
202
212
|
if (!cache) return !1;
|
|
@@ -205,7 +215,8 @@ export class RichTextEditPlugin {
|
|
|
205
215
|
const {lineInfo: lineInfo, columnInfo: columnInfo} = this.getColumnByIndex(cache, Math.round(this.curCursorIdx)), {lines: lines} = cache, totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
|
|
206
216
|
if (x) {
|
|
207
217
|
x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x,
|
|
208
|
-
this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1)
|
|
218
|
+
this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1),
|
|
219
|
+
this.selectionStartCursorIdx = this.curCursorIdx;
|
|
209
220
|
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
|
|
210
221
|
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this.hideSelection();
|
|
211
222
|
}
|
|
@@ -236,7 +247,7 @@ export class RichTextEditPlugin {
|
|
|
236
247
|
const placeholder = shadowRoot.getElementsByType("richtext")[0];
|
|
237
248
|
placeholder && shadowRoot.removeChild(placeholder);
|
|
238
249
|
}
|
|
239
|
-
const {textConfig: textConfig, editOptions: editOptions} = this.currRt.attribute;
|
|
250
|
+
const {textConfig: textConfig, editOptions: editOptions = {}} = this.currRt.attribute;
|
|
240
251
|
if (textConfig && textConfig.length) return;
|
|
241
252
|
if (!editOptions || !editOptions.placeholder) return;
|
|
242
253
|
const {placeholder: placeholder, placeholderColor: placeholderColor = "rgba(0, 0, 0, 0.6)", placeholderFontFamily: placeholderFontFamily, placeholderFontSize: placeholderFontSize} = editOptions, shadow = this.getShadow(this.currRt), textConfigItem = Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), {
|
|
@@ -246,41 +257,45 @@ export class RichTextEditPlugin {
|
|
|
246
257
|
placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
|
|
247
258
|
x: 0,
|
|
248
259
|
y: 0,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
editOptions: null,
|
|
260
|
+
dx: -this.deltaX,
|
|
261
|
+
dy: -this.deltaY,
|
|
252
262
|
angle: 0,
|
|
253
|
-
_debug_bounds: !1,
|
|
254
263
|
textConfig: [ textConfigItem ]
|
|
255
264
|
})), shadow.add(this.shadowPlaceHolder);
|
|
256
265
|
}
|
|
266
|
+
getRichTextAABBBounds(rt) {
|
|
267
|
+
const {attribute: attribute} = rt;
|
|
268
|
+
return attribute.textConfig.length ? rt.AABBBounds : getRichTextBounds(Object.assign(Object.assign({}, this.shadowPlaceHolder.attribute), {
|
|
269
|
+
x: attribute.x,
|
|
270
|
+
y: attribute.y,
|
|
271
|
+
textAlign: attribute.textAlign,
|
|
272
|
+
boundsMode: "accurate"
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
257
275
|
tryShowInputBounds() {
|
|
258
276
|
if (!this.currRt || !this.focusing) return;
|
|
259
277
|
const {editOptions: editOptions = {}} = this.currRt.attribute, {boundsStrokeWhenInput: boundsStrokeWhenInput} = editOptions;
|
|
260
278
|
if (!editOptions || !boundsStrokeWhenInput) return;
|
|
261
|
-
const
|
|
262
|
-
let b = this.currRt.AABBBounds, h = b.height();
|
|
263
|
-
if (!attribute.textConfig.length && this.editLine) {
|
|
264
|
-
const {points: points} = this.editLine.attribute;
|
|
265
|
-
h = points[1].y - points[0].y, b = getRichTextBounds(Object.assign({}, this.shadowPlaceHolder.attribute));
|
|
266
|
-
}
|
|
279
|
+
const b = this.getRichTextAABBBounds(this.currRt), height = b.height(), width = b.width();
|
|
267
280
|
this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
|
|
268
281
|
x: 0,
|
|
269
282
|
y: 0,
|
|
270
|
-
width:
|
|
271
|
-
height:
|
|
283
|
+
width: width,
|
|
284
|
+
height: height,
|
|
272
285
|
fill: !1,
|
|
273
286
|
stroke: boundsStrokeWhenInput,
|
|
274
287
|
lineWidth: 1,
|
|
275
288
|
zIndex: -1
|
|
276
289
|
});
|
|
277
|
-
this.getShadow(this.currRt)
|
|
290
|
+
const shadow = this.getShadow(this.currRt);
|
|
291
|
+
this.addEditLineOrBgOrBounds(this.shadowBounds, shadow), this.offsetLineBgAndShadowBounds(),
|
|
292
|
+
this.offsetShadowRoot();
|
|
278
293
|
}
|
|
279
294
|
trySyncPlaceholderToTextConfig() {
|
|
280
295
|
if (!this.currRt) return;
|
|
281
296
|
const {textConfig: textConfig, editOptions: editOptions} = this.currRt.attribute;
|
|
282
297
|
if (textConfig && textConfig.length) return;
|
|
283
|
-
if (!(editOptions && editOptions.placeholder && editOptions.
|
|
298
|
+
if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceholderToTextConfig)) return;
|
|
284
299
|
const {placeholder: placeholder} = editOptions;
|
|
285
300
|
this.currRt.setAttributes({
|
|
286
301
|
textConfig: [ Object.assign({
|
|
@@ -289,59 +304,95 @@ export class RichTextEditPlugin {
|
|
|
289
304
|
});
|
|
290
305
|
}
|
|
291
306
|
deactivate(context) {
|
|
292
|
-
context.stage.off("pointermove", this.handleMove
|
|
293
|
-
|
|
294
|
-
context.stage.off("
|
|
307
|
+
context.stage.off("pointermove", this.handleMove, {
|
|
308
|
+
capture: !0
|
|
309
|
+
}), context.stage.off("pointerdown", this.handlePointerDown, {
|
|
310
|
+
capture: !0
|
|
311
|
+
}), context.stage.off("pointerup", this.handlePointerUp, {
|
|
312
|
+
capture: !0
|
|
313
|
+
}), context.stage.off("pointerleave", this.handlePointerUp, {
|
|
314
|
+
capture: !0
|
|
315
|
+
}), context.stage.off("dblclick", this.handleDBLClick, {
|
|
316
|
+
capture: !0
|
|
317
|
+
}), application.global.addEventListener("keydown", this.handleKeyDown);
|
|
318
|
+
}
|
|
319
|
+
stopPropagation(e) {
|
|
320
|
+
e.stopPropagation();
|
|
321
|
+
}
|
|
322
|
+
addEditLineOrBgOrBounds(graphic, shadowRoot) {
|
|
323
|
+
let group = shadowRoot.getElementById("emptyBoundsContainer");
|
|
324
|
+
group || (group = createGroup({
|
|
325
|
+
x: 0,
|
|
326
|
+
y: 0,
|
|
327
|
+
width: 0,
|
|
328
|
+
height: 0,
|
|
329
|
+
boundsMode: "empty"
|
|
330
|
+
}), group.id = "emptyBoundsContainer", shadowRoot.add(group)), group.add(graphic);
|
|
331
|
+
}
|
|
332
|
+
removeEditLineOrBgOrBounds(graphic, shadowRoot) {
|
|
333
|
+
const group = shadowRoot.getElementById("emptyBoundsContainer");
|
|
334
|
+
group && group.removeChild(graphic);
|
|
295
335
|
}
|
|
296
336
|
onFocus(e, data) {
|
|
297
337
|
this.updateCbs && this.updateCbs.forEach((cb => cb("beforeOnfocus", this))), this.deFocus(!1),
|
|
298
|
-
this.focusing = !0;
|
|
338
|
+
this.focusing = !0, this.editing = !0;
|
|
299
339
|
const target = e.target;
|
|
300
340
|
if (!target || "richtext" !== target.type) return;
|
|
301
341
|
this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
|
|
302
342
|
const shadowRoot = this.getShadow(target), cache = target.getFrameCache();
|
|
303
|
-
if (cache)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
height: 0
|
|
322
|
-
});
|
|
323
|
-
this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
|
|
324
|
-
}
|
|
325
|
-
if (data = data || this.computedCursorPosByEvent(e, cache)) {
|
|
326
|
-
const {x: x, y1: y1, y2: y2, cursorIndex: cursorIndex} = data;
|
|
327
|
-
this.startCursorPos = {
|
|
328
|
-
x: x,
|
|
329
|
-
y: (y1 + y2) / 2
|
|
330
|
-
}, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
|
|
331
|
-
this.setCursorAndTextArea(x, y1, y2, target);
|
|
332
|
-
} else {
|
|
333
|
-
const x = 0, y1 = 0, y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
|
|
334
|
-
textConfig: [ {
|
|
335
|
-
text: "a"
|
|
336
|
-
} ]
|
|
337
|
-
})).height();
|
|
338
|
-
this.startCursorPos = {
|
|
339
|
-
x: x,
|
|
340
|
-
y: (y1 + y2) / 2
|
|
341
|
-
}, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
|
|
342
|
-
}
|
|
343
|
-
this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
|
|
343
|
+
if (!cache) return;
|
|
344
|
+
const {editOptions: editOptions = {}} = this.currRt.attribute;
|
|
345
|
+
if (editOptions.stopPropagation && target.addEventListener("*", this.stopPropagation),
|
|
346
|
+
this.offsetShadowRoot(target), !this.editLine) {
|
|
347
|
+
const line = createLine({
|
|
348
|
+
x: 0,
|
|
349
|
+
y: 0,
|
|
350
|
+
lineWidth: 1,
|
|
351
|
+
stroke: "black"
|
|
352
|
+
});
|
|
353
|
+
this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
|
|
354
|
+
const g = createGroup({
|
|
355
|
+
x: 0,
|
|
356
|
+
y: 0,
|
|
357
|
+
width: 0,
|
|
358
|
+
height: 0
|
|
359
|
+
});
|
|
360
|
+
this.editBg = g, this.addEditLineOrBgOrBounds(this.editLine, shadowRoot), this.addEditLineOrBgOrBounds(this.editBg, shadowRoot);
|
|
344
361
|
}
|
|
362
|
+
if (data = data || this.computedCursorPosByEvent(e, cache)) {
|
|
363
|
+
const {x: x, y1: y1, y2: y2, cursorIndex: cursorIndex} = data;
|
|
364
|
+
this.startCursorPos = {
|
|
365
|
+
x: x,
|
|
366
|
+
y: (y1 + y2) / 2
|
|
367
|
+
}, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
|
|
368
|
+
this.setCursorAndTextArea(x, y1, y2, target);
|
|
369
|
+
} else {
|
|
370
|
+
const x = 0, y1 = 0, y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
|
|
371
|
+
textConfig: [ {
|
|
372
|
+
text: "a"
|
|
373
|
+
} ]
|
|
374
|
+
})).height();
|
|
375
|
+
this.startCursorPos = {
|
|
376
|
+
x: x,
|
|
377
|
+
y: (y1 + y2) / 2
|
|
378
|
+
}, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
|
|
379
|
+
}
|
|
380
|
+
this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
|
|
381
|
+
}
|
|
382
|
+
offsetShadowRoot(rt) {
|
|
383
|
+
if (!(rt = rt || this.currRt)) return;
|
|
384
|
+
const shadowRoot = this.getShadow(rt);
|
|
385
|
+
if (!shadowRoot) return;
|
|
386
|
+
const cache = rt.getFrameCache();
|
|
387
|
+
cache && (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
|
|
388
|
+
shadowRootIdx: 1,
|
|
389
|
+
pickable: !1,
|
|
390
|
+
x: this.deltaX,
|
|
391
|
+
y: this.deltaY
|
|
392
|
+
}), this.shadowPlaceHolder && this.shadowPlaceHolder.setAttributes({
|
|
393
|
+
dx: -this.deltaX,
|
|
394
|
+
dy: -this.deltaY
|
|
395
|
+
}));
|
|
345
396
|
}
|
|
346
397
|
offsetLineBgAndShadowBounds() {
|
|
347
398
|
const rt = this.currRt, {textBaseline: textBaseline} = rt.attribute;
|
|
@@ -360,27 +411,27 @@ export class RichTextEditPlugin {
|
|
|
360
411
|
});
|
|
361
412
|
}
|
|
362
413
|
deFocus(trulyDeFocus = !1) {
|
|
363
|
-
|
|
364
|
-
if (!target) return;
|
|
365
|
-
this.updateCbs && this.updateCbs.forEach((cb => cb("beforeDefocus", this, {
|
|
414
|
+
this.editing = !1, this.updateCbs && this.updateCbs.forEach((cb => cb("beforeDefocus", this, {
|
|
366
415
|
trulyDeFocus: trulyDeFocus
|
|
367
|
-
})))
|
|
416
|
+
})));
|
|
368
417
|
const currRt = this.currRt;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
418
|
+
if (!currRt) return;
|
|
419
|
+
const {editOptions: editOptions = {}} = currRt.attribute;
|
|
420
|
+
editOptions.stopPropagation && currRt.removeEventListener("*", this.stopPropagation),
|
|
421
|
+
trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()),
|
|
422
|
+
this.currRt = null;
|
|
423
|
+
const shadowRoot = this.getShadow(currRt);
|
|
424
|
+
this.editLine && (this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot), this.editLine.release(),
|
|
425
|
+
this.editLine = null, this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot),
|
|
426
|
+
this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot),
|
|
372
427
|
this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder),
|
|
373
|
-
this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1
|
|
374
|
-
|
|
375
|
-
let lastConfig = textConfig[textConfig.length - 1], cleared = !1;
|
|
376
|
-
for (;lastConfig && "\n" === lastConfig.text; ) textConfig.pop(), lastConfig = textConfig[textConfig.length - 1],
|
|
377
|
-
cleared = !0;
|
|
378
|
-
cleared && currRt.setAttributes({
|
|
379
|
-
textConfig: textConfig
|
|
380
|
-
}), currRt.removeEventListener("pointerleave", this.handleLeave);
|
|
428
|
+
this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1,
|
|
429
|
+
currRt.removeEventListener("pointerleave", this.handleLeave);
|
|
381
430
|
}
|
|
382
431
|
addAnimateToLine(line) {
|
|
383
|
-
line.
|
|
432
|
+
line.setAttributes({
|
|
433
|
+
opacity: 1
|
|
434
|
+
}), line.animates && line.animates.forEach((animate => {
|
|
384
435
|
animate.stop(), animate.release();
|
|
385
436
|
}));
|
|
386
437
|
line.animate({
|
|
@@ -418,63 +469,61 @@ export class RichTextEditPlugin {
|
|
|
418
469
|
x: currCursorData.x,
|
|
419
470
|
y: (currCursorData.y1 + currCursorData.y2) / 2
|
|
420
471
|
}, line0Info = this.getLineByPoint(cache, startCursorPos), line1Info = this.getLineByPoint(cache, endCursorPos);
|
|
421
|
-
if (
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
472
|
+
if ((startCursorPos.y > endCursorPos.y || startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x) && ([startCursorPos, endCursorPos] = [ endCursorPos, startCursorPos ],
|
|
473
|
+
[line1Info, line0Info] = [ line0Info, line1Info ]), this.hideSelection(), line0Info === line1Info) this.editBg.setAttributes({
|
|
474
|
+
x: startCursorPos.x,
|
|
475
|
+
y: line0Info.top,
|
|
476
|
+
width: endCursorPos.x - startCursorPos.x,
|
|
477
|
+
height: line0Info.height,
|
|
478
|
+
fill: "#336df4",
|
|
479
|
+
fillOpacity: .2
|
|
480
|
+
}); else {
|
|
481
|
+
this.editBg.setAttributes({
|
|
482
|
+
x: 0,
|
|
425
483
|
y: line0Info.top,
|
|
426
|
-
width:
|
|
427
|
-
height:
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
this.editBg.add(createRect({
|
|
464
|
-
x: p0.left,
|
|
465
|
-
y: y,
|
|
466
|
-
width: p1.left + p1.width - p0.left,
|
|
467
|
-
height: line.height,
|
|
468
|
-
fill: "#336df4",
|
|
469
|
-
fillOpacity: .2
|
|
470
|
-
}));
|
|
471
|
-
}
|
|
472
|
-
y += line.height;
|
|
484
|
+
width: 0,
|
|
485
|
+
height: 0
|
|
486
|
+
});
|
|
487
|
+
const startIdx = cache.lines.findIndex((item => item === line0Info)), endIdx = cache.lines.findIndex((item => item === line1Info));
|
|
488
|
+
let y = 0;
|
|
489
|
+
for (let i = startIdx; i <= endIdx; i++) {
|
|
490
|
+
const line = cache.lines[i];
|
|
491
|
+
if (i === startIdx) {
|
|
492
|
+
const p = line.paragraphs[line.paragraphs.length - 1];
|
|
493
|
+
this.editBg.add(createRect({
|
|
494
|
+
x: startCursorPos.x,
|
|
495
|
+
y: y,
|
|
496
|
+
width: p.left + p.width - startCursorPos.x,
|
|
497
|
+
height: line.height,
|
|
498
|
+
fill: "#336df4",
|
|
499
|
+
fillOpacity: .2
|
|
500
|
+
}));
|
|
501
|
+
} else if (i === endIdx) {
|
|
502
|
+
const p = line.paragraphs[0];
|
|
503
|
+
this.editBg.add(createRect({
|
|
504
|
+
x: p.left,
|
|
505
|
+
y: y,
|
|
506
|
+
width: endCursorPos.x - p.left,
|
|
507
|
+
height: line.height,
|
|
508
|
+
fill: "#336df4",
|
|
509
|
+
fillOpacity: .2
|
|
510
|
+
}));
|
|
511
|
+
} else {
|
|
512
|
+
const p0 = line.paragraphs[0], p1 = line.paragraphs[line.paragraphs.length - 1];
|
|
513
|
+
this.editBg.add(createRect({
|
|
514
|
+
x: p0.left,
|
|
515
|
+
y: y,
|
|
516
|
+
width: p1.left + p1.width - p0.left,
|
|
517
|
+
height: line.height,
|
|
518
|
+
fill: "#336df4",
|
|
519
|
+
fillOpacity: .2
|
|
520
|
+
}));
|
|
473
521
|
}
|
|
522
|
+
y += line.height;
|
|
474
523
|
}
|
|
475
|
-
this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt),
|
|
476
|
-
this.triggerRender(), this.updateCbs.forEach((cb => cb("selection", this)));
|
|
477
524
|
}
|
|
525
|
+
this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt),
|
|
526
|
+
this.triggerRender(), this.updateCbs.forEach((cb => cb("selection", this)));
|
|
478
527
|
}
|
|
479
528
|
hideSelection() {
|
|
480
529
|
this.editBg && (this.editBg.removeAllChild(), this.editBg.setAttributes({
|
|
@@ -484,7 +533,8 @@ export class RichTextEditPlugin {
|
|
|
484
533
|
getShadow(rt) {
|
|
485
534
|
const sr = rt.shadowRoot || rt.attachShadow();
|
|
486
535
|
return sr.setAttributes({
|
|
487
|
-
|
|
536
|
+
width: 1,
|
|
537
|
+
height: 1
|
|
488
538
|
}), sr;
|
|
489
539
|
}
|
|
490
540
|
getLineByPoint(cache, p1) {
|
|
@@ -527,7 +577,7 @@ export class RichTextEditPlugin {
|
|
|
527
577
|
this.pluginService.stage.renderNextFrame();
|
|
528
578
|
}
|
|
529
579
|
computeGlobalDelta(cache) {
|
|
530
|
-
this.deltaX = 0, this.deltaY = 0;
|
|
580
|
+
this.deltaX = 0, this.deltaY = 0, 0 === cache.lines.length && this.shadowPlaceHolder && (cache = this.shadowPlaceHolder.getFrameCache());
|
|
531
581
|
const height = cache.height, actualHeight = cache.actualHeight, width = cache.lines.reduce(((w, item) => Math.max(w, item.actualWidth)), 0);
|
|
532
582
|
"center" === cache.globalAlign ? this.deltaX = -width / 2 : "right" === cache.globalAlign && (this.deltaX = -width),
|
|
533
583
|
"middle" === cache.verticalDirection ? this.deltaY = height / 2 - actualHeight / 2 : "bottom" === cache.verticalDirection && (this.deltaY = height - actualHeight);
|
|
@@ -566,7 +616,8 @@ export class RichTextEditPlugin {
|
|
|
566
616
|
y: y1
|
|
567
617
|
}, out);
|
|
568
618
|
const {left: left, top: top} = this.pluginService.stage.window.getBoundingClientRect();
|
|
569
|
-
out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.
|
|
619
|
+
out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot(),
|
|
620
|
+
this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
|
|
570
621
|
}
|
|
571
622
|
computedCursorPosByEvent(e, cache) {
|
|
572
623
|
const p1 = this.getEventPosition(e), lineInfo = this.getLineByPoint(cache, p1);
|