Formatting: Expand exceptions to multi-newline ops, multiple ops

This commit is contained in:
Scott Nonnenberg 2023-06-08 14:50:44 -07:00 committed by GitHub
parent 3ac2fb4ce4
commit 6e1916030d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 8 deletions

View file

@ -13,7 +13,7 @@ import type {
} from '../types/BodyRange';
import { BodyRange } from '../types/BodyRange';
import type { MentionBlot } from './mentions/blot';
import { QuillFormattingStyle } from './formatting/menu';
import { isNewlineOnlyOp, QuillFormattingStyle } from './formatting/menu';
import { isNotNil } from '../util/isNotNil';
export type MentionBlotValue = {
@ -165,8 +165,8 @@ export const getTextAndRangesFromOps = (
};
const preTrimText = ops.reduce((acc, op) => {
// We special-case single-newline ops because Quill doesn't apply styles to them
if (op.insert === '\n') {
// We special-case all-newline ops because Quill doesn't apply styles to them
if (isNewlineOnlyOp(op)) {
return acc + op.insert;
}