@flozy/editor 1.5.4 → 1.5.5

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.
@@ -34,7 +34,7 @@ const default_grid = {
34
34
  children: [{
35
35
  type: "paragraph",
36
36
  children: [{
37
- text: "Lorem Ipsum je fiktívny text, používaný pri návrhu tlačovín a typografie. Lorem Ipsum je štandardným výplňovým textom od 16. storočia, keď neznámy tlačiar zobral sadzobnicu plnú tlačových znakov a pomiešal ich, aby tak vytvoril vzorkovú knihu. Prežil nielen päť storočí, ale aj skok do elektronickej sadzby, a pritom zostal v podstate nezmenený. Spopularizovaný bol v 60-tych rokoch 20.storočia, vydaním hárkov Letraset, ktoré obsahovali pasáže Lorem Ipsum, a neskôr aj softvérom ako Aldus PageMaker, ktorý obsahoval verzie Lorem Ipsum."
37
+ text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
38
38
  }]
39
39
  }]
40
40
  }],
@@ -6,11 +6,9 @@ import { Editor, Range } from "slate";
6
6
  import { useSlate, useFocused } from "slate-react";
7
7
  import TextFormat from "./TextFormat";
8
8
  import usePopupStyle from "./PopupToolStyle";
9
+ import useDrag from "../../hooks/useDrag";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  const PopupTool = props => {
11
- const {
12
- onDrawerOpen
13
- } = props;
14
12
  const classes = usePopupStyle();
15
13
  const [anchorEl, setAnchorEl] = useState(null);
16
14
  const editor = useSlate();
@@ -20,12 +18,7 @@ const PopupTool = props => {
20
18
  } = editor;
21
19
  const open = Boolean(anchorEl);
22
20
  // const id = open ? "popup-edit-tool" : "";
23
-
24
- useEffect(() => {
25
- if (onDrawerOpen) {
26
- onDrawerOpen(open);
27
- }
28
- }, [open]);
21
+ const [event] = useDrag();
29
22
  useEffect(() => {
30
23
  if (!selection || !inFocus || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
31
24
  // setAnchorEl(null);
@@ -33,13 +26,15 @@ const PopupTool = props => {
33
26
  const domSelection = window.getSelection();
34
27
  const domRange = domSelection.getRangeAt(0);
35
28
  const rect = domRange.getBoundingClientRect();
36
- setAnchorEl({
37
- clientWidth: rect.width,
38
- clientHeight: rect.height,
39
- getBoundingClientRect: () => rect
40
- });
29
+ if (event === "end") {
30
+ setAnchorEl({
31
+ clientWidth: rect.width,
32
+ clientHeight: rect.height,
33
+ getBoundingClientRect: () => rect
34
+ });
35
+ }
41
36
  }
42
- }, [selection]);
37
+ }, [selection, event]);
43
38
  const handleClose = () => {
44
39
  setAnchorEl(null);
45
40
  };
@@ -59,7 +54,9 @@ const PopupTool = props => {
59
54
  hideBackdrop: true
60
55
  // handleClose={handleClose}
61
56
  ,
62
- className: "tools-drawer",
57
+ className: "tools-drawer"
58
+ // variant="persistent"
59
+ ,
63
60
  children: /*#__PURE__*/_jsx(TextFormat, {
64
61
  editor: editor,
65
62
  classes: classes,
@@ -0,0 +1,26 @@
1
+ import React, { useEffect, useState } from "react";
2
+ const useDrag = props => {
3
+ const [event, setEvent] = useState("");
4
+ useEffect(() => {
5
+ addListener();
6
+ return () => {
7
+ removeListener();
8
+ };
9
+ }, []);
10
+ const onMouseDown = () => {
11
+ setEvent("start");
12
+ };
13
+ const onMouseUp = () => {
14
+ setEvent("end");
15
+ };
16
+ const addListener = () => {
17
+ document.addEventListener("pointerdown", onMouseDown);
18
+ document.addEventListener("pointerup", onMouseUp);
19
+ };
20
+ const removeListener = () => {
21
+ document.removeEventListener("pointerdown", onMouseDown);
22
+ document.removeEventListener("pointerup", onMouseUp);
23
+ };
24
+ return [event];
25
+ };
26
+ export default useDrag;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"