mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-28 04:56:44 -06:00
Pari Plus emojiAutoSpacing
This commit is contained in:
parent
9cfc475b0e
commit
2c0297694c
6 changed files with 42 additions and 15 deletions
|
@ -1301,6 +1301,7 @@ enableMFMCheatsheet: "Enable MFM Cheatsheet in post form"
|
||||||
enableUndoClearPostForm: "Enable undo & clear button in post form"
|
enableUndoClearPostForm: "Enable undo & clear button in post form"
|
||||||
disableReactionsViewer: "Disable emoji reactions viewer"
|
disableReactionsViewer: "Disable emoji reactions viewer"
|
||||||
collapsedUnexpectedLangs: "Collapse notes using unexpected languages"
|
collapsedUnexpectedLangs: "Collapse notes using unexpected languages"
|
||||||
|
emojiAutoSpacing: "Automatically add spaces when inserting emoji"
|
||||||
autoSpacing: "Auto Spacing"
|
autoSpacing: "Auto Spacing"
|
||||||
autoSpacingDescription: "Adding spaces between CJK and English characters"
|
autoSpacingDescription: "Adding spaces between CJK and English characters"
|
||||||
performance: "Performance"
|
performance: "Performance"
|
||||||
|
|
|
@ -1308,6 +1308,7 @@ enableMFMCheatsheet: "在帖文编辑框中启用MFM Cheatsheet"
|
||||||
enableUndoClearPostForm: "在帖文编辑框中启用撤销/清空按钮"
|
enableUndoClearPostForm: "在帖文编辑框中启用撤销/清空按钮"
|
||||||
disableReactionsViewer: "禁用帖文表情回应显示"
|
disableReactionsViewer: "禁用帖文表情回应显示"
|
||||||
collapsedUnexpectedLangs: "折叠非期望语言的帖文"
|
collapsedUnexpectedLangs: "折叠非期望语言的帖文"
|
||||||
|
emojiAutoSpacing: "在插入 Emoji 时自动添加空格"
|
||||||
autoSpacing: "自动空格"
|
autoSpacing: "自动空格"
|
||||||
autoSpacingDescription: "在CJK字符和英文字符中添加空格"
|
autoSpacingDescription: "在CJK字符和英文字符中添加空格"
|
||||||
messageToFollower: "给关注者的消息"
|
messageToFollower: "给关注者的消息"
|
||||||
|
|
|
@ -1308,6 +1308,7 @@ enableMFMCheatsheet: "在貼文編輯框中啓用MFM Cheatsheet"
|
||||||
enableUndoClearPostForm: "在貼文編輯框中啓用撤回/清除按鈕"
|
enableUndoClearPostForm: "在貼文編輯框中啓用撤回/清除按鈕"
|
||||||
disableReactionsViewer: "禁用貼文表情回應顯示"
|
disableReactionsViewer: "禁用貼文表情回應顯示"
|
||||||
collapsedUnexpectedLangs: "省略顯示非期望語言的貼文"
|
collapsedUnexpectedLangs: "省略顯示非期望語言的貼文"
|
||||||
|
emojiAutoSpacing: "在插入 Emoji 時自動添加前後間距"
|
||||||
autoSpacing: "自動間距"
|
autoSpacing: "自動間距"
|
||||||
autoSpacingDescription: "在CJK字符和英文字符中添加間距"
|
autoSpacingDescription: "在CJK字符和英文字符中添加間距"
|
||||||
messageToFollower: "給追隨者的訊息"
|
messageToFollower: "給追隨者的訊息"
|
||||||
|
|
|
@ -999,14 +999,32 @@ async function insertEmoji(ev: MouseEvent) {
|
||||||
|
|
||||||
let pos = textareaEl.value?.selectionStart ?? 0;
|
let pos = textareaEl.value?.selectionStart ?? 0;
|
||||||
let posEnd = textareaEl.value?.selectionEnd ?? text.value.length;
|
let posEnd = textareaEl.value?.selectionEnd ?? text.value.length;
|
||||||
|
|
||||||
|
const addSpacing = (before: string, emoji: string, after: string) => {
|
||||||
|
let result = emoji;
|
||||||
|
const needSpaceBefore = before.length > 0 && !before.endsWith(' ');
|
||||||
|
const needSpaceAfter = after.length > 0 && !after.startsWith(' ');
|
||||||
|
|
||||||
|
if (needSpaceBefore) result = ' ' + result;
|
||||||
|
if (needSpaceAfter) result = result + ' ';
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
emojiPicker.show(
|
emojiPicker.show(
|
||||||
target as HTMLElement,
|
target as HTMLElement,
|
||||||
emoji => {
|
emoji => {
|
||||||
const textBefore = text.value.substring(0, pos);
|
const textBefore = text.value.substring(0, pos);
|
||||||
const textAfter = text.value.substring(posEnd);
|
const textAfter = text.value.substring(posEnd);
|
||||||
text.value = textBefore + emoji + textAfter;
|
|
||||||
pos += emoji.length;
|
const processedEmoji = defaultStore.state.emojiAutoSpacing
|
||||||
posEnd += emoji.length;
|
? addSpacing(textBefore, emoji, textAfter)
|
||||||
|
: emoji;
|
||||||
|
|
||||||
|
text.value = textBefore + processedEmoji + textAfter;
|
||||||
|
|
||||||
|
pos += processedEmoji.length;
|
||||||
|
posEnd += processedEmoji.length;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
textAreaReadOnly.value = false;
|
textAreaReadOnly.value = false;
|
||||||
|
|
|
@ -74,6 +74,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkSwitch v-model="collapseNotesRepliedTo">{{ i18n.ts.collapseNotesRepliedTo }}</MkSwitch>
|
<MkSwitch v-model="collapseNotesRepliedTo">{{ i18n.ts.collapseNotesRepliedTo }}</MkSwitch>
|
||||||
<MkSwitch v-model="disableReactionsViewer">{{ i18n.ts.disableReactionsViewer }}</MkSwitch>
|
<MkSwitch v-model="disableReactionsViewer">{{ i18n.ts.disableReactionsViewer }}</MkSwitch>
|
||||||
<MkSwitch v-model="collapsedUnexpectedLangs">{{ i18n.ts.collapsedUnexpectedLangs }}</MkSwitch>
|
<MkSwitch v-model="collapsedUnexpectedLangs">{{ i18n.ts.collapsedUnexpectedLangs }}</MkSwitch>
|
||||||
|
<MkSwitch v-model="emojiAutoSpacing">{{ i18n.ts.emojiAutoSpacing }}</MkSwitch>
|
||||||
<MkSelect v-model="autoSpacingBehaviour">
|
<MkSelect v-model="autoSpacingBehaviour">
|
||||||
<template #label>{{ i18n.ts.autoSpacing }}</template>
|
<template #label>{{ i18n.ts.autoSpacing }}</template>
|
||||||
<option :value="null">{{ i18n.ts.disabled }}</option>
|
<option :value="null">{{ i18n.ts.disabled }}</option>
|
||||||
|
@ -130,6 +131,7 @@ const autoSpacingBehaviour = computed(defaultStore.makeGetterSetter('autoSpacing
|
||||||
const collapseNotesRepliedTo = computed(defaultStore.makeGetterSetter('collapseNotesRepliedTo'));
|
const collapseNotesRepliedTo = computed(defaultStore.makeGetterSetter('collapseNotesRepliedTo'));
|
||||||
const disableReactionsViewer = computed(defaultStore.makeGetterSetter('disableReactionsViewer'));
|
const disableReactionsViewer = computed(defaultStore.makeGetterSetter('disableReactionsViewer'));
|
||||||
const collapsedUnexpectedLangs = computed(defaultStore.makeGetterSetter('collapsedUnexpectedLangs'));
|
const collapsedUnexpectedLangs = computed(defaultStore.makeGetterSetter('collapsedUnexpectedLangs'));
|
||||||
|
const emojiAutoSpacing = computed(defaultStore.makeGetterSetter('emojiAutoSpacing'));
|
||||||
|
|
||||||
definePageMetadata(() => ({
|
definePageMetadata(() => ({
|
||||||
title: 'Pari Plus!',
|
title: 'Pari Plus!',
|
||||||
|
|
|
@ -555,7 +555,11 @@ export const defaultStore = markRaw(new Storage('base', {
|
||||||
collapsedUnexpectedLangs: {
|
collapsedUnexpectedLangs: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: false,
|
default: false,
|
||||||
}
|
},
|
||||||
|
emojiAutoSpacing : {
|
||||||
|
where: 'device',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO: 他のタブと永続化されたstateを同期
|
// TODO: 他のタブと永続化されたstateを同期
|
||||||
|
|
Loading…
Reference in a new issue