diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index c2c011fda..c8b70d89b 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -65,6 +65,7 @@ module.exports = { ['/api/components', 'DOM Components'], ['/api/component', ' - Component'], ['/api/panels', 'Panels'], + ['/api/pages', 'Pages'], ['/api/style_manager', 'Style Manager'], ['/api/storage_manager', 'Storage Manager'], ['/api/device_manager', 'Device Manager'], diff --git a/docs/api.js b/docs/api.js index 541d0647b..6db02e247 100644 --- a/docs/api.js +++ b/docs/api.js @@ -23,6 +23,7 @@ const cmds = [ ['undo_manager/index.js', 'undo_manager.md'], ['canvas/index.js', 'canvas.md'], ['i18n/index.js', 'i18n.md'], + ['pages/index.js', 'pages.md'], ].map(entry => `${binRoot}documentation build ${srcRoot}/${entry[0]} -o ${docRoot}/api/${entry[1]} -f md --shallow --markdown-toc false`) .join(' && '); diff --git a/docs/api/canvas.md b/docs/api/canvas.md index d43da98a8..e03426cf9 100644 --- a/docs/api/canvas.md +++ b/docs/api/canvas.md @@ -24,36 +24,35 @@ const canvas = editor.Canvas; - [getWindow][5] - [getDocument][6] - [getBody][7] -- [getWrapperEl][8] -- [setCustomBadgeLabel][9] -- [hasFocus][10] -- [scrollTo][11] -- [setZoom][12] -- [getZoom][13] +- [setCustomBadgeLabel][8] +- [hasFocus][9] +- [scrollTo][10] +- [setZoom][11] +- [getZoom][12] ## getConfig Get the configuration object -Returns **[Object][14]** +Returns **[Object][13]** ## getElement Get the canvas element -Returns **[HTMLElement][15]** +Returns **[HTMLElement][14]** ## getFrameEl Get the iframe element of the canvas -Returns **[HTMLIFrameElement][16]** +Returns **[HTMLIFrameElement][15]** ## getWindow Get the window instance of the iframe element -Returns **[Window][17]** +Returns **[Window][16]** ## getDocument @@ -65,13 +64,7 @@ Returns **HTMLDocument** Get the body of the iframe element -Returns **[HTMLBodyElement][18]** - -## getWrapperEl - -Get the wrapper element containing all the components - -Returns **[HTMLElement][15]** +Returns **[HTMLBodyElement][17]** ## setCustomBadgeLabel @@ -79,7 +72,7 @@ Set custom badge naming strategy ### Parameters -- `f` **[Function][19]** +- `f` **[Function][18]** ### Examples @@ -93,13 +86,13 @@ canvas.setCustomBadgeLabel(function(component){ Get canvas rectangular data -Returns **[Object][14]** +Returns **[Object][13]** ## hasFocus Check if the canvas is focused -Returns **[Boolean][20]** +Returns **[Boolean][19]** ## scrollTo @@ -110,9 +103,9 @@ passed to it. For instance, you can scroll smoothly by using ### Parameters -- `el` **([HTMLElement][15] | Component)** -- `opts` **[Object][14]** Options, same as options for `scrollIntoView` (optional, default `{}`) - - `opts.force` **[Boolean][20]** Force the scroll, even if the element is already visible (optional, default `false`) +- `el` **([HTMLElement][14] | Component)** +- `opts` **[Object][13]** Options, same as options for `scrollIntoView` (optional, default `{}`) + - `opts.force` **[Boolean][19]** Force the scroll, even if the element is already visible (optional, default `false`) ### Examples @@ -130,7 +123,7 @@ Set zoom value ### Parameters -- `value` **[Number][21]** The zoom value, from 0 to 100 +- `value` **[Number][20]** The zoom value, from 0 to 100 Returns **this** @@ -138,7 +131,7 @@ Returns **this** Get zoom value -Returns **[Number][21]** +Returns **[Number][20]** ## addFrame @@ -146,7 +139,7 @@ Add new frame to the canvas ### Parameters -- `props` **[Object][14]** Frame properties (optional, default `{}`) +- `props` **[Object][13]** Frame properties (optional, default `{}`) - `opts` (optional, default `{}`) ### Examples @@ -186,30 +179,28 @@ Returns **Frame** [7]: #getbody -[8]: #getwrapperel - -[9]: #setcustombadgelabel +[8]: #setcustombadgelabel -[10]: #hasfocus +[9]: #hasfocus -[11]: #scrollto +[10]: #scrollto -[12]: #setzoom +[11]: #setzoom -[13]: #getzoom +[12]: #getzoom -[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[15]: https://developer.mozilla.org/docs/Web/HTML/Element +[14]: https://developer.mozilla.org/docs/Web/HTML/Element -[16]: https://developer.mozilla.org/docs/Web/API/HTMLIFrameElement +[15]: https://developer.mozilla.org/docs/Web/API/HTMLIFrameElement -[17]: https://developer.mozilla.org/docs/Web/API/Window +[16]: https://developer.mozilla.org/docs/Web/API/Window -[18]: https://developer.mozilla.org/docs/Web/HTML/Element/body +[17]: https://developer.mozilla.org/docs/Web/HTML/Element/body -[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function +[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function -[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/docs/api/component.md b/docs/api/component.md index 349dad368..b23816d4e 100644 --- a/docs/api/component.md +++ b/docs/api/component.md @@ -255,6 +255,25 @@ component.addAttributes({ 'data-key': 'value' }); Returns **this** +## removeAttributes + +Remove attributes from the component + +### Parameters + +- `attrs` **([String][1] \| [Array][4]<[String][1]>)** Array of attributes to remove (optional, default `[]`) +- `opts` (optional, default `{}`) +- `options` **[Object][2]** Options for the model update + +### Examples + +```javascript +component.removeAttributes('some-attr'); +component.removeAttributes(['some-attr1', 'some-attr2']); +``` + +Returns **this** + ## getStyle Get the style of the component @@ -282,6 +301,10 @@ Returns **[Object][2]** Return all component's attributes +### Parameters + +- `opts` (optional, default `{}`) + Returns **[Object][2]** ## addClass @@ -354,7 +377,7 @@ Add new component children ### Parameters - `components` **([Component][9] \| [String][1])** Component to add -- `opts` **[Object][2]** Options, same as in `model.add()`(from backbone) (optional, default `{}`) +- `opts` **[Object][2]** Options for the append action (optional, default `{}`) ### Examples @@ -366,6 +389,8 @@ someComponent.get('components').length // -> 2 // You can pass components directly otherComponent.append(otherComponent2); otherComponent.append([otherComponent3, otherComponent4]); +// append at specific index (eg. at the beginning) +someComponent.append(otherComponent, { at: 0 }); ``` Returns **[Array][4]** Array of appended components @@ -378,6 +403,7 @@ current collection is returned ### Parameters - `components` **([Component][9] \| [String][1])?** Components to set +- `opts` **[Object][2]** Options, same as in `Component.append()` (optional, default `{}`) ### Examples diff --git a/docs/api/css_composer.md b/docs/api/css_composer.md index 81003d764..108abe425 100644 --- a/docs/api/css_composer.md +++ b/docs/api/css_composer.md @@ -115,6 +115,10 @@ Returns **Collection** Remove all rules +### Parameters + +- `opts` (optional, default `{}`) + Returns **this** ## setRule diff --git a/docs/api/editor.md b/docs/api/editor.md index ff1d4ca68..3388b3782 100644 --- a/docs/api/editor.md +++ b/docs/api/editor.md @@ -27,6 +27,7 @@ editor.on('EVENT-NAME', (some, argument) => { - `component:mount` - Component is mounted to an element and rendered in canvas - `component:add` - Triggered when a new component is added to the editor, the model is passed as an argument to the callback - `component:remove` - Triggered when a component is removed, the model is passed as an argument to the callback +- `component:remove:before` - Triggered before the remove of the component, the model, remove function (if aborted via options, with this function you can complete the remove) and options (use options.abort = true to prevent remove), are passed as arguments to the callback - `component:clone` - Triggered when a component is cloned, the new model is passed as an argument to the callback - `component:update` - Triggered when a component is updated (moved, styled, etc.), the model is passed as an argument to the callback - `component:update:{propertyName}` - Listen any property change, the model is passed as an argument to the callback @@ -151,7 +152,8 @@ Returns HTML built inside canvas ### Parameters -- `opts` +- `opts` **[Object][3]** Options (optional, default `{}`) + - `opts.cleanId` **[Boolean][4]** Remove unnecessary IDs (eg. those created automatically) (optional, default `false`) Returns **[string][2]** HTML string diff --git a/docs/api/pages.md b/docs/api/pages.md new file mode 100644 index 000000000..08ec2e499 --- /dev/null +++ b/docs/api/pages.md @@ -0,0 +1,167 @@ + + +## PageManager + +You can customize the initial state of the module from the editor initialization + +```js +const editor = grapesjs.init({ + .... + pageManager: { + pages: [ + { + id: 'page-id', + styles: `.my-class { color: red }`, // or a JSON of styles + component: '