editor.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { LoadingPane } from '@/features/ide-react/components/editor/loading-pane'
  2. import {
  3. EditorScopeValue,
  4. useEditorManagerContext,
  5. } from '@/features/ide-react/context/editor-manager-context'
  6. import { useFileTreeOpenContext } from '@/features/ide-react/context/file-tree-open-context'
  7. import useScopeValue from '@/shared/hooks/use-scope-value'
  8. import classNames from 'classnames'
  9. import SourceEditor from '@/features/source-editor/components/source-editor'
  10. export const Editor = () => {
  11. const [editor] = useScopeValue<EditorScopeValue>('editor')
  12. const { selectedEntityCount, openEntity } = useFileTreeOpenContext()
  13. const { currentDocumentId } = useEditorManagerContext()
  14. if (!currentDocumentId) {
  15. return null
  16. }
  17. const isLoading = Boolean(
  18. (!editor.sharejs_doc || editor.opening) &&
  19. !editor.error_state &&
  20. editor.open_doc_id
  21. )
  22. return (
  23. <div
  24. className={classNames('ide-redesign-editor-content', {
  25. hidden: openEntity?.type !== 'doc' || selectedEntityCount !== 1,
  26. })}
  27. >
  28. <SourceEditor />
  29. {isLoading && <LoadingPane />}
  30. </div>
  31. )
  32. }