diff --git a/package-lock.json b/package-lock.json index ff425612..9b44bba9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.9", + "version": "13.4.11", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2b5a91a4..c1c1f919 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/types/YText.js b/src/types/YText.js index a12d0747..b5694507 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -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)) }) } diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index 62964520..3bd88365 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -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() } }