Skip to content

Commit

Permalink
fix: Wrap Editor with ErrorBoundary and solve all problems (#17377)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored Sep 11, 2023
1 parent 407d775 commit db58c09
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions frontend/src/scenes/notebooks/Notebook/Notebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { EditorFocusPosition } from './utils'
import { FlaggedFeature } from 'lib/components/FlaggedFeature'
import { FEATURE_FLAGS } from 'lib/constants'
import { NotebookSidebar } from './NotebookSidebar'
import { ErrorBoundary } from '~/layout/ErrorBoundary'

export type NotebookProps = {
shortId: string
Expand Down Expand Up @@ -101,23 +102,25 @@ export function Notebook({ shortId, editable = false, initialAutofocus = null }:
<FlaggedFeature flag={FEATURE_FLAGS.NOTEBOOK_SETTINGS_WIDGETS}>
<NotebookSidebar />
</FlaggedFeature>
<Editor
initialContent={content}
onCreate={setEditor}
onUpdate={onEditorUpdate}
onSelectionUpdate={onEditorSelectionUpdate}
placeholder={({ node }: { node: any }) => {
if (node.type.name === 'heading' && node.attrs.level === 1) {
return `Untitled - maybe.. "${headingPlaceholder}"`
}
<ErrorBoundary>
<Editor
initialContent={content}
onCreate={setEditor}
onUpdate={onEditorUpdate}
onSelectionUpdate={onEditorSelectionUpdate}
placeholder={({ node }: { node: any }) => {
if (node.type.name === 'heading' && node.attrs.level === 1) {
return `Untitled - maybe.. "${headingPlaceholder}"`
}

if (node.type.name === 'heading') {
return `Heading ${node.attrs.level}`
}
if (node.type.name === 'heading') {
return `Heading ${node.attrs.level}`
}

return ''
}}
/>
return ''
}}
/>
</ErrorBoundary>
</div>
</div>
</BindLogic>
Expand Down

0 comments on commit db58c09

Please sign in to comment.