@silexlabs/silex 3.0.0-alpha.151 → 3.0.0-alpha.153

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 (29) hide show
  1. package/dist/client/client/grapesjs/index.d.ts +4 -0
  2. package/dist/client/client/grapesjs/keymaps.d.ts +71 -0
  3. package/dist/client/client/grapesjs/project-bar.d.ts +4 -0
  4. package/dist/client/client/utils.d.ts +7 -0
  5. package/dist/client/css/admin.css +176 -6
  6. package/dist/client/js/main.js +118 -109
  7. package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +40 -9
  8. package/dist/plugins/server/plugins/server/GitlabConnector.js +58 -34
  9. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
  10. package/dist/plugins/server/plugins/server/GitlabHostingConnector.d.ts +18 -0
  11. package/dist/plugins/server/plugins/server/GitlabHostingConnector.js +98 -0
  12. package/dist/plugins/server/plugins/server/GitlabHostingConnector.js.map +1 -0
  13. package/package.json +6 -5
  14. package/src/css/grapesjs-plugins.scss +160 -0
  15. package/src/css/grapesjs.scss +31 -0
  16. package/src/css/project-bar.scss +5 -7
  17. package/src/ts/client/api.ts +8 -1
  18. package/src/ts/client/config.ts +1 -1
  19. package/src/ts/client/grapesjs/PublicationManager.ts +5 -0
  20. package/src/ts/client/grapesjs/PublicationUi.ts +45 -27
  21. package/src/ts/client/grapesjs/css-props.ts +608 -257
  22. package/src/ts/client/grapesjs/index.ts +91 -18
  23. package/src/ts/client/grapesjs/internal-links.ts +11 -1
  24. package/src/ts/client/grapesjs/keymaps.ts +155 -0
  25. package/src/ts/client/grapesjs/project-bar.ts +18 -7
  26. package/src/ts/client/grapesjs/settings.ts +44 -20
  27. package/src/ts/client/utils.ts +33 -9
  28. package/src/ts/plugins/server/GitlabConnector.ts +70 -46
  29. package/src/ts/plugins/server/GitlabHostingConnector.ts +102 -0
@@ -32,3 +32,163 @@
32
32
  @include square-borders-before;
33
33
  border-right-color: $secondaryColor;
34
34
  }
35
+
36
+ // grapesjs-notifications
37
+ .gjs-editor .gjs-notification {
38
+ max-height: initial;
39
+ text-align: left;
40
+ }
41
+ .gjs-editor .gjs-notification,
42
+ .gjs-editor .gjs-notification .gjs-sm-header,
43
+ .gjs-editor .gjs-notification .gjs-notification__item,
44
+ .gjs-editor .gjs-notification .gjs-notification__group > details,
45
+ .gjs-editor .gjs-notification .gjs-notification__group > details > ul,
46
+ .gjs-editor .gjs-notification .gjs-notification__group > details > summary,
47
+ .gjs-editor .gjs-notification .gjs-notification__group {
48
+ padding: 0;
49
+ margin: 0;
50
+ }
51
+ .gjs-editor .gjs-notification .gjs-notification__group,
52
+ .gjs-editor .gjs-notification .gjs-notification__item {
53
+ margin: 10px 0;
54
+ padding: 10px 0;
55
+ }
56
+
57
+ .gjs-editor .gjs-notification .gjs-notification__group .gjs-notification__item {
58
+ margin-left: 10px;
59
+ }
60
+
61
+ // publication-ui
62
+ #publish-dialog {
63
+ header {
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: space-between;
67
+ padding-top: 10px;
68
+ padding-bottom: 10px;
69
+ font-size: 0.95rem;
70
+ transition: 200ms;
71
+
72
+ svg {
73
+ width: 1.4rem;
74
+ vertical-align: middle;
75
+ margin-right: 5px;
76
+ }
77
+
78
+ button {
79
+ border: solid 2px #484848;
80
+ border-radius: 50px;
81
+ padding: 4px 9px;
82
+ background-color: #444;
83
+ color: $secondaryColor;
84
+ }
85
+
86
+ .connector {
87
+ color: $quaternaryColor;
88
+ }
89
+ }
90
+
91
+ main {
92
+ max-height: none;
93
+
94
+ .buttons {
95
+ display: grid;
96
+ grid-template-columns: 1fr;
97
+ grid-template-rows: auto;
98
+ grid-row-gap: 0.5rem;
99
+ transition: 200ms;
100
+ }
101
+
102
+ svg {
103
+ height: 0.9rem;
104
+ margin-left: 5px;
105
+ }
106
+
107
+ h3 {
108
+ margin: 0;
109
+ }
110
+
111
+ p {
112
+ margin-top: 0;
113
+ }
114
+
115
+ details {
116
+ border-radius: 5px;
117
+ border: solid #222 2px;
118
+ background-color: #222;
119
+ margin: 10px 0;
120
+ padding: 10px;
121
+ word-break: break-word;
122
+ overflow-y: auto;
123
+ max-height: 200px;
124
+ position: relative;
125
+
126
+ pre {
127
+ word-break: break-word;
128
+ }
129
+
130
+ summary {
131
+ font-size: 0.95rem;
132
+ opacity: 0.7;
133
+ }
134
+
135
+ .logs {
136
+ font-family: monospace;
137
+
138
+ * {
139
+ margin: 0;
140
+ padding-top: 3px;
141
+ padding-bottom: 3px;
142
+ border-radius: 5px;
143
+ list-style: '-';
144
+
145
+ &:hover {
146
+ transition: 200ms;
147
+ background-color: rgba(255, 255, 255, 0.05);
148
+ }
149
+ }
150
+ }
151
+
152
+ &:hover {
153
+ transition: 200ms;
154
+ border-color: $lighterPrimaryColor;
155
+ background-color: $darkerPrimaryColor;
156
+ }
157
+
158
+ * {
159
+ transition: 200ms;
160
+ }
161
+ }
162
+
163
+ details[open] summary {
164
+ margin-bottom: 10px;
165
+ }
166
+
167
+ .silex-button {
168
+ padding: 10px;
169
+ width: 100%;
170
+ transition: 200ms;
171
+
172
+ &:hover {
173
+ filter: brightness(1.2);
174
+ }
175
+
176
+ &:active {
177
+ filter: brightness(0.8);
178
+ }
179
+ }
180
+
181
+ .silex-button--primary {
182
+ background-color: $tertiaryColor;
183
+ }
184
+ }
185
+ }
186
+
187
+ // Adapting the layout of the suggestion list
188
+ .gjs-suggest {
189
+ max-height: 30vh;
190
+ overflow-y: scroll;
191
+ overflow-x: hidden;
192
+ padding-top: 7px;
193
+ border-bottom: solid $primaryColor 7px;
194
+ }
@@ -90,6 +90,37 @@
90
90
  right: var(--viewsPanelWidth);
91
91
  }
92
92
 
93
+ // Sticky CSS tags section
94
+ .top-style-section {
95
+ position: sticky;
96
+ top: -1px; /* Fixes a visual gap on the top */
97
+ border-bottom: solid $lighterPrimaryColor 1px;
98
+ background-color: $primaryColor;
99
+ box-shadow: 0 0 15px 0 #00000060;
100
+ z-index: 999;
101
+ }
102
+ .gjs-clm-label-sel {
103
+ opacity: 0.5;
104
+ }
105
+ .gjs-clm-sels-info {
106
+ padding: 7px 0;
107
+ margin: 0;
108
+ overflow-x: scroll;
109
+ }
110
+ .gjs-clm-sel-rule {
111
+ word-break: break-all;
112
+ }
113
+ #gjs-clm-tags-field.gjs-field {
114
+ margin: 0;
115
+ }
116
+ .gjs-clm-tags {
117
+ padding-top: 7px;
118
+ padding-bottom: 0;
119
+ }
120
+ #gjs-clm-up {
121
+ margin-top: 0;
122
+ }
123
+
93
124
  /*
94
125
  */
95
126
  // Font awesome 5 fix
@@ -30,7 +30,11 @@
30
30
  background-color: $lighterPrimaryColor;
31
31
  width: $projectBarWidth;
32
32
  box-shadow: none;
33
- }
33
+ }
34
+ }
35
+ .#{$pn-prefix}btn.project-bar__dirty {
36
+ background-color: $quaternaryColor;
37
+ color: white;
34
38
  }
35
39
  }
36
40
  .logo {
@@ -85,13 +89,7 @@
85
89
  }
86
90
  .project-bar__panel-header-button {
87
91
  cursor: pointer;
88
- font-size: large;
89
- font-weight: 400;
90
92
  span {
91
- position: relative;
92
- left: -2px;
93
- top: -11px;
94
- font-weight: bolder;
95
93
  background-color: #444;
96
94
  border-radius: 100%;
97
95
  display: inline-block;
@@ -141,7 +141,14 @@ export async function api<ReqQuery, ReqBody, ResBody>(route: ApiRoute | string,
141
141
  })
142
142
 
143
143
  if (!response.ok) {
144
- const json = await response.json()
144
+ let json
145
+ try {
146
+ json = await response.json()
147
+ } catch (err) {
148
+ // If the response is not JSON, throw a generic error
149
+ // This is the case when Silex backend has an uncatched error, e.g. expressjs 413 PayloadTooLargeError: request entity too large
150
+ throw new ApiError(response.statusText, response.status)
151
+ }
145
152
  throw new ApiError(json.message, response.status)
146
153
  }
147
154
 
@@ -115,7 +115,7 @@ export class ClientConfig extends Config {
115
115
  * @see https://fontlay.com/
116
116
  * @default Google Fonts
117
117
  */
118
- fontsServerUrl = 'https://www.googleapis.com'
118
+ fontsServerUrl = 'https://fonts.googleapis.com'
119
119
 
120
120
  /**
121
121
  * Init GrapesJS config which depend on the config file properties
@@ -298,6 +298,11 @@ export class PublicationManager {
298
298
  data: data as ApiPublicationPublishBody,
299
299
  options: this.settings.options,
300
300
  })
301
+
302
+ // in gitlab pages situation, getUrl from gitlabHostingConnector gives publication url obtained with Gitlab API pages
303
+ console.info('Gitlab url: ', url)
304
+ // could be used in an future UI
305
+
301
306
  this.job = job
302
307
  this.status = jobStatusToPublicationStatus(this.job.status)
303
308
  this.trackProgress()
@@ -21,6 +21,8 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'
21
21
  import { cmdPublicationLogin, cmdPublicationLogout, cmdPublicationStart, PublicationStatus, PublishableEditor } from './PublicationManager'
22
22
  import { ConnectorData, ConnectorType, PublicationJobData, PublicationSettings } from '../../types'
23
23
  import { connectorList } from '../api'
24
+ import { defaultKms } from './keymaps'
25
+ import { titleCase } from '../utils'
24
26
 
25
27
  /**
26
28
  * @fileoverview define the publication dialog
@@ -36,6 +38,12 @@ import { connectorList } from '../api'
36
38
  // Constants
37
39
  export const cmdPublish = 'publish-open-dialog'
38
40
 
41
+ // **
42
+ // Semantic Icons
43
+ const svgConnector = '<svg width="100%" height="100%" viewBox="0 0 44 23" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;"><g><g><path d="M2,11.427c0,0 3.846,-2.655 7.376,0c3.531,2.656 7.45,0 7.45,0" style="fill:none;stroke:#a291ff;stroke-width:4px;"/></g><path d="M32.165,6.424l9.156,0" style="fill:none;stroke:#a291ff;stroke-width:4px;"/><path d="M32.165,2l0,18.854" style="fill:none;stroke:#a291ff;stroke-width:4px;"/><path d="M32.165,16.43l9.156,0" style="fill:none;stroke:#a291ff;stroke-width:4px;"/><path d="M26.253,20.854c-5.203,0 -9.427,-4.224 -9.427,-9.427c-0,-5.203 4.224,-9.427 9.427,-9.427l5.912,-0l0,18.854l-5.912,0Z" style="fill:none;stroke:#a291ff;stroke-width:4px;"/></g></svg>'
44
+ const svgSuccess = '<svg viewBox="0 0 40 28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;"><path d="M3,12.969l11.868,11.869l21.838,-21.838" style="fill:none;stroke:#37bf76;stroke-width:6px;"/></svg>'
45
+ const svgError = '<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;"><g><path d="M3,28.915l25.915,-25.915" style="fill:none;stroke:#cf4443;stroke-width:6px;"/><path d="M28.915,28.915l-25.915,-25.915" style="fill:none;stroke:#cf4443;stroke-width:6px;"/></g></svg>'
46
+
39
47
  // **
40
48
  // Types
41
49
  export type PublicationDialogOptions = {
@@ -132,7 +140,7 @@ export class PublicationUi {
132
140
  id: 'publish-button',
133
141
  className: 'silex-button--size publish-button',
134
142
  command: cmdPublish,
135
- attributes: { title: 'Publish' },
143
+ attributes: { title: `Publish [${titleCase(defaultKms.kmOpenPublish.keys, '+')}]` },
136
144
  label: '<span class="fa-solid fa-upload"></span><span class="silex-button--small">Publish</span>',
137
145
  })
138
146
  })
@@ -152,6 +160,8 @@ export class PublicationUi {
152
160
  `, this.el)
153
161
  if (this.isOpen) {
154
162
  this.el.classList.remove('silex-dialog-hide')
163
+ const primaryBtn = this.el.querySelector('.silex-button--primary') as HTMLElement
164
+ if (primaryBtn) primaryBtn.focus()
155
165
  } else {
156
166
  this.el.classList.add('silex-dialog-hide')
157
167
  }
@@ -162,26 +172,39 @@ export class PublicationUi {
162
172
  async renderOpenDialog(job: PublicationJobData, status: PublicationStatus): Promise<TemplateResult> {
163
173
  return html`
164
174
  <header>
165
- <h3>Publication</h3>
175
+ <span>${unsafeHTML(svgConnector)} Connected to <span class="connector">${this.settings.connector.displayName}</span></span>
176
+ ${this.settings.connector.disableLogout ? '' : html`
177
+ <button
178
+ class="silex-button silex-button--secondary"
179
+ id="publish-button--secondary"
180
+ @click=${() => this.editor.Commands.run(cmdPublicationLogout)}
181
+ >Disconnect
182
+ </button>`}
166
183
  </header>
167
184
  <main>
168
185
  ${this.isPending(status) ? html`
169
- <p>Publication in progress</p>
186
+ <p>Publication in progress...</p>
170
187
  ` : ''}
171
188
  ${this.isReady(status) ? html`
172
- <p>You are connected to ${this.settings.connector.displayName}</p><p>Click on the publish button to publish your website</p>
189
+ <p>Click on the button below to publish your website.</p>
173
190
  ${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>`}
174
191
  ` : ''}
175
192
  ${this.isSuccess(status) ? html`
176
- <p>Publication success</p>
193
+ <h3 class="status">Publication success ${unsafeHTML(svgSuccess)}</h3>
177
194
  ${this.settings.options?.websiteUrl ? html`<p><a href="${this.settings.options.websiteUrl}" target="_blank">Click here to view the published website</a></p>` : ''}
178
195
  ` : ''}
179
196
  ${this.isError(status) || this.isLoggedOut(status) ? html`
180
- <p>Publication error</p>
181
- <div>${unsafeHTML(this.errorMessage)}</div>
197
+ <h3 class="status">Publication error ${unsafeHTML(svgError)}</h3>
198
+ <details open>
199
+ <summary>Details</summary>
200
+ ${unsafeHTML(this.errorMessage)}
201
+ </details>
182
202
  ` : ''}
183
203
  ${job?.message ? html`
184
- <p>${unsafeHTML(job.message)}</p>
204
+ <details open>
205
+ <summary>Details</summary>
206
+ ${unsafeHTML(job.message)}
207
+ </details>
185
208
  ` : ''}
186
209
  ${this.isPending(status) ? html`
187
210
  <progress
@@ -190,17 +213,13 @@ export class PublicationUi {
190
213
  ></progress>
191
214
  ` : ''}
192
215
  ${job?.logs?.length && job.logs[0].length ? html`
193
- <br><details>
216
+ <details>
194
217
  <summary>Logs</summary>
195
- <pre style="
196
- max-width: 100%;
197
- font-size: x-small;
198
- " >${unsafeHTML(cleanupLogEntry(job.logs))}
199
- </pre>
218
+ <div class="logs">${unsafeHTML(cleanupLogEntry(job.logs))}</div>
200
219
  </details>
201
220
  ` : ''}
202
221
  ${job?.errors?.length && job.errors[0].length ? html`
203
- <br><details>
222
+ <details>
204
223
  <summary>Errors</summary>
205
224
  <pre style="
206
225
  max-width: 100%;
@@ -210,8 +229,6 @@ export class PublicationUi {
210
229
  </pre>
211
230
  </details>
212
231
  ` : ''}
213
- </main>
214
- <footer>
215
232
  ${this.isPending(status) || this.isLoggedOut(status) ? '' : html`
216
233
  <button
217
234
  class="silex-button silex-button--primary"
@@ -219,19 +236,16 @@ export class PublicationUi {
219
236
  @click=${() => this.editor.Commands.run(cmdPublicationStart)}
220
237
  >Publish</button>
221
238
  `}
239
+ </main>
240
+ <footer>
222
241
  ${this.isLoggedOut(status) ? html`
223
242
  <button
224
243
  class="silex-button silex-button--primary"
225
244
  id="publish-button--primary"
226
245
  @click=${() => this.editor.Commands.run(cmdPublicationLogin, this.settings.connector)}
227
246
  >Connect</button>
228
- `: this.settings.connector.disableLogout ? '' : html`
229
- <button
230
- class="silex-button silex-button--secondary"
231
- id="publish-button--secondary"
232
- @click=${() => this.editor.Commands.run(cmdPublicationLogout)}
233
- >Disconnect</button>
234
- `}
247
+ `: ''}
248
+ <a href="https://docs.silex.me/en/user/publish" target="_blank">Help</a>
235
249
  <button
236
250
  class="silex-button silex-button--secondary"
237
251
  id="publish-button--secondary"
@@ -256,20 +270,23 @@ export class PublicationUi {
256
270
  //}
257
271
  return html`
258
272
  <main>
259
- <p>You need to connect a hosting connector to publish your website</p>
273
+ <p>You need to select a hosting connector to publish your website.</p>
260
274
  ${this.isError(status) || this.isLoggedOut(status) ? html`
261
275
  <p>Login error</p>
262
276
  <div>${unsafeHTML(this.errorMessage)}</div>
263
277
  ` : ''}
264
- ${hostingConnectors.map(connector => html`
278
+ <div class="buttons">
279
+ ${hostingConnectors.map(connector => html`
265
280
  <button
266
- class="silex-button silex-button--primary"
281
+ class="silex-button"
267
282
  id="publish-button--primary"
268
283
  @click=${() => this.editor.Commands.run(cmdPublicationLogin, connector)}
269
284
  >${connector.displayName}</button>
270
285
  `)}
286
+ </div>
271
287
  </main>
272
288
  <footer>
289
+ <a href="https://docs.silex.me/en/user/publish" target="_blank">Help</a>
273
290
  <button
274
291
  class="silex-button silex-button--secondary"
275
292
  id="publish-button--secondary"
@@ -288,6 +305,7 @@ export class PublicationUi {
288
305
  <p>Something went wrong: ${err.message}</p>
289
306
  </main>
290
307
  <footer>
308
+ <a href="https://docs.silex.me/en/user/publish" target="_blank">Help</a>
291
309
  <button
292
310
  class="silex-button silex-button--secondary"
293
311
  id="publish-button--secondary"