Skip to content

Commit

Permalink
fix: Profile page crash due to invalid topLevelElement (calcom#15198)
Browse files Browse the repository at this point in the history
  • Loading branch information
emrysal authored and p6l-richard committed Jul 22, 2024
1 parent 2218901 commit e2d1060
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/ui/components/editor/plugins/ToolbarPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,15 @@ export default function ToolbarPlugin(props: TextEditorProps) {
const nodes = $generateNodesFromDOM(editor, dom);

$getRoot().select();
$insertNodes(nodes);
try {
$insertNodes(nodes);
} catch (e: unknown) {
// resolves: "topLevelElement is root node at RangeSelection.insertNodes"
// @see https://stackoverflow.com/questions/73094258/setting-editor-from-html
const paragraphNode = $createParagraphNode();
nodes.forEach((n) => paragraphNode.append(n));
$getRoot().append(paragraphNode);
}

editor.registerUpdateListener(({ editorState, prevEditorState }) => {
editorState.read(() => {
Expand Down

0 comments on commit e2d1060

Please sign in to comment.