gwchq-textjam 0.1.7 → 0.1.9
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.
- package/LICENSE.txt +202 -202
- package/README.md +253 -256
- package/dist/assets/{PyodideWorkerdf6f34ea7e2b4495f8d4.js → PyodideWorker917534d142d1f853d376.js} +528 -528
- package/dist/assets/{pygalef3b78a56cb1d66beb61.js → pygalc0b4f32d2d2cc5a0c638.js} +495 -495
- package/dist/index.js +4891 -5793
- package/dist/style.css +8 -9
- package/package.json +268 -268
- package/dist/assets/gwc-logoa61b092912e3c38825d3.svg +0 -33
package/README.md
CHANGED
|
@@ -1,256 +1,253 @@
|
|
|
1
|
-
# Getting Started
|
|
2
|
-
|
|
3
|
-
This project provides a React component containing the Raspberry Pi Code Editor for embedding inside other applications. Although originally bootstrapped with [Create React App](https://github.com/facebook/create-react-app), the application has been ejected so all the build scripts etc. are now in the repo. Legacy web-component assets are still published for backwards compatibility, but the primary integration surface is the `TextJamEditor` React component.
|
|
4
|
-
|
|
5
|
-
# Local development
|
|
6
|
-
|
|
7
|
-
The app test page at `http://localhost:3011` can be used to develop the React component in isolation if needed.
|
|
8
|
-
|
|
9
|
-
## Install dependencies
|
|
10
|
-
|
|
11
|
-
This repository uses Yarn 3 (see `package.json` → `packageManager`). Please install dependencies with Yarn:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
yarn install
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Using `npm install` can fail due to strict peer-dependency resolution in npm for some legacy packages in this project.
|
|
18
|
-
|
|
19
|
-
## Available Scripts
|
|
20
|
-
|
|
21
|
-
In the project directory, you can run:
|
|
22
|
-
|
|
23
|
-
### `yarn start`
|
|
24
|
-
|
|
25
|
-
Runs the app in the development mode.\
|
|
26
|
-
Open [http://localhost:3011](http://localhost:3011) to view the web component test page in the browser.
|
|
27
|
-
|
|
28
|
-
The page will reload if you make edits.\
|
|
29
|
-
You will also see any lint errors in the console.
|
|
30
|
-
|
|
31
|
-
### `yarn test`
|
|
32
|
-
|
|
33
|
-
Launches the test runner in interactive watch mode.\
|
|
34
|
-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
35
|
-
|
|
36
|
-
### `yarn build:lib`
|
|
37
|
-
|
|
38
|
-
Builds the lib for production to the `dist` folder.\
|
|
39
|
-
It bundles React in production mode and optimizes the build for the best performance.
|
|
40
|
-
|
|
41
|
-
The build is minified and the filenames include the hashes.\
|
|
42
|
-
Your app is ready to be deployed!
|
|
43
|
-
|
|
44
|
-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
45
|
-
|
|
46
|
-
## Styling
|
|
47
|
-
|
|
48
|
-
The dev playground (`webpack.config.js`) keeps styles in JavaScript via `style-loader` for the fastest live reload experience. The library build (`webpack.lib.config.js`) extracts all CSS/SCSS into `dist/style.css` using `MiniCssExtractPlugin` so consumers can import a single stylesheet while still benefitting from CSS Modules (`*.module.(css|scss)`) for scoped styles.
|
|
49
|
-
|
|
50
|
-
### Styling Best Practices for Developers
|
|
51
|
-
|
|
52
|
-
**Focus on CSS Modules**: When adding or modifying styles, prioritize CSS Modules over global styles. Use the `.module.css` or `.module.scss` naming convention to ensure styles are scoped to components and avoid style conflicts.
|
|
53
|
-
|
|
54
|
-
**Refactor Global Styles**: When working on existing code, identify global styles and refactor them into CSS Modules when possible. This improves maintainability, reduces style conflicts, and makes components more self-contained.
|
|
55
|
-
|
|
56
|
-
**CSS Modules Structure**:
|
|
57
|
-
- Component-specific styles should live in `ComponentName/styles.module.scss` alongside the component
|
|
58
|
-
- Import styles as: `import classes from './styles.module.scss'`
|
|
59
|
-
- Use class names from the imported styles object: `className={classes.container}`
|
|
60
|
-
- Webpack automatically generates scoped class names like `ComponentName__container--abc123`
|
|
61
|
-
|
|
62
|
-
**When Global Styles Are Acceptable**:
|
|
63
|
-
- Design system tokens and variables (e.g., color palettes, spacing scales)
|
|
64
|
-
- Third-party library overrides that cannot be modularized
|
|
65
|
-
- Base resets or typography that must apply globally
|
|
66
|
-
|
|
67
|
-
**Example - Preferred CSS Modules Approach**:
|
|
68
|
-
```jsx
|
|
69
|
-
// ComponentName/ComponentName.jsx
|
|
70
|
-
import classes from './styles.module.scss';
|
|
71
|
-
|
|
72
|
-
export function ComponentName() {
|
|
73
|
-
return <div className={classes.container}>Content</div>;
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
```scss
|
|
78
|
-
// ComponentName/styles.module.scss
|
|
79
|
-
.container {
|
|
80
|
-
padding: 1rem;
|
|
81
|
-
background: var(--color-background);
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Testing
|
|
86
|
-
|
|
87
|
-
Automated unit tests can be run via the `yarn test` command. These unit tests are written using the JavaScript testing framework `Jest` and make use of the tools provided by the [React Testing Library](https://testing-library.com/docs/). Automated accessibility testing for components is available via the `jest-axe` library. This can be achieved using the `haveNoViolations` matcher provided by `jest-axe`, although this does not guarantee that the tested components have no accessibility issues.
|
|
88
|
-
|
|
89
|
-
## Publishing to npm
|
|
90
|
-
|
|
91
|
-
### Prerequisites
|
|
92
|
-
|
|
93
|
-
1. Ensure you're logged into npm:
|
|
94
|
-
```bash
|
|
95
|
-
npm login
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
2. Verify you have publish access to the `gwchq-textjam` package.
|
|
99
|
-
|
|
100
|
-
3. Make sure all changes are committed and the working directory is clean.
|
|
101
|
-
|
|
102
|
-
### Publishing Steps
|
|
103
|
-
|
|
104
|
-
1. **Update the version** in `package.json` following [semantic versioning](https://semver.org/):
|
|
105
|
-
- Patch: `0.1.2` → `0.1.3` (bug fixes)
|
|
106
|
-
- Minor: `0.1.2` → `0.2.0` (new features, backwards compatible)
|
|
107
|
-
- Major: `0.1.2` → `1.0.0` (breaking changes)
|
|
108
|
-
|
|
109
|
-
2. **Build the library** (automatically runs via `prepublishOnly` hook):
|
|
110
|
-
```bash
|
|
111
|
-
yarn build:lib
|
|
112
|
-
```
|
|
113
|
-
This creates the `dist` folder with:
|
|
114
|
-
- `index.js` - The main ESM module
|
|
115
|
-
- `style.css` - Extracted stylesheet
|
|
116
|
-
- `assets/` - Static assets (icons, fonts, etc.)
|
|
117
|
-
|
|
118
|
-
3. **Verify the build output**:
|
|
119
|
-
- Check that `dist/index.js` exists and is properly built
|
|
120
|
-
- Verify `dist/style.css` contains all styles
|
|
121
|
-
- Ensure all required assets are in `dist/assets/`
|
|
122
|
-
|
|
123
|
-
4. **Publish to npm**:
|
|
124
|
-
```bash
|
|
125
|
-
npm publish
|
|
126
|
-
```
|
|
127
|
-
The `prepublishOnly` script will automatically run `yarn build:lib` before publishing.
|
|
128
|
-
|
|
129
|
-
5. **Verify publication**:
|
|
130
|
-
```bash
|
|
131
|
-
npm view gwchq-textjam version
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### What Gets Published
|
|
135
|
-
|
|
136
|
-
The following files are included in the npm package (as defined in `package.json` → `files`):
|
|
137
|
-
- `dist/` - Built library files
|
|
138
|
-
- `README.md` - This file
|
|
139
|
-
- `LICENSE` - License file
|
|
140
|
-
|
|
141
|
-
### Package Exports
|
|
142
|
-
|
|
143
|
-
Consumers can import:
|
|
144
|
-
- Main component: `import { TextJamEditor } from "gwchq-textjam"`
|
|
145
|
-
- Stylesheet: `import "gwchq-textjam/style.css"`
|
|
146
|
-
|
|
147
|
-
# Using the editor as a React component
|
|
148
|
-
|
|
149
|
-
The editor can be imported and rendered directly inside another React application. The package exports the `TextJamEditor` component and `styles.css`:
|
|
150
|
-
|
|
151
|
-
```tsx
|
|
152
|
-
import { TextJamEditor } from "gwchq-textjam";
|
|
153
|
-
import "gwchq-textjam/style.css"
|
|
154
|
-
|
|
155
|
-
export function EditorWrapper() {
|
|
156
|
-
return (
|
|
157
|
-
<TextJamEditor
|
|
158
|
-
project={{ project_type: "python", identifier: "my-py-app" }}
|
|
159
|
-
/>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
The consumer's webpack config should include the following setups
|
|
165
|
-
```
|
|
166
|
-
{
|
|
167
|
-
...,
|
|
168
|
-
modules: {
|
|
169
|
-
rules: [
|
|
170
|
-
...,
|
|
171
|
-
{
|
|
172
|
-
test: /\.map$/,
|
|
173
|
-
type: "asset/resource",
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
test: /\.whl$/,
|
|
177
|
-
type: "asset/resource",
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
test: /\.glb$/,
|
|
181
|
-
type: "asset/resource",
|
|
182
|
-
},
|
|
183
|
-
]
|
|
184
|
-
},
|
|
185
|
-
plugins: [
|
|
186
|
-
new CopyWebpackPlugin({
|
|
187
|
-
patterns: [
|
|
188
|
-
...,
|
|
189
|
-
{
|
|
190
|
-
from: "node_modules/gwchq-textjam/dist/assets",
|
|
191
|
-
to: "assets",
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
}),
|
|
195
|
-
],
|
|
196
|
-
resolve: {
|
|
197
|
-
extensions: ['.js', '.jsx'],
|
|
198
|
-
alias: {
|
|
199
|
-
'react': path.resolve(__dirname, 'node_modules/react'),
|
|
200
|
-
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
|
|
201
|
-
'react-redux': path.resolve(__dirname, 'node_modules/react-redux'),
|
|
202
|
-
},
|
|
203
|
-
fallback: {
|
|
204
|
-
stream: require.resolve('stream-browserify'),
|
|
205
|
-
path: require.resolve('path-browserify'),
|
|
206
|
-
util: require.resolve('util/'),
|
|
207
|
-
assert: require.resolve("assert"),
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### Component props
|
|
214
|
-
|
|
215
|
-
`TextJamEditor` accepts the following props (previously exposed as web-component attributes):
|
|
216
|
-
|
|
217
|
-
- `project`: an object with the project data. Contains the following props:
|
|
218
|
-
- `project_type`: Possible values `web` | `python`. Default project files will be created according to this value
|
|
219
|
-
- `identifier`: A string that represents the project id. If provided, cached project with same id will be loaded
|
|
220
|
-
|
|
221
|
-
// TODO: review old options below
|
|
222
|
-
- `code`: A preset blob of code to show in the editor pane (overrides content of `main.py`/`index.html`)
|
|
223
|
-
- `embedded`: Enable embedded mode which hides some functionality (defaults to `false`)
|
|
224
|
-
- `loadCache`: Load latest version of project code from local storage (defaults to `true`)
|
|
225
|
-
- `locale`: Locale for UI elements and to determine the language of projects loaded from the API (defaults to `en`)
|
|
226
|
-
- `outputOnly`: Only display the output panel (defaults to `false`)
|
|
227
|
-
- `outputPanels`: Array of output panel names to display (defaults to `['text', 'visual']`)
|
|
228
|
-
- `outputSplitView`: Start with split view in output panel (defaults to `false`, i.e. tabbed view)
|
|
229
|
-
- `projectNameEditable`: Allow the user to edit the project name in the project bar (defaults to `false`)
|
|
230
|
-
- `readOnly`: Display the editor in read-only mode (defaults to `false`)
|
|
231
|
-
- `showSavePrompt`: Prompt the user to save their work (defaults to `false`)
|
|
232
|
-
- `sidebarOptions`: Array of strings specifying the panels to be displayed in the sidebar. Options include `"projects"`, `"file"`, `"download"`, `"settings"`.
|
|
233
|
-
- `
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
- `editor-
|
|
245
|
-
- `editor-
|
|
246
|
-
- `editor-
|
|
247
|
-
- `editor-
|
|
248
|
-
- `editor-
|
|
249
|
-
- `editor-
|
|
250
|
-
- `editor-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
These events make it possible for the host page to react to code execution, project changes, authentication requests, and theme updates.
|
|
256
|
-
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
This project provides a React component containing the Raspberry Pi Code Editor for embedding inside other applications. Although originally bootstrapped with [Create React App](https://github.com/facebook/create-react-app), the application has been ejected so all the build scripts etc. are now in the repo. Legacy web-component assets are still published for backwards compatibility, but the primary integration surface is the `TextJamEditor` React component.
|
|
4
|
+
|
|
5
|
+
# Local development
|
|
6
|
+
|
|
7
|
+
The app test page at `http://localhost:3011` can be used to develop the React component in isolation if needed.
|
|
8
|
+
|
|
9
|
+
## Install dependencies
|
|
10
|
+
|
|
11
|
+
This repository uses Yarn 3 (see `package.json` → `packageManager`). Please install dependencies with Yarn:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
yarn install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Using `npm install` can fail due to strict peer-dependency resolution in npm for some legacy packages in this project.
|
|
18
|
+
|
|
19
|
+
## Available Scripts
|
|
20
|
+
|
|
21
|
+
In the project directory, you can run:
|
|
22
|
+
|
|
23
|
+
### `yarn start`
|
|
24
|
+
|
|
25
|
+
Runs the app in the development mode.\
|
|
26
|
+
Open [http://localhost:3011](http://localhost:3011) to view the web component test page in the browser.
|
|
27
|
+
|
|
28
|
+
The page will reload if you make edits.\
|
|
29
|
+
You will also see any lint errors in the console.
|
|
30
|
+
|
|
31
|
+
### `yarn test`
|
|
32
|
+
|
|
33
|
+
Launches the test runner in interactive watch mode.\
|
|
34
|
+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
35
|
+
|
|
36
|
+
### `yarn build:lib`
|
|
37
|
+
|
|
38
|
+
Builds the lib for production to the `dist` folder.\
|
|
39
|
+
It bundles React in production mode and optimizes the build for the best performance.
|
|
40
|
+
|
|
41
|
+
The build is minified and the filenames include the hashes.\
|
|
42
|
+
Your app is ready to be deployed!
|
|
43
|
+
|
|
44
|
+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
45
|
+
|
|
46
|
+
## Styling
|
|
47
|
+
|
|
48
|
+
The dev playground (`webpack.config.js`) keeps styles in JavaScript via `style-loader` for the fastest live reload experience. The library build (`webpack.lib.config.js`) extracts all CSS/SCSS into `dist/style.css` using `MiniCssExtractPlugin` so consumers can import a single stylesheet while still benefitting from CSS Modules (`*.module.(css|scss)`) for scoped styles.
|
|
49
|
+
|
|
50
|
+
### Styling Best Practices for Developers
|
|
51
|
+
|
|
52
|
+
**Focus on CSS Modules**: When adding or modifying styles, prioritize CSS Modules over global styles. Use the `.module.css` or `.module.scss` naming convention to ensure styles are scoped to components and avoid style conflicts.
|
|
53
|
+
|
|
54
|
+
**Refactor Global Styles**: When working on existing code, identify global styles and refactor them into CSS Modules when possible. This improves maintainability, reduces style conflicts, and makes components more self-contained.
|
|
55
|
+
|
|
56
|
+
**CSS Modules Structure**:
|
|
57
|
+
- Component-specific styles should live in `ComponentName/styles.module.scss` alongside the component
|
|
58
|
+
- Import styles as: `import classes from './styles.module.scss'`
|
|
59
|
+
- Use class names from the imported styles object: `className={classes.container}`
|
|
60
|
+
- Webpack automatically generates scoped class names like `ComponentName__container--abc123`
|
|
61
|
+
|
|
62
|
+
**When Global Styles Are Acceptable**:
|
|
63
|
+
- Design system tokens and variables (e.g., color palettes, spacing scales)
|
|
64
|
+
- Third-party library overrides that cannot be modularized
|
|
65
|
+
- Base resets or typography that must apply globally
|
|
66
|
+
|
|
67
|
+
**Example - Preferred CSS Modules Approach**:
|
|
68
|
+
```jsx
|
|
69
|
+
// ComponentName/ComponentName.jsx
|
|
70
|
+
import classes from './styles.module.scss';
|
|
71
|
+
|
|
72
|
+
export function ComponentName() {
|
|
73
|
+
return <div className={classes.container}>Content</div>;
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```scss
|
|
78
|
+
// ComponentName/styles.module.scss
|
|
79
|
+
.container {
|
|
80
|
+
padding: 1rem;
|
|
81
|
+
background: var(--color-background);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Testing
|
|
86
|
+
|
|
87
|
+
Automated unit tests can be run via the `yarn test` command. These unit tests are written using the JavaScript testing framework `Jest` and make use of the tools provided by the [React Testing Library](https://testing-library.com/docs/). Automated accessibility testing for components is available via the `jest-axe` library. This can be achieved using the `haveNoViolations` matcher provided by `jest-axe`, although this does not guarantee that the tested components have no accessibility issues.
|
|
88
|
+
|
|
89
|
+
## Publishing to npm
|
|
90
|
+
|
|
91
|
+
### Prerequisites
|
|
92
|
+
|
|
93
|
+
1. Ensure you're logged into npm:
|
|
94
|
+
```bash
|
|
95
|
+
npm login
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
2. Verify you have publish access to the `gwchq-textjam` package.
|
|
99
|
+
|
|
100
|
+
3. Make sure all changes are committed and the working directory is clean.
|
|
101
|
+
|
|
102
|
+
### Publishing Steps
|
|
103
|
+
|
|
104
|
+
1. **Update the version** in `package.json` following [semantic versioning](https://semver.org/):
|
|
105
|
+
- Patch: `0.1.2` → `0.1.3` (bug fixes)
|
|
106
|
+
- Minor: `0.1.2` → `0.2.0` (new features, backwards compatible)
|
|
107
|
+
- Major: `0.1.2` → `1.0.0` (breaking changes)
|
|
108
|
+
|
|
109
|
+
2. **Build the library** (automatically runs via `prepublishOnly` hook):
|
|
110
|
+
```bash
|
|
111
|
+
yarn build:lib
|
|
112
|
+
```
|
|
113
|
+
This creates the `dist` folder with:
|
|
114
|
+
- `index.js` - The main ESM module
|
|
115
|
+
- `style.css` - Extracted stylesheet
|
|
116
|
+
- `assets/` - Static assets (icons, fonts, etc.)
|
|
117
|
+
|
|
118
|
+
3. **Verify the build output**:
|
|
119
|
+
- Check that `dist/index.js` exists and is properly built
|
|
120
|
+
- Verify `dist/style.css` contains all styles
|
|
121
|
+
- Ensure all required assets are in `dist/assets/`
|
|
122
|
+
|
|
123
|
+
4. **Publish to npm**:
|
|
124
|
+
```bash
|
|
125
|
+
npm publish
|
|
126
|
+
```
|
|
127
|
+
The `prepublishOnly` script will automatically run `yarn build:lib` before publishing.
|
|
128
|
+
|
|
129
|
+
5. **Verify publication**:
|
|
130
|
+
```bash
|
|
131
|
+
npm view gwchq-textjam version
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### What Gets Published
|
|
135
|
+
|
|
136
|
+
The following files are included in the npm package (as defined in `package.json` → `files`):
|
|
137
|
+
- `dist/` - Built library files
|
|
138
|
+
- `README.md` - This file
|
|
139
|
+
- `LICENSE` - License file
|
|
140
|
+
|
|
141
|
+
### Package Exports
|
|
142
|
+
|
|
143
|
+
Consumers can import:
|
|
144
|
+
- Main component: `import { TextJamEditor } from "gwchq-textjam"`
|
|
145
|
+
- Stylesheet: `import "gwchq-textjam/style.css"`
|
|
146
|
+
|
|
147
|
+
# Using the editor as a React component
|
|
148
|
+
|
|
149
|
+
The editor can be imported and rendered directly inside another React application. The package exports the `TextJamEditor` component and `styles.css`:
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
import { TextJamEditor } from "gwchq-textjam";
|
|
153
|
+
import "gwchq-textjam/style.css"
|
|
154
|
+
|
|
155
|
+
export function EditorWrapper() {
|
|
156
|
+
return (
|
|
157
|
+
<TextJamEditor
|
|
158
|
+
project={{ project_type: "python", identifier: "my-py-app" }}
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The consumer's webpack config should include the following setups
|
|
165
|
+
```
|
|
166
|
+
{
|
|
167
|
+
...,
|
|
168
|
+
modules: {
|
|
169
|
+
rules: [
|
|
170
|
+
...,
|
|
171
|
+
{
|
|
172
|
+
test: /\.map$/,
|
|
173
|
+
type: "asset/resource",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
test: /\.whl$/,
|
|
177
|
+
type: "asset/resource",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
test: /\.glb$/,
|
|
181
|
+
type: "asset/resource",
|
|
182
|
+
},
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
plugins: [
|
|
186
|
+
new CopyWebpackPlugin({
|
|
187
|
+
patterns: [
|
|
188
|
+
...,
|
|
189
|
+
{
|
|
190
|
+
from: "node_modules/gwchq-textjam/dist/assets",
|
|
191
|
+
to: "assets",
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
}),
|
|
195
|
+
],
|
|
196
|
+
resolve: {
|
|
197
|
+
extensions: ['.js', '.jsx'],
|
|
198
|
+
alias: {
|
|
199
|
+
'react': path.resolve(__dirname, 'node_modules/react'),
|
|
200
|
+
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
|
|
201
|
+
'react-redux': path.resolve(__dirname, 'node_modules/react-redux'),
|
|
202
|
+
},
|
|
203
|
+
fallback: {
|
|
204
|
+
stream: require.resolve('stream-browserify'),
|
|
205
|
+
path: require.resolve('path-browserify'),
|
|
206
|
+
util: require.resolve('util/'),
|
|
207
|
+
assert: require.resolve("assert"),
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Component props
|
|
214
|
+
|
|
215
|
+
`TextJamEditor` accepts the following props (previously exposed as web-component attributes):
|
|
216
|
+
|
|
217
|
+
- `project`: an object with the project data. Contains the following props:
|
|
218
|
+
- `project_type`: Possible values `web` | `python`. Default project files will be created according to this value
|
|
219
|
+
- `identifier`: A string that represents the project id. If provided, cached project with same id will be loaded
|
|
220
|
+
|
|
221
|
+
// TODO: review old options below
|
|
222
|
+
- `code`: A preset blob of code to show in the editor pane (overrides content of `main.py`/`index.html`)
|
|
223
|
+
- `embedded`: Enable embedded mode which hides some functionality (defaults to `false`)
|
|
224
|
+
- `loadCache`: Load latest version of project code from local storage (defaults to `true`)
|
|
225
|
+
- `locale`: Locale for UI elements and to determine the language of projects loaded from the API (defaults to `en`)
|
|
226
|
+
- `outputOnly`: Only display the output panel (defaults to `false`)
|
|
227
|
+
- `outputPanels`: Array of output panel names to display (defaults to `['text', 'visual']`)
|
|
228
|
+
- `outputSplitView`: Start with split view in output panel (defaults to `false`, i.e. tabbed view)
|
|
229
|
+
- `projectNameEditable`: Allow the user to edit the project name in the project bar (defaults to `false`)
|
|
230
|
+
- `readOnly`: Display the editor in read-only mode (defaults to `false`)
|
|
231
|
+
- `showSavePrompt`: Prompt the user to save their work (defaults to `false`)
|
|
232
|
+
- `sidebarOptions`: Array of strings specifying the panels to be displayed in the sidebar. Options include `"projects"`, `"file"`, `"download"`, `"settings"`.
|
|
233
|
+
- `theme`: Force editor into `"dark"` or `"light"` mode; browser/system preferences are used when omitted
|
|
234
|
+
|
|
235
|
+
When no props are supplied the component falls back to parsing the current page’s query string so the local development experience (`yarn start`) continues to work unchanged. You can override this by explicitly passing `queryString` or the equivalent props.
|
|
236
|
+
|
|
237
|
+
### Events and callbacks
|
|
238
|
+
|
|
239
|
+
For backwards compatibility the editor continues to dispatch the following `document` events. You can listen for them from your host application if you rely on the legacy integration layer:
|
|
240
|
+
|
|
241
|
+
- `editor-codeChanged`
|
|
242
|
+
- `editor-navigateToProjectsPage`
|
|
243
|
+
- `editor-projectOwnerLoaded`
|
|
244
|
+
- `editor-runCompleted`
|
|
245
|
+
- `editor-runStarted`
|
|
246
|
+
- `editor-stepChanged`
|
|
247
|
+
- `editor-logIn`
|
|
248
|
+
- `editor-signUp`
|
|
249
|
+
- `editor-quizReady`
|
|
250
|
+
- `editor-themeUpdated`
|
|
251
|
+
|
|
252
|
+
These events make it possible for the host page to react to code execution, project changes, authentication requests, and theme updates.
|
|
253
|
+
|