@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.select(editor, editor.selection);
64
- onSelectionChange(editor.selection);
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
- }) => React.createElement(FieldBox, {
88
- title: title,
89
- boxRef: rootRef,
90
- error: error,
91
- actions: React.createElement(Collapse, {
92
- expanded: isFocused
93
- }, React.createElement(Horizontal, {
94
- "$gap": 8
95
- }, canUsePersonalization && React.createElement(ImSpan, {
96
- onClick: () => insertDynamicContent(editor)
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);
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
- }), showDrop && React.createElement(DropContent, {
114
- top: showDrop.yValue,
115
- left: showDrop.xValue
116
- }, showDrop.type === 'personalization' && getDcByPath(editor.children, showDrop.path) && (renderDynamicContent === null || renderDynamicContent === void 0 ? void 0 : renderDynamicContent({
117
- dc: getDcByPath(editor.children, showDrop.path).dc,
118
- onChange: newDC => {
119
- Transforms.setNodes(editor, {
120
- dc: newDC
121
- }, {
122
- at: showDrop.path
123
- });
124
- }
125
- })), showDrop.type === 'emoji' && React.createElement(EmojiPicker, {
126
- onEmojiSelect: s => editor.insertText(s)
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: number[];
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: DynamicContent;
25
+ dc?: DynamicContent;
26
26
  onChange: (newDC: DynamicContent) => void;
27
27
  }) => ReactNode;
28
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",