This commit is contained in:
Kevin Jahns
2025-06-12 19:06:30 +02:00
parent 7e6a75fd1a
commit 0084ed1143

View File

@@ -944,7 +944,7 @@ export class YText extends AbstractType {
* that is not attributed. * that is not attributed.
* @type {import('../utils/Delta.js').FormattingAttributes} * @type {import('../utils/Delta.js').FormattingAttributes}
*/ */
let previousUnattributedAttributes = {} // contains previously known unattributed formatting const previousUnattributedAttributes = {} // contains previously known unattributed formatting
/** /**
* @type {import('../utils/Delta.js').FormattingAttributes} * @type {import('../utils/Delta.js').FormattingAttributes}
*/ */
@@ -1026,7 +1026,7 @@ export class YText extends AbstractType {
case ContentFormat: { case ContentFormat: {
const { key, value } = /** @type {ContentFormat} */ (c.content) const { key, value } = /** @type {ContentFormat} */ (c.content)
const currAttrVal = currentAttributes[key] ?? null const currAttrVal = currentAttributes[key] ?? null
if (attribution != null && (c.deleted || !previousUnattributedAttributes.hasOwnProperty(key))) { if (attribution != null && (c.deleted || !object.hasProperty(previousUnattributedAttributes, key))) {
previousUnattributedAttributes[key] = c.deleted ? value : currAttrVal previousUnattributedAttributes[key] = c.deleted ? value : currAttrVal
} }
// @todo write a function "updateCurrentAttributes" and "updateChangedAttributes" // @todo write a function "updateCurrentAttributes" and "updateChangedAttributes"
@@ -1088,13 +1088,12 @@ export class YText extends AbstractType {
previousAttributes[key] = value previousAttributes[key] = value
} }
// # Update Attributions // # Update Attributions
if (attribution != null || previousUnattributedAttributes.hasOwnProperty(key)) { if (attribution != null || object.hasProperty(previousUnattributedAttributes, key)) {
/** /**
* @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 changedAttributedAttributes = /** @type {{ [key: string]: Array<any> }} */ (formattingAttribution.attributes = object.assign({}, formattingAttribution.attributes ?? {})) const changedAttributedAttributes = /** @type {{ [key: string]: Array<any> }} */ (formattingAttribution.attributes = object.assign({}, formattingAttribution.attributes ?? {}))
if (attribution == null || equalAttrs(previousUnattributedAttributes[key], currentAttributes[key] ?? null)) { if (attribution == null || equalAttrs(previousUnattributedAttributes[key], currentAttributes[key] ?? null)) {
// an unattributed formatting attribute was found or an attributed formatting // an unattributed formatting attribute was found or an attributed formatting
// attribute was found that resets to the previous status // attribute was found that resets to the previous status