Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
633eb9033c | ||
|
|
4707fc46ac | ||
|
|
89b4320a8e | ||
|
|
0ea0a35521 | ||
|
|
5ddb7eefed |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.11",
|
"version": "13.5.12",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.11",
|
"version": "13.5.12",
|
||||||
"description": "Shared Editing Library",
|
"description": "Shared Editing Library",
|
||||||
"main": "./dist/yjs.cjs",
|
"main": "./dist/yjs.cjs",
|
||||||
"module": "./dist/yjs.mjs",
|
"module": "./dist/yjs.mjs",
|
||||||
|
|||||||
@@ -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()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export class YXmlElement extends YXmlFragment {
|
|||||||
el.setAttribute(key, attrs[key])
|
el.setAttribute(key, attrs[key])
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
el.insert(0, el.toArray().map(item => item instanceof AbstractType ? item.clone() : item))
|
el.insert(0, this.toArray().map(item => item instanceof AbstractType ? item.clone() : item))
|
||||||
return el
|
return el
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ export class YXmlFragment extends AbstractType {
|
|||||||
clone () {
|
clone () {
|
||||||
const el = new YXmlFragment()
|
const el = new YXmlFragment()
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
el.insert(0, el.toArray().map(item => item instanceof AbstractType ? item.clone() : item))
|
el.insert(0, this.toArray().map(item => item instanceof AbstractType ? item.clone() : item))
|
||||||
return el
|
return el
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,3 +150,36 @@ export const testInsertafter = tc => {
|
|||||||
el.insertAfter(deepsecond1, [new Y.XmlText()])
|
el.insertAfter(deepsecond1, [new Y.XmlText()])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {t.TestCase} tc
|
||||||
|
*/
|
||||||
|
export const testClone = tc => {
|
||||||
|
const ydoc = new Y.Doc()
|
||||||
|
const yxml = ydoc.getXmlFragment()
|
||||||
|
const first = new Y.XmlText('text')
|
||||||
|
const second = new Y.XmlElement('p')
|
||||||
|
const third = new Y.XmlElement('p')
|
||||||
|
yxml.push([first, second, third])
|
||||||
|
t.compareArrays(yxml.toArray(), [first, second, third])
|
||||||
|
|
||||||
|
const cloneYxml = yxml.clone()
|
||||||
|
ydoc.getArray('copyarr').insert(0, [cloneYxml])
|
||||||
|
t.assert(cloneYxml.length === 3)
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user