@pushwoosh/dumb-components 1.0.64 → 1.0.66

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.
@@ -28,8 +28,9 @@ export const RichMessageEditor = ({
28
28
  floatingStyles,
29
29
  update
30
30
  } = useFloating({
31
+ strategy: 'fixed',
31
32
  middleware: [offset(8), autoPlacement({
32
- allowedPlacements: ['left', 'left-start', 'left-end', 'right', 'right-start', 'right-end']
33
+ allowedPlacements: ['right', 'right-start', 'right-end', 'left', 'left-start', 'left-end']
33
34
  })]
34
35
  });
35
36
  const onSelectionChange = selection => {
@@ -109,6 +110,9 @@ export const RichMessageEditor = ({
109
110
  if (selection) {
110
111
  onSelectionChange(selection);
111
112
  }
113
+ },
114
+ onDelete: () => {
115
+ setShowDrop(undefined);
112
116
  }
113
117
  }), showDrop && React.createElement("div", {
114
118
  style: floatingStyles,
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare function renderElement(props: any): React.JSX.Element;
2
+ export declare function renderElement(props: any, onDelete: () => void): React.JSX.Element;
@@ -6,6 +6,7 @@ import { Chip } from '../../Chip';
6
6
  const DynamicContentElementComponent = ({
7
7
  attributes,
8
8
  element,
9
+ onDelete,
9
10
  children
10
11
  }) => {
11
12
  const editor = useSlateStatic();
@@ -38,6 +39,7 @@ const DynamicContentElementComponent = ({
38
39
  focus: point
39
40
  });
40
41
  }
42
+ onDelete();
41
43
  }
42
44
  }, React.createElement("span", null, tagName || 'Not set'), children);
43
45
  };
@@ -45,12 +47,14 @@ const Element = props => {
45
47
  const {
46
48
  attributes,
47
49
  children,
48
- element
50
+ element,
51
+ onDelete
49
52
  } = props;
50
53
  switch (element.type) {
51
54
  case 'dc':
52
55
  return React.createElement(DynamicContentElementComponent, {
53
- ...props
56
+ ...props,
57
+ onDelete: onDelete
54
58
  });
55
59
  default:
56
60
  return React.createElement("p", {
@@ -58,8 +62,9 @@ const Element = props => {
58
62
  }, children);
59
63
  }
60
64
  };
61
- export function renderElement(props) {
65
+ export function renderElement(props, onDelete) {
62
66
  return React.createElement(Element, {
63
- ...props
67
+ ...props,
68
+ onDelete: onDelete
64
69
  });
65
70
  }
@@ -13,6 +13,7 @@ export declare const SlateEditor: FC<SlateEditor>;
13
13
  type SlateEditableProps = {
14
14
  minHeight?: string;
15
15
  onFocus?: () => void;
16
+ onDelete: () => void;
16
17
  };
17
18
  export declare const SlateEditable: FC<SlateEditableProps>;
18
19
  export {};
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Slate } from 'slate-react';
3
+ import { usePersistentFunction } from '@pushwoosh/kit-helpers';
3
4
  import { renderElement } from './DynamicContentElement';
4
5
  import { content2string, string2content } from './helpers';
5
6
  import { EditableStyled } from './SlateEditor.styled';
@@ -23,11 +24,15 @@ export const SlateEditor = ({
23
24
  };
24
25
  export const SlateEditable = ({
25
26
  minHeight,
26
- onFocus
27
+ onFocus,
28
+ onDelete
27
29
  }) => {
30
+ const renderElementPersistent = usePersistentFunction(props => {
31
+ return renderElement(props, onDelete);
32
+ });
28
33
  return React.createElement(EditableStyled, {
29
34
  "$minHeight": minHeight,
30
- renderElement: renderElement,
35
+ renderElement: renderElementPersistent,
31
36
  onFocus: onFocus
32
37
  });
33
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.64",
3
+ "version": "1.0.66",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",