### Basic Asset Provider Setup (React/JS) Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Configures a basic Asset Provider using Lorem Picsum images. This example demonstrates how to define a provider with an ID, label, asset type, and an onLoad function to fetch assets. It's suitable for integrating image sources. ```javascript import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ...

Double click the image below to open the AssetManager

' }], } }, assets: { // Select by default the Lorem Picsum provider when the asset manager opens providerId: "picsum-pictures", providers: [{ id: "picsum-pictures", label: "Lorem Picsum pictures", types: "image", onLoad: async (props) => { return Array(30) .fill(0) .map((v, i) => ({ src: `https://picsum.photos/seed/${i + 1}/300/300.jpg`, name: `Image #${i + 1}` })); } }] } }} /> ``` -------------------------------- ### Wistia Video Gallery Example Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Illustrates the setup for a Wistia video within a LightGallery, including the media source, poster image, and associated caption. ```html

Wistia video

``` -------------------------------- ### Install Studio SDK Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Installs the GrapesJS Studio SDK package using npm. This is the first step to integrate the SDK into your project. ```bash npm i @grapesjs/studio-sdk ``` -------------------------------- ### Inline Styles Example Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md An example of how to apply inline styles to a component using a JavaScript object. ```javascript { "color": "red", "fontSize": "14px" } ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the Studio SDK plugins package using npm. This is the first step to using the YouTube Asset Provider. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### GrapesJS Templates Configuration Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Enable users to select and start with pre-configured designs using the Template manager. Facilitates easy project setup with various design starting points. ```javascript /* Configuration for GrapesJS Templates. Allows users to select and start with pre-configured designs via the Template manager. See: https://app.grapesjs.com/docs-sdk/configuration/templates */ const editor = grapesjs.init({ // ... other configurations // Example: Load templates from a remote source // templates: [ // { label: 'Basic Template', content: '...' }, // { label: 'Advanced Template', content: '...' }, // ], // ... }); ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install GrapesJS Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Instructions for installing the GrapesJS Studio SDK plugins package using npm, pnpm, yarn, or CDN. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This is the first step to using the Studio SDK plugins. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the Studio SDK plugins package using npm. This is the first step to integrate the plugins into your project. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the Studio SDK plugins package using npm. This is the first step to integrate the FsLightbox plugin into your project. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Custom Templates Example Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md An example demonstrating a custom array of templates to be displayed in a panel, including template ID, name, and data with nested components and styles. ```javascript templates: [{ id: 'template1', name: 'Template 1', data: { pages: [ { name: 'Home', component: '

Template 1

' } ] } }] ``` -------------------------------- ### Install GrapesJS Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the Studio SDK plugins package using npm. This is the first step to using the table plugin in your project. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Package Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This is the first step to using the Google Fonts asset provider. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### GrapesJS Studio Component Styling Examples Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Demonstrates adding components with inline styles, class-based styles, and controlling style property editability using GrapesJS Studio's API. This example showcases `style`, `styles`, `stylable`, and `unstylable` properties within component defaults. ```javascript import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ... { editor.Components.addType('component-style', { model: { defaults: { style: { color: 'red', padding: '20px' }, components: 'Styles per component', } } }); editor.Components.addType('component-style-class', { model: { defaults: { attributes: { class: 'component-style' }, styles: '.component-style { color: green; padding: 20px }', components: 'Styles with class selector', } } }); editor.Components.addType('component-only-color', { model: { defaults: { stylable: ['color'], style: { color: 'blue', padding: '20px' }, components: 'Allow updating only the color change', } } }); editor.Components.addType('component-skip-color', { model: { defaults: { unstylable: ['color'], style: { color: 'darkblue', padding: '20px' }, components: 'Do not allow updating the color', } } }); editor.onReady(() => { editor.getWrapper().append([ { type: 'component-style' }, { type: 'component-style-class' }, { type: 'component-only-color' }, { type: 'component-skip-color' }, ]); }); } ], project: { // Empty project for our demo purpose default: { pages: [{ name: 'Home' }] } }, layout: { default: { type: 'row', style: { height: '100%' }, children: [ { type: 'canvasSidebarTop', sidebarTop: { leftContainer: { buttons: [] }, rightContainer: { buttons: ({ items }) => [{ ...items.find(item => item.id === 'showCode'), variant: 'outline', label: 'Show code' }], }, } }, { type: 'panelSidebarTabs', style: { width: 300 } } ] } } }} /> ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This is the first step to integrating the plugins into your project. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This is the first step to integrate the flex component plugin into your project. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Package Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary package for Studio SDK plugins, including the LightGallery component. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install GrapesJS Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This is a prerequisite for using the EJS plugin. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install GrapesJS Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary package for GrapesJS Studio SDK plugins via npm. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the Studio SDK plugins package using npm. This is the first step to enable advanced features like custom empty states. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This is the first step to using the accordion component in your project. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This is the first step to integrate the SDK's features into your project. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### FsLightbox Integration Examples Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Demonstrates how to use the FsLightbox plugin to display different types of content, including images, videos, and custom elements within a GrapesJS project. ```html

Videos

YouTube video

HTML video

Custom types

Vimeo Video (iframe) Google Maps Custom element
Custom content
``` -------------------------------- ### Iframe Gallery Examples (Website, Maps, PDF) Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Provides examples of using LightGallery to display content via iframes, including external websites, Google Maps embeds, and PDF documents. ```html ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This is the first step to integrate GrapesJS Studio SDK with your React project. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Vimeo Video Gallery Example Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Shows how to configure a gallery item for a Vimeo video, specifying the video source, poster image, and descriptive subtitle. ```html

Vimeo video

``` -------------------------------- ### Install Studio SDK Plugins Package Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm, pnpm, or yarn. This is the first step to using the Swiper component plugin. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### GrapesJS Studio Context Menu Configuration Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Example of configuring the context menu globally and for specific components (Heading and Image) in GrapesJS Studio using React. ```javascript import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ...

Heading component

Text component
` } ] } }, plugins: [ editor => { // Update context menu for the Heading components editor.Components.addType('heading', { model: { defaults: { contextMenu: ({ items, component }) => [ ...items, // default component items { id: 'headingHTML', label: 'Heading HTML', icon: '', onClick: () => alert('Heading HTML: ' + component.toHTML()) } ] } } }); // Update context menu for the Image components editor.Components.addType('image', { model: { defaults: { contextMenu: ({ component }) => [ // skipping default items { id: 'imageItems', label: 'Image items', icon: 'image', items: [ { id: 'i1', label: 'Item 1', icon: 'check' }, { id: 'i2', label: 'Item 2', onClick: () => alert('Item 2') }, { id: 'i3', label: 'Item 3', items: [ { id: 'i3-1', label: 'Replace image', icon: 'refresh', onClick: () => component.set({ src: `https://picsum.photos/seed/${Math.random()}/300/300` }) } ] } ] } ] } } }); } ], components: { contextMenu: ({ items, component, type, source }) => { return [ { id: 'globalBefore', label: 'Global: Disabled', disabled: true }, // default items that you can 'map' and filter' ...items, { id: 'globalAfter', label: 'Global: Info', onClick: () => alert(`Type: ${type} Source: ${source} HTML: ${component.toHTML()}`) } ]; } }, }} /> ``` -------------------------------- ### Basic Swiper Configuration Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Demonstrates a basic Swiper setup with slides per view and spacing. This is a foundational example for creating carousel components. ```html
Slide 1
Slide 2
Slide 3
Slide 4
Slide 5
Slide 6
``` -------------------------------- ### GrapesJS Studio Toolbar Configuration Example Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Demonstrates how to configure the GrapesJS Studio toolbar globally and for specific components (heading and image) using React and JavaScript. Includes adding custom commands for updating component content, copying HTML, and fetching images. ```javascript import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ...

Heading component

Text component
` } ] } }, plugins: [ editor => { // Update toolbar for the Heading components editor.Components.addType('heading', { model: { defaults: { toolbarItems: ({ items, component }) => [ ...items, // default component items { id: 'component-update', label: '', command: () => { component.components('Updated heading: ' + new Date().toLocaleTimeString()); } } ] } } }); // Update toolbar for the Image components editor.Components.addType('image', { model: { defaults: { toolbarItems: ({ component }) => [ // skipping default items { id: 'component-copy-html', label: '', command: () => { navigator.clipboard.writeText(component.toHTML()); alert('Image HTML copied to clipboard'); } }, { id: 'component-fetch-image', label: '', command: async () => { await fetch('https://picsum.photos/200').then(async ({ url }) => { component.setAttributes({ src: url }); }); } } ] } } }); } ], components: { toolbar: ({ items, component }) => { return [ { id: 'global-preview', label: '', command: 'core:preview' }, // default items that you can 'map' and filter' ...items, { id: 'global-info', label: '', command: () => { ``` -------------------------------- ### PanelPageSettings Usage in React Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Demonstrates how to integrate the PanelPageSettings component within a React application using the GrapesJS Studio SDK. This example shows the basic setup of the StudioEditor with project and layout configurations, including the placement of the PanelPageSettings component. ```jsx import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ... Home page'}] } }, layout: { default: { type: 'row', style: { height: '100%' }, children: [ { type: 'column', style: { width: 300 }, children: { type: 'panelPageSettings' } }, { type: 'canvas' } ] }, } }} /> ``` -------------------------------- ### Initialize Global Styles in GrapesJS Studio Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Demonstrates how to initialize GrapesJS Studio with global styles enabled. This example shows setting up styles for 'h1' elements, including color and font size, and how to trigger the global style panel on editor readiness. ```react import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ... editor.onReady(() => { // let's show the global style panel on start editor.runCommand('studio:layoutToggle', { id: 'gs', layout: 'panelGlobalStyles', header: { label: 'Global Styles' }, placer: { type: 'absolute', position: 'right' } }); }) ], project: { default: { pages: [ { name: 'Home', component: '

Home page

'}, { name: 'About', component: '

About page

'}, ] } }, globalStyles: { default: [ { id: 'h1Color', property: 'color', field: 'color', defaultValue: 'red', selector: 'h1', label: 'H1 color' }, { id: 'h1Size', property: 'font-size', field: { type: 'number', min: 0.1, max: 10, step: 0.1, units: ['rem'] }, defaultValue: '2rem', selector: 'h1', label: 'H1 size' } ] } }} /> ``` -------------------------------- ### Initialize Web Project with Default Pages Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Demonstrates how to initialize a GrapesJS Studio SDK project of type 'web' and define default pages with their content. This setup is suitable for multi-page web applications. ```javascript import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ... Home page' }, { name: 'About', component: '

About page

' }, { name: 'Contact', component: '

Contact page

' }, ] }, } }} /> ``` -------------------------------- ### Setup Web Project with Studio SDK Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Integrates the Studio SDK into a web project, specifically for building web pages. It demonstrates how to use the StudioEditor component with options for project type and default pages. ```jsx import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ... Home page' }, { name: 'About', component: '

About page

' }, { name: 'Contact', component: '

Contact page

' }, ] }, } }} /> ``` -------------------------------- ### Install Studio SDK Plugins Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/plugins.md Installs the necessary Studio SDK plugins package using npm. This package includes the TinyMCE RTE plugin. ```bash npm i @grapesjs/studio-sdk-plugins ``` -------------------------------- ### Studio Editor Initialization and Command Usage Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Demonstrates how to initialize the StudioEditor component in a React application and use commands to toggle page settings and add pages. It includes event handlers like onReady and functions to interact with editor commands. ```javascript import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ... const onReady = (editor) => { // store the editor in your state manager }; const toggleAddPage = () => { const config = editor.runCommand(StudioCommands.getPagesConfig) || {}; editor.runCommand(StudioCommands.setPagesConfig, { config: { add: !config.add } }); } const togglePageSettings = () => { const state = editor.runCommand(StudioCommands.getPageSettings) || {}; editor.runCommand(StudioCommands.setPageSettings, { isOpen: !state.isOpen }); } // ... ``` -------------------------------- ### GrapesJS Studio SDK Data Sources Initialization (React) Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Demonstrates how to initialize the GrapesJS Studio SDK with Data Sources enabled. This includes enabling Data Source blocks, providing global data, and setting up a project with data-bound components like variables, conditions, and collections. ```javascript import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ... Variable

Condition

Hey, welcome back, valued customer! please register to see more!

Collection

  • Product Name: - Price:
` }, ] }, }, // Custom editor layout for demo purpose layout: { default: { type: 'row', style: { height: '100%' }, children: [ { type: 'panelBlocks', header: { label: 'Blocks', collapsible: false, style: { width: '300px' } }, symbols: false, }, { type: 'canvas' } ] } }, }} /> ``` -------------------------------- ### Row Layout Component Example Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Demonstrates how to use the Row layout component within the GrapesJS Studio SDK to arrange child components horizontally. It shows customization options like className and style, and includes examples of nesting different component types. ```javascript import StudioEditor from '@grapesjs/studio-sdk/react'; import '@grapesjs/studio-sdk/style'; // ... ``` -------------------------------- ### Asset Provider onLoad Function Examples Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Defines how to fetch assets. Supports returning an array of assets, or an array of Page objects for endless scrolling using pageIndex for offset-based or token-based pagination. ```javascript async () => { // Simple asset array return [ { src: 'https://www.example.com/items/1' }, { src: 'https://www.example.com/items/2' }, { src: 'https://www.example.com/items/3' } ] } ``` ```javascript async ({ pageIndex }) => { // Offset based pagination const pageSize = 20; const params = new URLSearchParams({ page: pageIndex, pageSize }) const response = await fetch(`https://www.example.com/items?${params}`) const page = await response.json() const itemCount = pageSize * pageIndex + page.items.length return { items: page.items, isLastPage: itemCount >= page.total } } ``` ```javascript async ({ pageCustomData }) => { // Token based pagination. const params = new URLSearchParams({ pageToken: pageCustomData?.token }) const response = await fetch(`https://www.example.com/items?${params}`) const page = await response.json() return { items: page.items, nextPageCustomData: { token: page.nextPageToken }, isLastPage: !page.nextPageToken } } ``` -------------------------------- ### Project Files Command Options Source: https://github.com/sidb03/grapesjs-studio-docs/blob/main/sdk.md Configuration options for the `studio:projectFiles` command. These options control how project files, including pages, assets, and styles, are exported. ```APIDOC studio:projectFiles command options: page: Type: Page Description: Export specific page. By default, all pages are exported. assetsFolder: Type: string Description: If the HTML contains base64 images, they will be exported as separate files and placed in the specified folder name. Default: assets filenameCss: Type: string Description: Filename for CSS file. Default: style.css styles: Type: string Description: Indicate how to export styles. By default, styles are exported in a separate CSS file. skipProject: Type: boolean Description: Skip project file (project JSON). Default: false exportConfig: Description: Configuration options for exporting data resolvers. Default: undefined optionsHtml: Description: Options for HTML export. ```