@flozy/editor 10.9.2 → 10.9.3

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.
@@ -61,8 +61,8 @@ const EditorButton = props => {
61
61
  fontFamily,
62
62
  textColorHover,
63
63
  bgColorHover,
64
- borderColorHover,
65
64
  // buttonIcon,
65
+ borderColorHover,
66
66
  iconPosition = "start",
67
67
  borderStyle,
68
68
  borderWidth,
@@ -312,6 +312,12 @@ const useFreeGridStyles = ({
312
312
  "& .toolbtn.remove": {
313
313
  display: "none"
314
314
  }
315
+ },
316
+ "& .edt-headings": {
317
+ margin: "0px"
318
+ },
319
+ "& .edt-paragraphs": {
320
+ margin: "0px"
315
321
  }
316
322
  },
317
323
  "& .fgi_type_embedScript": {
@@ -13,7 +13,7 @@ import { Droppable } from "./Droppable";
13
13
  import { useDndContext } from "@dnd-kit/core";
14
14
  import { getNodeWithType } from "../../utils/helper";
15
15
  import { ResizeIcon } from "../../common/iconListV2";
16
- import { isEmptyTextNode } from "../../helper";
16
+ import { getTextColor, isEmptyTextNode } from "../../helper";
17
17
  import SimpleText from "../SimpleText";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -443,8 +443,10 @@ const TableCell = props => {
443
443
  };
444
444
  const showRowDragBtn = (showRowDrag || isRowDragging) && containerEle?.scrollLeft <= 0;
445
445
  const TableResizer = isMobile && hoverCol === column ? MobileResizer : Resizer;
446
+ const cellTextColor = entireTextColor || rowProps?.textColor || parentProps?.textColor;
447
+ const textStyles = cellTextColor ? getTextColor(cellTextColor) : "inherit";
446
448
  return /*#__PURE__*/_jsxs(_Fragment, {
447
- children: [/*#__PURE__*/_jsxs("td", {
449
+ children: [/*#__PURE__*/_jsxs(Box, {
448
450
  ...element.attr,
449
451
  ...attributes,
450
452
  className: `editor-table-cell ${hasSelected ? "selection" : ""}`,
@@ -455,14 +457,19 @@ const TableCell = props => {
455
457
  fontFamily: entireFontFamily || "inherit",
456
458
  fontWeight: entireFontWeight || "inherit",
457
459
  fontSize: entireTextSize || "inherit",
458
- color: entireTextColor || "inherit",
459
460
  cursor: "text",
460
461
  verticalAlign: "top",
461
462
  padding: "0px",
462
463
  ...(sizeProps || {})
463
464
  },
465
+ sx: {
466
+ '& span[data-slate-string="true"]': {
467
+ ...textStyles
468
+ }
469
+ },
464
470
  ...tbProps,
465
471
  "data-cell": path.toString(),
472
+ component: "td",
466
473
  children: [isFirstRow && currentDraggingType === "col" ? /*#__PURE__*/_jsx(Droppable, {
467
474
  ...dndProps,
468
475
  dragType: currentDraggingType,
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { Editor, Text } from "slate";
2
+ import { Text } from "slate";
3
3
  import { useSlate } from "slate-react";
4
- import { getNodeText } from "../../utils/helper";
4
+ import { getNodeText, getNodeWithType } from "../../utils/helper";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  const isEmptyTextNode = node => {
7
7
  if (Text.isText(node)) {
@@ -37,9 +37,8 @@ const useDetectExitFromTitle = (titleNode, onSaveTitle) => {
37
37
  if (!editor.selection) return;
38
38
 
39
39
  // Get the current node where the cursor is
40
- const [nodeEntry] = Editor.nodes(editor, {
41
- at: editor.selection,
42
- match: n => n.type === "title"
40
+ const [nodeEntry] = getNodeWithType(editor, "title", {
41
+ at: editor.selection
43
42
  });
44
43
  if (nodeEntry) {
45
44
  setWasInsideTitle(true); // User was inside the title
@@ -143,13 +143,13 @@ const PopupTool = props => {
143
143
  sx: classes.popupWrapper,
144
144
  placement: "top-start",
145
145
  style: {
146
- boxShadow: 'unset'
146
+ boxShadow: "unset"
147
147
  } //this is for overriding global shadow from popupwrapper used in other places
148
148
  ,
149
149
  children: /*#__PURE__*/_jsx(Paper, {
150
150
  sx: {
151
151
  border: `1px solid ${theme?.palette?.editor?.inputFieldBorder}`,
152
- boxShadow: '1px 2px 12px 0px #0000001F'
152
+ boxShadow: "1px 2px 12px 0px #0000001F"
153
153
  },
154
154
  children: /*#__PURE__*/_jsx(MiniTextFormat, {
155
155
  editor: editor,
@@ -435,12 +435,12 @@ export const getBlock = props => {
435
435
  const commonHeadingProps = () => ({
436
436
  ...attributes,
437
437
  ...element.attr,
438
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element`
438
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent`
439
439
  });
440
440
  const commonParaProps = paraType => ({
441
441
  ...attributes,
442
442
  ...element.attr,
443
- className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
443
+ className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent ${paraType}`
444
444
  });
445
445
  const breakpoint = getDevice(window.innerWidth);
446
446
  const lineH = element?.children[0]?.lineHeight;
@@ -448,49 +448,37 @@ export const getBlock = props => {
448
448
  switch (element.type) {
449
449
  case "headingOne":
450
450
  return /*#__PURE__*/_jsx("h1", {
451
- ...attributes,
452
- ...element.attr,
453
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
451
+ ...commonHeadingProps(),
454
452
  placeholder: translation("Heading 1"),
455
453
  children: children
456
454
  });
457
455
  case "headingTwo":
458
456
  return /*#__PURE__*/_jsx("h2", {
459
- ...attributes,
460
- ...element.attr,
461
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
457
+ ...commonHeadingProps(),
462
458
  placeholder: translation("Heading 2"),
463
459
  children: children
464
460
  });
465
461
  case "headingThree":
466
462
  return /*#__PURE__*/_jsx("h3", {
467
- ...attributes,
468
- ...element.attr,
469
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
463
+ ...commonHeadingProps(),
470
464
  placeholder: translation("Heading 3"),
471
465
  children: children
472
466
  });
473
467
  case "headingFour":
474
468
  return /*#__PURE__*/_jsx("h4", {
475
- ...attributes,
476
- ...element.attr,
477
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
469
+ ...commonHeadingProps(),
478
470
  placeholder: translation("Heading 4"),
479
471
  children: children
480
472
  });
481
473
  case "headingFive":
482
474
  return /*#__PURE__*/_jsx("h5", {
483
- ...attributes,
484
- ...element.attr,
485
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
475
+ ...commonHeadingProps(),
486
476
  placeholder: translation("Heading 5"),
487
477
  children: children
488
478
  });
489
479
  case "headingSix":
490
480
  return /*#__PURE__*/_jsx("h6", {
491
- ...attributes,
492
- ...element.attr,
493
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
481
+ ...commonHeadingProps(),
494
482
  placeholder: translation("Heading 6"),
495
483
  children: children
496
484
  });
@@ -923,48 +923,6 @@ export const getCurrentNodeText = editor => {
923
923
  console.log("Error:", error);
924
924
  }
925
925
  };
926
- function convertColorToRgb(color) {
927
- if (color?.startsWith("#")) {
928
- // HEX to RGB
929
- let hex = color.replace("#", "");
930
- let r, g, b;
931
- if (hex.length === 3) {
932
- hex = hex.split("").map(x => x + x).join("");
933
- }
934
- if (hex.length === 6) {
935
- [r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
936
- return `rgb(${r}, ${g}, ${b})`;
937
- }
938
- } else {
939
- return color;
940
- }
941
- }
942
- export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
943
- const colorVars = hideThemeColors ? null : theme?.vars?.colors;
944
- let selectedValue = selectedColor;
945
- if (colorVars) {
946
- const convertedColor = convertColorToRgb(selectedColor);
947
- Object.entries(theme.colors).forEach(([key, value]) => {
948
- const convertedThemeColor = convertColorToRgb(value);
949
- if (convertedThemeColor === convertedColor) {
950
- selectedValue = colorVars[key];
951
- }
952
- });
953
- }
954
- return selectedValue;
955
- };
956
- const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
957
- export const getSelectedElementColor = (editor, format, theme) => {
958
- const [isThemeText] = Editor.nodes(editor, {
959
- at: editor.selection,
960
- match: n => themeTextFormats.includes(n?.type)
961
- });
962
- if (!isThemeText) {
963
- return activeMark(editor, "color") || "#000000";
964
- }
965
- const color = getSelectedElementStyle(format, editor, format);
966
- return getSelectedColor(color, theme);
967
- };
968
926
  export const isHavingColor = color => {
969
927
  if (!color) {
970
928
  return false;
@@ -1059,4 +1017,46 @@ export const handleCopy = (event, editor) => {
1059
1017
  event.clipboardData?.setData("text/plain", text);
1060
1018
  event.clipboardData?.setData("application/x-slate-fragment", encodedFragment);
1061
1019
  };
1062
- export const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "blockquote"];
1020
+ export const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "blockquote"];
1021
+ function convertColorToRgb(color) {
1022
+ if (color?.startsWith("#")) {
1023
+ // HEX to RGB
1024
+ let hex = color.replace("#", "");
1025
+ let r, g, b;
1026
+ if (hex.length === 3) {
1027
+ hex = hex.split("").map(x => x + x).join("");
1028
+ }
1029
+ if (hex.length === 6) {
1030
+ [r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
1031
+ return `rgb(${r}, ${g}, ${b})`;
1032
+ }
1033
+ } else {
1034
+ return color;
1035
+ }
1036
+ }
1037
+ export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
1038
+ const colorVars = hideThemeColors ? null : theme?.vars?.colors;
1039
+ let selectedValue = selectedColor;
1040
+ if (colorVars) {
1041
+ const convertedColor = convertColorToRgb(selectedColor);
1042
+ Object.entries(theme.colors).forEach(([key, value]) => {
1043
+ const convertedThemeColor = convertColorToRgb(value);
1044
+ if (convertedThemeColor === convertedColor) {
1045
+ selectedValue = colorVars[key];
1046
+ }
1047
+ });
1048
+ }
1049
+ return selectedValue;
1050
+ };
1051
+ const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
1052
+ export const getSelectedElementColor = (editor, format, theme) => {
1053
+ const [isThemeText] = Editor.nodes(editor, {
1054
+ at: editor.selection,
1055
+ match: n => themeTextFormats.includes(n?.type)
1056
+ });
1057
+ if (!isThemeText) {
1058
+ return activeMark(editor, "color") || "#000000";
1059
+ }
1060
+ const color = getSelectedElementStyle(format, editor, format);
1061
+ return getSelectedColor(color, theme);
1062
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.9.2",
3
+ "version": "10.9.3",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"