mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Prepends whitespace when inserting via emoji picker
This commit is contained in:
parent
ee2473d7d5
commit
e7c3c10829
@ -912,7 +912,11 @@ export default Component.extend({
|
|||||||
const captures = selected.pre.match(/\B:(\w*)$/);
|
const captures = selected.pre.match(/\B:(\w*)$/);
|
||||||
|
|
||||||
if (_.isEmpty(captures)) {
|
if (_.isEmpty(captures)) {
|
||||||
this._addText(selected, `:${code}:`);
|
if (selected.pre.match(/\S$/)) {
|
||||||
|
this._addText(selected, ` :${code}:`);
|
||||||
|
} else {
|
||||||
|
this._addText(selected, `:${code}:`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let numOfRemovedChars = selected.pre.length - captures[1].length;
|
let numOfRemovedChars = selected.pre.length - captures[1].length;
|
||||||
selected.pre = selected.pre.slice(
|
selected.pre = selected.pre.slice(
|
||||||
|
@ -4,7 +4,7 @@ import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
|||||||
acceptance("EmojiPicker", {
|
acceptance("EmojiPicker", {
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
const store = Discourse.__container__.lookup("service:emojis-store");
|
const store = Discourse.__container__.lookup("service:emoji-store");
|
||||||
store.reset();
|
store.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -60,6 +60,36 @@ QUnit.skip("emoji picker triggers event when picking emoji", async assert => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test(
|
||||||
|
"emoji picker adds leading whitespace before emoji",
|
||||||
|
async assert => {
|
||||||
|
await visit("/t/internationalization-localization/280");
|
||||||
|
await click("#topic-footer-buttons .btn.create");
|
||||||
|
|
||||||
|
// Whitespace should be added on text
|
||||||
|
await fillIn(".d-editor-input", "This is a test input");
|
||||||
|
await click("button.emoji.btn");
|
||||||
|
await click(".emoji-picker button[title='grinning']");
|
||||||
|
assert.equal(
|
||||||
|
find(".d-editor-input").val(),
|
||||||
|
"This is a test input :grinning:",
|
||||||
|
"it adds the emoji code and a leading whitespace when there is text"
|
||||||
|
);
|
||||||
|
await click("button.emoji.btn");
|
||||||
|
|
||||||
|
// Whitespace should not be added on whitespace
|
||||||
|
await fillIn(".d-editor-input", "This is a test input ");
|
||||||
|
await click("button.emoji.btn");
|
||||||
|
await click(".emoji-picker button[title='grinning']");
|
||||||
|
assert.equal(
|
||||||
|
find(".d-editor-input").val(),
|
||||||
|
"This is a test input :grinning:",
|
||||||
|
"it adds the emoji code and no leading whitespace when user already entered whitespace"
|
||||||
|
);
|
||||||
|
await click("button.emoji.btn");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
QUnit.skip("emoji picker has a list of recently used emojis", async assert => {
|
QUnit.skip("emoji picker has a list of recently used emojis", async assert => {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
await click("#topic-footer-buttons .btn.create");
|
await click("#topic-footer-buttons .btn.create");
|
||||||
|
@ -618,7 +618,6 @@ testCase(`doesn't jump to bottom with long text`, async function(
|
|||||||
});
|
});
|
||||||
|
|
||||||
componentTest("emoji", {
|
componentTest("emoji", {
|
||||||
skip: true,
|
|
||||||
template: "{{d-editor value=value}}",
|
template: "{{d-editor value=value}}",
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
// Test adding a custom button
|
// Test adding a custom button
|
||||||
@ -641,7 +640,7 @@ componentTest("emoji", {
|
|||||||
await click(
|
await click(
|
||||||
'.emoji-picker .section[data-section="smileys_&_emotion"] button.emoji[title="grinning"]'
|
'.emoji-picker .section[data-section="smileys_&_emotion"] button.emoji[title="grinning"]'
|
||||||
);
|
);
|
||||||
assert.equal(this.value, "hello world.:grinning:");
|
assert.equal(this.value, "hello world. :grinning:");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user