Skip to content

Commit

Permalink
feat(@lexical/devtools): Added DevTools panel + shared state
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleT committed Mar 20, 2024
1 parent b1caaee commit 4aa3be8
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/lexical-devtools/entrypoints/devtools-panel/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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.
*
*/

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

import lexicalLogo from '/lexical.svg';

function App() {
const [count, setCount] = useState(0);

return (
<>
<div>
<a href="https://lexical.dev" target="_blank">
<img src={lexicalLogo} className="logo" alt="Lexical logo" />
</a>
</div>
<div className="card">
<button onClick={() => setCount((c) => c + 1)}>count is {count}</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
</>
);
}

export default App;
11 changes: 11 additions & 0 deletions packages/lexical-devtools/entrypoints/devtools-panel/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions packages/lexical-devtools/entrypoints/devtools-panel/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* 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.
*
*/

import React from 'react';

Check failure on line 9 in packages/lexical-devtools/entrypoints/devtools-panel/main.tsx

View workflow job for this annotation

GitHub Actions / integrity (20.11.0)

Module '"/home/runner/work/lexical/lexical/node_modules/@types/react/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
import ReactDOM from 'react-dom/client';

Check failure on line 10 in packages/lexical-devtools/entrypoints/devtools-panel/main.tsx

View workflow job for this annotation

GitHub Actions / integrity (20.11.0)

Module '"/home/runner/work/lexical/lexical/node_modules/@types/react-dom/client"' has no default export.

import App from './App.tsx';

Check failure on line 12 in packages/lexical-devtools/entrypoints/devtools-panel/main.tsx

View workflow job for this annotation

GitHub Actions / integrity (20.11.0)

An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled.

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
8 changes: 8 additions & 0 deletions packages/lexical-devtools/entrypoints/devtools/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="module" src="./main.ts"></script>
</head>
</html>
14 changes: 14 additions & 0 deletions packages/lexical-devtools/entrypoints/devtools/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* 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.
*
*/

// Create the panel which appears within the browser devtools
browser.devtools.panels.create(

Check failure on line 10 in packages/lexical-devtools/entrypoints/devtools/main.ts

View workflow job for this annotation

GitHub Actions / integrity (20.11.0)

Cannot find name 'browser'.
'Lexical',
'icon/128.png',
'devtools-panel.html',
);

0 comments on commit 4aa3be8

Please sign in to comment.