@visactor/vrender-core 0.22.0-vstory.12 → 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/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/core/contributions/textMeasure/AtextMeasure.js +10 -0
- package/cjs/core/contributions/textMeasure/AtextMeasure.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 +1 -0
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/richtext.d.ts +1 -1
- package/cjs/graphic/richtext.js +22 -5
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +1 -0
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic.d.ts +1 -0
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.js +2 -1
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +8 -4
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +124 -81
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.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/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/resource-loader/loader.d.ts +2 -2
- package/cjs/resource-loader/loader.js.map +1 -1
- package/dist/index.es.js +150 -65
- 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/core/contributions/textMeasure/AtextMeasure.js +10 -0
- package/es/core/contributions/textMeasure/AtextMeasure.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 +1 -0
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/richtext.d.ts +1 -1
- package/es/graphic/richtext.js +19 -4
- package/es/graphic/richtext.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +1 -0
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic.d.ts +1 -0
- package/es/interface/graphic.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.js +2 -1
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +8 -4
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +124 -81
- package/es/plugins/builtin-plugin/richtext-edit-plugin.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/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/resource-loader/loader.d.ts +2 -2
- package/es/resource-loader/loader.js.map +1 -1
- package/package.json +1 -1
|
@@ -35,14 +35,15 @@ class Selection {
|
|
|
35
35
|
for (let i = 0; i < config.length; i++) if ("\n" !== config[i].text && (idx--, idx < 0)) return config[i][key];
|
|
36
36
|
return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
|
|
37
37
|
}
|
|
38
|
-
getFormat(key) {
|
|
39
|
-
return this.getAllFormat(key)[0];
|
|
38
|
+
getFormat(key, supportOutAttr = !1) {
|
|
39
|
+
return this.getAllFormat(key, supportOutAttr)[0];
|
|
40
40
|
}
|
|
41
|
-
getAllFormat(key) {
|
|
41
|
+
getAllFormat(key, supportOutAttr = !1) {
|
|
42
|
+
var _a, _b, _c, _d;
|
|
42
43
|
const valSet = new Set, minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx), maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
|
|
43
|
-
if (minCursorIdx === maxCursorIdx) return [ this._getFormat(key, minCursorIdx) ];
|
|
44
|
+
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) ];
|
|
44
45
|
for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
|
|
45
|
-
const val = this._getFormat(key, i);
|
|
46
|
+
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);
|
|
46
47
|
val && valSet.add(val);
|
|
47
48
|
}
|
|
48
49
|
return Array.from(valSet.values());
|
|
@@ -85,7 +86,7 @@ class RichTextEditPlugin {
|
|
|
85
86
|
const config = rt.attribute.textConfig;
|
|
86
87
|
this._formatTextCommand(payload, config, rt);
|
|
87
88
|
}, this.handleKeyDown = e => {
|
|
88
|
-
this.currRt && this.editing && (this.copyToClipboard(e) || this.
|
|
89
|
+
this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelectionKeyHandler(e) || this.directKeyHandler(e));
|
|
89
90
|
}, this.handleInput = (text, isComposing, cursorIdx, rt) => {
|
|
90
91
|
this.currRt && (this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.hideSelection(),
|
|
91
92
|
this.updateCbs.forEach((cb => cb("input", this))));
|
|
@@ -100,8 +101,9 @@ class RichTextEditPlugin {
|
|
|
100
101
|
}, this.handleFocusOut = () => {
|
|
101
102
|
throw new Error("不会走到这里 handleFocusOut");
|
|
102
103
|
}, this.handleMove = e => {
|
|
103
|
-
this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave
|
|
104
|
-
|
|
104
|
+
this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave, {
|
|
105
|
+
capture: !0
|
|
106
|
+
}), this.tryShowSelection(e, !1));
|
|
105
107
|
}, this.handleEnter = e => {
|
|
106
108
|
this.editing = !0, this.pluginService.stage.setCursor("text");
|
|
107
109
|
}, this.handleLeave = e => {
|
|
@@ -145,10 +147,17 @@ class RichTextEditPlugin {
|
|
|
145
147
|
idx > -1 && cbs.splice(idx, 1);
|
|
146
148
|
}
|
|
147
149
|
activate(context) {
|
|
148
|
-
this.pluginService = context, this.editModule = new edit_module_1.EditModule, context.stage.on("pointermove", this.handleMove
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
this.pluginService = context, this.editModule = new edit_module_1.EditModule, context.stage.on("pointermove", this.handleMove, {
|
|
151
|
+
capture: !0
|
|
152
|
+
}), context.stage.on("pointerdown", this.handlePointerDown, {
|
|
153
|
+
capture: !0
|
|
154
|
+
}), context.stage.on("pointerup", this.handlePointerUp, {
|
|
155
|
+
capture: !0
|
|
156
|
+
}), context.stage.on("pointerleave", this.handlePointerUp, {
|
|
157
|
+
capture: !0
|
|
158
|
+
}), context.stage.on("dblclick", this.handleDBLClick, {
|
|
159
|
+
capture: !0
|
|
160
|
+
}), application_1.application.global.addEventListener("keydown", this.handleKeyDown),
|
|
152
161
|
this.editModule.onInput(this.handleInput), this.editModule.onChange(this.handleChange),
|
|
153
162
|
this.editModule.onFocusOut(this.handleFocusOut);
|
|
154
163
|
}
|
|
@@ -179,18 +188,21 @@ class RichTextEditPlugin {
|
|
|
179
188
|
const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
|
|
180
189
|
this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this._tryShowSelection(pos, cache);
|
|
181
190
|
}
|
|
182
|
-
fullSelection(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return !1;
|
|
191
|
+
fullSelection() {
|
|
192
|
+
const currRt = this.currRt;
|
|
193
|
+
if (!currRt) return;
|
|
194
|
+
const cache = currRt.getFrameCache();
|
|
195
|
+
if (!cache) return;
|
|
196
|
+
const {lines: lines} = cache;
|
|
197
|
+
if (!lines.length || !lines[0].paragraphs.length) return;
|
|
198
|
+
const totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
|
|
199
|
+
this.selectionRange(-.1, totalCursorCount + .1);
|
|
192
200
|
}
|
|
193
|
-
|
|
201
|
+
fullSelectionKeyHandler(e) {
|
|
202
|
+
return !!(application_1.application.global.isMacOS() && e.metaKey && "a" === e.key || !application_1.application.global.isMacOS() && e.ctrlKey && "a" === e.key) && (this.fullSelection(),
|
|
203
|
+
e.preventDefault(), !0);
|
|
204
|
+
}
|
|
205
|
+
directKeyHandler(e) {
|
|
194
206
|
if ("ArrowUp" !== e.key && "ArrowDown" !== e.key && "ArrowLeft" !== e.key && "ArrowRight" !== e.key) return !1;
|
|
195
207
|
const cache = this.currRt.getFrameCache();
|
|
196
208
|
if (!cache) return !1;
|
|
@@ -230,7 +242,7 @@ class RichTextEditPlugin {
|
|
|
230
242
|
const placeholder = shadowRoot.getElementsByType("richtext")[0];
|
|
231
243
|
placeholder && shadowRoot.removeChild(placeholder);
|
|
232
244
|
}
|
|
233
|
-
const {textConfig: textConfig, editOptions: editOptions} = this.currRt.attribute;
|
|
245
|
+
const {textConfig: textConfig, editOptions: editOptions = {}} = this.currRt.attribute;
|
|
234
246
|
if (textConfig && textConfig.length) return;
|
|
235
247
|
if (!editOptions || !editOptions.placeholder) return;
|
|
236
248
|
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({}, (0,
|
|
@@ -242,38 +254,44 @@ class RichTextEditPlugin {
|
|
|
242
254
|
graphic_1.createRichText)(Object.assign(Object.assign({}, this.currRt.attribute), {
|
|
243
255
|
x: 0,
|
|
244
256
|
y: 0,
|
|
257
|
+
dx: -this.deltaX,
|
|
258
|
+
dy: -this.deltaY,
|
|
245
259
|
angle: 0,
|
|
246
|
-
_debug_bounds: !1,
|
|
247
260
|
textConfig: [ textConfigItem ]
|
|
248
261
|
})), shadow.add(this.shadowPlaceHolder);
|
|
249
262
|
}
|
|
263
|
+
getRichTextAABBBounds(rt) {
|
|
264
|
+
const {attribute: attribute} = rt;
|
|
265
|
+
return attribute.textConfig.length ? rt.AABBBounds : (0, graphic_1.getRichTextBounds)(Object.assign(Object.assign({}, this.shadowPlaceHolder.attribute), {
|
|
266
|
+
x: attribute.x,
|
|
267
|
+
y: attribute.y,
|
|
268
|
+
textAlign: attribute.textAlign,
|
|
269
|
+
boundsMode: "accurate"
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
250
272
|
tryShowInputBounds() {
|
|
251
273
|
if (!this.currRt || !this.focusing) return;
|
|
252
274
|
const {editOptions: editOptions = {}} = this.currRt.attribute, {boundsStrokeWhenInput: boundsStrokeWhenInput} = editOptions;
|
|
253
275
|
if (!editOptions || !boundsStrokeWhenInput) return;
|
|
254
|
-
const
|
|
255
|
-
let h = b.height();
|
|
256
|
-
if (!attribute.textConfig.length && this.editLine) {
|
|
257
|
-
const {points: points} = this.editLine.attribute;
|
|
258
|
-
h = points[1].y - points[0].y;
|
|
259
|
-
}
|
|
276
|
+
const b = this.getRichTextAABBBounds(this.currRt), height = b.height(), width = b.width();
|
|
260
277
|
this.shadowBounds = this.shadowBounds || (0, graphic_1.createRect)({}), this.shadowBounds.setAttributes({
|
|
261
278
|
x: 0,
|
|
262
279
|
y: 0,
|
|
263
|
-
width:
|
|
264
|
-
height:
|
|
280
|
+
width: width,
|
|
281
|
+
height: height,
|
|
265
282
|
fill: !1,
|
|
266
283
|
stroke: boundsStrokeWhenInput,
|
|
267
284
|
lineWidth: 1,
|
|
268
285
|
zIndex: -1
|
|
269
286
|
});
|
|
270
|
-
this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds()
|
|
287
|
+
this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds(),
|
|
288
|
+
this.offsetShadowRoot();
|
|
271
289
|
}
|
|
272
290
|
trySyncPlaceholderToTextConfig() {
|
|
273
291
|
if (!this.currRt) return;
|
|
274
292
|
const {textConfig: textConfig, editOptions: editOptions} = this.currRt.attribute;
|
|
275
293
|
if (textConfig && textConfig.length) return;
|
|
276
|
-
if (!editOptions
|
|
294
|
+
if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceholderToTextConfig)) return;
|
|
277
295
|
const {placeholder: placeholder} = editOptions;
|
|
278
296
|
this.currRt.setAttributes({
|
|
279
297
|
textConfig: [ Object.assign({
|
|
@@ -282,9 +300,20 @@ class RichTextEditPlugin {
|
|
|
282
300
|
});
|
|
283
301
|
}
|
|
284
302
|
deactivate(context) {
|
|
285
|
-
context.stage.off("pointermove", this.handleMove
|
|
286
|
-
|
|
287
|
-
context.stage.off("
|
|
303
|
+
context.stage.off("pointermove", this.handleMove, {
|
|
304
|
+
capture: !0
|
|
305
|
+
}), context.stage.off("pointerdown", this.handlePointerDown, {
|
|
306
|
+
capture: !0
|
|
307
|
+
}), context.stage.off("pointerup", this.handlePointerUp, {
|
|
308
|
+
capture: !0
|
|
309
|
+
}), context.stage.off("pointerleave", this.handlePointerUp, {
|
|
310
|
+
capture: !0
|
|
311
|
+
}), context.stage.off("dblclick", this.handleDBLClick, {
|
|
312
|
+
capture: !0
|
|
313
|
+
}), application_1.application.global.addEventListener("keydown", this.handleKeyDown);
|
|
314
|
+
}
|
|
315
|
+
stopPropagation(e) {
|
|
316
|
+
e.stopPropagation();
|
|
288
317
|
}
|
|
289
318
|
onFocus(e, data) {
|
|
290
319
|
this.updateCbs && this.updateCbs.forEach((cb => cb("beforeOnfocus", this))), this.deFocus(!1),
|
|
@@ -293,48 +322,59 @@ class RichTextEditPlugin {
|
|
|
293
322
|
if (!target || "richtext" !== target.type) return;
|
|
294
323
|
this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
|
|
295
324
|
const shadowRoot = this.getShadow(target), cache = target.getFrameCache();
|
|
296
|
-
if (cache)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
height: 0
|
|
315
|
-
});
|
|
316
|
-
this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
|
|
317
|
-
}
|
|
318
|
-
if (data = data || this.computedCursorPosByEvent(e, cache)) {
|
|
319
|
-
const {x: x, y1: y1, y2: y2, cursorIndex: cursorIndex} = data;
|
|
320
|
-
this.startCursorPos = {
|
|
321
|
-
x: x,
|
|
322
|
-
y: (y1 + y2) / 2
|
|
323
|
-
}, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
|
|
324
|
-
this.setCursorAndTextArea(x, y1, y2, target);
|
|
325
|
-
} else {
|
|
326
|
-
const x = 0, y1 = 0, y2 = (0, graphic_1.getRichTextBounds)(Object.assign(Object.assign({}, target.attribute), {
|
|
327
|
-
textConfig: [ {
|
|
328
|
-
text: "a"
|
|
329
|
-
} ]
|
|
330
|
-
})).height();
|
|
331
|
-
this.startCursorPos = {
|
|
332
|
-
x: x,
|
|
333
|
-
y: (y1 + y2) / 2
|
|
334
|
-
}, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
|
|
335
|
-
}
|
|
336
|
-
this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
|
|
325
|
+
if (!cache) return;
|
|
326
|
+
const {editOptions: editOptions = {}} = this.currRt.attribute;
|
|
327
|
+
if (editOptions.stopPropagation && target.addEventListener("*", this.stopPropagation),
|
|
328
|
+
this.offsetShadowRoot(target), !this.editLine) {
|
|
329
|
+
const line = (0, graphic_1.createLine)({
|
|
330
|
+
x: 0,
|
|
331
|
+
y: 0,
|
|
332
|
+
lineWidth: 1,
|
|
333
|
+
stroke: "black"
|
|
334
|
+
});
|
|
335
|
+
this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
|
|
336
|
+
const g = (0, graphic_1.createGroup)({
|
|
337
|
+
x: 0,
|
|
338
|
+
y: 0,
|
|
339
|
+
width: 0,
|
|
340
|
+
height: 0
|
|
341
|
+
});
|
|
342
|
+
this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
|
|
337
343
|
}
|
|
344
|
+
if (data = data || this.computedCursorPosByEvent(e, cache)) {
|
|
345
|
+
const {x: x, y1: y1, y2: y2, cursorIndex: cursorIndex} = data;
|
|
346
|
+
this.startCursorPos = {
|
|
347
|
+
x: x,
|
|
348
|
+
y: (y1 + y2) / 2
|
|
349
|
+
}, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
|
|
350
|
+
this.setCursorAndTextArea(x, y1, y2, target);
|
|
351
|
+
} else {
|
|
352
|
+
const x = 0, y1 = 0, y2 = (0, graphic_1.getRichTextBounds)(Object.assign(Object.assign({}, target.attribute), {
|
|
353
|
+
textConfig: [ {
|
|
354
|
+
text: "a"
|
|
355
|
+
} ]
|
|
356
|
+
})).height();
|
|
357
|
+
this.startCursorPos = {
|
|
358
|
+
x: x,
|
|
359
|
+
y: (y1 + y2) / 2
|
|
360
|
+
}, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
|
|
361
|
+
}
|
|
362
|
+
this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
|
|
363
|
+
}
|
|
364
|
+
offsetShadowRoot(rt) {
|
|
365
|
+
if (!(rt = rt || this.currRt)) return;
|
|
366
|
+
const shadowRoot = this.getShadow(rt);
|
|
367
|
+
if (!shadowRoot) return;
|
|
368
|
+
const cache = rt.getFrameCache();
|
|
369
|
+
cache && (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
|
|
370
|
+
shadowRootIdx: 1,
|
|
371
|
+
pickable: !1,
|
|
372
|
+
x: this.deltaX,
|
|
373
|
+
y: this.deltaY
|
|
374
|
+
}), this.shadowPlaceHolder && this.shadowPlaceHolder.setAttributes({
|
|
375
|
+
dx: -this.deltaX,
|
|
376
|
+
dy: -this.deltaY
|
|
377
|
+
}));
|
|
338
378
|
}
|
|
339
379
|
offsetLineBgAndShadowBounds() {
|
|
340
380
|
const rt = this.currRt, {textBaseline: textBaseline} = rt.attribute;
|
|
@@ -358,6 +398,8 @@ class RichTextEditPlugin {
|
|
|
358
398
|
})));
|
|
359
399
|
const target = this.currRt;
|
|
360
400
|
if (!target) return;
|
|
401
|
+
const {editOptions: editOptions = {}} = target.attribute;
|
|
402
|
+
editOptions.stopPropagation && target.removeEventListener("*", this.stopPropagation),
|
|
361
403
|
trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
|
|
362
404
|
const currRt = this.currRt;
|
|
363
405
|
this.currRt = null, this.editLine && (this.editLine.parent && this.editLine.parent.removeChild(this.editLine),
|
|
@@ -516,7 +558,7 @@ class RichTextEditPlugin {
|
|
|
516
558
|
this.pluginService.stage.renderNextFrame();
|
|
517
559
|
}
|
|
518
560
|
computeGlobalDelta(cache) {
|
|
519
|
-
this.deltaX = 0, this.deltaY = 0;
|
|
561
|
+
this.deltaX = 0, this.deltaY = 0, 0 === cache.lines.length && this.shadowPlaceHolder && (cache = this.shadowPlaceHolder.getFrameCache());
|
|
520
562
|
const height = cache.height, actualHeight = cache.actualHeight, width = cache.lines.reduce(((w, item) => Math.max(w, item.actualWidth)), 0);
|
|
521
563
|
"center" === cache.globalAlign ? this.deltaX = -width / 2 : "right" === cache.globalAlign && (this.deltaX = -width),
|
|
522
564
|
"middle" === cache.verticalDirection ? this.deltaY = height / 2 - actualHeight / 2 : "bottom" === cache.verticalDirection && (this.deltaY = height - actualHeight);
|
|
@@ -555,7 +597,8 @@ class RichTextEditPlugin {
|
|
|
555
597
|
y: y1
|
|
556
598
|
}, out);
|
|
557
599
|
const {left: left, top: top} = this.pluginService.stage.window.getBoundingClientRect();
|
|
558
|
-
out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.
|
|
600
|
+
out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot(),
|
|
601
|
+
this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
|
|
559
602
|
}
|
|
560
603
|
computedCursorPosByEvent(e, cache) {
|
|
561
604
|
const p1 = this.getEventPosition(e), lineInfo = this.getLineByPoint(cache, p1);
|