@flozy/editor 3.4.5 → 3.4.6

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.
@@ -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,
@@ -132,7 +132,8 @@ const Form = props => {
132
132
  fieldKey: pair[0],
133
133
  [pair[0]]: pair[1],
134
134
  placeholder: placeholder,
135
- form_name: formName
135
+ form_name: formName,
136
+ tagName: tagName
136
137
  });
137
138
  }
138
139
  let params = {
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "3.4.5",
3
+ "version": "3.4.6",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"