mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-11 21:28:12 +09:00
サロゲートペアを字数にカウントしないようにする (#2661)
* Update post-form.vue * Update messaging-message.ts * Update post-form.vue * Update note.ts * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#issuecomment-419579444 * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#issuecomment-419579444 * Update messaging-message.ts refs: https://github.com/syuilo/misskey/pull/2661#issuecomment-419579444 * Update note.ts refs: https://github.com/syuilo/misskey/pull/2661#issuecomment-419579444 * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#discussion_r216175581 * Update post-form.vue * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#discussion_r216242002 * Update post-form.vue refs: https://github.com/syuilo/misskey/pull/2661#discussion_r216242105
This commit is contained in:
parent
f73fbaf1a8
commit
042826af04
@ -45,7 +45,7 @@
|
|||||||
<span v-if="visibility === 'specified'">%fa:envelope%</span>
|
<span v-if="visibility === 'specified'">%fa:envelope%</span>
|
||||||
<span v-if="visibility === 'private'">%fa:lock%</span>
|
<span v-if="visibility === 'private'">%fa:lock%</span>
|
||||||
</button>
|
</button>
|
||||||
<p class="text-count" :class="{ over: text.length > 1000 }">{{ 1000 - text.length }}</p>
|
<p class="text-count" :class="{ over: this.trimmedLength(text) > 1000 }">{{ 1000 - this.trimmedLength(text) }}</p>
|
||||||
<button :class="{ posting }" class="submit" :disabled="!canPost" @click="post">
|
<button :class="{ posting }" class="submit" :disabled="!canPost" @click="post">
|
||||||
{{ posting ? '%i18n:@posting%' : submitText }}<mk-ellipsis v-if="posting"/>
|
{{ posting ? '%i18n:@posting%' : submitText }}<mk-ellipsis v-if="posting"/>
|
||||||
</button>
|
</button>
|
||||||
@ -63,6 +63,7 @@ import MkVisibilityChooser from '../../../common/views/components/visibility-cho
|
|||||||
import parse from '../../../../../mfm/parse';
|
import parse from '../../../../../mfm/parse';
|
||||||
import { host } from '../../../config';
|
import { host } from '../../../config';
|
||||||
import { erase } from '../../../../../prelude/array';
|
import { erase } from '../../../../../prelude/array';
|
||||||
|
import { length } from 'stringz';
|
||||||
import parseAcct from '../../../../../misc/acct/parse';
|
import parseAcct from '../../../../../misc/acct/parse';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
@ -147,7 +148,7 @@ export default Vue.extend({
|
|||||||
canPost(): boolean {
|
canPost(): boolean {
|
||||||
return !this.posting &&
|
return !this.posting &&
|
||||||
(1 <= this.text.length || 1 <= this.files.length || this.poll || this.renote) &&
|
(1 <= this.text.length || 1 <= this.files.length || this.poll || this.renote) &&
|
||||||
(this.text.trim().length <= 1000);
|
(length(this.text.trim()) <= 1000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -199,6 +200,10 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
trimmedLength(text: string) {
|
||||||
|
return length(text.trim());
|
||||||
|
},
|
||||||
|
|
||||||
addTag(tag: string) {
|
addTag(tag: string) {
|
||||||
insertTextAtCursor(this.$refs.text, ` #${tag} `);
|
insertTextAtCursor(this.$refs.text, ` #${tag} `);
|
||||||
},
|
},
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<button class="cancel" @click="cancel">%fa:times%</button>
|
<button class="cancel" @click="cancel">%fa:times%</button>
|
||||||
<div>
|
<div>
|
||||||
<span class="text-count" :class="{ over: text.length > 1000 }">{{ 1000 - text.length }}</span>
|
<span class="text-count" :class="{ over: trimmedLength(text) > 1000 }">{{ 1000 - trimmedLength(text) }}</span>
|
||||||
<span class="geo" v-if="geo">%fa:map-marker-alt%</span>
|
<span class="geo" v-if="geo">%fa:map-marker-alt%</span>
|
||||||
<button class="submit" :disabled="!canPost" @click="post">{{ submitText }}</button>
|
<button class="submit" :disabled="!canPost" @click="post">{{ submitText }}</button>
|
||||||
</div>
|
</div>
|
||||||
@ -60,6 +60,7 @@ import getFace from '../../../common/scripts/get-face';
|
|||||||
import parse from '../../../../../mfm/parse';
|
import parse from '../../../../../mfm/parse';
|
||||||
import { host } from '../../../config';
|
import { host } from '../../../config';
|
||||||
import { erase } from '../../../../../prelude/array';
|
import { erase } from '../../../../../prelude/array';
|
||||||
|
import { length } from 'stringz';
|
||||||
import parseAcct from '../../../../../misc/acct/parse';
|
import parseAcct from '../../../../../misc/acct/parse';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
@ -180,6 +181,10 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
trimmedLength(text: string) {
|
||||||
|
return length(text.trim());
|
||||||
|
},
|
||||||
|
|
||||||
addTag(tag: string) {
|
addTag(tag: string) {
|
||||||
insertTextAtCursor(this.$refs.text, ` #${tag} `);
|
insertTextAtCursor(this.$refs.text, ` #${tag} `);
|
||||||
},
|
},
|
||||||
|
@ -4,6 +4,7 @@ import { pack as packUser } from './user';
|
|||||||
import { pack as packFile } from './drive-file';
|
import { pack as packFile } from './drive-file';
|
||||||
import db from '../db/mongodb';
|
import db from '../db/mongodb';
|
||||||
import MessagingHistory, { deleteMessagingHistory } from './messaging-history';
|
import MessagingHistory, { deleteMessagingHistory } from './messaging-history';
|
||||||
|
import { length } from 'stringz';
|
||||||
|
|
||||||
const MessagingMessage = db.get<IMessagingMessage>('messagingMessages');
|
const MessagingMessage = db.get<IMessagingMessage>('messagingMessages');
|
||||||
export default MessagingMessage;
|
export default MessagingMessage;
|
||||||
@ -19,7 +20,7 @@ export interface IMessagingMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isValidText(text: string): boolean {
|
export function isValidText(text: string): boolean {
|
||||||
return text.length <= 1000 && text.trim() != '';
|
return length(text.trim()) <= 1000 && text.trim() != '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,7 @@ import * as mongo from 'mongodb';
|
|||||||
const deepcopy = require('deepcopy');
|
const deepcopy = require('deepcopy');
|
||||||
import rap from '@prezzemolo/rap';
|
import rap from '@prezzemolo/rap';
|
||||||
import db from '../db/mongodb';
|
import db from '../db/mongodb';
|
||||||
|
import { length } from 'stringz';
|
||||||
import { IUser, pack as packUser } from './user';
|
import { IUser, pack as packUser } from './user';
|
||||||
import { pack as packApp } from './app';
|
import { pack as packApp } from './app';
|
||||||
import PollVote, { deletePollVote } from './poll-vote';
|
import PollVote, { deletePollVote } from './poll-vote';
|
||||||
@ -24,11 +25,11 @@ Note.createIndex({
|
|||||||
export default Note;
|
export default Note;
|
||||||
|
|
||||||
export function isValidText(text: string): boolean {
|
export function isValidText(text: string): boolean {
|
||||||
return text.length <= 1000 && text.trim() != '';
|
return length(text.trim()) <= 1000 && text.trim() != '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isValidCw(text: string): boolean {
|
export function isValidCw(text: string): boolean {
|
||||||
return text.length <= 100;
|
return length(text.trim()) <= 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type INote = {
|
export type INote = {
|
||||||
|
Loading…
Reference in New Issue
Block a user