@silexlabs/silex 3.0.0-alpha.49 → 3.0.0-alpha.51

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 (119) hide show
  1. package/dist/client/client/config.d.ts +14 -1
  2. package/dist/client/client/grapesjs/PublicationManager.d.ts +2 -7
  3. package/dist/client/client/publication-transformers.d.ts +41 -0
  4. package/dist/client/css/admin.css +4 -1
  5. package/dist/client/js/main.js +3 -3
  6. package/dist/client/types.d.ts +18 -16
  7. package/dist/plugins/client/client/api.d.ts +83 -0
  8. package/dist/plugins/client/client/api.js +105 -0
  9. package/dist/plugins/client/client/api.js.map +1 -0
  10. package/dist/plugins/client/client/config.d.ts +58 -0
  11. package/dist/plugins/client/client/config.js +80 -0
  12. package/dist/plugins/client/client/config.js.map +1 -0
  13. package/dist/plugins/client/client/events.js +2 -0
  14. package/dist/plugins/client/client/events.js.map +1 -1
  15. package/dist/plugins/client/client/grapesjs/LoginDialog.d.ts +15 -0
  16. package/dist/plugins/client/client/grapesjs/LoginDialog.js +193 -0
  17. package/dist/plugins/client/client/grapesjs/LoginDialog.js.map +1 -0
  18. package/dist/plugins/client/client/grapesjs/PublicationManager.d.ts +70 -0
  19. package/dist/plugins/client/client/grapesjs/PublicationManager.js +310 -0
  20. package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +1 -0
  21. package/dist/plugins/client/client/grapesjs/PublicationUi.d.ts +61 -0
  22. package/dist/plugins/client/client/grapesjs/PublicationUi.js +324 -0
  23. package/dist/plugins/client/client/grapesjs/PublicationUi.js.map +1 -0
  24. package/dist/plugins/client/client/grapesjs/blocks.d.ts +1 -0
  25. package/dist/plugins/client/client/grapesjs/blocks.js +37 -0
  26. package/dist/plugins/client/client/grapesjs/blocks.js.map +1 -0
  27. package/dist/plugins/client/client/grapesjs/index.d.ts +5 -0
  28. package/dist/plugins/client/client/grapesjs/index.js +264 -0
  29. package/dist/plugins/client/client/grapesjs/index.js.map +1 -0
  30. package/dist/plugins/client/client/grapesjs/internal-links.d.ts +1 -0
  31. package/dist/plugins/client/client/grapesjs/internal-links.js +220 -0
  32. package/dist/plugins/client/client/grapesjs/internal-links.js.map +1 -0
  33. package/dist/plugins/client/client/grapesjs/new-page-dialog.d.ts +2 -0
  34. package/dist/plugins/client/client/grapesjs/new-page-dialog.js +83 -0
  35. package/dist/plugins/client/client/grapesjs/new-page-dialog.js.map +1 -0
  36. package/dist/plugins/client/client/grapesjs/openImport.d.ts +9 -0
  37. package/dist/plugins/client/client/grapesjs/openImport.js +74 -0
  38. package/dist/plugins/client/client/grapesjs/openImport.js.map +1 -0
  39. package/dist/plugins/client/client/grapesjs/page-panel.d.ts +3 -0
  40. package/dist/plugins/client/client/grapesjs/page-panel.js +113 -0
  41. package/dist/plugins/client/client/grapesjs/page-panel.js.map +1 -0
  42. package/dist/plugins/client/client/grapesjs/project-bar.d.ts +1 -0
  43. package/dist/plugins/client/client/grapesjs/project-bar.js +106 -0
  44. package/dist/plugins/client/client/grapesjs/project-bar.js.map +1 -0
  45. package/dist/plugins/client/client/grapesjs/rich-text.d.ts +1 -0
  46. package/dist/plugins/client/client/grapesjs/rich-text.js +31 -0
  47. package/dist/plugins/client/client/grapesjs/rich-text.js.map +1 -0
  48. package/dist/plugins/client/client/grapesjs/semantic.d.ts +1 -0
  49. package/dist/plugins/client/client/grapesjs/semantic.js +110 -0
  50. package/dist/plugins/client/client/grapesjs/semantic.js.map +1 -0
  51. package/dist/plugins/client/client/grapesjs/settings.d.ts +2 -0
  52. package/dist/plugins/client/client/grapesjs/settings.js +197 -0
  53. package/dist/plugins/client/client/grapesjs/settings.js.map +1 -0
  54. package/dist/plugins/client/client/grapesjs/storage.d.ts +1 -0
  55. package/dist/plugins/client/client/grapesjs/storage.js +124 -0
  56. package/dist/plugins/client/client/grapesjs/storage.js.map +1 -0
  57. package/dist/plugins/client/client/grapesjs/symbolDialogs.d.ts +3 -0
  58. package/dist/plugins/client/client/grapesjs/symbolDialogs.js +36 -0
  59. package/dist/plugins/client/client/grapesjs/symbolDialogs.js.map +1 -0
  60. package/dist/plugins/client/client/publication-transformers.d.ts +41 -0
  61. package/dist/plugins/client/client/publication-transformers.js +165 -0
  62. package/dist/plugins/client/client/publication-transformers.js.map +1 -0
  63. package/dist/plugins/client/constants.d.ts +29 -0
  64. package/dist/plugins/client/constants.js +46 -0
  65. package/dist/plugins/client/constants.js.map +1 -0
  66. package/dist/plugins/client/plugins/client/11ty.d.ts +17 -0
  67. package/dist/plugins/client/plugins/client/11ty.js +70 -0
  68. package/dist/plugins/client/plugins/client/11ty.js.map +1 -0
  69. package/dist/plugins/client/plugins/client/publicationRenderer.js +59 -21
  70. package/dist/plugins/client/plugins/client/publicationRenderer.js.map +1 -1
  71. package/dist/plugins/client/plugins/client/website-info.js +1 -1
  72. package/dist/plugins/client/plugins/client/website-info.js.map +1 -1
  73. package/dist/plugins/client/types.d.ts +18 -16
  74. package/dist/plugins/client/types.js.map +1 -1
  75. package/dist/plugins/server/plugins/server/FtpConnector.d.ts +2 -1
  76. package/dist/plugins/server/plugins/server/FtpConnector.js +5 -6
  77. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -1
  78. package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +1 -7
  79. package/dist/plugins/server/plugins/server/GitlabConnector.js +124 -112
  80. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
  81. package/dist/plugins/server/server/connectors/FsHosting.d.ts +2 -1
  82. package/dist/plugins/server/server/connectors/FsHosting.js +4 -5
  83. package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -1
  84. package/dist/plugins/server/server/connectors/FsStorage.js +1 -0
  85. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -1
  86. package/dist/plugins/server/server/connectors/connectors.d.ts +2 -1
  87. package/dist/plugins/server/server/connectors/connectors.js.map +1 -1
  88. package/dist/plugins/server/server/jobs.d.ts +6 -0
  89. package/dist/plugins/server/server/jobs.js +3 -1
  90. package/dist/plugins/server/server/jobs.js.map +1 -1
  91. package/dist/plugins/server/types.d.ts +18 -16
  92. package/dist/plugins/server/types.js.map +1 -1
  93. package/dist/server/server/api/publicationApi.js +14 -20
  94. package/dist/server/server/connectors/FsHosting.js +4 -5
  95. package/dist/server/server/connectors/FsStorage.js +1 -0
  96. package/dist/server/server/jobs.js +2 -1
  97. package/package.json +1 -1
  98. package/public/silex.js +23 -0
  99. package/src/css/website-info.scss +4 -1
  100. package/src/ts/client/config.ts +22 -2
  101. package/src/ts/client/events.ts +3 -0
  102. package/src/ts/client/grapesjs/PublicationManager.ts +23 -3
  103. package/src/ts/client/grapesjs/internal-links.ts +0 -2
  104. package/src/ts/client/grapesjs/storage.ts +1 -1
  105. package/src/ts/client/index.ts +4 -0
  106. package/src/ts/client/publication-transformers.test.ts +146 -0
  107. package/src/ts/client/publication-transformers.ts +188 -0
  108. package/src/ts/plugins/client/11ty.ts +89 -0
  109. package/src/ts/plugins/client/publicationRenderer.ts +64 -22
  110. package/src/ts/plugins/client/website-info.ts +1 -1
  111. package/src/ts/plugins/server/FtpConnector.ts +3 -3
  112. package/src/ts/plugins/server/GitlabConnector.ts +128 -109
  113. package/src/ts/server/api/publicationApi.ts +16 -23
  114. package/src/ts/server/connectors/FsHosting.ts +2 -2
  115. package/src/ts/server/connectors/FsStorage.ts +1 -0
  116. package/src/ts/server/connectors/connectors.ts +3 -1
  117. package/src/ts/server/jobs.ts +10 -0
  118. package/src/ts/server/utils/BackwardCompat.ts +530 -529
  119. package/src/ts/types.ts +20 -17
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-bar.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/project-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,UAAU,CAAA;AAErC,MAAM,OAAO,GAAG,mBAAmB,CAAA;AACnC,MAAM,gBAAgB,GAAG,uBAAuB,CAAA;AAEhD,MAAM,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,CAAC,CAAA;QACzC,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,IAAI,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAA;YAC7C,MAAM,KAAK,GAAG,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAA;YACzD,IAAG,IAAI,GAAG,KAAK,IAAI,CAAC,KAAK;gBAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;;gBAC5D,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;QAChD,CAAC,EAAE,GAAG,CAAC,CAAA,CAAC,oCAAoC;QAC5C,yEAAyE;QACzE,IAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;;YACvE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;IACpD,CAAC;IACD,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACxC,YAAY,EAAE,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const richTextPlugin: any;
@@ -0,0 +1,31 @@
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
+ import * as grapesjs from 'grapesjs/dist/grapes.min.js';
18
+ const pluginName = 'richText';
19
+ export const richTextPlugin = grapesjs.plugins.add(pluginName, (editor, opts) => {
20
+ editor.RichTextEditor.add('orderedList', {
21
+ icon: '1.',
22
+ attributes: { title: 'Ordered List' },
23
+ result: rte => rte.exec('insertOrderedList'),
24
+ });
25
+ editor.RichTextEditor.add('unorderedList', {
26
+ icon: '<i class="fa fa-list-ul"></i>',
27
+ attributes: { title: 'Unordered List' },
28
+ result: rte => rte.exec('insertUnorderedList'),
29
+ });
30
+ });
31
+ //# sourceMappingURL=rich-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/rich-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,QAAQ,MAAM,6BAA6B,CAAA;AAEvD,MAAM,UAAU,GAAG,UAAU,CAAA;AAE7B,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IAC9E,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE;QACvC,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,EAAC,KAAK,EAAE,cAAc,EAAC;QACnC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC;KAC7C,CAAC,CAAA;IACF,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,EAAE;QACzC,IAAI,EAAE,+BAA+B;QACrC,UAAU,EAAE,EAAC,KAAK,EAAE,gBAAgB,EAAC;QACrC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC;KAC/C,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const semanticPlugin: any;
@@ -0,0 +1,110 @@
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
+ import { html, render } from 'lit-html';
18
+ import { map } from 'lit-html/directives/map.js';
19
+ import grapesjs from 'grapesjs/dist/grapes.min.js';
20
+ // constants
21
+ const pluginName = 'semantic';
22
+ const tags = [
23
+ 'DIV',
24
+ 'P',
25
+ 'H1',
26
+ 'H2',
27
+ 'H3',
28
+ 'H4',
29
+ 'H5',
30
+ 'H6',
31
+ 'SPAN',
32
+ 'MAIN',
33
+ 'ASIDE',
34
+ 'SECTION',
35
+ 'ADDRESS',
36
+ 'ARTICLE',
37
+ 'BUTTON',
38
+ 'NAV',
39
+ 'HEADER',
40
+ 'FOOTER',
41
+ 'DETAILS',
42
+ 'SUMMARY',
43
+ 'PRE',
44
+ 'BLOCKQUOTE',
45
+ ];
46
+ // plugin code
47
+ export const semanticPlugin = grapesjs.plugins.add(pluginName, (editor, opts) => {
48
+ // Add the new trait to all component types
49
+ editor.DomComponents.getTypes().map(type => {
50
+ editor.DomComponents.addType(type.id, {
51
+ model: {
52
+ defaults: {
53
+ traits: [
54
+ // Keep the type original traits
55
+ ...editor.DomComponents.getType(type.id).model.prototype.defaults.traits,
56
+ // Add the new trait
57
+ {
58
+ label: 'Tag name',
59
+ type: 'tag-name',
60
+ },
61
+ ]
62
+ }
63
+ }
64
+ });
65
+ });
66
+ function doRender(el, tagName) {
67
+ const tagsWithCurrent = tags.includes(tagName.toUpperCase()) ? tags : tags.concat(tagName.toUpperCase());
68
+ render(html `
69
+ <label for="semantic__select" class="gjs-one-bg silex-label">Type</label>
70
+ <select id="semantic__select" @change=${event => doRender(el, event.target.value)}>
71
+ ${map(tagsWithCurrent, tag => html `
72
+ <option value="${tag}" ?selected=${tagName.toUpperCase() === tag}>${tag}</option>
73
+ `)}
74
+ </select>
75
+ `, el);
76
+ }
77
+ function doRenderCurrent(el) {
78
+ doRender(el, editor.getSelected()?.get('tagName') || '');
79
+ }
80
+ // Add semantic traits
81
+ // inspired by https://github.com/olivmonnier/grapesjs-plugin-header/blob/master/src/components.js
82
+ editor.TraitManager.addType('tag-name', {
83
+ createInput({ trait }) {
84
+ // Create a new element container and add some content
85
+ const el = document.createElement('div');
86
+ // update the UI when a page is added/renamed/removed
87
+ editor.on('page', () => doRenderCurrent(el));
88
+ doRenderCurrent(el);
89
+ // this will be the element passed to onEvent and onUpdate
90
+ return el;
91
+ },
92
+ // Update the component based on UI changes
93
+ // `elInput` is the result HTMLElement you get from `createInput`
94
+ onEvent({ elInput, component, event }) {
95
+ const value = elInput.querySelector('#semantic__select').value;
96
+ if (component.get('tagName').toUpperCase() === value.toUpperCase()) {
97
+ // Already done
98
+ }
99
+ else {
100
+ component.set('tagName', value);
101
+ }
102
+ },
103
+ // Update UI on the component change
104
+ onUpdate({ elInput, component }) {
105
+ const tagName = component.get('tagName');
106
+ doRender(elInput, tagName);
107
+ },
108
+ });
109
+ });
110
+ //# sourceMappingURL=semantic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/semantic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,UAAU,CAAA;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAC9C,OAAO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QACpC,QAAQ,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;YAC7B,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YACxC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC5B,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const cmdOpenSettings = "open-settings";
2
+ export declare const settingsDialog: any;
@@ -0,0 +1,197 @@
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
+ import { html, render } from 'lit-html';
18
+ import { live } from 'lit-html/directives/live.js';
19
+ import * as grapesjs from 'grapesjs/dist/grapes.min.js';
20
+ const pluginName = 'settings-dialog';
21
+ const el = document.createElement('div');
22
+ let modal;
23
+ export const cmdOpenSettings = 'open-settings';
24
+ let version = 'v3';
25
+ export const settingsDialog = grapesjs.plugins.add(pluginName, (editor, opts) => {
26
+ // Display Silex version from package.json
27
+ try {
28
+ version = VERSION;
29
+ }
30
+ catch (error) {
31
+ // Cannot get version from webpack (see plugin in webpack.config.js)
32
+ }
33
+ console.info('Silex version:', version);
34
+ editor.Commands.add(cmdOpenSettings, {
35
+ run: (_, sender, { page }) => {
36
+ modal = editor.Modal.open({
37
+ title: page ? 'Page settings' : 'Site Settings',
38
+ content: '',
39
+ attributes: { class: 'settings-dialog' },
40
+ })
41
+ .onceClose(() => {
42
+ editor.stopCommand(cmdOpenSettings); // apparently this is needed to be able to run the command several times
43
+ });
44
+ displaySettings(editor, opts, page);
45
+ modal.setContent(el);
46
+ const form = el.querySelector('form');
47
+ form.onsubmit = event => {
48
+ event.preventDefault();
49
+ saveSettings(editor, opts, page);
50
+ editor.stopCommand(cmdOpenSettings);
51
+ };
52
+ form.querySelector('input')?.focus();
53
+ return modal;
54
+ },
55
+ stop: () => {
56
+ modal.close();
57
+ },
58
+ });
59
+ // add settings to the website
60
+ editor.on('storage:start:store', (data) => {
61
+ data.settings = editor.getModel().get('settings');
62
+ data.name = editor.getModel().get('name');
63
+ });
64
+ editor.on('storage:end:load', (data) => {
65
+ const model = editor.getModel();
66
+ model.set('settings', data.settings || {});
67
+ model.set('name', data.name);
68
+ updateDom(editor);
69
+ });
70
+ editor.on('page', (e) => {
71
+ editor.Canvas.getFrameEl().addEventListener('load', () => {
72
+ updateDom(editor);
73
+ });
74
+ });
75
+ });
76
+ // Is the model a site or a page?
77
+ function isSite(model) { return !!model.getHtml; }
78
+ function displaySettings(editor, config, model = editor.getModel()) {
79
+ const settings = model.get('settings') || {};
80
+ model.set('settings', settings);
81
+ render(html `
82
+ <p>The page settings will override site settings, <a href="https://github.com/silexlabs/Silex/wiki/Settings" target="_blank">more info about settings here</a>.</p>
83
+ <form class="silex-form">
84
+ <h2>General settings</h2>
85
+ <div class="silex-form__group col2">
86
+ <label class="silex-form__element">
87
+ <h3>${isSite(model) ? 'Site name' : 'Page name'}</h3>
88
+ <p>${isSite(model) ? 'The project name in the editor, for you and your team.' : 'Label of the page in the editor, and file name of the HTML page.'}</p>
89
+ <input type="text" name="name" .value=${live(model.get('name') || '')}/>
90
+ </label>
91
+ <label class="silex-form__element">
92
+ <h3>Website language</h3>
93
+ <p>This is the default language code for this website. Example: en, fr, es...</p>
94
+ <input type="text" name="lang" .value=${live(settings.lang || '')}/>
95
+ </label>
96
+ <label class="silex-form__element">
97
+ <h3>Title</h3>
98
+ <p>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>
99
+ <input type="text" name="title" .value=${live(settings.title || '')}/>
100
+ </label>
101
+ <label class="silex-form__element">
102
+ <h3>Description</h3>
103
+ <p>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>
104
+ <input type="text" name="description" .value=${live(settings.description || '')}/>
105
+ </label>
106
+ <label class="silex-form__element">
107
+ <h3>Favicon</h3>
108
+ <p>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>
109
+ <input type="text" name="favicon" .value=${live(settings.favicon || '')}/>
110
+ </label>
111
+ </div>
112
+ <h2>Social networks sharing</h2>
113
+ <div>
114
+ <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>,
115
+ <a target="_blank" href="https://cards-dev.twitter.com/validator">Twitter</a>,
116
+ <a target="_blank" href="https://www.linkedin.com/post-inspector/inspect/">Linkedin</a></p>
117
+ </div>
118
+ <div class="silex-form__group col2">
119
+ <label class="silex-form__element">
120
+ <h3>Title</h3>
121
+ <p>The title of your website displayed when a user shares your website on a social network.
122
+ Do not include any branding in this title, just eye-catching phrase, e.g. "Learn everything about fishing".
123
+ Title should be between 60 and 90 characters long.</p>
124
+ <input type="text" name="og:title" .value=${live(settings['og:title'] || '')}/>
125
+ </label>
126
+ <label class="silex-form__element">
127
+ <h3>Description</h3>
128
+ <p>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>
129
+ <input type="text" name="og:description" .value=${live(settings['og:description'] || '')}/>
130
+ </label>
131
+ <label class="silex-form__element">
132
+ <h3>Image</h3>
133
+ <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>
134
+ <p>Please enter the full URL here, e.g. "http://mysite.com/path/to/image.jpg"</p>
135
+ <input type="text" name="og:image" .value=${live(settings['og:image'] || '')}/>
136
+ </label>
137
+ </div>
138
+ <h2>Code</h2>
139
+ <div class="silex-form__group">
140
+ <label class="silex-form__element">
141
+ <h3>HTML head</h3>
142
+ <p>HTML code which will be inserted in the HEAD tag.</p>
143
+ <textarea name="head" .value=${live(settings.head || '')}></textarea>
144
+ </label>
145
+ </div>
146
+ <footer>
147
+ <p class="silex-version">Silex ${version}</p>
148
+ <input class="silex-button" type="button" @click=${e => editor.stopCommand(cmdOpenSettings)} value="Cancel">
149
+ <input class="silex-button" type="submit" value="Ok">
150
+ </footer>
151
+ </form>
152
+ `, el);
153
+ }
154
+ function saveSettings(editor, config, model = editor.getModel()) {
155
+ const form = el.querySelector('form');
156
+ const formData = new FormData(form);
157
+ const data = Array.from(formData)
158
+ .reduce((aggregate, [key, value]) => {
159
+ aggregate[key] = value;
160
+ return aggregate;
161
+ }, {});
162
+ // take the name out to the main model (by design in grapesjs pages)
163
+ const { name, ...settings } = data;
164
+ model.set({
165
+ settings,
166
+ name,
167
+ });
168
+ // save if auto save is on
169
+ editor.getModel().set('changesCount', editor.getDirtyCount() + 1);
170
+ // update the DOM
171
+ updateDom(editor);
172
+ }
173
+ function getHeadContainer(doc, className) {
174
+ const container = doc.head.querySelector(`.${className}`);
175
+ if (container) {
176
+ return container;
177
+ }
178
+ const newContainer = doc.createElement('div');
179
+ newContainer.classList.add(className);
180
+ doc.head.appendChild(newContainer);
181
+ return newContainer;
182
+ }
183
+ function updateDom(editor) {
184
+ const doc = editor.Canvas.getDocument();
185
+ if (doc) {
186
+ // Site head
187
+ getHeadContainer(doc, 'site-head')
188
+ .innerHTML = editor.getModel().get('settings').head || '';
189
+ // Pages head
190
+ getHeadContainer(doc, 'page-head')
191
+ .innerHTML = editor.Pages.getSelected().get('settings')?.head || '';
192
+ }
193
+ else {
194
+ // No document??
195
+ }
196
+ }
197
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,UAAU,CAAA;AACrC,OAAO,EAAC,IAAI,EAAC,MAAM,6BAA6B,CAAA;AAChD,OAAO,KAAK,QAAQ,MAAM,6BAA6B,CAAA;AAIvD,MAAM,UAAU,GAAG,iBAAiB,CAAA;AACpC,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACxC,IAAI,KAAK,CAAA;AAKT,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAA;AAE9C,IAAI,OAAO,GAAG,IAAI,CAAA;AAClB,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IAC9E,0CAA0C;IAC1C,IAAI;QACF,OAAO,GAAG,OAAO,CAAA;KAClB;IAAC,OAAO,KAAK,EAAE;QACd,oEAAoE;KACrE;IACD,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IACvC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE;QACnC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAE;YACzB,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;gBACxB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe;gBAC/C,OAAO,EAAE,EAAE;gBACX,UAAU,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE;aACzC,C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gB,CAAC,GAAG,EAAE,SAAS;IACtC,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA;IACzD,IAAG,SAAS,EAAE;QACZ,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,YAAY,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC7C,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACrC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IAClC,OAAO,YAAY,CAAA;AACrB,CAAC;AACD,SAAS,SAAS,CAAC,MAAM;IACvB,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAA;IACvC,IAAG,GAAG,EAAE;QACN,YAAY;QACZ,gBAAgB,CAAC,GAAG,EAAE,WAAW,CAAC;aAC/B,SAAS,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,EAAE,CAAA;QAC3D,aAAa;QACb,gBAAgB,CAAC,GAAG,EAAE,WAAW,CAAC;aAC/B,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,IAAI,IAAI,EAAE,CAAA;KACtE;SAAM;QACL,gBAAgB;KACjB;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const storagePlugin: (editor: any) => void;
@@ -0,0 +1,124 @@
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
+ import { ConnectorType, ApiError } from '../../types';
18
+ import { websiteLoad, websiteSave } from '../api';
19
+ import { cmdLogin, eventLoggedIn, eventLoggedOut, getCurrentUser, updateUser } from './LoginDialog';
20
+ async function wait(ms) {
21
+ return new Promise((resolve) => {
22
+ setTimeout(resolve, ms);
23
+ });
24
+ }
25
+ export const storagePlugin = (editor) => {
26
+ editor.Storage.add('connector', {
27
+ async load(options) {
28
+ try {
29
+ const user = await getCurrentUser(editor) ?? await updateUser(editor, ConnectorType.STORAGE, options.connectorId);
30
+ if (user) {
31
+ const data = await websiteLoad({ websiteId: options.id, connectorId: user.storage.connectorId });
32
+ return data;
33
+ }
34
+ else {
35
+ return new Promise((resolve, reject) => {
36
+ editor.once(eventLoggedIn, async () => {
37
+ try {
38
+ editor.StorageManager.setAutosave(false);
39
+ const data = await editor.Storage.load(options);
40
+ editor.StorageManager.setAutosave(true);
41
+ //editor.loadProjectData(data)
42
+ resolve(data);
43
+ }
44
+ catch (err) {
45
+ console.error('connectorPlugin load error', err);
46
+ reject(err);
47
+ }
48
+ });
49
+ editor.Commands.run(cmdLogin);
50
+ });
51
+ }
52
+ }
53
+ catch (err) {
54
+ console.error('connectorPlugin load error', err);
55
+ throw err;
56
+ }
57
+ },
58
+ async store(data, options) {
59
+ try {
60
+ if (await getCurrentUser(editor)) {
61
+ const user = await getCurrentUser(editor);
62
+ await websiteSave({ websiteId: options.id, connectorId: user.storage.connectorId, data });
63
+ }
64
+ else {
65
+ editor.once(eventLoggedIn, () => {
66
+ return editor.Storage.save(options);
67
+ });
68
+ editor.Commands.run(cmdLogin);
69
+ }
70
+ }
71
+ catch (err) {
72
+ console.error('connectorPlugin store error', err);
73
+ throw err;
74
+ }
75
+ }
76
+ });
77
+ // Handle errors
78
+ editor.on('storage:error:load', (err) => {
79
+ handleError(err);
80
+ });
81
+ editor.on('storage:error:store', (err) => {
82
+ handleError(err);
83
+ });
84
+ editor.on('asset:upload:end', (err) => {
85
+ editor.store();
86
+ });
87
+ editor.on('asset:upload:error', (err) => {
88
+ handleError(err);
89
+ });
90
+ function handleError(_err) {
91
+ const err = typeof _err === 'string' ? JSON.parse(_err) : _err;
92
+ console.error('Error with loading or saving website or uploading asset', err, err instanceof ApiError);
93
+ if (err instanceof ApiError) {
94
+ console.error('ApiError', err.httpStatusCode, err.message);
95
+ switch (err.httpStatusCode) {
96
+ case 404:
97
+ return editor.Modal.open({
98
+ title: 'Website not found',
99
+ content: `This website could not be found.<br><hr>${err.message}`,
100
+ });
101
+ case 403:
102
+ return editor.Modal.open({
103
+ title: 'Access denied',
104
+ content: `You are not allowed to access this website.<br><hr>${err.message}`,
105
+ });
106
+ case 401:
107
+ editor.trigger(eventLoggedOut);
108
+ return;
109
+ default:
110
+ return editor.Modal.open({
111
+ title: 'Error',
112
+ content: `An error occured.<br>${err.message}`,
113
+ });
114
+ }
115
+ }
116
+ else {
117
+ return editor.Modal.open({
118
+ title: 'Error',
119
+ content: `An error occured.<br>${err.message}`,
120
+ });
121
+ }
122
+ }
123
+ };
124
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAsD,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACzG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEnG,KAAK,UAAU,IAAI,CAAC,EAAU;IAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,E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,EAAE,OAAO;gBACd,OAAO,EAAE,wBAAwB,GAAG,CAAC,OAAO,EAAE;aAC/C,CAAC,CAAA;SACH;IACH,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const cmdPromptAddSymbol = "symbol-prompt-add";
2
+ declare const _default: any;
3
+ export default _default;
@@ -0,0 +1,36 @@
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
+ import * as grapesjs from 'grapesjs/dist/grapes.min.js';
18
+ import { cmdAddSymbol } from '@silexlabs/grapesjs-symbols';
19
+ export const cmdPromptAddSymbol = 'symbol-prompt-add';
20
+ export default grapesjs.plugins.add(name, (editor, opts) => {
21
+ function getNext(prefix) {
22
+ let idx = 1;
23
+ while (editor.Symbols.find(s => s.get('label') === prefix + idx)) {
24
+ idx++;
25
+ }
26
+ return prefix + idx;
27
+ }
28
+ editor.Commands.add(cmdPromptAddSymbol, {
29
+ run: (_, sender) => {
30
+ const label = prompt('Label', getNext('Symbol '));
31
+ const icon = prompt('Icon', 'fa-list');
32
+ editor.runCommand(cmdAddSymbol, { label, icon });
33
+ }
34
+ });
35
+ });
36
+ //# sourceMappingURL=symbolDialogs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbolDialogs.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/symbolDialogs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,QAAQ,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAA;AAErD,eAAe,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACzD,SAAS,OAAO,CAAC,MAAM;QACrB,IAAI,GAAG,GAAG,CAAC,CAAA;QACX,OAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,MAAM,GAAG,GAAG,CAAC,EAAE;YAC/D,GAAG,EAAE,CAAA;SACN;QACD,OAAO,MAAM,GAAG,GAAG,CAAA;IACrB,CAAC;IACD,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,kBAAkB,EAAE;QACtC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YACjB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;YACjD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;YACtC,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAClD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,41 @@
1
+ import { Component, CssRule, ObjectStrings, Page } from 'grapesjs';
2
+ import { ClientSideFile, PublicationData } from '../types';
3
+ import { ClientConfig } from './config';
4
+ /**
5
+ * Interface for publication transformers
6
+ * They are added to the config object with config.addPublicationTransformer()
7
+ */
8
+ export interface PublicationTransformer {
9
+ renderComponent?(component: Component, toHtml: () => string): string | undefined;
10
+ renderCssRule?(rule: CssRule, initialRule: () => ObjectStrings): ObjectStrings | undefined;
11
+ pageToSlug?(page: Page): string;
12
+ transformFile?(file: ClientSideFile, page: Page | null): ClientSideFile;
13
+ }
14
+ /**
15
+ * Init publication transformers
16
+ * Called at startup in the /index.ts file
17
+ */
18
+ export declare function initPublicationTransformers(config: ClientConfig): Promise<void>;
19
+ /**
20
+ * Alter the components rendering
21
+ * Exported for unit tests
22
+ */
23
+ export declare function transformComponents(config: ClientConfig): void;
24
+ /**
25
+ * Alter the styles rendering
26
+ * Exported for unit tests
27
+ */
28
+ export declare function transformStyles(config: ClientConfig): void;
29
+ /**
30
+ * Create page slugs
31
+ * Exported for unit tests
32
+ */
33
+ export declare function transformPages(config: ClientConfig): void;
34
+ /**
35
+ * Transform files
36
+ * Exported for unit tests
37
+ */
38
+ export declare function transformFiles(config: ClientConfig, data: PublicationData): void;
39
+ export declare function resetTransformComponents(config: ClientConfig): void;
40
+ export declare function resetTransformStyles(config: ClientConfig): void;
41
+ export declare function resetTransformPages(config: ClientConfig): void;