copilot-lexical 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- copilot_lexical-0.1.0/LICENSE +21 -0
- copilot_lexical-0.1.0/PKG-INFO +259 -0
- copilot_lexical-0.1.0/README.md +246 -0
- copilot_lexical-0.1.0/copilot_lexical/__init__.py +5 -0
- copilot_lexical-0.1.0/copilot_lexical/__main__.py +35 -0
- copilot_lexical-0.1.0/copilot_lexical.egg-info/PKG-INFO +259 -0
- copilot_lexical-0.1.0/copilot_lexical.egg-info/SOURCES.txt +10 -0
- copilot_lexical-0.1.0/copilot_lexical.egg-info/dependency_links.txt +1 -0
- copilot_lexical-0.1.0/copilot_lexical.egg-info/entry_points.txt +2 -0
- copilot_lexical-0.1.0/copilot_lexical.egg-info/top_level.txt +1 -0
- copilot_lexical-0.1.0/pyproject.toml +25 -0
- copilot_lexical-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 goanpeca
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: copilot-lexical
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lexical editor with CopilotKit integration
|
|
5
|
+
Author-email: goanpeca <goanpeca@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/datalayer/copilot-lexical
|
|
8
|
+
Project-URL: Repository, https://github.com/datalayer/copilot-lexical
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# CopilotKit Lexical Example
|
|
15
|
+
|
|
16
|
+
A standalone example showcasing the integration of [Datalayer's Jupyter Lexical Editor](https://github.com/datalayer/jupyter-ui) with [CopilotKit](https://www.copilotkit.ai/) AI sidebar.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- 📝 **Rich Lexical Editor** - Full-featured editor based on Meta's Lexical framework
|
|
21
|
+
- 🤖 **AI Copilot Integration** - CopilotKit sidebar for AI-assisted editing
|
|
22
|
+
- 🚀 **Jupyter Runtime Support** - Toggle between runtime and non-runtime modes
|
|
23
|
+
- 🎨 **Primer Design System** - Beautiful UI with GitHub's Primer components
|
|
24
|
+
- ⚡ **Fast Dev Server** - Powered by Vite for instant HMR
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
- Node.js >= 22.0.0
|
|
29
|
+
- npm or yarn
|
|
30
|
+
- CopilotKit API key (get from [cloud.copilotkit.ai](https://cloud.copilotkit.ai/dashboard))
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. Install Dependencies
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd /Users/goanpeca/Desktop/develop/datalayer/copilot-lexical
|
|
38
|
+
npm install
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Sync Local Development Packages (Optional)
|
|
42
|
+
|
|
43
|
+
If you're developing locally and want to use the latest code from sibling repositories:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Sync all local packages
|
|
47
|
+
npm run sync:all
|
|
48
|
+
|
|
49
|
+
# Or sync individually
|
|
50
|
+
npm run sync:core # Sync @datalayer/core
|
|
51
|
+
npm run sync:jupyter # Sync jupyter-ui packages
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. Configure Environment
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cd copilot-lexical
|
|
58
|
+
cp .env.example .env
|
|
59
|
+
|
|
60
|
+
# Edit .env and add your CopilotKit API key
|
|
61
|
+
VITE_COPILOT_KIT_API_KEY=your_api_key_here
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 4. Run Development Server
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Start on default port (3000)
|
|
68
|
+
npm run dev
|
|
69
|
+
|
|
70
|
+
# Or sync local packages and start dev server
|
|
71
|
+
npm run dev:sync
|
|
72
|
+
|
|
73
|
+
# Or specify a custom port
|
|
74
|
+
npm run start 8080
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 5. Open in Browser
|
|
78
|
+
|
|
79
|
+
Navigate to [http://localhost:3000](http://localhost:3000)
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
### Toggle Kernel Mode
|
|
84
|
+
|
|
85
|
+
Use the header buttons to toggle between:
|
|
86
|
+
- **Without Runtime** - Static editor without Jupyter kernel
|
|
87
|
+
- **With Runtime** - Full Jupyter notebook capabilities with code execution
|
|
88
|
+
|
|
89
|
+
### AI Copilot
|
|
90
|
+
|
|
91
|
+
The CopilotKit sidebar provides AI-assisted editing:
|
|
92
|
+
- Ask the AI to insert content
|
|
93
|
+
- Format text and structure
|
|
94
|
+
- Manipulate the document
|
|
95
|
+
- Get writing suggestions
|
|
96
|
+
|
|
97
|
+
Example prompts:
|
|
98
|
+
- "Insert a heading"
|
|
99
|
+
- "Add a code block with Python code"
|
|
100
|
+
- "Create a bulleted list"
|
|
101
|
+
- "Format this text as bold"
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
### Project Structure
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
copilot-lexical/
|
|
109
|
+
├── src/
|
|
110
|
+
│ ├── App.tsx # Main application component
|
|
111
|
+
│ ├── App.css # Application styles
|
|
112
|
+
│ ├── main.tsx # Entry point
|
|
113
|
+
│ └── index.css # Global styles
|
|
114
|
+
├── index.html # HTML template
|
|
115
|
+
├── vite.config.ts # Vite configuration
|
|
116
|
+
├── tsconfig.json # TypeScript config
|
|
117
|
+
├── package.json # Dependencies and scripts
|
|
118
|
+
└── README.md # This file
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Scripts
|
|
122
|
+
|
|
123
|
+
#### Dev Server
|
|
124
|
+
|
|
125
|
+
- `npm run dev` - Start development server (default port 3000)
|
|
126
|
+
- `npm run dev:sync` - Sync local packages and start dev server
|
|
127
|
+
- `npm run start [port]` - Start dev server on custom port
|
|
128
|
+
|
|
129
|
+
#### Package Syncing
|
|
130
|
+
|
|
131
|
+
- `npm run sync:all` - Sync all local development packages
|
|
132
|
+
- `npm run sync:core` - Sync @datalayer/core only
|
|
133
|
+
- `npm run sync:jupyter` - Sync jupyter-ui packages only
|
|
134
|
+
|
|
135
|
+
#### Build & Type Check
|
|
136
|
+
|
|
137
|
+
- `npm run build` - Build for production
|
|
138
|
+
- `npm run preview` - Preview production build
|
|
139
|
+
- `npm run type-check` - Run TypeScript type checking
|
|
140
|
+
|
|
141
|
+
### Dependencies
|
|
142
|
+
|
|
143
|
+
**Core:**
|
|
144
|
+
- `@datalayer/jupyter-lexical` - Lexical editor with Jupyter integration
|
|
145
|
+
- `@datalayer/jupyter-react` - Jupyter React components
|
|
146
|
+
- `@copilotkit/react-core` - CopilotKit core functionality
|
|
147
|
+
- `@copilotkit/react-ui` - CopilotKit UI components
|
|
148
|
+
- `lexical` - Meta's Lexical editor framework
|
|
149
|
+
|
|
150
|
+
**UI:**
|
|
151
|
+
- `@primer/react` - GitHub's Primer design system
|
|
152
|
+
- `@primer/octicons-react` - GitHub icons
|
|
153
|
+
|
|
154
|
+
## Deployment
|
|
155
|
+
|
|
156
|
+
### Build for Production
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npm run build
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This creates an optimized production build in the `dist/` directory.
|
|
163
|
+
|
|
164
|
+
### Deploy as JupyterHub App
|
|
165
|
+
|
|
166
|
+
This example can be deployed as a JupyterHub managed service:
|
|
167
|
+
|
|
168
|
+
1. Build the production bundle
|
|
169
|
+
2. Configure JupyterHub to serve the app
|
|
170
|
+
3. Set environment variables in JupyterHub config
|
|
171
|
+
4. Users can access via: `https://your-hub.com/services/copilot-lexical/`
|
|
172
|
+
|
|
173
|
+
See [JupyterHub documentation](https://jupyterhub.readthedocs.io/) for deployment details.
|
|
174
|
+
|
|
175
|
+
## Environment Variables
|
|
176
|
+
|
|
177
|
+
| Variable | Required | Description |
|
|
178
|
+
|----------|----------|-------------|
|
|
179
|
+
| `VITE_COPILOT_KIT_API_KEY` | Yes | CopilotKit API key for AI features |
|
|
180
|
+
| `VITE_DATALAYER_API_TOKEN` | No | Datalayer token (only for runtime mode) |
|
|
181
|
+
|
|
182
|
+
## Development Workflow
|
|
183
|
+
|
|
184
|
+
### Using Local Development Packages
|
|
185
|
+
|
|
186
|
+
This project can use either published npm packages or local development versions:
|
|
187
|
+
|
|
188
|
+
#### Option 1: Use Published Packages (default)
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm install # Installs from npm registry
|
|
192
|
+
npm run dev
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Option 2: Use Local Development Packages
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npm install
|
|
199
|
+
npm run sync:all # Sync from ../core, ../jupyter-ui
|
|
200
|
+
npm run dev
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The sync scripts copy built `lib/` directories from sibling repositories:
|
|
204
|
+
|
|
205
|
+
- `../core/lib` → `node_modules/@datalayer/core/lib`
|
|
206
|
+
- `../jupyter-ui/packages/react/lib` → `node_modules/@datalayer/jupyter-react/lib`
|
|
207
|
+
- `../jupyter-ui/packages/lexical/lib` → `node_modules/@datalayer/jupyter-lexical/lib`
|
|
208
|
+
- `../jupyter-ui/packages/primer-addons/lib` → `node_modules/@datalayer/primer-addons/lib`
|
|
209
|
+
|
|
210
|
+
### Making Changes to Dependencies
|
|
211
|
+
|
|
212
|
+
1. Make changes in the source repository (e.g., `../jupyter-ui`)
|
|
213
|
+
2. Build the package: `npm run build` (in that repository)
|
|
214
|
+
3. Sync to copilot-lexical: `npm run sync:all`
|
|
215
|
+
4. Restart dev server if needed
|
|
216
|
+
|
|
217
|
+
## Troubleshooting
|
|
218
|
+
|
|
219
|
+
### CopilotKit not working
|
|
220
|
+
|
|
221
|
+
- Verify your API key is correct in `.env`
|
|
222
|
+
- Check browser console for errors
|
|
223
|
+
- Ensure you've configured an LLM provider in CopilotKit dashboard
|
|
224
|
+
|
|
225
|
+
### Local packages not syncing
|
|
226
|
+
|
|
227
|
+
- Ensure sibling repositories exist: `../core`, `../jupyter-ui`
|
|
228
|
+
- Build packages first: Run `npm run build` in those repos
|
|
229
|
+
- Check sync script output for warnings
|
|
230
|
+
|
|
231
|
+
### Port already in use
|
|
232
|
+
|
|
233
|
+
- Specify a different port: `npm run start 3001`
|
|
234
|
+
- Or kill the process using the port
|
|
235
|
+
|
|
236
|
+
## Contributing
|
|
237
|
+
|
|
238
|
+
1. Fork the repository
|
|
239
|
+
2. Create a feature branch
|
|
240
|
+
3. Make your changes
|
|
241
|
+
4. Add tests if applicable
|
|
242
|
+
5. Submit a pull request
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT License - Copyright (c) 2025-2026 Datalayer, Inc.
|
|
247
|
+
|
|
248
|
+
## Links
|
|
249
|
+
|
|
250
|
+
- [Datalayer](https://datalayer.ai)
|
|
251
|
+
- [Jupyter UI](https://github.com/datalayer/jupyter-ui)
|
|
252
|
+
- [CopilotKit](https://www.copilotkit.ai/)
|
|
253
|
+
- [Lexical](https://lexical.dev/)
|
|
254
|
+
|
|
255
|
+
## Support
|
|
256
|
+
|
|
257
|
+
- 📧 Email: support@datalayer.io
|
|
258
|
+
- 💬 GitHub Issues: [github.com/datalayer/copilot-lexical/issues](https://github.com/datalayer/copilot-lexical/issues)
|
|
259
|
+
- 📖 Documentation: [docs.datalayer.io](https://docs.datalayer.io)
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# CopilotKit Lexical Example
|
|
2
|
+
|
|
3
|
+
A standalone example showcasing the integration of [Datalayer's Jupyter Lexical Editor](https://github.com/datalayer/jupyter-ui) with [CopilotKit](https://www.copilotkit.ai/) AI sidebar.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 📝 **Rich Lexical Editor** - Full-featured editor based on Meta's Lexical framework
|
|
8
|
+
- 🤖 **AI Copilot Integration** - CopilotKit sidebar for AI-assisted editing
|
|
9
|
+
- 🚀 **Jupyter Runtime Support** - Toggle between runtime and non-runtime modes
|
|
10
|
+
- 🎨 **Primer Design System** - Beautiful UI with GitHub's Primer components
|
|
11
|
+
- ⚡ **Fast Dev Server** - Powered by Vite for instant HMR
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Node.js >= 22.0.0
|
|
16
|
+
- npm or yarn
|
|
17
|
+
- CopilotKit API key (get from [cloud.copilotkit.ai](https://cloud.copilotkit.ai/dashboard))
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### 1. Install Dependencies
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cd /Users/goanpeca/Desktop/develop/datalayer/copilot-lexical
|
|
25
|
+
npm install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Sync Local Development Packages (Optional)
|
|
29
|
+
|
|
30
|
+
If you're developing locally and want to use the latest code from sibling repositories:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Sync all local packages
|
|
34
|
+
npm run sync:all
|
|
35
|
+
|
|
36
|
+
# Or sync individually
|
|
37
|
+
npm run sync:core # Sync @datalayer/core
|
|
38
|
+
npm run sync:jupyter # Sync jupyter-ui packages
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Configure Environment
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cd copilot-lexical
|
|
45
|
+
cp .env.example .env
|
|
46
|
+
|
|
47
|
+
# Edit .env and add your CopilotKit API key
|
|
48
|
+
VITE_COPILOT_KIT_API_KEY=your_api_key_here
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 4. Run Development Server
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Start on default port (3000)
|
|
55
|
+
npm run dev
|
|
56
|
+
|
|
57
|
+
# Or sync local packages and start dev server
|
|
58
|
+
npm run dev:sync
|
|
59
|
+
|
|
60
|
+
# Or specify a custom port
|
|
61
|
+
npm run start 8080
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 5. Open in Browser
|
|
65
|
+
|
|
66
|
+
Navigate to [http://localhost:3000](http://localhost:3000)
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
### Toggle Kernel Mode
|
|
71
|
+
|
|
72
|
+
Use the header buttons to toggle between:
|
|
73
|
+
- **Without Runtime** - Static editor without Jupyter kernel
|
|
74
|
+
- **With Runtime** - Full Jupyter notebook capabilities with code execution
|
|
75
|
+
|
|
76
|
+
### AI Copilot
|
|
77
|
+
|
|
78
|
+
The CopilotKit sidebar provides AI-assisted editing:
|
|
79
|
+
- Ask the AI to insert content
|
|
80
|
+
- Format text and structure
|
|
81
|
+
- Manipulate the document
|
|
82
|
+
- Get writing suggestions
|
|
83
|
+
|
|
84
|
+
Example prompts:
|
|
85
|
+
- "Insert a heading"
|
|
86
|
+
- "Add a code block with Python code"
|
|
87
|
+
- "Create a bulleted list"
|
|
88
|
+
- "Format this text as bold"
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
### Project Structure
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
copilot-lexical/
|
|
96
|
+
├── src/
|
|
97
|
+
│ ├── App.tsx # Main application component
|
|
98
|
+
│ ├── App.css # Application styles
|
|
99
|
+
│ ├── main.tsx # Entry point
|
|
100
|
+
│ └── index.css # Global styles
|
|
101
|
+
├── index.html # HTML template
|
|
102
|
+
├── vite.config.ts # Vite configuration
|
|
103
|
+
├── tsconfig.json # TypeScript config
|
|
104
|
+
├── package.json # Dependencies and scripts
|
|
105
|
+
└── README.md # This file
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Scripts
|
|
109
|
+
|
|
110
|
+
#### Dev Server
|
|
111
|
+
|
|
112
|
+
- `npm run dev` - Start development server (default port 3000)
|
|
113
|
+
- `npm run dev:sync` - Sync local packages and start dev server
|
|
114
|
+
- `npm run start [port]` - Start dev server on custom port
|
|
115
|
+
|
|
116
|
+
#### Package Syncing
|
|
117
|
+
|
|
118
|
+
- `npm run sync:all` - Sync all local development packages
|
|
119
|
+
- `npm run sync:core` - Sync @datalayer/core only
|
|
120
|
+
- `npm run sync:jupyter` - Sync jupyter-ui packages only
|
|
121
|
+
|
|
122
|
+
#### Build & Type Check
|
|
123
|
+
|
|
124
|
+
- `npm run build` - Build for production
|
|
125
|
+
- `npm run preview` - Preview production build
|
|
126
|
+
- `npm run type-check` - Run TypeScript type checking
|
|
127
|
+
|
|
128
|
+
### Dependencies
|
|
129
|
+
|
|
130
|
+
**Core:**
|
|
131
|
+
- `@datalayer/jupyter-lexical` - Lexical editor with Jupyter integration
|
|
132
|
+
- `@datalayer/jupyter-react` - Jupyter React components
|
|
133
|
+
- `@copilotkit/react-core` - CopilotKit core functionality
|
|
134
|
+
- `@copilotkit/react-ui` - CopilotKit UI components
|
|
135
|
+
- `lexical` - Meta's Lexical editor framework
|
|
136
|
+
|
|
137
|
+
**UI:**
|
|
138
|
+
- `@primer/react` - GitHub's Primer design system
|
|
139
|
+
- `@primer/octicons-react` - GitHub icons
|
|
140
|
+
|
|
141
|
+
## Deployment
|
|
142
|
+
|
|
143
|
+
### Build for Production
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm run build
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
This creates an optimized production build in the `dist/` directory.
|
|
150
|
+
|
|
151
|
+
### Deploy as JupyterHub App
|
|
152
|
+
|
|
153
|
+
This example can be deployed as a JupyterHub managed service:
|
|
154
|
+
|
|
155
|
+
1. Build the production bundle
|
|
156
|
+
2. Configure JupyterHub to serve the app
|
|
157
|
+
3. Set environment variables in JupyterHub config
|
|
158
|
+
4. Users can access via: `https://your-hub.com/services/copilot-lexical/`
|
|
159
|
+
|
|
160
|
+
See [JupyterHub documentation](https://jupyterhub.readthedocs.io/) for deployment details.
|
|
161
|
+
|
|
162
|
+
## Environment Variables
|
|
163
|
+
|
|
164
|
+
| Variable | Required | Description |
|
|
165
|
+
|----------|----------|-------------|
|
|
166
|
+
| `VITE_COPILOT_KIT_API_KEY` | Yes | CopilotKit API key for AI features |
|
|
167
|
+
| `VITE_DATALAYER_API_TOKEN` | No | Datalayer token (only for runtime mode) |
|
|
168
|
+
|
|
169
|
+
## Development Workflow
|
|
170
|
+
|
|
171
|
+
### Using Local Development Packages
|
|
172
|
+
|
|
173
|
+
This project can use either published npm packages or local development versions:
|
|
174
|
+
|
|
175
|
+
#### Option 1: Use Published Packages (default)
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
npm install # Installs from npm registry
|
|
179
|
+
npm run dev
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### Option 2: Use Local Development Packages
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npm install
|
|
186
|
+
npm run sync:all # Sync from ../core, ../jupyter-ui
|
|
187
|
+
npm run dev
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The sync scripts copy built `lib/` directories from sibling repositories:
|
|
191
|
+
|
|
192
|
+
- `../core/lib` → `node_modules/@datalayer/core/lib`
|
|
193
|
+
- `../jupyter-ui/packages/react/lib` → `node_modules/@datalayer/jupyter-react/lib`
|
|
194
|
+
- `../jupyter-ui/packages/lexical/lib` → `node_modules/@datalayer/jupyter-lexical/lib`
|
|
195
|
+
- `../jupyter-ui/packages/primer-addons/lib` → `node_modules/@datalayer/primer-addons/lib`
|
|
196
|
+
|
|
197
|
+
### Making Changes to Dependencies
|
|
198
|
+
|
|
199
|
+
1. Make changes in the source repository (e.g., `../jupyter-ui`)
|
|
200
|
+
2. Build the package: `npm run build` (in that repository)
|
|
201
|
+
3. Sync to copilot-lexical: `npm run sync:all`
|
|
202
|
+
4. Restart dev server if needed
|
|
203
|
+
|
|
204
|
+
## Troubleshooting
|
|
205
|
+
|
|
206
|
+
### CopilotKit not working
|
|
207
|
+
|
|
208
|
+
- Verify your API key is correct in `.env`
|
|
209
|
+
- Check browser console for errors
|
|
210
|
+
- Ensure you've configured an LLM provider in CopilotKit dashboard
|
|
211
|
+
|
|
212
|
+
### Local packages not syncing
|
|
213
|
+
|
|
214
|
+
- Ensure sibling repositories exist: `../core`, `../jupyter-ui`
|
|
215
|
+
- Build packages first: Run `npm run build` in those repos
|
|
216
|
+
- Check sync script output for warnings
|
|
217
|
+
|
|
218
|
+
### Port already in use
|
|
219
|
+
|
|
220
|
+
- Specify a different port: `npm run start 3001`
|
|
221
|
+
- Or kill the process using the port
|
|
222
|
+
|
|
223
|
+
## Contributing
|
|
224
|
+
|
|
225
|
+
1. Fork the repository
|
|
226
|
+
2. Create a feature branch
|
|
227
|
+
3. Make your changes
|
|
228
|
+
4. Add tests if applicable
|
|
229
|
+
5. Submit a pull request
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT License - Copyright (c) 2025-2026 Datalayer, Inc.
|
|
234
|
+
|
|
235
|
+
## Links
|
|
236
|
+
|
|
237
|
+
- [Datalayer](https://datalayer.ai)
|
|
238
|
+
- [Jupyter UI](https://github.com/datalayer/jupyter-ui)
|
|
239
|
+
- [CopilotKit](https://www.copilotkit.ai/)
|
|
240
|
+
- [Lexical](https://lexical.dev/)
|
|
241
|
+
|
|
242
|
+
## Support
|
|
243
|
+
|
|
244
|
+
- 📧 Email: support@datalayer.io
|
|
245
|
+
- 💬 GitHub Issues: [github.com/datalayer/copilot-lexical/issues](https://github.com/datalayer/copilot-lexical/issues)
|
|
246
|
+
- 📖 Documentation: [docs.datalayer.io](https://docs.datalayer.io)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
Main entry point for running copilot_lexical as a module.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python -m copilot_lexical [port] [path_to_folder]
|
|
7
|
+
|
|
8
|
+
Examples:
|
|
9
|
+
python -m copilot_lexical # Uses default port 3000, default path
|
|
10
|
+
python -m copilot_lexical 5182 # Uses port 5182, default path
|
|
11
|
+
python -m copilot_lexical 60499 /path/to/app # Uses port 60499, custom path
|
|
12
|
+
"""
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
import os
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
def main():
|
|
19
|
+
# Parse arguments
|
|
20
|
+
port = sys.argv[1] if len(sys.argv) > 1 else "3000"
|
|
21
|
+
|
|
22
|
+
# If path is provided, use it; otherwise use project root (parent of copilot_lexical)
|
|
23
|
+
if len(sys.argv) > 2:
|
|
24
|
+
project_root = Path(sys.argv[2]).resolve()
|
|
25
|
+
else:
|
|
26
|
+
project_root = Path(__file__).parent.parent
|
|
27
|
+
|
|
28
|
+
# Change to project directory
|
|
29
|
+
os.chdir(project_root)
|
|
30
|
+
|
|
31
|
+
# Run npm start with the specified port
|
|
32
|
+
subprocess.run(["npm", "run", "start", port])
|
|
33
|
+
|
|
34
|
+
if __name__ == "__main__":
|
|
35
|
+
main()
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: copilot-lexical
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lexical editor with CopilotKit integration
|
|
5
|
+
Author-email: goanpeca <goanpeca@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/datalayer/copilot-lexical
|
|
8
|
+
Project-URL: Repository, https://github.com/datalayer/copilot-lexical
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# CopilotKit Lexical Example
|
|
15
|
+
|
|
16
|
+
A standalone example showcasing the integration of [Datalayer's Jupyter Lexical Editor](https://github.com/datalayer/jupyter-ui) with [CopilotKit](https://www.copilotkit.ai/) AI sidebar.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- 📝 **Rich Lexical Editor** - Full-featured editor based on Meta's Lexical framework
|
|
21
|
+
- 🤖 **AI Copilot Integration** - CopilotKit sidebar for AI-assisted editing
|
|
22
|
+
- 🚀 **Jupyter Runtime Support** - Toggle between runtime and non-runtime modes
|
|
23
|
+
- 🎨 **Primer Design System** - Beautiful UI with GitHub's Primer components
|
|
24
|
+
- ⚡ **Fast Dev Server** - Powered by Vite for instant HMR
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
- Node.js >= 22.0.0
|
|
29
|
+
- npm or yarn
|
|
30
|
+
- CopilotKit API key (get from [cloud.copilotkit.ai](https://cloud.copilotkit.ai/dashboard))
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. Install Dependencies
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd /Users/goanpeca/Desktop/develop/datalayer/copilot-lexical
|
|
38
|
+
npm install
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Sync Local Development Packages (Optional)
|
|
42
|
+
|
|
43
|
+
If you're developing locally and want to use the latest code from sibling repositories:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Sync all local packages
|
|
47
|
+
npm run sync:all
|
|
48
|
+
|
|
49
|
+
# Or sync individually
|
|
50
|
+
npm run sync:core # Sync @datalayer/core
|
|
51
|
+
npm run sync:jupyter # Sync jupyter-ui packages
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. Configure Environment
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cd copilot-lexical
|
|
58
|
+
cp .env.example .env
|
|
59
|
+
|
|
60
|
+
# Edit .env and add your CopilotKit API key
|
|
61
|
+
VITE_COPILOT_KIT_API_KEY=your_api_key_here
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 4. Run Development Server
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Start on default port (3000)
|
|
68
|
+
npm run dev
|
|
69
|
+
|
|
70
|
+
# Or sync local packages and start dev server
|
|
71
|
+
npm run dev:sync
|
|
72
|
+
|
|
73
|
+
# Or specify a custom port
|
|
74
|
+
npm run start 8080
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 5. Open in Browser
|
|
78
|
+
|
|
79
|
+
Navigate to [http://localhost:3000](http://localhost:3000)
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
### Toggle Kernel Mode
|
|
84
|
+
|
|
85
|
+
Use the header buttons to toggle between:
|
|
86
|
+
- **Without Runtime** - Static editor without Jupyter kernel
|
|
87
|
+
- **With Runtime** - Full Jupyter notebook capabilities with code execution
|
|
88
|
+
|
|
89
|
+
### AI Copilot
|
|
90
|
+
|
|
91
|
+
The CopilotKit sidebar provides AI-assisted editing:
|
|
92
|
+
- Ask the AI to insert content
|
|
93
|
+
- Format text and structure
|
|
94
|
+
- Manipulate the document
|
|
95
|
+
- Get writing suggestions
|
|
96
|
+
|
|
97
|
+
Example prompts:
|
|
98
|
+
- "Insert a heading"
|
|
99
|
+
- "Add a code block with Python code"
|
|
100
|
+
- "Create a bulleted list"
|
|
101
|
+
- "Format this text as bold"
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
### Project Structure
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
copilot-lexical/
|
|
109
|
+
├── src/
|
|
110
|
+
│ ├── App.tsx # Main application component
|
|
111
|
+
│ ├── App.css # Application styles
|
|
112
|
+
│ ├── main.tsx # Entry point
|
|
113
|
+
│ └── index.css # Global styles
|
|
114
|
+
├── index.html # HTML template
|
|
115
|
+
├── vite.config.ts # Vite configuration
|
|
116
|
+
├── tsconfig.json # TypeScript config
|
|
117
|
+
├── package.json # Dependencies and scripts
|
|
118
|
+
└── README.md # This file
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Scripts
|
|
122
|
+
|
|
123
|
+
#### Dev Server
|
|
124
|
+
|
|
125
|
+
- `npm run dev` - Start development server (default port 3000)
|
|
126
|
+
- `npm run dev:sync` - Sync local packages and start dev server
|
|
127
|
+
- `npm run start [port]` - Start dev server on custom port
|
|
128
|
+
|
|
129
|
+
#### Package Syncing
|
|
130
|
+
|
|
131
|
+
- `npm run sync:all` - Sync all local development packages
|
|
132
|
+
- `npm run sync:core` - Sync @datalayer/core only
|
|
133
|
+
- `npm run sync:jupyter` - Sync jupyter-ui packages only
|
|
134
|
+
|
|
135
|
+
#### Build & Type Check
|
|
136
|
+
|
|
137
|
+
- `npm run build` - Build for production
|
|
138
|
+
- `npm run preview` - Preview production build
|
|
139
|
+
- `npm run type-check` - Run TypeScript type checking
|
|
140
|
+
|
|
141
|
+
### Dependencies
|
|
142
|
+
|
|
143
|
+
**Core:**
|
|
144
|
+
- `@datalayer/jupyter-lexical` - Lexical editor with Jupyter integration
|
|
145
|
+
- `@datalayer/jupyter-react` - Jupyter React components
|
|
146
|
+
- `@copilotkit/react-core` - CopilotKit core functionality
|
|
147
|
+
- `@copilotkit/react-ui` - CopilotKit UI components
|
|
148
|
+
- `lexical` - Meta's Lexical editor framework
|
|
149
|
+
|
|
150
|
+
**UI:**
|
|
151
|
+
- `@primer/react` - GitHub's Primer design system
|
|
152
|
+
- `@primer/octicons-react` - GitHub icons
|
|
153
|
+
|
|
154
|
+
## Deployment
|
|
155
|
+
|
|
156
|
+
### Build for Production
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npm run build
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This creates an optimized production build in the `dist/` directory.
|
|
163
|
+
|
|
164
|
+
### Deploy as JupyterHub App
|
|
165
|
+
|
|
166
|
+
This example can be deployed as a JupyterHub managed service:
|
|
167
|
+
|
|
168
|
+
1. Build the production bundle
|
|
169
|
+
2. Configure JupyterHub to serve the app
|
|
170
|
+
3. Set environment variables in JupyterHub config
|
|
171
|
+
4. Users can access via: `https://your-hub.com/services/copilot-lexical/`
|
|
172
|
+
|
|
173
|
+
See [JupyterHub documentation](https://jupyterhub.readthedocs.io/) for deployment details.
|
|
174
|
+
|
|
175
|
+
## Environment Variables
|
|
176
|
+
|
|
177
|
+
| Variable | Required | Description |
|
|
178
|
+
|----------|----------|-------------|
|
|
179
|
+
| `VITE_COPILOT_KIT_API_KEY` | Yes | CopilotKit API key for AI features |
|
|
180
|
+
| `VITE_DATALAYER_API_TOKEN` | No | Datalayer token (only for runtime mode) |
|
|
181
|
+
|
|
182
|
+
## Development Workflow
|
|
183
|
+
|
|
184
|
+
### Using Local Development Packages
|
|
185
|
+
|
|
186
|
+
This project can use either published npm packages or local development versions:
|
|
187
|
+
|
|
188
|
+
#### Option 1: Use Published Packages (default)
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm install # Installs from npm registry
|
|
192
|
+
npm run dev
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Option 2: Use Local Development Packages
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npm install
|
|
199
|
+
npm run sync:all # Sync from ../core, ../jupyter-ui
|
|
200
|
+
npm run dev
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The sync scripts copy built `lib/` directories from sibling repositories:
|
|
204
|
+
|
|
205
|
+
- `../core/lib` → `node_modules/@datalayer/core/lib`
|
|
206
|
+
- `../jupyter-ui/packages/react/lib` → `node_modules/@datalayer/jupyter-react/lib`
|
|
207
|
+
- `../jupyter-ui/packages/lexical/lib` → `node_modules/@datalayer/jupyter-lexical/lib`
|
|
208
|
+
- `../jupyter-ui/packages/primer-addons/lib` → `node_modules/@datalayer/primer-addons/lib`
|
|
209
|
+
|
|
210
|
+
### Making Changes to Dependencies
|
|
211
|
+
|
|
212
|
+
1. Make changes in the source repository (e.g., `../jupyter-ui`)
|
|
213
|
+
2. Build the package: `npm run build` (in that repository)
|
|
214
|
+
3. Sync to copilot-lexical: `npm run sync:all`
|
|
215
|
+
4. Restart dev server if needed
|
|
216
|
+
|
|
217
|
+
## Troubleshooting
|
|
218
|
+
|
|
219
|
+
### CopilotKit not working
|
|
220
|
+
|
|
221
|
+
- Verify your API key is correct in `.env`
|
|
222
|
+
- Check browser console for errors
|
|
223
|
+
- Ensure you've configured an LLM provider in CopilotKit dashboard
|
|
224
|
+
|
|
225
|
+
### Local packages not syncing
|
|
226
|
+
|
|
227
|
+
- Ensure sibling repositories exist: `../core`, `../jupyter-ui`
|
|
228
|
+
- Build packages first: Run `npm run build` in those repos
|
|
229
|
+
- Check sync script output for warnings
|
|
230
|
+
|
|
231
|
+
### Port already in use
|
|
232
|
+
|
|
233
|
+
- Specify a different port: `npm run start 3001`
|
|
234
|
+
- Or kill the process using the port
|
|
235
|
+
|
|
236
|
+
## Contributing
|
|
237
|
+
|
|
238
|
+
1. Fork the repository
|
|
239
|
+
2. Create a feature branch
|
|
240
|
+
3. Make your changes
|
|
241
|
+
4. Add tests if applicable
|
|
242
|
+
5. Submit a pull request
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT License - Copyright (c) 2025-2026 Datalayer, Inc.
|
|
247
|
+
|
|
248
|
+
## Links
|
|
249
|
+
|
|
250
|
+
- [Datalayer](https://datalayer.ai)
|
|
251
|
+
- [Jupyter UI](https://github.com/datalayer/jupyter-ui)
|
|
252
|
+
- [CopilotKit](https://www.copilotkit.ai/)
|
|
253
|
+
- [Lexical](https://lexical.dev/)
|
|
254
|
+
|
|
255
|
+
## Support
|
|
256
|
+
|
|
257
|
+
- 📧 Email: support@datalayer.io
|
|
258
|
+
- 💬 GitHub Issues: [github.com/datalayer/copilot-lexical/issues](https://github.com/datalayer/copilot-lexical/issues)
|
|
259
|
+
- 📖 Documentation: [docs.datalayer.io](https://docs.datalayer.io)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
copilot_lexical/__init__.py
|
|
5
|
+
copilot_lexical/__main__.py
|
|
6
|
+
copilot_lexical.egg-info/PKG-INFO
|
|
7
|
+
copilot_lexical.egg-info/SOURCES.txt
|
|
8
|
+
copilot_lexical.egg-info/dependency_links.txt
|
|
9
|
+
copilot_lexical.egg-info/entry_points.txt
|
|
10
|
+
copilot_lexical.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
copilot_lexical
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "copilot-lexical"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Lexical editor with CopilotKit integration"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "goanpeca", email = "goanpeca@gmail.com" }
|
|
13
|
+
]
|
|
14
|
+
license = { text = "MIT" }
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Homepage = "https://github.com/datalayer/copilot-lexical"
|
|
18
|
+
Repository = "https://github.com/datalayer/copilot-lexical"
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
copilot-lexical = "copilot_lexical.__main__:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["."]
|
|
25
|
+
include = ["copilot_lexical*"]
|