Home / File/ EditorPane.js — react Source File

EditorPane.js — react Source File

Architecture documentation for EditorPane.js, a javascript file in the react codebase. 14 imports, 2 dependents.

File javascript BabelCompiler Validation 14 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c["EditorPane.js"]
  112f19f5_c561_f36f_4f9c_12048819ad24["portaledContent.js"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 112f19f5_c561_f36f_4f9c_12048819ad24
  99e412e8_4291_b219_15f8_f660472850c6["portaledContent"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 99e412e8_4291_b219_15f8_f660472850c6
  a517325f_0c62_ded5_ec08_5bbb6a82fe22["EditorPane.css"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> a517325f_0c62_ded5_ec08_5bbb6a82fe22
  5eb75744_619e_d7d3_c988_8d5803563f16["OpenInEditorButton.js"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 5eb75744_619e_d7d3_c988_8d5803563f16
  5318bf81_8df5_b7bf_4d85_f9add36399e6["OpenInEditorButton"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 5318bf81_8df5_b7bf_4d85_f9add36399e6
  92c8d128_26b7_05c1_1f27_a9a5ab236fc6["useEditorURL.js"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 92c8d128_26b7_05c1_1f27_a9a5ab236fc6
  19776675_fb50_d3e9_2e67_e3dcc7805e1e["useEditorURL"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 19776675_fb50_d3e9_2e67_e3dcc7805e1e
  4e037c1a_e2a6_57d5_f84d_9c399385f234["EditorSettings.js"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 4e037c1a_e2a6_57d5_f84d_9c399385f234
  ef0567ef_20f5_edba_0d6a_3cc41cfe68d8["EditorSettings"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> ef0567ef_20f5_edba_0d6a_3cc41cfe68d8
  d31d8c6c_50ef_6d6a_4682_cdf66edc0ca0["CodeEditorByDefault.js"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> d31d8c6c_50ef_6d6a_4682_cdf66edc0ca0
  d2be5ba0_2c7d_bbe3_e84c_f71455803f2b["CodeEditorByDefault"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> d2be5ba0_2c7d_bbe3_e84c_f71455803f2b
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  e990a84d_b490_703b_26b3_fe044fc7bcf3["Button"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> e990a84d_b490_703b_26b3_fe044fc7bcf3
  0cbf34b0_8358_799e_95fa_64745d5111eb["ButtonIcon"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 0cbf34b0_8358_799e_95fa_64745d5111eb
  style 6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import * as React from 'react';
import {useState, startTransition} from 'react';

import portaledContent from '../portaledContent';

import styles from './EditorPane.css';

import Button from 'react-devtools-shared/src/devtools/views/Button';
import ButtonIcon from 'react-devtools-shared/src/devtools/views/ButtonIcon';

import OpenInEditorButton from './OpenInEditorButton';
import useEditorURL from '../useEditorURL';

import EditorSettings from './EditorSettings';
import CodeEditorByDefault from '../Settings/CodeEditorByDefault';

export type SourceSelection = {
  url: string,
  // The selection is a ref so that we don't have to rerender every keystroke.
  selectionRef: {
    line: number,
    column: number,
  },
};

export type Props = {selectedSource: ?SourceSelection};

function EditorPane({selectedSource}: Props) {
  const [showSettings, setShowSettings] = useState(false);
  const [showLinkInfo, setShowLinkInfo] = useState(false);

  const editorURL = useEditorURL();

  if (showLinkInfo) {
    return (
      <div className={styles.EditorPane}>
        <div className={styles.EditorToolbar}>
          <div style={{display: 'flex', flex: '1 1 auto'}}>
            To enable link handling in your browser's DevTools settings, look
            for the option Extension -> Link Handling. Select "React Developer
            Tools".
          </div>
          <div className={styles.VRule} />
          <Button
            onClick={() =>
              startTransition(() => {
                setShowLinkInfo(false);
                setShowSettings(false);
              })
            }>
            <ButtonIcon type="close" />
          </Button>
        </div>
      </div>
    );
  }

  let editorToolbar;
  if (showSettings) {
    editorToolbar = (
      <div className={styles.EditorToolbar}>
        <EditorSettings />
        <div className={styles.VRule} />
        <Button onClick={() => startTransition(() => setShowSettings(false))}>
          <ButtonIcon type="close" />
        </Button>
      </div>
    );
  } else {
    editorToolbar = (
      <div className={styles.EditorToolbar}>
        <OpenInEditorButton
          className={styles.WideButton}
          editorURL={editorURL}
          source={selectedSource}
        />
        <div className={styles.VRule} />
        <Button
          onClick={() => startTransition(() => setShowSettings(true))}
          // We don't use the title here because we don't have enough space to show it.
          // Once we expand this pane we can add it.
          // title="Configure code editor"
        >
          <ButtonIcon type="settings" />
        </Button>
      </div>
    );
  }

  return (
    <div className={styles.EditorPane}>
      {editorToolbar}
      <div className={styles.EditorInfo}>
        {editorURL ? (
          <CodeEditorByDefault
            onChange={alwaysOpenInEditor => {
              if (alwaysOpenInEditor) {
                startTransition(() => setShowLinkInfo(true));
              }
            }}
          />
        ) : (
          'Configure an external editor to open local files.'
        )}
      </div>
    </div>
  );
}
export default (portaledContent(EditorPane): component());

Domain

Subdomains

Functions

Frequently Asked Questions

What does EditorPane.js do?
EditorPane.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in EditorPane.js?
EditorPane.js defines 1 function(s): EditorPane.
What does EditorPane.js depend on?
EditorPane.js imports 14 module(s): Button, ButtonIcon, CodeEditorByDefault, CodeEditorByDefault.js, EditorPane.css, EditorSettings, EditorSettings.js, OpenInEditorButton, and 6 more.
What files import EditorPane.js?
EditorPane.js is imported by 2 file(s): DevTools.js, OpenInEditorButton.js.
Where is EditorPane.js in the architecture?
EditorPane.js is located at packages/react-devtools-shared/src/devtools/views/Editor/EditorPane.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Editor).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free