@flozy/editor 3.4.5 → 3.4.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useEffect, useRef } from "react";
|
2
2
|
import sanitizeHtml from "sanitize-html";
|
3
|
-
import { allowedDomains } from "../../utils/helper";
|
3
|
+
import { allowedDomains, decodeString } from "../../utils/helper";
|
4
4
|
|
5
5
|
// const sanitize = (input) => {
|
6
6
|
// const doc = new DOMParser().parseFromString(input, "text/html");
|
@@ -23,11 +23,12 @@ const Code = props => {
|
|
23
23
|
children
|
24
24
|
} = props;
|
25
25
|
const {
|
26
|
-
embedData
|
26
|
+
embedData,
|
27
|
+
isEncoded
|
27
28
|
} = element;
|
28
29
|
useEffect(() => {
|
29
30
|
if (codeRef?.current) {
|
30
|
-
const clean = sanitizeHtml(embedData, {
|
31
|
+
const clean = sanitizeHtml(isEncoded ? decodeString(embedData) : embedData, {
|
31
32
|
allowedTags: false,
|
32
33
|
// Allow all tags
|
33
34
|
allowedAttributes: false,
|
@@ -1,12 +1,15 @@
|
|
1
1
|
import { Transforms } from "slate";
|
2
2
|
import insertNewLine from "./insertNewLine";
|
3
|
+
import { encodeString } from "./helper";
|
3
4
|
export const createEmbedScript = embedData => ({
|
4
5
|
type: "embedScript",
|
5
|
-
embedData: embedData,
|
6
|
+
embedData: encodeString(embedData),
|
6
7
|
children: [{
|
7
8
|
text: " "
|
8
|
-
}]
|
9
|
+
}],
|
10
|
+
isEncoded: true // to handle the old code's that already inserted
|
9
11
|
});
|
12
|
+
|
10
13
|
export const insertEmbedScript = (editor, embedData) => {
|
11
14
|
try {
|
12
15
|
const embed = createEmbedScript(embedData);
|
@@ -321,4 +321,22 @@ export const getLinkType = (linkType, url) => {
|
|
321
321
|
}
|
322
322
|
return linkType;
|
323
323
|
};
|
324
|
-
export const allowedDomains = ["youtube.com", "lemcal.com", "facebook.com", "calendly.com"];
|
324
|
+
export const allowedDomains = ["youtube.com", "lemcal.com", "facebook.com", "calendly.com"];
|
325
|
+
export const encodeString = str => {
|
326
|
+
try {
|
327
|
+
if (str) {
|
328
|
+
return btoa(str);
|
329
|
+
}
|
330
|
+
} catch (err) {
|
331
|
+
console.log(err);
|
332
|
+
}
|
333
|
+
};
|
334
|
+
export const decodeString = str => {
|
335
|
+
try {
|
336
|
+
if (str) {
|
337
|
+
return atob(str);
|
338
|
+
}
|
339
|
+
} catch (err) {
|
340
|
+
console.log(err);
|
341
|
+
}
|
342
|
+
};
|