fix: Crash with some find characters
fix: Warning on close of find dialog
This commit is contained in:
@@ -29,6 +29,7 @@ type Props = {
|
||||
|
||||
export default function FindAndReplace({ readOnly }: Props) {
|
||||
const editor = useEditor();
|
||||
const finalFocusRef = React.useRef<HTMLElement>(editor.view.dom);
|
||||
const selectionRef = React.useRef<string | undefined>();
|
||||
const inputRef = React.useRef<HTMLInputElement>(null);
|
||||
const { t } = useTranslation();
|
||||
@@ -224,6 +225,7 @@ export default function FindAndReplace({ readOnly }: Props) {
|
||||
<Portal>
|
||||
<Popover
|
||||
{...popover}
|
||||
unstable_finalFocusRef={finalFocusRef}
|
||||
style={style}
|
||||
aria-label={t("Find and replace")}
|
||||
width={420}
|
||||
|
||||
@@ -141,7 +141,14 @@ export default class FindAndReplace extends Extension {
|
||||
}
|
||||
|
||||
private get findRegExp() {
|
||||
return RegExp(this.searchTerm, !this.options.caseSensitive ? "gui" : "gu");
|
||||
try {
|
||||
return RegExp(
|
||||
this.searchTerm.replace(/\\+$/, ""),
|
||||
!this.options.caseSensitive ? "gui" : "gu"
|
||||
);
|
||||
} catch (err) {
|
||||
return RegExp("");
|
||||
}
|
||||
}
|
||||
|
||||
private goToMatch(direction: number): Command {
|
||||
|
||||
Reference in New Issue
Block a user