mirror of
https://github.com/yjs/yjs.git
synced 2025-12-16 03:37:50 +01:00
handle another attribution edge case for formatting
This commit is contained in:
@@ -1075,13 +1075,13 @@ export class YText extends AbstractType {
|
|||||||
previousAttributes[key] = value
|
previousAttributes[key] = value
|
||||||
}
|
}
|
||||||
// # Update Attributions
|
// # Update Attributions
|
||||||
if (attribution != null) {
|
if (attribution != null || d.usedAttribution?.attributes?.[key] != null) {
|
||||||
/**
|
/**
|
||||||
* @type {import('../utils/Delta.js').Attribution}
|
* @type {import('../utils/Delta.js').Attribution}
|
||||||
*/
|
*/
|
||||||
const formattingAttribution = object.assign({}, d.usedAttribution)
|
const formattingAttribution = object.assign({}, d.usedAttribution)
|
||||||
const attributesChanged = /** @type {{ [key: string]: Array<any> }} */ (formattingAttribution.attributes = object.assign({}, formattingAttribution.attributes ?? {}))
|
const attributesChanged = /** @type {{ [key: string]: Array<any> }} */ (formattingAttribution.attributes = object.assign({}, formattingAttribution.attributes ?? {}))
|
||||||
if (value === null) {
|
if (value === null || attribution == null) {
|
||||||
delete attributesChanged[key]
|
delete attributesChanged[key]
|
||||||
} else {
|
} else {
|
||||||
const by = attributesChanged[key] = (attributesChanged[key]?.slice() ?? [])
|
const by = attributesChanged[key] = (attributesChanged[key]?.slice() ?? [])
|
||||||
@@ -1089,12 +1089,14 @@ export class YText extends AbstractType {
|
|||||||
const attributedAt = (c.deleted ? attribution.deletedAt : attribution.insertedAt)
|
const attributedAt = (c.deleted ? attribution.deletedAt : attribution.insertedAt)
|
||||||
if (attributedAt) formattingAttribution.attributedAt = attributedAt
|
if (attributedAt) formattingAttribution.attributedAt = attributedAt
|
||||||
}
|
}
|
||||||
if (object.isEmpty(attributesChanged)) {
|
if (attribution != null) {
|
||||||
d.useAttribution(null)
|
if (object.isEmpty(attributesChanged)) {
|
||||||
} else {
|
d.useAttribution(null)
|
||||||
const attributedAt = (c.deleted ? attribution.deletedAt : attribution.insertedAt)
|
} else {
|
||||||
if (attributedAt != null) formattingAttribution.attributedAt = attributedAt
|
const attributedAt = (c.deleted ? attribution.deletedAt : attribution.insertedAt)
|
||||||
d.useAttribution(formattingAttribution)
|
if (attributedAt != null) formattingAttribution.attributedAt = attributedAt
|
||||||
|
d.useAttribution(formattingAttribution)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user