@flozy/editor 10.3.7 → 10.3.8

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.
@@ -1,5 +1,5 @@
1
- import React, { useState } from "react";
2
- import { Transforms } from "slate";
1
+ import React, { useEffect, useState } from "react";
2
+ import { Editor, Range, Transforms } from "slate";
3
3
  import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
4
4
  import AccordionBtnPopup from "./AccordionBtnPopup";
5
5
  import { IconButton, Tooltip, Box } from "@mui/material";
@@ -94,6 +94,20 @@ const Accordion = props => {
94
94
  theme
95
95
  } = useEditorContext();
96
96
  const classes = useCommonStyle(theme);
97
+ useEffect(() => {
98
+ if (!editor.selection || !children[1]) return;
99
+ try {
100
+ const accordionDetailsElement = element.children?.[1];
101
+ const detailsPath = ReactEditor.findPath(editor, accordionDetailsElement);
102
+ const detailsRange = Editor.range(editor, detailsPath);
103
+ const isInside = Range.intersection(detailsRange, editor.selection);
104
+ if (isInside && !toggle) {
105
+ setToggle(true);
106
+ }
107
+ } catch (e) {
108
+ console.error(e);
109
+ }
110
+ }, [editor.selection, children]);
97
111
  const onToggle = () => {
98
112
  setToggle(!toggle);
99
113
  };
@@ -29,6 +29,18 @@ import { useFreeGrid } from "../../Elements/FreeGrid/FreeGrid";
29
29
  import { jsx as _jsx } from "react/jsx-runtime";
30
30
  import { jsxs as _jsxs } from "react/jsx-runtime";
31
31
  import { Fragment as _Fragment } from "react/jsx-runtime";
32
+ function getTextElementHeight(textElement) {
33
+ let totalHeight = 0;
34
+ if (textElement) {
35
+ textElement.childNodes.forEach(node => {
36
+ if (node.textContent.trim()) {
37
+ const el = node;
38
+ totalHeight += el.offsetHeight || el.getBoundingClientRect().height;
39
+ }
40
+ });
41
+ }
42
+ return totalHeight;
43
+ }
32
44
  const ITEM_TYPES = ["child", "parent-container"];
33
45
  const EDIT_MODES = ["text", "form", "table"];
34
46
  const DISABLE_RESIZING = {
@@ -143,12 +155,11 @@ const RnD = props => {
143
155
  }
144
156
  }
145
157
  const currElement = getCurrentEle();
146
- const textElement = currElement?.querySelector(".fgi_type_text > .simple-text, .fgi_type_text");
158
+ const textElement = currElement?.querySelector(".fgi_type_text");
147
159
  if (breakpoint && textElement && childType === "text" && !enable) {
148
160
  timerId.current = setTimeout(() => {
149
- const {
150
- clientHeight
151
- } = textElement;
161
+ // const { clientHeight } = textElement;
162
+ const clientHeight = getTextElementHeight(textElement);
152
163
  const {
153
164
  height
154
165
  } = delta || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.3.7",
3
+ "version": "10.3.8",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"