@silexlabs/silex 3.0.0-alpha.96 → 3.0.0
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.
- package/.env.default +2 -1
- package/README.md +31 -9
- package/dist/client/client/api.d.ts +5 -0
- package/dist/client/client/assetUrl.d.ts +3 -0
- package/dist/client/client/config.d.ts +31 -0
- package/dist/client/client/events.d.ts +7 -1
- package/dist/client/client/grapesjs/PublicationManager.d.ts +2 -1
- package/dist/client/client/grapesjs/css-props.d.ts +6 -0
- package/dist/client/client/grapesjs/img.d.ts +6 -0
- package/dist/client/client/grapesjs/index.d.ts +2 -2
- package/dist/client/client/grapesjs/new-page-dialog.d.ts +1 -1
- package/dist/client/client/grapesjs/page-panel.d.ts +1 -1
- package/dist/client/client/grapesjs/project-bar.d.ts +16 -0
- package/dist/client/client/grapesjs/resize-panel.d.ts +1 -0
- package/dist/client/client/grapesjs/rich-text.d.ts +4 -1
- package/dist/client/client/grapesjs/semantic.d.ts +1 -1
- package/dist/client/client/grapesjs/settings-sections.d.ts +15 -0
- package/dist/client/client/grapesjs/settings.d.ts +3 -1
- package/dist/client/client/grapesjs/symbolDialogs.d.ts +1 -1
- package/dist/client/client/grapesjs/view-buttons.d.ts +1 -0
- package/dist/client/client/index.d.ts +10 -0
- package/dist/client/client/publication-transformers.d.ts +4 -3
- package/dist/client/client/publish-custom-code-block.d.ts +4 -0
- package/dist/client/client/publish-fonts.d.ts +4 -0
- package/dist/client/client/utils.d.ts +4 -0
- package/dist/client/constants.d.ts +1 -0
- package/dist/client/css/admin.css +273 -32
- package/dist/client/index.html +2 -1
- package/dist/client/js/main.js +164 -123
- package/dist/client/js/main.js.LICENSE.txt +15 -1
- package/dist/client/types.d.ts +12 -7
- package/dist/plugins/client/client/events.d.ts +7 -1
- package/dist/plugins/client/client/events.js +7 -1
- package/dist/plugins/client/client/events.js.map +1 -1
- package/dist/plugins/client/plugins/client/template.js +108 -58
- package/dist/plugins/client/plugins/client/template.js.map +1 -1
- package/dist/plugins/client/types.d.ts +12 -7
- package/dist/plugins/client/types.js +6 -0
- package/dist/plugins/client/types.js.map +1 -1
- package/dist/plugins/server/constants.d.ts +1 -0
- package/dist/plugins/server/constants.js +2 -1
- package/dist/plugins/server/constants.js.map +1 -1
- package/dist/plugins/server/plugins/server/FtpConnector.d.ts +1 -0
- package/dist/plugins/server/plugins/server/FtpConnector.js +12 -1
- package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -1
- package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +3 -0
- package/dist/plugins/server/plugins/server/GitlabConnector.js +72 -35
- package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
- package/dist/plugins/server/server/config.js +3 -3
- package/dist/plugins/server/server/config.js.map +1 -1
- package/dist/plugins/server/server/connectors/FsHosting.d.ts +1 -0
- package/dist/plugins/server/server/connectors/FsHosting.js +13 -1
- package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -1
- package/dist/plugins/server/server/connectors/FsStorage.d.ts +2 -1
- package/dist/plugins/server/server/connectors/FsStorage.js +29 -25
- package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -1
- package/dist/plugins/server/server/connectors/connectors.d.ts +1 -0
- package/dist/plugins/server/server/jobs.js +4 -2
- package/dist/plugins/server/server/jobs.js.map +1 -1
- package/dist/plugins/server/types.d.ts +12 -7
- package/dist/plugins/server/types.js +7 -1
- package/dist/plugins/server/types.js.map +1 -1
- package/dist/server/constants.js +2 -1
- package/dist/server/server/api/publicationApi.js +3 -5
- package/dist/server/server/api/websiteApi.js +26 -7
- package/dist/server/server/cli.js +9 -6
- package/dist/server/server/config.js +3 -3
- package/dist/server/server/connectors/FsHosting.js +13 -1
- package/dist/server/server/connectors/FsStorage.js +28 -25
- package/dist/server/server/jobs.js +4 -2
- package/dist/server/types.js +7 -1
- package/package.json +35 -31
- package/public/assets/favicon.ico +0 -0
- package/public/assets/favicon.png +0 -0
- package/public/assets/logo-silex-small.png +0 -0
- package/src/css/_variables.scss +5 -3
- package/src/css/dialog.scss +22 -1
- package/src/css/fonts.scss +31 -0
- package/src/css/footer.scss +1 -1
- package/src/css/grapesjs-plugins.scss +34 -0
- package/src/css/grapesjs.scss +26 -11
- package/src/css/index.scss +1 -0
- package/src/css/project-bar.scss +11 -7
- package/src/css/silex.scss +58 -5
- package/src/html/index.pug +2 -2
- package/src/ts/client/api.ts +14 -9
- package/src/ts/client/assetUrl.test.ts +145 -42
- package/src/ts/client/assetUrl.ts +29 -10
- package/src/ts/client/config.ts +85 -4
- package/src/ts/client/events.ts +15 -9
- package/src/ts/client/grapesjs/PublicationManager.ts +71 -38
- package/src/ts/client/grapesjs/PublicationUi.ts +13 -11
- package/src/ts/client/grapesjs/css-props.ts +544 -0
- package/src/ts/client/grapesjs/eleventy.ts +2 -5
- package/src/ts/client/grapesjs/footer.ts +24 -9
- package/src/ts/client/grapesjs/img.ts +147 -0
- package/src/ts/client/grapesjs/index.ts +63 -25
- package/src/ts/client/grapesjs/internal-links.test.ts +2 -1
- package/src/ts/client/grapesjs/internal-links.ts +0 -1
- package/src/ts/client/grapesjs/new-page-dialog.ts +2 -3
- package/src/ts/client/grapesjs/page-panel.ts +28 -3
- package/src/ts/client/grapesjs/project-bar.ts +83 -64
- package/src/ts/client/grapesjs/resize-panel.ts +20 -0
- package/src/ts/client/grapesjs/rich-text.ts +21 -13
- package/src/ts/client/grapesjs/semantic.ts +3 -3
- package/src/ts/client/grapesjs/settings-sections.ts +117 -0
- package/src/ts/client/grapesjs/settings.ts +120 -77
- package/src/ts/client/grapesjs/symbolDialogs.ts +2 -3
- package/src/ts/client/grapesjs/view-buttons.ts +42 -0
- package/src/ts/client/index.ts +13 -6
- package/src/ts/client/publication-transformers.test.ts +13 -5
- package/src/ts/client/publication-transformers.ts +60 -47
- package/{dist/plugins/client/client/utils.js → src/ts/client/publish-custom-code-block.ts} +14 -8
- package/{dist/plugins/client/page.js → src/ts/client/publish-fonts.ts} +19 -14
- package/src/ts/client/utils.ts +18 -0
- package/src/ts/constants.ts +1 -0
- package/src/ts/plugins/client/template.ts +112 -60
- package/src/ts/plugins/server/FtpConnector.ts +14 -2
- package/src/ts/plugins/server/GitlabConnector.ts +71 -32
- package/src/ts/server/api/publicationApi.ts +5 -5
- package/src/ts/server/api/websiteApi.ts +51 -17
- package/src/ts/server/cli.ts +7 -5
- package/src/ts/server/config.ts +4 -4
- package/src/ts/server/connectors/FsHosting.ts +11 -5
- package/src/ts/server/connectors/FsStorage.ts +33 -4
- package/src/ts/server/connectors/connectors.ts +1 -1
- package/src/ts/server/jobs.ts +4 -2
- package/src/ts/types.ts +10 -7
- package/dist/plugins/client/client/api.d.ts +0 -85
- package/dist/plugins/client/client/api.js +0 -114
- package/dist/plugins/client/client/api.js.map +0 -1
- package/dist/plugins/client/client/assetUrl.d.ts +0 -51
- package/dist/plugins/client/client/assetUrl.js +0 -224
- package/dist/plugins/client/client/assetUrl.js.map +0 -1
- package/dist/plugins/client/client/config.d.ts +0 -58
- package/dist/plugins/client/client/config.js +0 -90
- package/dist/plugins/client/client/config.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/LoginDialog.d.ts +0 -15
- package/dist/plugins/client/client/grapesjs/LoginDialog.js +0 -195
- package/dist/plugins/client/client/grapesjs/LoginDialog.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/PublicationManager.d.ts +0 -72
- package/dist/plugins/client/client/grapesjs/PublicationManager.js +0 -356
- package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/PublicationUi.d.ts +0 -62
- package/dist/plugins/client/client/grapesjs/PublicationUi.js +0 -336
- package/dist/plugins/client/client/grapesjs/PublicationUi.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/blocks.d.ts +0 -1
- package/dist/plugins/client/client/grapesjs/blocks.js +0 -37
- package/dist/plugins/client/client/grapesjs/blocks.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/breadcrumbs.d.ts +0 -1
- package/dist/plugins/client/client/grapesjs/breadcrumbs.js +0 -75
- package/dist/plugins/client/client/grapesjs/breadcrumbs.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/footer.d.ts +0 -2
- package/dist/plugins/client/client/grapesjs/footer.js +0 -28
- package/dist/plugins/client/client/grapesjs/footer.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/index.d.ts +0 -5
- package/dist/plugins/client/client/grapesjs/index.js +0 -313
- package/dist/plugins/client/client/grapesjs/index.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/internal-links.d.ts +0 -1
- package/dist/plugins/client/client/grapesjs/internal-links.js +0 -219
- package/dist/plugins/client/client/grapesjs/internal-links.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/new-page-dialog.d.ts +0 -2
- package/dist/plugins/client/client/grapesjs/new-page-dialog.js +0 -83
- package/dist/plugins/client/client/grapesjs/new-page-dialog.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/openImport.d.ts +0 -9
- package/dist/plugins/client/client/grapesjs/openImport.js +0 -74
- package/dist/plugins/client/client/grapesjs/openImport.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/page-panel.d.ts +0 -3
- package/dist/plugins/client/client/grapesjs/page-panel.js +0 -113
- package/dist/plugins/client/client/grapesjs/page-panel.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/project-bar.d.ts +0 -1
- package/dist/plugins/client/client/grapesjs/project-bar.js +0 -104
- package/dist/plugins/client/client/grapesjs/project-bar.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/rich-text.d.ts +0 -1
- package/dist/plugins/client/client/grapesjs/rich-text.js +0 -31
- package/dist/plugins/client/client/grapesjs/rich-text.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/semantic.d.ts +0 -1
- package/dist/plugins/client/client/grapesjs/semantic.js +0 -110
- package/dist/plugins/client/client/grapesjs/semantic.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/settings.d.ts +0 -2
- package/dist/plugins/client/client/grapesjs/settings.js +0 -198
- package/dist/plugins/client/client/grapesjs/settings.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/storage.d.ts +0 -1
- package/dist/plugins/client/client/grapesjs/storage.js +0 -126
- package/dist/plugins/client/client/grapesjs/storage.js.map +0 -1
- package/dist/plugins/client/client/grapesjs/symbolDialogs.d.ts +0 -3
- package/dist/plugins/client/client/grapesjs/symbolDialogs.js +0 -36
- package/dist/plugins/client/client/grapesjs/symbolDialogs.js.map +0 -1
- package/dist/plugins/client/client/publication-transformers.d.ts +0 -41
- package/dist/plugins/client/client/publication-transformers.js +0 -238
- package/dist/plugins/client/client/publication-transformers.js.map +0 -1
- package/dist/plugins/client/client/utils.d.ts +0 -2
- package/dist/plugins/client/client/utils.js.map +0 -1
- package/dist/plugins/client/constants.d.ts +0 -29
- package/dist/plugins/client/constants.js +0 -46
- package/dist/plugins/client/constants.js.map +0 -1
- package/dist/plugins/client/page.d.ts +0 -2
- package/dist/plugins/client/page.js.map +0 -1
- package/dist/plugins/client/plugins/client/11ty.d.ts +0 -17
- package/dist/plugins/client/plugins/client/11ty.js +0 -86
- package/dist/plugins/client/plugins/client/11ty.js.map +0 -1
- package/dist/plugins/client/plugins/client/publicationRenderer.d.ts +0 -2
- package/dist/plugins/client/plugins/client/publicationRenderer.js +0 -170
- package/dist/plugins/client/plugins/client/publicationRenderer.js.map +0 -1
- package/src/ts/plugins/client/11ty.ts +0 -104
- package/src/ts/plugins/client/publicationRenderer.ts +0 -174
|
@@ -1,198 +0,0 @@
|
|
|
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
|
-
sender.set('active', 0); // Deactivate the button to make it ready to be clicked again
|
|
43
|
-
editor.stopCommand(cmdOpenSettings); // apparently this is needed to be able to run the command several times
|
|
44
|
-
});
|
|
45
|
-
displaySettings(editor, opts, page);
|
|
46
|
-
modal.setContent(el);
|
|
47
|
-
const form = el.querySelector('form');
|
|
48
|
-
form.onsubmit = event => {
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
saveSettings(editor, opts, page);
|
|
51
|
-
editor.stopCommand(cmdOpenSettings);
|
|
52
|
-
};
|
|
53
|
-
form.querySelector('input')?.focus();
|
|
54
|
-
return modal;
|
|
55
|
-
},
|
|
56
|
-
stop: () => {
|
|
57
|
-
modal.close();
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
// add settings to the website
|
|
61
|
-
editor.on('storage:start:store', (data) => {
|
|
62
|
-
data.settings = editor.getModel().get('settings');
|
|
63
|
-
data.name = editor.getModel().get('name');
|
|
64
|
-
});
|
|
65
|
-
editor.on('storage:end:load', (data) => {
|
|
66
|
-
const model = editor.getModel();
|
|
67
|
-
model.set('settings', data.settings || {});
|
|
68
|
-
model.set('name', data.name);
|
|
69
|
-
updateDom(editor);
|
|
70
|
-
});
|
|
71
|
-
editor.on('page', (e) => {
|
|
72
|
-
editor.Canvas.getFrameEl().addEventListener('load', () => {
|
|
73
|
-
updateDom(editor);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
// Is the model a site or a page?
|
|
78
|
-
function isSite(model) { return !!model.getHtml; }
|
|
79
|
-
function displaySettings(editor, config, model = editor.getModel()) {
|
|
80
|
-
const settings = model.get('settings') || {};
|
|
81
|
-
model.set('settings', settings);
|
|
82
|
-
render(html `
|
|
83
|
-
<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>
|
|
84
|
-
<form class="silex-form">
|
|
85
|
-
<h2>General settings</h2>
|
|
86
|
-
<div class="silex-form__group col2">
|
|
87
|
-
<label class="silex-form__element">
|
|
88
|
-
<h3>${isSite(model) ? 'Site name' : 'Page name'}</h3>
|
|
89
|
-
<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>
|
|
90
|
-
<input type="text" name="name" .value=${live(model.get('name') || '')}/>
|
|
91
|
-
</label>
|
|
92
|
-
<label class="silex-form__element">
|
|
93
|
-
<h3>Website language</h3>
|
|
94
|
-
<p>This is the default language code for this website. Example: en, fr, es...</p>
|
|
95
|
-
<input type="text" name="lang" .value=${live(settings.lang || '')}/>
|
|
96
|
-
</label>
|
|
97
|
-
<label class="silex-form__element">
|
|
98
|
-
<h3>Title</h3>
|
|
99
|
-
<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>
|
|
100
|
-
<input type="text" name="title" .value=${live(settings.title || '')}/>
|
|
101
|
-
</label>
|
|
102
|
-
<label class="silex-form__element">
|
|
103
|
-
<h3>Description</h3>
|
|
104
|
-
<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>
|
|
105
|
-
<input type="text" name="description" .value=${live(settings.description || '')}/>
|
|
106
|
-
</label>
|
|
107
|
-
<label class="silex-form__element">
|
|
108
|
-
<h3>Favicon</h3>
|
|
109
|
-
<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>
|
|
110
|
-
<input type="text" name="favicon" .value=${live(settings.favicon || '')}/>
|
|
111
|
-
</label>
|
|
112
|
-
</div>
|
|
113
|
-
<h2>Social networks sharing</h2>
|
|
114
|
-
<div>
|
|
115
|
-
<p>Once your website is live, you can use these tools to test sharing: <a target="_blank" href="https://developers.facebook.com/tools/debug/">Facebook</a>,
|
|
116
|
-
<a target="_blank" href="https://cards-dev.twitter.com/validator">Twitter</a>,
|
|
117
|
-
<a target="_blank" href="https://www.linkedin.com/post-inspector/inspect/">Linkedin</a></p>
|
|
118
|
-
</div>
|
|
119
|
-
<div class="silex-form__group col2">
|
|
120
|
-
<label class="silex-form__element">
|
|
121
|
-
<h3>Title</h3>
|
|
122
|
-
<p>The title of your website displayed when a user shares your website on a social network.
|
|
123
|
-
Do not include any branding in this title, just eye-catching phrase, e.g. "Learn everything about fishing".
|
|
124
|
-
Title should be between 60 and 90 characters long.</p>
|
|
125
|
-
<input type="text" name="og:title" .value=${live(settings['og:title'] || '')}/>
|
|
126
|
-
</label>
|
|
127
|
-
<label class="silex-form__element">
|
|
128
|
-
<h3>Description</h3>
|
|
129
|
-
<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>
|
|
130
|
-
<input type="text" name="og:description" .value=${live(settings['og:description'] || '')}/>
|
|
131
|
-
</label>
|
|
132
|
-
<label class="silex-form__element">
|
|
133
|
-
<h3>Image</h3>
|
|
134
|
-
<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>
|
|
135
|
-
<p>Please enter the full URL here, e.g. "http://mysite.com/path/to/image.jpg"</p>
|
|
136
|
-
<input type="text" name="og:image" .value=${live(settings['og:image'] || '')}/>
|
|
137
|
-
</label>
|
|
138
|
-
</div>
|
|
139
|
-
<h2>Code</h2>
|
|
140
|
-
<div class="silex-form__group">
|
|
141
|
-
<label class="silex-form__element">
|
|
142
|
-
<h3>HTML head</h3>
|
|
143
|
-
<p>HTML code which will be inserted in the HEAD tag.</p>
|
|
144
|
-
<textarea name="head" .value=${live(settings.head || '')}></textarea>
|
|
145
|
-
</label>
|
|
146
|
-
</div>
|
|
147
|
-
<footer>
|
|
148
|
-
<p class="silex-version">Silex ${version}</p>
|
|
149
|
-
<input class="silex-button" type="button" @click=${e => editor.stopCommand(cmdOpenSettings)} value="Cancel">
|
|
150
|
-
<input class="silex-button" type="submit" value="Ok">
|
|
151
|
-
</footer>
|
|
152
|
-
</form>
|
|
153
|
-
`, el);
|
|
154
|
-
}
|
|
155
|
-
function saveSettings(editor, config, model = editor.getModel()) {
|
|
156
|
-
const form = el.querySelector('form');
|
|
157
|
-
const formData = new FormData(form);
|
|
158
|
-
const data = Array.from(formData)
|
|
159
|
-
.reduce((aggregate, [key, value]) => {
|
|
160
|
-
aggregate[key] = value;
|
|
161
|
-
return aggregate;
|
|
162
|
-
}, {});
|
|
163
|
-
// take the name out to the main model (by design in grapesjs pages)
|
|
164
|
-
const { name, ...settings } = data;
|
|
165
|
-
model.set({
|
|
166
|
-
settings,
|
|
167
|
-
name,
|
|
168
|
-
});
|
|
169
|
-
// save if auto save is on
|
|
170
|
-
editor.getModel().set('changesCount', editor.getDirtyCount() + 1);
|
|
171
|
-
// update the DOM
|
|
172
|
-
updateDom(editor);
|
|
173
|
-
}
|
|
174
|
-
function getHeadContainer(doc, className) {
|
|
175
|
-
const container = doc.head.querySelector(`.${className}`);
|
|
176
|
-
if (container) {
|
|
177
|
-
return container;
|
|
178
|
-
}
|
|
179
|
-
const newContainer = doc.createElement('div');
|
|
180
|
-
newContainer.classList.add(className);
|
|
181
|
-
doc.head.appendChild(newContainer);
|
|
182
|
-
return newContainer;
|
|
183
|
-
}
|
|
184
|
-
function updateDom(editor) {
|
|
185
|
-
const doc = editor.Canvas.getDocument();
|
|
186
|
-
if (doc) {
|
|
187
|
-
// Site head
|
|
188
|
-
getHeadContainer(doc, 'site-head')
|
|
189
|
-
.innerHTML = editor.getModel().get('settings').head || '';
|
|
190
|
-
// Pages head
|
|
191
|
-
getHeadContainer(doc, 'page-head')
|
|
192
|
-
.innerHTML = editor.Pages.getSelected().get('settings')?.head || '';
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
// No document??
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,6B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,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const storagePlugin: (editor: any) => void;
|
|
@@ -1,126 +0,0 @@
|
|
|
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
|
-
import { addTempDataToPages, addTempDataToAssetUrl, addTempDataToStyles, removeTempDataFromAssetUrl, removeTempDataFromPages, removeTempDataFromStyles } from '../assetUrl';
|
|
21
|
-
export const storagePlugin = (editor) => {
|
|
22
|
-
editor.Storage.add('connector', {
|
|
23
|
-
async load(options) {
|
|
24
|
-
try {
|
|
25
|
-
const user = await getCurrentUser(editor) ?? await updateUser(editor, ConnectorType.STORAGE, options.connectorId);
|
|
26
|
-
if (!user)
|
|
27
|
-
throw new ApiError('Not logged in', 401);
|
|
28
|
-
const data = await websiteLoad({ websiteId: options.id, connectorId: user.storage.connectorId });
|
|
29
|
-
if (data.assets)
|
|
30
|
-
data.assets = addTempDataToAssetUrl(data.assets, options.id, user.storage.connectorId);
|
|
31
|
-
if (data.pages)
|
|
32
|
-
data.pages = addTempDataToPages(data.pages, options.id, user.storage.connectorId);
|
|
33
|
-
if (data.styles)
|
|
34
|
-
data.styles = addTempDataToStyles(data.styles, options.id, user.storage.connectorId);
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
if (err.httpStatusCode === 401) {
|
|
39
|
-
editor.once(eventLoggedIn, async () => {
|
|
40
|
-
try {
|
|
41
|
-
editor.StorageManager.setAutosave(false);
|
|
42
|
-
const data = await editor.Storage.load(options);
|
|
43
|
-
editor.StorageManager.setAutosave(true);
|
|
44
|
-
editor.loadProjectData(data);
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
console.error('connectorPlugin load error', err);
|
|
48
|
-
throw err;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
editor.Commands.run(cmdLogin);
|
|
52
|
-
}
|
|
53
|
-
console.error('connectorPlugin load error', err);
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
async store(data, options) {
|
|
58
|
-
try {
|
|
59
|
-
if (await getCurrentUser(editor)) {
|
|
60
|
-
const user = await getCurrentUser(editor);
|
|
61
|
-
data.assets = removeTempDataFromAssetUrl(data.assets);
|
|
62
|
-
data.pages = removeTempDataFromPages(data.pages);
|
|
63
|
-
data.styles = removeTempDataFromStyles(data.styles);
|
|
64
|
-
await websiteSave({ websiteId: options.id, connectorId: user.storage.connectorId, data });
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
editor.once(eventLoggedIn, () => {
|
|
68
|
-
return editor.Storage.store();
|
|
69
|
-
});
|
|
70
|
-
editor.Commands.run(cmdLogin);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
console.error('connectorPlugin store error', err);
|
|
75
|
-
throw err;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
// Handle errors
|
|
80
|
-
editor.on('storage:error:load', (err) => {
|
|
81
|
-
handleError(err);
|
|
82
|
-
});
|
|
83
|
-
editor.on('storage:error:store', (err) => {
|
|
84
|
-
handleError(err);
|
|
85
|
-
});
|
|
86
|
-
editor.on('asset:upload:end', (err) => {
|
|
87
|
-
editor.store();
|
|
88
|
-
});
|
|
89
|
-
editor.on('asset:upload:error', (err) => {
|
|
90
|
-
handleError(err);
|
|
91
|
-
});
|
|
92
|
-
function handleError(_err) {
|
|
93
|
-
const err = typeof _err === 'string' ? JSON.parse(_err) : _err;
|
|
94
|
-
console.error('Error with loading or saving website or uploading asset', err, err instanceof ApiError);
|
|
95
|
-
if (err instanceof ApiError) {
|
|
96
|
-
console.error('ApiError', err.httpStatusCode, err.message);
|
|
97
|
-
switch (err.httpStatusCode) {
|
|
98
|
-
case 404:
|
|
99
|
-
return editor.Modal.open({
|
|
100
|
-
title: 'Website not found',
|
|
101
|
-
content: `This website could not be found.<br><hr>${err.message}`,
|
|
102
|
-
});
|
|
103
|
-
case 403:
|
|
104
|
-
return editor.Modal.open({
|
|
105
|
-
title: 'Access denied',
|
|
106
|
-
content: `You are not allowed to access this website.<br><hr>${err.message}`,
|
|
107
|
-
});
|
|
108
|
-
case 401:
|
|
109
|
-
editor.trigger(eventLoggedOut);
|
|
110
|
-
return;
|
|
111
|
-
default:
|
|
112
|
-
return editor.Modal.open({
|
|
113
|
-
title: 'Error',
|
|
114
|
-
content: `An error occured.<br>${err.message}`,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
return editor.Modal.open({
|
|
120
|
-
title: 'Error',
|
|
121
|
-
content: `An error occured.<br>${err.message}`,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../../../src/ts/client/grapesjs/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAsD,aAAa,EAAE,QAAQ,EAAiC,MAAM,aAAa,CAAA;AACxI,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;AACnG,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAE3K,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,EAAE;IACtC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QAC9B,KAAK,CAAC,IAAI,CAAC,OAAoD;YAC7D,IAAI;gBACF,MAAM,IAAI,GAAkB,MAAM,cAAc,CAAC,MAAM,CAAC,IAAI,MAAM,UA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AAE,eAAe;wBACtB,OAAO,EAAE,sDAAsD,GAAG,CAAC,OAAO,EAAE;qBAC7E,CAAC,CAAA;gBACJ,KAAK,GAAG;oBACN,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;oBAC9B,OAAM;gBACR;oBACE,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;wBACvB,KAAK,EAAE,OAAO;wBACd,OAAO,EAAE,wBAAwB,GAAG,CAAC,OAAO,EAAE;qBAC/C,CAAC,CAAA;aACH;SACF;aAAM;YACL,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;gBACvB,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,wBAAwB,GAAG,CAAC,OAAO,EAAE;aAC/C,CAAC,CAAA;SACH;IACH,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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 = 'fa-gem';
|
|
32
|
-
editor.runCommand(cmdAddSymbol, { label, icon });
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=symbolDialogs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,QAAQ,CAAA;YACrB,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAClD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Component, CssRule, Editor, ObjectStrings } from 'grapesjs';
|
|
2
|
-
import { ClientSideFile, ClientSideFileType, PublicationData } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Interface for publication transformers
|
|
5
|
-
* They are added to the config object with config.addPublicationTransformer()
|
|
6
|
-
*/
|
|
7
|
-
export interface PublicationTransformer {
|
|
8
|
-
renderComponent?(component: Component, toHtml: () => string): string | undefined;
|
|
9
|
-
renderCssRule?(rule: CssRule, initialRule: () => ObjectStrings): ObjectStrings | undefined;
|
|
10
|
-
transformFile?(file: ClientSideFile): ClientSideFile;
|
|
11
|
-
transformPermalink?(link: string, type: ClientSideFileType): string;
|
|
12
|
-
transformPath?(path: string, type: ClientSideFileType): string;
|
|
13
|
-
}
|
|
14
|
-
export declare function validatePublicationTransformer(transformer: PublicationTransformer): void;
|
|
15
|
-
/**
|
|
16
|
-
* Alter the components rendering
|
|
17
|
-
* Exported for unit tests
|
|
18
|
-
*/
|
|
19
|
-
export declare function renderComponents(editor: Editor): void;
|
|
20
|
-
/**
|
|
21
|
-
* Alter the styles rendering
|
|
22
|
-
* Exported for unit tests
|
|
23
|
-
*/
|
|
24
|
-
export declare function renderCssRules(editor: Editor): void;
|
|
25
|
-
/**
|
|
26
|
-
* Transform background image url according to the transformed path of assets
|
|
27
|
-
*/
|
|
28
|
-
export declare function transformBgImage(editor: Editor, style: ObjectStrings): ObjectStrings;
|
|
29
|
-
/**
|
|
30
|
-
* Transform files
|
|
31
|
-
* Exported for unit tests
|
|
32
|
-
*/
|
|
33
|
-
export declare function transformFiles(editor: Editor, data: PublicationData): void;
|
|
34
|
-
/**
|
|
35
|
-
* Transform files paths
|
|
36
|
-
* Exported for unit tests
|
|
37
|
-
*/
|
|
38
|
-
export declare function transformPermalink(editor: Editor, path: string, type: ClientSideFileType): string;
|
|
39
|
-
export declare function transformPath(editor: Editor, path: string, type: ClientSideFileType): string;
|
|
40
|
-
export declare function resetRenderComponents(editor: Editor): void;
|
|
41
|
-
export declare function resetRenderCssRules(editor: Editor): void;
|