From 63aafba52b61f1950f1078b7887296c05c7fbdce Mon Sep 17 00:00:00 2001 From: Ernest Date: Wed, 3 May 2023 11:49:10 -0700 Subject: [PATCH] Dont include attributes in embed retains --- src/types/YText.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/types/YText.js b/src/types/YText.js index 8f4f0b60..68fcecf0 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -625,6 +625,10 @@ export class YTextEvent extends YEvent { */ let insert = '' let retain = 0 + /** + * @type {string?} + */ + let retainType = null; let deleteLen = 0 const addOp = () => { if (action !== null) { @@ -656,8 +660,10 @@ export class YTextEvent extends YEvent { case 'retain': if (retain > 0) { op = { retain } - if (!object.isEmpty(attributes)) { - op.attributes = object.assign({}, attributes) + if (retainType === 'ContentString') { + if (!object.isEmpty(attributes)) { + op.attributes = object.assign({}, attributes) + } } } retain = 0 @@ -685,9 +691,10 @@ export class YTextEvent extends YEvent { } deleteLen += 1 } else if (!item.deleted) { - if (action !== 'retain') { + if (action !== 'retain' || retainType !== 'ContentEmbed') { addOp() action = 'retain' + retainType = 'ContentEmbed' } retain += 1 } @@ -708,9 +715,10 @@ export class YTextEvent extends YEvent { } deleteLen += item.length } else if (!item.deleted) { - if (action !== 'retain') { + if (action !== 'retain' || retainType !== 'ContentString') { addOp() action = 'retain' + retainType = 'ContentString' } retain += item.length }