From 469404c6e1012d6d398382c2ed9a2c604b159496 Mon Sep 17 00:00:00 2001 From: Cole Date: Mon, 1 Jun 2020 19:17:54 +0900 Subject: [PATCH] move quill relate newline remove logic to y-quill --- src/types/YText.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/types/YText.js b/src/types/YText.js index e02b2514..41fe0fee 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -853,16 +853,8 @@ export class YText extends AbstractType { const currentAttributes = new Map() for (let i = 0; i < delta.length; i++) { const op = delta[i] - if (op.insert !== undefined) { - // Quill assumes that the content starts with an empty paragraph. - // Yjs/Y.Text assumes that it starts empty. We always hide that - // there is a newline at the end of the content. - // If we omit this step, clients will see a different number of - // paragraphs, but nothing bad will happen. - const ins = (typeof op.insert === 'string' && i === delta.length - 1 && pos.right === null && op.insert.slice(-1) === '\n') ? op.insert.slice(0, -1) : op.insert - if (typeof ins !== 'string' || ins.length > 0) { - pos = insertText(transaction, this, pos.left, pos.right, currentAttributes, ins, op.attributes || {}) - } + if (op.insert !== undefined && (typeof op.insert !== 'string' || op.insert.length > 0)) { + pos = insertText(transaction, this, pos.left, pos.right, currentAttributes, op.insert, op.attributes || {}) } else if (op.retain !== undefined) { pos = formatText(transaction, this, pos.left, pos.right, currentAttributes, op.retain, op.attributes || {}) } else if (op.delete !== undefined) {