@silexlabs/silex 3.0.1-alpha.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 (323) hide show
  1. package/.env.default +20 -0
  2. package/.silex.js +67 -8
  3. package/LICENSE +661 -203
  4. package/README.md +37 -35
  5. package/dist/client/client/api.d.ts +90 -0
  6. package/dist/client/client/assetUrl.d.ts +54 -0
  7. package/dist/client/client/config.d.ts +102 -0
  8. package/dist/client/client/events.d.ts +23 -0
  9. package/dist/client/client/expose.d.ts +8 -0
  10. package/dist/client/client/grapesjs/LoginDialog.d.ts +15 -0
  11. package/dist/client/client/grapesjs/PublicationManager.d.ts +73 -0
  12. package/dist/client/client/grapesjs/PublicationUi.d.ts +59 -0
  13. package/dist/client/client/grapesjs/blocks.d.ts +1 -0
  14. package/dist/client/client/grapesjs/breadcrumbs.d.ts +1 -0
  15. package/dist/client/client/grapesjs/css-props.d.ts +6 -0
  16. package/dist/client/client/grapesjs/footer.d.ts +2 -0
  17. package/dist/client/client/grapesjs/img.d.ts +6 -0
  18. package/dist/client/client/grapesjs/index.d.ts +9 -0
  19. package/dist/client/client/grapesjs/internal-links.d.ts +1 -0
  20. package/dist/client/client/grapesjs/keymaps.d.ts +123 -0
  21. package/dist/client/client/grapesjs/new-page-dialog.d.ts +2 -0
  22. package/dist/client/client/grapesjs/openImport.d.ts +9 -0
  23. package/dist/client/client/grapesjs/page-panel.d.ts +9 -0
  24. package/dist/client/client/grapesjs/project-bar.d.ts +21 -0
  25. package/dist/client/client/grapesjs/resize-panel.d.ts +1 -0
  26. package/dist/client/client/grapesjs/rich-text.d.ts +4 -0
  27. package/dist/client/client/grapesjs/semantic.d.ts +1 -0
  28. package/dist/client/client/grapesjs/settings-sections.d.ts +16 -0
  29. package/dist/client/client/grapesjs/settings.d.ts +4 -0
  30. package/dist/client/client/grapesjs/storage.d.ts +2 -0
  31. package/dist/client/client/grapesjs/symbolDialogs.d.ts +3 -0
  32. package/dist/client/client/grapesjs/view-buttons.d.ts +1 -0
  33. package/dist/client/client/index.d.ts +10 -0
  34. package/dist/client/client/publication-transformers.d.ts +42 -0
  35. package/dist/client/client/publish-custom-code-block.d.ts +4 -0
  36. package/dist/client/client/publish-fonts.d.ts +4 -0
  37. package/dist/client/client/utils.d.ts +22 -0
  38. package/dist/client/constants.d.ts +32 -0
  39. package/dist/client/css/admin.css +1114 -328
  40. package/dist/client/css/admin.css.map +1 -0
  41. package/dist/client/grapesjs-filter-styles/dist/index.d.ts +4 -0
  42. package/dist/client/grapesjs-fonts/dist/index.d.ts +4 -0
  43. package/dist/client/grapesjs-fonts/src/commands.d.ts +3 -0
  44. package/dist/client/grapesjs-fonts/src/fonts.d.ts +4 -0
  45. package/dist/client/grapesjs-storage-rate-limit/dist/index.d.ts +4 -0
  46. package/dist/client/grapesjs-ui-suggest-classes/dist/index.d.ts +4 -0
  47. package/dist/client/index.html +3 -2
  48. package/dist/client/js/main.js +356 -131
  49. package/dist/client/js/main.js.LICENSE.txt +15 -1
  50. package/dist/client/page.d.ts +2 -0
  51. package/dist/client/silex-lib/src/ts/client/api.d.ts +90 -0
  52. package/dist/client/silex-lib/src/ts/client/assetUrl.d.ts +54 -0
  53. package/dist/client/silex-lib/src/ts/client/config.d.ts +102 -0
  54. package/dist/client/silex-lib/src/ts/client/events.d.ts +23 -0
  55. package/dist/client/silex-lib/src/ts/client/expose.d.ts +8 -0
  56. package/dist/client/silex-lib/src/ts/client/grapesjs/LoginDialog.d.ts +15 -0
  57. package/dist/client/silex-lib/src/ts/client/grapesjs/PublicationManager.d.ts +73 -0
  58. package/dist/client/silex-lib/src/ts/client/grapesjs/PublicationUi.d.ts +59 -0
  59. package/dist/client/silex-lib/src/ts/client/grapesjs/blocks.d.ts +1 -0
  60. package/dist/client/silex-lib/src/ts/client/grapesjs/breadcrumbs.d.ts +1 -0
  61. package/dist/client/silex-lib/src/ts/client/grapesjs/css-props.d.ts +6 -0
  62. package/dist/client/silex-lib/src/ts/client/grapesjs/footer.d.ts +2 -0
  63. package/dist/client/silex-lib/src/ts/client/grapesjs/img.d.ts +6 -0
  64. package/dist/client/silex-lib/src/ts/client/grapesjs/index.d.ts +9 -0
  65. package/dist/client/silex-lib/src/ts/client/grapesjs/internal-links.d.ts +1 -0
  66. package/dist/client/silex-lib/src/ts/client/grapesjs/keymaps.d.ts +123 -0
  67. package/dist/client/silex-lib/src/ts/client/grapesjs/new-page-dialog.d.ts +2 -0
  68. package/dist/client/silex-lib/src/ts/client/grapesjs/openImport.d.ts +9 -0
  69. package/dist/client/silex-lib/src/ts/client/grapesjs/page-panel.d.ts +9 -0
  70. package/dist/client/silex-lib/src/ts/client/grapesjs/project-bar.d.ts +21 -0
  71. package/dist/client/silex-lib/src/ts/client/grapesjs/resize-panel.d.ts +1 -0
  72. package/dist/client/silex-lib/src/ts/client/grapesjs/rich-text.d.ts +4 -0
  73. package/dist/client/silex-lib/src/ts/client/grapesjs/semantic.d.ts +1 -0
  74. package/dist/client/silex-lib/src/ts/client/grapesjs/settings-sections.d.ts +16 -0
  75. package/dist/client/silex-lib/src/ts/client/grapesjs/settings.d.ts +4 -0
  76. package/dist/client/silex-lib/src/ts/client/grapesjs/storage.d.ts +2 -0
  77. package/dist/client/silex-lib/src/ts/client/grapesjs/symbolDialogs.d.ts +3 -0
  78. package/dist/client/silex-lib/src/ts/client/grapesjs/view-buttons.d.ts +1 -0
  79. package/dist/client/silex-lib/src/ts/client/index.d.ts +10 -0
  80. package/dist/client/silex-lib/src/ts/client/publication-transformers.d.ts +42 -0
  81. package/dist/client/silex-lib/src/ts/client/publish-custom-code-block.d.ts +4 -0
  82. package/dist/client/silex-lib/src/ts/client/publish-fonts.d.ts +4 -0
  83. package/dist/client/silex-lib/src/ts/client/utils.d.ts +22 -0
  84. package/dist/client/silex-lib/src/ts/constants.d.ts +32 -0
  85. package/dist/client/silex-lib/src/ts/page.d.ts +2 -0
  86. package/dist/client/silex-lib/src/ts/types.d.ts +339 -0
  87. package/dist/client/types.d.ts +339 -0
  88. package/dist/plugins/client/client/events.d.ts +23 -0
  89. package/dist/plugins/client/client/events.js +43 -0
  90. package/dist/plugins/client/client/events.js.map +1 -0
  91. package/dist/plugins/client/plugins/client/template.d.ts +2 -0
  92. package/dist/plugins/client/plugins/client/template.js +234 -0
  93. package/dist/plugins/client/plugins/client/template.js.map +1 -0
  94. package/dist/plugins/client/plugins/client/website-info.d.ts +1 -0
  95. package/dist/plugins/client/plugins/client/website-info.js +72 -0
  96. package/dist/plugins/client/plugins/client/website-info.js.map +1 -0
  97. package/dist/plugins/client/types.d.ts +339 -0
  98. package/dist/plugins/client/types.js +80 -0
  99. package/dist/plugins/client/types.js.map +1 -0
  100. package/dist/plugins/server/constants.d.ts +32 -0
  101. package/dist/plugins/server/constants.js +76 -0
  102. package/dist/plugins/server/constants.js.map +1 -0
  103. package/dist/plugins/server/plugins/server/Cache.d.ts +2 -0
  104. package/dist/plugins/server/plugins/server/Cache.js +36 -0
  105. package/dist/plugins/server/plugins/server/Cache.js.map +1 -0
  106. package/dist/plugins/server/plugins/server/DownloadConnector.d.ts +29 -0
  107. package/dist/plugins/server/plugins/server/DownloadConnector.js +127 -0
  108. package/dist/plugins/server/plugins/server/DownloadConnector.js.map +1 -0
  109. package/dist/plugins/server/plugins/server/FtpConnector.d.ts +86 -0
  110. package/dist/plugins/server/plugins/server/FtpConnector.js +536 -0
  111. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -0
  112. package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +135 -0
  113. package/dist/plugins/server/plugins/server/GitlabConnector.js +649 -0
  114. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -0
  115. package/dist/plugins/server/plugins/server/GitlabHostingConnector.d.ts +16 -0
  116. package/dist/plugins/server/plugins/server/GitlabHostingConnector.js +209 -0
  117. package/dist/plugins/server/plugins/server/GitlabHostingConnector.js.map +1 -0
  118. package/dist/plugins/server/plugins/server/PublicationOptimizer.d.ts +0 -0
  119. package/dist/plugins/server/plugins/server/PublicationOptimizer.js +14 -0
  120. package/dist/plugins/server/plugins/server/PublicationOptimizer.js.map +1 -0
  121. package/dist/plugins/server/plugins/server/SslPlugin.d.ts +1 -0
  122. package/dist/plugins/server/plugins/server/SslPlugin.js +86 -0
  123. package/dist/plugins/server/plugins/server/SslPlugin.js.map +1 -0
  124. package/dist/plugins/server/plugins/server/StaticPlugin.d.ts +8 -0
  125. package/dist/plugins/server/plugins/server/StaticPlugin.js +45 -0
  126. package/dist/plugins/server/plugins/server/StaticPlugin.js.map +1 -0
  127. package/dist/plugins/server/server/config.d.ts +59 -0
  128. package/dist/plugins/server/server/config.js +181 -0
  129. package/dist/plugins/server/server/config.js.map +1 -0
  130. package/dist/plugins/server/server/connectors/FsHosting.d.ts +14 -0
  131. package/dist/plugins/server/server/connectors/FsHosting.js +66 -0
  132. package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -0
  133. package/dist/plugins/server/server/connectors/FsStorage.d.ts +44 -0
  134. package/dist/plugins/server/server/connectors/FsStorage.js +261 -0
  135. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -0
  136. package/dist/plugins/server/server/connectors/connectors.d.ts +86 -0
  137. package/dist/plugins/server/server/connectors/connectors.js +126 -0
  138. package/dist/plugins/server/server/connectors/connectors.js.map +1 -0
  139. package/dist/plugins/server/server/events.d.ts +26 -0
  140. package/dist/plugins/server/server/events.js +31 -0
  141. package/dist/plugins/server/server/events.js.map +1 -0
  142. package/dist/plugins/server/server/jobs.d.ts +12 -0
  143. package/dist/plugins/server/server/jobs.js +79 -0
  144. package/dist/plugins/server/server/jobs.js.map +1 -0
  145. package/dist/plugins/server/server/utils/validation.d.ts +7 -0
  146. package/dist/plugins/server/server/utils/validation.js +37 -0
  147. package/dist/plugins/server/server/utils/validation.js.map +1 -0
  148. package/dist/plugins/server/types.d.ts +339 -0
  149. package/dist/plugins/server/types.js +84 -0
  150. package/dist/plugins/server/types.js.map +1 -0
  151. package/dist/server/constants.js +55 -0
  152. package/dist/server/plugins/server/Cache.js +19 -0
  153. package/dist/server/server/api/api.js +20 -0
  154. package/dist/server/server/api/connectorApi.js +334 -0
  155. package/dist/server/server/api/publicationApi.js +106 -0
  156. package/dist/server/server/api/websiteApi.js +315 -0
  157. package/dist/server/server/cli.js +71 -0
  158. package/dist/server/server/config.js +120 -0
  159. package/dist/server/server/connectors/FsHosting.js +47 -0
  160. package/dist/server/server/connectors/FsStorage.js +228 -0
  161. package/dist/server/server/connectors/connectors.js +88 -0
  162. package/dist/server/server/events.js +14 -0
  163. package/dist/server/server/expose.js +27 -0
  164. package/dist/server/server/express.js +46 -0
  165. package/dist/server/server/index.js +94 -0
  166. package/dist/server/server/jobs.js +50 -0
  167. package/dist/server/server/utils/validation.js +14 -0
  168. package/dist/server/types.js +40 -0
  169. package/package.json +99 -49
  170. package/public/assets/download.png +0 -0
  171. package/public/assets/favicon.ico +0 -0
  172. package/public/assets/favicon.png +0 -0
  173. package/public/assets/ftp.png +0 -0
  174. package/public/assets/gitlab.png +0 -0
  175. package/public/assets/gitlab2.png +0 -0
  176. package/public/assets/laptop.png +0 -0
  177. package/public/assets/logo-silex-small.png +0 -0
  178. package/public/silex.js +22 -23
  179. package/src/css/_variables.scss +24 -20
  180. package/src/css/dialog.scss +35 -2
  181. package/src/css/fonts.scss +31 -0
  182. package/src/css/footer.scss +12 -0
  183. package/src/css/grapesjs-light.scss +180 -0
  184. package/src/css/grapesjs-plugins.scss +227 -0
  185. package/src/css/grapesjs.scss +159 -1
  186. package/src/css/index.scss +12 -1
  187. package/src/css/light.scss +7 -0
  188. package/src/css/loader.scss +2 -0
  189. package/src/css/project-bar.scss +32 -16
  190. package/src/css/silex.scss +79 -5
  191. package/src/css/website-info.scss +14 -0
  192. package/src/html/index.pug +3 -3
  193. package/src/html/templates/includes.pug +0 -1
  194. package/src/ts/client/api.ts +156 -0
  195. package/src/ts/client/assetUrl.test.ts +164 -0
  196. package/src/ts/client/assetUrl.ts +254 -0
  197. package/src/ts/client/config.ts +175 -13
  198. package/src/ts/client/events.ts +43 -0
  199. package/src/ts/client/expose.ts +27 -1
  200. package/src/ts/client/grapesjs/LoginDialog.ts +204 -0
  201. package/src/ts/client/grapesjs/PublicationManager.ts +433 -0
  202. package/src/ts/client/grapesjs/PublicationUi.ts +366 -0
  203. package/src/ts/client/grapesjs/blocks.ts +17 -0
  204. package/src/ts/client/grapesjs/breadcrumbs.ts +79 -0
  205. package/src/ts/client/grapesjs/css-props.ts +910 -0
  206. package/src/ts/client/grapesjs/eleventy.ts +30 -7
  207. package/src/ts/client/grapesjs/footer.ts +42 -0
  208. package/src/ts/client/grapesjs/img.ts +147 -0
  209. package/src/ts/client/grapesjs/index.ts +311 -122
  210. package/src/ts/client/grapesjs/internal-links.test.ts +19 -1
  211. package/src/ts/client/grapesjs/internal-links.ts +31 -7
  212. package/src/ts/client/grapesjs/keymaps.ts +207 -0
  213. package/src/ts/client/grapesjs/new-page-dialog.ts +19 -3
  214. package/src/ts/client/grapesjs/openImport.ts +22 -0
  215. package/src/ts/client/grapesjs/page-panel.ts +109 -7
  216. package/src/ts/client/grapesjs/project-bar.ts +133 -72
  217. package/src/ts/client/grapesjs/resize-panel.ts +20 -0
  218. package/src/ts/client/grapesjs/rich-text.ts +38 -13
  219. package/src/ts/client/grapesjs/semantic.ts +20 -3
  220. package/src/ts/client/grapesjs/settings-sections.ts +117 -0
  221. package/src/ts/client/grapesjs/settings.ts +191 -96
  222. package/src/ts/client/grapesjs/storage.ts +187 -0
  223. package/src/ts/client/grapesjs/symbolDialogs.ts +21 -5
  224. package/src/ts/client/grapesjs/view-buttons.ts +42 -0
  225. package/src/ts/client/index.ts +80 -21
  226. package/src/ts/client/publication-transformers.test.ts +207 -0
  227. package/src/ts/client/publication-transformers.ts +280 -0
  228. package/src/ts/client/publish-custom-code-block.ts +31 -0
  229. package/src/ts/client/publish-fonts.ts +36 -0
  230. package/src/ts/client/utils.ts +70 -1
  231. package/src/ts/constants.ts +78 -0
  232. package/src/ts/externs.ts +17 -0
  233. package/src/ts/page.ts +20 -3
  234. package/src/ts/plugins/client/template.ts +246 -0
  235. package/src/ts/plugins/client/website-info.ts +84 -0
  236. package/src/ts/plugins/server/Cache.ts +32 -0
  237. package/src/ts/plugins/server/DownloadConnector.ts +146 -0
  238. package/src/ts/plugins/server/FtpConnector.test.ts +82 -0
  239. package/src/ts/plugins/server/FtpConnector.ts +621 -0
  240. package/src/ts/plugins/server/GitlabConnector.ts +749 -0
  241. package/src/ts/plugins/server/GitlabHostingConnector.ts +215 -0
  242. package/src/ts/plugins/server/PublicationOptimizer.ts +14 -0
  243. package/src/ts/plugins/server/SslPlugin.ts +84 -0
  244. package/src/ts/plugins/server/StaticPlugin.ts +45 -0
  245. package/src/ts/server/api/api.ts +19 -0
  246. package/src/ts/server/api/connectorApi.ts +464 -0
  247. package/src/ts/server/api/publicationApi.ts +159 -0
  248. package/src/ts/server/api/websiteApi.ts +462 -0
  249. package/src/ts/server/cli.ts +48 -14
  250. package/src/ts/server/config.ts +158 -60
  251. package/src/ts/server/connectors/FsHosting.ts +66 -0
  252. package/src/ts/server/connectors/FsStorage.test.ts +51 -0
  253. package/src/ts/server/connectors/FsStorage.ts +290 -0
  254. package/src/ts/server/connectors/connectors.ts +203 -0
  255. package/src/ts/server/events.ts +37 -0
  256. package/src/ts/server/expose.ts +19 -0
  257. package/src/ts/server/express.ts +57 -5
  258. package/src/ts/server/index.ts +79 -16
  259. package/src/ts/server/jobs.test.ts +75 -0
  260. package/src/ts/server/jobs.ts +89 -0
  261. package/src/ts/server/utils/BackwardCompat.ts +546 -528
  262. package/src/ts/server/utils/validation.ts +34 -0
  263. package/src/ts/types.ts +295 -85
  264. package/.dockerignore +0 -5
  265. package/.editorconfig +0 -14
  266. package/.eslintrc.json +0 -43
  267. package/.github/FUNDING.yml +0 -13
  268. package/.github/workflows/docker-hub-publish.yml +0 -36
  269. package/.github/workflows/npm-publish.yml +0 -19
  270. package/.github/workflows/test.yml +0 -26
  271. package/.nvmrc +0 -1
  272. package/.silex/default/.silex.data.json +0 -1
  273. package/CODE_OF_CONDUCT.md +0 -128
  274. package/CONTRIBUTING.md +0 -131
  275. package/Dockerfile +0 -15
  276. package/directus.silex.js +0 -7
  277. package/dist/constants.js +0 -4
  278. package/dist/events.js +0 -5
  279. package/dist/page.js +0 -15
  280. package/dist/server/cli.js +0 -43
  281. package/dist/server/config.js +0 -70
  282. package/dist/server/express.js +0 -18
  283. package/dist/server/index.js +0 -58
  284. package/dist/types.js +0 -34
  285. package/jest.config.js +0 -10
  286. package/logos/logo_by_ceubri/silex-icon-2018@200px.png +0 -0
  287. package/logos/logo_by_ceubri/silex-icon-2018@4x.png +0 -0
  288. package/logos/logo_by_ceubri/silex-logo-2018-white-transp.pdf +0 -0
  289. package/logos/logo_by_ceubri/silex-logo-2018-white.jpg +0 -0
  290. package/logos/logo_by_ceubri/silex-logo-2018-white.pdf +0 -0
  291. package/logos/logo_by_ceubri/silex-logo-2018-white.png +0 -0
  292. package/logos/logo_by_ceubri/silex-logo-2018-white@0.5x.png +0 -0
  293. package/logos/logo_by_ceubri/silex-logo-2018-white@0.75x.png +0 -0
  294. package/logos/logo_by_ceubri/silex-logo-2018-white@4x.jpg +0 -0
  295. package/logos/logo_by_ceubri/silex-logo-2018-white@4x.png +0 -0
  296. package/logos/logo_by_ceubri/silex-logo-2018.ai +5 -2521
  297. package/logos/logo_by_ceubri/silex-logo-2018.jpg +0 -0
  298. package/logos/logo_by_ceubri/silex-logo-2018.pdf +0 -0
  299. package/logos/logo_by_ceubri/silex-logo-2018.png +0 -0
  300. package/logos/logo_by_ceubri/silex-logo-2018@0.5x.png +0 -0
  301. package/logos/logo_by_ceubri/silex-logo-2018@0.75x.png +0 -0
  302. package/logos/logo_by_ceubri/silex-logo-2018@4x.jpg +0 -0
  303. package/logos/logo_by_ceubri/silex-logo-2018@4x.png +0 -0
  304. package/logos/silexlabs.png +0 -0
  305. package/src/example-client-config.js +0 -47
  306. package/src/plugins/AuthPlugin.js +0 -21
  307. package/src/plugins/Cache.js +0 -11
  308. package/src/plugins/DefaultBackend.js +0 -149
  309. package/src/plugins/ExpressPlugin.js +0 -39
  310. package/src/plugins/HooksPlugin.js +0 -58
  311. package/src/plugins/PublishPlugin.js +0 -69
  312. package/src/plugins/SslPlugin.js +0 -66
  313. package/src/plugins/StaticPlugin.js +0 -48
  314. package/src/plugins/WebsitePlugin.js +0 -207
  315. package/src/ts/client/grapesjs/publish.ts +0 -386
  316. package/src/ts/client/grapesjs/template.ts +0 -166
  317. package/src/ts/events.ts +0 -2
  318. package/tsconfig-server-debug.json +0 -19
  319. package/tsconfig-server-release.json +0 -19
  320. package/tsconfig.jest.json +0 -9
  321. package/tsconfig.json +0 -26
  322. package/webpack.config.js +0 -28
  323. package/webpack.debug.config.js +0 -8
@@ -1,4 +1,21 @@
1
- import grapesjs from 'grapesjs'
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import grapesjs, { Editor, EditorConfig } from 'grapesjs'
2
19
  import openImport from './openImport'
3
20
 
4
21
  /**
@@ -6,6 +23,8 @@ import openImport from './openImport'
6
23
  * Handle plugins, options and initialization of the editor
7
24
  */
8
25
 
26
+ const notificationContainer = document.createElement('div')
27
+
9
28
  // ////////////////////
10
29
  // Plugins
11
30
  // ////////////////////
@@ -13,60 +32,106 @@ import blocksBasicPlugin from 'grapesjs-blocks-basic'
13
32
  import styleFilterPlugin from 'grapesjs-style-filter'
14
33
  import formPlugin from 'grapesjs-plugin-forms'
15
34
  import codePlugin from 'grapesjs-custom-code'
35
+ import navbarPlugin from 'grapesjs-navbar'
16
36
  import uiSuggestClasses from '@silexlabs/grapesjs-ui-suggest-classes'
17
- import * as symbolsPlugin from '@silexlabs/grapesjs-symbols' // Why is this not working without *?
37
+ import filterStyles from '@silexlabs/grapesjs-filter-styles'
38
+ import symbolsPlugin from '@silexlabs/grapesjs-symbols'
18
39
  import loadingPlugin from '@silexlabs/grapesjs-loading'
19
- import fontsDialogPlugin, { cmdOpenFonts } from '@silexlabs/grapesjs-fonts'
40
+ import fontsDialogPlugin from '@silexlabs/grapesjs-fonts'
20
41
  import symbolDialogsPlugin, { cmdPromptAddSymbol } from './symbolDialogs'
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'
21
53
 
22
54
  import { pagePanelPlugin, cmdTogglePages, cmdAddPage } from './page-panel'
23
55
  import { newPageDialog, cmdOpenNewPageDialog } from './new-page-dialog'
24
- import { projectBarPlugin } from './project-bar'
56
+ import { PROJECT_BAR_PANEL_ID, projectBarPlugin } from './project-bar'
25
57
  import { settingsDialog, cmdOpenSettings } from './settings'
26
58
  import { blocksPlugin } from './blocks'
27
59
  import { semanticPlugin } from './semantic'
28
- import { richTextPlugin } from './rich-text'
60
+ import { orderedList, richTextPlugin, unorderedList } from './rich-text'
29
61
  import { internalLinksPlugin } from './internal-links'
30
- import { publishPlugin } from './publish'
31
- import { templatePlugin } from './template'
32
- import { eleventyPlugin } from './eleventy'
62
+ import {defaultKms, keymapsPlugin} from './keymaps'
63
+ import publicationManagerPlugin, { PublicationManagerOptions } from './PublicationManager'
64
+ import ViewButtons from './view-buttons'
65
+ import { storagePlugin } from './storage'
66
+ import { API_PATH, API_WEBSITE_ASSETS_WRITE, API_WEBSITE_PATH } from '../../constants'
67
+ import { ClientConfig } from '../config'
68
+ import { titleCase } from '../utils'
33
69
 
34
70
  const plugins = [
35
- {name: './grapesjs/project-bar', value: projectBarPlugin}, // has to be before panels and dialogs
36
- {name: './grapesjs/settings', value: settingsDialog},
71
+ {name: './project-bar', value: projectBarPlugin}, // has to be before panels and dialogs
72
+ {name: 'grapesjs-style-bg', value: backgroundPlugin},
73
+ {name: './settings', value: settingsDialog},
37
74
  {name: '@silexlabs/grapesjs-fonts', value: fontsDialogPlugin},
38
- {name: './grapesjs/new-page-dialog', value: newPageDialog},
39
- {name: './grapesjs/page-panel', value: pagePanelPlugin},
75
+ {name: './new-page-dialog', value: newPageDialog},
76
+ {name: './page-panel', value: pagePanelPlugin},
40
77
  {name: 'grapesjs-blocks-basic', value: blocksBasicPlugin},
41
- {name: './grapesjs/blocks', value: blocksPlugin},
42
- {name: './grapesjs/semantic', value: semanticPlugin},
43
- {name: './grapesjs/rich-text', value: richTextPlugin},
78
+ {name: './blocks', value: blocksPlugin},
79
+ {name: './view-buttons', value: ViewButtons},
80
+ {name: './semantic', value: semanticPlugin},
81
+ {name: './rich-text', value: richTextPlugin},
44
82
  {name: 'grapesjs-style-filter', value: styleFilterPlugin},
45
83
  {name: 'grapesjs-plugin-forms', value: formPlugin},
46
84
  {name: 'grapesjs-custom-code', value: codePlugin},
47
- {name: './grapesjs/internal-links', value: internalLinksPlugin},
85
+ {name: './internal-links', value: internalLinksPlugin},
86
+ {name: './keymaps', value: keymapsPlugin},
48
87
  {name: '@silexlabs/grapesjs-ui-suggest-classes', value: uiSuggestClasses},
49
- {name: './grapesjs/symbolDialogs', value: symbolDialogsPlugin},
88
+ {name: '@silexlabs/grapesjs-filter-styles', value: filterStyles},
89
+ {name: './symbolDialogs', value: symbolDialogsPlugin},
50
90
  {name: '@silexlabs/grapesjs-symbols', value: symbolsPlugin},
51
- {name: './grapesjs/publish', value: publishPlugin},
52
- {name: './grapesjs/template', value: templatePlugin},
53
- {name: './grapesjs/eleventy', value: eleventyPlugin},
91
+ {name: './PublicationManager', value: publicationManagerPlugin},
92
+ {name: './storage', value: storagePlugin},
93
+ {name: './LoginDialog', value: loginDialogPlugin},
54
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}
55
105
  ]
56
106
  // Check that all plugins are loaded correctly
57
107
  plugins
58
- .filter(p => !p.value)
108
+ .filter(p => typeof p.value !== 'function')
59
109
  .forEach(p => {
60
- throw new Error(`Plugin ${p.name} could not be loaded correctly`)
110
+ throw new Error(`Plugin ${p.name} could not be loaded correctly (${p.value})`)
61
111
  })
62
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
+
63
127
  // ////////////////////
64
128
  // Config
65
129
  // ////////////////////
66
130
  const catBasic = 'Containers'
67
131
  const catComponents = 'Components'
68
132
 
69
- export function getEditorConfig(id: string, rootUrl: string) {
133
+ export function getEditorConfig(config: ClientConfig): EditorConfig {
134
+ const { websiteId, storageId, rootUrl } = config
70
135
  return {
71
136
  container: '#gjs',
72
137
  height: '100%',
@@ -84,121 +149,222 @@ export function getEditorConfig(id: string, rootUrl: string) {
84
149
  },
85
150
 
86
151
  assetManager: {
87
- upload: `${rootUrl}assets/`,
152
+ upload: `${rootUrl}${API_PATH}${API_WEBSITE_PATH}${API_WEBSITE_ASSETS_WRITE}/?websiteId=${websiteId}${ storageId ? `&connectorId=${storageId}` : ''}`,
88
153
  },
89
154
 
90
155
  storageManager: {
91
- autoload: true,
92
- type: 'remote',
156
+ autoload: false,
157
+ type: 'connector',
93
158
  options: {
94
- remote: {
95
- urlStore: `${rootUrl}website/?id=${id}`,
96
- urlLoad: `${rootUrl}website/?id=${id}`,
159
+ connector: {
160
+ id: websiteId,
161
+ connectorId: storageId,
97
162
  },
98
163
  },
99
164
  },
100
165
 
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
+
190
+
101
191
  plugins: plugins.map(p => p.value),
102
192
 
103
193
  pluginsOpts: {
104
- [blocksBasicPlugin as any]: {
194
+ [blocksBasicPlugin.toString()]: {
105
195
  blocks: ['text', 'image', 'video', 'map'],
106
196
  category: catBasic,
107
197
  //flexGrid: true,
108
198
  },
109
- [projectBarPlugin as any]: {
199
+ [projectBarPlugin.toString()]: {
110
200
  panels: [
111
201
  {
112
202
  id: 'dash',
113
203
  className: 'logo',
114
- attributes: { title: 'Go to your dashboard' },
115
- link: '/',
116
- command: 'open-dash',
204
+ attributes: { title: 'Dashboard' },
205
+ command: () => {
206
+ window.location.href = '/'
207
+ },
117
208
  }, {
118
209
  id: 'block-manager-btn',
119
210
  className: 'block-manager-btn fa fa-fw fa-plus',
120
- attributes: { title: 'Blocks', containerClassName: 'block-manager-container', },
121
- command: 'open-blocks',
211
+ name: 'Blocks',
212
+ attributes: { title: `Blocks (${titleCase(defaultKms.kmBlocks.keys, '+')})`, containerClassName: 'block-manager-container', },
213
+ command: cmdToggleBlocks,
122
214
  }, {
123
215
  id: 'symbols-btn',
124
- className: 'symbols-btn fa fa-fw fa-diamond',
125
- attributes: { title: 'Symbols', containerClassName: 'symbols-list-container', },
126
- command: 'open-symbols',
216
+ className: 'symbols-btn fa-regular fa-gem',
217
+ name: 'Symbols',
218
+ attributes: { title: `Symbols (${titleCase(defaultKms.kmSymbols.keys, '+')})`, containerClassName: 'symbols-list-container', },
219
+ command: cmdToggleSymbols,
127
220
  buttons: [
128
221
  {
129
222
  id: 'symbol-create-button',
130
- className: 'pages__add-page fa fa-plus',
131
- label: 'Create symbol from selection',
223
+ className: 'gjs-pn-btn',
132
224
  command: cmdPromptAddSymbol,
225
+ text: '\u271A',
133
226
  },
134
227
  ],
135
228
  }, {
136
229
  id: 'page-panel-btn',
137
230
  className: 'page-panel-btn fa fa-fw fa-file',
138
- attributes: { title: 'Pages', containerClassName: 'page-panel-container', },
231
+ name: 'Pages',
232
+ attributes: { title: `Pages (${titleCase(defaultKms.kmPages.keys, '+')})`, containerClassName: 'page-panel-container', },
139
233
  command: cmdTogglePages,
140
234
  buttons: [{
141
- className: 'pages__add-page fa fa-file',
235
+ className: 'gjs-pn-btn',
142
236
  command: cmdAddPage,
143
- text: '+',
237
+ text: '\u271A',
144
238
  }],
145
239
  }, {
146
240
  id: 'layer-manager-btn',
147
- className: 'layer-manager-btn fa fa-fw fa-list',
148
- attributes: { title: 'Layers', containerClassName: 'layer-manager-container', },
149
- command: 'open-layers',
241
+ className: 'layer-manager-btn fa-solid fa-layer-group',
242
+ name: 'Layers',
243
+ attributes: { title: `Layers (${titleCase(defaultKms.kmLayers.keys, '+')})`, containerClassName: 'layer-manager-container', },
244
+ command: cmdToggleLayers,
150
245
  }, {
151
246
  id: 'font-dialog-btn',
152
- className: 'font-manager-btn fa fa-fw fa-font',
153
- attributes: { title: 'Fonts' },
154
- command: cmdOpenFonts,
247
+ className: 'font-manager-btn fa-solid fa-font',
248
+ name: 'Fonts',
249
+ attributes: { title: `Fonts (${titleCase(defaultKms.kmOpenFonts.keys, '+')})` },
250
+ command: () => {
251
+ editor.runCommand('open-fonts')
252
+ },
155
253
  }, {
156
254
  id: 'settings-dialog-btn',
157
- className: 'page-panel-btn fa fa-fw fa-cog',
158
- attributes: { title: 'Settings' },
255
+ className: 'page-panel-btn fa-solid fa-gears',
256
+ name: 'Settings',
257
+ attributes: { title: `Settings (${titleCase(defaultKms.kmOpenSettings.keys, '+')})` },
159
258
  command: cmdOpenSettings,
160
259
  }, {
161
260
  id: 'spacer',
162
261
  attributes: {},
163
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
+ },
164
294
  }, {
165
295
  id: 'logout-button',
166
296
  className: 'page-panel-btn fa fa-fw fa-sign-out',
167
297
  attributes: { title: 'Sign out' },
168
- command: 'relogin',
298
+ command: cmdLogout,
169
299
  },
170
300
  ],
171
301
  },
172
- [publishPlugin as any]: {
302
+ [publicationManagerPlugin.toString()]: {
173
303
  appendTo: 'options',
174
- rootUrl,
175
- id,
176
- },
177
- [pagePanelPlugin as any]: {
304
+ websiteId,
305
+ } as PublicationManagerOptions,
306
+ [pagePanelPlugin.toString()]: {
178
307
  cmdOpenNewPageDialog,
179
308
  cmdOpenSettings,
180
309
  appendTo: '.page-panel-container',
181
310
  },
182
- [uiSuggestClasses as any]: {
311
+ [uiSuggestClasses.toString()]: {
183
312
  enableCount: false,
184
313
  enablePerformance: false,
185
314
  },
186
- [internalLinksPlugin as any]: {
315
+ [filterStyles.toString()]: {
316
+ appendBefore: '.gjs-sm-sectors',
317
+ },
318
+ [internalLinksPlugin.toString()]: {
187
319
  // FIXME: warn the user about links in error
188
- onError: (errors) => console.log('Links errors:', errors),
320
+ onError: (errors) => console.warn('Links errors:', errors),
189
321
  },
190
- [codePlugin as any]: {
322
+ [keymapsPlugin.toString()]: {
323
+ disableKeymaps: false,
324
+ },
325
+ [codePlugin.toString()]: {
191
326
  blockLabel: 'HTML',
192
327
  blockCustomCode: {
193
328
  category: catComponents,
194
- }
329
+ },
330
+ codeViewOptions: {
331
+ autoFormat: false,
332
+ },
195
333
  },
196
- [symbolsPlugin as any]: {
334
+ [symbolsPlugin.toString()]: {
197
335
  appendTo: '.symbols-list-container',
336
+ emptyText: 'No symbol yet.',
337
+ primaryColor: PRIMARY_COLOR,
338
+ secondaryColor: SECONDARY_COLOR,
339
+ highlightColor: TERTIARY_COLOR,
340
+ },
341
+ [fontsDialogPlugin.toString()]: {
342
+ api_key: config.fontsApiKey,
343
+ server_url: config.fontsServerUrl,
344
+ api_url: config.fontsApiUrl,
198
345
  },
199
- [fontsDialogPlugin as any]: {
200
- api_key: 'AIzaSyAdJTYSLPlKz4w5Iqyy-JAF2o8uQKd1FKc',
346
+ [loginDialogPlugin.toString()]: {
347
+ id: websiteId,
348
+ } as LoginDialogOptions,
349
+ [rateLimitPlugin.toString()]: {
350
+ time: 5000,
201
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
+ }
202
368
  },
203
369
  }
204
370
  }
@@ -206,69 +372,92 @@ export function getEditorConfig(id: string, rootUrl: string) {
206
372
  // ////////////////////
207
373
  // Initialize editor
208
374
  // ////////////////////
209
- // Expose grapes for plugins
210
- // window['grapesjs'] = grapesjs
211
-
212
375
  // Keep a ref to the editor singleton
213
- let editor
214
-
215
- export function initEditor(config, grapesJsPlugins) {
376
+ let editor: Editor
377
+ export async function initEditor(config: EditorConfig) {
216
378
  if(editor) throw new Error('Grapesjs editor already created')
379
+ return new Promise<Editor>((resolve, reject) => {
380
+ try {
381
+ /* @ts-ignore */
382
+ editor = grapesjs.init(config)
383
+ } catch(e) {
384
+ console.error('Error initializing GrapesJs with plugins:', plugins, e)
385
+ reject(e)
386
+ }
217
387
 
218
- editor = grapesjs.init({
219
- plugins: [
220
- ...grapesJsPlugins,
221
- ...config.plugins,
222
- ],
223
- ...config,
224
- })
388
+ // customize the editor
389
+ ['text']
390
+ .forEach(id => editor.Blocks.get(id)?.set('category', 'Basics'))
391
+ ;['image', 'video']
392
+ .forEach(id => editor.Blocks.get(id)?.set('category', 'Media'))
393
+ ;['map']
394
+ .forEach(id => editor.Blocks.get(id)?.set('category', 'Components'))
395
+ editor.Blocks.render([])
396
+
397
+ editor.Commands.add('gjs-open-import-webpage', openImport(editor, {
398
+ modalImportLabel: '',
399
+ modalImportContent: 'Paste a web page HTML code here.',
400
+ modalImportButton: 'Import',
401
+ modalImportTitle: 'Import from website',
402
+ }))
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)
225
423
 
226
- // customize the editor
227
- ;['text']
228
- .forEach(id => editor.Blocks.get(id)?.set('category', 'Basics'))
229
- ;['image', 'video']
230
- .forEach(id => editor.Blocks.get(id)?.set('category', 'Media'))
231
- ;['map']
232
- .forEach(id => editor.Blocks.get(id)?.set('category', 'Components'))
233
- editor.Blocks.render()
234
-
235
- editor.Commands.add('gjs-open-import-webpage', openImport(editor, {
236
- modalImportLabel: '',
237
- modalImportContent: 'Paste a web page HTML code here.',
238
- modalImportButton: 'Import',
239
- modalImportTitle: 'Import from website',
240
- }))
241
-
242
- editor.on('load', () => {
243
- // // move the options panel to the sidebar
244
- // const optionsEl = editor.Panels.getPanel('options').view.el
245
- // editor.Panels.getPanel('project-bar-panel').view.el
246
- // .appendChild(options)
247
- // options.style.width = 0
248
- // options.style.position = 'static'
249
- // remove blocks and layers buttons from the properties
250
- setTimeout(() => {
251
- editor.Panels.getPanel('views').buttons.remove('open-blocks')
252
- editor.Panels.getPanel('views').buttons.remove('open-layers')
253
- editor.Panels.getPanel('views').view.el.firstChild.style.justifyContent = 'initial' // align left
424
+ // Adjustments to do when the editor is ready
425
+ editor.on('load', () => {
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
254
434
  editor.Panels.getPanel('options').buttons.remove('export-template')
255
- })
435
+ editor.Panels.getPanel('options').buttons.remove('fullscreen')
256
436
 
257
- // use the style filter plugin
258
- editor.StyleManager.addProperty('extra',{ extend: 'filter' })
259
- })
437
+ // Render the block manager, otherwise it is empty
438
+ editor.BlockManager.render(null)
260
439
 
261
- // Handle errors
262
- editor.on('storage:error:load', (err) => {
263
- editor.Modal.open({
264
- title: 'Error loading website',
265
- content: `This website could not be loaded.<br><hr>${err}`,
266
- })
267
- })
268
- editor.on('storage:error:store', (err) => {
269
- editor.Modal.open({
270
- title: 'Error saving website',
271
- content: `This website could not be saved.<br><hr>${err}`,
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
+ )
458
+
459
+ // GrapesJs editor is ready
460
+ resolve(editor)
272
461
  })
273
462
  })
274
463
  }
@@ -1,3 +1,20 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+
1
18
  import { internalLinksPlugin } from './internal-links'
2
19
  import { expect, test, beforeEach } from '@jest/globals'
3
20
  import grapesjs from 'grapesjs'
@@ -48,6 +65,7 @@ const page2 = {
48
65
  },
49
66
  }
50
67
  beforeEach(() => {
68
+ /* @ts-ignore */
51
69
  editor = grapesjs.init({
52
70
  headless: true,
53
71
  storageManager: { autoload: false },
@@ -64,7 +82,7 @@ test('init', () => {
64
82
  test('rename page and rewrite links in current page', () => {
65
83
  const page = editor.Pages.getSelected()
66
84
  expect(page.id).toBe(pageMain.id)
67
- expect(page.getName()).toBeUndefined()
85
+ expect(page.getName()).toBe('')
68
86
  const newName = 'Home page'
69
87
  const newPath = './home-page.html'
70
88
  // Do not work: page.setName(newName)