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 { isNewlineOnlyOp, QuillFormattingStyle } from './formatting/menu';
|
||||||
import { isNotNil } from '../util/isNotNil';
|
import { isNotNil } from '../util/isNotNil';
|
||||||
import type { AciString } from '../types/ServiceId';
|
import type { AciString } from '../types/ServiceId';
|
||||||
|
import { emojiToData } from '../components/emoji/lib';
|
||||||
|
|
||||||
export type MentionBlotValue = {
|
export type MentionBlotValue = {
|
||||||
aci: AciString;
|
aci: AciString;
|
||||||
|
@ -403,12 +404,15 @@ export const insertEmojiOps = (
|
||||||
// eslint-disable-next-line no-cond-assign
|
// eslint-disable-next-line no-cond-assign
|
||||||
while ((match = re.exec(text))) {
|
while ((match = re.exec(text))) {
|
||||||
const [emoji] = match;
|
const [emoji] = match;
|
||||||
ops.push({ insert: text.slice(index, match.index), attributes });
|
const emojiData = emojiToData(emoji);
|
||||||
ops.push({
|
if (emojiData) {
|
||||||
insert: { emoji },
|
ops.push({ insert: text.slice(index, match.index), attributes });
|
||||||
attributes: { ...existingAttributes, ...attributes },
|
ops.push({
|
||||||
});
|
insert: { emoji },
|
||||||
index = match.index + emoji.length;
|
attributes: { ...existingAttributes, ...attributes },
|
||||||
|
});
|
||||||
|
index = match.index + emoji.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ops.push({ insert: text.slice(index, text.length), attributes });
|
ops.push({ insert: text.slice(index, text.length), attributes });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue