fixed a bunch of issues related to attribution of formats

This commit is contained in:
Kevin Jahns
2025-06-09 21:21:33 +02:00
parent 10a019806a
commit a9f802d77e

View File

@@ -972,7 +972,7 @@ export class YText extends AbstractType {
const renderDelete = c.render && c.deleted const renderDelete = c.render && c.deleted
// existing content that should be retained, only adding changed attributes // existing content that should be retained, only adding changed attributes
const retainContent = !c.render && (!c.deleted || c.attrs != null) const retainContent = !c.render && (!c.deleted || c.attrs != null)
const attribution = renderContent ? createAttributionFromAttributionItems(c.attrs, c.deleted) : null const attribution = (renderContent || c.content.constructor === ContentFormat) ? createAttributionFromAttributionItems(c.attrs, c.deleted) : null
switch (c.content.constructor) { switch (c.content.constructor) {
case ContentDeleted: { case ContentDeleted: {
if (renderDelete) d.delete(c.content.getLength()) if (renderDelete) d.delete(c.content.getLength())
@@ -1032,15 +1032,15 @@ export class YText extends AbstractType {
if (renderContent || renderDelete) { if (renderContent || renderDelete) {
if (c.deleted) { if (c.deleted) {
// content was deleted, but is possibly attributed // content was deleted, but is possibly attributed
if (equalAttrs(value, currAttrVal)) { if (!equalAttrs(value, currAttrVal)) { // do nothing if nothing changed
// nop if (equalAttrs(currAttrVal, previousAttributes[key] ?? null) && changedAttributes[key] !== undefined) {
} else if (equalAttrs(currAttrVal, previousAttributes[key] ?? null) && changedAttributes[key] !== undefined) {
delete changedAttributes[key] delete changedAttributes[key]
} else { } else {
changedAttributes[key] = currAttrVal changedAttributes[key] = currAttrVal
} }
// current attributes doesn't change // current attributes doesn't change
previousAttributes[key] = value previousAttributes[key] = value
}
} else { // !c.deleted } else { // !c.deleted
// content was inserted, and is possibly attributed // content was inserted, and is possibly attributed
if (equalAttrs(value, currAttrVal)) { if (equalAttrs(value, currAttrVal)) {