@silexlabs/silex 3.0.0-alpha.49 → 3.0.0-alpha.51

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 (119) hide show
  1. package/dist/client/client/config.d.ts +14 -1
  2. package/dist/client/client/grapesjs/PublicationManager.d.ts +2 -7
  3. package/dist/client/client/publication-transformers.d.ts +41 -0
  4. package/dist/client/css/admin.css +4 -1
  5. package/dist/client/js/main.js +3 -3
  6. package/dist/client/types.d.ts +18 -16
  7. package/dist/plugins/client/client/api.d.ts +83 -0
  8. package/dist/plugins/client/client/api.js +105 -0
  9. package/dist/plugins/client/client/api.js.map +1 -0
  10. package/dist/plugins/client/client/config.d.ts +58 -0
  11. package/dist/plugins/client/client/config.js +80 -0
  12. package/dist/plugins/client/client/config.js.map +1 -0
  13. package/dist/plugins/client/client/events.js +2 -0
  14. package/dist/plugins/client/client/events.js.map +1 -1
  15. package/dist/plugins/client/client/grapesjs/LoginDialog.d.ts +15 -0
  16. package/dist/plugins/client/client/grapesjs/LoginDialog.js +193 -0
  17. package/dist/plugins/client/client/grapesjs/LoginDialog.js.map +1 -0
  18. package/dist/plugins/client/client/grapesjs/PublicationManager.d.ts +70 -0
  19. package/dist/plugins/client/client/grapesjs/PublicationManager.js +310 -0
  20. package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +1 -0
  21. package/dist/plugins/client/client/grapesjs/PublicationUi.d.ts +61 -0
  22. package/dist/plugins/client/client/grapesjs/PublicationUi.js +324 -0
  23. package/dist/plugins/client/client/grapesjs/PublicationUi.js.map +1 -0
  24. package/dist/plugins/client/client/grapesjs/blocks.d.ts +1 -0
  25. package/dist/plugins/client/client/grapesjs/blocks.js +37 -0
  26. package/dist/plugins/client/client/grapesjs/blocks.js.map +1 -0
  27. package/dist/plugins/client/client/grapesjs/index.d.ts +5 -0
  28. package/dist/plugins/client/client/grapesjs/index.js +264 -0
  29. package/dist/plugins/client/client/grapesjs/index.js.map +1 -0
  30. package/dist/plugins/client/client/grapesjs/internal-links.d.ts +1 -0
  31. package/dist/plugins/client/client/grapesjs/internal-links.js +220 -0
  32. package/dist/plugins/client/client/grapesjs/internal-links.js.map +1 -0
  33. package/dist/plugins/client/client/grapesjs/new-page-dialog.d.ts +2 -0
  34. package/dist/plugins/client/client/grapesjs/new-page-dialog.js +83 -0
  35. package/dist/plugins/client/client/grapesjs/new-page-dialog.js.map +1 -0
  36. package/dist/plugins/client/client/grapesjs/openImport.d.ts +9 -0
  37. package/dist/plugins/client/client/grapesjs/openImport.js +74 -0
  38. package/dist/plugins/client/client/grapesjs/openImport.js.map +1 -0
  39. package/dist/plugins/client/client/grapesjs/page-panel.d.ts +3 -0
  40. package/dist/plugins/client/client/grapesjs/page-panel.js +113 -0
  41. package/dist/plugins/client/client/grapesjs/page-panel.js.map +1 -0
  42. package/dist/plugins/client/client/grapesjs/project-bar.d.ts +1 -0
  43. package/dist/plugins/client/client/grapesjs/project-bar.js +106 -0
  44. package/dist/plugins/client/client/grapesjs/project-bar.js.map +1 -0
  45. package/dist/plugins/client/client/grapesjs/rich-text.d.ts +1 -0
  46. package/dist/plugins/client/client/grapesjs/rich-text.js +31 -0
  47. package/dist/plugins/client/client/grapesjs/rich-text.js.map +1 -0
  48. package/dist/plugins/client/client/grapesjs/semantic.d.ts +1 -0
  49. package/dist/plugins/client/client/grapesjs/semantic.js +110 -0
  50. package/dist/plugins/client/client/grapesjs/semantic.js.map +1 -0
  51. package/dist/plugins/client/client/grapesjs/settings.d.ts +2 -0
  52. package/dist/plugins/client/client/grapesjs/settings.js +197 -0
  53. package/dist/plugins/client/client/grapesjs/settings.js.map +1 -0
  54. package/dist/plugins/client/client/grapesjs/storage.d.ts +1 -0
  55. package/dist/plugins/client/client/grapesjs/storage.js +124 -0
  56. package/dist/plugins/client/client/grapesjs/storage.js.map +1 -0
  57. package/dist/plugins/client/client/grapesjs/symbolDialogs.d.ts +3 -0
  58. package/dist/plugins/client/client/grapesjs/symbolDialogs.js +36 -0
  59. package/dist/plugins/client/client/grapesjs/symbolDialogs.js.map +1 -0
  60. package/dist/plugins/client/client/publication-transformers.d.ts +41 -0
  61. package/dist/plugins/client/client/publication-transformers.js +165 -0
  62. package/dist/plugins/client/client/publication-transformers.js.map +1 -0
  63. package/dist/plugins/client/constants.d.ts +29 -0
  64. package/dist/plugins/client/constants.js +46 -0
  65. package/dist/plugins/client/constants.js.map +1 -0
  66. package/dist/plugins/client/plugins/client/11ty.d.ts +17 -0
  67. package/dist/plugins/client/plugins/client/11ty.js +70 -0
  68. package/dist/plugins/client/plugins/client/11ty.js.map +1 -0
  69. package/dist/plugins/client/plugins/client/publicationRenderer.js +59 -21
  70. package/dist/plugins/client/plugins/client/publicationRenderer.js.map +1 -1
  71. package/dist/plugins/client/plugins/client/website-info.js +1 -1
  72. package/dist/plugins/client/plugins/client/website-info.js.map +1 -1
  73. package/dist/plugins/client/types.d.ts +18 -16
  74. package/dist/plugins/client/types.js.map +1 -1
  75. package/dist/plugins/server/plugins/server/FtpConnector.d.ts +2 -1
  76. package/dist/plugins/server/plugins/server/FtpConnector.js +5 -6
  77. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -1
  78. package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +1 -7
  79. package/dist/plugins/server/plugins/server/GitlabConnector.js +124 -112
  80. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
  81. package/dist/plugins/server/server/connectors/FsHosting.d.ts +2 -1
  82. package/dist/plugins/server/server/connectors/FsHosting.js +4 -5
  83. package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -1
  84. package/dist/plugins/server/server/connectors/FsStorage.js +1 -0
  85. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -1
  86. package/dist/plugins/server/server/connectors/connectors.d.ts +2 -1
  87. package/dist/plugins/server/server/connectors/connectors.js.map +1 -1
  88. package/dist/plugins/server/server/jobs.d.ts +6 -0
  89. package/dist/plugins/server/server/jobs.js +3 -1
  90. package/dist/plugins/server/server/jobs.js.map +1 -1
  91. package/dist/plugins/server/types.d.ts +18 -16
  92. package/dist/plugins/server/types.js.map +1 -1
  93. package/dist/server/server/api/publicationApi.js +14 -20
  94. package/dist/server/server/connectors/FsHosting.js +4 -5
  95. package/dist/server/server/connectors/FsStorage.js +1 -0
  96. package/dist/server/server/jobs.js +2 -1
  97. package/package.json +1 -1
  98. package/public/silex.js +23 -0
  99. package/src/css/website-info.scss +4 -1
  100. package/src/ts/client/config.ts +22 -2
  101. package/src/ts/client/events.ts +3 -0
  102. package/src/ts/client/grapesjs/PublicationManager.ts +23 -3
  103. package/src/ts/client/grapesjs/internal-links.ts +0 -2
  104. package/src/ts/client/grapesjs/storage.ts +1 -1
  105. package/src/ts/client/index.ts +4 -0
  106. package/src/ts/client/publication-transformers.test.ts +146 -0
  107. package/src/ts/client/publication-transformers.ts +188 -0
  108. package/src/ts/plugins/client/11ty.ts +89 -0
  109. package/src/ts/plugins/client/publicationRenderer.ts +64 -22
  110. package/src/ts/plugins/client/website-info.ts +1 -1
  111. package/src/ts/plugins/server/FtpConnector.ts +3 -3
  112. package/src/ts/plugins/server/GitlabConnector.ts +128 -109
  113. package/src/ts/server/api/publicationApi.ts +16 -23
  114. package/src/ts/server/connectors/FsHosting.ts +2 -2
  115. package/src/ts/server/connectors/FsStorage.ts +1 -0
  116. package/src/ts/server/connectors/connectors.ts +3 -1
  117. package/src/ts/server/jobs.ts +10 -0
  118. package/src/ts/server/utils/BackwardCompat.ts +530 -529
  119. package/src/ts/types.ts +20 -17
@@ -0,0 +1,324 @@
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
+ import { html, render } from 'lit-html';
18
+ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
19
+ //import { map } from 'lit-html/directives/map.js'
20
+ import { cmdPublicationLogin, cmdPublicationLogout, cmdPublicationStart, PublicationStatus } from './PublicationManager';
21
+ import { ConnectorType } from '../../types';
22
+ import { connectorList } from '../api';
23
+ /**
24
+ * @fileoverview define the publication dialog
25
+ * This is the UI of the publication feature
26
+ * It is a dialog which allows the user to login to a connector and publish the website
27
+ * It also displays the publication status and logs during the publication process
28
+ * This class is used by the PublicationManager
29
+ * This is optional, you can use the PublicationManager without this UI
30
+ * @TODO Use publication events instead of calls from the PublicationManager
31
+ */
32
+ // **
33
+ // Constants
34
+ export const cmdPublish = 'publish-open-dialog';
35
+ // **
36
+ // Utils
37
+ function cleanupLogEntry(arr) {
38
+ return arr[arr.length - 1]
39
+ ?.map(str => str.replace(/\[.*\]/g, '').trim())
40
+ ?.filter(str => !!str)
41
+ ?.join('\n');
42
+ }
43
+ /**
44
+ * Class to manage the publication dialog
45
+ */
46
+ export class PublicationUi {
47
+ editor;
48
+ options;
49
+ /**
50
+ * Dialog state
51
+ */
52
+ isOpen = false;
53
+ /**
54
+ * Dialog content
55
+ */
56
+ errorMessage = '';
57
+ /**
58
+ * Dialog element
59
+ * This is the DOM element of the dialog
60
+ */
61
+ el;
62
+ settings;
63
+ /**
64
+ * Initialize the dialog and the publish button
65
+ */
66
+ constructor(editor, options) {
67
+ this.editor = editor;
68
+ this.options = options;
69
+ // Reference to the dialog element
70
+ this.el = this.createDialogElements();
71
+ // Add the publish command to the editor
72
+ const openDialog = () => this.openDialog();
73
+ const closeDialog = () => this.closeDialog();
74
+ editor.Commands.add(cmdPublish, {
75
+ run(editor) { openDialog(); },
76
+ stop(editor) { closeDialog(); },
77
+ });
78
+ }
79
+ // **
80
+ // Convenient state checkers
81
+ isSuccess(status) {
82
+ return status === PublicationStatus.STATUS_SUCCESS;
83
+ }
84
+ isPending(status) {
85
+ return status === PublicationStatus.STATUS_PENDING;
86
+ }
87
+ isError(status) {
88
+ return status === PublicationStatus.STATUS_ERROR;
89
+ }
90
+ isLoggedOut(status) {
91
+ return status === PublicationStatus.STATUS_LOGGED_OUT;
92
+ }
93
+ isReady(status) {
94
+ return status === PublicationStatus.STATUS_NONE;
95
+ }
96
+ // **
97
+ // Functions to open and close the dialog
98
+ getDialogElements() {
99
+ const el = document.querySelector('#publish-dialog');
100
+ const primary = el?.querySelector('#publish-button--primary');
101
+ const secondary = el?.querySelector('#publish-button--secondary');
102
+ if (!el || !primary || !secondary)
103
+ throw new Error('Publication dialog elements not found');
104
+ return { el, primary, secondary };
105
+ }
106
+ createDialogElements() {
107
+ // Create the dialog element
108
+ const el = document.createElement('div');
109
+ el.id = 'publish-dialog';
110
+ el.className = 'silex-dialog-inline silex-dialog gjs-two-color';
111
+ document.body.append(el);
112
+ // Create the publish button
113
+ this.editor.Panels.addButton(this.options.appendTo, {
114
+ id: 'publish-button',
115
+ className: 'silex-button--size publish-button',
116
+ command: cmdPublish,
117
+ attributes: { title: 'Publish' },
118
+ label: '<span class="fa-solid fa-upload"></span><span class="silex-button--small">Publish</span>',
119
+ });
120
+ return el;
121
+ }
122
+ move(rect) {
123
+ Object.keys(rect).forEach(key => this.el.style[key] = rect[key] + 'px');
124
+ }
125
+ // **
126
+ // Functions to render the dialog
127
+ async renderDialog(job, status) {
128
+ try {
129
+ if (this.isOpen && (!status || !this.settings))
130
+ throw new Error('PublicationUi: open but no status or settings');
131
+ render(html `
132
+ ${!this.isOpen ? '' : this.settings.connector ? await this.renderOpenDialog(job, status) : await this.renderLoginDialog(status)}
133
+ `, this.el);
134
+ if (this.isOpen) {
135
+ this.el.classList.remove('silex-dialog-hide');
136
+ }
137
+ else {
138
+ this.el.classList.add('silex-dialog-hide');
139
+ }
140
+ }
141
+ catch (err) {
142
+ console.error('Error while rendering the dialog', err);
143
+ }
144
+ }
145
+ async renderOpenDialog(job, status) {
146
+ return html `
147
+ <main>
148
+ ${this.isPending(status) ? html `
149
+ <p>Publication in progress</p>
150
+ ` : ''}
151
+ ${this.isReady(status) ? html `
152
+ <p>You are connected to ${this.settings.connector.displayName}</p><p>Click on the publish button to publish your website</p>
153
+ ${this.settings.options && Object.entries(this.settings.options).length && html `<p>Publication options: <ul>${Object.entries(this.settings.options).map(([key, value]) => html `<li>${key}: ${value}</li>`)}</ul></p>`}
154
+ ` : ''}
155
+ ${this.isSuccess(status) ? html `
156
+ <p>Publication success</p>
157
+ ${this.settings.url ? html `<p><a href="${this.settings.url}" target="_blank">Click here to view the published website</a></p>` : ''}
158
+ ` : ''}
159
+ ${this.isError(status) || this.isLoggedOut(status) ? html `
160
+ <p>Publication error</p>
161
+ <div>${unsafeHTML(this.errorMessage)}</div>
162
+ ` : ''}
163
+ ${job && job.message ? html `
164
+ <p>${unsafeHTML(job.message)}</p>
165
+ ` : ''}
166
+ ${this.isPending(status) ? html `
167
+ <progress
168
+ value=""
169
+ style="width: 100%;"
170
+ ></progress>
171
+ ` : ''}
172
+ ${job && job.logs?.length && job.logs[0].length ? html `
173
+ <br><details>
174
+ <summary>Logs</summary>
175
+ <pre style="
176
+ max-width: 100%;
177
+ max-height: 50vh;
178
+ overflow: auto;
179
+ font-size: x-small;
180
+ "
181
+ >${unsafeHTML(cleanupLogEntry(job.logs))}
182
+ </pre>
183
+ </details>
184
+ ` : ''}
185
+ ${job && job.errors?.length && job.errors[0].length ? html `
186
+ <br><details>
187
+ <summary>Errors</summary>
188
+ <pre style="
189
+ max-width: 100%;
190
+ max-height: 50vh;
191
+ overflow: auto;
192
+ font-size: x-small;
193
+ "
194
+ >${unsafeHTML(cleanupLogEntry(job.errors))}
195
+ </pre>
196
+ </details>
197
+ ` : ''}
198
+ </main>
199
+ <footer>
200
+ ${this.isPending(status) || this.isLoggedOut(status) ? '' : html `
201
+ <button
202
+ class="silex-button silex-button--primary"
203
+ id="publish-button--primary"
204
+ @click=${() => this.editor.Commands.run(cmdPublicationStart)}
205
+ >Publish</button>
206
+ `}
207
+ ${this.isLoggedOut(status) ? html `
208
+ <button
209
+ class="silex-button silex-button--primary"
210
+ id="publish-button--primary"
211
+ @click=${() => this.editor.Commands.run(cmdPublicationLogin, this.settings.connector)}
212
+ >Login</button>
213
+ ` : this.settings.connector.disableLogout ? '' : html `
214
+ <button
215
+ class="silex-button silex-button--secondary"
216
+ id="publish-button--secondary"
217
+ @click=${() => this.editor.Commands.run(cmdPublicationLogout)}
218
+ >Logout</button>
219
+ `}
220
+ <button
221
+ class="silex-button silex-button--secondary"
222
+ id="publish-button--secondary"
223
+ @click=${() => this.editor.Commands.stop(cmdPublish)}
224
+ >Close</button>
225
+ </footer>
226
+ `;
227
+ }
228
+ async renderLoginDialog(status) {
229
+ try {
230
+ render(html `<main><p>Loading</p></main>`, this.el);
231
+ const hostingConnectors = await connectorList({ type: ConnectorType.HOSTING });
232
+ const loggedConnector = hostingConnectors.find(connector => connector.isLoggedIn);
233
+ if (loggedConnector) {
234
+ this.settings.connector = loggedConnector;
235
+ return this.renderOpenDialog(null, PublicationStatus.STATUS_NONE);
236
+ }
237
+ return html `
238
+ <main>
239
+ <p>You need to login to publish your website</p>
240
+ ${this.isError(status) || this.isLoggedOut(status) ? html `
241
+ <p>Login error</p>
242
+ <div>${unsafeHTML(this.errorMessage)}</div>
243
+ ` : ''}
244
+ ${hostingConnectors.map(connector => html `
245
+ <button
246
+ class="silex-button silex-button--primary"
247
+ id="publish-button--primary"
248
+ @click=${() => this.editor.Commands.run(cmdPublicationLogin, connector)}
249
+ >Login with ${connector.connectorId}</button>
250
+ `)}
251
+ </main>
252
+ <footer>
253
+ <button
254
+ class="silex-button silex-button--secondary"
255
+ id="publish-button--secondary"
256
+ @click=${() => this.editor.Commands.stop(cmdPublish)}
257
+ >Close</button>
258
+ </footer>
259
+ `;
260
+ }
261
+ catch (err) {
262
+ console.error(err);
263
+ return html `
264
+ <header>
265
+ <h3>Oops</h3>
266
+ </header>
267
+ <main>
268
+ <p>Unable to load hosting connectors</p>
269
+ <p>Something went wrong: ${err.message}</p>
270
+ </main>
271
+ <footer>
272
+ <button
273
+ class="silex-button silex-button--secondary"
274
+ id="publish-button--secondary"
275
+ @click=${() => this.editor.Commands.stop(cmdPublish)}
276
+ >Close</button>
277
+ </footer>
278
+ `;
279
+ }
280
+ }
281
+ displayPending(job, status) {
282
+ this.errorMessage = null;
283
+ this.renderDialog(job, status);
284
+ }
285
+ displayError(message, job, status) {
286
+ console.info(message);
287
+ this.errorMessage = message;
288
+ this.renderDialog(job, status);
289
+ }
290
+ async closeDialog() {
291
+ this.isOpen = false;
292
+ this.renderDialog(null, null);
293
+ }
294
+ async toggleDialog() {
295
+ if (this.isOpen)
296
+ this.closeDialog();
297
+ else
298
+ this.openDialog();
299
+ }
300
+ async openDialog() {
301
+ this.isOpen = true;
302
+ // Position
303
+ const buttonEl = this.editor.Panels.getPanel('options')?.view.el.querySelector('.publish-button');
304
+ if (buttonEl) {
305
+ const rect = buttonEl.getBoundingClientRect();
306
+ const width = 450;
307
+ const padding = 10 * 2;
308
+ const minHeight = 50;
309
+ this.move({
310
+ left: rect.right - width - padding,
311
+ top: rect.bottom + 10,
312
+ width,
313
+ minHeight,
314
+ });
315
+ }
316
+ else {
317
+ console.error('Unable to find publish button');
318
+ }
319
+ // Publication
320
+ //this.editor.Commands.run(cmdPublicationStart)
321
+ this.renderDialog(null, PublicationStatus.STATUS_NONE);
322
+ }
323
+ }
324
+ //# sourceMappingURL=PublicationUi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PublicationUi.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/PublicationUi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAkB,MAA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AA;QAElB,WAAW;QACX,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAA;QACjG,IAAG,QAAQ,EAAE;YACX,MAAM,IAAI,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAA;YAE7C,MAAM,KAAK,GAAG,GAAG,CAAA;YACjB,MAAM,OAAO,GAAG,EAAE,GAAG,CAAC,CAAA;YACtB,MAAM,SAAS,GAAG,EAAE,CAAA;YACpB,IAAI,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK,GAAG,OAAO;gBAClC,GAAG,EAAE,IAAI,CAAC,MAAM,GAAG,EAAE;gBACrB,KAAK;gBACL,SAAS;aACV,CAAC,CAAA;SACH;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;SAC/C;QAED,cAAc;QACd,+CAA+C;QAC/C,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;IACxD,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export declare const blocksPlugin: (editor: any, opts: any) => void;
@@ -0,0 +1,37 @@
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
+ export const blocksPlugin = (editor, opts) => {
18
+ // Defaults
19
+ const options = {
20
+ ...opts,
21
+ };
22
+ // Container block
23
+ const containerId = 'container';
24
+ editor.BlockManager.add(containerId, {
25
+ label: 'Container',
26
+ category: 'Basics',
27
+ attributes: { class: 'container-png' },
28
+ content: {
29
+ type: containerId,
30
+ style: {
31
+ 'min-height': '100px',
32
+ },
33
+ },
34
+ });
35
+ editor.DomComponents.addType(containerId, {});
36
+ };
37
+ //# sourceMappingURL=blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IAC3C,WAAW;IACX,MAAM,OAAO,GAAG;QACd,GAAG,IAAI;KACR,CAAA;IACD,kBAAkB;IAClB,MAAM,WAAW,GAAG,WAAW,CAAA;IAC/B,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE;QACnC,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE,QAAQ;QAClB,UAAU,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE;QACtC,OAAO,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE;gBACL,YAAY,EAAE,OAAO;aACtB;SACF;KACF,CAAC,CAAA;IACF,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC/C,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Editor, EditorConfig } from 'grapesjs';
2
+ import { ConnectorId, WebsiteId } from '../../types';
3
+ export declare function getEditorConfig(id: WebsiteId, connectorId: ConnectorId, rootUrl: string): EditorConfig;
4
+ export declare function initEditor(config: EditorConfig): Promise<Editor>;
5
+ export declare function getEditor(): Editor;
@@ -0,0 +1,264 @@
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
+ import grapesjs from 'grapesjs';
18
+ import openImport from './openImport';
19
+ /**
20
+ * @fileoverview This is where grapes config gets created
21
+ * Handle plugins, options and initialization of the editor
22
+ */
23
+ // ////////////////////
24
+ // Plugins
25
+ // ////////////////////
26
+ import blocksBasicPlugin from 'grapesjs-blocks-basic';
27
+ import styleFilterPlugin from 'grapesjs-style-filter';
28
+ import formPlugin from 'grapesjs-plugin-forms';
29
+ import codePlugin from 'grapesjs-custom-code';
30
+ import uiSuggestClasses from '@silexlabs/grapesjs-ui-suggest-classes';
31
+ import symbolsPlugin from '@silexlabs/grapesjs-symbols';
32
+ import loadingPlugin from '@silexlabs/grapesjs-loading';
33
+ import fontsDialogPlugin, { cmdOpenFonts } from '@silexlabs/grapesjs-fonts';
34
+ import symbolDialogsPlugin, { cmdPromptAddSymbol } from './symbolDialogs';
35
+ import loginDialogPlugin, { cmdLogout } from './LoginDialog';
36
+ import { pagePanelPlugin, cmdTogglePages, cmdAddPage } from './page-panel';
37
+ import { newPageDialog, cmdOpenNewPageDialog } from './new-page-dialog';
38
+ import { projectBarPlugin } from './project-bar';
39
+ import { settingsDialog, cmdOpenSettings } from './settings';
40
+ import { blocksPlugin } from './blocks';
41
+ import { semanticPlugin } from './semantic';
42
+ import { richTextPlugin } from './rich-text';
43
+ import { internalLinksPlugin } from './internal-links';
44
+ import publicationManagerPlugin from './PublicationManager';
45
+ import { storagePlugin } from './storage';
46
+ import { API_PATH, API_WEBSITE_ASSETS_WRITE, API_WEBSITE_PATH } from '../../constants';
47
+ const plugins = [
48
+ { name: './project-bar', value: projectBarPlugin },
49
+ { name: './settings', value: settingsDialog },
50
+ { name: '@silexlabs/grapesjs-fonts', value: fontsDialogPlugin },
51
+ { name: './new-page-dialog', value: newPageDialog },
52
+ { name: './page-panel', value: pagePanelPlugin },
53
+ { name: 'grapesjs-blocks-basic', value: blocksBasicPlugin },
54
+ { name: './blocks', value: blocksPlugin },
55
+ { name: './semantic', value: semanticPlugin },
56
+ { name: './rich-text', value: richTextPlugin },
57
+ { name: 'grapesjs-style-filter', value: styleFilterPlugin },
58
+ { name: 'grapesjs-plugin-forms', value: formPlugin },
59
+ { name: 'grapesjs-custom-code', value: codePlugin },
60
+ { name: './internal-links', value: internalLinksPlugin },
61
+ { name: '@silexlabs/grapesjs-ui-suggest-classes', value: uiSuggestClasses },
62
+ { name: './symbolDialogs', value: symbolDialogsPlugin },
63
+ { name: '@silexlabs/grapesjs-symbols', value: symbolsPlugin },
64
+ { name: './PublicationManager', value: publicationManagerPlugin },
65
+ { name: './storage', value: storagePlugin },
66
+ { name: './LoginDialog', value: loginDialogPlugin },
67
+ { name: '@silexlabs/grapesjs-loading', value: loadingPlugin },
68
+ ];
69
+ // Check that all plugins are loaded correctly
70
+ plugins
71
+ .filter(p => typeof p.value !== 'function')
72
+ .forEach(p => {
73
+ throw new Error(`Plugin ${p.name} could not be loaded correctly (${p.value})`);
74
+ });
75
+ // ////////////////////
76
+ // Config
77
+ // ////////////////////
78
+ const catBasic = 'Containers';
79
+ const catComponents = 'Components';
80
+ export function getEditorConfig(id, connectorId, rootUrl) {
81
+ return {
82
+ container: '#gjs',
83
+ height: '100%',
84
+ showOffsets: true,
85
+ showDevices: true,
86
+ //pageManager: {},
87
+ layerManager: {
88
+ appendTo: '.layer-manager-container',
89
+ },
90
+ blockManager: {
91
+ appendTo: '.block-manager-container',
92
+ },
93
+ assetManager: {
94
+ upload: `${rootUrl}${API_PATH}${API_WEBSITE_PATH}${API_WEBSITE_ASSETS_WRITE}/?websiteId=${id}${connectorId ? `&connectorId=${connectorId}` : ''}`,
95
+ },
96
+ storageManager: {
97
+ autoload: false,
98
+ //type: 'remote',
99
+ type: 'connector',
100
+ options: {
101
+ connector: {
102
+ id,
103
+ connectorId,
104
+ },
105
+ //remote: {
106
+ // urlStore: `${rootUrl}/${API_WEBSITE_WRITE}?id=${id}`,
107
+ // urlLoad: `${rootUrl}/${API_WEBSITE_READ}?id=${id}`,
108
+ //},
109
+ },
110
+ },
111
+ cssIcons: '/css/all.min.css',
112
+ plugins: plugins.map(p => p.value),
113
+ pluginsOpts: {
114
+ [blocksBasicPlugin]: {
115
+ blocks: ['text', 'image', 'video', 'map'],
116
+ category: catBasic,
117
+ //flexGrid: true,
118
+ },
119
+ [projectBarPlugin]: {
120
+ panels: [
121
+ {
122
+ id: 'dash',
123
+ className: 'logo',
124
+ attributes: { title: 'Go to your dashboard' },
125
+ link: '/',
126
+ command: 'open-dash',
127
+ }, {
128
+ id: 'block-manager-btn',
129
+ className: 'block-manager-btn fa fa-fw fa-plus',
130
+ attributes: { title: 'Blocks', containerClassName: 'block-manager-container', },
131
+ command: 'open-blocks',
132
+ }, {
133
+ id: 'symbols-btn',
134
+ className: 'symbols-btn fa-regular fa-gem',
135
+ attributes: { title: 'Symbols', containerClassName: 'symbols-list-container', },
136
+ command: 'open-symbols',
137
+ buttons: [
138
+ {
139
+ id: 'symbol-create-button',
140
+ className: 'pages__add-page fa-solid fa-plus',
141
+ label: 'Create symbol from selection',
142
+ command: cmdPromptAddSymbol,
143
+ },
144
+ ],
145
+ }, {
146
+ id: 'page-panel-btn',
147
+ className: 'page-panel-btn fa fa-fw fa-file',
148
+ attributes: { title: 'Pages', containerClassName: 'page-panel-container', },
149
+ command: cmdTogglePages,
150
+ buttons: [{
151
+ className: 'pages__add-page fa fa-file',
152
+ command: cmdAddPage,
153
+ text: '+',
154
+ }],
155
+ }, {
156
+ id: 'layer-manager-btn',
157
+ className: 'layer-manager-btn fa-solid fa-layer-group',
158
+ attributes: { title: 'Layers', containerClassName: 'layer-manager-container', },
159
+ command: 'open-layers',
160
+ }, {
161
+ id: 'font-dialog-btn',
162
+ className: 'font-manager-btn fa-solid fa-font',
163
+ attributes: { title: 'Fonts' },
164
+ command: cmdOpenFonts,
165
+ }, {
166
+ id: 'settings-dialog-btn',
167
+ className: 'page-panel-btn fa-solid fa-gears',
168
+ attributes: { title: 'Settings' },
169
+ command: cmdOpenSettings,
170
+ }, {
171
+ id: 'spacer',
172
+ attributes: {},
173
+ className: 'project-bar-spacer',
174
+ }, {
175
+ id: 'logout-button',
176
+ className: 'page-panel-btn fa fa-fw fa-sign-out',
177
+ attributes: { title: 'Sign out' },
178
+ command: cmdLogout,
179
+ },
180
+ ],
181
+ },
182
+ [publicationManagerPlugin]: {
183
+ appendTo: 'options',
184
+ websiteId: id,
185
+ },
186
+ [pagePanelPlugin]: {
187
+ cmdOpenNewPageDialog,
188
+ cmdOpenSettings,
189
+ appendTo: '.page-panel-container',
190
+ },
191
+ [uiSuggestClasses]: {
192
+ enableCount: false,
193
+ enablePerformance: false,
194
+ },
195
+ [internalLinksPlugin]: {
196
+ // FIXME: warn the user about links in error
197
+ onError: (errors) => console.log('Links errors:', errors),
198
+ },
199
+ [codePlugin]: {
200
+ blockLabel: 'HTML',
201
+ blockCustomCode: {
202
+ category: catComponents,
203
+ }
204
+ },
205
+ [symbolsPlugin]: {
206
+ appendTo: '.symbols-list-container',
207
+ },
208
+ [fontsDialogPlugin]: {
209
+ api_key: 'AIzaSyAdJTYSLPlKz4w5Iqyy-JAF2o8uQKd1FKc',
210
+ },
211
+ [loginDialogPlugin]: {
212
+ id,
213
+ },
214
+ },
215
+ };
216
+ }
217
+ // ////////////////////
218
+ // Initialize editor
219
+ // ////////////////////
220
+ // Keep a ref to the editor singleton
221
+ let editor;
222
+ export async function initEditor(config) {
223
+ if (editor)
224
+ throw new Error('Grapesjs editor already created');
225
+ return new Promise((resolve, reject) => {
226
+ try {
227
+ editor = grapesjs.init(config);
228
+ }
229
+ catch (e) {
230
+ console.error('Error initializing GrapesJs with plugins:', plugins, e);
231
+ reject(e);
232
+ }
233
+ // customize the editor
234
+ ['text']
235
+ .forEach(id => editor.Blocks.get(id)?.set('category', 'Basics'));
236
+ ['image', 'video']
237
+ .forEach(id => editor.Blocks.get(id)?.set('category', 'Media'));
238
+ ['map']
239
+ .forEach(id => editor.Blocks.get(id)?.set('category', 'Components'));
240
+ editor.Blocks.render([]);
241
+ editor.Commands.add('gjs-open-import-webpage', openImport(editor, {
242
+ modalImportLabel: '',
243
+ modalImportContent: 'Paste a web page HTML code here.',
244
+ modalImportButton: 'Import',
245
+ modalImportTitle: 'Import from website',
246
+ }));
247
+ editor.on('load', () => {
248
+ // remove blocks and layers buttons from the properties
249
+ editor.Panels.getPanel('views').buttons.remove('open-blocks');
250
+ editor.Panels.getPanel('views').buttons.remove('open-layers');
251
+ editor.Panels.getPanel('views').view.el.firstChild.style.justifyContent = 'initial'; // align left
252
+ editor.Panels.getPanel('options').buttons.remove('export-template');
253
+ editor.BlockManager.render(null);
254
+ // use the style filter plugin
255
+ editor.StyleManager.addProperty('extra', { extend: 'filter' });
256
+ // GrapesJs editor is ready
257
+ resolve(editor);
258
+ });
259
+ });
260
+ }
261
+ export function getEditor() {
262
+ return editor;
263
+ }
264
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,QAAkC,MAAM,UAAU,CAAA;AACzD,OAAO,UAAU,MAAM,cAAc,CAAA;AAErC;;;GAGG;AAEH,uBAAuB;AACvB,UAAU;AACV,uBAAuB;AACvB,OAAO,iBAAiB,MAAM,uBAAuB,CAAA;AACrD,OAAO,iBAAiB,MAAM,uBA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