@silexlabs/silex 3.0.1-0 → 3.0.1

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 (250) hide show
  1. package/.env.default +3 -2
  2. package/.silex.js +39 -1
  3. package/README.md +37 -35
  4. package/dist/client/client/api.d.ts +8 -1
  5. package/dist/client/client/assetUrl.d.ts +54 -0
  6. package/dist/client/client/config.d.ts +60 -1
  7. package/dist/client/client/events.d.ts +19 -10
  8. package/dist/client/client/grapesjs/PublicationManager.d.ts +6 -8
  9. package/dist/client/client/grapesjs/PublicationUi.d.ts +8 -10
  10. package/dist/client/client/grapesjs/breadcrumbs.d.ts +1 -0
  11. package/dist/client/client/grapesjs/css-props.d.ts +6 -0
  12. package/dist/client/client/grapesjs/footer.d.ts +2 -0
  13. package/dist/client/client/grapesjs/img.d.ts +6 -0
  14. package/dist/client/client/grapesjs/index.d.ts +6 -2
  15. package/dist/client/client/grapesjs/internal-links.d.ts +1 -1
  16. package/dist/client/client/grapesjs/keymaps.d.ts +123 -0
  17. package/dist/client/client/grapesjs/new-page-dialog.d.ts +1 -1
  18. package/dist/client/client/grapesjs/page-panel.d.ts +7 -1
  19. package/dist/client/client/grapesjs/project-bar.d.ts +20 -0
  20. package/dist/client/client/grapesjs/resize-panel.d.ts +1 -0
  21. package/dist/client/client/grapesjs/rich-text.d.ts +4 -1
  22. package/dist/client/client/grapesjs/semantic.d.ts +1 -1
  23. package/dist/client/client/grapesjs/settings-sections.d.ts +16 -0
  24. package/dist/client/client/grapesjs/settings.d.ts +3 -1
  25. package/dist/client/client/grapesjs/storage.d.ts +1 -0
  26. package/dist/client/client/grapesjs/symbolDialogs.d.ts +1 -1
  27. package/dist/client/client/grapesjs/view-buttons.d.ts +1 -0
  28. package/dist/client/client/index.d.ts +5 -0
  29. package/dist/client/client/publication-transformers.d.ts +42 -0
  30. package/dist/client/client/publish-custom-code-block.d.ts +4 -0
  31. package/dist/client/client/publish-fonts.d.ts +4 -0
  32. package/dist/client/client/utils.d.ts +22 -1
  33. package/dist/client/constants.d.ts +3 -0
  34. package/dist/client/css/admin.css +1107 -411
  35. package/dist/client/css/admin.css.map +1 -0
  36. package/dist/client/grapesjs-filter-styles/dist/index.d.ts +4 -0
  37. package/dist/client/grapesjs-fonts/dist/index.d.ts +4 -0
  38. package/dist/client/grapesjs-fonts/src/commands.d.ts +3 -0
  39. package/dist/client/grapesjs-fonts/src/fonts.d.ts +4 -0
  40. package/dist/client/grapesjs-storage-rate-limit/dist/index.d.ts +4 -0
  41. package/dist/client/grapesjs-ui-suggest-classes/dist/index.d.ts +4 -0
  42. package/dist/client/index.html +3 -2
  43. package/dist/client/js/main.js +305 -170
  44. package/dist/client/js/main.js.LICENSE.txt +21 -1
  45. package/dist/client/page.d.ts +1 -1
  46. package/dist/client/silex-lib/src/ts/client/api.d.ts +90 -0
  47. package/dist/client/silex-lib/src/ts/client/assetUrl.d.ts +54 -0
  48. package/dist/client/silex-lib/src/ts/client/config.d.ts +102 -0
  49. package/dist/client/silex-lib/src/ts/client/events.d.ts +23 -0
  50. package/dist/client/silex-lib/src/ts/client/expose.d.ts +8 -0
  51. package/dist/client/silex-lib/src/ts/client/grapesjs/LoginDialog.d.ts +15 -0
  52. package/dist/client/silex-lib/src/ts/client/grapesjs/PublicationManager.d.ts +73 -0
  53. package/dist/client/silex-lib/src/ts/client/grapesjs/PublicationUi.d.ts +59 -0
  54. package/dist/client/silex-lib/src/ts/client/grapesjs/blocks.d.ts +1 -0
  55. package/dist/client/silex-lib/src/ts/client/grapesjs/breadcrumbs.d.ts +1 -0
  56. package/dist/client/silex-lib/src/ts/client/grapesjs/css-props.d.ts +6 -0
  57. package/dist/client/silex-lib/src/ts/client/grapesjs/footer.d.ts +2 -0
  58. package/dist/client/silex-lib/src/ts/client/grapesjs/img.d.ts +6 -0
  59. package/dist/client/silex-lib/src/ts/client/grapesjs/index.d.ts +9 -0
  60. package/dist/client/silex-lib/src/ts/client/grapesjs/internal-links.d.ts +1 -0
  61. package/dist/client/silex-lib/src/ts/client/grapesjs/keymaps.d.ts +123 -0
  62. package/dist/client/silex-lib/src/ts/client/grapesjs/new-page-dialog.d.ts +2 -0
  63. package/dist/client/silex-lib/src/ts/client/grapesjs/openImport.d.ts +9 -0
  64. package/dist/client/silex-lib/src/ts/client/grapesjs/page-panel.d.ts +9 -0
  65. package/dist/client/silex-lib/src/ts/client/grapesjs/project-bar.d.ts +21 -0
  66. package/dist/client/silex-lib/src/ts/client/grapesjs/resize-panel.d.ts +1 -0
  67. package/dist/client/silex-lib/src/ts/client/grapesjs/rich-text.d.ts +4 -0
  68. package/dist/client/silex-lib/src/ts/client/grapesjs/semantic.d.ts +1 -0
  69. package/dist/client/silex-lib/src/ts/client/grapesjs/settings-sections.d.ts +16 -0
  70. package/dist/client/silex-lib/src/ts/client/grapesjs/settings.d.ts +4 -0
  71. package/dist/client/silex-lib/src/ts/client/grapesjs/storage.d.ts +2 -0
  72. package/dist/client/silex-lib/src/ts/client/grapesjs/symbolDialogs.d.ts +3 -0
  73. package/dist/client/silex-lib/src/ts/client/grapesjs/view-buttons.d.ts +1 -0
  74. package/dist/client/silex-lib/src/ts/client/index.d.ts +10 -0
  75. package/dist/client/silex-lib/src/ts/client/publication-transformers.d.ts +42 -0
  76. package/dist/client/silex-lib/src/ts/client/publish-custom-code-block.d.ts +4 -0
  77. package/dist/client/silex-lib/src/ts/client/publish-fonts.d.ts +4 -0
  78. package/dist/client/silex-lib/src/ts/client/utils.d.ts +22 -0
  79. package/dist/client/silex-lib/src/ts/constants.d.ts +32 -0
  80. package/dist/client/silex-lib/src/ts/page.d.ts +2 -0
  81. package/dist/client/silex-lib/src/ts/types.d.ts +339 -0
  82. package/dist/client/types.d.ts +59 -35
  83. package/dist/plugins/client/client/events.d.ts +19 -10
  84. package/dist/plugins/client/client/events.js +11 -0
  85. package/dist/plugins/client/client/events.js.map +1 -1
  86. package/dist/plugins/client/plugins/client/template.js +119 -71
  87. package/dist/plugins/client/plugins/client/template.js.map +1 -1
  88. package/dist/plugins/client/plugins/client/website-info.d.ts +1 -0
  89. package/dist/plugins/client/plugins/client/website-info.js +72 -0
  90. package/dist/plugins/client/plugins/client/website-info.js.map +1 -0
  91. package/dist/plugins/client/types.d.ts +59 -35
  92. package/dist/plugins/client/types.js +23 -0
  93. package/dist/plugins/client/types.js.map +1 -1
  94. package/dist/plugins/server/constants.d.ts +3 -0
  95. package/dist/plugins/server/constants.js +28 -1
  96. package/dist/plugins/server/constants.js.map +1 -1
  97. package/dist/plugins/server/plugins/server/Cache.js +9 -5
  98. package/dist/plugins/server/plugins/server/Cache.js.map +1 -1
  99. package/dist/plugins/server/plugins/server/DownloadConnector.d.ts +29 -0
  100. package/dist/plugins/server/plugins/server/DownloadConnector.js +127 -0
  101. package/dist/plugins/server/plugins/server/DownloadConnector.js.map +1 -0
  102. package/dist/plugins/server/plugins/server/FtpConnector.d.ts +5 -2
  103. package/dist/plugins/server/plugins/server/FtpConnector.js +38 -23
  104. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -1
  105. package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +63 -9
  106. package/dist/plugins/server/plugins/server/GitlabConnector.js +367 -91
  107. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
  108. package/dist/plugins/server/plugins/server/GitlabHostingConnector.d.ts +16 -0
  109. package/dist/plugins/server/plugins/server/GitlabHostingConnector.js +209 -0
  110. package/dist/plugins/server/plugins/server/GitlabHostingConnector.js.map +1 -0
  111. package/dist/plugins/server/plugins/server/SslPlugin.js +6 -6
  112. package/dist/plugins/server/plugins/server/SslPlugin.js.map +1 -1
  113. package/dist/plugins/server/plugins/server/StaticPlugin.d.ts +8 -1
  114. package/dist/plugins/server/plugins/server/StaticPlugin.js +5 -31
  115. package/dist/plugins/server/plugins/server/StaticPlugin.js.map +1 -1
  116. package/dist/plugins/server/server/config.js +8 -9
  117. package/dist/plugins/server/server/config.js.map +1 -1
  118. package/dist/plugins/server/server/connectors/FsHosting.d.ts +3 -2
  119. package/dist/plugins/server/server/connectors/FsHosting.js +18 -7
  120. package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -1
  121. package/dist/plugins/server/server/connectors/FsStorage.d.ts +3 -1
  122. package/dist/plugins/server/server/connectors/FsStorage.js +35 -28
  123. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -1
  124. package/dist/plugins/server/server/connectors/connectors.d.ts +7 -7
  125. package/dist/plugins/server/server/connectors/connectors.js +6 -7
  126. package/dist/plugins/server/server/connectors/connectors.js.map +1 -1
  127. package/dist/plugins/server/server/events.js +16 -0
  128. package/dist/plugins/server/server/events.js.map +1 -1
  129. package/dist/plugins/server/server/jobs.d.ts +6 -0
  130. package/dist/plugins/server/server/jobs.js +12 -8
  131. package/dist/plugins/server/server/jobs.js.map +1 -1
  132. package/dist/plugins/server/server/utils/validation.js +1 -2
  133. package/dist/plugins/server/server/utils/validation.js.map +1 -1
  134. package/dist/plugins/server/types.d.ts +59 -35
  135. package/dist/plugins/server/types.js +24 -1
  136. package/dist/plugins/server/types.js.map +1 -1
  137. package/dist/server/constants.js +27 -1
  138. package/dist/server/plugins/server/Cache.js +9 -5
  139. package/dist/server/server/api/api.js +1 -1
  140. package/dist/server/server/api/connectorApi.js +154 -25
  141. package/dist/server/server/api/publicationApi.js +17 -25
  142. package/dist/server/server/api/websiteApi.js +30 -8
  143. package/dist/server/server/cli.js +9 -6
  144. package/dist/server/server/config.js +8 -9
  145. package/dist/server/server/connectors/FsHosting.js +17 -7
  146. package/dist/server/server/connectors/FsStorage.js +34 -28
  147. package/dist/server/server/connectors/connectors.js +6 -7
  148. package/dist/server/server/express.js +4 -5
  149. package/dist/server/server/index.js +5 -1
  150. package/dist/server/server/jobs.js +11 -8
  151. package/dist/server/server/utils/validation.js +1 -2
  152. package/dist/server/types.js +13 -1
  153. package/package.json +56 -42
  154. package/public/assets/download.png +0 -0
  155. package/public/assets/favicon.ico +0 -0
  156. package/public/assets/favicon.png +0 -0
  157. package/public/assets/ftp.png +0 -0
  158. package/public/assets/gitlab.png +0 -0
  159. package/public/assets/gitlab2.png +0 -0
  160. package/public/assets/laptop.png +0 -0
  161. package/public/assets/logo-silex-small.png +0 -0
  162. package/public/silex.js +5 -23
  163. package/src/css/_variables.scss +23 -20
  164. package/src/css/dialog.scss +27 -1
  165. package/src/css/fonts.scss +31 -0
  166. package/src/css/footer.scss +12 -0
  167. package/src/css/grapesjs-light.scss +180 -0
  168. package/src/css/grapesjs-plugins.scss +227 -0
  169. package/src/css/grapesjs.scss +84 -10
  170. package/src/css/index.scss +12 -1
  171. package/src/css/light.scss +7 -0
  172. package/src/css/project-bar.scss +32 -16
  173. package/src/css/silex.scss +79 -5
  174. package/src/css/website-info.scss +14 -0
  175. package/src/html/index.pug +3 -3
  176. package/src/ts/client/api.ts +38 -14
  177. package/src/ts/client/assetUrl.test.ts +164 -0
  178. package/src/ts/client/assetUrl.ts +254 -0
  179. package/src/ts/client/config.ts +133 -5
  180. package/src/ts/client/events.ts +21 -9
  181. package/src/ts/client/grapesjs/LoginDialog.ts +4 -2
  182. package/src/ts/client/grapesjs/PublicationManager.ts +180 -54
  183. package/src/ts/client/grapesjs/PublicationUi.ts +122 -86
  184. package/src/ts/client/grapesjs/breadcrumbs.ts +79 -0
  185. package/src/ts/client/grapesjs/css-props.ts +910 -0
  186. package/src/ts/client/grapesjs/eleventy.ts +11 -8
  187. package/{dist/plugins/client/page.js → src/ts/client/grapesjs/footer.ts} +24 -13
  188. package/src/ts/client/grapesjs/img.ts +147 -0
  189. package/src/ts/client/grapesjs/index.ts +234 -52
  190. package/src/ts/client/grapesjs/internal-links.test.ts +2 -1
  191. package/src/ts/client/grapesjs/internal-links.ts +14 -7
  192. package/src/ts/client/grapesjs/keymaps.ts +207 -0
  193. package/src/ts/client/grapesjs/new-page-dialog.ts +2 -3
  194. package/src/ts/client/grapesjs/page-panel.ts +92 -7
  195. package/src/ts/client/grapesjs/project-bar.ts +116 -72
  196. package/src/ts/client/grapesjs/resize-panel.ts +20 -0
  197. package/src/ts/client/grapesjs/rich-text.ts +21 -13
  198. package/src/ts/client/grapesjs/semantic.ts +3 -3
  199. package/src/ts/client/grapesjs/settings-sections.ts +117 -0
  200. package/src/ts/client/grapesjs/settings.ts +174 -96
  201. package/src/ts/client/grapesjs/storage.ts +98 -33
  202. package/src/ts/client/grapesjs/symbolDialogs.ts +3 -4
  203. package/src/ts/{plugins/server/AuthPlugin.ts → client/grapesjs/view-buttons.ts} +23 -19
  204. package/src/ts/client/index.ts +35 -16
  205. package/src/ts/client/publication-transformers.test.ts +207 -0
  206. package/src/ts/client/publication-transformers.ts +280 -0
  207. package/{dist/plugins/client/client/utils.js → src/ts/client/publish-custom-code-block.ts} +14 -8
  208. package/src/ts/client/publish-fonts.ts +36 -0
  209. package/src/ts/client/utils.ts +53 -1
  210. package/src/ts/constants.ts +31 -0
  211. package/src/ts/page.ts +2 -2
  212. package/src/ts/plugins/client/template.ts +125 -75
  213. package/src/ts/plugins/client/website-info.ts +84 -0
  214. package/src/ts/plugins/server/Cache.ts +6 -2
  215. package/src/ts/plugins/server/DownloadConnector.ts +146 -0
  216. package/src/ts/plugins/server/FtpConnector.ts +47 -21
  217. package/src/ts/plugins/server/GitlabConnector.ts +423 -108
  218. package/src/ts/plugins/server/GitlabHostingConnector.ts +215 -0
  219. package/src/ts/plugins/server/SslPlugin.ts +5 -5
  220. package/src/ts/plugins/server/StaticPlugin.ts +3 -30
  221. package/src/ts/server/api/connectorApi.ts +165 -28
  222. package/src/ts/server/api/publicationApi.ts +17 -24
  223. package/src/ts/server/api/websiteApi.ts +57 -14
  224. package/src/ts/server/cli.ts +7 -5
  225. package/src/ts/server/config.ts +9 -10
  226. package/src/ts/server/connectors/FsHosting.ts +14 -8
  227. package/src/ts/server/connectors/FsStorage.ts +40 -7
  228. package/src/ts/server/connectors/connectors.ts +8 -6
  229. package/src/ts/server/events.ts +17 -0
  230. package/src/ts/server/express.ts +2 -2
  231. package/src/ts/server/index.ts +6 -0
  232. package/src/ts/server/jobs.ts +14 -2
  233. package/src/ts/server/utils/BackwardCompat.ts +530 -529
  234. package/src/ts/types.ts +78 -34
  235. package/dist/plugins/client/client/utils.d.ts +0 -1
  236. package/dist/plugins/client/client/utils.js.map +0 -1
  237. package/dist/plugins/client/page.d.ts +0 -2
  238. package/dist/plugins/client/page.js.map +0 -1
  239. package/dist/plugins/client/plugins/client/publicationRenderer.d.ts +0 -2
  240. package/dist/plugins/client/plugins/client/publicationRenderer.js +0 -128
  241. package/dist/plugins/client/plugins/client/publicationRenderer.js.map +0 -1
  242. package/dist/plugins/server/plugins/server/AuthPlugin.d.ts +0 -1
  243. package/dist/plugins/server/plugins/server/AuthPlugin.js +0 -38
  244. package/dist/plugins/server/plugins/server/AuthPlugin.js.map +0 -1
  245. package/dist/plugins/server/plugins/server/HooksPlugin.d.ts +0 -7
  246. package/dist/plugins/server/plugins/server/HooksPlugin.js +0 -74
  247. package/dist/plugins/server/plugins/server/HooksPlugin.js.map +0 -1
  248. package/src/example-client-config.js +0 -64
  249. package/src/ts/plugins/client/publicationRenderer.ts +0 -128
  250. package/src/ts/plugins/server/HooksPlugin.ts +0 -76
@@ -23,6 +23,8 @@ import openImport from './openImport'
23
23
  * Handle plugins, options and initialization of the editor
24
24
  */
25
25
 
26
+ const notificationContainer = document.createElement('div')
27
+
26
28
  // ////////////////////
27
29
  // Plugins
28
30
  // ////////////////////
@@ -30,47 +32,76 @@ import blocksBasicPlugin from 'grapesjs-blocks-basic'
30
32
  import styleFilterPlugin from 'grapesjs-style-filter'
31
33
  import formPlugin from 'grapesjs-plugin-forms'
32
34
  import codePlugin from 'grapesjs-custom-code'
35
+ import navbarPlugin from 'grapesjs-navbar'
33
36
  import uiSuggestClasses from '@silexlabs/grapesjs-ui-suggest-classes'
37
+ import filterStyles from '@silexlabs/grapesjs-filter-styles'
34
38
  import symbolsPlugin from '@silexlabs/grapesjs-symbols'
35
39
  import loadingPlugin from '@silexlabs/grapesjs-loading'
36
- import fontsDialogPlugin, { cmdOpenFonts } from '@silexlabs/grapesjs-fonts'
40
+ import fontsDialogPlugin from '@silexlabs/grapesjs-fonts'
37
41
  import symbolDialogsPlugin, { cmdPromptAddSymbol } from './symbolDialogs'
38
42
  import loginDialogPlugin, { LoginDialogOptions, cmdLogout } from './LoginDialog'
43
+ import footerPlugin from './footer'
44
+ import breadcrumbsPlugin from './breadcrumbs'
45
+ import imgPlugin from './img'
46
+ import cssPropsPlugin from './css-props'
47
+ import rateLimitPlugin from '@silexlabs/grapesjs-storage-rate-limit'
48
+ import borderPugin from 'grapesjs-style-border'
49
+ import backgroundPlugin from 'grapesjs-style-bg'
50
+ import resizePanelPlugin from './resize-panel'
51
+ import notificationsPlugin, { NotificationEditor } from '@silexlabs/grapesjs-notifications'
52
+ import keymapsDialogPlugin, { cmdKeymapsDialog, defaultOptions as keymapsDialogOpts } from '@silexlabs/grapesjs-keymaps-dialog'
39
53
 
40
54
  import { pagePanelPlugin, cmdTogglePages, cmdAddPage } from './page-panel'
41
55
  import { newPageDialog, cmdOpenNewPageDialog } from './new-page-dialog'
42
- import { projectBarPlugin } from './project-bar'
56
+ import { PROJECT_BAR_PANEL_ID, projectBarPlugin } from './project-bar'
43
57
  import { settingsDialog, cmdOpenSettings } from './settings'
44
58
  import { blocksPlugin } from './blocks'
45
59
  import { semanticPlugin } from './semantic'
46
- import { richTextPlugin } from './rich-text'
60
+ import { orderedList, richTextPlugin, unorderedList } from './rich-text'
47
61
  import { internalLinksPlugin } from './internal-links'
62
+ import {defaultKms, keymapsPlugin} from './keymaps'
48
63
  import publicationManagerPlugin, { PublicationManagerOptions } from './PublicationManager'
64
+ import ViewButtons from './view-buttons'
49
65
  import { storagePlugin } from './storage'
50
- import { ConnectorId, WebsiteId } from '../../types'
51
66
  import { API_PATH, API_WEBSITE_ASSETS_WRITE, API_WEBSITE_PATH } from '../../constants'
67
+ import { ClientConfig } from '../config'
68
+ import { titleCase } from '../utils'
52
69
 
53
70
  const plugins = [
54
71
  {name: './project-bar', value: projectBarPlugin}, // has to be before panels and dialogs
72
+ {name: 'grapesjs-style-bg', value: backgroundPlugin},
55
73
  {name: './settings', value: settingsDialog},
56
74
  {name: '@silexlabs/grapesjs-fonts', value: fontsDialogPlugin},
57
75
  {name: './new-page-dialog', value: newPageDialog},
58
76
  {name: './page-panel', value: pagePanelPlugin},
59
77
  {name: 'grapesjs-blocks-basic', value: blocksBasicPlugin},
60
78
  {name: './blocks', value: blocksPlugin},
79
+ {name: './view-buttons', value: ViewButtons},
61
80
  {name: './semantic', value: semanticPlugin},
62
81
  {name: './rich-text', value: richTextPlugin},
63
82
  {name: 'grapesjs-style-filter', value: styleFilterPlugin},
64
83
  {name: 'grapesjs-plugin-forms', value: formPlugin},
65
84
  {name: 'grapesjs-custom-code', value: codePlugin},
66
85
  {name: './internal-links', value: internalLinksPlugin},
86
+ {name: './keymaps', value: keymapsPlugin},
67
87
  {name: '@silexlabs/grapesjs-ui-suggest-classes', value: uiSuggestClasses},
88
+ {name: '@silexlabs/grapesjs-filter-styles', value: filterStyles},
68
89
  {name: './symbolDialogs', value: symbolDialogsPlugin},
69
90
  {name: '@silexlabs/grapesjs-symbols', value: symbolsPlugin},
70
91
  {name: './PublicationManager', value: publicationManagerPlugin},
71
92
  {name: './storage', value: storagePlugin},
72
93
  {name: './LoginDialog', value: loginDialogPlugin},
73
94
  {name: '@silexlabs/grapesjs-loading', value: loadingPlugin},
95
+ {name: './breadcrumbs', value: breadcrumbsPlugin},
96
+ {name: './img', value: imgPlugin},
97
+ {name: './css-props', value: cssPropsPlugin},
98
+ {name: './footer', value: footerPlugin},
99
+ {name: '@silexlabs/grapesjs-storage-rate-limit', value: rateLimitPlugin},
100
+ {name: 'grapesjs-style-border', value: borderPugin},
101
+ {name: './resize-panel', value: resizePanelPlugin},
102
+ {name: '@silexlabs/grapesjs-notifications', value: notificationsPlugin},
103
+ {name: '@silexlabs/grapesjs-keymaps-dialog', value: keymapsDialogPlugin},
104
+ {name: 'grapesjs-navbar', value:navbarPlugin}
74
105
  ]
75
106
  // Check that all plugins are loaded correctly
76
107
  plugins
@@ -79,13 +110,28 @@ plugins
79
110
  throw new Error(`Plugin ${p.name} could not be loaded correctly (${p.value})`)
80
111
  })
81
112
 
113
+ // Constants
114
+ const PRIMARY_COLOR = '#333333'
115
+ const SECONDARY_COLOR = '#ddd'
116
+ const TERTIARY_COLOR = '#8873FE'
117
+ const QUATERNARY_COLOR = '#A291FF'
118
+ const DARKER_PRIMARY_COLOR = '#363636'
119
+ const LIGHTER_PRIMARY_COLOR = '#575757'
120
+
121
+ // Commands
122
+ export const cmdToggleLayers = 'open-layers'
123
+ export const cmdToggleBlocks = 'open-blocks'
124
+ export const cmdToggleSymbols = 'open-symbols'
125
+ export const cmdToggleNotifications = 'open-notifications'
126
+
82
127
  // ////////////////////
83
128
  // Config
84
129
  // ////////////////////
85
130
  const catBasic = 'Containers'
86
131
  const catComponents = 'Components'
87
132
 
88
- export function getEditorConfig(id: WebsiteId, connectorId: ConnectorId, rootUrl: string): EditorConfig {
133
+ export function getEditorConfig(config: ClientConfig): EditorConfig {
134
+ const { websiteId, storageId, rootUrl } = config
89
135
  return {
90
136
  container: '#gjs',
91
137
  height: '100%',
@@ -103,90 +149,148 @@ export function getEditorConfig(id: WebsiteId, connectorId: ConnectorId, rootUrl
103
149
  },
104
150
 
105
151
  assetManager: {
106
- upload: `${rootUrl}${API_PATH}${API_WEBSITE_PATH}${API_WEBSITE_ASSETS_WRITE}/?websiteId=${id}${ connectorId ? `&connectorId=${connectorId}` : ''}`,
152
+ upload: `${rootUrl}${API_PATH}${API_WEBSITE_PATH}${API_WEBSITE_ASSETS_WRITE}/?websiteId=${websiteId}${ storageId ? `&connectorId=${storageId}` : ''}`,
107
153
  },
108
154
 
109
155
  storageManager: {
110
156
  autoload: false,
111
- //type: 'remote',
112
157
  type: 'connector',
113
158
  options: {
114
159
  connector: {
115
- id,
116
- connectorId,
160
+ id: websiteId,
161
+ connectorId: storageId,
117
162
  },
118
- //remote: {
119
- // urlStore: `${rootUrl}/${API_WEBSITE_WRITE}?id=${id}`,
120
- // urlLoad: `${rootUrl}/${API_WEBSITE_READ}?id=${id}`,
121
- //},
122
163
  },
123
164
  },
124
165
 
125
- cssIcons: '/css/all.min.css',
166
+ cssIcons: './css/all.min.css',
167
+ canvasCss: `
168
+ :root {
169
+ --primaryColor: ${PRIMARY_COLOR};
170
+ --secondaryColor: ${SECONDARY_COLOR};
171
+ --tertiaryColor: ${TERTIARY_COLOR};
172
+ --quaternaryColor: ${QUATERNARY_COLOR};
173
+ --darkerPrimaryColor: ${DARKER_PRIMARY_COLOR};
174
+ --lighterPrimaryColor: ${LIGHTER_PRIMARY_COLOR};
175
+ }
176
+ .gjs-frame-selected {
177
+ box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.5) !important; // Change to red border
178
+ }
179
+ .gjs-selected {
180
+ outline: 2px solid var(--tertiaryColor) !important;
181
+ outline-offset: -2px;
182
+ }
183
+ `,
184
+
185
+ richTextEditor: {
186
+ // @ts-ignore
187
+ actions: ['bold', 'italic', 'underline', 'strikethrough', 'link', 'wrap', orderedList, unorderedList],
188
+ },
189
+
126
190
 
127
191
  plugins: plugins.map(p => p.value),
128
192
 
129
193
  pluginsOpts: {
130
- [blocksBasicPlugin as any]: {
194
+ [blocksBasicPlugin.toString()]: {
131
195
  blocks: ['text', 'image', 'video', 'map'],
132
196
  category: catBasic,
133
197
  //flexGrid: true,
134
198
  },
135
- [projectBarPlugin as any]: {
199
+ [projectBarPlugin.toString()]: {
136
200
  panels: [
137
201
  {
138
202
  id: 'dash',
139
203
  className: 'logo',
140
- attributes: { title: 'Go to your dashboard' },
141
- link: '/',
142
- command: 'open-dash',
204
+ attributes: { title: 'Dashboard' },
205
+ command: () => {
206
+ window.location.href = '/'
207
+ },
143
208
  }, {
144
209
  id: 'block-manager-btn',
145
210
  className: 'block-manager-btn fa fa-fw fa-plus',
146
- attributes: { title: 'Blocks', containerClassName: 'block-manager-container', },
147
- command: 'open-blocks',
211
+ name: 'Blocks',
212
+ attributes: { title: `Blocks (${titleCase(defaultKms.kmBlocks.keys, '+')})`, containerClassName: 'block-manager-container', },
213
+ command: cmdToggleBlocks,
148
214
  }, {
149
215
  id: 'symbols-btn',
150
216
  className: 'symbols-btn fa-regular fa-gem',
151
- attributes: { title: 'Symbols', containerClassName: 'symbols-list-container', },
152
- command: 'open-symbols',
217
+ name: 'Symbols',
218
+ attributes: { title: `Symbols (${titleCase(defaultKms.kmSymbols.keys, '+')})`, containerClassName: 'symbols-list-container', },
219
+ command: cmdToggleSymbols,
153
220
  buttons: [
154
221
  {
155
222
  id: 'symbol-create-button',
156
- className: 'pages__add-page fa-solid fa-plus',
157
- label: 'Create symbol from selection',
223
+ className: 'gjs-pn-btn',
158
224
  command: cmdPromptAddSymbol,
225
+ text: '\u271A',
159
226
  },
160
227
  ],
161
228
  }, {
162
229
  id: 'page-panel-btn',
163
230
  className: 'page-panel-btn fa fa-fw fa-file',
164
- attributes: { title: 'Pages', containerClassName: 'page-panel-container', },
231
+ name: 'Pages',
232
+ attributes: { title: `Pages (${titleCase(defaultKms.kmPages.keys, '+')})`, containerClassName: 'page-panel-container', },
165
233
  command: cmdTogglePages,
166
234
  buttons: [{
167
- className: 'pages__add-page fa fa-file',
235
+ className: 'gjs-pn-btn',
168
236
  command: cmdAddPage,
169
- text: '+',
237
+ text: '\u271A',
170
238
  }],
171
239
  }, {
172
240
  id: 'layer-manager-btn',
173
241
  className: 'layer-manager-btn fa-solid fa-layer-group',
174
- attributes: { title: 'Layers', containerClassName: 'layer-manager-container', },
175
- command: 'open-layers',
242
+ name: 'Layers',
243
+ attributes: { title: `Layers (${titleCase(defaultKms.kmLayers.keys, '+')})`, containerClassName: 'layer-manager-container', },
244
+ command: cmdToggleLayers,
176
245
  }, {
177
246
  id: 'font-dialog-btn',
178
247
  className: 'font-manager-btn fa-solid fa-font',
179
- attributes: { title: 'Fonts' },
180
- command: cmdOpenFonts,
248
+ name: 'Fonts',
249
+ attributes: { title: `Fonts (${titleCase(defaultKms.kmOpenFonts.keys, '+')})` },
250
+ command: () => {
251
+ editor.runCommand('open-fonts')
252
+ },
181
253
  }, {
182
254
  id: 'settings-dialog-btn',
183
255
  className: 'page-panel-btn fa-solid fa-gears',
184
- attributes: { title: 'Settings' },
256
+ name: 'Settings',
257
+ attributes: { title: `Settings (${titleCase(defaultKms.kmOpenSettings.keys, '+')})` },
185
258
  command: cmdOpenSettings,
186
259
  }, {
187
260
  id: 'spacer',
188
261
  attributes: {},
189
262
  className: 'project-bar-spacer',
263
+ }, {
264
+ id: 'keymaps-btn',
265
+ className: 'keymaps-btn fa-solid fa-keyboard',
266
+ name: 'Shortcuts',
267
+ attributes: { title: 'Keyboard Shortcuts (Shift+H)' },
268
+ command: cmdKeymapsDialog,
269
+ }, {
270
+ id: 'notifications-btn',
271
+ className: 'notifications-btn fa-regular fa-bell',
272
+ name: 'Notifications',
273
+ attributes: { title: `Notifications (${titleCase(defaultKms.kmNotifications.keys, '+')})`, containerClassName: 'notifications-container', },
274
+ command: cmdToggleNotifications,
275
+ buttons: [{
276
+ className: 'gjs-pn-btn',
277
+ command: 'notifications:clear',
278
+ text: '\u2716',
279
+ }],
280
+ }, {
281
+ id: 'dash2',
282
+ className: 'fa-solid fa-house',
283
+ attributes: { title: 'Dashboard' },
284
+ command: () => {
285
+ window.location.href = '/'
286
+ },
287
+ }, {
288
+ id: 'help',
289
+ className: 'fa fa-fw fa-question-circle',
290
+ attributes: { title: 'Documentation' },
291
+ command: () => {
292
+ window.open('https://docs.silex.me/', '_blank')
293
+ },
190
294
  }, {
191
295
  id: 'logout-button',
192
296
  className: 'page-panel-btn fa fa-fw fa-sign-out',
@@ -195,38 +299,72 @@ export function getEditorConfig(id: WebsiteId, connectorId: ConnectorId, rootUrl
195
299
  },
196
300
  ],
197
301
  },
198
- [publicationManagerPlugin as any]: {
302
+ [publicationManagerPlugin.toString()]: {
199
303
  appendTo: 'options',
200
- websiteId: id,
304
+ websiteId,
201
305
  } as PublicationManagerOptions,
202
- [pagePanelPlugin as any]: {
306
+ [pagePanelPlugin.toString()]: {
203
307
  cmdOpenNewPageDialog,
204
308
  cmdOpenSettings,
205
309
  appendTo: '.page-panel-container',
206
310
  },
207
- [uiSuggestClasses as any]: {
311
+ [uiSuggestClasses.toString()]: {
208
312
  enableCount: false,
209
313
  enablePerformance: false,
210
314
  },
211
- [internalLinksPlugin as any]: {
315
+ [filterStyles.toString()]: {
316
+ appendBefore: '.gjs-sm-sectors',
317
+ },
318
+ [internalLinksPlugin.toString()]: {
212
319
  // FIXME: warn the user about links in error
213
- onError: (errors) => console.log('Links errors:', errors),
320
+ onError: (errors) => console.warn('Links errors:', errors),
321
+ },
322
+ [keymapsPlugin.toString()]: {
323
+ disableKeymaps: false,
214
324
  },
215
- [codePlugin as any]: {
325
+ [codePlugin.toString()]: {
216
326
  blockLabel: 'HTML',
217
327
  blockCustomCode: {
218
328
  category: catComponents,
219
- }
329
+ },
330
+ codeViewOptions: {
331
+ autoFormat: false,
332
+ },
220
333
  },
221
- [symbolsPlugin as any]: {
334
+ [symbolsPlugin.toString()]: {
222
335
  appendTo: '.symbols-list-container',
336
+ emptyText: 'No symbol yet.',
337
+ primaryColor: PRIMARY_COLOR,
338
+ secondaryColor: SECONDARY_COLOR,
339
+ highlightColor: TERTIARY_COLOR,
223
340
  },
224
- [fontsDialogPlugin as any]: {
225
- api_key: 'AIzaSyAdJTYSLPlKz4w5Iqyy-JAF2o8uQKd1FKc',
341
+ [fontsDialogPlugin.toString()]: {
342
+ api_key: config.fontsApiKey,
343
+ server_url: config.fontsServerUrl,
344
+ api_url: config.fontsApiUrl,
226
345
  },
227
- [loginDialogPlugin as any]: {
228
- id,
346
+ [loginDialogPlugin.toString()]: {
347
+ id: websiteId,
229
348
  } as LoginDialogOptions,
349
+ [rateLimitPlugin.toString()]: {
350
+ time: 5000,
351
+ },
352
+ [imgPlugin.toString()]: {
353
+ replacedElements: config.replacedElements,
354
+ },
355
+ [notificationsPlugin.toString()]: {
356
+ container: notificationContainer,
357
+ reverse: true,
358
+ },
359
+ [keymapsDialogPlugin.toString()]: {
360
+ longPressDuration: null,
361
+ shortcut: 'shift+h',
362
+ },
363
+ [navbarPlugin.toString()]:{
364
+ block:{
365
+ category: 'Components'
366
+ }
367
+ }
230
368
  },
231
369
  }
232
370
  }
@@ -240,6 +378,7 @@ export async function initEditor(config: EditorConfig) {
240
378
  if(editor) throw new Error('Grapesjs editor already created')
241
379
  return new Promise<Editor>((resolve, reject) => {
242
380
  try {
381
+ /* @ts-ignore */
243
382
  editor = grapesjs.init(config)
244
383
  } catch(e) {
245
384
  console.error('Error initializing GrapesJs with plugins:', plugins, e)
@@ -262,17 +401,60 @@ export async function initEditor(config: EditorConfig) {
262
401
  modalImportTitle: 'Import from website',
263
402
  }))
264
403
 
404
+ // Detect loading errors
405
+ // Display a useful notification
406
+ const typeConfig = {
407
+ view: {
408
+ onRender({editor, el, model}) {
409
+ const src = model.getAttributes().src
410
+ el.addEventListener('error', () => {
411
+ editor.runCommand('notifications:add', {
412
+ type: 'error',
413
+ group: 'Image loading error',
414
+ message: `Error loading image: ${src}`,
415
+ componentId: model.getId(),
416
+ })
417
+ })
418
+ },
419
+ },
420
+ }
421
+ editor.DomComponents.addType('image', typeConfig)
422
+ editor.DomComponents.addType('iframe', typeConfig)
423
+
424
+ // Adjustments to do when the editor is ready
265
425
  editor.on('load', () => {
266
- // remove blocks and layers buttons from the properties
267
- editor.Panels.getPanel('views').buttons.remove('open-blocks')
268
- editor.Panels.getPanel('views').buttons.remove('open-layers')
269
- editor.Panels.getPanel('views').view.el.firstChild.style.justifyContent = 'initial' // align left
426
+ const views = editor.Panels.getPanel('views')
427
+
428
+ // Remove blocks and layers buttons from the properties
429
+ // This is because in Silex they are on the left
430
+ views.buttons.remove(cmdToggleBlocks)
431
+ views.buttons.remove(cmdToggleLayers)
432
+
433
+ // Remove useless buttons
270
434
  editor.Panels.getPanel('options').buttons.remove('export-template')
435
+ editor.Panels.getPanel('options').buttons.remove('fullscreen')
271
436
 
437
+ // Render the block manager, otherwise it is empty
272
438
  editor.BlockManager.render(null)
273
439
 
274
- // use the style filter plugin
275
- editor.StyleManager.addProperty('extra',{ extend: 'filter' })
440
+ // Use the style filter plugin
441
+ editor.StyleManager.addProperty('extra', { extend: 'filter' })
442
+
443
+ // Add a class to the Style Manager's sticky top section
444
+ editor.SelectorManager.selectorTags.el.parentElement.classList.add('top-style-section')
445
+
446
+ // Add the notifications container
447
+ document.body.querySelector('.notifications-container')?.appendChild(notificationContainer)
448
+ // Mark the button as dirty when there are notifications
449
+ // TODO: move this in the notifications plugin options
450
+ editor.on(
451
+ 'notifications:changed',
452
+ () => {
453
+ const notificationButton = editor.Panels.getPanel(PROJECT_BAR_PANEL_ID).view?.el.querySelector('.notifications-btn')
454
+ ;(editor as NotificationEditor)
455
+ .NotificationManager['length'] ? notificationButton?.classList.add('project-bar__dirty') : notificationButton?.classList.remove('project-bar__dirty')
456
+ }
457
+ )
276
458
 
277
459
  // GrapesJs editor is ready
278
460
  resolve(editor)
@@ -65,6 +65,7 @@ const page2 = {
65
65
  },
66
66
  }
67
67
  beforeEach(() => {
68
+ /* @ts-ignore */
68
69
  editor = grapesjs.init({
69
70
  headless: true,
70
71
  storageManager: { autoload: false },
@@ -81,7 +82,7 @@ test('init', () => {
81
82
  test('rename page and rewrite links in current page', () => {
82
83
  const page = editor.Pages.getSelected()
83
84
  expect(page.id).toBe(pageMain.id)
84
- expect(page.getName()).toBeUndefined()
85
+ expect(page.getName()).toBe('')
85
86
  const newName = 'Home page'
86
87
  const newPath = './home-page.html'
87
88
  // Do not work: page.setName(newName)
@@ -18,8 +18,6 @@
18
18
  import {html, render} from 'lit-html'
19
19
  import {map} from 'lit-html/directives/map.js'
20
20
  import grapesjs from 'grapesjs/dist/grapes.min.js'
21
-
22
- import { Page } from '../../types'
23
21
  import { getPageLink } from '../../page'
24
22
 
25
23
  // constants
@@ -32,7 +30,7 @@ const options: grapesjs.SelectOption = [
32
30
  ]
33
31
 
34
32
  // plugin code
35
- export const internalLinksPlugin = grapesjs.plugins.add(pluginName, (editor, opts) => {
33
+ export const internalLinksPlugin = (editor, opts) => {
36
34
  // update links when a page link changes
37
35
  function onAll(cbk) {
38
36
  editor.Pages.getAll()
@@ -58,12 +56,21 @@ export const internalLinksPlugin = grapesjs.plugins.add(pluginName, (editor, opt
58
56
  // mark all links as issues
59
57
  const issues = []
60
58
  onAll(component => {
61
- console.log(component.getAttributes().href, getPageLink(page.previous('name')), page.previous('name'))
62
59
  if(component.getAttributes().href === getPageLink(page.previous('name'))) {
63
60
  issues.push(component)
64
61
  }
65
62
  })
66
- opts?.onError(issues)
63
+ // Add a notification for the issues
64
+ if(issues.length) {
65
+ issues.forEach(component => {
66
+ editor.runCommand('notifications:add', {
67
+ type: 'error',
68
+ message: `Page ${page.previous('name')} was removed, please fix the following links:`,
69
+ componentId: component.getId(),
70
+ group: 'Broken internal links',
71
+ })
72
+ })
73
+ }
67
74
  break
68
75
  }
69
76
  })
@@ -109,7 +116,7 @@ export const internalLinksPlugin = grapesjs.plugins.add(pluginName, (editor, opt
109
116
  function getDefaultHref(type) {
110
117
  switch(type) {
111
118
  case 'email': return 'mailto:'
112
- case 'page': return getPageLink()
119
+ case 'page': return getPageLink(null)
113
120
  case 'url': return 'https://'
114
121
  }
115
122
  }
@@ -224,4 +231,4 @@ export const internalLinksPlugin = grapesjs.plugins.add(pluginName, (editor, opt
224
231
  doRender(elInput, href)
225
232
  },
226
233
  })
227
- })
234
+ }