@pushwoosh/dumb-components 1.0.54 → 1.0.56
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.
|
@@ -47,21 +47,17 @@ export const RichMessageEditor = ({
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
const insertDynamicContent = editor => {
|
|
50
|
+
const insertDynamicContent = (editor, dc) => {
|
|
51
51
|
const newDC = {
|
|
52
52
|
type: 'dc',
|
|
53
|
-
dc
|
|
54
|
-
tagName: '',
|
|
55
|
-
modifier: 'regular',
|
|
56
|
-
defaultValue: ''
|
|
57
|
-
},
|
|
53
|
+
dc,
|
|
58
54
|
children: [{
|
|
59
55
|
text: ''
|
|
60
56
|
}]
|
|
61
57
|
};
|
|
62
58
|
Transforms.insertNodes(editor, newDC);
|
|
63
|
-
Transforms.
|
|
64
|
-
|
|
59
|
+
Transforms.move(editor);
|
|
60
|
+
setShowDrop(undefined);
|
|
65
61
|
};
|
|
66
62
|
const clickAwayHandler = usePersistentFunction(() => {
|
|
67
63
|
setShowDrop(undefined);
|
|
@@ -84,45 +80,54 @@ export const RichMessageEditor = ({
|
|
|
84
80
|
onSelectionChange: onSelectionChange
|
|
85
81
|
}, ({
|
|
86
82
|
editor
|
|
87
|
-
}) =>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
83
|
+
}) => {
|
|
84
|
+
var _getDcByPath;
|
|
85
|
+
return React.createElement(FieldBox, {
|
|
86
|
+
title: title,
|
|
87
|
+
boxRef: rootRef,
|
|
88
|
+
error: error,
|
|
89
|
+
actions: React.createElement(Collapse, {
|
|
90
|
+
expanded: isFocused
|
|
91
|
+
}, React.createElement(Horizontal, {
|
|
92
|
+
"$gap": 8
|
|
93
|
+
}, canUsePersonalization && React.createElement(ImSpan, {
|
|
94
|
+
onClick: () => showDropArea({
|
|
95
|
+
type: 'personalization'
|
|
96
|
+
})
|
|
97
|
+
}, React.createElement(PersonalizationIcon, null), "Personalization"), canUseEmoji && React.createElement(ImSpan, {
|
|
98
|
+
onClick: () => showDropArea({
|
|
99
|
+
type: 'emoji'
|
|
100
|
+
})
|
|
101
|
+
}, React.createElement(EmojiIcon, null), "Emoji")))
|
|
102
|
+
}, React.createElement(SlateEditable, {
|
|
103
|
+
minHeight: minHeight,
|
|
104
|
+
onFocus: () => {
|
|
105
|
+
setIsFocused(true);
|
|
106
|
+
const {
|
|
107
|
+
selection
|
|
108
|
+
} = editor;
|
|
109
|
+
if (selection) {
|
|
110
|
+
onSelectionChange(selection);
|
|
111
|
+
}
|
|
111
112
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
113
|
+
}), showDrop && React.createElement(DropContent, {
|
|
114
|
+
top: showDrop.yValue,
|
|
115
|
+
left: showDrop.xValue
|
|
116
|
+
}, showDrop.type === 'personalization' && (renderDynamicContent === null || renderDynamicContent === void 0 ? void 0 : renderDynamicContent({
|
|
117
|
+
dc: showDrop.path ? (_getDcByPath = getDcByPath(editor.children, showDrop.path)) === null || _getDcByPath === void 0 ? void 0 : _getDcByPath.dc : undefined,
|
|
118
|
+
onChange: newDC => {
|
|
119
|
+
if (showDrop.path) {
|
|
120
|
+
Transforms.setNodes(editor, {
|
|
121
|
+
dc: newDC
|
|
122
|
+
}, {
|
|
123
|
+
at: showDrop.path
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
insertDynamicContent(editor, newDC);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
})), showDrop.type === 'emoji' && React.createElement(EmojiPicker, {
|
|
130
|
+
onEmojiSelect: s => editor.insertText(s)
|
|
131
|
+
})));
|
|
132
|
+
});
|
|
128
133
|
};
|
|
@@ -6,7 +6,7 @@ type DropValueCommon = {
|
|
|
6
6
|
};
|
|
7
7
|
export type DropValuePersonalization = {
|
|
8
8
|
type: 'personalization';
|
|
9
|
-
path
|
|
9
|
+
path?: number[];
|
|
10
10
|
};
|
|
11
11
|
export type DropValueEmoji = {
|
|
12
12
|
type: 'emoji';
|
|
@@ -22,7 +22,7 @@ export type RichMessageEditorProps = {
|
|
|
22
22
|
canUseEmoji?: boolean;
|
|
23
23
|
onBlur?: () => void;
|
|
24
24
|
renderDynamicContent?: (props: {
|
|
25
|
-
dc
|
|
25
|
+
dc?: DynamicContent;
|
|
26
26
|
onChange: (newDC: DynamicContent) => void;
|
|
27
27
|
}) => ReactNode;
|
|
28
28
|
};
|