@silexlabs/silex 3.0.0-alpha.32 → 3.0.0-alpha.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +661 -203
  2. package/README.md +4 -2
  3. package/dist/client/client/config.d.ts +258 -0
  4. package/dist/client/client/expose.d.ts +3 -0
  5. package/dist/client/client/grapesjs/blocks.d.ts +1 -0
  6. package/dist/client/client/grapesjs/eleventy.d.ts +1 -0
  7. package/dist/client/client/grapesjs/index.d.ts +237 -0
  8. package/dist/client/client/grapesjs/internal-links.d.ts +1 -0
  9. package/dist/client/client/grapesjs/new-page-dialog.d.ts +2 -0
  10. package/dist/client/client/grapesjs/openImport.d.ts +4 -0
  11. package/dist/client/client/grapesjs/page-panel.d.ts +3 -0
  12. package/dist/client/client/grapesjs/project-bar.d.ts +1 -0
  13. package/dist/client/client/grapesjs/publish.d.ts +18 -0
  14. package/dist/client/client/grapesjs/rich-text.d.ts +1 -0
  15. package/dist/client/client/grapesjs/semantic.d.ts +1 -0
  16. package/dist/client/client/grapesjs/settings.d.ts +2 -0
  17. package/dist/client/client/grapesjs/symbolDialogs.d.ts +3 -0
  18. package/dist/client/client/grapesjs/template.d.ts +1 -0
  19. package/dist/client/client/index.d.ts +4 -0
  20. package/dist/client/client/utils.d.ts +1 -0
  21. package/dist/client/constants.d.ts +4 -0
  22. package/dist/client/events.d.ts +2 -0
  23. package/dist/client/js/main.js +53 -53
  24. package/dist/client/js/main.js.LICENSE.txt +2 -24
  25. package/dist/client/page.d.ts +2 -0
  26. package/dist/client/types.d.ts +99 -0
  27. package/dist/server/index.js +12 -2
  28. package/dist/types.js +1 -1
  29. package/package.json +42 -35
  30. package/src/plugins/DefaultBackend.js +29 -8
  31. package/src/ts/client/config.ts +17 -0
  32. package/src/ts/client/expose.ts +17 -1
  33. package/src/ts/client/grapesjs/blocks.ts +17 -0
  34. package/src/ts/client/grapesjs/eleventy.ts +17 -0
  35. package/src/ts/client/grapesjs/index.ts +44 -18
  36. package/src/ts/client/grapesjs/internal-links.test.ts +17 -0
  37. package/src/ts/client/grapesjs/internal-links.ts +17 -0
  38. package/src/ts/client/grapesjs/new-page-dialog.ts +17 -0
  39. package/src/ts/client/grapesjs/openImport.ts +17 -0
  40. package/src/ts/client/grapesjs/page-panel.ts +17 -0
  41. package/src/ts/client/grapesjs/project-bar.ts +17 -0
  42. package/src/ts/client/grapesjs/publish.ts +17 -0
  43. package/src/ts/client/grapesjs/rich-text.ts +17 -0
  44. package/src/ts/client/grapesjs/semantic.ts +17 -0
  45. package/src/ts/client/grapesjs/settings.ts +17 -0
  46. package/src/ts/client/grapesjs/symbolDialogs.ts +18 -1
  47. package/src/ts/client/grapesjs/template.ts +17 -0
  48. package/src/ts/client/index.ts +18 -0
  49. package/src/ts/client/utils.ts +17 -0
  50. package/src/ts/constants.ts +17 -0
  51. package/src/ts/events.ts +17 -0
  52. package/src/ts/externs.ts +17 -0
  53. package/src/ts/page.ts +17 -0
  54. package/src/ts/server/cli.ts +18 -0
  55. package/src/ts/server/config.ts +17 -0
  56. package/src/ts/server/express.ts +17 -0
  57. package/src/ts/server/index.ts +24 -3
  58. package/src/ts/server/utils/BackwardCompat.ts +17 -0
  59. package/src/ts/types.ts +17 -0
  60. package/.dockerignore +0 -5
  61. package/.editorconfig +0 -14
  62. package/.eslintrc.json +0 -43
  63. package/.github/FUNDING.yml +0 -13
  64. package/.github/workflows/docker-hub-publish.yml +0 -36
  65. package/.github/workflows/npm-publish.yml +0 -19
  66. package/.github/workflows/test.yml +0 -26
  67. package/.nvmrc +0 -1
  68. package/.silex.js +0 -12
  69. package/CODE_OF_CONDUCT.md +0 -128
  70. package/CONTRIBUTING.md +0 -131
  71. package/Dockerfile +0 -15
  72. package/directus.silex.js +0 -7
  73. package/jest.config.js +0 -10
  74. package/logos/logo_by_ceubri/silex-icon-2018@200px.png +0 -0
  75. package/logos/logo_by_ceubri/silex-icon-2018@4x.png +0 -0
  76. package/logos/logo_by_ceubri/silex-logo-2018-white-transp.pdf +0 -0
  77. package/logos/logo_by_ceubri/silex-logo-2018-white.jpg +0 -0
  78. package/logos/logo_by_ceubri/silex-logo-2018-white.pdf +0 -0
  79. package/logos/logo_by_ceubri/silex-logo-2018-white.png +0 -0
  80. package/logos/logo_by_ceubri/silex-logo-2018-white@0.5x.png +0 -0
  81. package/logos/logo_by_ceubri/silex-logo-2018-white@0.75x.png +0 -0
  82. package/logos/logo_by_ceubri/silex-logo-2018-white@4x.jpg +0 -0
  83. package/logos/logo_by_ceubri/silex-logo-2018-white@4x.png +0 -0
  84. package/logos/logo_by_ceubri/silex-logo-2018.ai +5 -2521
  85. package/logos/logo_by_ceubri/silex-logo-2018.jpg +0 -0
  86. package/logos/logo_by_ceubri/silex-logo-2018.pdf +0 -0
  87. package/logos/logo_by_ceubri/silex-logo-2018.png +0 -0
  88. package/logos/logo_by_ceubri/silex-logo-2018@0.5x.png +0 -0
  89. package/logos/logo_by_ceubri/silex-logo-2018@0.75x.png +0 -0
  90. package/logos/logo_by_ceubri/silex-logo-2018@4x.jpg +0 -0
  91. package/logos/logo_by_ceubri/silex-logo-2018@4x.png +0 -0
  92. package/logos/silexlabs.png +0 -0
  93. package/public/assets/container.png +0 -0
  94. package/public/assets/favicon.png +0 -0
  95. package/public/assets/logo-silex-small.png +0 -0
  96. package/public/robots.txt +0 -2
  97. package/public/silex.js +0 -25
  98. package/tsconfig-server-debug.json +0 -20
  99. package/tsconfig-server-release.json +0 -20
  100. package/tsconfig.jest.json +0 -9
  101. package/tsconfig.json +0 -27
  102. package/webpack.config.js +0 -28
  103. package/webpack.debug.config.js +0 -8
@@ -1,38 +1,16 @@
1
1
  /*!
2
- * Sizzle CSS Selector Engine v2.3.10
3
- * https://sizzlejs.com/
4
- *
5
- * Copyright JS Foundation and other contributors
6
- * Released under the MIT license
7
- * https://js.foundation/
8
- *
9
- * Date: 2023-02-14
10
- */
11
-
12
- /*!
13
- * jQuery JavaScript Library v3.6.4
2
+ * jQuery JavaScript Library v3.7.0
14
3
  * https://jquery.com/
15
4
  *
16
- * Includes Sizzle.js
17
- * https://sizzlejs.com/
18
- *
19
5
  * Copyright OpenJS Foundation and other contributors
20
6
  * Released under the MIT license
21
7
  * https://jquery.org/license
22
8
  *
23
- * Date: 2023-03-08T15:28Z
9
+ * Date: 2023-05-11T18:29Z
24
10
  */
25
11
 
26
12
  /*! @silexlabs/grapesjs-loading - 1.0.8 */
27
13
 
28
- /*! grapesjs-style-filter - 1.0.1 */
29
-
30
- /**
31
- * @license
32
- * Copyright 2017 Google LLC
33
- * SPDX-License-Identifier: BSD-3-Clause
34
- */
35
-
36
14
  /**
37
15
  * @license
38
16
  * Copyright 2018 Google LLC
@@ -0,0 +1,2 @@
1
+ export declare function getPageSlug(pageName?: string): string;
2
+ export declare function getPageLink(pageName?: string): string;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @fileoverview define types for Silex client and server
3
+ */
4
+ export declare const defaultPublicationSettings: PublicationSettings;
5
+ export declare const defaultSite: WebsiteData;
6
+ export interface WebsiteSettings {
7
+ description: string;
8
+ title: string;
9
+ lang: string;
10
+ head: string;
11
+ favicon: string;
12
+ 'og:title': string;
13
+ 'og:description': string;
14
+ 'og:image': string;
15
+ }
16
+ export interface WebsiteData {
17
+ pages: Page[];
18
+ assets: Asset[];
19
+ styles: Style[];
20
+ name: string;
21
+ settings: WebsiteSettings;
22
+ fonts: Font[];
23
+ symbols: symbol[];
24
+ publication: PublicationSettings;
25
+ }
26
+ export interface Font {
27
+ name: string;
28
+ value: string;
29
+ variants: string[];
30
+ }
31
+ export interface PublicationSettings {
32
+ path?: string;
33
+ url?: string;
34
+ autoHomePage?: boolean;
35
+ assets?: {
36
+ path?: string;
37
+ url?: string;
38
+ };
39
+ html?: {
40
+ path?: string;
41
+ ext?: string;
42
+ };
43
+ css?: {
44
+ path?: string;
45
+ url?: string;
46
+ ext?: string;
47
+ };
48
+ }
49
+ export interface File {
50
+ html: string;
51
+ css: string;
52
+ htmlPath: string;
53
+ cssPath: string;
54
+ }
55
+ export interface Page {
56
+ name?: string;
57
+ id: string;
58
+ type?: string;
59
+ frames: Frame[];
60
+ settings?: WebsiteSettings;
61
+ cssExt?: string;
62
+ htmlExt?: string;
63
+ }
64
+ export interface Frame {
65
+ component: {
66
+ type: string;
67
+ stylable: string[];
68
+ };
69
+ components: Component[];
70
+ }
71
+ export interface Component {
72
+ type: string;
73
+ content?: string;
74
+ attributes: {
75
+ [key: string]: string;
76
+ };
77
+ conponents: Component[];
78
+ }
79
+ export declare enum Unit {
80
+ PX = "px"
81
+ }
82
+ export interface Asset {
83
+ type: string;
84
+ src: string;
85
+ unitDim: Unit;
86
+ height: number;
87
+ width: number;
88
+ name: string;
89
+ }
90
+ export interface Style {
91
+ selectors: Selector[];
92
+ style: {
93
+ [key: string]: string;
94
+ };
95
+ }
96
+ export type Selector = string | {
97
+ name: string;
98
+ type: number;
99
+ };
@@ -26,14 +26,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.getConfig = exports.start = exports.page = exports.constants = exports.events = exports.types = exports.config = void 0;
29
30
  const config_1 = __importDefault(require("./config"));
31
+ exports.getConfig = config_1.default;
30
32
  const express_1 = __importDefault(require("./express"));
33
+ exports.start = express_1.default;
31
34
  const config = __importStar(require("./config"));
35
+ exports.config = config;
32
36
  const types = __importStar(require("../types"));
37
+ exports.types = types;
33
38
  const events = __importStar(require("../events"));
39
+ exports.events = events;
34
40
  const constants = __importStar(require("../constants"));
41
+ exports.constants = constants;
35
42
  const page = __importStar(require("../page"));
36
- exports.default = { config, types, events, constants, page };
43
+ exports.page = page;
37
44
  async function main() {
38
45
  const config = await (0, config_1.default)();
39
46
  const app = await (0, express_1.default)(config);
@@ -44,7 +51,7 @@ I'm ready, listening to port ${config.port}
44
51
  startLiverReload();
45
52
  }
46
53
  }
47
- main();
54
+ exports.default = main;
48
55
  async function startLiverReload() {
49
56
  const { createServer } = await Promise.resolve().then(() => __importStar(require('livereload')));
50
57
  const { resolve } = await Promise.resolve().then(() => __importStar(require('path')));
@@ -56,3 +63,6 @@ async function startLiverReload() {
56
63
  });
57
64
  server.watch(dist);
58
65
  }
66
+ if (require.main === module) {
67
+ main();
68
+ }
package/dist/types.js CHANGED
@@ -31,4 +31,4 @@ exports.defaultSite = {
31
31
  var Unit;
32
32
  (function (Unit) {
33
33
  Unit["PX"] = "px";
34
- })(Unit = exports.Unit || (exports.Unit = {}));
34
+ })(Unit || (exports.Unit = Unit = {}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silexlabs/silex",
3
3
  "description": "Free and easy website builder for everyone.",
4
- "version": "3.0.0-alpha.32",
4
+ "version": "3.0.0-alpha.36",
5
5
  "version:backwardcompat": "3.0.0",
6
6
  "author": {
7
7
  "name": "Alex Hoyau",
@@ -11,9 +11,16 @@
11
11
  "bin": {
12
12
  "silex": "./dist/server/cli.js"
13
13
  },
14
- "license": "GPL-3.0",
14
+ "files": [
15
+ "dist/",
16
+ "src/",
17
+ "package.json",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "license": "AGPL-3.0-or-later",
15
22
  "engines": {
16
- "node": ">=12"
23
+ "node": ">=18"
17
24
  },
18
25
  "watch": {
19
26
  "build:css:debug": {
@@ -52,9 +59,9 @@
52
59
  "release": "",
53
60
  "watch": "npm-watch",
54
61
  "start": "node dist/server/index.js",
55
- "start:debug": "cross-env SILEX_DEBUG=true nodemon --watch dist/server dist/server/index.js",
56
- "prepublishOnly": "npm run lint && npm test && npm run build",
57
- "preversion": "npm run prepublishOnly",
62
+ "start:debug": "cross-env FS_ROOT=`pwd`/.silex cross-env SILEX_DEBUG=true nodemon --watch dist/server dist/server/index.js",
63
+ "prepublishOnly": "$npm_execpath run lint && $npm_execpath test && $npm_execpath run build",
64
+ "preversion": "$npm_execpath run prepublishOnly",
58
65
  "build": "run-s build:css:release build:html build:client:release build:server:release",
59
66
  "webpack": "webpack --config webpack.config.js",
60
67
  "build:css:release": "sass --load-path ../../node_modules --load-path node_modules --no-source-map src/css/index.scss dist/client/css/admin.css",
@@ -66,67 +73,67 @@
66
73
  "build:server:release": "tsc -p tsconfig-server-release.json",
67
74
  "build:server:debug": "SILEX_DEBUG=true tsc -p tsconfig-server-debug.json",
68
75
  "lint": "eslint 'src/ts/**/*.ts'",
69
- "lint:fix": "npm run lint -- --fix",
76
+ "lint:fix": "$npm_execpath run lint -- --fix",
70
77
  "test": "node --experimental-vm-modules `node_modules jest`/jest/bin/jest.js",
71
- "test:watch": "npm test -- --watch"
78
+ "test:watch": "$npm_execpath test -- --watch"
72
79
  },
73
80
  "dependencies": {
74
- "@directus/sdk": "^10.3.3",
81
+ "@directus/sdk": "10.3.3",
75
82
  "@silexlabs/grapesjs-directus-storage": "1.0.15",
76
83
  "@silexlabs/grapesjs-fonts": "1.0.12",
77
84
  "@silexlabs/grapesjs-loading": "1.0.8",
78
- "@silexlabs/grapesjs-symbols": "1.0.18",
85
+ "@silexlabs/grapesjs-symbols": "1.0.22",
79
86
  "@silexlabs/grapesjs-ui-suggest-classes": "1.0.23",
80
- "@silexlabs/silex-plugins": "^1.0.10",
87
+ "@silexlabs/silex-plugins": "1.0.10",
81
88
  "adm-zip": "0.5.10",
82
89
  "body-parser": "1.20.2",
83
- "cli": "^1.0.1",
90
+ "cli": "1.0.1",
84
91
  "compression": "1.7.4",
85
92
  "cookie-parser": "1.4.6",
86
93
  "cookie-session": "2.0.0",
87
- "cors": "^2.8.5",
94
+ "cors": "2.8.5",
88
95
  "cross-env": "7.0.3",
89
96
  "express": "4.18.2",
90
97
  "express-force-ssl": "0.3.2",
91
98
  "formidable": "2.1.1",
92
99
  "grapesjs": "0.21.2",
93
- "grapesjs-blocks-basic": "1.0.1",
94
- "grapesjs-custom-code": "1.0.1",
95
- "grapesjs-plugin-forms": "2.0.5",
96
- "grapesjs-style-filter": "1.0.1",
97
- "html-minifier": "^4.0.0",
98
- "lit-html": "2.7.2",
100
+ "grapesjs-blocks-basic": "1.0.2",
101
+ "grapesjs-custom-code": "1.0.2",
102
+ "grapesjs-plugin-forms": "2.0.6",
103
+ "grapesjs-style-filter": "1.0.2",
104
+ "html-minifier": "4.0.0",
105
+ "lit-html": "2.7.4",
99
106
  "mkdirp": "3.0.1",
100
107
  "node_modules-path": "2.0.7",
101
- "node-fetch": "^2.6.9",
108
+ "node-fetch": "2.6.9",
102
109
  "normalize.css": "8.0.1",
103
110
  "object-path": "0.11.8",
104
111
  "promise-sequential": "1.1.1",
105
- "sass": "1.62.0",
112
+ "sass": "1.63.6",
106
113
  "serve-static": "1.15.0"
107
114
  },
108
115
  "devDependencies": {
109
116
  "@types/express": "4.17.17",
110
- "@types/jest": "29.5.1",
111
- "@types/node": "18.16.0",
112
- "@typescript-eslint/eslint-plugin": "^5.59.1",
113
- "@typescript-eslint/parser": "^5.59.1",
114
- "css-loader": "6.7.3",
115
- "eslint": "8.39.0",
117
+ "@types/jest": "29.5.2",
118
+ "@types/node": "20.3.1",
119
+ "@typescript-eslint/eslint-plugin": "5.60.0",
120
+ "@typescript-eslint/parser": "5.60.0",
121
+ "css-loader": "6.8.1",
122
+ "eslint": "8.43.0",
116
123
  "file-loader": "6.2.0",
117
124
  "jest": "29.5.0",
118
- "jest-environment-jsdom": "^29.5.0",
119
- "livereload": "^0.9.3",
125
+ "jest-environment-jsdom": "29.5.0",
126
+ "livereload": "0.9.3",
120
127
  "nodemon": "2.0.22",
121
128
  "npm-run-all": "4.1.5",
122
129
  "npm-watch": "0.11.0",
123
130
  "pug-cli": "1.0.0-alpha6",
124
- "style-loader": "3.3.2",
125
- "ts-jest": "^29.1.0",
126
- "ts-loader": "9.4.2",
127
- "typescript": "5.0.4",
128
- "webpack": "5.80.0",
129
- "webpack-cli": "5.0.2"
131
+ "style-loader": "3.3.3",
132
+ "ts-jest": "29.1.0",
133
+ "ts-loader": "9.4.3",
134
+ "typescript": "5.1.3",
135
+ "webpack": "5.88.0",
136
+ "webpack-cli": "5.1.4"
130
137
  },
131
138
  "repository": {
132
139
  "type": "git",
@@ -52,17 +52,38 @@ exports.del = async function (id) {
52
52
 
53
53
  // List projects
54
54
  exports.list = async function () {
55
- const ids = await readdir(FS_ROOT)
56
- return Promise.all(ids.map(async id => ({
57
- id,
58
- ...await exports.readData(id),
59
- stats: await stat(path(id) + DATA_FILE_NAME),
60
- })))
55
+ try {
56
+ const ids = await readdir(FS_ROOT)
57
+ return Promise.all(ids.map(async id => ({
58
+ id,
59
+ ...await exports.readData(id),
60
+ stats: await stat(path(id) + DATA_FILE_NAME),
61
+ })))
62
+ } catch (error) {
63
+ if (error.code === 'ENOENT') {
64
+ console.log(`\nError: Directory ${FS_ROOT} does not exist.\nIf your want to read from a different folder ues the FS_ROOT environment variable or --fs-root command line argument?\n`);
65
+ const betterError = new Error(`The directory ${FS_ROOT} does not exist`)
66
+ betterError.code = 'ENOENT'
67
+ throw betterError
68
+ }
69
+ throw error
70
+ }
61
71
  }
62
72
  // Read project data
63
73
  exports.readData = async function (id) {
64
- const data = await readFile(path(id) + DATA_FILE_NAME)
65
- return JSON.parse(data.toString())
74
+ const filePath = path(id) + DATA_FILE_NAME
75
+ try {
76
+ const data = await readFile(filePath)
77
+ return JSON.parse(data.toString())
78
+ } catch (error) {
79
+ if (error.code === 'ENOENT') {
80
+ console.log(`\nError: File ${filePath} or directory ${FS_ROOT} do not exist.\nIf your want to read from a different folder use the FS_ROOT environment variable or --fs-root command line argument?\n`);
81
+ const betterError = new Error(`The website ${id} does not exist`)
82
+ betterError.code = 'ENOENT'
83
+ throw betterError
84
+ }
85
+ throw error
86
+ }
66
87
  }
67
88
  // Write project data
68
89
  exports.writeData = async function (id, data) {
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  import { Config, Plugin } from '@silexlabs/silex-plugins'
2
19
  import { getEditorConfig } from './grapesjs'
3
20
  import { CLIENT_CONFIG_FILE_NAME } from '../constants'
@@ -1,4 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  export * from './index'
2
19
  export * from './grapesjs/index'
3
20
  export * from './config'
4
-
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  export const blocksPlugin = (editor, opts) => {
2
19
  // Defaults
3
20
  const options = {
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  import grapesjs from 'grapesjs/dist/grapes.min.js'
2
19
 
3
20
  import { getPageSlug } from '../../page'
@@ -1,4 +1,21 @@
1
- import grapesjs, { EditorConfig } from 'grapesjs'
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import grapesjs from 'grapesjs'
2
19
  import openImport from './openImport'
3
20
 
4
21
  /**
@@ -55,9 +72,9 @@ const plugins = [
55
72
  ]
56
73
  // Check that all plugins are loaded correctly
57
74
  plugins
58
- .filter(p => !p.value)
75
+ .filter(p => typeof p.value !== 'function')
59
76
  .forEach(p => {
60
- throw new Error(`Plugin ${p.name} could not be loaded correctly`)
77
+ throw new Error(`Plugin ${p.name} could not be loaded correctly (${p.value})`)
61
78
  })
62
79
 
63
80
  // ////////////////////
@@ -212,19 +229,24 @@ export function getEditorConfig(id: string, rootUrl: string) {
212
229
  // Keep a ref to the editor singleton
213
230
  let editor
214
231
 
215
- export function initEditor(config: EditorConfig, grapesJsPlugins) {
232
+ export function initEditor(config, grapesJsPlugins) {
216
233
  if(editor) throw new Error('Grapesjs editor already created')
217
234
 
218
- editor = grapesjs.init({
219
- plugins: [
220
- ...grapesJsPlugins,
221
- ...config.plugins,
222
- ],
223
- ...config,
224
- })
235
+ try {
236
+ editor = grapesjs.init({
237
+ plugins: [
238
+ ...grapesJsPlugins,
239
+ ...config.plugins,
240
+ ],
241
+ ...config,
242
+ })
243
+ } catch(e) {
244
+ console.error('Error initializing GrapesJs with plugins:', plugins, e)
245
+ throw e
246
+ }
225
247
 
226
248
  // customize the editor
227
- ;['text']
249
+ ['text']
228
250
  .forEach(id => editor.Blocks.get(id)?.set('category', 'Basics'))
229
251
  ;['image', 'video']
230
252
  .forEach(id => editor.Blocks.get(id)?.set('category', 'Media'))
@@ -258,15 +280,19 @@ export function initEditor(config: EditorConfig, grapesJsPlugins) {
258
280
  editor.StyleManager.addProperty('extra',{ extend: 'filter' })
259
281
  })
260
282
 
261
- editor.StorageManager.onError = (type: string, err: Error) => {
262
- editor.Modal.open(type === 'load' ? {
283
+ // Handle errors
284
+ editor.on('storage:error:load', (err) => {
285
+ editor.Modal.open({
263
286
  title: 'Error loading website',
264
- content: `This website could not be loaded.<br><hr>Error: ${err.message}`,
265
- } : {
287
+ content: `This website could not be loaded.<br><hr>${err}`,
288
+ })
289
+ })
290
+ editor.on('storage:error:store', (err) => {
291
+ editor.Modal.open({
266
292
  title: 'Error saving website',
267
- content: `This website could not be saved.<br><hr>Error: ${err.message}`,
293
+ content: `This website could not be saved.<br><hr>${err}`,
268
294
  })
269
- }
295
+ })
270
296
  }
271
297
 
272
298
  export function getEditor() {
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  import { internalLinksPlugin } from './internal-links'
2
19
  import { expect, test, beforeEach } from '@jest/globals'
3
20
  import grapesjs from 'grapesjs'
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  import {html, render} from 'lit-html'
2
19
  import {map} from 'lit-html/directives/map.js'
3
20
  import grapesjs from 'grapesjs/dist/grapes.min.js'
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  import * as grapesjs from 'grapesjs/dist/grapes.min.js'
2
19
  import {html, render} from 'lit-html'
3
20
  import {live} from 'lit-html/directives/live.js'
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  // from https://github.com/artf/grapesjs-preset-webpage/blob/3e5a9e12998c9a32b6f1199953084163678e6c17/src/commands/openImport.js
2
19
  export default function openImport(editor, config) {
3
20
  const pfx = editor.getConfig('stylePrefix')
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  import * as grapesjs from 'grapesjs/dist/grapes.min.js'
2
19
  import {html, render} from 'lit-html'
3
20