parent
89b4320a8e
commit
4707fc46ac
@ -164,12 +164,13 @@ const insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes
|
|||||||
}
|
}
|
||||||
const doc = transaction.doc
|
const doc = transaction.doc
|
||||||
const ownClientId = doc.clientID
|
const ownClientId = doc.clientID
|
||||||
let nextFormat = currPos.left
|
|
||||||
const right = currPos.right
|
|
||||||
negatedAttributes.forEach((val, key) => {
|
negatedAttributes.forEach((val, key) => {
|
||||||
nextFormat = new Item(createID(ownClientId, getState(doc.store, ownClientId)), nextFormat, nextFormat && nextFormat.lastId, right, right && right.id, parent, null, new ContentFormat(key, val))
|
const left = currPos.left
|
||||||
|
const right = currPos.right
|
||||||
|
const nextFormat = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val))
|
||||||
nextFormat.integrate(transaction, 0)
|
nextFormat.integrate(transaction, 0)
|
||||||
currPos.right = nextFormat
|
currPos.right = nextFormat
|
||||||
|
currPos.forward()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,3 +168,18 @@ export const testClone = tc => {
|
|||||||
t.assert(cloneYxml.length === 3)
|
t.assert(cloneYxml.length === 3)
|
||||||
t.compare(cloneYxml.toJSON(), yxml.toJSON())
|
t.compare(cloneYxml.toJSON(), yxml.toJSON())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {t.TestCase} tc
|
||||||
|
*/
|
||||||
|
export const testFormattingBug = tc => {
|
||||||
|
const ydoc = new Y.Doc()
|
||||||
|
const yxml = /** @type {Y.XmlText} */ (ydoc.get('', Y.XmlText))
|
||||||
|
const delta = [
|
||||||
|
{ insert: 'A', attributes: { em: {}, strong: {} } },
|
||||||
|
{ insert: 'B', attributes: { em: {} } },
|
||||||
|
{ insert: 'C', attributes: { em: {}, strong: {} } }
|
||||||
|
]
|
||||||
|
yxml.applyDelta(delta)
|
||||||
|
t.compare(yxml.toDelta(), delta)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user