Fix: emojis
This commit is contained in:
parent
4416c56884
commit
9567a6ddf9
|
@ -50,6 +50,10 @@ function customEmoji() {
|
||||||
emojiList('home')
|
emojiList('home')
|
||||||
}
|
}
|
||||||
function defEmoji(target) {
|
function defEmoji(target) {
|
||||||
|
var selin = $("#textarea").prop('selectionStart');
|
||||||
|
if (!selin) {
|
||||||
|
selin = 0;
|
||||||
|
}
|
||||||
var emojiraw = newpack.filter(function (item, index) {
|
var emojiraw = newpack.filter(function (item, index) {
|
||||||
if (item.short_name == target) return true;
|
if (item.short_name == target) return true;
|
||||||
});
|
});
|
||||||
|
@ -60,22 +64,11 @@ function defEmoji(target) {
|
||||||
emoji = twemoji.convert.fromCodePoint(hex[0]);
|
emoji = twemoji.convert.fromCodePoint(hex[0]);
|
||||||
}
|
}
|
||||||
var now = $("#textarea").val();
|
var now = $("#textarea").val();
|
||||||
var selin = localStorage.getItem("cursor");
|
|
||||||
var now = $("#textarea").val();
|
|
||||||
if (selin > 0) {
|
|
||||||
var before = now.substr(0, selin);
|
var before = now.substr(0, selin);
|
||||||
var after = now.substr(selin, now.length);
|
var after = now.substr(selin, now.length);
|
||||||
newt = before + emoji + after;
|
newt = before + emoji + after;
|
||||||
} else {
|
|
||||||
newt = emoji + now;
|
|
||||||
}
|
|
||||||
$("#textarea").val(newt);
|
$("#textarea").val(newt);
|
||||||
$("#textarea").focus();
|
$("#textarea").focus();
|
||||||
var selin = $("#textarea").prop('selectionStart');
|
|
||||||
if (!selin) {
|
|
||||||
selin = 0;
|
|
||||||
}
|
|
||||||
localStorage.setItem("cursor", selin);
|
|
||||||
}
|
}
|
||||||
function faicon() {
|
function faicon() {
|
||||||
var json = faicons;
|
var json = faicons;
|
||||||
|
|
|
@ -10,8 +10,6 @@ function emojiToggle(reaction) {
|
||||||
if (!selin) {
|
if (!selin) {
|
||||||
selin = 0;
|
selin = 0;
|
||||||
}
|
}
|
||||||
localStorage.setItem("cursor", selin);
|
|
||||||
|
|
||||||
if ($("#emoji").hasClass("hide")) {
|
if ($("#emoji").hasClass("hide")) {
|
||||||
$("#emoji").removeClass("hide")
|
$("#emoji").removeClass("hide")
|
||||||
$("#right-side").show()
|
$("#right-side").show()
|
||||||
|
@ -173,35 +171,31 @@ function emojiList(target, reaction) {
|
||||||
//絵文字など様々なものをテキストボックスに挿入
|
//絵文字など様々なものをテキストボックスに挿入
|
||||||
function emojiInsert(code, del) {
|
function emojiInsert(code, del) {
|
||||||
var now = $("#textarea").val();
|
var now = $("#textarea").val();
|
||||||
var selin = localStorage.getItem("cursor");
|
var selin = $("#textarea").prop('selectionStart');
|
||||||
if (localStorage.getItem("emoji-zero-width") == "yes") {
|
if (localStorage.getItem("emoji-zero-width") == "yes") {
|
||||||
var brank = "";
|
var blank = "";
|
||||||
} else {
|
} else {
|
||||||
var brank = " ";
|
var blank = " ";
|
||||||
}
|
}
|
||||||
var now = $("#textarea").val();
|
|
||||||
if (selin > 0) {
|
|
||||||
var before = now.substr(0, selin);
|
var before = now.substr(0, selin);
|
||||||
var after = now.substr(selin, now.length);
|
if (before.slice(-1) != " ") {
|
||||||
newt = before + brank + code + brank + after;
|
before = before + blank
|
||||||
} else {
|
|
||||||
newt = code + brank;
|
|
||||||
}
|
}
|
||||||
|
var after = now.substr(selin, now.length);
|
||||||
|
if (after.slice(-1) != " ") {
|
||||||
|
after = blank + after
|
||||||
|
}
|
||||||
|
newt = before + code + after;
|
||||||
if (!del) {
|
if (!del) {
|
||||||
$("#textarea").val(newt);
|
$("#textarea").val(newt);
|
||||||
//emoji();
|
//emoji();
|
||||||
} else {
|
} else {
|
||||||
var regExp = new RegExp(del.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&"), "g");
|
var regExp = new RegExp(del.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&"), "g");
|
||||||
var now = now.replace(regExp, "");
|
var now = now.replace(regExp, "");
|
||||||
$("#textarea").val(now + brank + code);
|
$("#textarea").val(now + blank + code);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#textarea").focus();
|
$("#textarea").focus();
|
||||||
var selin = $("#textarea").prop('selectionStart');
|
|
||||||
if (!selin) {
|
|
||||||
selin = 0;
|
|
||||||
}
|
|
||||||
localStorage.setItem("cursor", selin);
|
|
||||||
}
|
}
|
||||||
//改行挿入
|
//改行挿入
|
||||||
function brInsert(code) {
|
function brInsert(code) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ var oldSuggest;
|
||||||
var suggest;
|
var suggest;
|
||||||
|
|
||||||
input.addEventListener("focus", function () {
|
input.addEventListener("focus", function () {
|
||||||
|
localStorage.removeItem("cursor");
|
||||||
var acct_id = $("#post-acct-sel").val();
|
var acct_id = $("#post-acct-sel").val();
|
||||||
$("#suggest").html("");
|
$("#suggest").html("");
|
||||||
window.clearInterval(timer);
|
window.clearInterval(timer);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user