├── .gitignore ├── README.md ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.js ├── Editor.js ├── Home.js ├── api_utils ├── geditor_config.js ├── geditor_utils.js └── index.js ├── components ├── PageDetail.js ├── PageSection.js ├── Sidebar.js └── TopNav.js ├── index.js ├── plugins ├── charts │ ├── components.js │ ├── components │ │ └── LineChart.js │ └── index.js ├── swiper │ ├── blocks.js │ ├── components.js │ └── index.js └── tailwind │ ├── components.js │ ├── index.js │ ├── tailwind_classes.js │ └── traits.js ├── redux ├── actions │ └── pageAction.js ├── reducers │ ├── index.js │ └── pageReducer.js └── store.js ├── reportWebVitals.js └── styles └── main.scss /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | package-lock.json 25 | .DS_Store 26 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-grapesjs", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@popperjs/core": "^2.9.3", 7 | "axios": "^0.21.1", 8 | "bootstrap": "^5.1.1", 9 | "chart.js": "^3.8.2", 10 | "grapesjs": "^0.17.22", 11 | "grapesjs-blocks-basic": "^0.1.8", 12 | "grapesjs-blocks-bootstrap4": "^0.2.3", 13 | "grapesjs-plugin-export": "^1.0.7", 14 | "grapesjs-style-bg": "^1.0.5", 15 | "jquery": "^3.6.0", 16 | "react": "^17.0.2", 17 | "react-bootstrap": "^2.0.0-rc.1", 18 | "react-dom": "^17.0.2", 19 | "react-redux": "^7.2.5", 20 | "react-router-dom": "^5.2.0", 21 | "react-scripts": "^5.0.1", 22 | "redux": "^4.1.1", 23 | "redux-devtools-extension": "^2.13.9", 24 | "redux-thunk": "^2.3.0", 25 | "sass": "^1.49.7", 26 | "web-vitals": "^1.1.2" 27 | }, 28 | "scripts": { 29 | "start": "react-scripts start", 30 | "build": "react-scripts build", 31 | "test": "react-scripts test", 32 | "eject": "react-scripts eject" 33 | }, 34 | "eslintConfig": { 35 | "extends": [ 36 | "react-app", 37 | "react-app/jest" 38 | ] 39 | }, 40 | "browserslist": { 41 | "production": [ 42 | ">0.2%", 43 | "not dead", 44 | "not op_mini all" 45 | ], 46 | "development": [ 47 | "last 1 chrome version", 48 | "last 1 firefox version", 49 | "last 1 safari version" 50 | ] 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code-dexterous/grapesjs-example-react/e0b47288559b2c67eb845b36a80e5ea4a908deab/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code-dexterous/grapesjs-example-react/e0b47288559b2c67eb845b36a80e5ea4a908deab/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code-dexterous/grapesjs-example-react/e0b47288559b2c67eb845b36a80e5ea4a908deab/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; 3 | import { useDispatch } from "react-redux"; 4 | import Home from "./Home"; 5 | import Editor from "./Editor"; 6 | import { pageLoad } from "./redux/actions/pageAction"; 7 | 8 | function App() { 9 | const dispatch = useDispatch(); 10 | 11 | useEffect(() => { 12 | pageLoad()(dispatch); 13 | }, [dispatch]); 14 | 15 | return ( 16 | 17 | 18 | 19 | 20 | 21 | 22 | ); 23 | } 24 | 25 | export default App; 26 | -------------------------------------------------------------------------------- /src/Editor.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import { useParams } from "react-router-dom"; 3 | import axios from "axios"; 4 | import { useSelector } from "react-redux"; 5 | import { API_HOST } from "./api_utils"; 6 | import Sidebar from "./components/Sidebar"; 7 | import TopNav from "./components/TopNav"; 8 | import geditorConfig from "./api_utils/geditor_config"; 9 | import PageSection from "./components/PageSection"; 10 | 11 | const Editor = () => { 12 | const [editor, setEditor] = useState(null); 13 | const [assets, setAssets] = useState([]); 14 | const { pageId } = useParams(); 15 | 16 | const { pageStore } = useSelector((state) => state); 17 | const { pages } = pageStore; 18 | 19 | useEffect(() => { 20 | async function getAllAssets() { 21 | try { 22 | const response = await axios.get(`${API_HOST}assets/`); 23 | setAssets(response.data); 24 | } catch (error) { 25 | setAssets(error.message); 26 | } 27 | } 28 | 29 | getAllAssets(); 30 | }, []); 31 | 32 | useEffect(() => { 33 | const editor = geditorConfig(assets, pageId); 34 | setEditor(editor); 35 | }, [pageId, assets]); 36 | return ( 37 |
38 | 50 |
54 | 55 |
56 |
57 |
58 | ); 59 | }; 60 | 61 | export default Editor; 62 | -------------------------------------------------------------------------------- /src/Home.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import { Link } from "react-router-dom"; 3 | import { useSelector, useDispatch } from "react-redux"; 4 | import { createPage } from "./redux/actions/pageAction"; 5 | 6 | const Home = () => { 7 | const [name, setName] = useState(""); 8 | const [isValid, setIsValid] = useState(true); 9 | const dispatch = useDispatch(); 10 | 11 | const { pageStore } = useSelector((state) => state); 12 | const { pages } = pageStore; 13 | 14 | const handleSubmit = async () => { 15 | if (!name) { 16 | setIsValid(false); 17 | return; 18 | } 19 | createPage(name)(dispatch); 20 | }; 21 | 22 | return ( 23 |
24 |
25 |
26 |
27 |
28 |
29 | Create Page 30 |
31 |
32 |
33 |
34 | 37 | setName(e.target.value)} 47 | /> 48 | {!isValid && ( 49 |
50 | Please provide a valid name. 51 |
52 | )} 53 |
54 |
55 |
56 | 63 | 70 |
71 |
72 |
73 |
74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | {pages 85 | ? pages.map((page) => ( 86 | 87 | 88 | 89 | 90 | 93 | 94 | )) 95 | : "No Page"} 96 | 97 |
IDNameSlugAction
{page._id}{page.name}{page.slug} 91 | Edit 92 |
98 |
99 |
100 |
101 | ); 102 | }; 103 | 104 | export default Home; 105 | -------------------------------------------------------------------------------- /src/api_utils/geditor_config.js: -------------------------------------------------------------------------------- 1 | import grapesjs from "grapesjs"; 2 | import gjsBlockBasic from "grapesjs-blocks-basic"; 3 | import $ from "jquery"; 4 | import grapesjsBlockBootstrap from "grapesjs-blocks-bootstrap4"; 5 | import grapesjsPluginExport from "grapesjs-plugin-export"; 6 | import grapesjsStyleBg from "grapesjs-style-bg"; 7 | 8 | import { 9 | addEditorCommand, 10 | deviceManager, 11 | layerManager, 12 | panels, 13 | scripts, 14 | selectorManager, 15 | storageSetting, 16 | styleManager, 17 | styles, 18 | toggleSidebar, 19 | traitManager, 20 | } from "./geditor_utils"; 21 | import tailwindComponent from "../plugins/tailwind"; 22 | import swiperComponent from "../plugins/swiper"; 23 | import chartLibComponent from "../plugins/charts"; 24 | 25 | const geditorConfig = (assets, pageId) => { 26 | $(".panel__devices").html(""); 27 | $(".panel__basic-actions").html(""); 28 | $(".panel__editor").html(""); 29 | $("#blocks").html(""); 30 | $("#styles-container").html(""); 31 | $("#layers-container").html(""); 32 | $("#trait-container").html(""); 33 | 34 | // Content for Preview 35 | const navbar = $("#navbar"); 36 | const mainContent = $("#main-content"); 37 | const panelTopBar = $("#main-content > .navbar-light"); 38 | 39 | const editor = grapesjs.init({ 40 | container: "#editor", 41 | blockManager: { 42 | appendTo: "#blocks", 43 | }, 44 | styleManager: styleManager, 45 | layerManager: layerManager, 46 | traitManager: traitManager, 47 | selectorManager: selectorManager, 48 | panels: panels, 49 | deviceManager: deviceManager, 50 | assetManager: { assets: assets, upload: false }, 51 | storageManager: storageSetting(pageId), 52 | canvas: { 53 | styles: styles, 54 | scripts: scripts, 55 | }, 56 | plugins: [ 57 | tailwindComponent, 58 | gjsBlockBasic, 59 | swiperComponent, 60 | grapesjsBlockBootstrap, 61 | grapesjsPluginExport, 62 | grapesjsStyleBg, 63 | chartLibComponent, 64 | ], 65 | pluginsOpts: { 66 | tailwindComponent: {}, 67 | gjsBlockBasic: {}, 68 | swiperComponent: {}, 69 | grapesjsBlockBootstrap: {}, 70 | grapesjsPluginExport: {}, 71 | grapesjsStyleBg: {}, 72 | chartLibComponent: {}, 73 | }, 74 | }); 75 | 76 | addEditorCommand(editor); 77 | editor.on("run:preview", () => { 78 | console.log("It will trigger when we click on preview icon"); 79 | // This will be used to hide border 80 | editor.stopCommand("sw-visibility"); 81 | // This will hide the sidebar view 82 | navbar.removeClass("sidebar"); 83 | // This will make the main-content to be full width 84 | mainContent.removeClass("main-content"); 85 | 86 | // This will hide top panel where we have added the button 87 | panelTopBar.addClass("d-none"); 88 | }); 89 | editor.on("stop:preview", () => { 90 | // This event is reverse of the above event. 91 | console.log("It will trigger when we click on cancel preview icon"); 92 | editor.runCommand("sw-visibility"); 93 | navbar.addClass("sidebar"); 94 | mainContent.addClass("main-content"); 95 | panelTopBar.removeClass("d-none"); 96 | }); 97 | editor.on("component:selected", (component) => { 98 | const newTool = { 99 | icon: "fa fa-plus-square", 100 | title: "Check Toolbar", 101 | commandName: "new-tool-cmd", 102 | id: "new-tool", 103 | }; 104 | 105 | const defaultToolbar = component.get("toolbar"); 106 | const checkAlreadyExist = defaultToolbar.find( 107 | (toolbar) => toolbar.command === newTool.commandName 108 | ); 109 | if (!checkAlreadyExist) { 110 | defaultToolbar.unshift({ 111 | id: newTool.id, 112 | attributes: { class: newTool.icon, title: newTool.title }, 113 | command: newTool.commandName, 114 | }); 115 | component.set("toolbar", defaultToolbar); 116 | } 117 | }); 118 | 119 | setTimeout(() => { 120 | let categories = editor.BlockManager.getCategories(); 121 | categories.each((category) => category.set("open", false)); 122 | }, 1000); 123 | return editor; 124 | }; 125 | 126 | export default geditorConfig; 127 | -------------------------------------------------------------------------------- /src/api_utils/geditor_utils.js: -------------------------------------------------------------------------------- 1 | import { API_HOST } from "."; 2 | 3 | export const styleManager = { 4 | appendTo: "#styles-container", 5 | sectors: [ 6 | { 7 | name: "General", 8 | buildProps: [ 9 | "float", 10 | "display", 11 | "position", 12 | "top", 13 | "right", 14 | "left", 15 | "bottom", 16 | ], 17 | properties: [ 18 | { 19 | name: "Alignment", 20 | property: "float", 21 | type: "radio", 22 | defaults: "none", 23 | list: [ 24 | { value: "none", className: "fa fa-times" }, 25 | { value: "left", className: "fa fa-align-left" }, 26 | { value: "right", className: "fa fa-align-right" }, 27 | ], 28 | }, 29 | { property: "position", type: "select" }, 30 | ], 31 | }, 32 | { 33 | name: "Dimension", 34 | open: false, 35 | buildProps: [ 36 | "width", 37 | "max-width", 38 | "min-width", 39 | "height", 40 | "max-height", 41 | "min-height", 42 | "margin", 43 | "padding", 44 | ], 45 | properties: [ 46 | { 47 | id: "flex-width", 48 | type: "integer", 49 | name: "Width", 50 | units: ["px", "%"], 51 | property: "flex-basis", 52 | toRequire: 1, 53 | }, 54 | { 55 | property: "margin", 56 | properties: [ 57 | { name: "Top", property: "margin-top" }, 58 | { name: "Right", property: "margin-right" }, 59 | { name: "Bottom", property: "margin-bottom" }, 60 | { name: "Left", property: "margin-left" }, 61 | ], 62 | }, 63 | { 64 | property: "padding", 65 | properties: [ 66 | { name: "Top", property: "padding-top" }, 67 | { name: "Right", property: "padding-right" }, 68 | { name: "Bottom", property: "padding-bottom" }, 69 | { name: "Left", property: "padding-left" }, 70 | ], 71 | }, 72 | ], 73 | }, 74 | { 75 | name: "Typography", 76 | open: false, 77 | buildProps: [ 78 | "font-family", 79 | "font-size", 80 | "font-weight", 81 | "letter-spacing", 82 | "color", 83 | "line-height", 84 | "text-align", 85 | "text-decoration", 86 | "text-shadow", 87 | ], 88 | properties: [ 89 | { name: "Font", property: "font-family" }, 90 | { name: "Weight", property: "font-weight" }, 91 | { name: "Font color", property: "color" }, 92 | { 93 | property: "text-align", 94 | type: "radio", 95 | defaults: "left", 96 | list: [ 97 | { value: "left", name: "Left", className: "fa fa-align-left" }, 98 | { 99 | value: "center", 100 | name: "Center", 101 | className: "fa fa-align-center", 102 | }, 103 | { value: "right", name: "Right", className: "fa fa-align-right" }, 104 | { 105 | value: "justify", 106 | name: "Justify", 107 | className: "fa fa-align-justify", 108 | }, 109 | ], 110 | }, 111 | { 112 | property: "text-decoration", 113 | type: "radio", 114 | defaults: "none", 115 | list: [ 116 | { value: "none", name: "None", className: "fa fa-times" }, 117 | { 118 | value: "underline", 119 | name: "underline", 120 | className: "fa fa-underline", 121 | }, 122 | { 123 | value: "line-through", 124 | name: "Line-through", 125 | className: "fa fa-strikethrough", 126 | }, 127 | ], 128 | }, 129 | { 130 | property: "text-shadow", 131 | properties: [ 132 | { name: "X position", property: "text-shadow-h" }, 133 | { name: "Y position", property: "text-shadow-v" }, 134 | { name: "Blur", property: "text-shadow-blur" }, 135 | { name: "Color", property: "text-shadow-color" }, 136 | ], 137 | }, 138 | ], 139 | }, 140 | { 141 | name: "Decorations", 142 | open: false, 143 | buildProps: [ 144 | "opacity", 145 | "border-radius", 146 | "border", 147 | "box-shadow", 148 | "background-bg", 149 | ], 150 | properties: [ 151 | { 152 | type: "slider", 153 | property: "opacity", 154 | defaults: 1, 155 | step: 0.01, 156 | max: 1, 157 | min: 0, 158 | }, 159 | { 160 | property: "border-radius", 161 | properties: [ 162 | { name: "Top", property: "border-top-left-radius" }, 163 | { name: "Right", property: "border-top-right-radius" }, 164 | { name: "Bottom", property: "border-bottom-left-radius" }, 165 | { name: "Left", property: "border-bottom-right-radius" }, 166 | ], 167 | }, 168 | { 169 | property: "box-shadow", 170 | properties: [ 171 | { name: "X position", property: "box-shadow-h" }, 172 | { name: "Y position", property: "box-shadow-v" }, 173 | { name: "Blur", property: "box-shadow-blur" }, 174 | { name: "Spread", property: "box-shadow-spread" }, 175 | { name: "Color", property: "box-shadow-color" }, 176 | { name: "Shadow type", property: "box-shadow-type" }, 177 | ], 178 | }, 179 | { 180 | id: "background-bg", 181 | property: "background", 182 | type: "bg", 183 | }, 184 | ], 185 | }, 186 | { 187 | name: "Extra", 188 | open: false, 189 | buildProps: ["transition", "perspective", "transform"], 190 | properties: [ 191 | { 192 | property: "transition", 193 | properties: [ 194 | { name: "Property", property: "transition-property" }, 195 | { name: "Duration", property: "transition-duration" }, 196 | { name: "Easing", property: "transition-timing-function" }, 197 | ], 198 | }, 199 | { 200 | property: "transform", 201 | properties: [ 202 | { name: "Rotate X", property: "transform-rotate-x" }, 203 | { name: "Rotate Y", property: "transform-rotate-y" }, 204 | { name: "Rotate Z", property: "transform-rotate-z" }, 205 | { name: "Scale X", property: "transform-scale-x" }, 206 | { name: "Scale Y", property: "transform-scale-y" }, 207 | { name: "Scale Z", property: "transform-scale-z" }, 208 | ], 209 | }, 210 | ], 211 | }, 212 | { 213 | name: "Flex", 214 | open: false, 215 | properties: [ 216 | { 217 | name: "Flex Container", 218 | property: "display", 219 | type: "select", 220 | defaults: "block", 221 | list: [ 222 | { value: "block", name: "Disable" }, 223 | { value: "flex", name: "Enable" }, 224 | ], 225 | }, 226 | { 227 | name: "Flex Parent", 228 | property: "label-parent-flex", 229 | type: "integer", 230 | }, 231 | { 232 | name: "Direction", 233 | property: "flex-direction", 234 | type: "radio", 235 | defaults: "row", 236 | list: [ 237 | { 238 | value: "row", 239 | name: "Row", 240 | className: "icons-flex icon-dir-row", 241 | title: "Row", 242 | }, 243 | { 244 | value: "row-reverse", 245 | name: "Row reverse", 246 | className: "icons-flex icon-dir-row-rev", 247 | title: "Row reverse", 248 | }, 249 | { 250 | value: "column", 251 | name: "Column", 252 | title: "Column", 253 | className: "icons-flex icon-dir-col", 254 | }, 255 | { 256 | value: "column-reverse", 257 | name: "Column reverse", 258 | title: "Column reverse", 259 | className: "icons-flex icon-dir-col-rev", 260 | }, 261 | ], 262 | }, 263 | { 264 | name: "Justify", 265 | property: "justify-content", 266 | type: "radio", 267 | defaults: "flex-start", 268 | list: [ 269 | { 270 | value: "flex-start", 271 | className: "icons-flex icon-just-start", 272 | title: "Start", 273 | }, 274 | { 275 | value: "flex-end", 276 | title: "End", 277 | className: "icons-flex icon-just-end", 278 | }, 279 | { 280 | value: "space-between", 281 | title: "Space between", 282 | className: "icons-flex icon-just-sp-bet", 283 | }, 284 | { 285 | value: "space-around", 286 | title: "Space around", 287 | className: "icons-flex icon-just-sp-ar", 288 | }, 289 | { 290 | value: "center", 291 | title: "Center", 292 | className: "icons-flex icon-just-sp-cent", 293 | }, 294 | ], 295 | }, 296 | { 297 | name: "Align", 298 | property: "align-items", 299 | type: "radio", 300 | defaults: "center", 301 | list: [ 302 | { 303 | value: "flex-start", 304 | title: "Start", 305 | className: "icons-flex icon-al-start", 306 | }, 307 | { 308 | value: "flex-end", 309 | title: "End", 310 | className: "icons-flex icon-al-end", 311 | }, 312 | { 313 | value: "stretch", 314 | title: "Stretch", 315 | className: "icons-flex icon-al-str", 316 | }, 317 | { 318 | value: "center", 319 | title: "Center", 320 | className: "icons-flex icon-al-center", 321 | }, 322 | ], 323 | }, 324 | { 325 | name: "Flex Children", 326 | property: "label-parent-flex", 327 | type: "integer", 328 | }, 329 | { 330 | name: "Order", 331 | property: "order", 332 | type: "integer", 333 | defaults: 0, 334 | min: 0, 335 | }, 336 | { 337 | name: "Flex", 338 | property: "flex", 339 | type: "composite", 340 | properties: [ 341 | { 342 | name: "Grow", 343 | property: "flex-grow", 344 | type: "integer", 345 | defaults: 0, 346 | min: 0, 347 | }, 348 | { 349 | name: "Shrink", 350 | property: "flex-shrink", 351 | type: "integer", 352 | defaults: 0, 353 | min: 0, 354 | }, 355 | { 356 | name: "Basis", 357 | property: "flex-basis", 358 | type: "integer", 359 | units: ["px", "%", ""], 360 | unit: "", 361 | defaults: "auto", 362 | }, 363 | ], 364 | }, 365 | { 366 | name: "Align", 367 | property: "align-self", 368 | type: "radio", 369 | defaults: "auto", 370 | list: [ 371 | { 372 | value: "auto", 373 | name: "Auto", 374 | }, 375 | { 376 | value: "flex-start", 377 | title: "Start", 378 | className: "icons-flex icon-al-start", 379 | }, 380 | { 381 | value: "flex-end", 382 | title: "End", 383 | className: "icons-flex icon-al-end", 384 | }, 385 | { 386 | value: "stretch", 387 | title: "Stretch", 388 | className: "icons-flex icon-al-str", 389 | }, 390 | { 391 | value: "center", 392 | title: "Center", 393 | className: "icons-flex icon-al-center", 394 | }, 395 | ], 396 | }, 397 | ], 398 | }, 399 | ], 400 | }; 401 | 402 | export const layerManager = { 403 | appendTo: "#layers-container", 404 | }; 405 | export const traitManager = { 406 | appendTo: "#trait-container", 407 | }; 408 | export const selectorManager = { 409 | appendTo: "#styles-container", 410 | }; 411 | export const panels = { 412 | defaults: [ 413 | { 414 | id: "basic-actions", 415 | el: ".panel__basic-actions", 416 | buttons: [ 417 | { 418 | id: "visibility", 419 | active: true, // active by default 420 | className: "btn-toggle-borders", 421 | label: '', 422 | command: "sw-visibility", // Built-in command 423 | }, 424 | ], 425 | }, 426 | { 427 | id: "editor-actions", 428 | el: ".panel__editor", 429 | buttons: [ 430 | { 431 | id: "saveDb", 432 | className: "fa fa-paper-plane btn-save", 433 | command: "saveDb", 434 | }, 435 | { 436 | id: "cmd-clear", 437 | className: "fa fa-trash", 438 | command: "cmd-clear", 439 | }, 440 | { 441 | id: "undo", 442 | className: "fa fa-undo", 443 | command: "undo", 444 | }, 445 | { 446 | id: "redo", 447 | className: "fa fa-repeat", 448 | command: "redo", 449 | }, 450 | { 451 | id: "export", 452 | className: "fa fa-download", 453 | command: "export", 454 | }, 455 | { 456 | id: "preview", 457 | className: "fa fa-eye", 458 | command: "preview", 459 | }, 460 | ], 461 | }, 462 | { 463 | id: "panel-devices", 464 | el: ".panel__devices", 465 | buttons: [ 466 | { 467 | id: "device-desktop", 468 | label: '', 469 | command: "set-device-desktop", 470 | active: true, 471 | togglable: false, 472 | }, 473 | { 474 | id: "device-mobile", 475 | label: '', 476 | command: "set-device-mobile", 477 | togglable: false, 478 | }, 479 | ], 480 | }, 481 | ], 482 | }; 483 | export const deviceManager = { 484 | devices: [ 485 | { 486 | name: "Desktop", 487 | width: "", 488 | }, 489 | { 490 | name: "Mobile", 491 | width: "320px", 492 | widthMedia: "480px", 493 | }, 494 | ], 495 | }; 496 | 497 | export const addEditorCommand = (editor) => { 498 | // Commands 499 | editor.Commands.add("set-device-desktop", { 500 | run: (editor) => editor.setDevice("Desktop"), 501 | }); 502 | editor.Commands.add("set-device-mobile", { 503 | run: (editor) => editor.setDevice("Mobile"), 504 | }); 505 | 506 | // Save Button 507 | editor.Commands.add("saveDb", { 508 | run: (editor, sender) => { 509 | sender && sender.set("active"); 510 | editor.store(); 511 | }, 512 | }); 513 | 514 | //Clear Button 515 | editor.Commands.add("cmd-clear", { 516 | run: (editor) => { 517 | editor.DomComponents.clear(); 518 | editor.CssComposer.clear(); 519 | }, 520 | }); 521 | 522 | //Undo 523 | editor.Commands.add("undo", { 524 | run: (editor) => editor.UndoManager.undo(), 525 | }); 526 | 527 | // Redo 528 | editor.Commands.add("redo", { 529 | run: (editor) => editor.UndoManager.redo(), 530 | }); 531 | 532 | editor.Commands.add("export", { 533 | run: (editor) => editor.runCommand("gjs-export-zip"), 534 | }); 535 | 536 | editor.Commands.add("new-tool-cmd", { 537 | run: (editor) => console.log("Checking New Toolbar"), 538 | }); 539 | }; 540 | 541 | export const storageSetting = (pageId) => { 542 | return { 543 | type: "remote", 544 | stepsBeforeSave: 3, 545 | contentTypeJson: true, 546 | storeComponents: true, 547 | storeStyles: true, 548 | storeHtml: true, 549 | storeCss: true, 550 | headers: { 551 | "Content-Type": "application/json", 552 | }, 553 | id: "mycustom-", 554 | urlStore: `${API_HOST}pages/${pageId}/content`, 555 | urlLoad: `${API_HOST}pages/${pageId}/content`, 556 | }; 557 | }; 558 | 559 | export const scripts = [ 560 | "https://code.jquery.com/jquery-3.5.1.slim.min.js", 561 | "https://unpkg.com/swiper@7/swiper-bundle.min.js", 562 | "https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js", 563 | "https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js", 564 | "https://cdn.jsdelivr.net/npm/chart.js", 565 | ]; 566 | export const styles = [ 567 | "https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css", 568 | "https://unpkg.com/swiper@7/swiper-bundle.min.css", 569 | "https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css", 570 | ]; 571 | 572 | export const toggleSidebar = (fromEditor) => { 573 | const sidebar = document.getElementById("navbar"); 574 | const mainContent = document.getElementById("main-content"); 575 | if (fromEditor) { 576 | sidebar.classList.remove("d-flex"); 577 | sidebar.classList.add("d-none"); 578 | mainContent.classList.remove("w-85", "start-15"); 579 | } else if (sidebar.classList.contains("d-flex")) { 580 | sidebar.classList.remove("d-flex"); 581 | sidebar.classList.add("d-none"); 582 | mainContent.classList.remove("w-85", "start-15"); 583 | } else { 584 | sidebar.classList.remove("d-none"); 585 | sidebar.classList.add("d-flex"); 586 | mainContent.classList.add("w-85", "start-15"); 587 | } 588 | }; 589 | -------------------------------------------------------------------------------- /src/api_utils/index.js: -------------------------------------------------------------------------------- 1 | export const API_HOST = "http://localhost:8080/api/"; 2 | -------------------------------------------------------------------------------- /src/components/PageDetail.js: -------------------------------------------------------------------------------- 1 | import { Link } from "react-router-dom"; 2 | function PageDetail({ page }) { 3 | const { name } = page; 4 | return ( 5 |
  • 6 | 7 | {name} 8 | 9 |
    10 | 13 | 16 |
    17 |
  • 18 | ); 19 | } 20 | 21 | export default PageDetail; 22 | -------------------------------------------------------------------------------- /src/components/PageSection.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useReducer } from "react"; 2 | import { useDispatch } from "react-redux"; 3 | import { Modal, Button } from "react-bootstrap"; 4 | import { createPage } from "../redux/actions/pageAction"; 5 | import PageDetail from "./PageDetail"; 6 | 7 | export default function PageSection({ pages }) { 8 | const [show, setShow] = useReducer((show) => !show, false); 9 | const [name, setName] = useState(""); 10 | const [isValid, setIsValid] = useState(true); 11 | const [error, setError] = useState(""); 12 | 13 | const dispatch = useDispatch(); 14 | 15 | const handleSubmit = async () => { 16 | if (!name) { 17 | setIsValid(false); 18 | return; 19 | } else { 20 | createPage(name)(dispatch); 21 | closeModal(); 22 | } 23 | }; 24 | 25 | const closeModal = () => { 26 | setName(""); 27 | setError(""); 28 | setShow(); 29 | }; 30 | return ( 31 |
    32 | 40 |
    41 | 49 | 50 | Create Page 51 | 52 | 53 |
    54 | 57 | setName(e.target.value)} 67 | /> 68 | {!isValid && ( 69 |
    70 | Please provide a valid name. 71 |
    72 | )} 73 |
    74 |
    75 | 76 | 79 | 82 | 83 |
    84 |
    85 | 90 |
    91 | ); 92 | } 93 | -------------------------------------------------------------------------------- /src/components/Sidebar.js: -------------------------------------------------------------------------------- 1 | function Sidebar() { 2 | return ( 3 | <> 4 | 62 |
    63 |
    69 |
    70 |
    71 |
    77 |
    78 |
    79 |
    85 |
    86 |
    87 |
    93 |
    94 |
    95 |
    96 | 97 | ); 98 | } 99 | 100 | export default Sidebar; 101 | -------------------------------------------------------------------------------- /src/components/TopNav.js: -------------------------------------------------------------------------------- 1 | import { toggleSidebar } from "../api_utils/geditor_utils"; 2 | 3 | function TopNav() { 4 | const handleClick = () => { 5 | toggleSidebar(false); 6 | }; 7 | return ( 8 | 21 | ); 22 | } 23 | 24 | export default TopNav; 25 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import "grapesjs/dist/css/grapes.min.css"; 4 | import "bootstrap"; 5 | import App from "./App"; 6 | import "./styles/main.scss"; 7 | import reportWebVitals from "./reportWebVitals"; 8 | import DataProvider from "./redux/store"; 9 | 10 | ReactDOM.render( 11 | 12 | 13 | 14 | 15 | , 16 | document.getElementById("root") 17 | ); 18 | 19 | reportWebVitals(); 20 | -------------------------------------------------------------------------------- /src/plugins/charts/components.js: -------------------------------------------------------------------------------- 1 | import LineChart, { LineChartBlock } from "./components/LineChart"; 2 | export default (editor, opts = {}) => { 3 | const dc = editor.DomComponents; 4 | const bm = editor.BlockManager; 5 | const { blocks, labels, types, labelChartCategory } = opts; 6 | 7 | if (blocks.lineChart) { 8 | LineChartBlock(bm, labelChartCategory, labels.lineChart, types.lineChart); 9 | LineChart(dc, labels.lineChart, types.lineChart, opts); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /src/plugins/charts/components/LineChart.js: -------------------------------------------------------------------------------- 1 | const Chart = require("chart.js"); 2 | export const LineChartBlock = (bm, category, label, type) => { 3 | bm.add(type, { 4 | label, 5 | category, 6 | content: ``, 7 | }); 8 | }; 9 | export default (dc, label, type, config) => { 10 | const defaultType = dc.getType("default"); 11 | const defaultModel = defaultType.model; 12 | const defaultView = defaultType.view; 13 | dc.addType(type, { 14 | model: { 15 | defaults: { 16 | script: function () { 17 | const initLib = function () { 18 | const labels = [ 19 | "January", 20 | "February", 21 | "March", 22 | "April", 23 | "May", 24 | "June", 25 | ]; 26 | const data = { 27 | labels: labels, 28 | datasets: [ 29 | { 30 | label: "My First dataset", 31 | backgroundColor: "rgb(255, 99, 132)", 32 | borderColor: "rgb(255, 99, 132)", 33 | data: [0, 10, 5, 2, 20, 30, 45], 34 | }, 35 | ], 36 | }; 37 | 38 | const config = { 39 | type: "line", 40 | data: data, 41 | options: {}, 42 | }; 43 | 44 | const ctx = document.getElementById("lineChart").getContext("2d"); 45 | const myChart = new Chart(ctx, config); 46 | }; 47 | if (typeof Chart == "undefined") { 48 | const script = document.createElement("script"); 49 | script.onload = initLib; 50 | script.src = "https://cdn.jsdelivr.net/npm/chart.js"; 51 | document.body.appendChild(script); 52 | } else { 53 | console.log("InitLib"); 54 | initLib(); 55 | } 56 | }, 57 | }, 58 | }, 59 | isComponent: (el) => { 60 | if (el.getAttribute && el.getAttribute("data-gjs-type") == type) { 61 | return { type }; 62 | } 63 | }, 64 | view: defaultView.extend({ 65 | init({ model }) {}, 66 | }), 67 | }); 68 | }; 69 | -------------------------------------------------------------------------------- /src/plugins/charts/index.js: -------------------------------------------------------------------------------- 1 | import grapesjs from "grapesjs"; 2 | import loadComponents from "./components"; 3 | 4 | export default grapesjs.plugins.add("charts", (editor, opts = {}) => { 5 | let default_blocks = { 6 | lineChart: true, 7 | }; 8 | let default_labels = { 9 | lineChart: "Line Chart", 10 | }; 11 | let default_types = { 12 | lineChart: "lineChart", 13 | }; 14 | 15 | let options = { 16 | ...{ 17 | blocks: default_blocks, 18 | labels: default_labels, 19 | types: default_types, 20 | labelChartCategory: "Charts", 21 | }, 22 | ...opts, 23 | }; 24 | loadComponents(editor, options); 25 | }); 26 | -------------------------------------------------------------------------------- /src/plugins/swiper/blocks.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/no-anonymous-default-export */ 2 | export default (editor, opts = {}) => { 3 | const bm = editor.BlockManager; 4 | const style = ` 36 | `; 37 | bm.add(opts.name, { 38 | label: ` 39 | 40 |
    41 | ${opts.label} 42 |
    43 | `, 44 | category: opts.category, 45 | content: `
    46 |
    47 |
    Slide 1
    48 |
    Slide 2
    49 |
    Slide 3
    50 |
    Slide 4
    51 |
    Slide 5
    52 |
    53 | 54 |
    55 |
    56 |
    57 | 58 |
    ${style}`, 59 | }); 60 | }; 61 | -------------------------------------------------------------------------------- /src/plugins/swiper/components.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | /* eslint-disable import/no-anonymous-default-export */ 3 | 4 | export default (editor, opts = {}) => { 5 | const dc = editor.DomComponents; 6 | const defaultType = dc.getType("default"); 7 | const defaultView = defaultType.view; 8 | 9 | dc.addType(opts.name, { 10 | model: { 11 | defaults: { 12 | traits: [ 13 | { 14 | type: "checkbox", 15 | name: "dynamicProgress", 16 | label: "Dynamic Progress", 17 | changeProp: 1, 18 | }, 19 | { 20 | type: "select", 21 | name: "progressType", 22 | label: "Progress Type", 23 | changeProp: 1, 24 | options: [ 25 | { value: "bullets", name: "Bullets" }, 26 | { value: "fraction", name: "Fraction" }, 27 | { value: "progressbar", name: "Progressbar" }, 28 | ], 29 | }, 30 | ], 31 | script: function () { 32 | const dynamicProgress = "{[ dynamicProgress ]}"; 33 | const progressType = "{[ progressType ]}"; 34 | 35 | const initLib = function () { 36 | const swiper = new Swiper(".mySwiper", { 37 | spaceBetween: 30, 38 | centeredSlides: true, 39 | autoplay: { 40 | delay: 2500, 41 | disableOnInteraction: false, 42 | }, 43 | pagination: { 44 | el: ".swiper-pagination", 45 | clickable: true, 46 | dynamicBullets: !!dynamicProgress, 47 | type: progressType, 48 | }, 49 | navigation: { 50 | nextEl: ".swiper-button-next", 51 | prevEl: ".swiper-button-prev", 52 | }, 53 | }); 54 | console.log("swiper :>> ", swiper); 55 | }; 56 | 57 | if (typeof Swiper == "undefined") { 58 | const script = document.createElement("script"); 59 | script.onload = initLib; 60 | script.src = "https://unpkg.com/swiper@7/swiper-bundle.min.js"; 61 | document.body.appendChild(script); 62 | } else { 63 | initLib(); 64 | } 65 | }, 66 | }, 67 | }, 68 | 69 | isComponent: (el) => { 70 | if (el.className && el.className.includes("swiper-container")) { 71 | return { 72 | type: opts.name, 73 | }; 74 | } 75 | }, 76 | 77 | view: defaultView.extend({ 78 | init({ model }) { 79 | this.listenTo(model, "change:dynamicProgress", this.updateScript); 80 | this.listenTo(model, "change:progressType", this.updateScript); 81 | }, 82 | }), 83 | }); 84 | }; 85 | -------------------------------------------------------------------------------- /src/plugins/swiper/index.js: -------------------------------------------------------------------------------- 1 | import grapesjs from "grapesjs"; 2 | import loadComponents from "./components"; 3 | import loadBlocks from "./blocks"; 4 | 5 | export default grapesjs.plugins.add("swiperComponent", (editor, opts = {}) => { 6 | let options = { 7 | label: "Swiper", 8 | name: "cswiper", 9 | category: "Custom", 10 | }; 11 | for (let name in options) { 12 | if (!(name in opts)) opts[name] = options[name]; 13 | } 14 | 15 | loadBlocks(editor, options); 16 | loadComponents(editor, opts); 17 | }); 18 | -------------------------------------------------------------------------------- /src/plugins/tailwind/components.js: -------------------------------------------------------------------------------- 1 | import { 2 | backgroundAttachment, 3 | backgroundClip, 4 | bgColor, 5 | bgRepeat, 6 | bgSize, 7 | borderColor, 8 | borderRadius, 9 | borderStyle, 10 | borderWidth, 11 | fontVariant, 12 | fontWeight, 13 | letterSpacing, 14 | lineHeight, 15 | tableBorder, 16 | tableLayout, 17 | textAlignment, 18 | textColor, 19 | textDecoration, 20 | textFontSize, 21 | textOpacity, 22 | textOverflow, 23 | textTransformation, 24 | verticalAlign, 25 | wordBreak, 26 | } from "./tailwind_classes"; 27 | 28 | /* eslint-disable import/no-anonymous-default-export */ 29 | export default (editor, opts = {}) => { 30 | const dc = editor.DomComponents; 31 | 32 | dc.getTypes().forEach((type) => { 33 | if (type.id === "text" || type.id === "link") { 34 | dc.addType(type.id, { 35 | model: { 36 | defaults: { 37 | traits: [ 38 | ...type.model.prototype.defaults.traits, 39 | { 40 | type: "class_select", 41 | options: textColor.map((color) => ({ 42 | name: color, 43 | value: color, 44 | })), 45 | label: "Text Color", 46 | }, 47 | { 48 | type: "class_select", 49 | options: textAlignment.map((color) => ({ 50 | name: color, 51 | value: color, 52 | })), 53 | label: "Text Alignment", 54 | }, 55 | { 56 | type: "class_select", 57 | options: textOpacity.map((color) => ({ 58 | name: color, 59 | value: color, 60 | })), 61 | label: "Text Opacity", 62 | }, 63 | { 64 | type: "class_select", 65 | options: textDecoration.map((color) => ({ 66 | name: color, 67 | value: color, 68 | })), 69 | label: "Text Decoration", 70 | }, 71 | { 72 | type: "class_select", 73 | options: textTransformation.map((color) => ({ 74 | name: color, 75 | value: color, 76 | })), 77 | label: "Text Transformation", 78 | }, 79 | { 80 | type: "class_select", 81 | options: textOverflow.map((color) => ({ 82 | name: color, 83 | value: color, 84 | })), 85 | label: "Text Overflow", 86 | }, 87 | { 88 | type: "class_select", 89 | options: textFontSize.map((color) => ({ 90 | name: color, 91 | value: color, 92 | })), 93 | label: "Font Size", 94 | }, 95 | { 96 | type: "class_select", 97 | options: fontWeight.map((color) => ({ 98 | name: color, 99 | value: color, 100 | })), 101 | label: "Font Weight", 102 | }, 103 | { 104 | type: "class_select", 105 | options: fontVariant.map((color) => ({ 106 | name: color, 107 | value: color, 108 | })), 109 | label: "Font Variant", 110 | }, 111 | { 112 | type: "class_select", 113 | options: letterSpacing.map((color) => ({ 114 | name: color, 115 | value: color, 116 | })), 117 | label: "Letter Spacing", 118 | }, 119 | { 120 | type: "class_select", 121 | options: lineHeight.map((color) => ({ 122 | name: color, 123 | value: color, 124 | })), 125 | label: "Line Height", 126 | }, 127 | { 128 | type: "class_select", 129 | options: verticalAlign.map((color) => ({ 130 | name: color, 131 | value: color, 132 | })), 133 | label: "Vertical Align", 134 | }, 135 | { 136 | type: "class_select", 137 | options: wordBreak.map((color) => ({ 138 | name: color, 139 | value: color, 140 | })), 141 | label: "Word Break", 142 | }, 143 | ], 144 | }, 145 | }, 146 | }); 147 | } 148 | 149 | if (type.id === "table") { 150 | dc.addType(type.id, { 151 | model: { 152 | defaults: { 153 | traits: [ 154 | ...type.model.prototype.defaults.traits, 155 | { 156 | type: "class_select", 157 | options: tableBorder.map((color) => ({ 158 | name: color, 159 | value: color, 160 | })), 161 | label: "Table Border", 162 | }, 163 | { 164 | type: "class_select", 165 | options: tableLayout.map((color) => ({ 166 | name: color, 167 | value: color, 168 | })), 169 | label: "Table Layout", 170 | }, 171 | ], 172 | }, 173 | }, 174 | }); 175 | } 176 | 177 | const toolbar = [ 178 | { 179 | attributes: { 180 | class: "fa fa-arrow-up", 181 | }, 182 | command: (e) => e.runCommand("core:component-exit", { force: 1 }), 183 | }, 184 | { 185 | attributes: { 186 | class: "fa fa-arrows gjs-no-touch-actions", 187 | draggable: true, 188 | }, 189 | command: "tld-move", 190 | }, 191 | 192 | { 193 | attributes: { 194 | class: "fa fa-clone", 195 | }, 196 | command: "tlb-clone", 197 | }, 198 | { 199 | attributes: { 200 | class: "fa fa-trash-o", 201 | }, 202 | command: "tlb-delete", 203 | }, 204 | { 205 | attributes: { 206 | class: "fa fa-gear", 207 | }, 208 | command: (e) => { 209 | console.log("Another way to add toolbar"); 210 | alert("Another way to add toolbar"); 211 | }, 212 | }, 213 | ]; 214 | 215 | if (type.id === "svg" || type.id === "svg-in") { 216 | dc.addType(type.id, { 217 | model: { 218 | defaults: { 219 | traits: [ 220 | ...dc.getType(type.id).model.prototype.defaults.traits, 221 | { 222 | type: "class_select", 223 | options: [{ name: "fill-current", value: "fill-current" }], 224 | label: "Fill", 225 | }, 226 | { 227 | type: "class_select", 228 | options: [{ name: "stroke-current", value: "stroke-current" }], 229 | label: "Stroke", 230 | }, 231 | { 232 | type: "class_select", 233 | options: [ 234 | { name: "stroke-0", value: "stroke-0" }, 235 | { name: "stroke-1", value: "stroke-1" }, 236 | { name: "stroke-2", value: "stroke-2" }, 237 | ], 238 | label: "Stroke Width", 239 | }, 240 | ], 241 | }, 242 | }, 243 | }); 244 | } 245 | 246 | let defaultTraits = []; 247 | if (dc.getType(type.id).model.prototype.defaults.traits) { 248 | defaultTraits = dc.getType(type.id).model.prototype.defaults.traits; 249 | } 250 | dc.addType(type.id, { 251 | model: { 252 | defaults: { 253 | toolbar, 254 | traits: [ 255 | ...defaultTraits, 256 | { 257 | type: "class_select", 258 | options: backgroundAttachment.map((color) => ({ 259 | name: color, 260 | value: color, 261 | })), 262 | label: "BG Attachment", 263 | }, 264 | { 265 | type: "class_select", 266 | options: backgroundClip.map((color) => ({ 267 | name: color, 268 | value: color, 269 | })), 270 | label: "BG Clip", 271 | }, 272 | { 273 | type: "class_select", 274 | options: bgColor.map((color) => ({ 275 | name: color, 276 | value: color, 277 | })), 278 | label: "BG Color", 279 | }, 280 | { 281 | type: "class_select", 282 | options: bgRepeat.map((color) => ({ 283 | name: color, 284 | value: color, 285 | })), 286 | label: "BG Repeat", 287 | }, 288 | { 289 | type: "class_select", 290 | options: bgSize.map((color) => ({ 291 | name: color, 292 | value: color, 293 | })), 294 | label: "BG Size", 295 | }, 296 | 297 | { 298 | type: "class_select", 299 | options: borderRadius.map((color) => ({ 300 | name: color, 301 | value: color, 302 | })), 303 | label: "Border Radius", 304 | }, 305 | { 306 | type: "class_select", 307 | options: borderWidth.map((color) => ({ 308 | name: color, 309 | value: color, 310 | })), 311 | label: "Border Width", 312 | }, 313 | { 314 | type: "class_select", 315 | options: borderColor.map((color) => ({ 316 | name: color, 317 | value: color, 318 | })), 319 | label: "Border Color", 320 | }, 321 | { 322 | type: "class_select", 323 | options: borderStyle.map((color) => ({ 324 | name: color, 325 | value: color, 326 | })), 327 | label: "Border Style", 328 | }, 329 | ], 330 | }, 331 | }, 332 | }); 333 | }); 334 | }; 335 | -------------------------------------------------------------------------------- /src/plugins/tailwind/index.js: -------------------------------------------------------------------------------- 1 | import grapesjs from "grapesjs"; 2 | import loadComponents from "./components"; 3 | import loadTraits from "./traits"; 4 | 5 | export default grapesjs.plugins.add( 6 | "tailwindComponent", 7 | (editor, opts = {}) => { 8 | let options = {}; 9 | for (let name in options) { 10 | if (!(name in opts)) opts[name] = options[name]; 11 | } 12 | 13 | loadTraits(editor, options); 14 | loadComponents(editor, opts); 15 | } 16 | ); 17 | -------------------------------------------------------------------------------- /src/plugins/tailwind/tailwind_classes.js: -------------------------------------------------------------------------------- 1 | export const textColor = [ 2 | "text-transparent", 3 | "text-black", 4 | "text-white", 5 | "text-gray-50", 6 | "text-gray-100", 7 | "text-gray-200", 8 | "text-gray-300", 9 | "text-gray-400", 10 | "text-gray-500", 11 | "text-gray-600", 12 | "text-gray-700", 13 | "text-gray-800", 14 | "text-gray-900", 15 | 16 | "text-red-50", 17 | "text-red-100", 18 | "text-red-200", 19 | "text-red-300", 20 | "text-red-400", 21 | "text-red-500", 22 | "text-red-600", 23 | "text-red-700", 24 | "text-red-800", 25 | "text-red-900", 26 | 27 | "text-yellow-50", 28 | "text-yellow-100", 29 | "text-yellow-200", 30 | "text-yellow-300", 31 | "text-yellow-400", 32 | "text-yellow-500", 33 | "text-yellow-600", 34 | "text-yellow-700", 35 | "text-yellow-800", 36 | "text-yellow-900", 37 | 38 | "text-green-50", 39 | "text-green-100", 40 | "text-green-200", 41 | "text-green-300", 42 | "text-green-400", 43 | "text-green-500", 44 | "text-green-600", 45 | "text-green-700", 46 | "text-green-800", 47 | "text-green-900", 48 | 49 | "text-blue-50", 50 | "text-blue-100", 51 | "text-blue-200", 52 | "text-blue-300", 53 | "text-blue-400", 54 | "text-blue-500", 55 | "text-blue-600", 56 | "text-blue-700", 57 | "text-blue-800", 58 | "text-blue-900", 59 | 60 | "text-indigo-50", 61 | "text-indigo-100", 62 | "text-indigo-200", 63 | "text-indigo-300", 64 | "text-indigo-400", 65 | "text-indigo-500", 66 | "text-indigo-600", 67 | "text-indigo-700", 68 | "text-indigo-800", 69 | "text-indigo-900", 70 | 71 | "text-purple-50", 72 | "text-purple-100", 73 | "text-purple-200", 74 | "text-purple-300", 75 | "text-purple-400", 76 | "text-purple-500", 77 | "text-purple-600", 78 | "text-purple-700", 79 | "text-purple-800", 80 | "text-purple-900", 81 | 82 | "text-pink-50", 83 | "text-pink-100", 84 | "text-pink-200", 85 | "text-pink-300", 86 | "text-pink-400", 87 | "text-pink-500", 88 | "text-pink-600", 89 | "text-pink-700", 90 | "text-pink-800", 91 | "text-pink-900", 92 | ]; 93 | 94 | export const textAlignment = [ 95 | "text-left", 96 | "text-center", 97 | "text-right", 98 | "text-justify", 99 | ]; 100 | 101 | export const textOpacity = [ 102 | "text-opacity-0", 103 | "text-opacity-5", 104 | "text-opacity-10", 105 | "text-opacity-20", 106 | "text-opacity-25", 107 | "text-opacity-30", 108 | "text-opacity-40", 109 | "text-opacity-50", 110 | "text-opacity-60", 111 | "text-opacity-70", 112 | "text-opacity-75", 113 | "text-opacity-80", 114 | "text-opacity-90", 115 | "text-opacity-95", 116 | "text-opacity-100", 117 | ]; 118 | 119 | export const textDecoration = ["underline", "line-through", "no-underline"]; 120 | 121 | export const textTransformation = [ 122 | "uppercase", 123 | "lowercase", 124 | "capitalize", 125 | "normal-case", 126 | ]; 127 | 128 | export const textOverflow = ["truncate", "overflow-ellipsis", "overflow-clip"]; 129 | 130 | export const textFontSize = [ 131 | "text-xs", 132 | "text-sm", 133 | "text-base", 134 | "text-lg", 135 | "text-xl", 136 | "text-2xl", 137 | "text-3xl", 138 | "text-4xl", 139 | "text-5xl", 140 | "text-6xl", 141 | "text-7xl", 142 | "text-8xl", 143 | "text-9xl", 144 | ]; 145 | 146 | export const fontWeight = [ 147 | "font-thin", 148 | "font-extralight", 149 | "font-light", 150 | "font-normal", 151 | "font-medium", 152 | "font-semibold", 153 | "font-bold", 154 | "font-extrabold", 155 | "font-black", 156 | ]; 157 | 158 | export const fontVariant = [ 159 | "normal-nums", 160 | "ordinal", 161 | "slashed-zero", 162 | "lining-nums", 163 | "oldstyle-nums", 164 | "proportional-nums", 165 | "tabular-nums", 166 | "diagonal-fractions", 167 | "stacked-fractions", 168 | ]; 169 | 170 | export const letterSpacing = [ 171 | "tracking-tighter", 172 | "tracking-tight", 173 | "tracking-normal", 174 | "tracking-wide", 175 | "tracking-wider", 176 | "tracking-widest", 177 | ]; 178 | 179 | export const lineHeight = [ 180 | "leading-3", 181 | "leading-4", 182 | "leading-5", 183 | "leading-6", 184 | "leading-7", 185 | "leading-8", 186 | "leading-9", 187 | "leading-10", 188 | "leading-none", 189 | "leading-tight", 190 | "leading-snug", 191 | "leading-normal", 192 | "leading-relaxed", 193 | "leading-loose", 194 | ]; 195 | 196 | export const verticalAlign = [ 197 | "align-baseline", 198 | "align-top", 199 | "align-middle", 200 | "align-bottom", 201 | "align-text-top", 202 | "align-text-bottom", 203 | ]; 204 | 205 | export const wordBreak = ["break-normal", "break-words", "break-all"]; 206 | export const tableBorder = ["border-collapse", "border-separate"]; 207 | export const tableLayout = ["table-auto", "table-fixed"]; 208 | 209 | export const backgroundAttachment = ["bg-fixed", "bg-local", "bg-scroll"]; 210 | export const backgroundClip = [ 211 | "bg-clip-border", 212 | "bg-clip-padding", 213 | "bg-clip-content", 214 | "bg-clip-text", 215 | ]; 216 | 217 | export const bgColor = [ 218 | "bg-transparent", 219 | "bg-black", 220 | "bg-white", 221 | "bg-gray-400", 222 | "bg-gray-700", 223 | "bg-red-400", 224 | "bg-red-700", 225 | "bg-yellow-400", 226 | "bg-yellow-700", 227 | "bg-green-400", 228 | "bg-green-700", 229 | "bg-blue-400", 230 | "bg-blue-700", 231 | "bg-indigo-400", 232 | "bg-indigo-700", 233 | "bg-purple-400", 234 | "bg-purple-700", 235 | "bg-pink-400", 236 | "bg-pink-700", 237 | ]; 238 | 239 | export const bgRepeat = [ 240 | "bg-repeat", 241 | "bg-no-repeat", 242 | "bg-repeat-x", 243 | "bg-repeat-y", 244 | "bg-repeat-round", 245 | "bg-repeat-space", 246 | ]; 247 | 248 | export const bgSize = ["bg-auto", "bg-cover", "bg-contain"]; 249 | 250 | export const borderRadius = [ 251 | "rounded-none", 252 | "rounded", 253 | "rounded-lg", 254 | "rounded-full", 255 | ]; 256 | 257 | export const borderWidth = [ 258 | "border-0", 259 | "border-4", 260 | "border", 261 | "border-t-4", 262 | "border-r-4", 263 | "border-l-4", 264 | "border-b-4", 265 | ]; 266 | 267 | export const borderColor = [ 268 | "border-black", 269 | "border-gray-500", 270 | "border-red-500", 271 | "border-yellow-500", 272 | "border-green-500", 273 | "border-blue-500", 274 | "border-indigo-500", 275 | "border-purple-500", 276 | "border-pink-500", 277 | ]; 278 | 279 | export const borderStyle = [ 280 | "border-solid", 281 | "border-dashed", 282 | "border-dotted", 283 | "border-double", 284 | "border-none", 285 | ]; 286 | -------------------------------------------------------------------------------- /src/plugins/tailwind/traits.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/no-anonymous-default-export */ 2 | export default (editor, config = {}) => { 3 | const tm = editor.TraitManager; 4 | 5 | tm.addType("class_select", { 6 | events: { 7 | change: "onChange", 8 | }, 9 | createInput({ trait }) { 10 | const md = this.model; 11 | const opts = md.get("options") || []; 12 | const input = document.createElement("select"); 13 | const target_view_el = this.target.view.el; 14 | 15 | for (let i = 0; i < opts.length; i++) { 16 | const option = document.createElement("option"); 17 | let value = opts[i].value; 18 | if (value === "") { 19 | value = "text-black"; 20 | } 21 | option.text = opts[i].name; 22 | option.value = value; 23 | 24 | const css = Array.from(target_view_el.classList); 25 | 26 | const value_a = value.split(" "); 27 | const intersection = css.filter((x) => value_a.includes(x)); 28 | 29 | if (intersection.length === value_a.length) { 30 | option.setAttribute("selected", "selected"); 31 | } 32 | 33 | input.append(option); 34 | } 35 | return input; 36 | }, 37 | onUpdate({ elInput, component }) { 38 | const classes = component.getClasses(); 39 | const opts = this.model.get("options") || []; 40 | for (let i = 0; i < opts.length; i++) { 41 | let value = opts[i].value; 42 | if (value && classes.includes(value)) { 43 | elInput.value = value; 44 | return; 45 | } 46 | } 47 | elInput.value = "text-black"; 48 | }, 49 | 50 | onEvent({ elInput, component, event }) { 51 | const classes = this.model.get("options").map((opt) => opt.value); 52 | for (let i = 0; i < classes.length; i++) { 53 | if (classes[i].length > 0) { 54 | const classes_i_a = classes[i].split(" "); 55 | for (let j = 0; j < classes_i_a.length; j++) { 56 | if (classes_i_a[j].length > 0) { 57 | component.removeClass(classes_i_a[j]); 58 | } 59 | } 60 | } 61 | } 62 | const value = this.model.get("value"); 63 | const elAttributes = component.attributes.attributes; 64 | delete elAttributes[""]; 65 | 66 | if (value.length > 0 && value !== "text-black") { 67 | const value_a = value.split(" "); 68 | for (let i = 0; i < value_a.length; i++) { 69 | component.addClass(value_a[i]); 70 | } 71 | } 72 | component.em.trigger("component:toggled"); 73 | }, 74 | }); 75 | }; 76 | -------------------------------------------------------------------------------- /src/redux/actions/pageAction.js: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import { API_HOST } from "../../api_utils"; 3 | 4 | export const TYPES = { 5 | LIST_PAGE_REQUEST_SEND: "LIST_PAGE_REQUEST_SEND", 6 | LIST_PAGE_REQUEST_ERROR: "LIST_PAGE_REQUEST_ERROR", 7 | LIST_PAGE_REQUEST_SUCCESS: "LIST_PAGE_REQUEST_SUCCESS", 8 | 9 | CREATE_PAGE_REQUEST: "CREATE_PAGE_REQUEST", 10 | CREATE_PAGE_ERROR: "CREATE_PAGE_ERROR", 11 | CREATE_PAGE_SUCCESS: "CREATE_PAGE_SUCCESS", 12 | }; 13 | 14 | export const pageLoad = () => async (dispatch) => { 15 | dispatch({ type: TYPES.LIST_PAGE_REQUEST_SEND }); 16 | try { 17 | const response = await axios.get(`${API_HOST}pages/`); 18 | dispatch({ type: TYPES.LIST_PAGE_REQUEST_SUCCESS, data: response.data }); 19 | } catch (error) { 20 | dispatch({ type: TYPES.LIST_PAGE_REQUEST_ERROR, error: error }); 21 | } 22 | }; 23 | 24 | export const createPage = (name) => async (dispatch) => { 25 | dispatch({ type: TYPES.CREATE_PAGE_REQUEST }); 26 | try { 27 | const response = await axios.post(`${API_HOST}pages/`, { name }); 28 | dispatch({ type: TYPES.CREATE_PAGE_SUCCESS, data: response.data }); 29 | } catch (error) { 30 | dispatch({ type: TYPES.CREATE_PAGE_ERROR, data: error }); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /src/redux/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from "redux"; 2 | import pageReducer from "./pageReducer"; 3 | 4 | export default combineReducers({ 5 | pageStore: pageReducer, 6 | }); 7 | -------------------------------------------------------------------------------- /src/redux/reducers/pageReducer.js: -------------------------------------------------------------------------------- 1 | import { TYPES } from "../actions/pageAction"; 2 | 3 | const { 4 | LIST_PAGE_REQUEST_SEND, 5 | LIST_PAGE_REQUEST_ERROR, 6 | LIST_PAGE_REQUEST_SUCCESS, 7 | 8 | CREATE_PAGE_REQUEST, 9 | CREATE_PAGE_ERROR, 10 | CREATE_PAGE_SUCCESS, 11 | } = TYPES; 12 | 13 | const initialState = { 14 | listPageLoading: false, 15 | listPageError: "", 16 | pages: [], 17 | createPageError: "", 18 | createPageLoading: false, 19 | }; 20 | 21 | const pageReducer = (state = initialState, action) => { 22 | switch (action.type) { 23 | case LIST_PAGE_REQUEST_SEND: 24 | return { ...state, listPageLoading: true, listPageError: "" }; 25 | case LIST_PAGE_REQUEST_ERROR: 26 | return { ...state, listPageLoading: false, listPageError: action.error }; 27 | case LIST_PAGE_REQUEST_SUCCESS: 28 | return { 29 | ...state, 30 | listPageLoading: false, 31 | listPageError: "", 32 | pages: action.data, 33 | }; 34 | 35 | case CREATE_PAGE_REQUEST: 36 | return { ...state, createPageError: "", createPageLoading: true }; 37 | case CREATE_PAGE_ERROR: 38 | return { 39 | ...state, 40 | createPageError: action.data, 41 | createPageLoading: false, 42 | }; 43 | case CREATE_PAGE_SUCCESS: 44 | return { ...state, createPageError: "", createPageLoading: false, pages: [...state.pages, action.data]}; 45 | 46 | default: 47 | return state; 48 | } 49 | }; 50 | 51 | export default pageReducer; 52 | -------------------------------------------------------------------------------- /src/redux/store.js: -------------------------------------------------------------------------------- 1 | import { createStore, applyMiddleware } from "redux"; 2 | import { Provider } from "react-redux"; 3 | import thunk from "redux-thunk"; 4 | import { composeWithDevTools } from "redux-devtools-extension"; 5 | 6 | import rootReducer from "./reducers"; 7 | const store = createStore( 8 | rootReducer, 9 | composeWithDevTools(applyMiddleware(thunk)) 10 | ); 11 | 12 | const DataProvider = ({ children }) => { 13 | return {children}; 14 | }; 15 | 16 | export default DataProvider; 17 | -------------------------------------------------------------------------------- /src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /src/styles/main.scss: -------------------------------------------------------------------------------- 1 | @import "~bootstrap/scss/bootstrap"; 2 | 3 | body { 4 | margin: 0; 5 | padding: 0; 6 | } 7 | 8 | html { 9 | overflow: scroll; 10 | overflow-x: hidden; 11 | -ms-overflow-style: none; 12 | scrollbar-width: none; 13 | } 14 | 15 | ::-webkit-scrollbar { 16 | display: none; 17 | } 18 | 19 | .sidenav { 20 | top: 0; 21 | left: 0; 22 | width: 15%; 23 | height: 100vh; 24 | overflow: scroll; 25 | overflow-x: hidden; 26 | -ms-overflow-style: none; 27 | scrollbar-width: none; 28 | background-color: rgba(255, 255, 255, 0.95); 29 | transition: 0.5s; 30 | box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05); 31 | border: 1px solid rgba(0, 0, 0, 0.3); 32 | .logo { 33 | border-bottom: 1px solid rgba(0, 0, 0, 0.3); 34 | text-transform: uppercase; 35 | font-size: 20px; 36 | font-weight: 700; 37 | } 38 | .pages { 39 | height: 100px; 40 | overflow: scroll; 41 | overflow-x: hidden; 42 | } 43 | } 44 | .w-85 { 45 | width: 85%; 46 | } 47 | .start-15 { 48 | left: 15%; 49 | } 50 | .main-content { 51 | .navbar { 52 | padding: 0; 53 | .container-fluid { 54 | padding: 0; 55 | } 56 | } 57 | 58 | #editor { 59 | border: 2px solid rgba(0, 0, 0, 0.3); 60 | } 61 | } 62 | 63 | .nav { 64 | justify-content: space-between; 65 | } 66 | .gjs-pn-panel { 67 | position: relative; 68 | } 69 | 70 | .gjs-cv-canvas { 71 | width: 100%; 72 | height: 100%; 73 | top: 0; 74 | } 75 | 76 | .tab-content { 77 | display: contents; 78 | } 79 | 80 | #block { 81 | height: 100%; 82 | #blocks { 83 | height: 100%; 84 | 85 | .gjs-blocks-c { 86 | align-items: center; 87 | justify-content: center; 88 | } 89 | .gjs-block { 90 | justify-content: center; 91 | } 92 | } 93 | } 94 | 95 | /* Theming */ 96 | .gjs-one-bg { 97 | background-color: #fcf6f5ff; 98 | } 99 | 100 | .gjs-two-color { 101 | color: #990011ff; 102 | } 103 | 104 | .gjs-three-bg { 105 | background-color: #990011ff; 106 | color: #fcf6f5ff; 107 | } 108 | 109 | .gjs-four-color, 110 | .gjs-four-color-h:hover { 111 | color: #990011ff; 112 | } 113 | 114 | .gjs-pn-btn { 115 | border: 1px solid #990011ff; 116 | } 117 | 118 | // Customize Bootstrap CSS 119 | 120 | .btn, 121 | .nav-link, 122 | .modal-content, 123 | .form-control { 124 | border-radius: 0 !important; 125 | } 126 | 127 | .btn { 128 | .fa { 129 | color: #990011ff; 130 | } 131 | &:hover { 132 | .fa { 133 | color: #fcf6f5ff; 134 | } 135 | } 136 | } 137 | 138 | /** Error **/ 139 | .error { 140 | .bg-body { 141 | min-height: 150px; 142 | max-height: 150px; 143 | display: flex; 144 | align-items: center; 145 | justify-content: center; 146 | .title { 147 | font-weight: 600; 148 | } 149 | } 150 | .btn { 151 | border-radius: 40px !important; 152 | padding: 15px 20px; 153 | font-size: 14px; 154 | font-weight: 700; 155 | min-width: 150px; 156 | } 157 | } 158 | 159 | /** Assets **/ 160 | .gjs-am-meta, 161 | .gjs-am-close, 162 | .gjs-am-file-uploader, 163 | .gjs-am-assets-header { 164 | display: none; 165 | } 166 | 167 | .gjs-am-assets-cont { 168 | width: 100%; 169 | } 170 | 171 | .gjs-am-assets { 172 | justify-content: space-between; 173 | display: flex; 174 | flex-wrap: wrap; 175 | } 176 | 177 | .gjs-am-asset-image { 178 | margin-top: 1rem; 179 | margin-bottom: 1rem; 180 | display: contents; 181 | } 182 | 183 | .gjs-am-preview-cont { 184 | margin-top: 1rem; 185 | } 186 | .gjs-block-label { 187 | .fa { 188 | font-size: 25px; 189 | } 190 | } 191 | .grp-wrapper { 192 | background-image: url("data:image/png:base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg=="); 193 | } 194 | .grp-preview { 195 | position: absolute; 196 | top: 0; 197 | left: 0; 198 | width: 100%; 199 | height: 100%; 200 | cursor: crosshair; 201 | } 202 | .grp-handler { 203 | width: 4px; 204 | margin-left: -2px; 205 | user-select: none; 206 | height: 100%; 207 | -webkit-user-select: none; 208 | -moz-user-select: none; 209 | } 210 | 211 | .grp-handler-close { 212 | color: rgba(0, 0, 0, 0.4); 213 | border-radius: 0 2px 10px rgba(0, 0, 0, 0.25); 214 | background-color: #fff; 215 | text-align: center; 216 | width: 15px; 217 | height: 15px; 218 | margin-left: -5px; 219 | line-height: 10px; 220 | font-size: 21px; 221 | cursor: pointer; 222 | } 223 | 224 | .grp-handler-close { 225 | position: absolute; 226 | top: -17px; 227 | } 228 | 229 | .grp-handler-drag { 230 | background-color: rgba(0, 0, 0, 0.5); 231 | cursor: col-resize; 232 | width: 100%; 233 | height: 100%; 234 | } 235 | 236 | .grp-handler-selected .grap-handler-drag { 237 | background-color: rgba(255, 255, 255, 0.5); 238 | } 239 | 240 | .grp-handler-cp-c { 241 | display: none; 242 | } 243 | 244 | .grp-handler-selected .grp-handler-cp-c { 245 | display: block; 246 | } 247 | 248 | .grp-handler-cp-wrap { 249 | width: 15px; 250 | height: 15px; 251 | margin-left: -8px; 252 | border: 3px solid #fff; 253 | box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); 254 | overflow: hidden; 255 | border-radius: 100%; 256 | cursor: pointer; 257 | } 258 | 259 | .grp-handler-cp-wrap input[type="color"] { 260 | opacity: 0; 261 | cursor: pointer; 262 | } 263 | --------------------------------------------------------------------------------