From 8d65b13b3dc250aa23b8d927a4467f6f70d19046 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 5 Dec 2023 21:38:54 -0500 Subject: [PATCH] fix: FindAndReplace does not update to reflect changing between readOnly/editable --- app/editor/extensions/FindAndReplace.tsx | 6 +++--- app/editor/index.tsx | 2 +- shared/editor/lib/Extension.ts | 2 +- shared/editor/lib/ExtensionManager.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/editor/extensions/FindAndReplace.tsx b/app/editor/extensions/FindAndReplace.tsx index 81e32f778..f3c53782c 100644 --- a/app/editor/extensions/FindAndReplace.tsx +++ b/app/editor/extensions/FindAndReplace.tsx @@ -4,7 +4,7 @@ import { Command, Plugin, PluginKey } from "prosemirror-state"; import { Decoration, DecorationSet } from "prosemirror-view"; import * as React from "react"; import scrollIntoView from "smooth-scroll-into-view-if-needed"; -import Extension from "@shared/editor/lib/Extension"; +import Extension, { WidgetProps } from "@shared/editor/lib/Extension"; import FindAndReplace from "../components/FindAndReplace"; const pluginKey = new PluginKey("find-and-replace"); @@ -294,8 +294,8 @@ export default class FindAndReplaceExtension extends Extension { ]; } - public widget = () => ( - + public widget = ({ readOnly }: WidgetProps) => ( + ); private results: { from: number; to: number }[] = []; diff --git a/app/editor/index.tsx b/app/editor/index.tsx index 5171433f5..2c0346403 100644 --- a/app/editor/index.tsx +++ b/app/editor/index.tsx @@ -763,7 +763,7 @@ export class Editor extends React.PureComponent< )} {this.widgets && Object.values(this.widgets).map((Widget, index) => ( - + ))} diff --git a/shared/editor/lib/Extension.ts b/shared/editor/lib/Extension.ts index 90552d832..ae0cfad0a 100644 --- a/shared/editor/lib/Extension.ts +++ b/shared/editor/lib/Extension.ts @@ -7,7 +7,7 @@ import { Editor } from "../../../app/editor"; export type CommandFactory = (attrs?: Record) => Command; -export type WidgetProps = { rtl: boolean }; +export type WidgetProps = { rtl: boolean; readOnly: boolean | undefined }; export default class Extension { options: any; diff --git a/shared/editor/lib/ExtensionManager.ts b/shared/editor/lib/ExtensionManager.ts index 4d7a89eee..e99103fd1 100644 --- a/shared/editor/lib/ExtensionManager.ts +++ b/shared/editor/lib/ExtensionManager.ts @@ -44,7 +44,7 @@ export default class ExtensionManager { get widgets() { return this.extensions - .filter((extension) => extension.widget({ rtl: false })) + .filter((extension) => extension.widget({ rtl: false, readOnly: false })) .reduce( (nodes, node: Node) => ({ ...nodes,