@pushwoosh/dumb-components 1.0.65 → 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.
- package/RichMessageEditor/RichMessageEditor.js +3 -0
- package/RichMessageEditor/slate/DynamicContentElement.d.ts +1 -1
- package/RichMessageEditor/slate/DynamicContentElement.js +9 -4
- package/RichMessageEditor/slate/SlateEditor.d.ts +1 -0
- package/RichMessageEditor/slate/SlateEditor.js +7 -2
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -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:
|
|
35
|
+
renderElement: renderElementPersistent,
|
|
31
36
|
onFocus: onFocus
|
|
32
37
|
});
|
|
33
38
|
};
|