docs: 📝 Add Code block
This commit is contained in:
37
apps/docs/docs/editor/blocks/code.md
Normal file
37
apps/docs/docs/editor/blocks/code.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Code
|
||||
|
||||
The "Code" block allows you to execute Javascript code. If you want to set a variable value with Javascript, use the [Set variable block](./set-variable) instead.
|
||||
|
||||
**It doesn't allow you to create custom visual block**
|
||||
|
||||
<img src="/img/blocks/code.png" width="600" alt="Code block"/>
|
||||
|
||||
## Examples
|
||||
|
||||
### Reload page
|
||||
|
||||
```js
|
||||
window.location.reload()
|
||||
```
|
||||
|
||||
### Wait for 3 seconds
|
||||
|
||||
By default, Promises will be awaited. So something like this will work:
|
||||
|
||||
```js
|
||||
return new Promise((res) => setTimeout(res, 3000))
|
||||
```
|
||||
|
||||
### Post a message to parent
|
||||
|
||||
```js
|
||||
postMessage('hello there!', '*')
|
||||
```
|
||||
|
||||
Then on your parent website you could listen for those messages:
|
||||
|
||||
```js
|
||||
addEventListener('message', ({ data }) => console.log(data))
|
||||
```
|
||||
|
||||
Do you need to do something but you're not sure how to? [Ask the community for help!](https://www.facebook.com/groups/typebot)
|
BIN
apps/docs/static/img/blocks/code.png
vendored
Normal file
BIN
apps/docs/static/img/blocks/code.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 342 KiB |
Reference in New Issue
Block a user