From 0b8016c50d838d19bd5c959bd429d4e9ab8f29bc Mon Sep 17 00:00:00 2001 From: David Brochart Date: Fri, 12 Jul 2024 13:29:07 +0200 Subject: [PATCH] Fix createOutputs, rename 'modeldb' origin to 'silent-change' --- javascript/src/ycell.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/javascript/src/ycell.ts b/javascript/src/ycell.ts index 7ee0743..3a5729a 100644 --- a/javascript/src/ycell.ts +++ b/javascript/src/ycell.ts @@ -660,7 +660,7 @@ export class YBaseCell events: Y.YEvent[], transaction: Y.Transaction ) => { - if (transaction.origin !== 'modeldb') { + if (transaction.origin !== 'silent-change') { this._changed.emit(this.getChanges(events)); } }; @@ -771,13 +771,12 @@ export class YCodeCell createOutputs(outputs: Array): Array> { const newOutputs: Array> = []; - for (const output of outputs) { - let _newOutput: { [id: string]: any }; - const newOutput = new Y.Map(); + for (const output of JSONExt.deepCopy(outputs)) { + let _newOutput1: { [id: string]: any }; if (output.output_type === 'stream') { // Set the text field as a Y.Text const { text, ...outputWithoutText } = output; - _newOutput = outputWithoutText; + _newOutput1 = outputWithoutText; const newText = new Y.Text(); let length = 0; // text is a list of strings @@ -785,13 +784,15 @@ export class YCodeCell newText.insert(length, str); length += str.length; } - _newOutput['text'] = newText; + _newOutput1['text'] = newText; } else { - _newOutput = output; + _newOutput1 = output; } - for (const [key, value] of Object.entries(_newOutput)) { - newOutput.set(key, value); + const _newOutput2: [string, any][] = []; + for (const [key, value] of Object.entries(_newOutput1)) { + _newOutput2.push([key, value]); } + const newOutput = new Y.Map(_newOutput2); newOutputs.push(newOutput); } return newOutputs;