Skip to content

Commit

Permalink
fix: getEditorString (#2185)
Browse files Browse the repository at this point in the history
* fix

* Create red-jokes-think.md
  • Loading branch information
zbeyens authored Feb 2, 2023
1 parent 9ce97f4 commit 90c83a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/red-jokes-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@udecode/plate-core": patch
---

fix: `getEditorString` should not throw an error when a node is not found. Returns an empty string in that case.
10 changes: 9 additions & 1 deletion packages/core/src/slate/editor/getEditorString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ export const getEditorString = <V extends Value>(
editor: TEditor<V>,
at: Location | null | undefined,
options?: EditorStringOptions
) => (at ? Editor.string(editor as any, at, options) : '');
) => {
if (!at) return '';

try {
return Editor.string(editor as any, at, options);
} catch (error) {
return '';
}
};

2 comments on commit 90c83a0

@vercel
Copy link

@vercel vercel bot commented on 90c83a0 Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

plate-examples – ./

plate-examples-udecode.vercel.app
plate-examples.vercel.app
plate-examples-git-main-udecode.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 90c83a0 Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

plate – ./

www.plate.udecode.io
plate-udecode.vercel.app
plate-git-main-udecode.vercel.app
plate.udecode.io

Please sign in to comment.