@capillarytech/creatives-library 9.0.5 → 9.0.6-beta.0.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "9.0.5",
4
+ "version": "9.0.6-beta.0.1",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -40,15 +40,18 @@ class NewCallTask extends React.Component { // eslint-disable-line react/prefer-
40
40
  this.insertAtCursor(`{{${data}}}`);
41
41
  }
42
42
 
43
+ setInputRef = (textarea) => {
44
+ this.textArea = textarea;
45
+ }
46
+
43
47
  insertAtCursor = (myValue) => {
44
- const textAreaRef = document.getElementById('new-call-task-message-body');
45
- if (!textAreaRef) return;
46
- textAreaRef.focus();
48
+ this.textArea.focus();
49
+ const textAreaRef = this.textArea.textAreaRef;
47
50
  let pos = textAreaRef.selectionEnd + myValue.length;
48
51
  //IE support
49
52
  let newMessage = textAreaRef.value + myValue;
50
53
  if (document.selection) {
51
- textAreaRef.focus();
54
+ this.textArea.focus();
52
55
  const sel = document.selection.createRange();
53
56
  sel.text = myValue;
54
57
  } else if (textAreaRef.selectionStart || textAreaRef.selectionStart === '0') { //MOZILLA and others
@@ -125,7 +128,7 @@ class NewCallTask extends React.Component { // eslint-disable-line react/prefer-
125
128
  injectedTags={injectedTags}
126
129
  />
127
130
  <CapInput.TextArea
128
- id="new-call-task-message-body"
131
+ setInputRef={this.setInputRef}
129
132
  label={formatMessage(messages.messageHeader)}
130
133
  onChange={this.updateMessageBody}
131
134
  value={messageBody}
@@ -166,6 +166,10 @@ export class FTP extends React.Component {
166
166
  this.insertAtCursor(`{{${data}}}`);
167
167
  };
168
168
 
169
+ setInputRef = (textarea) => {
170
+ this.textArea = textarea;
171
+ };
172
+
169
173
  getServerSelectionContent = () => {
170
174
  const { getFTPServersInProgress } = this.props.FTP || {};
171
175
  const { formatMessage } = this.props.intl;
@@ -253,7 +257,7 @@ export class FTP extends React.Component {
253
257
  injectedTags={injectedTags || {}}
254
258
  />
255
259
  <CapInput.TextArea
256
- id="ftp-message-content"
260
+ setInputRef={this.setInputRef}
257
261
  label={formatMessage(messages.messageHeader)}
258
262
  onChange={this.updateMessageBody}
259
263
  value={messageContent}
@@ -525,14 +529,13 @@ export class FTP extends React.Component {
525
529
  };
526
530
 
527
531
  insertAtCursor = (myValue) => {
528
- const textAreaRef = document.getElementById('ftp-message-content');
529
- if (!textAreaRef) return;
530
- textAreaRef.focus();
532
+ this.textArea.focus();
533
+ const textAreaRef = this.textArea.textAreaRef;
531
534
  let pos = textAreaRef.selectionEnd + myValue.length;
532
535
  //IE support
533
536
  let newMessage = textAreaRef.value + myValue;
534
537
  if (document.selection) {
535
- textAreaRef.focus();
538
+ this.textArea.focus();
536
539
  const sel = document.selection.createRange();
537
540
  sel.text = myValue;
538
541
  } else if (textAreaRef.selectionStart || textAreaRef.selectionStart === '0') { //MOZILLA and others
@@ -1,4 +1,4 @@
1
- import React, { useRef, useEffect } from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { FormattedMessage } from 'react-intl';
4
4
  import CapInput from '@capillarytech/cap-ui-library/CapInput';
@@ -73,13 +73,6 @@ export const MessageSection = ({
73
73
  handleMessageTextAreaRef,
74
74
  isAiContentBotDisabled,
75
75
  }) => {
76
- // resolve the underlying DOM
77
- // <textarea> by id and feed it to the existing ref handler. CapEmojiPicker and
78
- // the Aira trigger both read `messageTextAreaRef.current` as that DOM node.
79
- useEffect(() => {
80
- handleMessageTextAreaRef(document?.getElementById('webpush-message-input'));
81
- }, [handleMessageTextAreaRef]);
82
-
83
76
  const renderCharacterCount = () => {
84
77
  if (!SHOW_CHARACTER_COUNT) return null;
85
78
 
@@ -126,6 +119,7 @@ export const MessageSection = ({
126
119
  size="default"
127
120
  isRequired
128
121
  autosize={{ minRows: 3, maxRows: 5 }}
122
+ setInputRef={handleMessageTextAreaRef}
129
123
  errorMessage={
130
124
  error && (
131
125
  <CapError className="webpush-template-message-error">
@@ -152,7 +146,7 @@ MessageSection.propTypes = {
152
146
  tagList: PropTypes.node,
153
147
  messageCountRef: PropTypes.object,
154
148
  messageTextAreaRef: PropTypes.object,
155
- handleMessageTextAreaRef: PropTypes.func,
149
+ handleMessageTextAreaRef: PropTypes.func.isRequired,
156
150
  isAiContentBotDisabled: PropTypes.bool,
157
151
  };
158
152
 
@@ -161,7 +155,6 @@ MessageSection.defaultProps = {
161
155
  tagList: null,
162
156
  messageCountRef: null,
163
157
  messageTextAreaRef: null,
164
- handleMessageTextAreaRef: () => {},
165
158
  isAiContentBotDisabled: false,
166
159
  };
167
160