@vonaffenfels/contentful-teasermanager 1.2.32 → 1.2.41
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/.babelrc +19 -19
- package/dist/TestStory.js +94 -0
- package/dist/TestStory2.js +94 -0
- package/dist/TestStory3.js +94 -0
- package/dist/index.html +12 -0
- package/dist/index.js +120203 -0
- package/jest.config.js +8 -8
- package/package.json +3 -3
- package/postcss.config.js +6 -6
- package/src/components/Contentful/ConfigScreen.js +154 -154
- package/src/components/Contentful/Dialog/LogicEditor.js +602 -602
- package/src/components/Contentful/Dialog/NewestArticles.js +198 -198
- package/src/components/Contentful/Dialog.js +87 -87
- package/src/components/Contentful/EntryEditor.js +196 -196
- package/src/components/Contentful/Page.js +9 -9
- package/src/components/NoAccess.js +12 -12
- package/src/components/Teasermanager/Timeline.js +179 -179
- package/src/components/Teasermanager/Timeline.module.css +89 -89
- package/src/components/Teasermanager.js +269 -269
- package/src/components/Teasermanager.module.css +137 -137
- package/src/dev.js +5 -5
- package/src/hooks/useDebounce.js +20 -20
- package/src/hooks/useOnScreen.js +23 -23
- package/src/icons/remove.svg +7 -7
- package/src/index.html +11 -11
- package/src/index.js +51 -51
- package/src/lib/contentfulClient.js +12 -12
- package/src/lib/runLoaders.js +46 -46
- package/src/queryFromLogic.test.js +148 -148
- package/src/scss/index.scss +11 -11
- package/src/utils/germanTimezoneOffset.js +35 -35
- package/src/utils/germanTimezoneOffset.test.js +51 -51
- package/tailwind.config.js +5 -5
- package/webpack.config.dev.js +25 -25
- package/webpack.config.js +174 -174
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
.wrapper *[data-teasermanager-slot] {
|
|
2
|
-
position: relative;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.management {
|
|
6
|
-
font-family: Arial, Helvetica, sans-serif;
|
|
7
|
-
|
|
8
|
-
background-color: rgba(255, 255, 255, 0.2);
|
|
9
|
-
outline: 2px dashed black;
|
|
10
|
-
color: black;
|
|
11
|
-
text-align: center;
|
|
12
|
-
vertical-align: middle;
|
|
13
|
-
position: absolute;
|
|
14
|
-
top: 0;
|
|
15
|
-
left: 0;
|
|
16
|
-
width: 100%;
|
|
17
|
-
height: 100%;
|
|
18
|
-
cursor: pointer;
|
|
19
|
-
|
|
20
|
-
display: flex;
|
|
21
|
-
justify-items: center;
|
|
22
|
-
align-items: center;
|
|
23
|
-
padding: 1em;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.remove-button {
|
|
27
|
-
display: flex;
|
|
28
|
-
padding: 0.5em;
|
|
29
|
-
position: absolute;
|
|
30
|
-
top: 0;
|
|
31
|
-
right: 0;
|
|
32
|
-
cursor: pointer;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.loading {
|
|
36
|
-
animation: pulse 3s ease-in-out infinite;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.loading:after {
|
|
40
|
-
content: '';
|
|
41
|
-
position: absolute;
|
|
42
|
-
top: 50%;
|
|
43
|
-
left: 50%;
|
|
44
|
-
margin-top: -50px;
|
|
45
|
-
margin-left: -50px;
|
|
46
|
-
width: 100px;
|
|
47
|
-
height: 100px;
|
|
48
|
-
border-radius: 999999px;
|
|
49
|
-
border: 10px dotted white;
|
|
50
|
-
filter: drop-shadow(2px 4px 6px black);
|
|
51
|
-
animation: loading 3s linear infinite;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@keyframes loading {
|
|
55
|
-
0% {
|
|
56
|
-
transform: rotate(0deg);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
100% {
|
|
60
|
-
transform: rotate(360deg);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@keyframes pulse {
|
|
65
|
-
from {
|
|
66
|
-
opacity: 1;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
50% {
|
|
70
|
-
opacity: 0.3;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
to {
|
|
74
|
-
opacity: 1;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@media (prefers-color-scheme: dark) {
|
|
79
|
-
.management {
|
|
80
|
-
outline: 2px dashed white;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.management:hover {
|
|
85
|
-
background-color: rgba(255, 255, 255, 0.9);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.label {
|
|
89
|
-
visibility: hidden;
|
|
90
|
-
width: 100%;
|
|
91
|
-
height: 100%;
|
|
92
|
-
font-weight: bold;
|
|
93
|
-
text-align: center;
|
|
94
|
-
align-content: center;
|
|
95
|
-
padding: 6px;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.labelLogic {
|
|
99
|
-
visibility: hidden;
|
|
100
|
-
width: 100%;
|
|
101
|
-
height: 100%;
|
|
102
|
-
font-weight: bold;
|
|
103
|
-
text-align: center;
|
|
104
|
-
align-content: center;
|
|
105
|
-
padding: 1em;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.labelLogic:hover {
|
|
109
|
-
background-color: rgba(0, 0, 0, 0.3);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.label:hover {
|
|
113
|
-
background-color: rgba(0, 0, 0, 0.3);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.management:hover .label {
|
|
117
|
-
visibility: visible;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.management:hover .labelLogic {
|
|
121
|
-
visibility: visible;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.changed {
|
|
125
|
-
background-color: rgba(172, 255, 156, 0.4);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.changed:hover {
|
|
129
|
-
background-color: rgba(97, 255, 68, 0.6);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.changed-border {
|
|
133
|
-
outline-color: green;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.logic-border {
|
|
137
|
-
outline-color: orange;
|
|
1
|
+
.wrapper *[data-teasermanager-slot] {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.management {
|
|
6
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
7
|
+
|
|
8
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
9
|
+
outline: 2px dashed black;
|
|
10
|
+
color: black;
|
|
11
|
+
text-align: center;
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
position: absolute;
|
|
14
|
+
top: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-items: center;
|
|
22
|
+
align-items: center;
|
|
23
|
+
padding: 1em;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.remove-button {
|
|
27
|
+
display: flex;
|
|
28
|
+
padding: 0.5em;
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 0;
|
|
31
|
+
right: 0;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.loading {
|
|
36
|
+
animation: pulse 3s ease-in-out infinite;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.loading:after {
|
|
40
|
+
content: '';
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: 50%;
|
|
43
|
+
left: 50%;
|
|
44
|
+
margin-top: -50px;
|
|
45
|
+
margin-left: -50px;
|
|
46
|
+
width: 100px;
|
|
47
|
+
height: 100px;
|
|
48
|
+
border-radius: 999999px;
|
|
49
|
+
border: 10px dotted white;
|
|
50
|
+
filter: drop-shadow(2px 4px 6px black);
|
|
51
|
+
animation: loading 3s linear infinite;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@keyframes loading {
|
|
55
|
+
0% {
|
|
56
|
+
transform: rotate(0deg);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
100% {
|
|
60
|
+
transform: rotate(360deg);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@keyframes pulse {
|
|
65
|
+
from {
|
|
66
|
+
opacity: 1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
50% {
|
|
70
|
+
opacity: 0.3;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
to {
|
|
74
|
+
opacity: 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media (prefers-color-scheme: dark) {
|
|
79
|
+
.management {
|
|
80
|
+
outline: 2px dashed white;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.management:hover {
|
|
85
|
+
background-color: rgba(255, 255, 255, 0.9);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.label {
|
|
89
|
+
visibility: hidden;
|
|
90
|
+
width: 100%;
|
|
91
|
+
height: 100%;
|
|
92
|
+
font-weight: bold;
|
|
93
|
+
text-align: center;
|
|
94
|
+
align-content: center;
|
|
95
|
+
padding: 6px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.labelLogic {
|
|
99
|
+
visibility: hidden;
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 100%;
|
|
102
|
+
font-weight: bold;
|
|
103
|
+
text-align: center;
|
|
104
|
+
align-content: center;
|
|
105
|
+
padding: 1em;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.labelLogic:hover {
|
|
109
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.label:hover {
|
|
113
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.management:hover .label {
|
|
117
|
+
visibility: visible;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.management:hover .labelLogic {
|
|
121
|
+
visibility: visible;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.changed {
|
|
125
|
+
background-color: rgba(172, 255, 156, 0.4);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.changed:hover {
|
|
129
|
+
background-color: rgba(97, 255, 68, 0.6);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.changed-border {
|
|
133
|
+
outline-color: green;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.logic-border {
|
|
137
|
+
outline-color: orange;
|
|
138
138
|
}
|
package/src/dev.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '@vonaffenfels/slate-editor/dist/index.css';
|
|
2
|
-
import './scss/index.scss';
|
|
3
|
-
import './scss/dev.scss';
|
|
4
|
-
import {BaseContentfulApp} from "./index"
|
|
5
|
-
|
|
1
|
+
import '@vonaffenfels/slate-editor/dist/index.css';
|
|
2
|
+
import './scss/index.scss';
|
|
3
|
+
import './scss/dev.scss';
|
|
4
|
+
import {BaseContentfulApp} from "./index"
|
|
5
|
+
|
|
6
6
|
BaseContentfulApp();
|
package/src/hooks/useDebounce.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import React, {useState, useEffect} from "react";
|
|
2
|
-
|
|
3
|
-
export default function useDebounce(value, delay) {
|
|
4
|
-
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
5
|
-
|
|
6
|
-
useEffect(
|
|
7
|
-
() => {
|
|
8
|
-
const handler = setTimeout(() => {
|
|
9
|
-
setDebouncedValue(value);
|
|
10
|
-
}, delay);
|
|
11
|
-
|
|
12
|
-
return () => {
|
|
13
|
-
clearTimeout(handler);
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
[value],
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
return debouncedValue;
|
|
1
|
+
import React, {useState, useEffect} from "react";
|
|
2
|
+
|
|
3
|
+
export default function useDebounce(value, delay) {
|
|
4
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
5
|
+
|
|
6
|
+
useEffect(
|
|
7
|
+
() => {
|
|
8
|
+
const handler = setTimeout(() => {
|
|
9
|
+
setDebouncedValue(value);
|
|
10
|
+
}, delay);
|
|
11
|
+
|
|
12
|
+
return () => {
|
|
13
|
+
clearTimeout(handler);
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
[value],
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return debouncedValue;
|
|
21
21
|
}
|
package/src/hooks/useOnScreen.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useState, useEffect, useRef,
|
|
3
|
-
} from "react";
|
|
4
|
-
|
|
5
|
-
export default function useOnScreen(ref) {
|
|
6
|
-
const [isIntersecting, setIntersecting] = useState(false);
|
|
7
|
-
const observerRef = useRef();
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (!observerRef.current && ref.current) {
|
|
11
|
-
observerRef.current = new IntersectionObserver(([entry]) => setIntersecting(entry.isIntersecting));
|
|
12
|
-
|
|
13
|
-
observerRef.current.observe(ref.current);
|
|
14
|
-
|
|
15
|
-
return () => {
|
|
16
|
-
if (observerRef.current) {
|
|
17
|
-
observerRef.current.disconnect();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}, []);
|
|
22
|
-
|
|
23
|
-
return isIntersecting;
|
|
1
|
+
import React, {
|
|
2
|
+
useState, useEffect, useRef,
|
|
3
|
+
} from "react";
|
|
4
|
+
|
|
5
|
+
export default function useOnScreen(ref) {
|
|
6
|
+
const [isIntersecting, setIntersecting] = useState(false);
|
|
7
|
+
const observerRef = useRef();
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!observerRef.current && ref.current) {
|
|
11
|
+
observerRef.current = new IntersectionObserver(([entry]) => setIntersecting(entry.isIntersecting));
|
|
12
|
+
|
|
13
|
+
observerRef.current.observe(ref.current);
|
|
14
|
+
|
|
15
|
+
return () => {
|
|
16
|
+
if (observerRef.current) {
|
|
17
|
+
observerRef.current.disconnect();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
return isIntersecting;
|
|
24
24
|
}
|
package/src/icons/remove.svg
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
<svg height="0px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
3
|
-
viewBox="0 0 496.158 496.158" xml:space="preserve">
|
|
4
|
-
<path style="fill:#E04F5F;" d="M0,248.085C0,111.063,111.069,0.003,248.075,0.003c137.013,0,248.083,111.061,248.083,248.082
|
|
5
|
-
c0,137.002-111.07,248.07-248.083,248.07C111.069,496.155,0,385.087,0,248.085z"/>
|
|
6
|
-
<path style="fill:#FFFFFF;" d="M383.546,206.286H112.612c-3.976,0-7.199,3.225-7.199,7.2v69.187c0,3.976,3.224,7.199,7.199,7.199
|
|
7
|
-
h270.934c3.976,0,7.199-3.224,7.199-7.199v-69.187C390.745,209.511,387.521,206.286,383.546,206.286z"/>
|
|
1
|
+
|
|
2
|
+
<svg height="0px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
3
|
+
viewBox="0 0 496.158 496.158" xml:space="preserve">
|
|
4
|
+
<path style="fill:#E04F5F;" d="M0,248.085C0,111.063,111.069,0.003,248.075,0.003c137.013,0,248.083,111.061,248.083,248.082
|
|
5
|
+
c0,137.002-111.07,248.07-248.083,248.07C111.069,496.155,0,385.087,0,248.085z"/>
|
|
6
|
+
<path style="fill:#FFFFFF;" d="M383.546,206.286H112.612c-3.976,0-7.199,3.225-7.199,7.2v69.187c0,3.976,3.224,7.199,7.199,7.199
|
|
7
|
+
h270.934c3.976,0,7.199-3.224,7.199-7.199v-69.187C390.745,209.511,387.521,206.286,383.546,206.286z"/>
|
|
8
8
|
</svg>
|
package/src/index.html
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8"/>
|
|
5
|
-
<title>Slate Block Editor Contentful App</title>
|
|
6
|
-
<script src="https://media-library.cloudinary.com/global/all.js"></script>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="root">
|
|
10
|
-
</div>
|
|
11
|
-
</body>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>Slate Block Editor Contentful App</title>
|
|
6
|
+
<script src="https://media-library.cloudinary.com/global/all.js"></script>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root">
|
|
10
|
+
</div>
|
|
11
|
+
</body>
|
|
12
12
|
</html>
|
package/src/index.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {createRoot} from 'react-dom/client';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
init,
|
|
6
|
-
locations,
|
|
7
|
-
} from '@contentful/app-sdk';
|
|
8
|
-
|
|
9
|
-
import EntryEditor from './components/Contentful/EntryEditor';
|
|
10
|
-
import Config from './components/Contentful/ConfigScreen';
|
|
11
|
-
import Dialog from "./components/Contentful/Dialog";
|
|
12
|
-
import Page from "./components/Contentful/Page";
|
|
13
|
-
import {initContentfulClient} from "./lib/contentfulClient";
|
|
14
|
-
|
|
15
|
-
export const BaseContentfulApp = (props = {}) => {
|
|
16
|
-
init((sdk) => {
|
|
17
|
-
const rootContainer = document.getElementById('root');
|
|
18
|
-
|
|
19
|
-
if (props.initPortal && sdk.parameters?.invocation?.portal) {
|
|
20
|
-
props.initPortal(sdk.parameters.invocation.portal);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
initContentfulClient(sdk);
|
|
24
|
-
|
|
25
|
-
const RendererWrapperComponent = props.RendererWrapperComponent || (({children}) => <div>{children}</div>);
|
|
26
|
-
const ComponentLocationSettings = [
|
|
27
|
-
{
|
|
28
|
-
location: locations.LOCATION_APP_CONFIG,
|
|
29
|
-
component: <Config sdk={sdk}/>,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
location: locations.LOCATION_ENTRY_EDITOR,
|
|
33
|
-
component: <RendererWrapperComponent sdk={sdk}><EntryEditor sdk={sdk}/></RendererWrapperComponent>,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
location: locations.LOCATION_DIALOG,
|
|
37
|
-
component: <Dialog sdk={sdk} portals={props.portals} getArticleThumbnailUrl={props.getArticleThumbnailUrl}/>,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
location: locations.LOCATION_PAGE,
|
|
41
|
-
component: <RendererWrapperComponent sdk={sdk}><Page sdk={sdk}/></RendererWrapperComponent>,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
|
|
45
|
-
ComponentLocationSettings.forEach((componentLocationSetting) => {
|
|
46
|
-
if (sdk.location.is(componentLocationSetting.location)) {
|
|
47
|
-
const root = createRoot(rootContainer); // createRoot(container!) if you use TypeScript
|
|
48
|
-
root.render(componentLocationSetting.component);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {createRoot} from 'react-dom/client';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
init,
|
|
6
|
+
locations,
|
|
7
|
+
} from '@contentful/app-sdk';
|
|
8
|
+
|
|
9
|
+
import EntryEditor from './components/Contentful/EntryEditor';
|
|
10
|
+
import Config from './components/Contentful/ConfigScreen';
|
|
11
|
+
import Dialog from "./components/Contentful/Dialog";
|
|
12
|
+
import Page from "./components/Contentful/Page";
|
|
13
|
+
import {initContentfulClient} from "./lib/contentfulClient";
|
|
14
|
+
|
|
15
|
+
export const BaseContentfulApp = (props = {}) => {
|
|
16
|
+
init((sdk) => {
|
|
17
|
+
const rootContainer = document.getElementById('root');
|
|
18
|
+
|
|
19
|
+
if (props.initPortal && sdk.parameters?.invocation?.portal) {
|
|
20
|
+
props.initPortal(sdk.parameters.invocation.portal);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
initContentfulClient(sdk);
|
|
24
|
+
|
|
25
|
+
const RendererWrapperComponent = props.RendererWrapperComponent || (({children}) => <div>{children}</div>);
|
|
26
|
+
const ComponentLocationSettings = [
|
|
27
|
+
{
|
|
28
|
+
location: locations.LOCATION_APP_CONFIG,
|
|
29
|
+
component: <Config sdk={sdk}/>,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
location: locations.LOCATION_ENTRY_EDITOR,
|
|
33
|
+
component: <RendererWrapperComponent sdk={sdk}><EntryEditor sdk={sdk}/></RendererWrapperComponent>,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
location: locations.LOCATION_DIALOG,
|
|
37
|
+
component: <Dialog sdk={sdk} portals={props.portals} getArticleThumbnailUrl={props.getArticleThumbnailUrl}/>,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
location: locations.LOCATION_PAGE,
|
|
41
|
+
component: <RendererWrapperComponent sdk={sdk}><Page sdk={sdk}/></RendererWrapperComponent>,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
ComponentLocationSettings.forEach((componentLocationSetting) => {
|
|
46
|
+
if (sdk.location.is(componentLocationSetting.location)) {
|
|
47
|
+
const root = createRoot(rootContainer); // createRoot(container!) if you use TypeScript
|
|
48
|
+
root.render(componentLocationSetting.component);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
52
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
let __contentfulClient;
|
|
2
|
-
|
|
3
|
-
export const getContentfulClient = () => {
|
|
4
|
-
if (!__contentfulClient) {
|
|
5
|
-
throw new Error(`Contentful client not initialized run initContentfulClient(sdk) first`);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return __contentfulClient;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const initContentfulClient = (sdk) => {
|
|
12
|
-
__contentfulClient = sdk.space;
|
|
1
|
+
let __contentfulClient;
|
|
2
|
+
|
|
3
|
+
export const getContentfulClient = () => {
|
|
4
|
+
if (!__contentfulClient) {
|
|
5
|
+
throw new Error(`Contentful client not initialized run initContentfulClient(sdk) first`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return __contentfulClient;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const initContentfulClient = (sdk) => {
|
|
12
|
+
__contentfulClient = sdk.space;
|
|
13
13
|
}
|
package/src/lib/runLoaders.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
export const runLoaders = async (value, portal, contextId, currentDate) => {
|
|
2
|
-
if (!Array.isArray(value)) {
|
|
3
|
-
return value;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const newValue = await Promise.all(value.map(async (item) => {
|
|
7
|
-
try {
|
|
8
|
-
return await runLoader(item, portal, contextId, currentDate)
|
|
9
|
-
} catch (e) {
|
|
10
|
-
console.error(e);
|
|
11
|
-
return item;
|
|
12
|
-
}
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
return newValue;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const runLoader = async (item, portal, contextId, currentDate = new Date()) => {
|
|
19
|
-
|
|
20
|
-
if (!item?.block) {
|
|
21
|
-
return item;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
const response = await fetch(`/api/loader/?portal=${portal}&block=${item.block}`, {
|
|
25
|
-
method: "POST",
|
|
26
|
-
body: JSON.stringify({
|
|
27
|
-
variables: {
|
|
28
|
-
...(item.attributes || {}),
|
|
29
|
-
teasermanagerDate: currentDate,
|
|
30
|
-
},
|
|
31
|
-
context: {activeContent: {sys: {id: contextId}}},
|
|
32
|
-
}),
|
|
33
|
-
}).then(res => res.json());
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
...item,
|
|
37
|
-
attributes: {
|
|
38
|
-
...(item.attributes || {}),
|
|
39
|
-
...response,
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.error(e);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return item;
|
|
1
|
+
export const runLoaders = async (value, portal, contextId, currentDate) => {
|
|
2
|
+
if (!Array.isArray(value)) {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const newValue = await Promise.all(value.map(async (item) => {
|
|
7
|
+
try {
|
|
8
|
+
return await runLoader(item, portal, contextId, currentDate)
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error(e);
|
|
11
|
+
return item;
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
return newValue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const runLoader = async (item, portal, contextId, currentDate = new Date()) => {
|
|
19
|
+
|
|
20
|
+
if (!item?.block) {
|
|
21
|
+
return item;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch(`/api/loader/?portal=${portal}&block=${item.block}`, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
variables: {
|
|
28
|
+
...(item.attributes || {}),
|
|
29
|
+
teasermanagerDate: currentDate,
|
|
30
|
+
},
|
|
31
|
+
context: {activeContent: {sys: {id: contextId}}},
|
|
32
|
+
}),
|
|
33
|
+
}).then(res => res.json());
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
...item,
|
|
37
|
+
attributes: {
|
|
38
|
+
...(item.attributes || {}),
|
|
39
|
+
...response,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(e);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return item;
|
|
47
47
|
}
|