FIX: backport caret moves to a wrong position when uploading an image via toolbar (#15865)
* FIX: Caret moves to a wrong position when uploading an image via toolbar * Skip the test
This commit is contained in:
parent
0674d07cdf
commit
2c8f62e271
|
@ -477,7 +477,7 @@ export default Component.extend(TextareaTextManipulation, {
|
|||
key: "#",
|
||||
afterComplete: (value) => {
|
||||
this.set("value", value);
|
||||
return this._focusTextArea();
|
||||
schedule("afterRender", this, this._focusTextArea);
|
||||
},
|
||||
transformComplete: (obj) => {
|
||||
return obj.text;
|
||||
|
@ -504,7 +504,7 @@ export default Component.extend(TextareaTextManipulation, {
|
|||
key: ":",
|
||||
afterComplete: (text) => {
|
||||
this.set("value", text);
|
||||
this._focusTextArea();
|
||||
schedule("afterRender", this, this._focusTextArea);
|
||||
},
|
||||
|
||||
onKeyUp: (text, cp) => {
|
||||
|
|
|
@ -25,18 +25,16 @@ export default Mixin.create({
|
|||
|
||||
// ensures textarea scroll position is correct
|
||||
_focusTextArea() {
|
||||
schedule("afterRender", () => {
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||
return;
|
||||
}
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._textarea) {
|
||||
return;
|
||||
}
|
||||
if (!this._textarea) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._textarea.blur();
|
||||
this._textarea.focus();
|
||||
});
|
||||
this._textarea.blur();
|
||||
this._textarea.focus();
|
||||
},
|
||||
|
||||
_insertBlock(text) {
|
||||
|
@ -171,7 +169,7 @@ export default Mixin.create({
|
|||
this._$textarea.prop("selectionStart", (pre + text).length + 2);
|
||||
this._$textarea.prop("selectionEnd", (pre + text).length + 2);
|
||||
|
||||
this._focusTextArea();
|
||||
schedule("afterRender", this, this._focusTextArea);
|
||||
},
|
||||
|
||||
_addText(sel, text, options) {
|
||||
|
|
|
@ -316,6 +316,30 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
|
|||
appEvents.trigger("composer:add-files", image);
|
||||
});
|
||||
|
||||
skip("should place cursor properly after inserting a placeholder", async function (assert) {
|
||||
const appEvents = loggedInUser().appEvents;
|
||||
const done = assert.async();
|
||||
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
await fillIn(".d-editor-input", "The image:\ntext after image");
|
||||
const input = query(".d-editor-input");
|
||||
input.selectionStart = 10;
|
||||
input.selectionEnd = 10;
|
||||
|
||||
appEvents.on("composer:all-uploads-complete", () => {
|
||||
// after uploading we have this in the textarea:
|
||||
// "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\ntext after image"
|
||||
// cursor should be just before "text after image":
|
||||
assert.equal(input.selectionStart, 76);
|
||||
assert.equal(input.selectionEnd, 76);
|
||||
done();
|
||||
});
|
||||
|
||||
const image = createFile("avatar.png");
|
||||
appEvents.trigger("composer:add-files", image);
|
||||
});
|
||||
|
||||
test("should be able to paste a table with files and not upload the files", async function (assert) {
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
|
|
Loading…
Reference in New Issue