getTextAndRangesFromOps: Don't trim leading whitespace if monospace
This commit is contained in:
parent
61b4558140
commit
092936b69d
2 changed files with 52 additions and 2 deletions
|
@ -224,6 +224,42 @@ describe('getTextAndRangesFromOps', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('does not trim at beginning of the message if monospace', () => {
|
||||
const ops = [
|
||||
{
|
||||
insert: ' ',
|
||||
},
|
||||
{
|
||||
insert: ' Text with leading ',
|
||||
attributes: { monospace: true },
|
||||
},
|
||||
{
|
||||
insert: 'whitespace!!',
|
||||
attributes: { bold: true, italic: true },
|
||||
},
|
||||
];
|
||||
const { text, bodyRanges } = getTextAndRangesFromOps(ops);
|
||||
assert.equal(text, ' Text with leading whitespace!!');
|
||||
assert.equal(bodyRanges.length, 3);
|
||||
assert.deepEqual(bodyRanges, [
|
||||
{
|
||||
start: 0,
|
||||
length: 20,
|
||||
style: BodyRange.Style.MONOSPACE,
|
||||
},
|
||||
{
|
||||
start: 20,
|
||||
length: 12,
|
||||
style: BodyRange.Style.BOLD,
|
||||
},
|
||||
{
|
||||
start: 20,
|
||||
length: 12,
|
||||
style: BodyRange.Style.ITALIC,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('handles formatting of whitespace at beginning/ending of message', () => {
|
||||
const ops = [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue