Skip to content

Commit

Permalink
Dont include attributes in embed retains
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest committed May 3, 2023
1 parent adaa95e commit 63aafba
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/types/YText.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 63aafba

Please sign in to comment.