@capillarytech/creatives-library 2.0.17 → 2.0.19
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.
|
@@ -24,7 +24,7 @@ import * as charCount from '../../../utils/smsCharCount';
|
|
|
24
24
|
import { checkUnicode} from '../../../utils/smsCharCountV2';
|
|
25
25
|
import * as globalActions from '../../../containers/Cap/actions';
|
|
26
26
|
import {getMessageObject} from '../../../utils/messageUtils';
|
|
27
|
-
import callNativeEvent from '../../../utils/callNativeEvent';
|
|
27
|
+
// import callNativeEvent from '../../../utils/callNativeEvent';
|
|
28
28
|
|
|
29
29
|
export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
30
30
|
constructor(props) {
|
|
@@ -219,7 +219,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
219
219
|
onTagSelect(data, currentTab) {
|
|
220
220
|
console.log('parent data tag', data, currentTab);
|
|
221
221
|
const editorId = currentTab > 1 ? `sms-editor${currentTab}` : 'sms-editor';
|
|
222
|
-
this.insertAtCursor(document.getElementById(editorId), `{{${data}}}
|
|
222
|
+
this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`, currentTab);
|
|
223
223
|
document.getElementById(editorId).focus();
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -740,7 +740,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
740
740
|
return false;
|
|
741
741
|
}
|
|
742
742
|
|
|
743
|
-
insertAtCursor(field, myValue) {
|
|
743
|
+
insertAtCursor(field, myValue, currentTab) {
|
|
744
744
|
//IE support
|
|
745
745
|
const myField = field;
|
|
746
746
|
if (document.selection) {
|
|
@@ -758,8 +758,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
758
758
|
} else {
|
|
759
759
|
myField.value += myValue;
|
|
760
760
|
}
|
|
761
|
-
const
|
|
762
|
-
|
|
761
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
762
|
+
formData[currentTab - 1][field.id] = myField.value;
|
|
763
|
+
this.setState({formData});
|
|
764
|
+
// const event = new Event('input', { bubbles: true });
|
|
765
|
+
// callNativeEvent({field, value: myField.value, event});
|
|
763
766
|
}
|
|
764
767
|
|
|
765
768
|
startTemplateCreation(data) {
|
|
@@ -24,7 +24,7 @@ import '../Create/_smsCreate.scss';
|
|
|
24
24
|
import messages from './messages';
|
|
25
25
|
import * as globalActions from '../../../containers/Cap/actions';
|
|
26
26
|
import {getMessageObject} from '../../../utils/messageUtils';
|
|
27
|
-
import callNativeEvent from '../../../utils/callNativeEvent';
|
|
27
|
+
// import callNativeEvent from '../../../utils/callNativeEvent';
|
|
28
28
|
|
|
29
29
|
export class Edit extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
30
30
|
constructor(props) {
|
|
@@ -217,7 +217,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
217
217
|
onTagSelect(data, currentTab) {
|
|
218
218
|
console.log('parent data tag', data, currentTab);
|
|
219
219
|
const editorId = currentTab > 1 ? `sms-editor${currentTab}` : 'sms-editor';
|
|
220
|
-
this.insertAtCursor(document.getElementById(editorId), `{{${data}}}
|
|
220
|
+
this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`, currentTab);
|
|
221
221
|
document.getElementById(editorId).focus();
|
|
222
222
|
}
|
|
223
223
|
|
|
@@ -755,7 +755,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
|
-
insertAtCursor(field, myValue) {
|
|
758
|
+
insertAtCursor(field, myValue, currentTab) {
|
|
759
759
|
//IE support
|
|
760
760
|
const myField = field;
|
|
761
761
|
if (document.selection) {
|
|
@@ -773,8 +773,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
773
773
|
} else {
|
|
774
774
|
myField.value += myValue;
|
|
775
775
|
}
|
|
776
|
-
const
|
|
777
|
-
|
|
776
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
777
|
+
formData[currentTab - 1][field.id] = myField.value;
|
|
778
|
+
this.setState({formData});
|
|
779
|
+
// const event = new Event('input', { bubbles: true });
|
|
780
|
+
// callNativeEvent({field, value: myField.value, event});
|
|
778
781
|
}
|
|
779
782
|
|
|
780
783
|
handleFrameTasks = (e) => {
|
package/package.json
CHANGED
package/utils/callNativeEvent.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
//https://github.com/facebook/react/issues/11488#issuecomment-470623779
|
|
2
|
-
export default function callNativeEvent({field, value,
|
|
3
|
-
|
|
2
|
+
export default function callNativeEvent({field, value, event}) {
|
|
3
|
+
//cuz in react 16 native events does not work
|
|
4
|
+
const ev = event;
|
|
4
5
|
const input = field;
|
|
5
6
|
const lastValue = input.value;
|
|
6
7
|
input.value = value;
|
|
7
8
|
// hack React15
|
|
8
|
-
|
|
9
|
+
ev.simulated = true;
|
|
9
10
|
// hack React16 内部定义了descriptor拦截value,此处重置状态
|
|
10
11
|
const tracker = input._valueTracker;
|
|
11
12
|
if (tracker) {
|
|
12
13
|
tracker.setValue(lastValue);
|
|
13
14
|
}
|
|
14
|
-
input.dispatchEvent(
|
|
15
|
+
input.dispatchEvent(ev);
|
|
15
16
|
}
|