@silexlabs/silex 3.0.1-alpha.0 → 3.0.2

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 +92 -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 +80 -19
  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,92 +1,153 @@
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 { Editor, Panel } from 'grapesjs'
1
19
  import {html, render} from 'lit-html'
2
20
 
3
- const panelId = 'project-bar-panel'
4
- const containerPanelId = 'project-bar-container'
21
+ export const PROJECT_BAR_PANEL_ID = 'project-bar-panel'
22
+ export const containerPanelId = 'project-bar-container'
23
+
24
+ export interface PanelObject {
25
+ command: string | ((editor: Editor) => void)
26
+ text: string
27
+ className: string
28
+ name?: string
29
+ attributes: {
30
+ title?: string
31
+ containerClassName?: string
32
+ }
33
+ buttons?: {
34
+ command: string
35
+ text: string
36
+ className: string
37
+ }[]
38
+ onClick?: (editor: Editor) => void
39
+ }
5
40
 
6
41
  export const projectBarPlugin = (editor, opts) => {
7
42
  // create the panels container for all panels in grapesjs
8
43
  const containerPanel = editor.Panels.addPanel({
9
44
  id: containerPanelId,
10
- visible : false,
45
+ visible: false,
46
+ // resize project panel button
47
+ buttons: [{
48
+ id: 'resizeBlocks',
49
+ className: 'viewsOptionsProjectPanel__size-btn',
50
+ command: 'resize-ProjectPanel',
51
+ attributes: { title: 'Resize Project Panel' },
52
+ }],
53
+ })
54
+ // resize project panel command
55
+ editor.Commands.add('resize-ProjectPanel', {
56
+ run: (editor, sender) => {
57
+ document.documentElement.style.setProperty('--viewsProjectPanelWidth', '26%')
58
+ },
59
+ stop: (editor, sender) => {
60
+ document.documentElement.style.setProperty('--viewsProjectPanelWidth', '13%')
61
+ },
11
62
  })
12
63
  // create the project bar panel in grapesjs
13
- const projectBarPanel = editor.Panels.addPanel({
14
- id: panelId,
64
+ editor.Panels.addPanel({
65
+ id: PROJECT_BAR_PANEL_ID,
15
66
  buttons: opts.panels,
16
- visible : true,
67
+ visible: true,
17
68
  })
18
- const panelsEl = opts.panels.map(panel => {
19
- const el = document.createElement('div')
69
+ // add the panels to the container
70
+ opts.panels.map(panel => addButton(editor, panel))
20
71
 
21
- // create container for panel
22
- if(panel.attributes.containerClassName) {
23
- el.classList.add('project-bar__panel', panel.attributes.containerClassName, 'gjs-hidden')
72
+ // Handle the preview mode which behaves oddly
73
+ editor.on('stop:preview', () => {
74
+ containerPanel.set('visible', false)
75
+ updateSqueez(editor)
76
+ })
24
77
 
25
- // add header
26
- if(panel.attributes.title) {
27
- render(html`
28
- <header class="project-bar__panel-header">
29
- <h3 class="project-bar__panel-header-title">${ panel.attributes.title }</h3>
30
- ${ panel.buttons?.map(button => {
31
- return html`
32
- <div
33
- class="project-bar__panel-header-button ${ button.className }"
34
- @click=${e => editor.runCommand(button.command)}
35
- ><span>${ button.text }</span></div>
36
- `
37
- }) }
38
- </header>
39
- `, el)
40
- }
78
+ // All other events where the canvas is resized
79
+ editor.on('load device:select page', () => {
80
+ updateSqueez(editor)
81
+ })
82
+ }
41
83
 
42
- // temporarily attach it to the body
43
- // this lets the block manager and other plugins attach to their container
44
- document.body.appendChild(el)
84
+ function updateSqueez(editor: Editor) {
85
+ const containerPanel = editor.Panels.getPanel(containerPanelId)
86
+ // make sure the squeez corresponds to the state (reset when change page)
87
+ if(containerPanel.get('visible')) document.body.classList.add('silex-squeeze-left')
88
+ else document.body.classList.remove('silex-squeeze-left')
89
+ editor.refresh()
90
+ }
45
91
 
46
- // on load attach the panels to the main container
47
- // this is when the main containerPanel has an element
48
- editor.on('load', () => {
49
- const containerPanelEl = containerPanel.view.el
50
- containerPanelEl.appendChild(el)
51
- })
92
+ export function addButton(editor: Editor, panel: PanelObject) {
93
+ const containerPanel = editor.Panels.getPanel(containerPanelId)
94
+ const el = document.createElement('div')
95
+ // create container for panel
96
+ if(panel.attributes.containerClassName) {
97
+ el.classList.add('project-bar__panel', panel.attributes.containerClassName, 'gjs-hidden')
98
+ // add header
99
+ const title = panel.name ?? panel.attributes.title
100
+ if(title) {
101
+ render(html`
102
+ <header class="project-bar__panel-header">
103
+ <h3 class="project-bar__panel-header-title">${ title }</h3>
104
+ ${ panel.buttons?.map(button => {
105
+ return html`
106
+ <div
107
+ class="project-bar__panel-header-button ${ button.className }"
108
+ @click=${e => editor.runCommand(button.command)}
109
+ ><span>${ button.text }</span></div>
110
+ `
111
+ }) }
112
+ </header>
113
+ `, el)
52
114
  }
53
-
54
- // commands for show / hide panels
55
- editor.Commands.add(panel.command, {
56
- run() {
57
- if(panel.link) {
58
- window.open(panel.link)
59
- }
60
- if(panel.attributes.containerClassName) {
61
- containerPanel.set('visible', true)
62
- el.classList.remove('gjs-hidden')
63
- editor.Canvas.getFrameEl().classList.add('silex-squeeze-left')
64
- }
65
- },
66
- stop() {
67
- if(panel.attributes.containerClassName) {
68
- containerPanel.set('visible', false)
69
- el.classList.add('gjs-hidden')
70
- editor.Canvas.getFrameEl().classList.remove('silex-squeeze-left')
71
- }
72
- },
115
+ // temporarily attach it to the body
116
+ // this lets the block manager and other plugins attach to their container
117
+ document.body.appendChild(el)
118
+ // on load attach the panels to the main container
119
+ // this is when the main containerPanel has an element
120
+ editor.on('load', () => {
121
+ const containerPanelEl = containerPanel.view.el
122
+ containerPanelEl.appendChild(el)
73
123
  })
74
- })
75
- function updateSqueez() {
76
- const containerPanelEl = containerPanel.view.el
77
- const iframe = editor.Canvas.getFrameEl()
78
- iframe.classList.remove('enable-squeeze')
79
- setTimeout(() => {
80
- const left = iframe.getClientRects()[0]?.left
81
- const right = containerPanelEl.getClientRects()[0]?.right
82
- if(left < right || !right) iframe.classList.add('enable-squeeze')
83
- else iframe.classList.remove('enable-squeeze')
84
- }, 400) // More than the transition duration
85
- // make sure the squeez corresponds to the state (reset when change page)
86
- if(containerPanel.get('visible')) iframe.classList.add('silex-squeeze-left')
87
- else iframe.classList.remove('silex-squeeze-left')
88
124
  }
89
- editor.on('load device:select page', () => {
90
- updateSqueez()
125
+ // commands for show / hide panels
126
+ // handle the case where command is a normal command, then let the Panel handle it
127
+ typeof panel.command === 'string' && editor.Commands.add(panel.command, {
128
+ run() {
129
+ if(panel.attributes.containerClassName) {
130
+ containerPanel.set('visible', true)
131
+ el.classList.remove('gjs-hidden')
132
+ document.body.classList.add('silex-squeeze-left')
133
+ editor.refresh()
134
+ }
135
+ // Call the onClick function if it exists
136
+ if(panel.onClick) panel.onClick(editor)
137
+ // Remove the dirty flag
138
+ el.classList.remove('project-bar__dirty')
139
+ },
140
+ stop() {
141
+ if(panel.attributes.containerClassName) {
142
+ containerPanel.set('visible', false)
143
+ el.classList.add('gjs-hidden')
144
+ document.body.classList.remove('silex-squeeze-left')
145
+ editor.refresh()
146
+ }
147
+ // Call the onClick function if it exists
148
+ if(panel.onClick) panel.onClick(editor)
149
+ // Remove the dirty flag
150
+ el.classList.remove('project-bar__dirty')
151
+ },
91
152
  })
92
153
  }
@@ -0,0 +1,20 @@
1
+ export default function(editor) {
2
+ editor.Panels.addPanel({
3
+ id: 'viewsOptions',
4
+ buttons: [{
5
+ id: 'resize',
6
+ // icon for arrow left
7
+ className: 'viewsOptions__size-btn',
8
+ command: 'resize-panel',
9
+ attributes: { title: 'Resize panel' },
10
+ }],
11
+ })
12
+ editor.Commands.add('resize-panel', {
13
+ run: (editor, sender) => {
14
+ document.documentElement.style.setProperty('--viewsPanelWidth', '40%')
15
+ },
16
+ stop: (editor, sender) => {
17
+ document.documentElement.style.setProperty('--viewsPanelWidth', '20%')
18
+ },
19
+ })
20
+ }
@@ -1,16 +1,41 @@
1
- import * as grapesjs from 'grapesjs/dist/grapes.min.js'
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 { RichTextEditorAction } from 'grapesjs'
2
19
 
3
20
  const pluginName = 'richText'
4
21
 
5
- export const richTextPlugin = grapesjs.plugins.add(pluginName, (editor, opts) => {
6
- editor.RichTextEditor.add('orderedList', {
7
- icon: '1.',
8
- attributes: {title: 'Ordered List'},
9
- result: rte => rte.exec('insertOrderedList'),
10
- })
11
- editor.RichTextEditor.add('unorderedList', {
12
- icon: '<i class="fa fa-list-ul"></i>',
13
- attributes: {title: 'Unordered List'},
14
- result: rte => rte.exec('insertUnorderedList'),
15
- })
16
- })
22
+ export const orderedList: RichTextEditorAction = {
23
+ name: 'orderedList',
24
+ icon: '1.',
25
+ attributes: { title: 'Ordered List' },
26
+ result: rte => rte.exec('insertOrderedList'),
27
+ }
28
+
29
+ export const unorderedList: RichTextEditorAction = {
30
+ name: 'unorderedList',
31
+ icon: '•',
32
+ //icon: '<i class="fa fa-list-ul"></i>',
33
+ attributes: { title: 'Unordered List' },
34
+ result: rte => rte.exec('insertUnorderedList'),
35
+ }
36
+
37
+ export const richTextPlugin = (editor, opts) => {
38
+ // This doesn't work, it is now added in the editor config
39
+ //editor.RichTextEditor.add('orderedList', orderedList)
40
+ //editor.RichTextEditor.add('unorderedList', unorderedList)
41
+ }
@@ -1,6 +1,22 @@
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 {html, render} from 'lit-html'
2
19
  import {map} from 'lit-html/directives/map.js'
3
- import grapesjs from 'grapesjs/dist/grapes.min.js'
4
20
 
5
21
  // constants
6
22
  const pluginName = 'semantic'
@@ -31,7 +47,7 @@ const tags = [
31
47
  ]
32
48
 
33
49
  // plugin code
34
- export const semanticPlugin = grapesjs.plugins.add(pluginName, (editor, opts) => {
50
+ export const semanticPlugin = (editor, opts) => {
35
51
  // Add the new trait to all component types
36
52
  editor.DomComponents.getTypes().map(type => {
37
53
  editor.DomComponents.addType(type.id, {
@@ -44,6 +60,7 @@ export const semanticPlugin = grapesjs.plugins.add(pluginName, (editor, opts) =>
44
60
  {
45
61
  label: 'Tag name',
46
62
  type: 'tag-name',
63
+ name: 'tag-name',
47
64
  },
48
65
  ]
49
66
  }
@@ -94,4 +111,4 @@ export const semanticPlugin = grapesjs.plugins.add(pluginName, (editor, opts) =>
94
111
  doRender(elInput, tagName)
95
112
  },
96
113
  })
97
- })
114
+ }
@@ -0,0 +1,117 @@
1
+ import {live} from 'lit-html/directives/live.js'
2
+ import {html, TemplateResult} from 'lit-html'
3
+ import { WebsiteSettings } from '../../types'
4
+
5
+ // ID of the code editor wrapper
6
+ export const idCodeWrapper = 'settings-head-wrapper'
7
+
8
+ // Is the model a site or a page?
9
+ export function isSite(model: any) { return !!model.getHtml }
10
+
11
+ export interface SettingsSection {
12
+ id: string
13
+ label: string
14
+ render: (settings: WebsiteSettings, model: Backbone.Model) => TemplateResult
15
+ }
16
+
17
+ /**
18
+ * This is the settings dialog default sections
19
+ * Each section has an entry in the sidebar
20
+ * Each section render as part of the settings form
21
+ * The form is submitted to save the settings with all FormData
22
+ */
23
+ export const defaultSections: SettingsSection[] = [{
24
+ id: 'general',
25
+ label: 'General',
26
+ render: (settings, model) => html`
27
+ <div id="settings-general" class="silex-hideable">
28
+ <div class="gjs-sm-sector-title">General</div>
29
+ <div class="silex-form__group col2">
30
+ <label class="silex-form__element">
31
+ <h3>${isSite(model) ? 'Site name' : 'Page name'}</h3>
32
+ <p class="silex-help">${isSite(model) ? 'The project name in the editor, for you to remember what it is about.' : 'Label of the page in the editor, and file name of the published HTML page.'}</p>
33
+ <input type="text" name="name" .value=${live(model.get('name') || '')}/>
34
+ </label>
35
+ <label class="silex-form__element">
36
+ <h3>Website language</h3>
37
+ <p class="silex-help">This is the default language code for this website. Example: en, fr, es...</p>
38
+ <input type="text" name="lang" .value=${live(settings.lang || '')}/>
39
+ </label>
40
+ </div>
41
+ </div>
42
+ `,
43
+ }, {
44
+ id: 'seo',
45
+ label: 'SEO',
46
+ render: (settings, model) => html`
47
+ <div id="settings-seo" class="silex-hideable silex-hidden">
48
+ <div class="gjs-sm-sector-title">SEO</div>
49
+ <div class="silex-form__group col2">
50
+ <label class="silex-form__element">
51
+ <h3>Title</h3>
52
+ <p class="silex-help">Title of the browser window, and title in the search engines results. It is used by search engines to find out what your site is talking about. The title should be a maximum of 70 characters long, including spaces.</p>
53
+ <input type="text" name="title" .value=${live(settings.title || '')}/>
54
+ </label>
55
+ <label class="silex-form__element">
56
+ <h3>Description</h3>
57
+ <p class="silex-help">Description displayed by the search engines in search results. It is used by search engines to find out what your site is talking about. It is best to keep meta descriptions between 150 and 160 characters.</p>
58
+ <input type="text" name="description" .value=${live(settings.description || '')}/>
59
+ </label>
60
+ <label class="silex-form__element">
61
+ <h3>Favicon</h3>
62
+ <p class="silex-help">Small image displayed in the browser's address bar and in tabs. The recommended size is 16×16 or 32×32 pixels. This can be a URL or a relative path.</p>
63
+ <input type="text" name="favicon" .value=${live(settings.favicon || '')}/>
64
+ </label>
65
+ </div>
66
+ </div>
67
+ `,
68
+ }, {
69
+ id: 'social',
70
+ label: 'Social',
71
+ render: (settings, model) => html`
72
+ <div id="settings-social" class="silex-hideable silex-hidden">
73
+ <div class="gjs-sm-sector-title">Social</div>
74
+ <div class="silex-help">
75
+ <p>Once your website is live, you can use these tools to test sharing:&nbsp;<a target="_blank" href="https://developers.facebook.com/tools/debug/">Facebook</a>,
76
+ <a target="_blank" href="https://cards-dev.twitter.com/validator">Twitter</a>,
77
+ <a target="_blank" href="https://www.linkedin.com/post-inspector/inspect/">Linkedin</a></p>
78
+ </div>
79
+ <div class="silex-form__group col2">
80
+ <label class="silex-form__element">
81
+ <h3>Title</h3>
82
+ <p class="silex-help">The title of your website displayed when a user shares your website on a social network.
83
+ Do not include any branding in this title, just eye-catching phrase, e.g. "Learn everything about fishing".
84
+ Title should be between 60 and 90 characters long.</p>
85
+ <input type="text" name="og:title" .value=${live(settings['og:title'] || '')}/>
86
+ </label>
87
+ <label class="silex-form__element">
88
+ <h3>Description</h3>
89
+ <p class="silex-help">Description displayed when a user shares your website on a social network. Make it catchy, and invite readers to visit your website too, e.g. "Sam's website about fishing, check it out!" Title should be between 60 and 90 characters long.</p>
90
+ <input type="text" name="og:description" .value=${live(settings['og:description'] || '')}/>
91
+ </label>
92
+ <label class="silex-form__element">
93
+ <h3>Image</h3>
94
+ <div class="silex-help">
95
+ <p>Thumbnail image which is displayed when your website is shared on a social network. The optimal size is 1200×627 pixels. At this size, your thumbnail will be big and stand out from the crowd. But do not exceed the 5MB size limit. If you use an image that is smaller than 400 pixels x 209 pixels, it will render as a much smaller thumbnail.</p>
96
+ <p>Please enter the full URL here, e.g. "http://mysite.com/path/to/image.jpg"</p>
97
+ </div>
98
+ <input type="text" name="og:image" .value=${live(settings['og:image'] || '')}/>
99
+ </label>
100
+ </div>
101
+ </div>
102
+ `,
103
+ }, {
104
+ id: 'code',
105
+ label: 'Code',
106
+ render: (settings, model) => html`
107
+ <div id="settings-code" class="silex-hideable silex-hidden">
108
+ <div class="gjs-sm-sector-title">Code</div>
109
+ <div class="silex-form__group">
110
+ <label class="silex-form__element" id="${idCodeWrapper}">
111
+ <h3>HTML head</h3>
112
+ <p class="silex-help">HTML code which will be inserted in the HEAD tag.</p>
113
+ </label>
114
+ </div>
115
+ </div>
116
+ `,
117
+ }]