@vonaffenfels/slate-editor 1.2.11 → 1.2.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/slate-editor",
3
- "version": "1.2.11",
3
+ "version": "1.2.13",
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": "fa0c31b3c84bf9dfc1ce3707da9fb135834adb85",
75
+ "gitHead": "8c1592b503c1df6efc4d84716d738d81207c3b9c",
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  }
@@ -13,6 +13,7 @@ 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;
16
17
  const textLength = getElementTextLength(element);
17
18
  const isPlaceable = isAdPlaceable(element, counters);
18
19
 
@@ -33,7 +34,7 @@ export const addAdsToValue = (value, adDefinitionDesktop = [], adDefinitionMobil
33
34
  counters.currElementsChain.push(element);
34
35
 
35
36
  if (checkAdPlacement(
36
- currAd, counters, counters.currTextCounterDesktop, element,
37
+ currAd, counters, counters.currTextCounterDesktop, element, nextElement,
37
38
  )) {
38
39
  placedAdDesktop = currAd;
39
40
  if (currAd.reset !== false) {
@@ -42,7 +43,7 @@ export const addAdsToValue = (value, adDefinitionDesktop = [], adDefinitionMobil
42
43
  }
43
44
 
44
45
  if (checkAdPlacement(
45
- currAdMobile, counters, counters.currTextCounterMobile, element,
46
+ currAdMobile, counters, counters.currTextCounterMobile, element, nextElement,
46
47
  )) {
47
48
  placedAdMobile = currAdMobile;
48
49
  if (currAdMobile.reset !== false) {
@@ -120,7 +121,7 @@ const isAdPlaceable = (element, counters) => {
120
121
  };
121
122
 
122
123
  const checkAdPlacement = (
123
- ad, counters, currTextCounter = 0, element = null,
124
+ ad, counters, currTextCounter = 0, element = null, nextElement = null,
124
125
  ) => {
125
126
  let canBePlaced = false;
126
127
 
@@ -135,6 +136,18 @@ const checkAdPlacement = (
135
136
  canBePlaced = true;
136
137
  }
137
138
 
139
+ const disallowedAdjacents = ad?.disallowedAdjacents || [
140
+ "Inline/ProductTeaser",
141
+ "Inline/AboTeaser",
142
+ ];
143
+
144
+ // dont allow ads before+after disallowedAdjacents elements
145
+ if (element?.type === "storybook" && disallowedAdjacents.includes(element?.block)) {
146
+ canBePlaced = false;
147
+ } else if (nextElement?.type === "storybook" && disallowedAdjacents.includes(nextElement?.block)) {
148
+ canBePlaced = false;
149
+ }
150
+
138
151
  // dont allow inline anywhere BUT paragraphs
139
152
  if (ad?.inline && element?.type !== "paragraph") {
140
153
  canBePlaced = false;