@flozy/editor 10.5.9 → 10.6.1

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.
@@ -92,3 +92,7 @@
92
92
  border-width: 1px 0 0;
93
93
  border-color: rgba(55, 53, 47, .1607843137254902);
94
94
  }
95
+
96
+ .disablePointerEvent {
97
+ pointer-events: none;
98
+ }
@@ -3,7 +3,6 @@ import { Editor, Text } from "slate";
3
3
  import { useSlate } from "slate-react";
4
4
  import { getNodeText } from "../../utils/helper";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
- import { jsxs as _jsxs } from "react/jsx-runtime";
7
6
  const isEmptyTextNode = node => {
8
7
  if (Text.isText(node)) {
9
8
  return !node.text.trim();
@@ -19,7 +18,7 @@ const Title = props => {
19
18
  } = props;
20
19
  const isEmpty = !customProps?.readOnly && isEmptyTextNode(element?.children[0]) ? "empty" : "";
21
20
  useDetectExitFromTitle(element, customProps?.getTitleSaveData);
22
- return /*#__PURE__*/_jsxs("div", {
21
+ return /*#__PURE__*/_jsx("div", {
23
22
  ...attributes,
24
23
  placeholder: "Title",
25
24
  className: `content-editable ${isEmpty}`,
@@ -27,9 +26,7 @@ const Title = props => {
27
26
  fontWeight: "bold",
28
27
  fontSize: "20px"
29
28
  },
30
- children: [children, /*#__PURE__*/_jsx("span", {
31
- contentEditable: false
32
- })]
29
+ children: children
33
30
  });
34
31
  };
35
32
  export default Title;
@@ -164,7 +164,10 @@ export default function LinkSettings(props) {
164
164
  setNav(navOption);
165
165
  setNavValue("");
166
166
  },
167
- translation: translation
167
+ translation: translation,
168
+ radioProps: {
169
+ disableRipple: true
170
+ }
168
171
  })
169
172
  })
170
173
  }), /*#__PURE__*/_jsx(Grid, {
@@ -124,14 +124,39 @@ const isOverLapLine = ({
124
124
  export function getClosestDraggable(x, y, className, activeClassName) {
125
125
  const draggables = document.querySelectorAll(className);
126
126
  const activeDragEle = document.querySelectorAll(activeClassName)[0];
127
+ const container = document.querySelector("#slate-wrapper-scroll-container");
128
+ if (!activeDragEle || !container) return [];
129
+ const containerRect = container.getBoundingClientRect();
127
130
  const {
128
131
  left: aLeft,
129
132
  top: aTop,
130
133
  width: aWidth,
131
134
  height: aHeight
132
135
  } = activeDragEle?.getBoundingClientRect() || {};
133
- let lines = [];
136
+ const lines = [];
137
+ const clampLine = ({
138
+ x,
139
+ y,
140
+ width,
141
+ height
142
+ }) => {
143
+ if (width > 1) {
144
+ if (x < containerRect.left) x = containerRect.left;
145
+ if (x + width > containerRect.right) width = containerRect.right - x;
146
+ }
147
+ if (height > 1) {
148
+ if (y < containerRect.top) y = containerRect.top;
149
+ if (y + height > containerRect.bottom) height = containerRect.bottom - y;
150
+ }
151
+ return {
152
+ x,
153
+ y,
154
+ width,
155
+ height
156
+ };
157
+ };
134
158
  draggables.forEach(draggable => {
159
+ if (draggable === activeDragEle) return;
135
160
  const {
136
161
  left,
137
162
  top,
@@ -148,42 +173,45 @@ export function getClosestDraggable(x, y, className, activeClassName) {
148
173
  x: xVal,
149
174
  y: yVal
150
175
  }, lines)) {
151
- lines.push({
152
- y: top,
176
+ const line = {
153
177
  x: xVal,
178
+ y: yVal,
154
179
  width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
155
180
  height: 1
156
- });
181
+ };
182
+ lines.push(clampLine(line));
157
183
  }
158
184
 
159
185
  // bottom match
160
186
  xVal = x < left ? aLeft : left;
161
187
  yVal = top + height;
162
- if (Math.abs(top + height - (aTop + aHeight)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
188
+ if (Math.abs(yVal - (aTop + aHeight)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
163
189
  x: xVal,
164
190
  y: yVal
165
191
  }, lines)) {
166
- lines.push({
167
- y: yVal,
192
+ const line = {
168
193
  x: xVal,
194
+ y: yVal,
169
195
  width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
170
196
  height: 1
171
- });
197
+ };
198
+ lines.push(clampLine(line));
172
199
  }
173
200
 
174
- // center match
201
+ // center match (horizontal)
175
202
  xVal = x < left ? aLeft : left;
176
203
  yVal = top + height / 2;
177
- if (Math.abs(top + height / 2 - (aTop + aHeight / 2)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
204
+ if (Math.abs(yVal - (aTop + aHeight / 2)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
178
205
  x: xVal,
179
206
  y: yVal
180
207
  }, lines, "y")) {
181
- lines.push({
182
- y: yVal,
208
+ const line = {
183
209
  x: xVal,
210
+ y: yVal,
184
211
  width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
185
212
  height: 1
186
- });
213
+ };
214
+ lines.push(clampLine(line));
187
215
  }
188
216
 
189
217
  // right match
@@ -193,12 +221,13 @@ export function getClosestDraggable(x, y, className, activeClassName) {
193
221
  x: xVal,
194
222
  y: yVal
195
223
  }, lines)) {
196
- lines.push({
197
- y: yVal,
224
+ const line = {
198
225
  x: xVal,
226
+ y: yVal,
199
227
  width: 1,
200
228
  height: Math.abs(aTop - top)
201
- });
229
+ };
230
+ lines.push(clampLine(line));
202
231
  }
203
232
 
204
233
  // left match
@@ -208,27 +237,29 @@ export function getClosestDraggable(x, y, className, activeClassName) {
208
237
  x: xVal,
209
238
  y: yVal
210
239
  }, lines)) {
211
- lines.push({
212
- y: yVal,
240
+ const line = {
213
241
  x: xVal,
242
+ y: yVal,
214
243
  width: 1,
215
244
  height: Math.abs(aTop - top)
216
- });
245
+ };
246
+ lines.push(clampLine(line));
217
247
  }
218
248
 
219
- // middle match
249
+ // middle match (vertical)
220
250
  xVal = left + width / 2;
221
251
  yVal = top < aTop ? top : aTop;
222
- if (Math.abs(aLeft + aWidth / 2 - (left + width / 2)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
252
+ if (Math.abs(aLeft + aWidth / 2 - xVal) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
223
253
  x: xVal,
224
254
  y: yVal
225
255
  }, lines)) {
226
- lines.push({
227
- y: yVal,
256
+ const line = {
228
257
  x: xVal,
258
+ y: yVal,
229
259
  width: 1,
230
260
  height: Math.abs(aTop - top)
231
- });
261
+ };
262
+ lines.push(clampLine(line));
232
263
  }
233
264
  });
234
265
  return lines;
@@ -158,8 +158,11 @@ const RnD = props => {
158
158
  const textElement = currElement?.querySelector(".fgi_type_text");
159
159
  if (breakpoint && textElement && childType === "text" && !enable) {
160
160
  timerId.current = setTimeout(() => {
161
- // const { clientHeight } = textElement;
162
- const clientHeight = getTextElementHeight(textElement);
161
+ const {
162
+ clientHeight
163
+ } = textElement;
164
+ // const clientHeight = getTextElementHeight(textElement);
165
+
163
166
  const {
164
167
  height
165
168
  } = delta || {};
@@ -49,7 +49,6 @@ import ColumnView from "../Elements/DataView/Layouts/ColumnView";
49
49
  import SearchAttachment from "../Elements/Search/SearchAttachment";
50
50
  import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
51
51
  import { jsx as _jsx } from "react/jsx-runtime";
52
- import { jsxs as _jsxs } from "react/jsx-runtime";
53
52
  const alignment = ["alignLeft", "alignRight", "alignCenter", "alignJustify"];
54
53
  const list_types = ["orderedList", "unorderedList"];
55
54
  const LIST_FORMAT_TYPE = {
@@ -421,52 +420,52 @@ export const getBlock = props => {
421
420
  const selectedLineHeight = getBreakpointLineSpacing(lineH, breakpoint);
422
421
  switch (element.type) {
423
422
  case "headingOne":
424
- return /*#__PURE__*/_jsxs("h1", {
425
- ...commonHeadingProps(),
423
+ return /*#__PURE__*/_jsx("h1", {
424
+ ...attributes,
425
+ ...element.attr,
426
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
426
427
  placeholder: translation("Heading 1"),
427
- children: [children, /*#__PURE__*/_jsx("span", {
428
- contentEditable: false
429
- })]
428
+ children: children
430
429
  });
431
430
  case "headingTwo":
432
- return /*#__PURE__*/_jsxs("h2", {
433
- ...commonHeadingProps(),
431
+ return /*#__PURE__*/_jsx("h2", {
432
+ ...attributes,
433
+ ...element.attr,
434
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
434
435
  placeholder: translation("Heading 2"),
435
- children: [children, /*#__PURE__*/_jsx("span", {
436
- contentEditable: false
437
- })]
436
+ children: children
438
437
  });
439
438
  case "headingThree":
440
- return /*#__PURE__*/_jsxs("h3", {
441
- ...commonHeadingProps(),
439
+ return /*#__PURE__*/_jsx("h3", {
440
+ ...attributes,
441
+ ...element.attr,
442
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
442
443
  placeholder: translation("Heading 3"),
443
- children: [children, /*#__PURE__*/_jsx("span", {
444
- contentEditable: false
445
- })]
444
+ children: children
446
445
  });
447
446
  case "headingFour":
448
- return /*#__PURE__*/_jsxs("h4", {
449
- ...commonHeadingProps(),
447
+ return /*#__PURE__*/_jsx("h4", {
448
+ ...attributes,
449
+ ...element.attr,
450
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
450
451
  placeholder: translation("Heading 4"),
451
- children: [children, /*#__PURE__*/_jsx("span", {
452
- contentEditable: false
453
- })]
452
+ children: children
454
453
  });
455
454
  case "headingFive":
456
- return /*#__PURE__*/_jsxs("h5", {
457
- ...commonHeadingProps(),
455
+ return /*#__PURE__*/_jsx("h5", {
456
+ ...attributes,
457
+ ...element.attr,
458
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
458
459
  placeholder: translation("Heading 5"),
459
- children: [children, /*#__PURE__*/_jsx("span", {
460
- contentEditable: false
461
- })]
460
+ children: children
462
461
  });
463
462
  case "headingSix":
464
- return /*#__PURE__*/_jsxs("h6", {
465
- ...commonHeadingProps(),
463
+ return /*#__PURE__*/_jsx("h6", {
464
+ ...attributes,
465
+ ...element.attr,
466
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
466
467
  placeholder: translation("Heading 6"),
467
- children: [children, /*#__PURE__*/_jsx("span", {
468
- contentEditable: false
469
- })]
468
+ children: children
470
469
  });
471
470
  case "paragraphOne":
472
471
  return /*#__PURE__*/_jsx("p", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.5.9",
3
+ "version": "10.6.1",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"