From 8c661345f0465c2689a510591a4190aa2479a107 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 21 Sep 2023 10:24:18 -0400 Subject: [PATCH] fix: Incorrect translation of != null --- .../lib/prosemirror-recreate-transform/recreateTransform.ts | 6 +++--- shared/editor/lib/uploadPlaceholder.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/editor/lib/prosemirror-recreate-transform/recreateTransform.ts b/shared/editor/lib/prosemirror-recreate-transform/recreateTransform.ts index 6f29db3f8..2a2b1e4fe 100644 --- a/shared/editor/lib/prosemirror-recreate-transform/recreateTransform.ts +++ b/shared/editor/lib/prosemirror-recreate-transform/recreateTransform.ts @@ -91,7 +91,7 @@ export class RecreateTransform { // collect operations until we receive a valid document: // apply ops-patches until a valid prosemirror document is retrieved, // then try to create a transformation step or retry with next operation - while (toDoc === null) { + while (!toDoc) { applyPatch(afterStepJSON, [op]); try { @@ -125,7 +125,7 @@ export class RecreateTransform { // Text is being replaced, we apply text diffing to find the smallest possible diffs. this.addReplaceTextSteps(op, afterStepJSON); ops = []; - } else if (toDoc && this.addReplaceStep(toDoc, afterStepJSON)) { + } else if (this.addReplaceStep(toDoc, afterStepJSON)) { // operations have been applied ops = []; } @@ -144,7 +144,7 @@ export class RecreateTransform { const fromNode = fromDoc.nodeAt(start) as Node; const toNode = toDoc.nodeAt(start) as Node; - if (start !== null) { + if (!start) { // @note this completly updates all attributes in one step, by completely replacing node const nodeType = fromNode.type === toNode.type ? null : toNode.type; try { diff --git a/shared/editor/lib/uploadPlaceholder.tsx b/shared/editor/lib/uploadPlaceholder.tsx index b74746f5e..ee77bf8a5 100644 --- a/shared/editor/lib/uploadPlaceholder.tsx +++ b/shared/editor/lib/uploadPlaceholder.tsx @@ -3,7 +3,7 @@ import { Decoration, DecorationSet } from "prosemirror-view"; import * as React from "react"; import ReactDOM from "react-dom"; import FileExtension from "../components/FileExtension"; -import { recreateTransform } from "../lib/prosemirror-recreate-transform"; +import { recreateTransform } from "./prosemirror-recreate-transform"; // based on the example at: https://prosemirror.net/examples/upload/ const uploadPlaceholder = new Plugin({