@flozy/editor 10.2.6 → 10.2.7

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.
@@ -17,7 +17,7 @@ const IMAGE_SLECTOR_OPTIONS = {
17
17
  };
18
18
  const TAB_SHOW = {
19
19
  Image: ["upload", "choose", "addLink"],
20
- Video: ["addLink"],
20
+ Video: ["upload", "addLink"],
21
21
  Embed: ["addLink"],
22
22
  Document: ["addLink", "upload"]
23
23
  };
@@ -35,7 +35,7 @@ const ImageSelector = props => {
35
35
  customProps
36
36
  } = props;
37
37
  const translation = customProps?.translation;
38
- const [tabValue, setTabValue] = useState(title === "Image" ? "choose" : "addLink");
38
+ const [tabValue, setTabValue] = useState(title === "Image" ? "choose" : "Video" ? "upload" : "addLink");
39
39
  const [image, setImage] = useState(value || "");
40
40
  const handleTabChange = (e, newValue) => {
41
41
  setImage("");
@@ -6,6 +6,10 @@ const embedVideoStyle = [{
6
6
  label: "URL",
7
7
  key: "url",
8
8
  type: "text"
9
+ }, {
10
+ label: "File",
11
+ key: "url",
12
+ type: "embedUpload"
9
13
  }]
10
14
  }, {
11
15
  tab: "Aspect Ratio",
@@ -0,0 +1,115 @@
1
+ import React, { useState } from "react";
2
+ import { Grid, Button, Typography } from "@mui/material";
3
+ import ImageSelector from "../../ImageSelector/ImageSelector";
4
+ import UploadStyles from "../../ImageSelector/UploadStyles";
5
+ import Icon from "../../Icon";
6
+ import { useEditorContext } from "../../../hooks/useMouseMove";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ const EmbedUpload = props => {
10
+ const {
11
+ value,
12
+ data,
13
+ customProps,
14
+ onChange
15
+ } = props;
16
+ const {
17
+ translation
18
+ } = customProps;
19
+ const {
20
+ key
21
+ } = data;
22
+ const [base64, setBase64] = useState(value);
23
+ const [open, setOpen] = useState(false);
24
+ const {
25
+ theme
26
+ } = useEditorContext();
27
+ const classes = UploadStyles(theme);
28
+ const onRemoveBG = () => {
29
+ setBase64(null);
30
+ onChange({
31
+ [key]: "none"
32
+ });
33
+ };
34
+ const handleClick = () => {
35
+ setOpen(true);
36
+ };
37
+ const handleClose = () => {
38
+ setOpen(false);
39
+ };
40
+ const onSelectImage = img => {
41
+ setBase64(img);
42
+ onChange({
43
+ [key]: img
44
+ });
45
+ handleClose();
46
+ };
47
+ return /*#__PURE__*/_jsxs(Grid, {
48
+ item: true,
49
+ xs: 12,
50
+ children: [/*#__PURE__*/_jsx(Typography, {
51
+ variant: "body1",
52
+ color: "primary",
53
+ sx: {
54
+ fontSize: "14px",
55
+ fontWeight: "500",
56
+ marginBottom: "8px"
57
+ },
58
+ children: translation("Upload Video")
59
+ }), /*#__PURE__*/_jsx(Grid, {
60
+ container: true,
61
+ sx: classes.uploadContainer,
62
+ children: /*#__PURE__*/_jsx(Grid, {
63
+ item: true,
64
+ xs: 12,
65
+ sx: classes.uploadField,
66
+ children: /*#__PURE__*/_jsx(Grid, {
67
+ className: "uploadImageSection",
68
+ children: base64 ? /*#__PURE__*/_jsxs(Grid, {
69
+ justifyItems: "center",
70
+ alignItems: "center",
71
+ children: [/*#__PURE__*/_jsx(Typography, {
72
+ style: {
73
+ padding: "8px",
74
+ fontSize: "8px",
75
+ color: theme?.palette?.editor?.textColor,
76
+ textAlign: "center"
77
+ },
78
+ children: base64
79
+ }), /*#__PURE__*/_jsx(Grid, {
80
+ className: "removeImageText",
81
+ onClick: onRemoveBG,
82
+ children: translation("REMOVE")
83
+ })]
84
+ }) : /*#__PURE__*/_jsx(Grid, {
85
+ className: "uploadImageText",
86
+ children: /*#__PURE__*/_jsxs(Button, {
87
+ component: "label",
88
+ variant: "text",
89
+ style: {
90
+ background: "none"
91
+ },
92
+ onClick: handleClick,
93
+ sx: classes.uploadIcon,
94
+ children: [/*#__PURE__*/_jsx(Icon, {
95
+ icon: "fileUpload"
96
+ }), /*#__PURE__*/_jsx("span", {
97
+ style: {
98
+ paddingLeft: "8px"
99
+ },
100
+ children: translation("Upload a Video")
101
+ })]
102
+ })
103
+ })
104
+ })
105
+ })
106
+ }), /*#__PURE__*/_jsx(ImageSelector, {
107
+ open: open,
108
+ title: "Video",
109
+ onClose: handleClose,
110
+ customProps: customProps,
111
+ onSelectImage: onSelectImage
112
+ })]
113
+ });
114
+ };
115
+ export default EmbedUpload;
@@ -19,6 +19,7 @@ import SelectSwitch from "./selectSwitch";
19
19
  import CardsMapping from "./card";
20
20
  import MetaDataMapping from "./metaDataMapping";
21
21
  import LineSpacing from "./lineSpacing";
22
+ import EmbedUpload from "./embedUpload";
22
23
  const FieldMap = {
23
24
  text: Text,
24
25
  bannerSpacing: BannerSpacing,
@@ -40,6 +41,7 @@ const FieldMap = {
40
41
  selectSwitch: SelectSwitch,
41
42
  card: CardsMapping,
42
43
  metadatamapping: MetaDataMapping,
43
- lineSpacing: LineSpacing
44
+ lineSpacing: LineSpacing,
45
+ embedUpload: EmbedUpload
44
46
  };
45
47
  export default FieldMap;
@@ -22,6 +22,12 @@ const Uploader = props => {
22
22
  const {
23
23
  theme
24
24
  } = useEditorContext();
25
+ const allowedFormat = {
26
+ "Document": ".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.rtf",
27
+ "Image": "image/*",
28
+ "Video": "video/*",
29
+ "Embed": "*"
30
+ };
25
31
  const handleChange = async e => {
26
32
  const uFile = e.target.files[0];
27
33
  const strImage = await convertBase64(uFile);
@@ -63,6 +69,7 @@ const Uploader = props => {
63
69
  const renderThumb = () => {
64
70
  switch (title) {
65
71
  case "Document":
72
+ case "Video":
66
73
  return /*#__PURE__*/_jsxs(_Fragment, {
67
74
  children: [/*#__PURE__*/_jsx(Typography, {
68
75
  style: {
@@ -120,6 +127,7 @@ const Uploader = props => {
120
127
  sx: classes.uploadIcon,
121
128
  children: [/*#__PURE__*/_jsx("input", {
122
129
  type: "file",
130
+ accept: allowedFormat[title],
123
131
  style: {
124
132
  opacity: 0,
125
133
  width: "0px"
@@ -72,11 +72,9 @@ const ThemeSettings = props => {
72
72
  });
73
73
  const currentSelectedTheme = result?.data?.find(d => d.id === id);
74
74
  const currThemeName = currentSelectedTheme?.name;
75
- if (currThemeName && currThemeName !== name) {
75
+ if (currentSelectedTheme) {
76
76
  // for theme templates created by design team
77
- updateTheme({
78
- name: currThemeName
79
- });
77
+ updateTheme(currentSelectedTheme);
80
78
  }
81
79
  setThemes(result?.data || []);
82
80
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.2.6",
3
+ "version": "10.2.7",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"