Merge branch 'main' of github.com:yjs/yjs into main

This commit is contained in:
Kevin Jahns 2021-01-10 00:17:30 +01:00
commit e19f16f22c
4 changed files with 29 additions and 2 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.4.9",
"version": "13.4.11",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.4.9",
"version": "13.4.11",
"description": "Shared Editing Library",
"main": "./dist/yjs.cjs",
"module": "./dist/yjs.mjs",

View File

@ -169,6 +169,8 @@ const insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes
negatedAttributes.forEach((val, key) => {
left = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val))
left.integrate(transaction, 0)
currPos.currentAttributes.set(key, val)
updateCurrentAttributes(currPos.currentAttributes, /** @type {ContentFormat} */ (left.content))
})
}

View File

@ -78,6 +78,29 @@ export const testBasicFormat = tc => {
compare(users)
}
/**
* @param {t.TestCase} tc
*/
export const testMultilineFormat = tc => {
const ydoc = new Y.Doc()
const testText = ydoc.getText('test')
testText.insert(0, 'Test\nMulti-line\nFormatting')
testText.applyDelta([
{ retain: 4, attributes: { bold: true } },
{ retain: 1 }, // newline character
{ retain: 10, attributes: { bold: true } },
{ retain: 1 }, // newline character
{ retain: 10, attributes: { bold: true } }
])
t.compare(testText.toDelta(), [
{ insert: 'Test', attributes: { bold: true } },
{ insert: '\n' },
{ insert: 'Multi-line', attributes: { bold: true } },
{ insert: '\n' },
{ insert: 'Formatting', attributes: { bold: true } }
])
}
/**
* @param {t.TestCase} tc
*/
@ -286,7 +309,9 @@ export const testBestCase = tc => {
}
const tryGc = () => {
// @ts-ignore
if (typeof global !== 'undefined' && global.gc) {
// @ts-ignore
global.gc()
}
}