22
33Now you can integrate our code cells into your webapps and run AO LUA anywhere 🎉
44
5+ [ ![ npm] ( https://img.shields.io/badge/@betteridea/codecell-npm-red )] ( https://www.npmjs.com/package/@betteridea/codecell )
6+ [ ![ downloads] ( https://img.shields.io/npm/dt/@betteridea/codecell?color=red )] ( https://www.npmjs.com/package/@betteridea/codecell )
7+ [ ![ X Follow] ( https://img.shields.io/twitter/follow/betteridea-dev )] ( https://twitter.com/betteridea-dev )
8+
9+
510## Installation
611
712``` bash
813npm install @betteridea/codecell
914```
1015
16+ ## API
17+
18+ ### ` CodeCell `
19+
20+ A react component to render a code cell in your app.
21+
22+ #### Props
23+
24+ - ` cellId ` - Unique id for the cell
25+ - ` appName ` - Unique app name
26+ - ` code ` - Initial code for the cell
27+ - ` width ` - Width of the cell
28+ - ` height ` - Height of the cell
29+ - ` className ` - Class names for styling
30+ - ` style ` - Inline styles
31+ - ` devMode ` - Boolean to enable dev mode
32+
33+ ### ` setCellCode `
34+
35+ To update the code in a cell, after it has been rendered.
36+ It is discouraged to update code by changing the ` code ` prop directly, since it re-renders the iframe, again this is personal preference.
37+
38+ #### Arguments
39+
40+ - ` cellId ` - Unique id of the cell
41+ - ` code ` - Code to set in the cell
42+ - ` devMode ` - Boolean to enable dev mode
43+
44+
45+ ### ~~ ` runCell ` ~~ (deprecated due to security reasons)
46+
47+ ~~ To run the code in a cell, after it has been rendered (optional, since the cell already has a run button)~~
48+
49+ #### ~~ Arguments~~
50+
51+ - ~~ ` cellId ` - Unique id of the cell to run~~
52+ - ~~ ` devMode ` - Boolean to enable dev mode~~
53+
1154## Usage
1255
1356``` javascript
@@ -21,7 +64,7 @@ import { CodeCell, runCell } from '@betteridea/codecell';
2164/ >
2265```
2366
24- To run code from external sources, you can use the ` runCell ` function.
67+ ~~ To run code from external sources, you can use the ` runCell ` function.~~ (deprecated due to security reasons)
2568
2669``` javascript
2770import { runCell } from ' @betteridea/codecell' ;
@@ -32,27 +75,16 @@ import { runCell } from '@betteridea/codecell';
3275runCell (" 1" );
3376```
3477
35- ## API
36-
37- ### ` CodeCell `
38-
39- #### Props
40-
41- - ` cellId ` - Unique id for the cell
42- - ` appName ` - Unique app name
43- - ` code ` - Initial code for the cell
44- - ` width ` - Width of the cell
45- - ` height ` - Height of the cell
46- - ` className ` - Class names for styling
47- - ` style ` - Inline styles
48- - ` devMode ` - Boolean to enable dev mode
78+ To update the cell with a different code snippet, you can use the ` setCellCode ` function.
4979
50- ### ` runCell `
80+ ``` javascript
81+ import { setCellCode } from ' @betteridea/codecell' ;
5182
52- #### Arguments
83+ ...
5384
54- - ` cellId ` - Unique id of the cell to run
55- - ` devMode ` - Boolean to enable dev mode
85+ // This will update the code in the cell with the id provided
86+ setCellCode (" 1" , " print('Updated code!')" );
87+ ```
5688
5789## Developing
5890
0 commit comments