@flozy/editor 9.2.9 → 9.3.0

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.
@@ -14,6 +14,7 @@ import Shorthands from "./common/Shorthands";
14
14
  import usePopupStyle from "./Toolbar/PopupTool/PopupToolStyle";
15
15
  import { EditorProvider } from "./hooks/useMouseMove";
16
16
  import decorators from "./utils/Decorators";
17
+ import convertMDToHTML from "./helper/markdown";
17
18
  import { useDebouncedCallback } from "use-debounce";
18
19
  import { jsx as _jsx } from "react/jsx-runtime";
19
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -31,7 +32,9 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
31
32
  onBlur = () => {},
32
33
  isMobile = false,
33
34
  debounceTimeOut = 10,
34
- translation
35
+ translation,
36
+ isMarkDown = false,
37
+ markDownContent = ''
35
38
  } = props;
36
39
  const classes = usePopupStyle(theme);
37
40
  const convertedContent = draftToSlate({
@@ -42,8 +45,7 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
42
45
  }]
43
46
  }]
44
47
  });
45
- const [value] = useState(convertedContent);
46
- const debouncedValue = useRef(value);
48
+ const debouncedValue = useRef(convertedContent);
47
49
  const debounced = useDebouncedCallback(
48
50
  // function
49
51
  value => {
@@ -276,7 +278,8 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
276
278
  }
277
279
  };
278
280
 
279
- return /*#__PURE__*/_jsx(EditorProvider, {
281
+ const html = isMarkDown ? convertMDToHTML(markDownContent) : null;
282
+ return !isMarkDown ? /*#__PURE__*/_jsx(EditorProvider, {
280
283
  theme: theme,
281
284
  editor: editor,
282
285
  children: /*#__PURE__*/_jsxs(Slate, {
@@ -312,6 +315,14 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
312
315
  customProps: customProps
313
316
  }) : null]
314
317
  }, id)
318
+ }) : /*#__PURE__*/_jsx("div", {
319
+ ref: debouncedValue,
320
+ dangerouslySetInnerHTML: {
321
+ __html: html || ""
322
+ },
323
+ style: {
324
+ overflow: "hidden"
325
+ }
315
326
  });
316
327
  });
317
328
  ChatEditor.displayName = "ChatEditor";
@@ -378,7 +378,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
378
378
  translation: translationFn,
379
379
  getTitleSaveData
380
380
  };
381
- const lineH = getBreakpointLineSpacing(lineHeight, breakpoint);
381
+ const lineH = getBreakpointLineSpacing(lineHeight, breakpoint || (isMobile ? "xs" : ""));
382
382
  const renderElement = useCallback(props => {
383
383
  return /*#__PURE__*/_jsx(Element, {
384
384
  ...props,
@@ -33,17 +33,15 @@ const ToolTableComponent = props => {
33
33
  const {
34
34
  updateTableSelection
35
35
  } = useTable();
36
- return /*#__PURE__*/_jsx("div", {
37
- children: /*#__PURE__*/_jsx(TableTool, {
38
- theme: editorTheme,
39
- handleToolAction: (type, option) => {
40
- handleAction(type, option);
41
- if (type === "duplicate") {
42
- updateTableSelection(getDefaultTableSelection());
43
- }
44
- },
45
- translation: translation
46
- })
36
+ return /*#__PURE__*/_jsx(TableTool, {
37
+ theme: editorTheme,
38
+ handleToolAction: (type, option) => {
39
+ handleAction(type, option);
40
+ if (type === "duplicate") {
41
+ updateTableSelection(getDefaultTableSelection());
42
+ }
43
+ },
44
+ translation: translation
47
45
  });
48
46
  };
49
47
  const MoreTableSettings = props => {
@@ -135,6 +133,7 @@ const ToolBar = props => {
135
133
  arrow: true,
136
134
  onClick: () => handleAction("delete"),
137
135
  children: /*#__PURE__*/_jsx(IconButton, {
136
+ className: "editor-deleteicon",
138
137
  children: /*#__PURE__*/_jsx(DeleteIcon, {})
139
138
  })
140
139
  })
@@ -16,7 +16,7 @@ import SelectSuperSubscript from "./MiniTextFormat/SelectSuperSubscript";
16
16
  import { ColorResetIcon, TextDefaultStyleIcon } from "../../common/iconListV2";
17
17
  import FontFamilyAutocomplete from "../FormatTools/FontFamilyAutocomplete";
18
18
  import { useEditorContext } from "../../hooks/useMouseMove";
19
- // import LineSpacing from "../../common/StyleBuilder/fieldTypes/lineSpacing";
19
+ import LineSpacing from "../../common/StyleBuilder/fieldTypes/lineSpacing";
20
20
  import { getPageSettings } from "../../utils/pageSettings";
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -38,15 +38,18 @@ const TextFormat = props => {
38
38
  const {
39
39
  translation
40
40
  } = customProps;
41
-
42
- // const { element: pageSt } = getPageSettings(editor) || {};
43
- // const pageSettingLine = pageSt?.pageProps?.lineHeight;
41
+ const {
42
+ element: pageSt
43
+ } = getPageSettings(editor) || {};
44
+ const pageSettingLine = pageSt?.pageProps?.lineHeight;
44
45
  const {
45
46
  fontFamilies,
46
47
  theme: appTheme
47
48
  } = useEditorContext();
48
- // const { activeBreakPoint } = useEditorContext();
49
- // const breakpoint = activeBreakPoint === "" ? "lg" : activeBreakPoint;
49
+ const {
50
+ activeBreakPoint
51
+ } = useEditorContext();
52
+ const breakpoint = activeBreakPoint === "" ? "lg" : activeBreakPoint;
50
53
  const fontWeight = allTools.find(f => f.format === "fontWeight");
51
54
  const fontStyle = allTools.filter(f => f.type === "mark" && f.format !== "strikethrough" && f.format !== "superscript" && f.format !== "subscript");
52
55
  const fontAlign = allTools.filter(f => f.format?.indexOf("align") >= 0);
@@ -68,12 +71,8 @@ const TextFormat = props => {
68
71
  updateTheme
69
72
  } = useEditorTheme();
70
73
  const customized = isTextCustomized(editor);
71
-
72
- // let lineSpacingValue = activeMark(editor, "lineHeight");
73
- // lineSpacingValue =
74
- // lineSpacingValue?.[breakpoint] !== undefined
75
- // ? lineSpacingValue
76
- // : pageSettingLine;
74
+ let lineSpacingValue = activeMark(editor, "lineHeight");
75
+ lineSpacingValue = lineSpacingValue?.[breakpoint] !== undefined ? lineSpacingValue : pageSettingLine;
77
76
  const handleColorPicker = type => e => {
78
77
  setType(type);
79
78
  setAnchorEl(e.currentTarget);
@@ -114,11 +113,13 @@ const TextFormat = props => {
114
113
  value
115
114
  });
116
115
  };
117
-
118
- // const handleLineSpacing = (data) => {
119
- // const [[format, value]] = Object.entries(data);
120
- // addMarkData(editor, { format, value });
121
- // };
116
+ const handleLineSpacing = data => {
117
+ const [[format, value]] = Object.entries(data);
118
+ addMarkData(editor, {
119
+ format,
120
+ value
121
+ });
122
+ };
122
123
  return /*#__PURE__*/_jsxs(Grid, {
123
124
  container: true,
124
125
  sx: classes.textFormatWrapper,
@@ -433,6 +434,32 @@ const TextFormat = props => {
433
434
  xs: 12,
434
435
  sx: classes.dividerGrid,
435
436
  children: /*#__PURE__*/_jsx(Divider, {})
437
+ }), /*#__PURE__*/_jsxs(Grid, {
438
+ item: true,
439
+ xs: 12,
440
+ children: [/*#__PURE__*/_jsx(Typography, {
441
+ variant: "body1",
442
+ color: "primary",
443
+ sx: classes.typoLabel,
444
+ children: "Line Spacing"
445
+ }), /*#__PURE__*/_jsx(Grid, {
446
+ item: true,
447
+ xs: 12,
448
+ className: "typo-icons",
449
+ sx: classes.evenSpace,
450
+ children: /*#__PURE__*/_jsx(LineSpacing, {
451
+ value: lineSpacingValue,
452
+ onChange: handleLineSpacing,
453
+ data: {
454
+ key: "lineHeight"
455
+ }
456
+ })
457
+ })]
458
+ }), /*#__PURE__*/_jsx(Grid, {
459
+ item: true,
460
+ xs: 12,
461
+ sx: classes.dividerGrid,
462
+ children: /*#__PURE__*/_jsx(Divider, {})
436
463
  }), /*#__PURE__*/_jsx(Grid, {
437
464
  item: true,
438
465
  xs: 12,
@@ -25,13 +25,11 @@ const pageSettingsStyle = [{
25
25
  label: "Padding",
26
26
  key: "bannerSpacing",
27
27
  type: "bannerSpacing"
28
- }
29
- // {
30
- // label: "Line Spacing",
31
- // key: "lineHeight",
32
- // type: "lineSpacing",
33
- // },
34
- ]
28
+ }, {
29
+ label: "Line Spacing",
30
+ key: "lineHeight",
31
+ type: "lineSpacing"
32
+ }]
35
33
  }, {
36
34
  tab: "Max Width",
37
35
  value: "maxWidth",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.2.9",
3
+ "version": "9.3.0",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"