@flozy/editor 3.5.1 → 3.5.2
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/dist/Editor/Editor.css
CHANGED
|
@@ -574,6 +574,16 @@ blockquote {
|
|
|
574
574
|
margin: auto;
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
+
.embed-code .element-toolbar {
|
|
578
|
+
left: 0;
|
|
579
|
+
right: 0;
|
|
580
|
+
bottom: 0;
|
|
581
|
+
top: 0;
|
|
582
|
+
width: fit-content;
|
|
583
|
+
height: fit-content;
|
|
584
|
+
margin: auto;
|
|
585
|
+
}
|
|
586
|
+
|
|
577
587
|
.resize-br {
|
|
578
588
|
position: absolute !important;
|
|
579
589
|
bottom: 2px;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from "react";
|
|
2
2
|
import sanitizeHtml from "sanitize-html";
|
|
3
3
|
import { allowedDomains, decodeString } from "../../utils/helper";
|
|
4
|
+
import { IconButton, Tooltip } from "@mui/material";
|
|
5
|
+
import { DeleteIcon } from "../../assets/svg/AIIcons";
|
|
6
|
+
import { ReactEditor, useSlateStatic } from "slate-react";
|
|
7
|
+
import { Transforms } from "slate";
|
|
4
8
|
|
|
5
9
|
// const sanitize = (input) => {
|
|
6
10
|
// const doc = new DOMParser().parseFromString(input, "text/html");
|
|
@@ -21,18 +25,45 @@ const getCode = (embedData, isEncoded) => {
|
|
|
21
25
|
}
|
|
22
26
|
return embedData;
|
|
23
27
|
};
|
|
28
|
+
const ToolBar = ({
|
|
29
|
+
onDelete
|
|
30
|
+
}) => {
|
|
31
|
+
return /*#__PURE__*/_jsx("div", {
|
|
32
|
+
className: "element-toolbar visible-on-hover",
|
|
33
|
+
contentEditable: false,
|
|
34
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
35
|
+
title: "Delete",
|
|
36
|
+
arrow: true,
|
|
37
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
38
|
+
onClick: onDelete,
|
|
39
|
+
children: /*#__PURE__*/_jsx(DeleteIcon, {})
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
};
|
|
24
44
|
const Code = props => {
|
|
25
45
|
const codeRef = useRef();
|
|
26
46
|
const {
|
|
27
47
|
element,
|
|
28
48
|
attributes,
|
|
29
|
-
children
|
|
49
|
+
children,
|
|
50
|
+
customProps
|
|
30
51
|
} = props;
|
|
31
52
|
const {
|
|
32
53
|
embedData,
|
|
33
54
|
isEncoded,
|
|
34
55
|
isSanitized
|
|
35
56
|
} = element;
|
|
57
|
+
const {
|
|
58
|
+
readOnly
|
|
59
|
+
} = customProps;
|
|
60
|
+
const editor = useSlateStatic();
|
|
61
|
+
const path = ReactEditor.findPath(editor, element);
|
|
62
|
+
const onDelete = () => {
|
|
63
|
+
Transforms.removeNodes(editor, {
|
|
64
|
+
at: path
|
|
65
|
+
});
|
|
66
|
+
};
|
|
36
67
|
useEffect(() => {
|
|
37
68
|
if (codeRef?.current) {
|
|
38
69
|
const code = getCode(embedData, isEncoded);
|
|
@@ -50,12 +81,14 @@ const Code = props => {
|
|
|
50
81
|
}
|
|
51
82
|
}, []);
|
|
52
83
|
return /*#__PURE__*/_jsxs("div", {
|
|
84
|
+
className: "embed-code has-hover",
|
|
53
85
|
contentEditable: false,
|
|
54
|
-
className: `embed-code`,
|
|
55
86
|
...attributes,
|
|
56
87
|
children: [/*#__PURE__*/_jsx("div", {
|
|
57
88
|
ref: codeRef
|
|
58
|
-
}), children
|
|
89
|
+
}), children, !readOnly && /*#__PURE__*/_jsx(ToolBar, {
|
|
90
|
+
onDelete: onDelete
|
|
91
|
+
})]
|
|
59
92
|
});
|
|
60
93
|
};
|
|
61
94
|
export default Code;
|