From 80e83a84c6d8c9a4ca1c447f9f94e23e690a9516 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 12 Jan 2025 19:32:51 +0100 Subject: [PATCH] Revert "fix(yText): applyDelta should support both Delta and Ops[]" --- src/types/YText.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/types/YText.js b/src/types/YText.js index a754cde1..a196ecd0 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -972,16 +972,15 @@ export class YText extends AbstractType { if (this.doc !== null) { transact(this.doc, transaction => { const currPos = new ItemTextListPosition(null, this._start, 0, new Map()) - const ops = Array.isArray(delta) ? delta : (Array.isArray(delta?.ops) ? delta.ops : []); - for (let i = 0; i < ops.length; i++) { - const op = ops[i] + 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 = (!sanitize && typeof op.insert === 'string' && i === ops.length - 1 && currPos.right === null && op.insert.slice(-1) === '\n') ? op.insert.slice(0, -1) : op.insert + const ins = (!sanitize && typeof op.insert === 'string' && i === delta.length - 1 && currPos.right === null && op.insert.slice(-1) === '\n') ? op.insert.slice(0, -1) : op.insert if (typeof ins !== 'string' || ins.length > 0) { insertText(transaction, this, currPos, ins, op.attributes || {}) }