@flozy/editor 3.5.0 → 3.5.2
Sign up to get free protection for your applications and to get access to all the features.
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;
|
@@ -31,7 +31,11 @@ const FormNumbers = props => {
|
|
31
31
|
component: "input",
|
32
32
|
...rest,
|
33
33
|
type: "number",
|
34
|
+
inputProps: {
|
35
|
+
min: 0
|
36
|
+
},
|
34
37
|
onChange: onChange,
|
38
|
+
onWheel: e => e.target.blur(),
|
35
39
|
sx: {
|
36
40
|
width: "100%",
|
37
41
|
border: `1px solid ${borderColor || "#FFF"}`,
|
@@ -46,9 +50,17 @@ const FormNumbers = props => {
|
|
46
50
|
},
|
47
51
|
borderStyle: borderStyle || "solid",
|
48
52
|
color: textColor || "#000",
|
49
|
-
background: bgColor || "transparent"
|
53
|
+
background: bgColor || "transparent",
|
54
|
+
'&::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
|
55
|
+
'-webkit-appearance': 'none',
|
56
|
+
margin: 0
|
57
|
+
},
|
58
|
+
'&[type=number]': {
|
59
|
+
'-moz-appearance': 'textfield' // Hide spin buttons for Firefox
|
60
|
+
}
|
50
61
|
}
|
51
62
|
})
|
52
63
|
});
|
53
64
|
};
|
65
|
+
|
54
66
|
export default FormNumbers;
|