@silexlabs/silex 3.3.1-3 → 3.3.1-5

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/README.md +27 -2
  2. package/dist/client/css/admin.css +26 -9
  3. package/dist/client/index.html +3 -3
  4. package/dist/client/js/main.js +285 -217
  5. package/dist/client/js/main.js.LICENSE.txt +2 -13
  6. package/dist/client/page.d.ts +1 -1
  7. package/dist/client/types.d.ts +1 -17
  8. package/dist/plugins/client/types.d.ts +1 -17
  9. package/dist/plugins/client/types.js.map +1 -1
  10. package/dist/plugins/server/page.d.ts +1 -1
  11. package/dist/plugins/server/page.js.map +1 -1
  12. package/dist/plugins/server/plugins/server/FtpConnector.js +53 -8
  13. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -1
  14. package/dist/plugins/server/plugins/server/GitlabConnector.js +106 -85
  15. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
  16. package/dist/plugins/server/server/connectors/FsStorage.js +50 -4
  17. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -1
  18. package/dist/plugins/server/server/utils/websiteDataSerialization.d.ts +20 -0
  19. package/dist/plugins/server/server/utils/websiteDataSerialization.js +127 -0
  20. package/dist/plugins/server/server/utils/websiteDataSerialization.js.map +1 -0
  21. package/dist/plugins/server/types.d.ts +1 -17
  22. package/dist/plugins/server/types.js.map +1 -1
  23. package/dist/server/page.js +14 -0
  24. package/dist/server/server/cli.js +0 -0
  25. package/dist/server/server/connectors/FsStorage.js +40 -4
  26. package/dist/server/server/utils/websiteDataSerialization.js +85 -0
  27. package/package.json +13 -13
  28. package/src/css/_variables.scss +4 -0
  29. package/src/css/grapesjs-plugins.scss +5 -0
  30. package/src/css/grapesjs.scss +8 -2
  31. package/src/css/loader.scss +9 -6
  32. package/src/css/page-panel.scss +3 -2
  33. package/src/css/project-bar.scss +0 -1
  34. package/src/html/index.pug +1 -1
  35. package/src/ts/client/assetUrl.ts +1 -1
  36. package/src/ts/client/grapesjs/PublicationUi.ts +1 -1
  37. package/src/ts/client/grapesjs/css-props.ts +4 -3
  38. package/src/ts/client/grapesjs/flex.ts +8 -4
  39. package/src/ts/client/grapesjs/img.ts +9 -3
  40. package/src/ts/client/grapesjs/index.ts +9 -11
  41. package/src/ts/client/grapesjs/li.ts +3 -1
  42. package/src/ts/client/grapesjs/sectors.ts +3 -1
  43. package/src/ts/client/grapesjs/storage.ts +25 -30
  44. package/src/ts/client/index.ts +2 -3
  45. package/src/ts/page.ts +1 -1
  46. package/src/ts/plugins/server/FtpConnector.test.ts +2 -1
  47. package/src/ts/plugins/server/FtpConnector.ts +61 -9
  48. package/src/ts/plugins/server/GitlabConnector.ts +112 -102
  49. package/src/ts/server/connectors/FsStorage.test.ts +6 -2
  50. package/src/ts/server/connectors/FsStorage.ts +60 -5
  51. package/src/ts/server/utils/websiteDataSerialization.test.ts +59 -0
  52. package/src/ts/server/utils/websiteDataSerialization.ts +143 -0
  53. package/src/ts/types.ts +2 -20
  54. package/dist/client/css/admin.css.map +0 -1
  55. package/dist/client/grapesjs-filter-styles/dist/index.d.ts +0 -4
  56. package/dist/client/grapesjs-fonts/dist/index.d.ts +0 -4
  57. package/dist/client/grapesjs-fonts/src/commands.d.ts +0 -3
  58. package/dist/client/grapesjs-fonts/src/fonts.d.ts +0 -4
  59. package/dist/client/grapesjs-storage-rate-limit/dist/index.d.ts +0 -4
  60. package/dist/client/grapesjs-ui-suggest-classes/dist/index.d.ts +0 -4
  61. package/dist/client/silex-lib/src/ts/client/api.d.ts +0 -90
  62. package/dist/client/silex-lib/src/ts/client/assetUrl.d.ts +0 -46
  63. package/dist/client/silex-lib/src/ts/client/config.d.ts +0 -102
  64. package/dist/client/silex-lib/src/ts/client/events.d.ts +0 -23
  65. package/dist/client/silex-lib/src/ts/client/expose.d.ts +0 -8
  66. package/dist/client/silex-lib/src/ts/client/grapesjs/LoginDialog.d.ts +0 -15
  67. package/dist/client/silex-lib/src/ts/client/grapesjs/PublicationManager.d.ts +0 -74
  68. package/dist/client/silex-lib/src/ts/client/grapesjs/PublicationUi.d.ts +0 -59
  69. package/dist/client/silex-lib/src/ts/client/grapesjs/blocks.d.ts +0 -1
  70. package/dist/client/silex-lib/src/ts/client/grapesjs/breadcrumbs.d.ts +0 -1
  71. package/dist/client/silex-lib/src/ts/client/grapesjs/css-props.d.ts +0 -6
  72. package/dist/client/silex-lib/src/ts/client/grapesjs/flex.d.ts +0 -7
  73. package/dist/client/silex-lib/src/ts/client/grapesjs/footer.d.ts +0 -2
  74. package/dist/client/silex-lib/src/ts/client/grapesjs/img.d.ts +0 -6
  75. package/dist/client/silex-lib/src/ts/client/grapesjs/index.d.ts +0 -9
  76. package/dist/client/silex-lib/src/ts/client/grapesjs/internal-links.d.ts +0 -1
  77. package/dist/client/silex-lib/src/ts/client/grapesjs/keymaps.d.ts +0 -123
  78. package/dist/client/silex-lib/src/ts/client/grapesjs/li.d.ts +0 -7
  79. package/dist/client/silex-lib/src/ts/client/grapesjs/new-page-dialog.d.ts +0 -2
  80. package/dist/client/silex-lib/src/ts/client/grapesjs/openImport.d.ts +0 -9
  81. package/dist/client/silex-lib/src/ts/client/grapesjs/page-panel.d.ts +0 -9
  82. package/dist/client/silex-lib/src/ts/client/grapesjs/project-bar.d.ts +0 -21
  83. package/dist/client/silex-lib/src/ts/client/grapesjs/resize-panel.d.ts +0 -1
  84. package/dist/client/silex-lib/src/ts/client/grapesjs/rich-text.d.ts +0 -4
  85. package/dist/client/silex-lib/src/ts/client/grapesjs/scroll.d.ts +0 -7
  86. package/dist/client/silex-lib/src/ts/client/grapesjs/sectors.d.ts +0 -11
  87. package/dist/client/silex-lib/src/ts/client/grapesjs/semantic.d.ts +0 -1
  88. package/dist/client/silex-lib/src/ts/client/grapesjs/settings-sections.d.ts +0 -16
  89. package/dist/client/silex-lib/src/ts/client/grapesjs/settings.d.ts +0 -4
  90. package/dist/client/silex-lib/src/ts/client/grapesjs/storage.d.ts +0 -3
  91. package/dist/client/silex-lib/src/ts/client/grapesjs/symbolDialogs.d.ts +0 -3
  92. package/dist/client/silex-lib/src/ts/client/grapesjs/upload-progress.d.ts +0 -2
  93. package/dist/client/silex-lib/src/ts/client/grapesjs/view-buttons.d.ts +0 -1
  94. package/dist/client/silex-lib/src/ts/client/index.d.ts +0 -10
  95. package/dist/client/silex-lib/src/ts/client/publication-transformers.d.ts +0 -42
  96. package/dist/client/silex-lib/src/ts/client/publish-custom-code-block.d.ts +0 -4
  97. package/dist/client/silex-lib/src/ts/client/publish-fonts.d.ts +0 -4
  98. package/dist/client/silex-lib/src/ts/client/utils.d.ts +0 -22
  99. package/dist/client/silex-lib/src/ts/constants.d.ts +0 -33
  100. package/dist/client/silex-lib/src/ts/page.d.ts +0 -2
  101. package/dist/client/silex-lib/src/ts/types.d.ts +0 -341
  102. package/src/ts/client/grapesjs/dynamic-plugins.ts +0 -63
  103. package/src/ts/client/grapesjs/plugin-options.ts +0 -243
@@ -1,341 +0,0 @@
1
- /**
2
- * @fileoverview define types for Silex client and server
3
- */
4
- export interface PublicationSettings {
5
- connector?: ConnectorData;
6
- options?: ConnectorOptions;
7
- }
8
- export interface WebsiteFile {
9
- html: string;
10
- css: string;
11
- htmlPath: string;
12
- cssPath: string;
13
- }
14
- export declare class ApiError extends Error {
15
- readonly httpStatusCode: number;
16
- constructor(message: string, httpStatusCode: number);
17
- }
18
- export type ApiResponseError = {
19
- message: string;
20
- };
21
- export type ApiPublicationPublishBody = WebsiteData;
22
- export type ApiPublicationPublishQuery = {
23
- websiteId: WebsiteId;
24
- hostingId: ConnectorId;
25
- storageId: ConnectorId;
26
- options: ConnectorOptions;
27
- };
28
- export type ApiPublicationPublishResponse = {
29
- url: string;
30
- job: PublicationJobData;
31
- };
32
- export type ApiPublicationStatusQuery = {
33
- jobId: JobId;
34
- };
35
- export type ApiPublicationStatusResponse = PublicationJobData;
36
- export type ApiWebsiteReadQuery = {
37
- websiteId: WebsiteId;
38
- connectorId?: ConnectorId;
39
- };
40
- export type ApiWebsiteReadResponse = WebsiteData;
41
- export type ApiWebsiteListQuery = {
42
- connectorId?: ConnectorId;
43
- };
44
- export type ApiWebsiteListResponse = WebsiteMeta[];
45
- export type ApiWebsiteWriteQuery = {
46
- websiteId: WebsiteId;
47
- connectorId?: ConnectorId;
48
- };
49
- export type ApiWebsiteWriteBody = WebsiteData;
50
- export type ApiWebsiteWriteResponse = {
51
- message: string;
52
- };
53
- export type ApiWebsiteCreateQuery = {
54
- connectorId?: ConnectorId;
55
- };
56
- export type ApiWebsiteCreateBody = WebsiteMetaFileContent;
57
- export type ApiWebsiteCreateResponse = {
58
- message: string;
59
- };
60
- export type ApiWebsiteDeleteQuery = {
61
- websiteId: WebsiteId;
62
- connectorId?: ConnectorId;
63
- };
64
- export type ApiWebsiteDuplicateQuery = {
65
- websiteId: WebsiteId;
66
- connectorId?: ConnectorId;
67
- };
68
- export type ApiWebsiteMetaReadQuery = {
69
- websiteId: WebsiteId;
70
- connectorId?: ConnectorId;
71
- };
72
- export type ApiWebsiteMetaReadResponse = WebsiteMeta;
73
- export type ApiWebsiteMetaWriteQuery = {
74
- websiteId: WebsiteId;
75
- connectorId?: ConnectorId;
76
- };
77
- export type ApiWebsiteMetaWriteBody = WebsiteMetaFileContent;
78
- export type ApiWebsiteMetaWriteResponse = {
79
- message: string;
80
- };
81
- export type ApiWebsiteAssetsReadQuery = {
82
- websiteId: WebsiteId;
83
- connectorId?: ConnectorId;
84
- };
85
- export type ApiWebsiteAssetsReadParams = {
86
- path: string;
87
- };
88
- export type ApiWebsiteAssetsReadResponse = string;
89
- export type ApiWebsiteAssetsWriteQuery = {
90
- websiteId: WebsiteId;
91
- connectorId?: ConnectorId;
92
- };
93
- export type ApiWebsiteAssetsWriteBody = ClientSideFile[];
94
- export type ApiWebsiteAssetsWriteResponse = {
95
- data: string[];
96
- };
97
- export type ApiConnectorListQuery = {
98
- type: ConnectorType;
99
- };
100
- export type ApiConnectorListResponse = ConnectorData[];
101
- export type ApiConnectorLoginQuery = {
102
- connectorId: ConnectorId;
103
- type: ConnectorType;
104
- };
105
- export type ApiConnectorLoggedInPostMessage = {
106
- type: string;
107
- error: boolean;
108
- message: string;
109
- connectorId: ConnectorId;
110
- options: ConnectorOptions;
111
- };
112
- export type ApiConnectorLoginCbkQuery = {
113
- connectorId?: ConnectorId;
114
- type: ConnectorType;
115
- error?: string;
116
- };
117
- export type ApiConnectorLoginCbkBody = object;
118
- export type ApiConnectorSettingsQuery = {
119
- connectorId?: ConnectorId;
120
- type: ConnectorType;
121
- };
122
- export type ApiConnectorSettingsResponse = string;
123
- export type ApiConnectorSettingsPostQuery = {
124
- connectorId?: ConnectorId;
125
- type: ConnectorType;
126
- };
127
- export type ApiConnectorSettingsPostBody = ConnectorUserSettings;
128
- export type ApiConnectorSettingsPostResponse = {
129
- message: string;
130
- };
131
- export type ApiConnectorLogoutQuery = {
132
- connectorId?: ConnectorId;
133
- type: ConnectorType;
134
- };
135
- export type ApiConnectorUserQuery = {
136
- connectorId?: ConnectorId;
137
- type: ConnectorType;
138
- };
139
- export type ApiConnectorUserResponse = ConnectorUser;
140
- export declare const defaultWebsiteData: WebsiteData;
141
- export interface Component {
142
- type: string;
143
- content?: string;
144
- attributes: {
145
- [key: string]: string;
146
- };
147
- components: Component[];
148
- }
149
- export interface Page {
150
- id: string;
151
- name: string;
152
- slug: string;
153
- settings: WebsiteSettings;
154
- frames: {
155
- component: Component;
156
- }[];
157
- }
158
- export interface WebsiteData {
159
- pages: Page[];
160
- assets: Asset[];
161
- styles: Style[];
162
- settings: WebsiteSettings;
163
- fonts: Font[];
164
- symbols: symbol[];
165
- publication: PublicationSettings;
166
- }
167
- export interface PublicationData extends WebsiteData {
168
- files?: ClientSideFile[];
169
- }
170
- export interface WebsiteSettings {
171
- description?: string;
172
- title?: string;
173
- lang?: string;
174
- head?: string;
175
- favicon?: string;
176
- 'og:title'?: string;
177
- 'og:description'?: string;
178
- 'og:image'?: string;
179
- }
180
- export interface Font {
181
- name: string;
182
- value: string;
183
- variants: string[];
184
- }
185
- export declare enum Unit {
186
- PX = "px"
187
- }
188
- export interface Asset {
189
- type: string;
190
- src: string;
191
- unitDim: Unit;
192
- height: number;
193
- width: number;
194
- name: string;
195
- path?: string;
196
- }
197
- export interface Style {
198
- selectors: Selector[];
199
- style: {
200
- [key: string]: string;
201
- };
202
- }
203
- export type Selector = string | {
204
- name: string;
205
- type: number;
206
- };
207
- /**
208
- * Type for a connector id
209
- */
210
- export type ConnectorId = string;
211
- export type ConnectorOptions = {
212
- websiteUrl?: string;
213
- [key: string]: any;
214
- };
215
- export declare enum ClientSideFileType {
216
- HTML = "html",
217
- ASSET = "asset",
218
- CSS = "css",
219
- OTHER = "other"
220
- }
221
- export declare enum Initiator {
222
- HTML = "html",
223
- CSS = "css"
224
- }
225
- /**
226
- * Type for a client side file when the content is not available, used to handle file names and paths and urls
227
- */
228
- export interface ClientSideFileWithPermalink {
229
- path: string;
230
- permalink?: string;
231
- type: ClientSideFileType;
232
- }
233
- /**
234
- * Type for a client side file when the content is available as a string
235
- */
236
- export interface ClientSideFileWithContent extends ClientSideFileWithPermalink {
237
- content: string;
238
- }
239
- /**
240
- * Type for a client side file when the content is in the connector
241
- */
242
- export interface ClientSideFileWithSrc extends ClientSideFileWithPermalink {
243
- src: string;
244
- }
245
- /**
246
- * Type for a client side file
247
- * @see connector/File
248
- */
249
- export type ClientSideFile = ClientSideFileWithContent | ClientSideFileWithSrc;
250
- /**
251
- * Type for file listing
252
- */
253
- export interface FileMeta {
254
- name: string;
255
- isDir: boolean;
256
- size: number;
257
- createdAt: Date;
258
- updatedAt: Date;
259
- metadata?: object;
260
- }
261
- /**
262
- * Enum to express if the connector is a storage or a hosting
263
- */
264
- export declare enum ConnectorType {
265
- STORAGE = "STORAGE",
266
- HOSTING = "HOSTING"
267
- }
268
- /**
269
- * Type for a website id
270
- */
271
- export type WebsiteId = string;
272
- /**
273
- * Back end data shared with the front end
274
- */
275
- export interface ConnectorData {
276
- connectorId: ConnectorId;
277
- type: ConnectorType;
278
- displayName: string;
279
- icon: string;
280
- disableLogout: boolean;
281
- isLoggedIn: boolean;
282
- oauthUrl: string | null;
283
- color: string;
284
- background: string;
285
- }
286
- /**
287
- * User settings for a connector and for a given website
288
- */
289
- export type ConnectorUserSettings = {
290
- [websiteId: string]: object;
291
- };
292
- /**
293
- * Back end data shared with the front end
294
- */
295
- export interface ConnectorUser {
296
- name: string;
297
- email?: string;
298
- picture?: string;
299
- storage: ConnectorData;
300
- }
301
- export interface WebsiteMetaFileContent {
302
- name: string;
303
- imageUrl?: string;
304
- connectorUserSettings: ConnectorUserSettings;
305
- }
306
- /**
307
- * Back end data sent to the front end
308
- * Meta data can be the root path of the websites, or the bucket name, etc.
309
- */
310
- export interface WebsiteMeta extends WebsiteMetaFileContent {
311
- websiteId: WebsiteId;
312
- createdAt?: Date;
313
- updatedAt?: Date;
314
- }
315
- /**
316
- * Enum to express if the job is in progress or finished or errored
317
- */
318
- export declare enum JobStatus {
319
- IN_PROGRESS = "IN_PROGRESS",
320
- SUCCESS = "SUCCESS",
321
- ERROR = "ERROR"
322
- }
323
- /**
324
- * Id used to track the progress of a publication
325
- */
326
- export type JobId = string;
327
- /**
328
- * Data structure which is sent to the client to display the progress of a job
329
- */
330
- export interface JobData {
331
- jobId: JobId;
332
- status: JobStatus;
333
- message: string;
334
- _timeout?: ReturnType<typeof setTimeout>;
335
- }
336
- export interface PublicationJobData extends JobData {
337
- logs: string[][];
338
- errors: string[][];
339
- startTime?: number;
340
- endTime?: number;
341
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * Dynamic plugin loader for external GrapesJS plugins
3
- * These plugins are loaded at runtime to reduce initial bundle size
4
- */
5
-
6
- export interface PluginDefinition {
7
- name: string
8
- value: any
9
- }
10
-
11
- /**
12
- * Load all external plugins dynamically
13
- */
14
- export async function loadDynamicPlugins(): Promise<PluginDefinition[]> {
15
- const [
16
- blocksBasicPlugin,
17
- styleFilterPlugin,
18
- formPlugin,
19
- codePlugin,
20
- filterStyles,
21
- symbolsPlugin,
22
- loadingPlugin,
23
- fontsDialogPlugin,
24
- selectorPlugin,
25
- rateLimitPlugin,
26
- borderPlugin,
27
- backgroundPlugin,
28
- notificationsPlugin,
29
- keymapsDialogPlugin,
30
- ] = await Promise.all([
31
- import('grapesjs-blocks-basic').then(m => m.default),
32
- import('grapesjs-style-filter').then(m => m.default),
33
- import('grapesjs-plugin-forms').then(m => m.default),
34
- import('grapesjs-custom-code').then(m => m.default),
35
- import('@silexlabs/grapesjs-filter-styles').then(m => m.default),
36
- import('@silexlabs/grapesjs-symbols').then(m => m.default),
37
- import('@silexlabs/grapesjs-loading').then(m => m.default),
38
- import('@silexlabs/grapesjs-fonts').then(m => m.default),
39
- import('@silexlabs/grapesjs-advanced-selector').then(m => m.default),
40
- import('@silexlabs/grapesjs-storage-rate-limit').then(m => m.default),
41
- import('grapesjs-style-border').then(m => m.default),
42
- import('grapesjs-style-bg').then(m => m.default),
43
- import('@silexlabs/grapesjs-notifications').then(m => m.default),
44
- import('@silexlabs/grapesjs-keymaps-dialog').then(m => m.default),
45
- ])
46
-
47
- return [
48
- { name: 'grapesjs-blocks-basic', value: blocksBasicPlugin },
49
- { name: 'grapesjs-style-filter', value: styleFilterPlugin },
50
- { name: 'grapesjs-plugin-forms', value: formPlugin },
51
- { name: 'grapesjs-custom-code', value: codePlugin },
52
- { name: '@silexlabs/grapesjs-filter-styles', value: filterStyles },
53
- { name: '@silexlabs/grapesjs-symbols', value: symbolsPlugin },
54
- { name: '@silexlabs/grapesjs-loading', value: loadingPlugin },
55
- { name: '@silexlabs/grapesjs-fonts', value: fontsDialogPlugin },
56
- { name: '@silexlabs/grapesjs-advanced-selector', value: selectorPlugin },
57
- { name: '@silexlabs/grapesjs-storage-rate-limit', value: rateLimitPlugin },
58
- { name: 'grapesjs-style-border', value: borderPlugin },
59
- { name: 'grapesjs-style-bg', value: backgroundPlugin },
60
- { name: '@silexlabs/grapesjs-notifications', value: notificationsPlugin },
61
- { name: '@silexlabs/grapesjs-keymaps-dialog', value: keymapsDialogPlugin },
62
- ]
63
- }
@@ -1,243 +0,0 @@
1
- /**
2
- * Plugin options configuration for all GrapesJS plugins
3
- */
4
-
5
- import { EditorConfig } from 'grapesjs'
6
- import { PluginDefinition } from './dynamic-plugins'
7
- import { staticPlugins, cmdPromptAddSymbol, cmdTogglePages, cmdAddPage, cmdOpenSettings, PROJECT_BAR_PANEL_ID, cmdOpenNewPageDialog } from './static-plugins'
8
- import { NotificationEditor } from '@silexlabs/grapesjs-notifications'
9
- import { cmdKeymapsDialog } from '@silexlabs/grapesjs-keymaps-dialog'
10
- // Commands will be imported from the main index file
11
- export const cmdToggleLayers = 'open-layers'
12
- export const cmdToggleBlocks = 'open-blocks'
13
- export const cmdToggleSymbols = 'open-symbols'
14
- export const cmdToggleNotifications = 'open-notifications'
15
- import { ClientConfig } from '../config'
16
- import { titleCase } from '../utils'
17
- import { defaultKms } from './keymaps'
18
-
19
- // Constants
20
- const PRIMARY_COLOR = '#333333'
21
- const SECONDARY_COLOR = '#ddd'
22
- const TERTIARY_COLOR = '#8873FE'
23
- const QUATERNARY_COLOR = '#A291FF'
24
- const catBasic = 'Containers'
25
- const catComponents = 'Components'
26
-
27
- // Create notification container
28
- const notificationContainer = document.createElement('div')
29
-
30
- /**
31
- * Get plugin options for static plugins
32
- */
33
- export function getStaticPluginOptions(config: ClientConfig) {
34
- const { websiteId, storageId } = config
35
-
36
- const projectBarPluginValue = staticPlugins.find(p => p.name === './project-bar')?.value
37
- const imgPluginValue = staticPlugins.find(p => p.name === './img')?.value
38
- const pagePanelPluginValue = staticPlugins.find(p => p.name === './page-panel')?.value
39
- const internalLinksPluginValue = staticPlugins.find(p => p.name === './internal-links')?.value
40
- const keymapsPluginValue = staticPlugins.find(p => p.name === './keymaps')?.value
41
- const loginDialogPluginValue = staticPlugins.find(p => p.name === './LoginDialog')?.value
42
-
43
- return {
44
- [projectBarPluginValue?.toString()]: {
45
- panels: [
46
- {
47
- id: 'dash',
48
- className: 'logo',
49
- attributes: { title: 'Dashboard' },
50
- command: () => {
51
- window.location.href = '/'
52
- },
53
- }, {
54
- id: 'block-manager-btn',
55
- className: 'block-manager-btn fa fa-fw fa-plus',
56
- name: 'Blocks',
57
- attributes: { title: `Blocks (${titleCase(defaultKms.kmBlocks.keys, '+')})`, containerClassName: 'block-manager-container', },
58
- command: cmdToggleBlocks,
59
- }, {
60
- id: 'symbols-btn',
61
- className: 'symbols-btn fa-regular fa-gem',
62
- name: 'Symbols',
63
- attributes: { title: `Symbols (${titleCase(defaultKms.kmSymbols.keys, '+')})`, containerClassName: 'symbols-list-container', },
64
- command: cmdToggleSymbols,
65
- buttons: [
66
- {
67
- id: 'symbol-create-button',
68
- className: 'gjs-pn-btn',
69
- command: cmdPromptAddSymbol,
70
- text: '\u271A',
71
- },
72
- ],
73
- }, {
74
- id: 'page-panel-btn',
75
- className: 'page-panel-btn fa fa-fw fa-file',
76
- name: 'Pages',
77
- attributes: { title: `Pages (${titleCase(defaultKms.kmPages.keys, '+')})`, containerClassName: 'page-panel-container', },
78
- command: cmdTogglePages,
79
- buttons: [{
80
- className: 'gjs-pn-btn',
81
- command: cmdAddPage,
82
- text: '\u271A',
83
- }],
84
- }, {
85
- id: 'layer-manager-btn',
86
- className: 'layer-manager-btn fa-solid fa-layer-group',
87
- name: 'Layers',
88
- attributes: { title: `Layers (${titleCase(defaultKms.kmLayers.keys, '+')})`, containerClassName: 'layer-manager-container', },
89
- command: cmdToggleLayers,
90
- }, {
91
- id: 'font-dialog-btn',
92
- className: 'font-manager-btn fa-solid fa-font',
93
- name: 'Fonts',
94
- attributes: { title: `Fonts (${titleCase(defaultKms.kmOpenFonts.keys, '+')})` },
95
- command: () => {
96
- // @ts-ignore - editor will be available at runtime
97
- editor.runCommand('open-fonts')
98
- },
99
- }, {
100
- id: 'settings-dialog-btn',
101
- className: 'page-panel-btn fa-solid fa-gears',
102
- name: 'Settings',
103
- attributes: { title: `Settings (${titleCase(defaultKms.kmOpenSettings.keys, '+')})` },
104
- command: cmdOpenSettings,
105
- }, {
106
- id: 'spacer',
107
- attributes: {},
108
- className: 'project-bar-spacer',
109
- }, {
110
- id: 'keymaps-btn',
111
- className: 'keymaps-btn fa-solid fa-keyboard',
112
- name: 'Shortcuts',
113
- attributes: { title: 'Keyboard Shortcuts (Shift+H)' },
114
- command: cmdKeymapsDialog,
115
- }, {
116
- id: 'notifications-btn',
117
- className: 'notifications-btn fa-regular fa-bell',
118
- name: 'Notifications',
119
- attributes: { title: `Notifications (${titleCase(defaultKms.kmNotifications.keys, '+')})`, containerClassName: 'notifications-container', },
120
- command: cmdToggleNotifications,
121
- }, {
122
- id: 'logout-btn',
123
- className: 'logout-btn fa fa-fw fa-power-off',
124
- name: 'Logout',
125
- attributes: { title: 'Logout' },
126
- command: () => {
127
- // @ts-ignore - editor will be available at runtime
128
- editor.runCommand('logout')
129
- },
130
- }],
131
- },
132
- ...(pagePanelPluginValue && {
133
- [pagePanelPluginValue.toString()]: {
134
- cmdOpenNewPageDialog,
135
- cmdOpenSettings,
136
- appendTo: '.page-panel-container',
137
- }
138
- }),
139
- ...(internalLinksPluginValue && {
140
- [internalLinksPluginValue.toString()]: {
141
- // FIXME: warn the user about links in error
142
- onError: (errors: any) => console.warn('Links errors:', errors),
143
- }
144
- }),
145
- ...(keymapsPluginValue && {
146
- [keymapsPluginValue.toString()]: {
147
- disableKeymaps: false,
148
- }
149
- }),
150
- ...(loginDialogPluginValue && {
151
- [loginDialogPluginValue.toString()]: {
152
- id: websiteId,
153
- }
154
- }),
155
- ...(imgPluginValue && {
156
- [imgPluginValue.toString()]: {
157
- replacedElements: config.replacedElements,
158
- websiteId,
159
- storageId,
160
- }
161
- }),
162
- }
163
- }
164
-
165
- /**
166
- * Get plugin options for dynamic plugins
167
- */
168
- export function getDynamicPluginOptions(dynamicPlugins: PluginDefinition[], config: ClientConfig) {
169
- const options: any = {}
170
-
171
- dynamicPlugins.forEach(plugin => {
172
- const pluginKey = plugin.value.toString()
173
-
174
- switch (plugin.name) {
175
- case 'grapesjs-blocks-basic':
176
- options[pluginKey] = {
177
- blocks: ['text', 'image', 'video', 'map'],
178
- category: catBasic,
179
- }
180
- break
181
-
182
- case '@silexlabs/grapesjs-fonts':
183
- options[pluginKey] = {
184
- api_key: (config as any).fontsApiKey || 'dummy-key-for-development',
185
- server_url: (config as any).fontsServerUrl,
186
- api_url: (config as any).fontsApiUrl,
187
- }
188
- break
189
-
190
- case '@silexlabs/grapesjs-filter-styles':
191
- options[pluginKey] = {
192
- appendBefore: '.gjs-sm-sectors',
193
- }
194
- break
195
-
196
- case 'grapesjs-custom-code':
197
- options[pluginKey] = {
198
- blockLabel: 'HTML',
199
- blockCustomCode: {
200
- category: catComponents,
201
- },
202
- codeViewOptions: {
203
- autoFormat: false,
204
- },
205
- }
206
- break
207
-
208
- case '@silexlabs/grapesjs-symbols':
209
- options[pluginKey] = {
210
- appendTo: '.symbols-list-container',
211
- emptyText: 'No symbol yet.',
212
- primaryColor: PRIMARY_COLOR,
213
- secondaryColor: SECONDARY_COLOR,
214
- highlightColor: TERTIARY_COLOR,
215
- }
216
- break
217
-
218
- case '@silexlabs/grapesjs-storage-rate-limit':
219
- options[pluginKey] = {
220
- time: 5000,
221
- }
222
- break
223
-
224
- case '@silexlabs/grapesjs-notifications':
225
- options[pluginKey] = {
226
- container: notificationContainer,
227
- reverse: true,
228
- }
229
- break
230
-
231
- case '@silexlabs/grapesjs-keymaps-dialog':
232
- options[pluginKey] = {
233
- longPressDuration: null,
234
- shortcut: 'shift+h',
235
- }
236
- break
237
- }
238
- })
239
-
240
- return options
241
- }
242
-
243
- export { notificationContainer }