Formatting: Expand exceptions to multi-newline ops, multiple ops
This commit is contained in:
parent
3ac2fb4ce4
commit
6e1916030d
3 changed files with 54 additions and 8 deletions
|
@ -125,6 +125,43 @@ describe('getTextAndRangesFromOps', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('handles trimming with no-formatting single- and multi-newline ops', () => {
|
||||
const ops = [
|
||||
{
|
||||
insert: 'line1',
|
||||
attributes: { bold: true },
|
||||
},
|
||||
// quill doesn't put formatting on all-newline ops
|
||||
{
|
||||
insert: '\n',
|
||||
},
|
||||
{
|
||||
insert: 'line2',
|
||||
attributes: { bold: true },
|
||||
},
|
||||
{
|
||||
insert: '\n\n',
|
||||
},
|
||||
{
|
||||
insert: 'line4',
|
||||
attributes: { bold: true },
|
||||
},
|
||||
{
|
||||
insert: '\n\n',
|
||||
},
|
||||
];
|
||||
const { text, bodyRanges } = getTextAndRangesFromOps(ops);
|
||||
assert.equal(text, 'line1\nline2\n\nline4');
|
||||
assert.equal(bodyRanges.length, 1);
|
||||
assert.deepEqual(bodyRanges, [
|
||||
{
|
||||
start: 0,
|
||||
length: 18,
|
||||
style: BodyRange.Style.BOLD,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('handles trimming at the end of the message', () => {
|
||||
const ops = [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue