@vonaffenfels/slate-editor 1.2.11 → 1.2.12
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/dist/Renderer.js +1 -1
- package/dist/index.js +4 -4
- package/package.json +2 -2
- package/src/Serializer/ads.js +17 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/slate-editor",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"cssnano": "^5.0.1",
|
|
73
73
|
"escape-html": "^1.0.3"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "56a8de39a476572111d31320f3034d254be91885",
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
}
|
package/src/Serializer/ads.js
CHANGED
|
@@ -13,6 +13,8 @@ export const addAdsToValue = (value, adDefinitionDesktop = [], adDefinitionMobil
|
|
|
13
13
|
|
|
14
14
|
for (let i = 0; i < value.length; i++) {
|
|
15
15
|
const element = value[i];
|
|
16
|
+
const nextElement = value[i + 1] || null;
|
|
17
|
+
console.log("DEBUG ELEMENTS", element);
|
|
16
18
|
const textLength = getElementTextLength(element);
|
|
17
19
|
const isPlaceable = isAdPlaceable(element, counters);
|
|
18
20
|
|
|
@@ -33,7 +35,7 @@ export const addAdsToValue = (value, adDefinitionDesktop = [], adDefinitionMobil
|
|
|
33
35
|
counters.currElementsChain.push(element);
|
|
34
36
|
|
|
35
37
|
if (checkAdPlacement(
|
|
36
|
-
currAd, counters, counters.currTextCounterDesktop, element,
|
|
38
|
+
currAd, counters, counters.currTextCounterDesktop, element, nextElement,
|
|
37
39
|
)) {
|
|
38
40
|
placedAdDesktop = currAd;
|
|
39
41
|
if (currAd.reset !== false) {
|
|
@@ -42,7 +44,7 @@ export const addAdsToValue = (value, adDefinitionDesktop = [], adDefinitionMobil
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
if (checkAdPlacement(
|
|
45
|
-
currAdMobile, counters, counters.currTextCounterMobile, element,
|
|
47
|
+
currAdMobile, counters, counters.currTextCounterMobile, element, nextElement,
|
|
46
48
|
)) {
|
|
47
49
|
placedAdMobile = currAdMobile;
|
|
48
50
|
if (currAdMobile.reset !== false) {
|
|
@@ -120,7 +122,7 @@ const isAdPlaceable = (element, counters) => {
|
|
|
120
122
|
};
|
|
121
123
|
|
|
122
124
|
const checkAdPlacement = (
|
|
123
|
-
ad, counters, currTextCounter = 0, element = null,
|
|
125
|
+
ad, counters, currTextCounter = 0, element = null, nextElement = null,
|
|
124
126
|
) => {
|
|
125
127
|
let canBePlaced = false;
|
|
126
128
|
|
|
@@ -135,6 +137,18 @@ const checkAdPlacement = (
|
|
|
135
137
|
canBePlaced = true;
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
const disallowedAdjacents = ad?.disallowedAdjacents || [
|
|
141
|
+
"Inline/ProductTeaser",
|
|
142
|
+
"Inline/AboTeaser",
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
// dont allow ads before+after disallowedAdjacents elements
|
|
146
|
+
if (element?.type === "storybook" && disallowedAdjacents.includes(element?.block)) {
|
|
147
|
+
canBePlaced = false;
|
|
148
|
+
} else if (nextElement?.type === "storybook" && disallowedAdjacents.includes(nextElement?.block)) {
|
|
149
|
+
canBePlaced = false;
|
|
150
|
+
}
|
|
151
|
+
|
|
138
152
|
// dont allow inline anywhere BUT paragraphs
|
|
139
153
|
if (ad?.inline && element?.type !== "paragraph") {
|
|
140
154
|
canBePlaced = false;
|