From edc1f9418f422cf83ad2c56d52595f9c473dfb22 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 14:45:51 +0100 Subject: [PATCH 1/5] reproduce #271 --- tests/y-text.tests.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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() } } From 186f7140b622aeda4b4a924dc9323513b2ca13c6 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 14:55:08 +0100 Subject: [PATCH 2/5] fix #271 - multiline text formatting issue --- src/types/YText.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/YText.js b/src/types/YText.js index a12d0747..dfd525e9 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -169,6 +169,7 @@ 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) }) } From 8086a4f816eff36bc69880c091aeec21da0790af Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 14:58:21 +0100 Subject: [PATCH 3/5] 13.4.10 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff425612..57a94b0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.9", + "version": "13.4.10", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2b5a91a4..e9cab969 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.9", + "version": "13.4.10", "description": "Shared Editing Library", "main": "./dist/yjs.cjs", "module": "./dist/yjs.mjs", From ca667be68b7e034867ca03f01f4e3f7bd9eccb03 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 14:59:56 +0100 Subject: [PATCH 4/5] proper updating of text-attributes --- src/types/YText.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/YText.js b/src/types/YText.js index dfd525e9..b5694507 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -170,6 +170,7 @@ const insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes 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)) }) } From 97d97147105043de8232f71f80447eba920347cb Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 15:01:52 +0100 Subject: [PATCH 5/5] 13.4.11 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 57a94b0f..9b44bba9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.10", + "version": "13.4.11", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e9cab969..c1c1f919 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.10", + "version": "13.4.11", "description": "Shared Editing Library", "main": "./dist/yjs.cjs", "module": "./dist/yjs.mjs",