@griddo/ax 10.1.79 → 10.1.81

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "10.1.79",
4
+ "version": "10.1.81",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -230,5 +230,5 @@
230
230
  "publishConfig": {
231
231
  "access": "public"
232
232
  },
233
- "gitHead": "7983caa7394962e73188ec16d3335997293056ca"
233
+ "gitHead": "9e09e84487847bde76f2bb9941539dbf2bc76ae3"
234
234
  }
@@ -90,15 +90,17 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
90
90
  }
91
91
  };
92
92
 
93
+ const getTimeSinceModuleCopy = (moduleCopy: { date: string; element: Record<string, any> }) =>
94
+ differenceInSeconds(new Date(), new Date(moduleCopy.date));
95
+
93
96
  const showAddItemButton = (!maxItems || fixedValue.length < maxItems) && !disabled;
94
- const timeSinceModuleCopy = !!moduleCopy && differenceInSeconds(new Date(), new Date(moduleCopy.date));
95
97
  const eightHoursInSeconds = 8 * 60 * 60;
96
98
 
97
- const showPasteModuleButton =
99
+ const showPasteModuleButton: boolean =
98
100
  showAddItemButton &&
99
101
  (isModuleArr || objKey === "componentModules") &&
100
102
  !!moduleCopy &&
101
- timeSinceModuleCopy && timeSinceModuleCopy < eightHoursInSeconds &&
103
+ getTimeSinceModuleCopy(moduleCopy) < eightHoursInSeconds &&
102
104
  (whiteList.includes(moduleCopyComponent) || isModuleCopyUnavailable);
103
105
 
104
106
  const canReplace = maxItems === 1 && whiteList.length > 1;
@@ -11,7 +11,7 @@ import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
11
11
  import * as S from "./style";
12
12
 
13
13
  const RichText = (props: IRichTextProps): JSX.Element => {
14
- const { value, error, placeholder, onChange, disabled, editorID, handleValidation, html = false, delayed } = props;
14
+ const { value, error, placeholder, onChange, disabled, editorID, handleValidation, validators, html = false, delayed } = props;
15
15
 
16
16
  const valueUnformatted = value ? formatIframe(value, true) : "";
17
17
 
@@ -68,7 +68,7 @@ const RichText = (props: IRichTextProps): JSX.Element => {
68
68
 
69
69
  const handleOnBlur = (event: React.FocusEvent<HTMLTextAreaElement>, editorState: EditorState) => {
70
70
  const plainContent = editorState.getCurrentContent().getPlainText();
71
- handleValidation && handleValidation(plainContent);
71
+ handleValidation && handleValidation(plainContent, validators);
72
72
  };
73
73
 
74
74
  const toolbar = {
@@ -122,9 +122,10 @@ export interface IRichTextProps {
122
122
  placeholder?: string;
123
123
  disabled?: boolean;
124
124
  onChange: (value: string) => void;
125
- handleValidation?: (value: string) => void;
125
+ handleValidation?: (value: string, validators?: Record<string, unknown>) => void;
126
126
  html: boolean;
127
127
  delayed?: boolean;
128
+ validators?: Record<string, unknown>;
128
129
  }
129
130
 
130
131
  export default memo(RichText);
@@ -334,9 +334,9 @@ function getPage(pageID?: number, global?: boolean): (dispatch: Dispatch, getSta
334
334
  const { liveStatus, component } = getDefaultSchema(baseSchema);
335
335
 
336
336
  if (isNewTranslation) {
337
- page["liveStatus"] = liveStatus;
338
- page["canBeTranslated"] = true;
339
- page["originalLanguage"] = page.language;
337
+ page["liveStatus"] = liveStatus;
338
+ page["canBeTranslated"] = true;
339
+ page["originalLanguage"] = page.language;
340
340
  }
341
341
 
342
342
  if (global) page["component"] = component;
@@ -912,7 +912,7 @@ function pasteModule(
912
912
  const response = await structuredData.getDataContentBulk(fixed, currentSiteInfo.id);
913
913
  if (isReqOk(response.status)) {
914
914
  const validDataIds: number[] = [];
915
- response.data.forEach((data: IStructuredDataContent) => data.relatedSite && validDataIds.push(data.id));
915
+ response.data.items.forEach((data: IStructuredDataContent) => data.relatedSite && validDataIds.push(data.id));
916
916
  const hasInvalidData = validDataIds.length < fixed.length;
917
917
  validatedModuleCopy.data.fixed = validDataIds;
918
918
  if (hasInvalidData) {
@@ -1470,5 +1470,5 @@ export {
1470
1470
  restorePageNavigation,
1471
1471
  getPageSummary,
1472
1472
  getPageTranslation,
1473
- setIsTranslated
1473
+ setIsTranslated,
1474
1474
  };
@@ -13,6 +13,7 @@ import {
13
13
  isValidDateRange,
14
14
  stringToDate,
15
15
  isEmptyObj,
16
+ stripHtml,
16
17
  } from "@ax/helpers";
17
18
 
18
19
  import { findByEditorID } from "@ax/forms";
@@ -25,13 +26,13 @@ const VALIDATORS = {
25
26
  return { isValid, errorCode: "ERR001" };
26
27
  },
27
28
  maxChar: (val: string | null, max: number): IError => {
28
- const length = val ? val.length : 0;
29
- const isValid = length <= max;
29
+ const noHtmlVal = stripHtml(val);
30
+ const isValid = noHtmlVal.length <= max;
30
31
  return { isValid, errorCode: "ERR003" };
31
32
  },
32
33
  minChar: (val: string | null, min: number): IError => {
33
- const length = val ? val.length : 0;
34
- const isValid = length >= min;
34
+ const noHtmlVal = stripHtml(val);
35
+ const isValid = noHtmlVal.length >= min;
35
36
  return { isValid, errorCode: "ERR002" };
36
37
  },
37
38
  maxValue: (val: string, len: number): IError => {
@@ -21,6 +21,7 @@ import {
21
21
  splitAndJoin,
22
22
  splitAndTrim,
23
23
  copyTextToClipboard,
24
+ stripHtml,
24
25
  } from "./strings";
25
26
 
26
27
  import {
@@ -185,4 +186,5 @@ export {
185
186
  isMultipleNavigationModules,
186
187
  areEqual,
187
188
  parseTheme,
189
+ stripHtml,
188
190
  };
@@ -122,6 +122,13 @@ const copyTextToClipboard = (text: string): Promise<void> => {
122
122
  }
123
123
  };
124
124
 
125
+ const stripHtml = (html: string | null) => {
126
+ if(!html || typeof html !== "string") return "";
127
+ const tmp = document.createElement("DIV");
128
+ tmp.innerHTML = html;
129
+ return tmp.textContent || tmp.innerText || "";
130
+ };
131
+
125
132
  export {
126
133
  filterImageText,
127
134
  splitCamelCase,
@@ -137,4 +144,5 @@ export {
137
144
  splitAndJoin,
138
145
  splitAndTrim,
139
146
  copyTextToClipboard,
147
+ stripHtml,
140
148
  };