mirror of
https://github.com/yjs/yjs.git
synced 2025-12-16 03:37:50 +01:00
fixed a bunch of issues related to attribution of formats
This commit is contained in:
@@ -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
|
||||||
|
previousAttributes[key] = value
|
||||||
}
|
}
|
||||||
// current attributes doesn't change
|
|
||||||
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)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user