├── .gitignore
├── LICENSE
├── README.txt
├── custom_icons
├── expressions-icon.svg
└── storage-icon.svg
├── dist
├── grapesjs-mavo.min.css
└── grapesjs-mavo.min.js
├── expressions.json
├── grapesjs
├── .editorconfig
├── .eslintrc
├── .github
│ ├── ISSUE_TEMPLATE.md
│ └── no-response.yml
├── .gitignore
├── .travis.yml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── dist
│ ├── css
│ │ └── grapes.min.css
│ ├── fonts
│ │ ├── FontAwesome.otf
│ │ ├── fontawesome-webfont.eot
│ │ ├── fontawesome-webfont.svg
│ │ ├── fontawesome-webfont.ttf
│ │ ├── fontawesome-webfont.woff
│ │ ├── fontawesome-webfont.woff2
│ │ ├── main-fonts.eot
│ │ ├── main-fonts.svg
│ │ ├── main-fonts.ttf
│ │ └── main-fonts.woff
│ ├── grapes.js
│ └── grapes.min.js
├── index.html
├── package-lock.json
├── package.json
├── src
│ ├── asset_manager
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Asset.js
│ │ │ ├── AssetImage.js
│ │ │ └── Assets.js
│ │ └── view
│ │ │ ├── AssetImageView.js
│ │ │ ├── AssetView.js
│ │ │ ├── AssetsView.js
│ │ │ └── FileUploader.js
│ ├── block_manager
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Block.js
│ │ │ ├── Blocks.js
│ │ │ ├── Categories.js
│ │ │ └── Category.js
│ │ └── view
│ │ │ ├── BlockView.js
│ │ │ ├── BlocksView.js
│ │ │ └── CategoryView.js
│ ├── canvas
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Canvas.js
│ │ │ └── Frame.js
│ │ └── view
│ │ │ ├── CanvasView.js
│ │ │ └── FrameView.js
│ ├── code_manager
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── CodeMirrorEditor.js
│ │ │ ├── CssGenerator.js
│ │ │ ├── HtmlGenerator.js
│ │ │ ├── JsGenerator.js
│ │ │ └── JsonGenerator.js
│ │ └── view
│ │ │ └── EditorView.js
│ ├── commands
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Command.js
│ │ │ └── Commands.js
│ │ └── view
│ │ │ ├── CommandAbstract.js
│ │ │ ├── CreateComponent.js
│ │ │ ├── DeleteComponent.js
│ │ │ ├── Drag.js
│ │ │ ├── ExportTemplate.js
│ │ │ ├── Fullscreen.js
│ │ │ ├── ImageComponent.js
│ │ │ ├── InsertCustom.js
│ │ │ ├── MoveComponent.js
│ │ │ ├── OpenAssets.js
│ │ │ ├── OpenBlocks.js
│ │ │ ├── OpenLayers.js
│ │ │ ├── OpenStyleManager.js
│ │ │ ├── OpenTraitManager.js
│ │ │ ├── Preview.js
│ │ │ ├── Resize.js
│ │ │ ├── SelectComponent.js
│ │ │ ├── SelectParent.js
│ │ │ ├── SelectPosition.js
│ │ │ ├── ShowOffset.js
│ │ │ ├── SwitchVisibility.js
│ │ │ └── TextComponent.js
│ ├── css_composer
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── CssRule.js
│ │ │ └── CssRules.js
│ │ └── view
│ │ │ ├── CssGroupRuleView.js
│ │ │ ├── CssRuleView.js
│ │ │ └── CssRulesView.js
│ ├── device_manager
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Device.js
│ │ │ └── Devices.js
│ │ └── view
│ │ │ └── DevicesView.js
│ ├── dom_components
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Component.js
│ │ │ ├── ComponentImage.js
│ │ │ ├── ComponentLink.js
│ │ │ ├── ComponentMap.js
│ │ │ ├── ComponentScript.js
│ │ │ ├── ComponentSvg.js
│ │ │ ├── ComponentTable.js
│ │ │ ├── ComponentTableBody.js
│ │ │ ├── ComponentTableCell.js
│ │ │ ├── ComponentTableFoot.js
│ │ │ ├── ComponentTableHead.js
│ │ │ ├── ComponentTableRow.js
│ │ │ ├── ComponentText.js
│ │ │ ├── ComponentTextNode.js
│ │ │ ├── ComponentVideo.js
│ │ │ ├── Components.js
│ │ │ ├── Toolbar.js
│ │ │ └── ToolbarButton.js
│ │ └── view
│ │ │ ├── ComponentImageView.js
│ │ │ ├── ComponentLinkView.js
│ │ │ ├── ComponentMapView.js
│ │ │ ├── ComponentScriptView.js
│ │ │ ├── ComponentSvgView.js
│ │ │ ├── ComponentTableBodyView.js
│ │ │ ├── ComponentTableCellView.js
│ │ │ ├── ComponentTableFootView.js
│ │ │ ├── ComponentTableHeadView.js
│ │ │ ├── ComponentTableRowView.js
│ │ │ ├── ComponentTableView.js
│ │ │ ├── ComponentTextNodeView.js
│ │ │ ├── ComponentTextView.js
│ │ │ ├── ComponentVideoView.js
│ │ │ ├── ComponentView.js
│ │ │ ├── ComponentsView.js
│ │ │ ├── ToolbarButtonView.js
│ │ │ └── ToolbarView.js
│ ├── domain_abstract
│ │ ├── model
│ │ │ ├── Styleable.js
│ │ │ └── TypeableCollection.js
│ │ ├── ui
│ │ │ ├── Input.js
│ │ │ ├── InputColor.js
│ │ │ └── InputNumber.js
│ │ └── view
│ │ │ └── DomainViews.js
│ ├── editor
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ └── Editor.js
│ │ └── view
│ │ │ └── EditorView.js
│ ├── index.js
│ ├── keymaps
│ │ └── index.js
│ ├── modal_dialog
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ └── Modal.js
│ │ └── view
│ │ │ └── ModalView.js
│ ├── navigator
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ └── view
│ │ │ ├── ItemView.js
│ │ │ └── ItemsView.js
│ ├── panels
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Button.js
│ │ │ ├── Buttons.js
│ │ │ ├── Panel.js
│ │ │ └── Panels.js
│ │ └── view
│ │ │ ├── ButtonView.js
│ │ │ ├── ButtonsView.js
│ │ │ ├── PanelView.js
│ │ │ └── PanelsView.js
│ ├── parser
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ └── model
│ │ │ ├── ParserCss.js
│ │ │ └── ParserHtml.js
│ ├── plugin_manager
│ │ ├── config
│ │ │ └── config.js
│ │ └── index.js
│ ├── rich_text_editor
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ └── model
│ │ │ └── RichTextEditor.js
│ ├── selector_manager
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Selector.js
│ │ │ └── Selectors.js
│ │ └── view
│ │ │ ├── ClassTagView.js
│ │ │ └── ClassTagsView.js
│ ├── storage_manager
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ └── model
│ │ │ ├── LocalStorage.js
│ │ │ └── RemoteStorage.js
│ ├── style_manager
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Layer.js
│ │ │ ├── Layers.js
│ │ │ ├── Properties.js
│ │ │ ├── Property.js
│ │ │ ├── PropertyComposite.js
│ │ │ ├── PropertyFactory.js
│ │ │ ├── PropertyInteger.js
│ │ │ ├── PropertyRadio.js
│ │ │ ├── PropertySlider.js
│ │ │ ├── PropertyStack.js
│ │ │ ├── Sector.js
│ │ │ └── Sectors.js
│ │ └── view
│ │ │ ├── LayerView.js
│ │ │ ├── LayersView.js
│ │ │ ├── PropertiesView.js
│ │ │ ├── PropertyColorView.js
│ │ │ ├── PropertyCompositeView.js
│ │ │ ├── PropertyFileView.js
│ │ │ ├── PropertyIntegerView.js
│ │ │ ├── PropertyRadioView.js
│ │ │ ├── PropertySelectView.js
│ │ │ ├── PropertySliderView.js
│ │ │ ├── PropertyStackView.js
│ │ │ ├── PropertyView.js
│ │ │ ├── SectorView.js
│ │ │ └── SectorsView.js
│ ├── styles
│ │ ├── fonts
│ │ │ ├── FontAwesome.otf
│ │ │ ├── fontawesome-webfont.eot
│ │ │ ├── fontawesome-webfont.svg
│ │ │ ├── fontawesome-webfont.ttf
│ │ │ ├── fontawesome-webfont.woff
│ │ │ ├── fontawesome-webfont.woff2
│ │ │ ├── main-fonts.eot
│ │ │ ├── main-fonts.svg
│ │ │ ├── main-fonts.ttf
│ │ │ └── main-fonts.woff
│ │ └── scss
│ │ │ ├── _gjs_assets.scss
│ │ │ ├── _gjs_blocks.scss
│ │ │ ├── _gjs_canvas.scss
│ │ │ ├── _gjs_devices.scss
│ │ │ ├── _gjs_inputs.scss
│ │ │ ├── _gjs_layers.scss
│ │ │ ├── _gjs_modal.scss
│ │ │ ├── _gjs_panels.scss
│ │ │ ├── _gjs_rte.scss
│ │ │ ├── _gjs_selectors.scss
│ │ │ ├── _gjs_style_manager.scss
│ │ │ ├── _gjs_traits.scss
│ │ │ ├── _gjs_variables.scss
│ │ │ └── main.scss
│ ├── trait_manager
│ │ ├── config
│ │ │ └── config.js
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Trait.js
│ │ │ ├── TraitFactory.js
│ │ │ └── Traits.js
│ │ └── view
│ │ │ ├── TraitCheckboxView.js
│ │ │ ├── TraitColorView.js
│ │ │ ├── TraitNumberView.js
│ │ │ ├── TraitSelectView.js
│ │ │ ├── TraitView.js
│ │ │ └── TraitsView.js
│ ├── undo_manager
│ │ └── index.js
│ └── utils
│ │ ├── ColorPicker.js
│ │ ├── Dragger.js
│ │ ├── Droppable.js
│ │ ├── Resizer.js
│ │ ├── Sorter.js
│ │ ├── extender.js
│ │ ├── fetch.js
│ │ ├── index.js
│ │ ├── mixins.js
│ │ └── polyfills.js
├── test
│ ├── helper.js
│ ├── main.js
│ └── specs
│ │ ├── asset_manager
│ │ ├── index.js
│ │ ├── model
│ │ │ ├── Asset.js
│ │ │ ├── AssetImage.js
│ │ │ └── Assets.js
│ │ └── view
│ │ │ ├── AssetImageView.js
│ │ │ ├── AssetView.js
│ │ │ ├── AssetsView.js
│ │ │ └── FileUploader.js
│ │ ├── block_manager
│ │ ├── index.js
│ │ └── view
│ │ │ └── BlocksView.js
│ │ ├── code_manager
│ │ ├── index.js
│ │ └── model
│ │ │ └── CodeModels.js
│ │ ├── commands
│ │ ├── index.js
│ │ ├── model
│ │ │ └── CommandModels.js
│ │ └── view
│ │ │ └── CommandAbstract.js
│ │ ├── css_composer
│ │ ├── e2e
│ │ │ └── CssComposer.js
│ │ ├── index.js
│ │ ├── model
│ │ │ └── CssModels.js
│ │ └── view
│ │ │ ├── CssRuleView.js
│ │ │ └── CssRulesView.js
│ │ ├── device_manager
│ │ ├── index.js
│ │ └── view
│ │ │ └── DevicesView.js
│ │ ├── dom_components
│ │ ├── index.js
│ │ ├── model
│ │ │ └── Component.js
│ │ └── view
│ │ │ ├── ComponentImageView.js
│ │ │ ├── ComponentTextView.js
│ │ │ ├── ComponentV.js
│ │ │ └── ComponentsView.js
│ │ ├── grapesjs
│ │ └── index.js
│ │ ├── keymaps
│ │ └── index.js
│ │ ├── modal
│ │ ├── index.js
│ │ └── view
│ │ │ └── ModalView.js
│ │ ├── panels
│ │ ├── e2e
│ │ │ └── PanelsE2e.js
│ │ ├── index.js
│ │ ├── model
│ │ │ └── PanelModels.js
│ │ └── view
│ │ │ ├── ButtonView.js
│ │ │ ├── ButtonsView.js
│ │ │ ├── PanelView.js
│ │ │ └── PanelsView.js
│ │ ├── parser
│ │ ├── index.js
│ │ └── model
│ │ │ ├── ParserCss.js
│ │ │ └── ParserHtml.js
│ │ ├── plugin_manager
│ │ └── index.js
│ │ ├── selector_manager
│ │ ├── e2e
│ │ │ └── ClassManager.js
│ │ ├── index.js
│ │ ├── model
│ │ │ └── SelectorModels.js
│ │ └── view
│ │ │ ├── ClassTagView.js
│ │ │ └── ClassTagsView.js
│ │ ├── storage_manager
│ │ ├── index.js
│ │ └── model
│ │ │ └── Models.js
│ │ ├── style_manager
│ │ ├── index.js
│ │ ├── model
│ │ │ └── Models.js
│ │ └── view
│ │ │ ├── LayerView.js
│ │ │ ├── PropertyColorView.js
│ │ │ ├── PropertyCompositeView.js
│ │ │ ├── PropertyIntegerView.js
│ │ │ ├── PropertyRadioView.js
│ │ │ ├── PropertySelectView.js
│ │ │ ├── PropertyStackView.js
│ │ │ ├── PropertyView.js
│ │ │ ├── SectorView.js
│ │ │ └── SectorsView.js
│ │ ├── test_utils.js
│ │ ├── trait_manager
│ │ ├── index.js
│ │ ├── model
│ │ │ └── TraitsModel.js
│ │ └── view
│ │ │ └── TraitsView.js
│ │ └── utils
│ │ ├── Sorter.js
│ │ └── main.js
└── webpack.config.js
├── index.css
├── index.html
├── index.js
├── logo.svg
├── package-lock.json
├── package.json
├── src
├── blocks
│ └── index.js
├── commands
│ ├── index.js
│ └── openImport.js
├── components
│ └── index.js
├── consts.js
├── index.js
├── panels
│ └── index.js
├── style
│ ├── _variables.scss
│ └── main.scss
├── styles
│ └── index.js
└── traits
│ └── index.js
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | private/
4 | .eslintrc
5 | *.log
6 | _index.html
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017, (YOUR NAME)
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | - Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 | - Redistributions in binary form must reproduce the above copyright notice, this
10 | list of conditions and the following disclaimer in the documentation and/or
11 | other materials provided with the distribution.
12 | - Neither the name "GrapesJS" nor the names of its contributors may be
13 | used to endorse or promote products derived from this software without
14 | specific prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | README
--------------------------------------------------------------------------------
/custom_icons/storage-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dist/grapesjs-mavo.min.css:
--------------------------------------------------------------------------------
1 | .gjs-one-bg{background-color:#463a3c}.gjs-one-color{color:#463a3c}.gjs-one-color-h:hover{color:#463a3c}.gjs-two-bg{background-color:#b9a5a6}.gjs-two-color{color:#b9a5a6}.gjs-two-color-h:hover{color:#b9a5a6}.gjs-three-bg{background-color:#804f7b}.gjs-three-color{color:#804f7b}.gjs-three-color-h:hover{color:#804f7b}.gjs-four-bg{background-color:#d97aa6}.gjs-four-color{color:#d97aa6}.gjs-four-color-h:hover{color:#d97aa6}
2 |
--------------------------------------------------------------------------------
/grapesjs/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 |
7 | [*.js]
8 | charset = utf-8
9 | indent_style = space
10 | indent_size = 2
11 |
--------------------------------------------------------------------------------
/grapesjs/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "node": true
5 | },
6 | "parserOptions": {
7 | "sourceType": "module",
8 | "ecmaFeatures": {
9 | "experimentalObjectRestSpread": true
10 | }
11 | },
12 | "rules": {
13 | "strict": 0,
14 | "quotes": [0, "single"],
15 | "eol-last": [0],
16 | "no-mixed-requires": [0],
17 | "no-underscore-dangle": [0]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/grapesjs/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## WARNING
2 | READ and FOLLOW next 5 steps, then REMOVE them before posting the issue
3 |
4 | 1. Follow CONTRIBUTING Guidelines https://github.com/artf/grapesjs/blob/master/CONTRIBUTING.md
5 | 2. Use the GitHub Issues EXCLUSIVELY for BUGS, FEATURE REQUESTS or QUESTIONS. Prefix the title of the issue with its context, eg. `[Bug]: ....`
6 | 3. Do a quick SEARCH first, to see if someone else didn't open the same issue
7 | 4. DON'T ASK to create examples/code for you, read DOCS and APIs first, then you can post what you have tried (we'd like to see your code) and what you're unable to achieve
8 | 5. All relative statements/questions have to be filled/answered, otherwise, the issue might be CLOSED
9 |
10 | ## You're submitting a BUG
11 | 1. Are you using the latest release (older versions are NOT supported)?
12 | 1. If you're not sure, type `grapesjs.version` in console and press ENTER
13 | 1. Are you facing the bug with your local copy of GrapesJS or with the current demo?
14 | 1. If a local copy
15 | 1. Indicate all informations about your OS, browser and GrapesJS version.
16 | 1. Are you able to reproduce the bug from the demo?
17 | 1. What is the expected behavior?
18 | 1. What happens instead?
19 | 1. If you're able to reproduce the bug indicate all the necessary steps
20 | 1. Attach screenshots (using KAP/LICEcap), screencasts or live demo
21 | 1. JSFiddle Starter template https://jsfiddle.net/szLp8h4n
22 | 1. CodeSandbox Starter template https://codesandbox.io/s/1r0w2pk1vl
23 |
24 | ## You're submitting a FEATURE REQUEST
25 | 1. Be sure to work on the latest version, as the feature might be already there
26 | 1. Keep in mind that the feature should be considered valid to use for everyone, not only for your case
27 |
--------------------------------------------------------------------------------
/grapesjs/.github/no-response.yml:
--------------------------------------------------------------------------------
1 | # Configuration for probot-no-response - https://github.com/probot/no-response
2 |
3 | # Number of days of inactivity before an Issue is closed for lack of response
4 | daysUntilClose: 10
5 | # Label requiring a response
6 | responseRequiredLabel: more-information-needed
7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable
8 | closeComment: >
9 | This issue has been automatically closed because there has been no response
10 | to our request for more information from the original author. With only the
11 | information that is currently in the issue, we don't have enough information
12 | to take action. Please reach out if you have or find the answers we need so
13 | that we can investigate further.
14 |
--------------------------------------------------------------------------------
/grapesjs/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .settings/
3 | .sass-cache/
4 | .project
5 | .idea
6 | npm-debug.log*
7 | yarn-error.log
8 | yarn.lock
9 | style/.sass-cache/
10 |
11 | img/
12 | images/
13 | private/
14 | docs/
15 | vendor/
16 | coverage/
17 | node_modules/
18 | bower_components/
19 | grapesjs-*.tgz
20 | _index.html
21 |
--------------------------------------------------------------------------------
/grapesjs/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "7.6"
4 |
--------------------------------------------------------------------------------
/grapesjs/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017-current, Artur Arseniev
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | - Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 | - Redistributions in binary form must reproduce the above copyright notice, this
10 | list of conditions and the following disclaimer in the documentation and/or
11 | other materials provided with the distribution.
12 | - Neither the name "GrapesJS" nor the names of its contributors may be
13 | used to endorse or promote products derived from this software without
14 | specific prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/grapesjs/dist/fonts/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mavoweb/create/b5fca8f6331b368ab40acba48165733e33bc71e4/grapesjs/dist/fonts/FontAwesome.otf
--------------------------------------------------------------------------------
/grapesjs/dist/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mavoweb/create/b5fca8f6331b368ab40acba48165733e33bc71e4/grapesjs/dist/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/grapesjs/dist/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mavoweb/create/b5fca8f6331b368ab40acba48165733e33bc71e4/grapesjs/dist/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/grapesjs/dist/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mavoweb/create/b5fca8f6331b368ab40acba48165733e33bc71e4/grapesjs/dist/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/grapesjs/dist/fonts/fontawesome-webfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mavoweb/create/b5fca8f6331b368ab40acba48165733e33bc71e4/grapesjs/dist/fonts/fontawesome-webfont.woff2
--------------------------------------------------------------------------------
/grapesjs/dist/fonts/main-fonts.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mavoweb/create/b5fca8f6331b368ab40acba48165733e33bc71e4/grapesjs/dist/fonts/main-fonts.eot
--------------------------------------------------------------------------------
/grapesjs/dist/fonts/main-fonts.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mavoweb/create/b5fca8f6331b368ab40acba48165733e33bc71e4/grapesjs/dist/fonts/main-fonts.ttf
--------------------------------------------------------------------------------
/grapesjs/dist/fonts/main-fonts.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mavoweb/create/b5fca8f6331b368ab40acba48165733e33bc71e4/grapesjs/dist/fonts/main-fonts.woff
--------------------------------------------------------------------------------
/grapesjs/src/asset_manager/model/Asset.js:
--------------------------------------------------------------------------------
1 | module.exports = require('backbone').Model.extend({
2 | idAttribute: 'src',
3 |
4 | defaults: {
5 | type: '',
6 | src: ''
7 | },
8 |
9 | /**
10 | * Get filename of the asset
11 | * @return {string}
12 | * @private
13 | * */
14 | getFilename() {
15 | return this.get('src')
16 | .split('/')
17 | .pop();
18 | },
19 |
20 | /**
21 | * Get extension of the asset
22 | * @return {string}
23 | * @private
24 | * */
25 | getExtension() {
26 | return this.getFilename()
27 | .split('.')
28 | .pop();
29 | }
30 | });
31 |
--------------------------------------------------------------------------------
/grapesjs/src/asset_manager/model/AssetImage.js:
--------------------------------------------------------------------------------
1 | const Asset = require('./Asset');
2 |
3 | module.exports = Asset.extend({
4 | defaults: {
5 | ...Asset.prototype.defaults,
6 | type: 'image',
7 | unitDim: 'px',
8 | height: 0,
9 | width: 0
10 | }
11 | });
12 |
--------------------------------------------------------------------------------
/grapesjs/src/asset_manager/model/Assets.js:
--------------------------------------------------------------------------------
1 | import TypeableCollection from 'domain_abstract/model/TypeableCollection';
2 |
3 | module.exports = require('backbone')
4 | .Collection.extend(TypeableCollection)
5 | .extend({
6 | types: [
7 | {
8 | id: 'image',
9 | model: require('./AssetImage'),
10 | view: require('./../view/AssetImageView'),
11 | isType(value) {
12 | if (typeof value == 'string') {
13 | return {
14 | type: 'image',
15 | src: value
16 | };
17 | }
18 | return value;
19 | }
20 | }
21 | ]
22 | });
23 |
--------------------------------------------------------------------------------
/grapesjs/src/asset_manager/view/AssetImageView.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./AssetView').extend({
2 | events: {
3 | 'click [data-toggle=asset-remove]': 'onRemove',
4 | click: 'onClick',
5 | dblclick: 'onDblClick'
6 | },
7 |
8 | getPreview() {
9 | const pfx = this.pfx;
10 | const src = this.model.get('src');
11 | return `
12 |
13 |
14 | `;
15 | },
16 |
17 | getInfo() {
18 | const pfx = this.pfx;
19 | const model = this.model;
20 | let name = model.get('name');
21 | let width = model.get('width');
22 | let height = model.get('height');
23 | let unit = model.get('unitDim');
24 | let dim = width && height ? `${width}x${height}${unit}` : '';
25 | name = name || model.getFilename();
26 | return `
27 | ${name}
28 | ${dim}
29 | `;
30 | },
31 |
32 | init(o) {
33 | const pfx = this.pfx;
34 | this.className += ` ${pfx}asset-image`;
35 | },
36 |
37 | /**
38 | * Triggered when the asset is clicked
39 | * @private
40 | * */
41 | onClick() {
42 | var onClick = this.config.onClick;
43 | var model = this.model;
44 | this.collection.trigger('deselectAll');
45 | this.$el.addClass(this.pfx + 'highlight');
46 |
47 | if (typeof onClick === 'function') {
48 | onClick(model);
49 | } else {
50 | this.updateTarget(this.collection.target);
51 | }
52 | },
53 |
54 | /**
55 | * Triggered when the asset is double clicked
56 | * @private
57 | * */
58 | onDblClick() {
59 | const em = this.em;
60 | var onDblClick = this.config.onDblClick;
61 | var model = this.model;
62 |
63 | if (typeof onDblClick === 'function') {
64 | onDblClick(model);
65 | } else {
66 | this.updateTarget(this.collection.target);
67 | em && em.get('Modal').close();
68 | }
69 |
70 | var onSelect = this.collection.onSelect;
71 | if (typeof onSelect == 'function') {
72 | onSelect(this.model);
73 | }
74 | },
75 |
76 | /**
77 | * Remove asset from collection
78 | * @private
79 | * */
80 | onRemove(e) {
81 | e.stopImmediatePropagation();
82 | this.model.collection.remove(this.model);
83 | }
84 | });
85 |
--------------------------------------------------------------------------------
/grapesjs/src/asset_manager/view/AssetView.js:
--------------------------------------------------------------------------------
1 | module.exports = Backbone.View.extend({
2 | initialize(o = {}) {
3 | this.options = o;
4 | this.collection = o.collection;
5 | const config = o.config || {};
6 | this.config = config;
7 | this.pfx = config.stylePrefix || '';
8 | this.ppfx = config.pStylePrefix || '';
9 | this.em = config.em;
10 | this.className = this.pfx + 'asset';
11 | this.listenTo(this.model, 'destroy remove', this.remove);
12 | this.model.view = this;
13 | const init = this.init && this.init.bind(this);
14 | init && init(o);
15 | },
16 |
17 | template() {
18 | const pfx = this.pfx;
19 | return `
20 |
21 | ${this.getPreview()}
22 |
23 |
24 | ${this.getInfo()}
25 |
26 |
27 | ⨯
28 |
29 | `;
30 | },
31 |
32 | /**
33 | * Update target if exists
34 | * @param {Model} target
35 | * @private
36 | * */
37 | updateTarget(target) {
38 | if (target && target.set) {
39 | target.set('attributes', _.clone(target.get('attributes')));
40 | target.set('src', this.model.get('src'));
41 | }
42 | },
43 |
44 | getPreview() {
45 | return '';
46 | },
47 |
48 | getInfo() {
49 | return '';
50 | },
51 |
52 | render() {
53 | const el = this.el;
54 | el.innerHTML = this.template(this, this.model);
55 | el.className = this.className;
56 | return this;
57 | }
58 | });
59 |
--------------------------------------------------------------------------------
/grapesjs/src/block_manager/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // Specify the element to use as a container, string (query) or HTMLElement
3 | // With the empty value, nothing will be rendered
4 | appendTo: '',
5 |
6 | blocks: []
7 | };
8 |
--------------------------------------------------------------------------------
/grapesjs/src/block_manager/model/Block.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var Category = require('./Category');
3 |
4 | module.exports = Backbone.Model.extend({
5 | defaults: {
6 | label: '',
7 | content: '',
8 | category: '',
9 | attributes: {}
10 | },
11 |
12 | initialize(opts = {}) {
13 | let category = this.get('category');
14 |
15 | if (category) {
16 | if (typeof category == 'string') {
17 | var catObj = new Category({
18 | id: category,
19 | label: category
20 | });
21 | }
22 | }
23 | }
24 | });
25 |
--------------------------------------------------------------------------------
/grapesjs/src/block_manager/model/Blocks.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var Block = require('./Block');
3 |
4 | module.exports = Backbone.Collection.extend({
5 | model: Block
6 | });
7 |
--------------------------------------------------------------------------------
/grapesjs/src/block_manager/model/Categories.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Collection.extend({
4 | model: require('./Category')
5 | });
6 |
--------------------------------------------------------------------------------
/grapesjs/src/block_manager/model/Category.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | defaults: {
5 | id: '',
6 | label: '',
7 | open: true,
8 | attributes: {}
9 | }
10 | });
11 |
--------------------------------------------------------------------------------
/grapesjs/src/block_manager/view/CategoryView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.View.extend({
4 | template: _.template(`
5 |
6 |
7 | <%= label %>
8 |
9 |
10 | `),
11 |
12 | events: {},
13 |
14 | initialize(o = {}, config = {}) {
15 | this.config = config;
16 | const pfx = this.config.pStylePrefix || '';
17 | this.pfx = pfx;
18 | this.caretR = 'fa fa-caret-right';
19 | this.caretD = 'fa fa-caret-down';
20 | this.iconClass = `${pfx}caret-icon`;
21 | this.activeClass = `${pfx}open`;
22 | this.className = `${pfx}block-category`;
23 | this.events[`click .${pfx}title`] = 'toggle';
24 | this.listenTo(this.model, 'change:open', this.updateVisibility);
25 | this.delegateEvents();
26 | },
27 |
28 | updateVisibility() {
29 | if (this.model.get('open')) this.open();
30 | else this.close();
31 | },
32 |
33 | open() {
34 | this.el.className = `${this.className} ${this.activeClass}`;
35 | this.getIconEl().className = `${this.iconClass} ${this.caretD}`;
36 | this.getBlocksEl().style.display = '';
37 | },
38 |
39 | close() {
40 | this.el.className = this.className;
41 | this.getIconEl().className = `${this.iconClass} ${this.caretR}`;
42 | this.getBlocksEl().style.display = 'none';
43 | },
44 |
45 | toggle() {
46 | var model = this.model;
47 | model.set('open', !model.get('open'));
48 | },
49 |
50 | getIconEl() {
51 | if (!this.iconEl) {
52 | this.iconEl = this.el.querySelector('.' + this.iconClass);
53 | }
54 |
55 | return this.iconEl;
56 | },
57 |
58 | getBlocksEl() {
59 | if (!this.blocksEl) {
60 | this.blocksEl = this.el.querySelector('.' + this.pfx + 'blocks-c');
61 | }
62 |
63 | return this.blocksEl;
64 | },
65 |
66 | append(el) {
67 | this.getBlocksEl().appendChild(el);
68 | },
69 |
70 | render() {
71 | this.el.innerHTML = this.template({
72 | pfx: this.pfx,
73 | label: this.model.get('label')
74 | });
75 | this.el.className = this.className;
76 | this.$el.css({ order: this.model.get('order') });
77 | this.updateVisibility();
78 | return this;
79 | }
80 | });
81 |
--------------------------------------------------------------------------------
/grapesjs/src/canvas/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stylePrefix: 'cv-',
3 |
4 | // Coming soon
5 | rulers: false,
6 |
7 | /*
8 | * Append external scripts in head of the iframe before renderBody content
9 | * In this case, you have to add them manually later in the final HTML page
10 | * @example
11 | * scripts: [
12 | * 'https://...',
13 | * ]
14 | */
15 | scripts: [],
16 |
17 | /*
18 | * Append external styles. This styles won't be added to the final HTML/CSS
19 | * @example
20 | * styles: [
21 | * 'https://...',
22 | * ]
23 | */
24 | styles: [],
25 |
26 | /**
27 | * Add custom badge naming strategy
28 | * @example
29 | * customBadgeLabel: function(ComponentModel) {
30 | * return ComponentModel.getName();
31 | * }
32 | */
33 | customBadgeLabel: function(ComponentModel) {
34 | var propertyName;
35 | var property = ComponentModel.get('traits').where({ name: 'property' })[0];
36 | if (property) {
37 | propertyName = property.get('value');
38 | }
39 | if (propertyName && propertyName !== '') {
40 | return ComponentModel.getName() + ' - ' + propertyName;
41 | }
42 | return ComponentModel.getName();
43 | }
44 | };
45 |
--------------------------------------------------------------------------------
/grapesjs/src/canvas/model/Canvas.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var Frame = require('./Frame');
3 |
4 | module.exports = Backbone.Model.extend({
5 | defaults: {
6 | frame: '',
7 | wrapper: '',
8 | rulers: false
9 | },
10 |
11 | initialize(config) {
12 | var conf = this.conf || {};
13 | this.set('frame', new Frame(conf.frame));
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/grapesjs/src/canvas/model/Frame.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | defaults: {
5 | wrapper: '',
6 | width: '',
7 | height: '',
8 | attributes: {}
9 | }
10 | });
11 |
--------------------------------------------------------------------------------
/grapesjs/src/canvas/view/FrameView.js:
--------------------------------------------------------------------------------
1 | import { bindAll } from 'underscore';
2 |
3 | const motionsEv =
4 | 'transitionend oTransitionEnd transitionend webkitTransitionEnd';
5 |
6 | module.exports = require('backbone').View.extend({
7 | tagName: 'iframe',
8 |
9 | attributes: {
10 | allowfullscreen: 'allowfullscreen'
11 | },
12 |
13 | initialize(o) {
14 | bindAll(this, 'udpateOffset');
15 | this.config = o.config || {};
16 | this.ppfx = this.config.pStylePrefix || '';
17 | this.em = this.config.em;
18 | this.listenTo(this.em, 'change:device', this.updateDim);
19 | },
20 |
21 | /**
22 | * Update dimensions of the frame
23 | * @private
24 | */
25 | updateDim(model) {
26 | const em = this.em;
27 | const device = em.getDeviceModel();
28 | const style = this.el.style;
29 | const currW = style.width || '';
30 | const currH = style.height || '';
31 | const newW = device ? device.get('width') : '';
32 | const newH = device ? device.get('height') : '';
33 | const noChanges = currW == newW && currH == newH;
34 | style.width = newW;
35 | style.height = newH;
36 | this.udpateOffset();
37 | // Prevent fixed highlighting box which appears when on
38 | // component hover during the animation
39 | em.stopDefault({ preserveSelected: 1 });
40 | noChanges ? this.udpateOffset() : this.$el.on(motionsEv, this.udpateOffset);
41 | },
42 |
43 | udpateOffset() {
44 | const em = this.em;
45 | const offset = em.get('Canvas').getOffset();
46 | em.set('canvasOffset', offset);
47 | em.runDefault({ preserveSelected: 1 });
48 | this.$el.off(motionsEv, this.udpateOffset);
49 | },
50 |
51 | getBody() {
52 | this.$el.contents().find('body');
53 | },
54 |
55 | getWrapper() {
56 | return this.$el.contents().find('body > div');
57 | },
58 |
59 | render() {
60 | this.$el.attr({ class: this.ppfx + 'frame' });
61 | return this;
62 | }
63 | });
64 |
--------------------------------------------------------------------------------
/grapesjs/src/code_manager/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // Style prefix
3 | stylePrefix: 'cm-',
4 |
5 | inlineCss: false
6 | };
7 |
--------------------------------------------------------------------------------
/grapesjs/src/code_manager/model/CodeMirrorEditor.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var CodeMirror = require('codemirror/lib/codemirror');
3 | var htmlMode = require('codemirror/mode/htmlmixed/htmlmixed');
4 | var cssMode = require('codemirror/mode/css/css');
5 | var formatting = require('codemirror-formatting');
6 |
7 | module.exports = Backbone.Model.extend({
8 | defaults: {
9 | input: '',
10 | label: '',
11 | codeName: '',
12 | theme: '',
13 | readOnly: true,
14 | lineNumbers: true
15 | },
16 |
17 | /** @inheritdoc */
18 | init(el) {
19 | this.editor = CodeMirror.fromTextArea(el, {
20 | dragDrop: false,
21 | lineWrapping: true,
22 | mode: this.get('codeName'),
23 | ...this.attributes
24 | });
25 |
26 | return this;
27 | },
28 |
29 | /** @inheritdoc */
30 | setContent(v) {
31 | if (!this.editor) return;
32 | this.editor.setValue(v);
33 | if (this.editor.autoFormatRange) {
34 | CodeMirror.commands.selectAll(this.editor);
35 | this.editor.autoFormatRange(
36 | this.editor.getCursor(true),
37 | this.editor.getCursor(false)
38 | );
39 | CodeMirror.commands.goDocStart(this.editor);
40 | }
41 | }
42 | });
43 |
--------------------------------------------------------------------------------
/grapesjs/src/code_manager/model/HtmlGenerator.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | build(model, opts = {}) {
5 | const models = model.get('components');
6 |
7 | if (opts.exportWrapper) {
8 | return opts.wrappesIsBody
9 | ? `${this.buildModels(models)}`
10 | : model.toHTML();
11 | }
12 |
13 | return this.buildModels(models);
14 | },
15 |
16 | buildModels(models) {
17 | let code = '';
18 | models.each(model => {
19 | code += model.toHTML();
20 | });
21 | return code;
22 | }
23 | });
24 |
--------------------------------------------------------------------------------
/grapesjs/src/code_manager/model/JsGenerator.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | mapModel(model) {
5 | var code = '';
6 | var script = model.get('script');
7 | var type = model.get('type');
8 | var comps = model.get('components');
9 | var id = model.getId();
10 |
11 | if (script) {
12 | // If the component has scripts we need to expose his ID
13 | var attr = model.get('attributes');
14 | attr = _.extend({}, attr, { id });
15 | model.set('attributes', attr);
16 | var scrStr = model.getScriptString();
17 |
18 | // If the script was updated, I'll put its code in a separate container
19 | if (model.get('scriptUpdated')) {
20 | this.mapJs[type + '-' + id] = { ids: [id], code: scrStr };
21 | } else {
22 | var mapType = this.mapJs[type];
23 |
24 | if (mapType) {
25 | mapType.ids.push(id);
26 | } else {
27 | this.mapJs[type] = { ids: [id], code: scrStr };
28 | }
29 | }
30 | }
31 |
32 | comps.each(function(model) {
33 | code += this.mapModel(model);
34 | }, this);
35 |
36 | return code;
37 | },
38 |
39 | build(model) {
40 | this.mapJs = {};
41 | this.mapModel(model);
42 |
43 | var code = '';
44 |
45 | for (var type in this.mapJs) {
46 | var mapType = this.mapJs[type];
47 | var ids = '#' + mapType.ids.join(', #');
48 | code += `
49 | var items = document.querySelectorAll('${ids}');
50 | for (var i = 0, len = items.length; i < len; i++) {
51 | (function(){${mapType.code}}.bind(items[i]))();
52 | }`;
53 | }
54 |
55 | return code;
56 | }
57 | });
58 |
--------------------------------------------------------------------------------
/grapesjs/src/code_manager/model/JsonGenerator.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | /** @inheritdoc */
5 | build(model) {
6 | var json = model.toJSON();
7 | this.beforeEach(json);
8 |
9 | _.each(
10 | json,
11 | function(v, attr) {
12 | var obj = json[attr];
13 | if (obj instanceof Backbone.Model) {
14 | json[attr] = this.build(obj);
15 | } else if (obj instanceof Backbone.Collection) {
16 | var coll = obj;
17 | json[attr] = [];
18 | if (coll.length) {
19 | coll.each(function(el, index) {
20 | json[attr][index] = this.build(el);
21 | }, this);
22 | }
23 | }
24 | },
25 | this
26 | );
27 |
28 | return json;
29 | },
30 |
31 | /**
32 | * Execute on each object
33 | * @param {Object} obj
34 | */
35 | beforeEach(obj) {
36 | delete obj.status;
37 | }
38 | });
39 |
--------------------------------------------------------------------------------
/grapesjs/src/code_manager/view/EditorView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.View.extend({
4 | template: _.template(`
5 | `),
9 |
10 | initialize(o) {
11 | this.config = o.config || {};
12 | this.pfx = this.config.stylePrefix;
13 | },
14 |
15 | render() {
16 | var obj = this.model.toJSON();
17 | obj.pfx = this.pfx;
18 | this.$el.html(this.template(obj));
19 | this.$el.attr('class', this.pfx + 'editor-c');
20 | this.$el.find('#' + this.pfx + 'code').append(this.model.get('input'));
21 | return this;
22 | }
23 | });
24 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | ESCAPE_KEY: 27,
3 |
4 | stylePrefix: 'com-',
5 |
6 | defaults: [],
7 |
8 | // Editor model
9 | em: null,
10 |
11 | // If true center new first-level components
12 | firstCentered: true,
13 |
14 | // If true the new component will created with 'height', else 'min-height'
15 | newFixedH: false,
16 |
17 | // Minimum height (in px) of new component
18 | minComponentH: 50,
19 |
20 | // Minimum width (in px) of component on creation
21 | minComponentW: 50
22 | };
23 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/model/Command.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | defaults: {
5 | id: ''
6 | }
7 | });
8 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/model/Commands.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var Command = require('./Command');
3 |
4 | module.exports = Backbone.Collection.extend({
5 | model: Command
6 | });
7 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/DeleteComponent.js:
--------------------------------------------------------------------------------
1 | const SelectComponent = require('./SelectComponent');
2 | const $ = Backbone.$;
3 |
4 | module.exports = _.extend({}, SelectComponent, {
5 | init(o) {
6 | _.bindAll(this, 'startDelete', 'stopDelete', 'onDelete');
7 | this.hoverClass = this.pfx + 'hover-delete';
8 | this.badgeClass = this.pfx + 'badge-red';
9 | },
10 |
11 | enable() {
12 | var that = this;
13 | this.$el
14 | .find('*')
15 | .mouseover(this.startDelete)
16 | .mouseout(this.stopDelete)
17 | .click(this.onDelete);
18 | },
19 |
20 | /**
21 | * Start command
22 | * @param {Object} e
23 | * @private
24 | */
25 | startDelete(e) {
26 | e.stopPropagation();
27 | var $this = $(e.target);
28 |
29 | // Show badge if possible
30 | if ($this.data('model').get('removable')) {
31 | $this.addClass(this.hoverClass);
32 | this.attachBadge($this.get(0));
33 | }
34 | },
35 |
36 | /**
37 | * Stop command
38 | * @param {Object} e
39 | * @private
40 | */
41 | stopDelete(e) {
42 | e.stopPropagation();
43 | var $this = $(e.target);
44 | $this.removeClass(this.hoverClass);
45 |
46 | // Hide badge if possible
47 | if (this.badge) this.badge.css({ left: -1000, top: -1000 });
48 | },
49 |
50 | /**
51 | * Delete command
52 | * @param {Object} e
53 | * @private
54 | */
55 | onDelete(e) {
56 | e.stopPropagation();
57 | var $this = $(e.target);
58 |
59 | // Do nothing in case can't remove
60 | if (!$this.data('model').get('removable')) return;
61 |
62 | $this.data('model').destroy();
63 | this.removeBadge();
64 | this.clean();
65 | },
66 |
67 | /**
68 | * Updates badge label
69 | * @param {Object} model
70 | * @private
71 | * */
72 | updateBadgeLabel(model) {
73 | this.badge.html('Remove ' + model.getName());
74 | }
75 | });
76 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/Drag.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | run(editor, sender, opts) {
3 | var el = (opts && opts.el) || '';
4 | var canvas = editor.Canvas;
5 | var dragger = this.dragger;
6 | var options = opts.options || {};
7 | var canvasView = canvas.getCanvasView();
8 | options.prefix = editor.getConfig().stylePrefix;
9 | options.mousePosFetcher = canvas.getMouseRelativePos;
10 | options.posFetcher = canvasView.getElementPos.bind(canvasView);
11 |
12 | // Create the resizer for the canvas if not yet created
13 | if (!dragger) {
14 | dragger = editor.Utils.Dragger.init(options);
15 | this.dragger = dragger;
16 | }
17 |
18 | dragger.setOptions(options);
19 | dragger.focus(el);
20 |
21 | if (options.event) {
22 | dragger.start(options.event);
23 | }
24 |
25 | return dragger;
26 | },
27 |
28 | stop() {
29 | if (this.canvasResizer) this.canvasResizer.blur();
30 | }
31 | };
32 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/ExportTemplate.js:
--------------------------------------------------------------------------------
1 | const $ = Backbone.$;
2 |
3 | module.exports = {
4 | run(editor, sender, opts = {}) {
5 | sender && sender.set && sender.set('active', 0);
6 | const config = editor.getConfig();
7 | const modal = editor.Modal;
8 | const pfx = config.stylePrefix;
9 | this.cm = editor.CodeManager || null;
10 |
11 | if (!this.$editors) {
12 | const oHtmlEd = this.buildEditor('htmlmixed', 'hopscotch', 'HTML');
13 | const oCsslEd = this.buildEditor('css', 'hopscotch', 'CSS');
14 | this.htmlEditor = oHtmlEd.el;
15 | this.cssEditor = oCsslEd.el;
16 | const $editors = $(``);
17 | $editors.append(oHtmlEd.$el).append(oCsslEd.$el);
18 | this.$editors = $editors;
19 | }
20 |
21 | modal.setTitle(config.textViewCode);
22 | modal.setContent(this.$editors);
23 | modal.open();
24 | this.htmlEditor.setContent(editor.getHtml());
25 | this.cssEditor.setContent(editor.getCss());
26 | },
27 |
28 | stop(editor) {
29 | const modal = editor.Modal;
30 | modal && modal.close();
31 | },
32 |
33 | buildEditor(codeName, theme, label) {
34 | const input = document.createElement('textarea');
35 | !this.codeMirror && (this.codeMirror = this.cm.getViewer('CodeMirror'));
36 |
37 | const el = this.codeMirror.clone().set({
38 | label,
39 | codeName,
40 | theme,
41 | input
42 | });
43 |
44 | const $el = new this.cm.EditorView({
45 | model: el,
46 | config: this.cm.getConfig()
47 | }).render().$el;
48 |
49 | el.init(input);
50 |
51 | return { el, $el };
52 | }
53 | };
54 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/Fullscreen.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | /**
3 | * Check if fullscreen mode is enabled
4 | * @return {Boolean}
5 | */
6 | isEnabled() {
7 | var d = document;
8 | if (
9 | d.fullscreenElement ||
10 | d.webkitFullscreenElement ||
11 | d.mozFullScreenElement
12 | )
13 | return 1;
14 | else return 0;
15 | },
16 |
17 | /**
18 | * Enable fullscreen mode and return browser prefix
19 | * @param {HTMLElement} el
20 | * @return {string}
21 | */
22 | enable(el) {
23 | var pfx = '';
24 | if (el.requestFullscreen) el.requestFullscreen();
25 | else if (el.webkitRequestFullscreen) {
26 | pfx = 'webkit';
27 | el.webkitRequestFullscreen();
28 | } else if (el.mozRequestFullScreen) {
29 | pfx = 'moz';
30 | el.mozRequestFullScreen();
31 | } else if (el.msRequestFullscreen) el.msRequestFullscreen();
32 | else console.warn('Fullscreen not supported');
33 | return pfx;
34 | },
35 |
36 | /**
37 | * Disable fullscreen mode
38 | */
39 | disable() {
40 | var d = document;
41 | if (d.exitFullscreen) d.exitFullscreen();
42 | else if (d.webkitExitFullscreen) d.webkitExitFullscreen();
43 | else if (d.mozCancelFullScreen) d.mozCancelFullScreen();
44 | else if (d.msExitFullscreen) d.msExitFullscreen();
45 | },
46 |
47 | /**
48 | * Triggered when the state of the fullscreen is changed. Inside detects if
49 | * it's enabled
50 | * @param {strinf} pfx Browser prefix
51 | * @param {Event} e
52 | */
53 | fsChanged(pfx, e) {
54 | var d = document;
55 | var ev = (pfx || '') + 'fullscreenchange';
56 | if (!this.isEnabled()) {
57 | this.stop(null, this.sender);
58 | document.removeEventListener(ev, this.fsChanged);
59 | }
60 | },
61 |
62 | run(editor, sender) {
63 | this.sender = sender;
64 | var pfx = this.enable(editor.getContainer());
65 | this.fsChanged = this.fsChanged.bind(this, pfx);
66 | document.addEventListener(pfx + 'fullscreenchange', this.fsChanged);
67 | if (editor) editor.trigger('change:canvasOffset');
68 | },
69 |
70 | stop(editor, sender) {
71 | if (sender && sender.set) sender.set('active', false);
72 | this.disable();
73 | if (editor) editor.trigger('change:canvasOffset');
74 | }
75 | };
76 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/ImageComponent.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var InsertCustom = require('./InsertCustom');
3 |
4 | module.exports = _.extend({}, InsertCustom, {
5 | /**
6 | * Trigger before insert
7 | * @param {Object} object
8 | * @private
9 | *
10 | * */
11 | beforeInsert(object) {
12 | object.type = 'image';
13 | object.style = {};
14 | object.attributes = {};
15 | object.attributes.onmousedown = 'return false';
16 | if (
17 | this.config.firstCentered &&
18 | this.getCanvasWrapper() == this.sorter.target
19 | ) {
20 | object.style.margin = '0 auto';
21 | }
22 | },
23 |
24 | /**
25 | * Trigger after insert
26 | * @param {Object} model Model created after insert
27 | * @private
28 | * */
29 | afterInsert(model) {
30 | model.trigger('dblclick');
31 | if (this.sender) this.sender.set('active', false);
32 | }
33 | });
34 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/InsertCustom.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var CreateComponent = require('./CreateComponent');
3 |
4 | module.exports = _.extend({}, CreateComponent, {
5 | init(...args) {
6 | CreateComponent.init.apply(this, args);
7 | _.bindAll(this, 'insertComponent');
8 | this.allowDraw = 0;
9 | },
10 |
11 | /**
12 | * Run method
13 | * @private
14 | * */
15 | run(em, sender, options) {
16 | this.em = em;
17 | this.sender = sender;
18 | this.opt = options || {};
19 | this.$wr = this.$wrapper;
20 | this.enable();
21 | },
22 |
23 | enable(...args) {
24 | CreateComponent.enable.apply(this, args);
25 | this.$wr.on('click', this.insertComponent);
26 | },
27 |
28 | /**
29 | * Start insert event
30 | * @private
31 | * */
32 | insertComponent() {
33 | this.$wr.off('click', this.insertComponent);
34 | this.stopSelectPosition();
35 | var object = this.buildContent();
36 | this.beforeInsert(object);
37 | var index = this.sorter.lastPos.index;
38 | // By default, collections do not trigger add event, so silent is used
39 | var model = this.create(this.sorter.target, object, index, null, {
40 | silent: false
41 | });
42 |
43 | if (this.opt.terminateAfterInsert && this.sender)
44 | this.sender.set('active', false);
45 | else this.enable();
46 |
47 | if (!model) return;
48 |
49 | this.afterInsert(model, this);
50 | },
51 |
52 | /**
53 | * Trigger before insert
54 | * @param {Object} obj
55 | * @private
56 | * */
57 | beforeInsert(obj) {},
58 |
59 | /**
60 | * Trigger after insert
61 | * @param {Object} model Model created after insert
62 | * @private
63 | * */
64 | afterInsert(model) {},
65 |
66 | /**
67 | * Create different object, based on content, to insert inside canvas
68 | *
69 | * @return {Object}
70 | * @private
71 | * */
72 | buildContent() {
73 | return this.opt.content || {};
74 | }
75 | });
76 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/OpenAssets.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | run(editor, sender, opts = {}) {
3 | const modal = editor.Modal;
4 | const am = editor.AssetManager;
5 | const config = am.getConfig();
6 | const amContainer = am.getContainer();
7 | const title = opts.modalTitle || config.modalTitle || '';
8 | const types = opts.types;
9 | const accept = opts.accept;
10 |
11 | am.setTarget(opts.target);
12 | am.onClick(opts.onClick);
13 | am.onDblClick(opts.onDblClick);
14 | am.onSelect(opts.onSelect);
15 |
16 | if (!this.rendered || types) {
17 | let assets = am.getAll();
18 |
19 | if (types) {
20 | assets = assets.filter(a => types.indexOf(a.get('type')) !== -1);
21 | }
22 |
23 | am.render(assets);
24 | this.rendered = 1;
25 | }
26 |
27 | if (accept) {
28 | const uploadEl = amContainer.querySelector(
29 | `input#${config.stylePrefix}uploadFile`
30 | );
31 | uploadEl && uploadEl.setAttribute('accept', accept);
32 | }
33 |
34 | modal.setTitle(title);
35 | modal.setContent(amContainer);
36 | modal.open();
37 | }
38 | };
39 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/OpenBlocks.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | run(editor, sender) {
3 | const bm = editor.BlockManager;
4 | const pn = editor.Panels;
5 |
6 | if (!this.blocks) {
7 | bm.render();
8 | const id = 'views-container';
9 | const blocks = document.createElement('div');
10 | const panels = pn.getPanel(id) || pn.addPanel({ id });
11 | blocks.appendChild(bm.getContainer());
12 | panels.set('appendContent', blocks).trigger('change:appendContent');
13 | this.blocks = blocks;
14 | }
15 |
16 | this.blocks.style.display = 'block';
17 | },
18 |
19 | stop() {
20 | const blocks = this.blocks;
21 | blocks && (blocks.style.display = 'none');
22 | }
23 | };
24 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/OpenLayers.js:
--------------------------------------------------------------------------------
1 | const Layers = require('navigator');
2 | const $ = Backbone.$;
3 |
4 | module.exports = {
5 | run(editor) {
6 | const lm = editor.LayerManager;
7 | const pn = editor.Panels;
8 |
9 | if (!this.layers) {
10 | const id = 'views-container';
11 | const layers = document.createElement('div');
12 | const panels = pn.getPanel(id) || pn.addPanel({ id });
13 | layers.appendChild(lm.render());
14 | panels.set('appendContent', layers).trigger('change:appendContent');
15 | this.layers = layers;
16 | }
17 |
18 | this.layers.style.display = 'block';
19 | },
20 |
21 | stop() {
22 | const layers = this.layers;
23 | layers && (layers.style.display = 'none');
24 | }
25 | };
26 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/OpenStyleManager.js:
--------------------------------------------------------------------------------
1 | const StyleManager = require('style_manager');
2 | const Backbone = require('backbone');
3 | const $ = Backbone.$;
4 |
5 | module.exports = {
6 | run(em, sender) {
7 | this.sender = sender;
8 | if (!this.$cn) {
9 | var config = em.getConfig(),
10 | panels = em.Panels;
11 | // Main container
12 | this.$cn = $('');
13 | // Secondary container
14 | this.$cn2 = $('');
15 | this.$cn.append(this.$cn2);
16 |
17 | // Device Manager
18 | var dvm = em.DeviceManager;
19 | if (dvm && config.showDevices) {
20 | var devicePanel = panels.addPanel({ id: 'devices-c' });
21 | devicePanel
22 | .set('appendContent', dvm.render())
23 | .trigger('change:appendContent');
24 | }
25 |
26 | // Class Manager container
27 | var clm = em.SelectorManager;
28 | if (clm) this.$cn2.append(clm.render([]));
29 |
30 | this.$cn2.append(em.StyleManager.render());
31 | var smConfig = em.StyleManager.getConfig();
32 | const pfx = smConfig.stylePrefix;
33 | // Create header
34 | this.$header = $(
35 | ``
36 | );
37 | this.$cn.append(this.$header);
38 |
39 | // Create panel if not exists
40 | if (!panels.getPanel('views-container'))
41 | this.panel = panels.addPanel({ id: 'views-container' });
42 | else this.panel = panels.getPanel('views-container');
43 |
44 | // Add all containers to the panel
45 | this.panel.set('appendContent', this.$cn).trigger('change:appendContent');
46 |
47 | this.target = em.editor;
48 | this.listenTo(this.target, 'change:selectedComponent', this.toggleSm);
49 | }
50 | this.toggleSm();
51 | },
52 |
53 | /**
54 | * Toggle Style Manager visibility
55 | * @private
56 | */
57 | toggleSm() {
58 | const sender = this.sender;
59 | if (sender && sender.get && !sender.get('active')) return;
60 |
61 | if (this.target.get('selectedComponent')) {
62 | this.$cn2.show();
63 | this.$header.hide();
64 | } else {
65 | this.$cn2.hide();
66 | this.$header.show();
67 | }
68 | },
69 |
70 | stop() {
71 | // Hide secondary container if exists
72 | if (this.$cn2) this.$cn2.hide();
73 |
74 | // Hide header container if exists
75 | if (this.$header) this.$header.hide();
76 | }
77 | };
78 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/OpenTraitManager.js:
--------------------------------------------------------------------------------
1 | const $ = require('backbone').$;
2 |
3 | module.exports = {
4 | run(editor, sender) {
5 | this.sender = sender;
6 |
7 | var config = editor.Config;
8 | var pfx = config.stylePrefix;
9 | var tm = editor.TraitManager;
10 | var panelC;
11 |
12 | if (!this.$cn) {
13 | var tmView = tm.getTraitsViewer();
14 | var confTm = tm.getConfig();
15 | this.$cn = $('');
16 | this.$cn2 = $('');
17 | this.$cn.append(this.$cn2);
18 | this.$header = $('').append(
19 | ``
20 | );
21 | this.$cn.append(this.$header);
22 | this.$cn2.append(
23 | `
${confTm.labelContainer}
`
24 | );
25 | this.$cn2.append(tmView.render().el);
26 | var panels = editor.Panels;
27 |
28 | if (!panels.getPanel('views-container'))
29 | panelC = panels.addPanel({ id: 'views-container' });
30 | else panelC = panels.getPanel('views-container');
31 |
32 | panelC
33 | .set('appendContent', this.$cn.get(0))
34 | .trigger('change:appendContent');
35 |
36 | this.target = editor.getModel();
37 | this.listenTo(this.target, 'change:selectedComponent', this.toggleTm);
38 | }
39 |
40 | this.toggleTm();
41 | },
42 |
43 | /**
44 | * Toggle Trait Manager visibility
45 | * @private
46 | */
47 | toggleTm() {
48 | const sender = this.sender;
49 | if (sender && sender.get && !sender.get('active')) return;
50 |
51 | if (this.target.get('selectedComponent')) {
52 | this.$cn2.show();
53 | this.$header.hide();
54 | } else {
55 | this.$cn2.hide();
56 | this.$header.show();
57 | }
58 | },
59 |
60 | stop() {
61 | this.$cn2 && this.$cn2.hide();
62 | this.$header && this.$header.hide();
63 | }
64 | };
65 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/Preview.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | getPanels(editor) {
3 | if (!this.panels) this.panels = editor.Panels.getPanelsEl();
4 | return this.panels;
5 | },
6 |
7 | tglPointers(editor, v) {
8 | var elP = editor.Canvas.getBody().querySelectorAll(
9 | '.' + this.ppfx + 'no-pointer'
10 | );
11 | _.each(elP, item => {
12 | item.style.pointerEvents = v ? '' : 'all';
13 | });
14 | },
15 |
16 | run(editor, sender) {
17 | if (sender && sender.set) sender.set('active', false);
18 | editor.stopCommand('sw-visibility');
19 | editor.getModel().stopDefault();
20 | var that = this;
21 | var panels = this.getPanels(editor);
22 | var canvas = editor.Canvas.getElement();
23 | var editorEl = editor.getEl();
24 | var pfx = editor.Config.stylePrefix;
25 | if (!this.helper) {
26 | this.helper = document.createElement('span');
27 | this.helper.className = pfx + 'off-prv fa fa-eye-slash';
28 | editorEl.appendChild(this.helper);
29 | this.helper.onclick = () => {
30 | editor.stopCommand('preview');
31 | };
32 | }
33 | this.helper.style.display = 'inline-block';
34 | this.tglPointers(editor);
35 |
36 | /*
37 | editor.Canvas.getBody().querySelectorAll('.' + pfx + 'no-pointer').forEach(function(){
38 | this.style.pointerEvents = 'all';
39 | });*/
40 |
41 | panels.style.display = 'none';
42 | var canvasS = canvas.style;
43 | canvasS.width = '100%';
44 | canvasS.height = '100%';
45 | canvasS.top = '0';
46 | canvasS.left = '0';
47 | canvasS.padding = '0';
48 | canvasS.margin = '0';
49 | editor.trigger('change:canvasOffset');
50 | },
51 |
52 | stop(editor, sender) {
53 | var panels = this.getPanels(editor);
54 | editor.runCommand('sw-visibility');
55 | editor.getModel().runDefault();
56 | panels.style.display = 'block';
57 | var canvas = editor.Canvas.getElement();
58 | canvas.setAttribute('style', '');
59 | if (this.helper) {
60 | this.helper.style.display = 'none';
61 | }
62 | editor.trigger('change:canvasOffset');
63 | this.tglPointers(editor, 1);
64 | }
65 | };
66 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/Resize.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | run(editor, sender, opts) {
3 | var opt = opts || {};
4 | var el = opt.el || '';
5 | var canvas = editor.Canvas;
6 | var canvasResizer = this.canvasResizer;
7 | var options = opt.options || {};
8 | var canvasView = canvas.getCanvasView();
9 | options.ratioDefault = 1;
10 | options.appendTo = canvas.getResizerEl();
11 | options.prefix = editor.getConfig().stylePrefix;
12 | options.posFetcher = canvasView.getElementPos.bind(canvasView);
13 | options.mousePosFetcher = canvas.getMouseRelativePos;
14 |
15 | // Create the resizer for the canvas if not yet created
16 | if (!canvasResizer || opt.forceNew) {
17 | this.canvasResizer = editor.Utils.Resizer.init(options);
18 | canvasResizer = this.canvasResizer;
19 | }
20 |
21 | canvasResizer.setOptions(options);
22 | canvasResizer.blur();
23 | canvasResizer.focus(el);
24 | return canvasResizer;
25 | },
26 |
27 | stop() {
28 | const resizer = this.canvasResizer;
29 | resizer && resizer.blur();
30 | }
31 | };
32 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/SelectParent.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | run(editor) {
3 | const sel = editor.getSelected();
4 | let comp = sel && sel.parent();
5 |
6 | // Recurse through the parent() chain until a selectable parent is found
7 | while (comp && !comp.get('selectable')) {
8 | comp = comp.parent();
9 | }
10 |
11 | comp && editor.select(comp);
12 | }
13 | };
14 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/SwitchVisibility.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | run(ed) {
3 | ed.Canvas.getBody().className = this.ppfx + 'dashed';
4 | },
5 |
6 | stop(ed) {
7 | ed.Canvas.getBody().className = '';
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/grapesjs/src/commands/view/TextComponent.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var CreateComponent = require('./CreateComponent');
3 |
4 | module.exports = _.extend({}, CreateComponent, {
5 | /**
6 | * This event is triggered at the beginning of a draw operation
7 | * @param {Object} component Object component before creation
8 | * @private
9 | * */
10 | beforeDraw(component) {
11 | component.type = 'text';
12 | if (!component.style) component.style = {};
13 | component.style.padding = '10px';
14 | },
15 |
16 | /**
17 | * This event is triggered at the end of a draw operation
18 | * @param {Object} model Component model created
19 | * @private
20 | * */
21 | afterDraw(model) {
22 | if (!model || !model.set) return;
23 | model.trigger('focus');
24 | if (this.sender) this.sender.set('active', false);
25 | }
26 | });
27 |
--------------------------------------------------------------------------------
/grapesjs/src/css_composer/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // Style prefix
3 | stylePrefix: 'css-',
4 |
5 | // Custom CSS string to render on top
6 | staticRules: '',
7 |
8 | // Default CSS style
9 | rules: []
10 | };
11 |
--------------------------------------------------------------------------------
/grapesjs/src/css_composer/model/CssRules.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var CssRule = require('./CssRule');
3 |
4 | module.exports = Backbone.Collection.extend({
5 | initialize(models, opt) {
6 | // Inject editor
7 | if (opt && opt.em) this.editor = opt.em;
8 |
9 | // Not used
10 | this.model = (attrs, options) => {
11 | var model;
12 |
13 | if (!options.em && opt && opt.em) options.em = opt.em;
14 |
15 | switch (1) {
16 | default:
17 | model = new CssRule(attrs, options);
18 | }
19 |
20 | return model;
21 | };
22 | },
23 |
24 | add(models, opt = {}) {
25 | if (typeof models === 'string') {
26 | models = this.editor.get('Parser').parseCss(models);
27 | }
28 | opt.em = this.editor;
29 | return Backbone.Collection.prototype.add.apply(this, [models, opt]);
30 | }
31 | });
32 |
--------------------------------------------------------------------------------
/grapesjs/src/css_composer/view/CssGroupRuleView.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./CssRuleView').extend({
2 | _createElement: function(tagName) {
3 | return document.createTextNode('');
4 | },
5 |
6 | render() {
7 | const model = this.model;
8 | const important = model.get('important');
9 | this.el.textContent = model.getDeclaration({ important });
10 | return this;
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/grapesjs/src/css_composer/view/CssRuleView.js:
--------------------------------------------------------------------------------
1 | module.exports = require('backbone').View.extend({
2 | tagName: 'style',
3 |
4 | initialize(o = {}) {
5 | this.config = o.config || {};
6 | const model = this.model;
7 | const toTrack = 'change:style change:state change:mediaText';
8 | this.listenTo(model, toTrack, this.render);
9 | this.listenTo(model, 'destroy remove', this.remove);
10 | this.listenTo(model.get('selectors'), 'change', this.render);
11 | },
12 |
13 | render() {
14 | const model = this.model;
15 | const important = model.get('important');
16 | this.el.innerHTML = this.model.toCSS({ important });
17 | return this;
18 | }
19 | });
20 |
--------------------------------------------------------------------------------
/grapesjs/src/device_manager/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devices: [],
3 |
4 | deviceLabel: 'Device'
5 | };
6 |
--------------------------------------------------------------------------------
/grapesjs/src/device_manager/model/Device.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | idAttribute: 'name',
5 |
6 | defaults: {
7 | name: '',
8 |
9 | // Width to set for the editor iframe
10 | width: '',
11 |
12 | // Height to set for the editor iframe
13 | height: '',
14 |
15 | // The width which will be used in media queries,
16 | // If empty the width will be used
17 | widthMedia: null
18 | },
19 |
20 | initialize() {
21 | if (this.get('widthMedia') == null) {
22 | this.set('widthMedia', this.get('width'));
23 | }
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/grapesjs/src/device_manager/model/Devices.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var Device = require('./Device');
3 |
4 | module.exports = Backbone.Collection.extend({
5 | model: Device
6 | });
7 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stylePrefix: 'comp-',
3 |
4 | wrapperId: 'wrapper',
5 |
6 | wrapperName: 'Body',
7 |
8 | // Default wrapper configuration
9 | wrapper: {
10 | removable: false,
11 | copyable: false,
12 | draggable: false,
13 | components: [],
14 | traits: [],
15 | stylable: [
16 | 'background',
17 | 'background-color',
18 | 'background-image',
19 | 'background-repeat',
20 | 'background-attachment',
21 | 'background-position',
22 | 'background-size'
23 | ]
24 | },
25 |
26 | // Could be used for default components
27 | components: [],
28 |
29 | // Class for new image component
30 | imageCompClass: 'fa fa-picture-o',
31 |
32 | // Open assets manager on create of image component
33 | oAssetsOnCreate: true,
34 |
35 | // TODO to remove
36 | // Editor should also store the wrapper informations, but as this change might
37 | // break stuff I set ii as an opt-in option, for now.
38 | storeWrapper: 0,
39 |
40 | // List of void elements
41 | voidElements: [
42 | 'area',
43 | 'base',
44 | 'br',
45 | 'col',
46 | 'embed',
47 | 'hr',
48 | 'img',
49 | 'input',
50 | 'keygen',
51 | 'link',
52 | 'menuitem',
53 | 'meta',
54 | 'param',
55 | 'source',
56 | 'track',
57 | 'wbr'
58 | ]
59 | };
60 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentLink.js:
--------------------------------------------------------------------------------
1 | const Component = require('./ComponentText');
2 |
3 | module.exports = Component.extend(
4 | {
5 | defaults: {
6 | ...Component.prototype.defaults,
7 | type: 'link',
8 | tagName: 'a',
9 | traits: ['title', 'href', 'target']
10 | },
11 |
12 | /**
13 | * Returns object of attributes for HTML
14 | * @return {Object}
15 | * @private
16 | */
17 | getAttrToHTML(...args) {
18 | const attr = Component.prototype.getAttrToHTML.apply(this, args);
19 | delete attr.onmousedown;
20 | return attr;
21 | }
22 | },
23 | {
24 | isComponent(el) {
25 | let result;
26 | let avoidEdit;
27 |
28 | if (el.tagName == 'A') {
29 | result = {
30 | type: 'link',
31 | editable: 0
32 | };
33 |
34 | // The link is editable only if, at least, one of its
35 | // children is a text node (not empty one)
36 | const children = el.childNodes;
37 | const len = children.length;
38 | if (!len) delete result.editable;
39 |
40 | for (let i = 0; i < len; i++) {
41 | const child = children[i];
42 |
43 | if (child.nodeType == 3 && child.textContent.trim() != '') {
44 | delete result.editable;
45 | break;
46 | }
47 | }
48 | }
49 |
50 | return result;
51 | }
52 | }
53 | );
54 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentScript.js:
--------------------------------------------------------------------------------
1 | var Component = require('./Component');
2 |
3 | module.exports = Component.extend(
4 | {
5 | defaults: _.extend({}, Component.prototype.defaults, {
6 | type: 'script',
7 | droppable: false,
8 | draggable: false,
9 | layerable: false
10 | })
11 | },
12 | {
13 | isComponent(el) {
14 | if (el.tagName == 'SCRIPT') {
15 | var result = { type: 'script' };
16 |
17 | if (el.src) {
18 | result.src = el.src;
19 | result.onload = el.onload;
20 | }
21 |
22 | return result;
23 | }
24 | }
25 | }
26 | );
27 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentSvg.js:
--------------------------------------------------------------------------------
1 | var Component = require('./Component');
2 |
3 | module.exports = Component.extend(
4 | {
5 | defaults: {
6 | ...Component.prototype.defaults,
7 | highlightable: 0
8 | },
9 |
10 | getName() {
11 | let name = this.get('tagName');
12 | let customName = this.get('custom-name');
13 | name = name.charAt(0).toUpperCase() + name.slice(1);
14 | return customName || name;
15 | }
16 | },
17 | {
18 | isComponent(el) {
19 | if (SVGElement && el instanceof SVGElement) {
20 | // Some SVG elements require uppercase letters (eg.
)
21 | const tagName = el.tagName;
22 | // Make the root resizable
23 | const resizable = tagName == 'svg' ? true : false;
24 |
25 | return {
26 | tagName,
27 | type: 'svg',
28 | resizable
29 | };
30 | }
31 | }
32 | }
33 | );
34 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentTable.js:
--------------------------------------------------------------------------------
1 | const Component = require('./Component');
2 |
3 | module.exports = Component.extend(
4 | {
5 | defaults: {
6 | ...Component.prototype.defaults,
7 | type: 'table',
8 | tagName: 'table',
9 | droppable: ['tbody', 'thead', 'tfoot']
10 | },
11 |
12 | initialize(o, opt) {
13 | Component.prototype.initialize.apply(this, arguments);
14 | const components = this.get('components');
15 | !components.length && components.add({ type: 'tbody' });
16 | }
17 | },
18 | {
19 | isComponent(el) {
20 | let result = '';
21 |
22 | if (el.tagName == 'TABLE') {
23 | result = { type: 'table' };
24 | }
25 |
26 | return result;
27 | }
28 | }
29 | );
30 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentTableBody.js:
--------------------------------------------------------------------------------
1 | const Component = require('./Component');
2 |
3 | module.exports = Component.extend(
4 | {
5 | defaults: {
6 | ...Component.prototype.defaults,
7 | type: 'tbody',
8 | tagName: 'tbody',
9 | draggable: ['table'],
10 | droppable: ['tr'],
11 | columns: 1,
12 | rows: 1
13 | },
14 |
15 | initialize(o, opt) {
16 | Component.prototype.initialize.apply(this, arguments);
17 | const components = this.get('components');
18 | let columns = this.get('columns');
19 | let rows = this.get('rows');
20 |
21 | // Init components if empty
22 | if (!components.length) {
23 | const rowsToAdd = [];
24 |
25 | while (rows--) {
26 | const columnsToAdd = [];
27 | let clm = columns;
28 |
29 | while (clm--) {
30 | columnsToAdd.push({
31 | type: 'cell',
32 | classes: ['cell']
33 | });
34 | }
35 |
36 | rowsToAdd.push({
37 | type: 'row',
38 | classes: ['row'],
39 | components: columnsToAdd
40 | });
41 | }
42 |
43 | components.add(rowsToAdd);
44 | }
45 | }
46 | },
47 | {
48 | isComponent(el) {
49 | let result = '';
50 |
51 | if (el.tagName == 'TBODY') {
52 | result = { type: 'tbody' };
53 | }
54 |
55 | return result;
56 | }
57 | }
58 | );
59 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentTableCell.js:
--------------------------------------------------------------------------------
1 | const Component = require('./Component');
2 |
3 | module.exports = Component.extend(
4 | {
5 | defaults: {
6 | ...Component.prototype.defaults,
7 | type: 'cell',
8 | tagName: 'td',
9 | draggable: ['tr']
10 | }
11 | },
12 | {
13 | isComponent(el) {
14 | let result = '';
15 | const tag = el.tagName;
16 |
17 | if (tag == 'TD' || tag == 'TH') {
18 | result = {
19 | type: 'cell',
20 | tagName: tag.toLowerCase()
21 | };
22 | }
23 |
24 | return result;
25 | }
26 | }
27 | );
28 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentTableFoot.js:
--------------------------------------------------------------------------------
1 | const ComponentTableBody = require('./ComponentTableBody');
2 |
3 | module.exports = ComponentTableBody.extend(
4 | {
5 | defaults: {
6 | ...ComponentTableBody.prototype.defaults,
7 | type: 'tfoot',
8 | tagName: 'tfoot'
9 | }
10 | },
11 | {
12 | isComponent(el) {
13 | let result = '';
14 |
15 | if (el.tagName == 'TFOOT') {
16 | result = { type: 'tfoot' };
17 | }
18 |
19 | return result;
20 | }
21 | }
22 | );
23 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentTableHead.js:
--------------------------------------------------------------------------------
1 | const ComponentTableBody = require('./ComponentTableBody');
2 |
3 | module.exports = ComponentTableBody.extend(
4 | {
5 | defaults: {
6 | ...ComponentTableBody.prototype.defaults,
7 | type: 'thead',
8 | tagName: 'thead'
9 | }
10 | },
11 | {
12 | isComponent(el) {
13 | let result = '';
14 |
15 | if (el.tagName == 'THEAD') {
16 | result = { type: 'thead' };
17 | }
18 |
19 | return result;
20 | }
21 | }
22 | );
23 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentTableRow.js:
--------------------------------------------------------------------------------
1 | const Component = require('./Component');
2 |
3 | module.exports = Component.extend(
4 | {
5 | defaults: {
6 | ...Component.prototype.defaults,
7 | type: 'row',
8 | tagName: 'tr',
9 | draggable: ['thead', 'tbody', 'tfoot'],
10 | droppable: ['th', 'td']
11 | },
12 |
13 | initialize(o, opt) {
14 | Component.prototype.initialize.apply(this, arguments);
15 |
16 | // Clean the row from non cell components
17 | const cells = [];
18 | const components = this.get('components');
19 | components.each(model => model.is('cell') && cells.push(model));
20 | components.reset(cells);
21 | }
22 | },
23 | {
24 | isComponent(el) {
25 | let result = '';
26 |
27 | if (el.tagName == 'TR') {
28 | result = { type: 'row' };
29 | }
30 |
31 | return result;
32 | }
33 | }
34 | );
35 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentText.js:
--------------------------------------------------------------------------------
1 | const Component = require('./Component');
2 |
3 | module.exports = Component.extend({
4 | defaults: {
5 | ...Component.prototype.defaults,
6 | type: 'text',
7 | droppable: false,
8 | editable: true
9 | }
10 | });
11 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ComponentTextNode.js:
--------------------------------------------------------------------------------
1 | var Component = require('./Component');
2 |
3 | module.exports = Component.extend(
4 | {
5 | defaults: _.extend({}, Component.prototype.defaults, {
6 | droppable: false,
7 | editable: true
8 | }),
9 |
10 | toHTML() {
11 | return this.get('content');
12 | }
13 | },
14 | {
15 | isComponent(el) {
16 | var result = '';
17 | if (el.nodeType === 3) {
18 | result = {
19 | type: 'textnode',
20 | content: el.textContent
21 | };
22 | }
23 | return result;
24 | }
25 | }
26 | );
27 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/Components.js:
--------------------------------------------------------------------------------
1 | import { isEmpty } from 'underscore';
2 |
3 | const Backbone = require('backbone');
4 |
5 | module.exports = Backbone.Collection.extend({
6 | initialize(models, opt = {}) {
7 | this.listenTo(this, 'add', this.onAdd);
8 | this.config = opt.config;
9 | this.em = opt.em;
10 |
11 | this.model = (attrs, options) => {
12 | var model;
13 | var df = opt.componentTypes;
14 | options.em = opt.em;
15 | options.config = opt.config;
16 | options.componentTypes = df;
17 |
18 | for (var it = 0; it < df.length; it++) {
19 | var dfId = df[it].id;
20 | if (dfId == attrs.type) {
21 | model = df[it].model;
22 | break;
23 | }
24 | }
25 |
26 | if (!model) {
27 | // get the last one
28 | model = df[df.length - 1].model;
29 | }
30 |
31 | return new model(attrs, options);
32 | };
33 | },
34 |
35 | add(models, opt = {}) {
36 | if (typeof models === 'string') {
37 | const cssc = this.em.get('CssComposer');
38 | const parsed = this.em.get('Parser').parseHtml(models);
39 | models = parsed.html;
40 |
41 | if (parsed.css && cssc) {
42 | const { avoidUpdateStyle } = opt;
43 | const added = cssc.addCollection(parsed.css, {
44 | extend: 1,
45 | avoidUpdateStyle
46 | });
47 | }
48 | }
49 |
50 | return Backbone.Collection.prototype.add.apply(this, [models, opt]);
51 | },
52 |
53 | onAdd(model, c, opts) {
54 | const em = this.em;
55 | const style = model.getStyle();
56 | const avoidInline = em && em.getConfig('avoidInlineStyle');
57 |
58 | if (
59 | !isEmpty(style) &&
60 | !avoidInline &&
61 | em &&
62 | em.get &&
63 | em.getConfig('forceClass')
64 | ) {
65 | const name = model.cid;
66 | const rule = em.get('CssComposer').setClassRule(name, style);
67 | model.setStyle({});
68 | model.addClass(name);
69 | }
70 | }
71 | });
72 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/Toolbar.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ToolbarButton = require('./ToolbarButton');
3 |
4 | module.exports = Backbone.Collection.extend({ model: ToolbarButton });
5 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/model/ToolbarButton.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | defaults: {
5 | command: '',
6 | attributes: {}
7 | }
8 | });
9 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentLinkView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentTextView');
3 |
4 | module.exports = ComponentView.extend({
5 | render(...args) {
6 | ComponentView.prototype.render.apply(this, args);
7 |
8 | // I need capturing instead of bubbling as bubbled clicks from other
9 | // children will execute the link event
10 | this.el.addEventListener('click', this.prevDef, true);
11 |
12 | return this;
13 | }
14 | });
15 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentMapView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentImageView');
3 |
4 | module.exports = ComponentView.extend({
5 | tagName: 'div',
6 |
7 | events: {},
8 |
9 | initialize(o) {
10 | ComponentView.prototype.initialize.apply(this, arguments);
11 | this.classEmpty = this.ppfx + 'plh-map';
12 | },
13 |
14 | /**
15 | * Update the map on the canvas
16 | * @private
17 | */
18 | updateSrc() {
19 | this.getIframe().src = this.model.get('src');
20 | },
21 |
22 | getIframe() {
23 | if (!this.iframe) {
24 | var ifrm = document.createElement('iframe');
25 | ifrm.src = this.model.get('src');
26 | ifrm.frameBorder = 0;
27 | ifrm.style.height = '100%';
28 | ifrm.style.width = '100%';
29 | ifrm.className = this.ppfx + 'no-pointer';
30 | this.iframe = ifrm;
31 | }
32 | return this.iframe;
33 | },
34 |
35 | render(...args) {
36 | ComponentView.prototype.render.apply(this, args);
37 | this.updateClasses();
38 | this.el.appendChild(this.getIframe());
39 | return this;
40 | }
41 | });
42 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentScriptView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentImageView');
3 |
4 | module.exports = ComponentView.extend({
5 | tagName: 'script',
6 |
7 | events: {},
8 |
9 | render() {
10 | var model = this.model;
11 | var src = model.get('src');
12 | var em = this.em;
13 | var scriptCount = em && em.get('scriptCount') ? em.get('scriptCount') : 0;
14 | var content = '';
15 |
16 | // If it's an external script
17 | if (src) {
18 | var onload = model.get('onload');
19 | var svar = 'script' + scriptCount;
20 | var svarNext = 'script' + (scriptCount + 1);
21 | content =
22 | 'var ' +
23 | svar +
24 | " = document.createElement('script');\n" +
25 | svar +
26 | '.onload = function(){\n' +
27 | (onload ? onload + '();\n' : '') +
28 | 'typeof ' +
29 | svarNext +
30 | "Start == 'function' && " +
31 | svarNext +
32 | 'Start();\n' +
33 | '};\n' +
34 | svar +
35 | ".src = '" +
36 | src +
37 | "';\n" +
38 | 'function ' +
39 | svar +
40 | 'Start() { document.body.appendChild(' +
41 | svar +
42 | '); };\n' +
43 | (!scriptCount ? svar + 'Start();' : '');
44 | if (em) {
45 | em.set('scriptCount', scriptCount + 1);
46 | }
47 | } else {
48 | content = model.get('content');
49 | }
50 |
51 | this.el.innerHTML = content;
52 | return this;
53 | }
54 | });
55 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentSvgView.js:
--------------------------------------------------------------------------------
1 | const ComponentView = require('./ComponentView');
2 |
3 | module.exports = ComponentView.extend({
4 | _createElement: function(tagName) {
5 | return document.createElementNS('http://www.w3.org/2000/svg', tagName);
6 | }
7 | });
8 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentTableBodyView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentView');
3 |
4 | module.exports = ComponentView.extend({});
5 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentTableCellView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentView');
3 |
4 | module.exports = ComponentView.extend({});
5 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentTableFootView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentView');
3 |
4 | module.exports = ComponentView.extend({});
5 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentTableHeadView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentView');
3 |
4 | module.exports = ComponentView.extend({});
5 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentTableRowView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentView');
3 |
4 | module.exports = ComponentView.extend({});
5 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentTableView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ComponentView = require('./ComponentView');
3 |
4 | module.exports = ComponentView.extend({
5 | events: {}
6 | });
7 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ComponentTextNodeView.js:
--------------------------------------------------------------------------------
1 | module.exports = require('backbone').View.extend({});
2 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ToolbarButtonView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.View.extend({
4 | events() {
5 | return (
6 | this.model.get('events') || {
7 | mousedown: 'handleClick'
8 | }
9 | );
10 | },
11 |
12 | attributes() {
13 | return this.model.get('attributes');
14 | },
15 |
16 | initialize(opts) {
17 | this.editor = opts.config.editor;
18 | },
19 |
20 | handleClick(event) {
21 | event.preventDefault();
22 | event.stopPropagation();
23 | this.execCommand(event);
24 | },
25 |
26 | execCommand(event) {
27 | const opts = { event };
28 | const command = this.model.get('command');
29 | const editor = this.editor;
30 |
31 | if (typeof command === 'function') {
32 | command(editor, null, opts);
33 | }
34 |
35 | if (typeof command === 'string') {
36 | editor.runCommand(command, opts);
37 | }
38 | },
39 |
40 | render() {
41 | var config = this.editor.getConfig();
42 | this.el.className += ' ' + config.stylePrefix + 'toolbar-item';
43 | return this;
44 | }
45 | });
46 |
--------------------------------------------------------------------------------
/grapesjs/src/dom_components/view/ToolbarView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var DomainViews = require('domain_abstract/view/DomainViews');
3 | var ToolbarButtonView = require('./ToolbarButtonView');
4 |
5 | module.exports = DomainViews.extend({
6 | itemView: ToolbarButtonView,
7 |
8 | initialize(opts) {
9 | this.config = { editor: opts.editor || '' };
10 | this.listenTo(this.collection, 'reset', this.render);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/grapesjs/src/domain_abstract/ui/Input.js:
--------------------------------------------------------------------------------
1 | const $ = Backbone.$;
2 |
3 | module.exports = Backbone.View.extend({
4 | events: {
5 | change: 'handleChange'
6 | },
7 |
8 | template() {
9 | return ``;
10 | },
11 |
12 | inputClass() {
13 | return `${this.ppfx}field`;
14 | },
15 |
16 | holderClass() {
17 | return `${this.ppfx}input-holder`;
18 | },
19 |
20 | initialize(opts = {}) {
21 | const ppfx = opts.ppfx || '';
22 | this.opts = opts;
23 | this.ppfx = ppfx;
24 | this.em = opts.target || {};
25 | this.listenTo(this.model, 'change:value', this.handleModelChange);
26 | },
27 |
28 | /**
29 | * Fired when the element of the property is updated
30 | */
31 | elementUpdated() {
32 | this.model.trigger('el:change');
33 | },
34 |
35 | /**
36 | * Set value to the input element
37 | * @param {string} value
38 | */
39 | setValue(value) {
40 | const model = this.model;
41 | let val = value || model.get('defaults');
42 | const input = this.getInputEl();
43 | input && (input.value = val);
44 | },
45 |
46 | /**
47 | * Updates the view when the model is changed
48 | * */
49 | handleModelChange(model, value, opts) {
50 | this.setValue(value, opts);
51 | },
52 |
53 | /**
54 | * Handled when the view is changed
55 | */
56 | handleChange(e) {
57 | e.stopPropagation();
58 | this.model.set('value', this.getInputEl().value);
59 | this.elementUpdated();
60 | },
61 |
62 | /**
63 | * Get the input element
64 | * @return {HTMLElement}
65 | */
66 | getInputEl() {
67 | if (!this.inputEl) {
68 | const plh = this.model.get('defaults');
69 | this.inputEl = $(``);
70 | }
71 |
72 | return this.inputEl.get(0);
73 | },
74 |
75 | render() {
76 | const el = this.$el;
77 | el.addClass(this.inputClass());
78 | el.html(this.template());
79 | el.find(`.${this.holderClass()}`).append(this.getInputEl());
80 | return this;
81 | }
82 | });
83 |
--------------------------------------------------------------------------------
/grapesjs/src/domain_abstract/view/DomainViews.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.View.extend({
4 | // Default view
5 | itemView: '',
6 |
7 | // Defines the View per type
8 | itemsView: '',
9 |
10 | itemType: 'type',
11 |
12 | initialize(opts, config) {
13 | this.config = config || {};
14 | },
15 |
16 | /**
17 | * Add new model to the collection
18 | * @param {Model} model
19 | * @private
20 | * */
21 | addTo(model) {
22 | this.add(model);
23 | },
24 |
25 | /**
26 | * Render new model inside the view
27 | * @param {Model} model
28 | * @param {Object} fragment Fragment collection
29 | * @private
30 | * */
31 | add(model, fragment) {
32 | var frag = fragment || null;
33 | var itemView = this.itemView;
34 | var typeField = model.get(this.itemType);
35 | if (this.itemsView && this.itemsView[typeField]) {
36 | itemView = this.itemsView[typeField];
37 | }
38 | var view = new itemView(
39 | {
40 | model,
41 | config: this.config
42 | },
43 | this.config
44 | );
45 | var rendered = view.render().el;
46 |
47 | if (frag) frag.appendChild(rendered);
48 | else this.$el.append(rendered);
49 | },
50 |
51 | render() {
52 | var frag = document.createDocumentFragment();
53 | this.$el.empty();
54 |
55 | if (this.collection.length)
56 | this.collection.each(function(model) {
57 | this.add(model, frag);
58 | }, this);
59 |
60 | this.$el.append(frag);
61 | return this;
62 | }
63 | });
64 |
--------------------------------------------------------------------------------
/grapesjs/src/editor/view/EditorView.js:
--------------------------------------------------------------------------------
1 | const $ = Backbone.$;
2 |
3 | module.exports = Backbone.View.extend({
4 | initialize() {
5 | const model = this.model;
6 | model.view = this;
7 | this.conf = model.config;
8 | this.pn = model.get('Panels');
9 | model.on('loaded', () => {
10 | this.pn.active();
11 | this.pn.disableButtons();
12 | model.runDefault();
13 | setTimeout(() => model.trigger('load'), 0);
14 | });
15 | },
16 |
17 | render() {
18 | const model = this.model;
19 | const el = this.$el;
20 | const conf = this.conf;
21 | const contEl = $(conf.el || `body ${conf.container}`);
22 | const pfx = conf.stylePrefix;
23 | el.empty();
24 |
25 | if (conf.width) contEl.css('width', conf.width);
26 |
27 | if (conf.height) contEl.css('height', conf.height);
28 |
29 | el.append(model.get('Canvas').render());
30 | el.append(this.pn.render());
31 | el.attr('class', `${pfx}editor ${pfx}one-bg ${pfx}two-color`);
32 | contEl
33 | .addClass(`${pfx}editor-cont`)
34 | .empty()
35 | .append(el);
36 |
37 | return this;
38 | }
39 | });
40 |
--------------------------------------------------------------------------------
/grapesjs/src/modal_dialog/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stylePrefix: 'mdl-',
3 |
4 | title: '',
5 |
6 | content: '',
7 |
8 | backdrop: true
9 | };
10 |
--------------------------------------------------------------------------------
/grapesjs/src/modal_dialog/model/Modal.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | defaults: {
5 | title: '',
6 | content: '',
7 | open: false
8 | }
9 | });
10 |
--------------------------------------------------------------------------------
/grapesjs/src/navigator/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stylePrefix: '',
3 |
4 | // Specify the element to use as a container, string (query) or HTMLElement
5 | // With the empty value, nothing will be rendered
6 | appendTo: '',
7 |
8 | // Enable/Disable globally the possibility to sort layers
9 | sortable: 1,
10 |
11 | // Enable/Disable globally the possibility to hide layers
12 | hidable: 1,
13 |
14 | // Hide textnodes
15 | hideTextnode: 1,
16 |
17 | // Indicates if the wrapper is visible in layers
18 | showWrapper: 1
19 | };
20 |
--------------------------------------------------------------------------------
/grapesjs/src/navigator/index.js:
--------------------------------------------------------------------------------
1 | import defaults from './config/config';
2 | import ItemView from './view/ItemView';
3 | import ItemsView from './view/ItemsView';
4 | import { isElement } from 'underscore';
5 |
6 | module.exports = () => {
7 | let em;
8 | let layers;
9 | let config = {};
10 | let View = ItemsView;
11 |
12 | return {
13 | name: 'LayerManager',
14 |
15 | init(opts = {}) {
16 | config = { ...defaults, ...opts };
17 | config.stylePrefix = opts.pStylePrefix;
18 | em = config.em;
19 |
20 | return this;
21 | },
22 |
23 | onLoad() {
24 | const collection = em.get('DomComponents').getComponents();
25 | const parent = collection.parent;
26 | const options = {
27 | level: 0,
28 | config,
29 | opened: config.opened || {}
30 | };
31 |
32 | // Show wrapper if requested
33 | if (config.showWrapper && parent) {
34 | View = ItemView;
35 | options.model = parent;
36 | } else {
37 | options.collection = collection;
38 | }
39 |
40 | layers = new View(options);
41 | em && em.on('component:selected', this.componentChanged);
42 | this.componentChanged();
43 | },
44 |
45 | postRender() {
46 | const elTo = config.appendTo;
47 |
48 | if (elTo) {
49 | const el = isElement(elTo) ? elTo : document.querySelector(elTo);
50 | el.appendChild(this.render());
51 | }
52 | },
53 |
54 | /**
55 | * Return the view of layers
56 | * @return {View}
57 | */
58 | getAll() {
59 | return layers;
60 | },
61 |
62 | /**
63 | * Triggered when the selected component is changed
64 | * @private
65 | */
66 | componentChanged(e, md, opts = {}) {
67 | if (opts.fromLayers) return;
68 | const opened = em.get('opened');
69 | const model = em.getSelected();
70 | let parent = model && model.collection ? model.collection.parent : null;
71 | for (let cid in opened) opened[cid].set('open', 0);
72 |
73 | while (parent) {
74 | parent.set('open', 1);
75 | opened[parent.cid] = parent;
76 | parent = parent.collection ? parent.collection.parent : null;
77 | }
78 | },
79 |
80 | render() {
81 | return layers.render().el;
82 | }
83 | };
84 | };
85 |
--------------------------------------------------------------------------------
/grapesjs/src/panels/config/config.js:
--------------------------------------------------------------------------------
1 | var crc = 'create-comp';
2 | var mvc = 'move-comp';
3 | var swv = 'sw-visibility';
4 | var expt = 'export-template';
5 | var osm = 'open-sm';
6 | var otm = 'open-tm';
7 | var ola = 'open-layers';
8 | var obl = 'open-blocks';
9 | var ful = 'fullscreen';
10 | var prv = 'preview';
11 |
12 | module.exports = {
13 | stylePrefix: 'pn-',
14 |
15 | // Default panels fa-sliders for features
16 | defaults: [
17 | {
18 | id: 'commands',
19 | buttons: [{}]
20 | },
21 | {
22 | id: 'options',
23 | buttons: [
24 | {
25 | active: true,
26 | id: swv,
27 | className: 'fa fa-square-o',
28 | command: swv,
29 | context: swv,
30 | attributes: { title: 'View components' }
31 | },
32 | {
33 | id: prv,
34 | className: 'fa fa-eye',
35 | command: prv,
36 | context: prv,
37 | attributes: { title: 'Preview' }
38 | },
39 | {
40 | id: ful,
41 | className: 'fa fa-arrows-alt',
42 | command: ful,
43 | context: ful,
44 | attributes: { title: 'Fullscreen' }
45 | },
46 | {
47 | id: expt,
48 | className: 'fa fa-code',
49 | command: expt,
50 | attributes: { title: 'View code' }
51 | }
52 | ]
53 | },
54 | {
55 | id: 'views',
56 | buttons: [
57 | {
58 | id: osm,
59 | className: 'fa fa-paint-brush',
60 | command: osm,
61 | active: true,
62 | attributes: { title: 'Open Style Manager' }
63 | },
64 | {
65 | id: otm,
66 | className: 'fa fa-cog',
67 | command: otm,
68 | attributes: { title: 'Settings' }
69 | },
70 | {
71 | id: ola,
72 | className: 'fa fa-bars',
73 | command: ola,
74 | attributes: { title: 'Open Layer Manager' }
75 | },
76 | {
77 | id: obl,
78 | className: 'fa fa-th-large',
79 | command: obl,
80 | attributes: { title: 'Open Blocks' }
81 | }
82 | ]
83 | }
84 | ],
85 |
86 | // Editor model
87 | em: null,
88 |
89 | // Delay before show children buttons (in milliseconds)
90 | delayBtnsShow: 300
91 | };
92 |
--------------------------------------------------------------------------------
/grapesjs/src/panels/model/Button.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 |
3 | module.exports = Backbone.Model.extend({
4 | defaults: {
5 | id: '',
6 | label: '',
7 | className: '',
8 | command: '',
9 | context: '',
10 | buttons: [],
11 | attributes: {},
12 | options: {},
13 | active: false,
14 | dragDrop: false,
15 | runDefaultCommand: true,
16 | stopDefaultCommand: false,
17 | disable: false
18 | },
19 |
20 | initialize(options) {
21 | if (this.get('buttons').length) {
22 | var Buttons = require('./Buttons');
23 | this.set('buttons', new Buttons(this.get('buttons')));
24 | }
25 | }
26 | });
27 |
--------------------------------------------------------------------------------
/grapesjs/src/panels/model/Buttons.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var Button = require('./Button');
3 |
4 | module.exports = Backbone.Collection.extend({
5 | model: Button,
6 |
7 | /**
8 | * Deactivate all buttons, except one passed
9 | * @param {Object} except Model to ignore
10 | * @param {Boolean} r Recursive flag
11 | *
12 | * @return void
13 | * */
14 | deactivateAllExceptOne(except, r) {
15 | this.forEach((model, index) => {
16 | if (model !== except) {
17 | model.set('active', false);
18 | if (r && model.get('buttons').length)
19 | model.get('buttons').deactivateAllExceptOne(except, r);
20 | }
21 | });
22 | },
23 |
24 | /**
25 | * Deactivate all buttons
26 | * @param {String} ctx Context string
27 | *
28 | * @return void
29 | * */
30 | deactivateAll(ctx) {
31 | var context = ctx || '';
32 | this.forEach((model, index) => {
33 | if (model.get('context') == context) {
34 | model.set('active', false);
35 | if (model.get('buttons').length)
36 | model.get('buttons').deactivateAll(context);
37 | }
38 | });
39 | },
40 |
41 | /**
42 | * Disables all buttons
43 | * @param {String} ctx Context string
44 | *
45 | * @return void
46 | * */
47 | disableAllButtons(ctx) {
48 | var context = ctx || '';
49 | this.forEach((model, index) => {
50 | if (model.get('context') == context) {
51 | model.set('disable', true);
52 | if (model.get('buttons').length)
53 | model.get('buttons').disableAllButtons(context);
54 | }
55 | });
56 | },
57 |
58 | /**
59 | * Disables all buttons, except one passed
60 | * @param {Object} except Model to ignore
61 | * @param {Boolean} r Recursive flag
62 | *
63 | * @return void
64 | * */
65 | disableAllButtonsExceptOne(except, r) {
66 | this.forEach((model, index) => {
67 | if (model !== except) {
68 | model.set('disable', true);
69 | if (r && model.get('buttons').length)
70 | model.get('buttons').disableAllButtonsExceptOne(except, r);
71 | }
72 | });
73 | }
74 | });
75 |
--------------------------------------------------------------------------------
/grapesjs/src/panels/model/Panel.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var Buttons = require('./Buttons');
3 |
4 | module.exports = Backbone.Model.extend({
5 | defaults: {
6 | id: '',
7 | content: '',
8 | visible: true,
9 | buttons: [],
10 | attributes: {}
11 | },
12 |
13 | initialize(options) {
14 | this.btn = this.get('buttons') || [];
15 | this.buttons = new Buttons(this.btn);
16 | this.set('buttons', this.buttons);
17 | }
18 | });
19 |
--------------------------------------------------------------------------------
/grapesjs/src/panels/model/Panels.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var Panel = require('./Panel');
3 |
4 | module.exports = Backbone.Collection.extend({
5 | model: Panel
6 | });
7 |
--------------------------------------------------------------------------------
/grapesjs/src/panels/view/ButtonsView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var ButtonView = require('./ButtonView');
3 |
4 | module.exports = Backbone.View.extend({
5 | initialize(o) {
6 | this.opt = o || {};
7 | this.config = this.opt.config || {};
8 | this.pfx = this.config.stylePrefix || '';
9 | this.parentM = this.opt.parentM || null;
10 | this.listenTo(this.collection, 'add', this.addTo);
11 | this.listenTo(this.collection, 'reset remove', this.render);
12 | this.className = this.pfx + 'buttons';
13 | },
14 |
15 | /**
16 | * Add to collection
17 | * @param Object Model
18 | *
19 | * @return Object
20 | * */
21 | addTo(model) {
22 | this.addToCollection(model);
23 | },
24 |
25 | /**
26 | * Add new object to collection
27 | * @param Object Model
28 | * @param Object Fragment collection
29 | *
30 | * @return Object Object created
31 | * */
32 | addToCollection(model, fragmentEl) {
33 | var fragment = fragmentEl || null;
34 | var viewObject = ButtonView;
35 |
36 | var view = new viewObject({
37 | model,
38 | config: this.config,
39 | parentM: this.parentM
40 | });
41 | var rendered = view.render().el;
42 |
43 | if (fragment) {
44 | fragment.appendChild(rendered);
45 | } else {
46 | this.$el.append(rendered);
47 | }
48 |
49 | return rendered;
50 | },
51 |
52 | render() {
53 | var fragment = document.createDocumentFragment();
54 | this.$el.empty();
55 |
56 | this.collection.each(function(model) {
57 | this.addToCollection(model, fragment);
58 | }, this);
59 |
60 | this.$el.append(fragment);
61 | this.$el.attr('class', _.result(this, 'className'));
62 | return this;
63 | }
64 | });
65 |
--------------------------------------------------------------------------------
/grapesjs/src/panels/view/PanelsView.js:
--------------------------------------------------------------------------------
1 | var Backbone = require('backbone');
2 | var PanelView = require('./PanelView');
3 |
4 | module.exports = Backbone.View.extend({
5 | initialize(o) {
6 | this.opt = o || {};
7 | this.config = this.opt.config || {};
8 | this.pfx = this.config.stylePrefix || '';
9 | this.listenTo(this.collection, 'add', this.addTo);
10 | this.listenTo(this.collection, 'reset', this.render);
11 | this.className = this.pfx + 'panels';
12 | },
13 |
14 | /**
15 | * Add to collection
16 | * @param Object Model
17 | *
18 | * @return Object
19 | * @private
20 | * */
21 | addTo(model) {
22 | this.addToCollection(model);
23 | },
24 |
25 | /**
26 | * Add new object to collection
27 | * @param Object Model
28 | * @param Object Fragment collection
29 | * @param integer Index of append
30 | *
31 | * @return Object Object created
32 | * @private
33 | * */
34 | addToCollection(model, fragmentEl) {
35 | const fragment = fragmentEl || null;
36 | const config = this.config;
37 | const el = model.get('el');
38 | const view = new PanelView({
39 | el,
40 | model,
41 | config
42 | });
43 | const rendered = view.render().el;
44 | const appendTo = model.get('appendTo');
45 |
46 | // Do nothing if the panel was requested to be another element
47 | if (el) {
48 | } else if (appendTo) {
49 | var appendEl = document.querySelector(appendTo);
50 | appendEl.appendChild(rendered);
51 | } else {
52 | if (fragment) {
53 | fragment.appendChild(rendered);
54 | } else {
55 | this.$el.append(rendered);
56 | }
57 | }
58 |
59 | view.initResize();
60 | return rendered;
61 | },
62 |
63 | render() {
64 | const $el = this.$el;
65 | const frag = document.createDocumentFragment();
66 | $el.empty();
67 | this.collection.each(model => this.addToCollection(model, frag));
68 | $el.append(frag);
69 | $el.attr('class', this.className);
70 | return this;
71 | }
72 | });
73 |
--------------------------------------------------------------------------------
/grapesjs/src/parser/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | textTags: ['br', 'b', 'i', 'u', 'a', 'ul', 'ol']
3 | };
4 |
--------------------------------------------------------------------------------
/grapesjs/src/parser/index.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | var c = {},
3 | defaults = require('./config/config'),
4 | parserCss = require('./model/ParserCss'),
5 | parserHtml = require('./model/ParserHtml');
6 | var pHtml, pCss;
7 |
8 | return {
9 | compTypes: '',
10 |
11 | /**
12 | * Name of the module
13 | * @type {String}
14 | * @private
15 | */
16 | name: 'Parser',
17 |
18 | /**
19 | * Initialize module. Automatically called with a new instance of the editor
20 | * @param {Object} config Configurations
21 | * @param {Array