@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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@use "variables" as *;
|
|
2
|
+
|
|
3
|
+
// grapesjs-style-bg
|
|
4
|
+
@use "grapick/dist/grapick.min.css";
|
|
5
|
+
|
|
6
|
+
// grapesjs-style-border
|
|
7
|
+
@mixin square-borders-before {
|
|
8
|
+
display: block;
|
|
9
|
+
content: '' !important;
|
|
10
|
+
border: 2px solid $tertiaryColor;
|
|
11
|
+
width: 10px;
|
|
12
|
+
height: 10px;
|
|
13
|
+
margin: auto;
|
|
14
|
+
}
|
|
15
|
+
.fa-arrows::before {
|
|
16
|
+
@include square-borders-before;
|
|
17
|
+
border-color: $secondaryColor;
|
|
18
|
+
}
|
|
19
|
+
.fa-long-arrow-up::before {
|
|
20
|
+
@include square-borders-before;
|
|
21
|
+
border-top-color: $secondaryColor;
|
|
22
|
+
}
|
|
23
|
+
.fa-long-arrow-down::before {
|
|
24
|
+
@include square-borders-before;
|
|
25
|
+
border-bottom-color: $secondaryColor;
|
|
26
|
+
}
|
|
27
|
+
.fa-long-arrow-left::before {
|
|
28
|
+
@include square-borders-before;
|
|
29
|
+
border-left-color: $secondaryColor;
|
|
30
|
+
}
|
|
31
|
+
.fa-long-arrow-right::before {
|
|
32
|
+
@include square-borders-before;
|
|
33
|
+
border-right-color: $secondaryColor;
|
|
34
|
+
}
|
package/src/css/grapesjs.scss
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@use "variables" as *;
|
|
2
|
+
@use "grapesjs-plugins";
|
|
2
3
|
|
|
3
4
|
#gjs {
|
|
4
5
|
flex: 1 1 auto;
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
left: auto;
|
|
36
37
|
}
|
|
37
38
|
.#{$cv-prefix}canvas {
|
|
38
|
-
width: calc(100% -
|
|
39
|
+
width: calc(100% - var(--viewsPanelWidth) - $projectBarWidth);
|
|
39
40
|
}
|
|
40
41
|
.#{$pn-prefix}devices-c {
|
|
41
42
|
display: flex;
|
|
@@ -44,7 +45,6 @@
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
.#{$pn-prefix}views-container {
|
|
47
|
-
width: $viewsPanelWidth;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
.gjs-editor {
|
|
@@ -52,6 +52,17 @@
|
|
|
52
52
|
font-size: 0.75rem;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// Dialogs
|
|
56
|
+
.gjs-mdl-header {
|
|
57
|
+
background-color: $primaryColor;
|
|
58
|
+
color: $secondaryColor;
|
|
59
|
+
padding: 20px;
|
|
60
|
+
border-bottom: 1px solid $lighterPrimaryColor;
|
|
61
|
+
.gjs-mdl-btn-close {
|
|
62
|
+
top: 15px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
// Inside the canvas
|
|
56
67
|
.gjs-toolbar {
|
|
57
68
|
background-color: $tertiaryColor;
|
|
@@ -66,6 +77,19 @@
|
|
|
66
77
|
outline: 1px solid $tertiaryColor;
|
|
67
78
|
}
|
|
68
79
|
|
|
80
|
+
// Property panels
|
|
81
|
+
.gjs-pn-buttons {
|
|
82
|
+
justify-content: unset;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.gjs-pn-views-container, .gjs-pn-views {
|
|
86
|
+
width: var(--viewsPanelWidth);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.gjs-pn-options {
|
|
90
|
+
right: var(--viewsPanelWidth);
|
|
91
|
+
}
|
|
92
|
+
|
|
69
93
|
/*
|
|
70
94
|
*/
|
|
71
95
|
// Font awesome 5 fix
|
|
@@ -141,12 +165,3 @@
|
|
|
141
165
|
.fa-diamond:before {
|
|
142
166
|
content: "\f3a5";
|
|
143
167
|
}
|
|
144
|
-
/*
|
|
145
|
-
.fa-plus:before {
|
|
146
|
-
content: "+";
|
|
147
|
-
font-size: 35px;
|
|
148
|
-
}
|
|
149
|
-
// .fa-plus {
|
|
150
|
-
// background-image: svg(<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32V224H48c-17.7 0-32 14.3-32 32s14.3 32 32 32H192V432c0 17.7 14.3 32 32 32s32-14.3 32-32V288H400c17.7 0 32-14.3 32-32s-14.3-32-32-32H256V80z"/></svg>);
|
|
151
|
-
// }
|
|
152
|
-
*/
|
package/src/css/index.scss
CHANGED
package/src/css/project-bar.scss
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
@use "variables" as *;
|
|
2
2
|
|
|
3
3
|
// squeeze the stage iframe when panel is open
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
left:
|
|
10
|
-
width:
|
|
4
|
+
//.silex-squeeze-left .gjs-frame-wrapper {
|
|
5
|
+
// margin-left: 18%;
|
|
6
|
+
// width: auto;
|
|
7
|
+
//}
|
|
8
|
+
.silex-squeeze-left .gjs-cv-canvas {
|
|
9
|
+
left: calc(13% + 35px);
|
|
10
|
+
width: auto;
|
|
11
|
+
right: var(--viewsPanelWidth);
|
|
11
12
|
}
|
|
13
|
+
|
|
14
|
+
|
|
12
15
|
// button bar
|
|
13
16
|
.#{$pn-prefix}project-bar-panel {
|
|
14
17
|
width: $projectBarWidth;
|
|
@@ -35,6 +38,7 @@ iframe.enable-squeeze.silex-squeeze-left {
|
|
|
35
38
|
background-repeat: no-repeat;
|
|
36
39
|
background-position: center center;
|
|
37
40
|
background-color: transparent;
|
|
41
|
+
background-size: contain;
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
|
package/src/css/silex.scss
CHANGED
|
@@ -29,11 +29,34 @@
|
|
|
29
29
|
width: 100%;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// Resize options panel button
|
|
33
|
+
.silex-workspace {
|
|
34
|
+
.gjs-pn-viewsOptions {
|
|
35
|
+
z-index: $z-views-options-buttons;
|
|
36
|
+
right: 0;
|
|
37
|
+
left: auto;
|
|
38
|
+
|
|
39
|
+
.viewsOptions__size-btn::before {
|
|
40
|
+
content: '←';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.silex-hidden {
|
|
46
|
+
/* do not really hide, because it breaks the code editor init in the site settings + for animation */
|
|
47
|
+
visibility: hidden;
|
|
48
|
+
position: absolute;
|
|
49
|
+
opacity: 0;
|
|
50
|
+
height: 10px;
|
|
51
|
+
width: 10px;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
}
|
|
54
|
+
|
|
32
55
|
// full screen settings
|
|
33
56
|
.settings-dialog > div {
|
|
34
57
|
max-width: none;
|
|
35
58
|
width: 100%;
|
|
36
|
-
|
|
59
|
+
height: 100vh;
|
|
37
60
|
overflow: auto;
|
|
38
61
|
form.silex-form {
|
|
39
62
|
padding-bottom: 100px; // leave space for fixed footer
|
|
@@ -63,6 +86,10 @@
|
|
|
63
86
|
font-size: x-small;
|
|
64
87
|
}
|
|
65
88
|
}
|
|
89
|
+
.CodeMirror {
|
|
90
|
+
min-height: 400px;
|
|
91
|
+
height: auto;
|
|
92
|
+
}
|
|
66
93
|
}
|
|
67
94
|
|
|
68
95
|
button.silex-button,
|
|
@@ -83,6 +110,7 @@ input.silex-button[type="submit"] {
|
|
|
83
110
|
padding: 5px;
|
|
84
111
|
}
|
|
85
112
|
|
|
113
|
+
.silex-button.disabled,
|
|
86
114
|
.silex-button[disabled] {
|
|
87
115
|
opacity: .8;
|
|
88
116
|
cursor: unset;
|
|
@@ -98,6 +126,7 @@ input.silex-button[type="submit"] {
|
|
|
98
126
|
|
|
99
127
|
.silex-button--size {
|
|
100
128
|
max-height: 30px;
|
|
129
|
+
margin: 0 10px;
|
|
101
130
|
}
|
|
102
131
|
|
|
103
132
|
.silex-button--small {
|
|
@@ -113,11 +142,15 @@ input.silex-button[type="submit"] {
|
|
|
113
142
|
display: block;
|
|
114
143
|
}
|
|
115
144
|
|
|
145
|
+
.silex-sidebar-dialog,
|
|
116
146
|
.silex-bar {
|
|
117
147
|
display: flex;
|
|
118
148
|
&>* {
|
|
119
149
|
margin: 5px;
|
|
120
150
|
}
|
|
151
|
+
main {
|
|
152
|
+
width: 100%;
|
|
153
|
+
}
|
|
121
154
|
}
|
|
122
155
|
|
|
123
156
|
ol.silex-list,
|
|
@@ -125,15 +158,15 @@ ul.silex-list {
|
|
|
125
158
|
list-style: none;
|
|
126
159
|
margin: 0;
|
|
127
160
|
padding: 0;
|
|
128
|
-
background-color: #575757;
|
|
161
|
+
//background-color: #575757;
|
|
129
162
|
&>li {
|
|
130
163
|
padding: 5px;
|
|
131
|
-
border-bottom: 1px solid
|
|
132
|
-
background-color: #444;
|
|
164
|
+
border-bottom: 1px solid $lighterPrimaryColor;
|
|
165
|
+
//background-color: #444;
|
|
133
166
|
margin: 5px;
|
|
134
167
|
}
|
|
135
168
|
fieldset {
|
|
136
|
-
border-color:
|
|
169
|
+
border-color: $lighterPrimaryColor;
|
|
137
170
|
}
|
|
138
171
|
h4 { // badge-like
|
|
139
172
|
display: inline-block;
|
|
@@ -158,6 +191,26 @@ ul.silex-list {
|
|
|
158
191
|
}
|
|
159
192
|
}
|
|
160
193
|
|
|
194
|
+
ol.silex-list--menu,
|
|
195
|
+
ul.silex-list--menu {
|
|
196
|
+
&>li {
|
|
197
|
+
padding: 15px;
|
|
198
|
+
margin: 0;
|
|
199
|
+
border: 1px solid transparent;
|
|
200
|
+
border-bottom-color: $lighterPrimaryColor;
|
|
201
|
+
text-align: center;
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
}
|
|
204
|
+
&>li:first-child {
|
|
205
|
+
border-top-color: $lighterPrimaryColor;
|
|
206
|
+
}
|
|
207
|
+
.active,
|
|
208
|
+
&>li:hover {
|
|
209
|
+
color: $tertiaryColor;
|
|
210
|
+
background-color: $darkerPrimaryColor;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
161
214
|
form.silex-form {
|
|
162
215
|
display: flex;
|
|
163
216
|
flex-direction: column;
|
package/src/html/index.pug
CHANGED
|
@@ -34,6 +34,6 @@ html(lang="en", translate="no")
|
|
|
34
34
|
script(src='js/main.js')
|
|
35
35
|
|
|
36
36
|
block silex-start
|
|
37
|
-
// Here you can use silex.config to hook into silex options before silex starts
|
|
38
37
|
script.
|
|
39
|
-
|
|
38
|
+
silex.start()
|
|
39
|
+
// From here silex.config is available and Silex is getting started
|
package/src/ts/client/api.ts
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { API_CONNECTOR_LIST, API_CONNECTOR_USER, API_CONNECTOR_LOGOUT, API_CONNECTOR_PATH, API_PATH, API_PUBLICATION_PATH, API_PUBLICATION_PUBLISH, API_PUBLICATION_STATUS, API_WEBSITE_ASSET_READ, API_WEBSITE_ASSETS_WRITE, API_WEBSITE_DELETE, API_WEBSITE_LIST, API_WEBSITE_PATH, API_WEBSITE_READ, API_WEBSITE_WRITE, API_WEBSITE_META_READ, API_WEBSITE_META_WRITE, API_WEBSITE_CREATE } from '../constants'
|
|
19
|
-
import { ApiPublicationPublishBody, ApiPublicationPublishQuery, ApiPublicationPublishResponse, ApiPublicationStatusQuery, ApiPublicationStatusResponse, ConnectorId, JobData, JobId, PublicationJobData, WebsiteId, ApiConnectorListResponse, ApiConnectorListQuery, ConnectorData, ConnectorType, ApiWebsiteReadQuery, ApiWebsiteReadResponse, WebsiteData, ApiWebsiteWriteQuery, ApiWebsiteWriteBody, ApiWebsiteWriteResponse, ApiWebsiteDeleteQuery, ApiWebsiteAssetsReadQuery, ApiWebsiteAssetsReadResponse, ApiWebsiteAssetsWriteQuery, ApiWebsiteAssetsWriteBody, ApiWebsiteAssetsWriteResponse, ClientSideFile, PublicationData, ApiConnectorUserResponse, ConnectorUser, WebsiteMeta, ApiConnectorLogoutQuery, ApiConnectorUserQuery, ApiWebsiteListResponse, ApiWebsiteListQuery, WebsiteMetaFileContent, ApiWebsiteCreateQuery, ApiWebsiteCreateBody, ApiWebsiteCreateResponse, ApiWebsiteMetaWriteQuery, ApiWebsiteMetaWriteBody, ApiWebsiteMetaWriteResponse, ApiWebsiteMetaReadQuery, ApiWebsiteMetaReadResponse, ConnectorOptions, ApiError } from '../types'
|
|
18
|
+
import { API_CONNECTOR_LIST, API_CONNECTOR_USER, API_CONNECTOR_LOGOUT, API_CONNECTOR_PATH, API_PATH, API_PUBLICATION_PATH, API_PUBLICATION_PUBLISH, API_PUBLICATION_STATUS, API_WEBSITE_ASSET_READ, API_WEBSITE_ASSETS_WRITE, API_WEBSITE_DELETE, API_WEBSITE_LIST, API_WEBSITE_PATH, API_WEBSITE_READ, API_WEBSITE_WRITE, API_WEBSITE_META_READ, API_WEBSITE_META_WRITE, API_WEBSITE_CREATE, API_WEBSITE_DUPLICATE } from '../constants'
|
|
19
|
+
import { ApiPublicationPublishBody, ApiPublicationPublishQuery, ApiPublicationPublishResponse, ApiPublicationStatusQuery, ApiPublicationStatusResponse, ConnectorId, JobData, JobId, PublicationJobData, WebsiteId, ApiConnectorListResponse, ApiConnectorListQuery, ConnectorData, ConnectorType, ApiWebsiteReadQuery, ApiWebsiteReadResponse, WebsiteData, ApiWebsiteWriteQuery, ApiWebsiteWriteBody, ApiWebsiteWriteResponse, ApiWebsiteDeleteQuery, ApiWebsiteAssetsReadQuery, ApiWebsiteAssetsReadResponse, ApiWebsiteAssetsWriteQuery, ApiWebsiteAssetsWriteBody, ApiWebsiteAssetsWriteResponse, ClientSideFile, PublicationData, ApiConnectorUserResponse, ConnectorUser, WebsiteMeta, ApiConnectorLogoutQuery, ApiConnectorUserQuery, ApiWebsiteListResponse, ApiWebsiteListQuery, WebsiteMetaFileContent, ApiWebsiteCreateQuery, ApiWebsiteCreateBody, ApiWebsiteCreateResponse, ApiWebsiteMetaWriteQuery, ApiWebsiteMetaWriteBody, ApiWebsiteMetaWriteResponse, ApiWebsiteMetaReadQuery, ApiWebsiteMetaReadResponse, ConnectorOptions, ApiError, ApiWebsiteDuplicateQuery } from '../types'
|
|
20
20
|
|
|
21
21
|
export enum ApiRoute {
|
|
22
22
|
PUBLICATION_PUBLISH = API_PATH + API_PUBLICATION_PATH + API_PUBLICATION_PUBLISH,
|
|
@@ -27,6 +27,7 @@ export enum ApiRoute {
|
|
|
27
27
|
WEBSITE_READ = API_PATH + API_WEBSITE_PATH + API_WEBSITE_READ,
|
|
28
28
|
WEBSITE_WRITE = API_PATH + API_WEBSITE_PATH + API_WEBSITE_WRITE,
|
|
29
29
|
WEBSITE_DELETE = API_PATH + API_WEBSITE_PATH + API_WEBSITE_DELETE,
|
|
30
|
+
WEBSITE_DUPLICATE = API_PATH + API_WEBSITE_PATH + API_WEBSITE_DUPLICATE,
|
|
30
31
|
WEBSITE_CREATE = API_PATH + API_WEBSITE_PATH + API_WEBSITE_CREATE,
|
|
31
32
|
WEBSITE_LIST = API_PATH + API_WEBSITE_PATH + API_WEBSITE_LIST,
|
|
32
33
|
WEBSITE_ASSETS_READ = API_PATH + API_WEBSITE_PATH + API_WEBSITE_ASSET_READ,
|
|
@@ -83,23 +84,27 @@ export async function websiteList({connectorId}: {connectorId?: ConnectorId}): P
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
export async function websiteLoad({websiteId, connectorId}: {websiteId: WebsiteId, connectorId?: ConnectorId}): Promise<WebsiteData> {
|
|
86
|
-
return api<ApiWebsiteReadQuery, null, ApiWebsiteReadResponse>(ApiRoute.WEBSITE_READ, 'GET', { websiteId, connectorId
|
|
87
|
+
return api<ApiWebsiteReadQuery, null, ApiWebsiteReadResponse>(ApiRoute.WEBSITE_READ, 'GET', { websiteId, connectorId }) as Promise<WebsiteData>
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
export async function websiteSave({websiteId, data, connectorId}: {websiteId: WebsiteId, data: WebsiteData, connectorId?: ConnectorId}): Promise<void> {
|
|
90
|
-
const { message } = await api<ApiWebsiteWriteQuery, ApiWebsiteWriteBody, ApiWebsiteWriteResponse>(ApiRoute.WEBSITE_WRITE, 'POST', { websiteId, connectorId
|
|
91
|
+
const { message } = await api<ApiWebsiteWriteQuery, ApiWebsiteWriteBody, ApiWebsiteWriteResponse>(ApiRoute.WEBSITE_WRITE, 'POST', { websiteId, connectorId }, data)
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
export async function websiteDelete({websiteId, connectorId}: {websiteId: WebsiteId, connectorId?: ConnectorId}): Promise<void> {
|
|
94
|
-
await api<ApiWebsiteDeleteQuery, null, null>(ApiRoute.WEBSITE_DELETE, 'DELETE', { websiteId, connectorId
|
|
95
|
+
await api<ApiWebsiteDeleteQuery, null, null>(ApiRoute.WEBSITE_DELETE, 'DELETE', { websiteId, connectorId })
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function websiteDuplicate({websiteId, connectorId}: {websiteId: WebsiteId, connectorId?: ConnectorId}): Promise<void> {
|
|
99
|
+
await api<ApiWebsiteDuplicateQuery, null, null>(ApiRoute.WEBSITE_DUPLICATE, 'POST', { websiteId, connectorId })
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
export async function websiteCreate({websiteId, data, connectorId}: {websiteId: WebsiteId, data: WebsiteMetaFileContent, connectorId?: ConnectorId}): Promise<void> {
|
|
98
|
-
await api<ApiWebsiteCreateQuery, ApiWebsiteCreateBody, ApiWebsiteCreateResponse>(ApiRoute.WEBSITE_CREATE, 'PUT', { connectorId
|
|
103
|
+
await api<ApiWebsiteCreateQuery, ApiWebsiteCreateBody, ApiWebsiteCreateResponse>(ApiRoute.WEBSITE_CREATE, 'PUT', { connectorId }, data)
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
export async function websiteMetaWrite({websiteId, data, connectorId}: {websiteId: WebsiteId, data: WebsiteMetaFileContent, connectorId?: ConnectorId}): Promise<void> {
|
|
102
|
-
await api<ApiWebsiteMetaWriteQuery, ApiWebsiteMetaWriteBody, ApiWebsiteMetaWriteResponse>(ApiRoute.WEBSITE_META_WRITE, 'POST', { websiteId, connectorId
|
|
107
|
+
await api<ApiWebsiteMetaWriteQuery, ApiWebsiteMetaWriteBody, ApiWebsiteMetaWriteResponse>(ApiRoute.WEBSITE_META_WRITE, 'POST', { websiteId, connectorId }, data)
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
export async function websiteMetaRead({websiteId, connectorId}: {websiteId: WebsiteId, connectorId?: ConnectorId}): Promise<WebsiteMeta> {
|
|
@@ -107,7 +112,7 @@ export async function websiteMetaRead({websiteId, connectorId}: {websiteId: Webs
|
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
export async function websiteAssetsLoad({path, websiteId, connectorId}: {path: string, websiteId: WebsiteId, connectorId: ConnectorId}): Promise<string> {
|
|
110
|
-
return api<ApiWebsiteAssetsReadQuery, null, ApiWebsiteAssetsReadResponse>(`${ApiRoute.WEBSITE_ASSETS_READ}/${path}`, 'GET', { websiteId, connectorId
|
|
115
|
+
return api<ApiWebsiteAssetsReadQuery, null, ApiWebsiteAssetsReadResponse>(`${ApiRoute.WEBSITE_ASSETS_READ}/${path}`, 'GET', { websiteId, connectorId })
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
/**
|
|
@@ -115,7 +120,7 @@ export async function websiteAssetsLoad({path, websiteId, connectorId}: {path: s
|
|
|
115
120
|
* @see assetManager in src/ts/client/grapesjs/index.ts
|
|
116
121
|
*/
|
|
117
122
|
export async function websiteAssetsSave({websiteId, connectorId, files}: {websiteId: WebsiteId, connectorId: ConnectorId, files: ClientSideFile[]}): Promise<string[]> {
|
|
118
|
-
const { data } = await api<ApiWebsiteAssetsWriteQuery, ApiWebsiteAssetsWriteBody, ApiWebsiteAssetsWriteResponse>(ApiRoute.WEBSITE_ASSETS_WRITE, 'POST', { websiteId, connectorId
|
|
123
|
+
const { data } = await api<ApiWebsiteAssetsWriteQuery, ApiWebsiteAssetsWriteBody, ApiWebsiteAssetsWriteResponse>(ApiRoute.WEBSITE_ASSETS_WRITE, 'POST', { websiteId, connectorId }, files)
|
|
119
124
|
return data
|
|
120
125
|
}
|
|
121
126
|
|
|
@@ -1,55 +1,64 @@
|
|
|
1
1
|
import { jest, expect, describe, it, beforeEach } from '@jest/globals'
|
|
2
|
+
import { removeTempDataFromStyles } from './assetUrl'
|
|
2
3
|
|
|
3
4
|
describe('assetUrl', () => {
|
|
4
5
|
beforeEach(() => {
|
|
5
6
|
jest.resetModules()
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
//it('store url to display url', async () => {
|
|
9
|
-
// const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
10
|
-
// // Convert a valid URL as stored
|
|
11
|
-
// expect(storedToDisplayed('/assets/test.webp', 'test-id', 'test-connector'))
|
|
12
|
-
// .toBe('/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
13
|
-
// // Convert a URL which is already as displayed
|
|
14
|
-
// expect(storedToDisplayed('/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector', 'test-id', 'test-connector'))
|
|
15
|
-
// .toBe('/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
16
|
-
//})
|
|
17
|
-
|
|
18
|
-
//it('display url to store url', async () => {
|
|
19
|
-
// const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
20
|
-
// // Convert a valid URL as displayed
|
|
21
|
-
// expect(displayedToStored('/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector'))
|
|
22
|
-
// .toBe('/assets/test.webp')
|
|
23
|
-
// // Convert a URL which is already as stored
|
|
24
|
-
// expect(displayedToStored('/assets/test.webp'))
|
|
25
|
-
// .toBe('/assets/test.webp')
|
|
26
|
-
//})
|
|
27
|
-
|
|
28
|
-
//it('store url to display url with a root path', async () => {
|
|
29
|
-
// Object.defineProperty(window, 'location', {
|
|
30
|
-
// value: {
|
|
31
|
-
// href: 'http://localhost:6800/silex',
|
|
32
|
-
// pathname: '/silex',
|
|
33
|
-
// origin: 'http://localhost:6800',
|
|
34
|
-
// },
|
|
35
|
-
// });
|
|
36
|
-
// const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
37
|
-
// // Convert a valid URL as stored
|
|
38
|
-
// expect(storedToDisplayed('/assets/test.webp', 'test-id', 'test-connector'))
|
|
39
|
-
// .toBe('/silex/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
40
|
-
// // Convert a URL which is already as displayed
|
|
41
|
-
// expect(storedToDisplayed('/silex/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector', 'test-id', 'test-connector'))
|
|
42
|
-
// .toBe('/silex/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
43
|
-
//})
|
|
44
|
-
|
|
45
|
-
it('display url to store url with a root path', async () => {
|
|
46
7
|
Object.defineProperty(window, 'location', {
|
|
47
8
|
value: {
|
|
48
|
-
href: 'http://localhost:6800/
|
|
49
|
-
pathname: '
|
|
9
|
+
href: 'http://localhost:6800/',
|
|
10
|
+
pathname: '',
|
|
50
11
|
origin: 'http://localhost:6800',
|
|
51
12
|
},
|
|
52
13
|
})
|
|
14
|
+
Object.assign(window.location, {
|
|
15
|
+
href: 'http://localhost:6800/',
|
|
16
|
+
pathname: '',
|
|
17
|
+
origin: 'http://localhost:6800',
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('store url to display url', async () => {
|
|
22
|
+
const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
23
|
+
// Convert a valid URL as stored
|
|
24
|
+
expect(storedToDisplayed('/assets/test.webp', 'test-id', 'test-connector'))
|
|
25
|
+
.toBe('/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
26
|
+
// Convert a URL which is already as displayed
|
|
27
|
+
expect(storedToDisplayed('/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector', 'test-id', 'test-connector'))
|
|
28
|
+
.toBe('/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('display url to store url', async () => {
|
|
32
|
+
const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
33
|
+
// Convert a valid URL as displayed
|
|
34
|
+
expect(displayedToStored('/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector'))
|
|
35
|
+
.toBe('/assets/test.webp')
|
|
36
|
+
// Convert a URL which is already as stored
|
|
37
|
+
expect(displayedToStored('/assets/test.webp'))
|
|
38
|
+
.toBe('/assets/test.webp')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('store url to display url with a root path', async () => {
|
|
42
|
+
Object.assign(window.location, {
|
|
43
|
+
href: 'http://localhost:6800/silex',
|
|
44
|
+
pathname: '/silex',
|
|
45
|
+
origin: 'http://localhost:6800',
|
|
46
|
+
})
|
|
47
|
+
const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
48
|
+
// Convert a valid URL as stored
|
|
49
|
+
expect(storedToDisplayed('/assets/test.webp', 'test-id', 'test-connector'))
|
|
50
|
+
.toBe('/silex/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
51
|
+
// Convert a URL which is already as displayed
|
|
52
|
+
expect(storedToDisplayed('/silex/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector', 'test-id', 'test-connector'))
|
|
53
|
+
.toBe('/silex/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('display url to store url with a root path', async () => {
|
|
57
|
+
Object.assign(window.location, {
|
|
58
|
+
href: 'http://localhost:6800/silex',
|
|
59
|
+
pathname: '/silex',
|
|
60
|
+
origin: 'http://localhost:6800',
|
|
61
|
+
})
|
|
53
62
|
const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
54
63
|
// Convert a valid URL as displayed
|
|
55
64
|
expect(displayedToStored('/silex/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector'))
|
|
@@ -58,4 +67,98 @@ describe('assetUrl', () => {
|
|
|
58
67
|
expect(displayedToStored('/assets/test.webp'))
|
|
59
68
|
.toBe('/assets/test.webp')
|
|
60
69
|
})
|
|
70
|
+
|
|
71
|
+
it('store url to display url with escapable chars', async () => {
|
|
72
|
+
Object.assign(window.location, {
|
|
73
|
+
href: 'http://localhost:6800/silex%20with%20spaces',
|
|
74
|
+
pathname: '/silex%20with%20spaces',
|
|
75
|
+
origin: 'http://localhost:6800',
|
|
76
|
+
})
|
|
77
|
+
const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
78
|
+
// Convert a valid URL as displayed
|
|
79
|
+
expect(displayedToStored('/silex%20with%20spaces/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector'))
|
|
80
|
+
.toBe('/assets/test.webp')
|
|
81
|
+
// Convert a URL which is already as stored
|
|
82
|
+
expect(displayedToStored('/assets/test.webp'))
|
|
83
|
+
.toBe('/assets/test.webp')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('display url to store url with escapable chars', async () => {
|
|
87
|
+
Object.assign(window.location, {
|
|
88
|
+
href: 'http://localhost:6800/silex%20with%20spaces',
|
|
89
|
+
pathname: '/silex%20with%20spaces',
|
|
90
|
+
origin: 'http://localhost:6800',
|
|
91
|
+
})
|
|
92
|
+
const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
93
|
+
// Convert a valid URL as stored
|
|
94
|
+
expect(storedToDisplayed('/assets/test.webp', 'test-id', 'test-connector'))
|
|
95
|
+
.toBe('/silex with spaces/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
96
|
+
// Convert a URL which is already as displayed
|
|
97
|
+
expect(storedToDisplayed('/silex%20with%20spaces/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector', 'test-id', 'test-connector'))
|
|
98
|
+
.toBe('/silex%20with%20spaces/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
99
|
+
expect(storedToDisplayed('/silex with spaces/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector', 'test-id', 'test-connector'))
|
|
100
|
+
.toBe('/silex with spaces/api/website/assets/test.webp?websiteId=test-id&connectorId=test-connector')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('store url to display url with escapable website id and connector id', async () => {
|
|
104
|
+
const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
105
|
+
// Convert a valid URL as displayed
|
|
106
|
+
expect(displayedToStored('/api/website/assets/test.webp?websiteId=test%20id&connectorId=test%20connector'))
|
|
107
|
+
.toBe('/assets/test.webp')
|
|
108
|
+
// Convert a URL which is already as stored
|
|
109
|
+
expect(displayedToStored('/assets/test.webp'))
|
|
110
|
+
.toBe('/assets/test.webp')
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('display url to store url with escapable website id and connector id', async () => {
|
|
114
|
+
const { displayedToStored, storedToDisplayed } = await import('./assetUrl')
|
|
115
|
+
const websiteId = 'test id'
|
|
116
|
+
const websiteIdEncoded = 'test+id'
|
|
117
|
+
const connectorId = 'test connector'
|
|
118
|
+
const connectorIdEncoded = 'test+connector'
|
|
119
|
+
// Convert a valid URL as stored
|
|
120
|
+
expect(storedToDisplayed('/assets/test.webp', websiteId, connectorId))
|
|
121
|
+
.toBe(`/api/website/assets/test.webp?websiteId=${websiteIdEncoded}&connectorId=${connectorIdEncoded}`)
|
|
122
|
+
// Convert a URL which is already as displayed
|
|
123
|
+
expect(storedToDisplayed(`/api/website/assets/test.webp?websiteId=${websiteIdEncoded}&connectorId=${connectorIdEncoded}`, websiteId, connectorId))
|
|
124
|
+
.toBe(`/api/website/assets/test.webp?websiteId=${websiteIdEncoded}&connectorId=${connectorIdEncoded}`)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('multiple backgrounds', async () => {
|
|
128
|
+
// // FIXME: this should mock the functions but it doesnt
|
|
129
|
+
// const mocked = {
|
|
130
|
+
// displayedToStored: jest.fn((url: string) => url),
|
|
131
|
+
// storedToDisplayed: jest.fn((url: string) => url),
|
|
132
|
+
// }
|
|
133
|
+
// jest.mock('./assetUrl', () => (mocked))
|
|
134
|
+
//addTempDataToStyles([toStyle(bgImageDisplayed)], websiteId, connectorId)
|
|
135
|
+
//expect(mocked.displayedToStored).toBeCalledTimes(1)
|
|
136
|
+
const { addTempDataToStyles } = await import('./assetUrl')
|
|
137
|
+
|
|
138
|
+
const websiteId = 'test-id'
|
|
139
|
+
const connectorId = 'test-connector'
|
|
140
|
+
const bgImageDisplayed = `linear-gradient(to right, #1fb101 0%, #df1313 67%, rgba(234, 97, 97, 255) 78%, white 100%), url('/api/website/assets/qIg7JPRc.webp?websiteId=${websiteId}&connectorId=${connectorId}'), linear-gradient(#0ca311 0%, #0ca311 100%)`
|
|
141
|
+
const bgImageStored = 'linear-gradient(to right, #1fb101 0%, #df1313 67%, rgba(234, 97, 97, 255) 78%, white 100%), url(\'/assets/qIg7JPRc.webp\'), linear-gradient(#0ca311 0%, #0ca311 100%)'
|
|
142
|
+
const selectors = ['body']
|
|
143
|
+
function toStyle(bgImage: string) {
|
|
144
|
+
return {
|
|
145
|
+
style: {
|
|
146
|
+
'background-image': bgImage,
|
|
147
|
+
},
|
|
148
|
+
selectors,
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// From stored to displayed
|
|
152
|
+
expect(addTempDataToStyles([toStyle(bgImageStored)], websiteId, connectorId))
|
|
153
|
+
.toEqual([toStyle(bgImageDisplayed)])
|
|
154
|
+
// From displayed to displayed (error case)
|
|
155
|
+
expect(addTempDataToStyles([toStyle(bgImageDisplayed)], websiteId, connectorId))
|
|
156
|
+
.toEqual([toStyle(bgImageDisplayed)])
|
|
157
|
+
// From displayed to stored
|
|
158
|
+
expect(removeTempDataFromStyles([toStyle(bgImageDisplayed)]))
|
|
159
|
+
.toEqual([toStyle(bgImageStored)])
|
|
160
|
+
//// From stored to stored (error case)
|
|
161
|
+
expect(removeTempDataFromStyles([toStyle(bgImageStored)]))
|
|
162
|
+
.toEqual([toStyle(bgImageStored)])
|
|
163
|
+
})
|
|
61
164
|
})
|
|
@@ -15,7 +15,6 @@ const baseUrl = window.location.pathname.replace(/\/$/, '')
|
|
|
15
15
|
|
|
16
16
|
// Orging and path, should we use config.rootUrl?
|
|
17
17
|
const SERVER_URL = window.location.origin
|
|
18
|
-
console.log('SERVER_URL', SERVER_URL)
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Function to convert a path from it stored version to the displayed version
|
|
@@ -36,11 +35,17 @@ export function storedToDisplayed(path: string, websiteId: WebsiteId, storageId:
|
|
|
36
35
|
url.searchParams.set('websiteId', websiteId)
|
|
37
36
|
url.searchParams.set('connectorId', storageId)
|
|
38
37
|
// Back to a relative URL, keep the path but not the origin
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
return `${decodeURIComponent(url.pathname)}${url.search}`
|
|
39
|
+
//const encodedPath = '/' + url.toString() // add a leading slash
|
|
40
|
+
// .replace(new RegExp(`^${SERVER_URL}`), '')
|
|
41
|
+
// .replace(/^\//, '') // remove the first slash if it exists
|
|
42
|
+
//return decodeURIComponent(encodedPath)
|
|
43
43
|
} else {
|
|
44
|
+
if(path.startsWith('<svg') || path.startsWith('data:image')) {
|
|
45
|
+
// SVG or data URL
|
|
46
|
+
return path
|
|
47
|
+
}
|
|
48
|
+
// Not a stored path, is there a problem?
|
|
44
49
|
console.warn('storedToDisplayed: path is not a stored path', path)
|
|
45
50
|
return path
|
|
46
51
|
}
|
|
@@ -69,6 +74,10 @@ export function displayedToStored(path: string): string {
|
|
|
69
74
|
.replace(/^\//, '') // remove the first slash if it exists
|
|
70
75
|
return decodeURIComponent(encodedPath)
|
|
71
76
|
} else {
|
|
77
|
+
if(path.startsWith('<svg') || path.startsWith('data:image')) {
|
|
78
|
+
// SVG or data URL
|
|
79
|
+
return path
|
|
80
|
+
}
|
|
72
81
|
console.warn('displayedToStored: path is not a displayed path', path)
|
|
73
82
|
return path
|
|
74
83
|
}
|
|
@@ -196,17 +205,22 @@ export function removeTempDataFromPages(pages: Page[]): Page[] {
|
|
|
196
205
|
|
|
197
206
|
/**
|
|
198
207
|
* Add data to stylesheets
|
|
208
|
+
* e.g. linear-gradient(to right, #1fb101 0%, #df1313 67%, rgba(234, 97, 97, 255) 78%, white 100%), url('/assets/qIg7JPRc.webp'), linear-gradient(#0ca311 0%, #0ca311 100%)
|
|
199
209
|
*/
|
|
200
210
|
export function addTempDataToStyles(styles: Style[], websiteId: WebsiteId, storageId: ConnectorId): Style[] {
|
|
201
|
-
const
|
|
211
|
+
const regex = new RegExp(/(.*)(url\((["']?)([^"']+?)\1\))*(.*)/, 'g')
|
|
212
|
+
|
|
202
213
|
return styles.map((style: Style) => {
|
|
203
214
|
if (style.style && style.style['background-image']) {
|
|
204
|
-
const
|
|
215
|
+
const bgImage = style.style['background-image']
|
|
216
|
+
.replace(/url\((['"]?)([^'"]+)\1\)/g, (match, quote, url) => {
|
|
217
|
+
return `url(${quote}${storedToDisplayed(url, websiteId, storageId)}${quote})`
|
|
218
|
+
})
|
|
205
219
|
return {
|
|
206
220
|
...style,
|
|
207
221
|
style: {
|
|
208
222
|
...style.style,
|
|
209
|
-
'background-image':
|
|
223
|
+
'background-image': bgImage,
|
|
210
224
|
},
|
|
211
225
|
}
|
|
212
226
|
}
|
|
@@ -216,17 +230,22 @@ export function addTempDataToStyles(styles: Style[], websiteId: WebsiteId, stora
|
|
|
216
230
|
|
|
217
231
|
/**
|
|
218
232
|
* Remove temp data from stylesheets
|
|
233
|
+
* The property `background-image` contains the URLs of the assets and other values,
|
|
234
|
+
* e.g. `linear-gradient(to right, #1fb101 0%, #df1313 67%, rgba(234, 97, 97, 255) 78%, white 100%), url('/api/website/assets/qIg7JPRc.webp?websiteId=default&connectorId=fs-storage'), linear-gradient(#0ca311 0%, #0ca311 100%)`
|
|
219
235
|
*/
|
|
220
236
|
export function removeTempDataFromStyles(styles: Style[]): Style[] {
|
|
221
237
|
const pattern = /url\((["']?)([^"']+?)\1\)/g
|
|
222
238
|
return styles.map((style: Style) => {
|
|
223
239
|
if (style.style && style.style['background-image']) {
|
|
224
|
-
const
|
|
240
|
+
const bgImage = style.style['background-image']
|
|
241
|
+
.replace(/url\((['"]?)([^'"]+)\1\)/g, (match, quote, url) => {
|
|
242
|
+
return `url(${quote}${displayedToStored(url)}${quote})`
|
|
243
|
+
})
|
|
225
244
|
return {
|
|
226
245
|
...style,
|
|
227
246
|
style: {
|
|
228
247
|
...style.style,
|
|
229
|
-
'background-image':
|
|
248
|
+
'background-image': bgImage,
|
|
230
249
|
},
|
|
231
250
|
}
|
|
232
251
|
}
|