Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/.vuepress/theme/layouts/StudioSdkBannerSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<template>
<a class="banner-sdk-sidebar" :href="getSdkDocsLink()">
<h2 class="banner-sdk-sidebar__title">Supercharge Your GrapesJS Development 🚀</h2>
<img class="banner-sdk-sidebar__image" :src="$withBase('/studio-banner.jpg')" alt="Studio SDK">
<img class="banner-sdk-sidebar__image" :src="$withBase('/studio-banner.jpg')" alt="Studio SDK" />
<p class="banner-sdk-sidebar__content">
Studio SDK is the next-level visual builder with advanced features, custom plugins, and seamless integration. Save time and build faster!
Studio SDK is the next-level visual builder with advanced features, custom plugins, and seamless integration. Save
time and build faster!
</p>
</a>
</template>

<script>
import { getSdkDocsLink } from './utils';
import { getSdkDocsLink } from './utils';

export default {
methods: {
getSdkDocsLink() {
return getSdkDocsLink('sidebar');
}
}
},
},
};
</script>

Expand Down
8 changes: 4 additions & 4 deletions docs/.vuepress/theme/layouts/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const getSdkUtmParams = (medium = '') => {
return `utm_source=grapesjs-docs&utm_medium=${medium}`;
}
return `utm_source=grapesjs-docs&utm_medium=${medium}`;
};

export const getSdkDocsLink = (medium = '') => {
return `https://app.grapesjs.com/docs-sdk/overview/getting-started?${getSdkUtmParams(medium)}`;
}
return `https://app.grapesjs.com/docs-sdk/overview/getting-started?${getSdkUtmParams(medium)}`;
};
1 change: 1 addition & 0 deletions docs/api/canvas.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ Set canvas zoom value
### Parameters

* `value` **[Number][9]** The zoom value, from 0 to 100
* `opts` **SetZoomOptions** (optional, default `{}`)

### Examples

Expand Down
14 changes: 14 additions & 0 deletions docs/api/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ editor.on('command:run:my-command', ({ result, options }) => { ... });
editor.on('command:stop:before:my-command', ({ options }) => { ... });
```

* `command:call` Triggered on run or stop of a command.

```javascript
editor.on('command:call', ({ id, result, options, type }) => {
console.log('Command id', id, 'command result', result, 'call type', type);
});
```

* `command:call:COMMAND-ID` Triggered on run or stop of a specific command.

```javascript
editor.on('command:call:my-command', ({ result, options, type }) => { ... });
```

## Methods

* [add][2]
Expand Down
3 changes: 2 additions & 1 deletion docs/api/component.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ By setting override to specific properties, changes of those properties will be
### Parameters

* `value` **([Boolean][3] | [String][1] | [Array][5]<[String][1]>)**&#x20;
* `options` **DynamicWatchersOptions** (optional, default `{}`)

### Examples

Expand Down Expand Up @@ -280,7 +281,7 @@ Update attributes of the component
### Parameters

* `attrs` **[Object][2]** Key value attributes
* `opts` **SetAttrOptions** (optional, default `{}`)
* `opts` **SetAttrOptions** (optional, default `{skipWatcherUpdates:false,fromDataSource:false}`)
* `options` **[Object][2]** Options for the model update

### Examples
Expand Down
64 changes: 55 additions & 9 deletions docs/api/editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,65 @@ const editor = grapesjs.init({
```

## Available Events
* `update` Event triggered on any change of the project (eg. component added/removed, style changes, etc.)

You can make use of available events in this way
```javascript
editor.on('update', () => { ... });
```

```js
editor.on('EVENT-NAME', (some, argument) => {
// do something
})
* `undo` Undo executed.

```javascript
editor.on('undo', () => { ... });
```

* `redo` Redo executed.

```javascript
editor.on('redo', () => { ... });
```

* `load` Editor is loaded. At this stage, the project is loaded in the editor and elements in the canvas are rendered.

```javascript
editor.on('load', () => { ... });
```

* `project:load` Project JSON loaded in the editor. The event is triggered on the initial load and on the `editor.loadProjectData` method.

```javascript
editor.on('project:load', ({ project, initial }) => { ... });
```

* `project:get` Event triggered on request of the project data. This can be used to extend the project with custom data.

```javascript
editor.on('project:get', ({ project }) => { project.myCustomKey = 'value' });
```

* `log` Log message triggered.

```javascript
editor.on('log', (msg, opts) => { ... });
```

* `telemetry:init` Initial telemetry data are sent.

```javascript
editor.on('telemetry:init', () => { ... });
```

* `update` - The structure of the template is updated (its HTML/CSS)
* `undo` - Undo executed
* `redo` - Redo executed
* `load` - Editor is loaded
* `destroy` Editor started destroy (on `editor.destroy()`).

```javascript
editor.on('destroy', () => { ... });
```

* `destroyed` Editor destroyed.

```javascript
editor.on('destroyed', () => { ... });
```

### Components

Expand Down
30 changes: 30 additions & 0 deletions docs/api/pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,32 @@ pageManager.remove(somePage);

Returns **[Page]** Removed Page

## move

Move a page to a specific index in the pages collection.
If the index is out of bounds, the page will not be moved.

### Parameters

* `page` **([string][3] | [Page])** Page or page id to move.
* `opts` **[Object][2]?** Move options (optional, default `{}`)

* `opts.at` **[number][4]?** The target index where the page should be moved.

### Examples

```javascript
// Move a page to index 2
const movedPage = pageManager.move('page-id', { at: 2 });
if (movedPage) {
console.log('Page moved successfully:', movedPage);
} else {
console.log('Page could not be moved.');
}
```

Returns **(Page | [undefined][5])** The moved page, or `undefined` if the page does not exist or the index is out of bounds.

## get

Get page by id
Expand Down Expand Up @@ -192,3 +218,7 @@ Returns **[Page]**&#x20;
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
38 changes: 36 additions & 2 deletions docs/api/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,43 @@ const { Parser } = editor;
```

## Available Events
* `parse:html` On HTML parse, an object containing the input and the output of the parser is passed as an argument.

* `parse:html` - On HTML parse, an object containing the input and the output of the parser is passed as an argument
* `parse:css` - On CSS parse, an object containing the input and the output of the parser is passed as an argument
```javascript
editor.on('parse:html', ({ input, output }) => { ... });
```

* `parse:html:before` Event triggered before the HTML parsing starts. An object containing the input is passed as an argument.

```javascript
editor.on('parse:html:before', (options) => {
console.log('Parser input', options.input);
// You can also process the input and update `options.input`
options.input += '<div>Extra content</div>';
});
```

* `parse:css` On CSS parse, an object containing the input and the output of the parser is passed as an argument.

```javascript
editor.on('parse:css', ({ input, output }) => { ... });
```

* `parse:css:before` Event triggered before the CSS parsing starts. An object containing the input is passed as an argument.

```javascript
editor.on('parse:css:before', (options) => {
console.log('Parser input', options.input);
// You can also process the input and update `options.input`
options.input += '.my-class { color: red; }';
});
```

* `parse` Catch-all event for all the events mentioned above. An object containing all the available data about the triggered event is passed as an argument to the callback.

```javascript
editor.on('parse', ({ event, ... }) => { ... });
```

## Methods

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/editor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ export enum EditorEvents {
destroyed = 'destroyed',
}
/**{END_EVENTS}*/

// need this to avoid the TS documentation generator to break
export default EditorEvents;
3 changes: 3 additions & 0 deletions packages/core/src/parser/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ export enum ParserEvents {
all = 'parse',
}
/**{END_EVENTS}*/

// need this to avoid the TS documentation generator to break
export default ParserEvents;