-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document Editor page #56
Conversation
...ojectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/index.tsx
Outdated
Show resolved
Hide resolved
...app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/layout.tsx
Outdated
Show resolved
Hide resolved
552ac7d
to
9339d63
Compare
// When imported, Monaco automatically tries to use the window object. | ||
// Since this is not available when rendering on the server, we only | ||
// render the fallback component for SSR. | ||
if (typeof window === 'undefined') return <DocumentTextEditorFallback /> | ||
const [isClient, setIsClient] = useState(false) | ||
|
||
useEffect(() => { | ||
setIsClient(typeof window !== 'undefined') | ||
}, []) | ||
|
||
if (!isClient) { | ||
return <DocumentTextEditorFallback /> | ||
} | ||
return <DocumentTextEditor {...props} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the "hydration" error that Next.js shows when loading the editor, because it rendered something different in SSR and in the browser. Now, both render the fallback at first and then the browser updates to the actual editor (which renders the fallback too until monaco fully loads anyways)
47cefff
to
f8c081f
Compare
const document = documents.find((d) => d.path === path) | ||
if (!document) { | ||
throw new NotFoundError('Document not found') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a core method. originalGetDocumentByPath
|
||
const documentContent = documentsByPath[path] | ||
if (documentContent === undefined) { | ||
throw new Error('Document not found') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who handles this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler does
onMount={handleEditorDidMount} | ||
onChange={handleValueChange} | ||
options={{ | ||
fixedOverflowWidgets: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much pain in this boolean 😂
f8c081f
to
b8fcc87
Compare
b8fcc87
to
61ba4dc
Compare
First iteration of the document editor page. Clicking on a document from the sidebar shows the editor, which can be used to edit documents from draft commits.
Screen.Recording.2024-07-23.at.17.04.59.mov