From 8aeec067d2234fd87dcb0634be3730bbc33d4288 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 21 Jul 2021 00:49:29 +0200 Subject: [PATCH] Add Page to docs --- docs/.vuepress/config.js | 4 +++- docs/api.js | 1 + docs/api/component.md | 4 ++++ docs/api/editor.md | 6 ++++++ docs/api/page.md | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 docs/api/page.md diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index c8b70d89b..160dc7cab 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -1,6 +1,7 @@ const version = require('./../../package.json').version; const isDev = process.argv[2] === 'dev'; const devPath = 'http://localhost:8080/dist'; +const subDivider = " ‍ ‍ ‍ "; module.exports = { title: 'GrapesJS', @@ -63,9 +64,10 @@ module.exports = { ['/api/block_manager', 'Block Manager'], ['/api/commands', 'Commands'], ['/api/components', 'DOM Components'], - ['/api/component', ' - Component'], + ['/api/component', `${subDivider}Component`], ['/api/panels', 'Panels'], ['/api/pages', 'Pages'], + ['/api/page', `${subDivider}Page`], ['/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 6db02e247..15b9a5b74 100644 --- a/docs/api.js +++ b/docs/api.js @@ -24,6 +24,7 @@ const cmds = [ ['canvas/index.js', 'canvas.md'], ['i18n/index.js', 'i18n.md'], ['pages/index.js', 'pages.md'], + ['pages/model/Page.js', 'page.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/component.md b/docs/api/component.md index edb874507..8f89c97ae 100644 --- a/docs/api/component.md +++ b/docs/api/component.md @@ -277,6 +277,10 @@ Returns **this** Get the style of the component +#### Parameters + +* `opts` (optional, default `{}`) + Returns **[Object][2]** ### setStyle diff --git a/docs/api/editor.md b/docs/api/editor.md index 6a4615e92..3ac957f58 100644 --- a/docs/api/editor.md +++ b/docs/api/editor.md @@ -179,6 +179,12 @@ Returns **[string][3]** CSS string Returns JS of all components +### Parameters + +* `opts` **[Object][4]** Options (optional, default `{}`) + + * `opts.component` **Component?** Get the JS of a particular component + Returns **[string][3]** JS string ## getComponents diff --git a/docs/api/page.md b/docs/api/page.md new file mode 100644 index 000000000..117f81ff1 --- /dev/null +++ b/docs/api/page.md @@ -0,0 +1,40 @@ + + +## getAllFrames + +Get all frames + +### Examples + +```javascript +const arrayOfFrames = page.getAllFrames(); +``` + +Returns **[Array][1]\** + +## getMainFrame + +Get the first frame of the page (identified always as the main one) + +### Examples + +```javascript +const mainFrame = page.getMainFrame(); +``` + +Returns **Frame** + +## getMainComponent + +Get the root component (usually is the `wrapper` component) from the main frame + +### Examples + +```javascript +const rootComponent = page.getMainComponent(); +console.log(rootComponent.toHTML()); +``` + +Returns **Component** + +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array