CompositionArea: On paste, create emoji Op only if we have data
This commit is contained in:
parent
dc9caa0a99
commit
2532e8902a
1 changed files with 10 additions and 6 deletions
|
@ -16,6 +16,7 @@ import type { MentionBlot } from './mentions/blot';
|
|||
import { isNewlineOnlyOp, QuillFormattingStyle } from './formatting/menu';
|
||||
import { isNotNil } from '../util/isNotNil';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import { emojiToData } from '../components/emoji/lib';
|
||||
|
||||
export type MentionBlotValue = {
|
||||
aci: AciString;
|
||||
|
@ -403,12 +404,15 @@ export const insertEmojiOps = (
|
|||
// eslint-disable-next-line no-cond-assign
|
||||
while ((match = re.exec(text))) {
|
||||
const [emoji] = match;
|
||||
ops.push({ insert: text.slice(index, match.index), attributes });
|
||||
ops.push({
|
||||
insert: { emoji },
|
||||
attributes: { ...existingAttributes, ...attributes },
|
||||
});
|
||||
index = match.index + emoji.length;
|
||||
const emojiData = emojiToData(emoji);
|
||||
if (emojiData) {
|
||||
ops.push({ insert: text.slice(index, match.index), attributes });
|
||||
ops.push({
|
||||
insert: { emoji },
|
||||
attributes: { ...existingAttributes, ...attributes },
|
||||
});
|
||||
index = match.index + emoji.length;
|
||||
}
|
||||
}
|
||||
|
||||
ops.push({ insert: text.slice(index, text.length), attributes });
|
||||
|
|
Loading…
Reference in a new issue