@griddo/ax 1.75.162 → 1.75.164
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": "1.75.
|
|
4
|
+
"version": "1.75.164",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -86,15 +86,14 @@
|
|
|
86
86
|
"date-fns": "^2.21.3",
|
|
87
87
|
"dotenv": "6.2.0",
|
|
88
88
|
"dotenv-expand": "5.1.0",
|
|
89
|
+
"draft-convert": "^2.1.13",
|
|
89
90
|
"draft-js": "^0.11.7",
|
|
90
91
|
"draft-js-import-html": "^1.4.1",
|
|
91
|
-
"draftjs-to-html": "^0.9.1",
|
|
92
92
|
"enhanced-resolve": "^5.8.2",
|
|
93
93
|
"env-cmd": "^10.1.0",
|
|
94
94
|
"file-loader": "^6.2.0",
|
|
95
95
|
"find-up": "^5.0.0",
|
|
96
96
|
"fs-extra": "7.0.1",
|
|
97
|
-
"html-to-draftjs": "^1.5.0",
|
|
98
97
|
"html-to-image": "^1.9.0",
|
|
99
98
|
"html-webpack-plugin": "4.5.0",
|
|
100
99
|
"identity-obj-proxy": "3.0.0",
|
|
@@ -233,5 +232,5 @@
|
|
|
233
232
|
"publishConfig": {
|
|
234
233
|
"access": "public"
|
|
235
234
|
},
|
|
236
|
-
"gitHead": "
|
|
235
|
+
"gitHead": "3c0a6d18ce34990a17549ad4f67d17e461eef3b0"
|
|
237
236
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useState, useEffect, memo, useRef } from "react";
|
|
2
2
|
import { Editor } from "react-draft-wysiwyg";
|
|
3
|
-
import { EditorState, convertFromRaw, convertToRaw
|
|
3
|
+
import { EditorState, convertFromRaw, convertToRaw } from "draft-js";
|
|
4
4
|
import { markdownToDraft, draftToMarkdown } from "markdown-draft-js";
|
|
5
|
-
import
|
|
6
|
-
import htmlToDraft from "html-to-draftjs";
|
|
5
|
+
import { convertFromHTML, convertToHTML } from "draft-convert";
|
|
7
6
|
import { stateFromHTML } from "draft-js-import-html";
|
|
7
|
+
import { formatIframe } from "./utils";
|
|
8
8
|
import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
|
|
9
9
|
|
|
10
10
|
import * as S from "./style";
|
|
@@ -12,17 +12,17 @@ import * as S from "./style";
|
|
|
12
12
|
const RichText = (props: IRichTextProps): JSX.Element => {
|
|
13
13
|
const { value, error, placeholder, onChange, disabled, editorID, handleValidation, html = false, delayed } = props;
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
15
|
+
const valueUnformatted = formatIframe(value, true);
|
|
16
|
+
|
|
17
|
+
const rawData = html ? convertFromHTML(valueUnformatted || "") : markdownToDraft(value);
|
|
18
|
+
const contentState = html ? rawData : convertFromRaw(rawData);
|
|
18
19
|
|
|
19
20
|
const [editorState, setEditorState] = useState(() => EditorState.createWithContent(contentState));
|
|
20
21
|
const timeOutRef = useRef<ReturnType<typeof setTimeout>>();
|
|
21
22
|
|
|
22
23
|
useEffect(() => {
|
|
23
|
-
const rawData = html ?
|
|
24
|
-
const
|
|
25
|
-
const contentState = html ? ContentState.createFromBlockArray(contentBlocks, entityMap) : convertFromRaw(rawData);
|
|
24
|
+
const rawData = html ? convertFromHTML(valueUnformatted || "") : markdownToDraft(value);
|
|
25
|
+
const contentState = html ? rawData : convertFromRaw(rawData);
|
|
26
26
|
setEditorState(EditorState.createWithContent(contentState));
|
|
27
27
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
28
|
}, [editorID]);
|
|
@@ -47,7 +47,8 @@ const RichText = (props: IRichTextProps): JSX.Element => {
|
|
|
47
47
|
const plainContent = content.getPlainText();
|
|
48
48
|
const rawObject = convertToRaw(content);
|
|
49
49
|
const markdownString =
|
|
50
|
-
plainContent === "" ? plainContent : html ?
|
|
50
|
+
plainContent === "" ? plainContent : html ? formatIframe(convertToHTML(content)) : draftToMarkdown(rawObject);
|
|
51
|
+
|
|
51
52
|
onChange(markdownString);
|
|
52
53
|
error && handleValidation && handleValidation(plainContent);
|
|
53
54
|
};
|
|
@@ -56,7 +57,8 @@ const RichText = (props: IRichTextProps): JSX.Element => {
|
|
|
56
57
|
const content = stateFromHTML(pastedValue);
|
|
57
58
|
setEditorState(() => EditorState.createWithContent(content));
|
|
58
59
|
const rawObject = convertToRaw(content);
|
|
59
|
-
const markdownString = html ?
|
|
60
|
+
const markdownString = html ? formatIframe(convertToHTML(content)) : draftToMarkdown(rawObject);
|
|
61
|
+
|
|
60
62
|
onChange(markdownString);
|
|
61
63
|
return false;
|
|
62
64
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const formatIframe = (iframeToFormat: string, firstConversion?: boolean) => {
|
|
2
|
+
let iframeFormatted = iframeToFormat;
|
|
3
|
+
if (firstConversion) {
|
|
4
|
+
if (iframeFormatted.match(/<iframe[^>]*?(?:\/>|>[^<]*?<\/iframe>)/g)) {
|
|
5
|
+
iframeFormatted = iframeToFormat.replaceAll("<iframe", "<iframe");
|
|
6
|
+
iframeFormatted = iframeFormatted.replaceAll("></iframe>", "></iframe>");
|
|
7
|
+
}
|
|
8
|
+
} else {
|
|
9
|
+
if (iframeToFormat.match(/(?:<iframe[^>]*)/g)) {
|
|
10
|
+
iframeFormatted = iframeToFormat.replaceAll("<iframe", "<iframe");
|
|
11
|
+
iframeFormatted = iframeFormatted.replaceAll("></iframe>", "></iframe>");
|
|
12
|
+
iframeFormatted = iframeFormatted.replace(/"/g, '"');
|
|
13
|
+
iframeFormatted = iframeFormatted.replace(/&/g, "&");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return iframeFormatted;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { formatIframe };
|
package/src/global.d.ts
CHANGED