Update CLI editor configuration

parent 9cf6739c
Pipeline #74344529 passed with stage
in 1 minute and 38 seconds
---
source: sections/_guide_editor/03.03-configuration.md
bookmark: cli-configuration
name: Configuration
title: Configuring the editor
sub: true
code: |
``` json
{
"name": "my-editor-bundle",
"version": "0.0.1",
"tripetto": {
"blocks": [
"block-on-npm",
"block-on-github"
],
"noFurtherLoading": true
},
"dependencies": {
"tripetto": "*",
"block-on-npm": "^1.0.0",
"block-on-github": "git+ssh://[email protected]/user/block.git"
},
"scripts": {
"start": "tripetto ./example.json"
}
}
```
---
By default, the editor comes with a predefined set of blocks. These blocks are automatically loaded when the editor starts. You can configure the editor to only use the blocks you want, or you can add additional blocks. There are three methods for configuring the available blocks. In all cases an array with block package names needs to be supplied.
### Method 1: Locally using an npm package file
If you start the editor from a folder containing a `package.json` file, you can use this file to embed your configuration:
```json
{
"name": "your-package-name",
"version": "0.0.1",
"tripetto": {
"blocks": [
"block-a",
"block-b"
]
}
}
```
In this case you can also include the editor as a package dependency, so you could distribute the editor with your own package. The local instance will parse the configuration found in `package.json` and load the appropriate block packages.
Since the block packages are preferably npm packages, they can be included as package dependencies as well. This allows you to create bundled packages that contain the editor with a complete set of block packages.
An example package file is displayed to the right (or a bit further down, if you're reading this on a device with limited screen width).
{: .success }
You can choose to make the specified block packages available in the same local folder as the configuration, or install the block packages globally.
{: .warning }
### Method 2: Locally using a configuration file
If you don't want to pollute your `package.json` file or you are not using the editor from within a package, you can create a separate configuration file named `tripetto.json` with the following structure:
```json
{
"blocks": [
"block-a",
"block-b"
]
}
```
When the editor is started from a folder containing a `tripetto.json` file, this configuration will be parsed.
You can choose to make the specified block packages available in the same local folder as the configuration, or install the block packages globally.
{: .warning }
### Method 3: Globally
If you want to specify blocks globally, create a file in the user/home folder `~/tripetto.json` with the following structure:
```json
{
"blocks": [
"block-a",
"block-b"
]
}
```
Since the configuration is global, the block packages should also be globally installed. Otherwise the editor can't find the supplied block packages.
{: .warning }
### Configuration loading order
When Tripetto starts, it tries to load any configuration files in the following order:
1. `tripetto.json` in the current working directory;
2. `package.json` in the current working directory;
3. `~/tripetto.json` in the user/home folder;
4. `tripetto.json` in the installation directory of the editor package;
5. `package.json` in the installation directory of the editor package.
#### Stop further loading
You can stop further loading of configuration files (and thus blocks) by setting the property `noFurtherLoading` to `true`:
```json
{
"name": "your-package-name",
"version": "0.0.1",
"tripetto": {
"blocks": [
"block-a",
"block-b"
],
"noFurtherLoading": true
}
}
```
As soon the editor hits a configuration file that has this option enabled, the loading stops right after processing that file.
The configuration files mentioned in step 4 and 5 are included in the editor package itself and should therefore not be altered. Changes will be lost when the editor package is updated.
{: .warning}
---
source: sections/_guide_editor/03.03-configuration.md
bookmark: cli-configuration
name: Configuration
title: Configuring the editor
sub: true
code: |
``` json
{
"name": "my-editor-bundle",
"version": "0.0.1",
"tripetto": {
"blocks": [
"block-on-npm",
"block-on-github"
],
"noFurtherLoading": true
},
"dependencies": {
"tripetto": "*",
"block-on-npm": "^1.0.0",
"block-on-github": "git+ssh://[email protected]/user/block.git"
},
"scripts": {
"start": "tripetto ./example.json"
}
}
```
---
By default, the editor loads no blocks. So you need to configure the editor in order to load the blocks you want. There are three methods for configuring the available blocks. In all cases an array with block package names needs to be supplied. You can find a list of available blocks [here](https://tripetto.com/sdk/developers/blocks/).
### Method 1: Locally using an npm package file
If you start the editor from a folder containing a `package.json` file, you can use this file to embed your configuration:
```json
{
"name": "your-package-name",
"version": "0.0.1",
"tripetto": {
"blocks": [
"block-a",
"block-b"
]
}
}
```
In this case you can also include the editor as a package dependency, so you could distribute the editor with your own package. The local instance will parse the configuration found in `package.json` and load the appropriate block packages.
Since the block packages are preferably npm packages, they can be included as package dependencies as well. This allows you to create bundled packages that contain the editor with a complete set of block packages.
An example package file is displayed to the right (or a bit further down, if you're reading this on a device with limited screen width).
{: .success }
You can choose to make the specified block packages available in the same local folder as the configuration, or install the block packages globally.
{: .warning }
### Method 2: Locally using a configuration file
If you don't want to pollute your `package.json` file or you are not using the editor from within a package, you can create a separate configuration file named `tripetto.json` with the following structure:
```json
{
"blocks": [
"block-a",
"block-b"
]
}
```
When the editor is started from a folder containing a `tripetto.json` file, this configuration will be parsed.
You can choose to make the specified block packages available in the same local folder as the configuration, or install the block packages globally.
{: .warning }
### Method 3: Globally
If you want to specify blocks globally, create a file in the user/home folder `~/tripetto.json` with the following structure:
```json
{
"blocks": [
"block-a",
"block-b"
]
}
```
Since the configuration is global, the block packages should also be globally installed. Otherwise the editor can't find the supplied block packages.
{: .warning }
### Configuration loading order
When Tripetto starts, it tries to load any configuration files in the following order:
1. `tripetto.json` in the current working directory;
2. `package.json` in the current working directory;
3. `~/tripetto.json` in the user/home folder;
4. `tripetto.json` in the installation directory of the editor package;
5. `package.json` in the installation directory of the editor package.
#### Stop further loading
You can stop further loading of configuration files (and thus blocks) by setting the property `noFurtherLoading` to `true`:
```json
{
"name": "your-package-name",
"version": "0.0.1",
"tripetto": {
"blocks": [
"block-a",
"block-b"
],
"noFurtherLoading": true
}
}
```
As soon the editor hits a configuration file that has this option enabled, the loading stops right after processing that file.
The configuration files mentioned in step 4 and 5 are included in the editor package itself and should therefore not be altered. Changes will be lost when the editor package is updated.
{: .warning}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment