react-bootstrap-front 3.9.0 → 3.9.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,6 +1,6 @@
1
1
  {
2
2
  "name": "react-bootstrap-front",
3
- "version": "3.9.0",
3
+ "version": "3.9.1",
4
4
  "description": "React Bootstrap Components",
5
5
  "keywords": [
6
6
  "Bootstrap 4",
@@ -298,7 +298,7 @@ export default class ResponsiveModalInner extends Component {
298
298
  </div>
299
299
  }
300
300
  </div>
301
- {this.props.buttons && (
301
+ {(this.props.buttons || this.props.help || this.props.saving) && (
302
302
  <div className={classnames('modal-footer', this.props.modalClassName)}>
303
303
  {(this.props.help || this.props.saving ) &&
304
304
  <div className="modal-left-buttons">
@@ -8,7 +8,6 @@ import { getFieldId } from '../helpers';
8
8
  export const InputJson = props => {
9
9
  let myId = getFieldId(props.name, props.id);
10
10
  const data = JSON.parse(props.value) || {};
11
- console.log(data, props.value);
12
11
  return (
13
12
  <InputGroup {...props} id={myId}>
14
13
  {props.prepend && props.prepend !== '' && (
@@ -1,7 +1,7 @@
1
1
  import React, { Component } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
- import { EditorState, Modifier } from 'draft-js';
4
+ import { EditorState, Modifier, CompositeDecorator } from 'draft-js';
5
5
  import { Editor } from 'react-draft-wysiwyg';
6
6
  import { convertToHTML, convertFromHTML } from 'draft-convert';
7
7
  import { htmlToString } from '../helpers';
@@ -52,6 +52,9 @@ const toHtml = {
52
52
  if (entity.type === 'LINK') {
53
53
  return <a href={entity.data.url}>{originalText}</a>;
54
54
  }
55
+ if (entity.type === 'MAILMERGE') {
56
+ return <span data-mailmerge="{originalText}">{originalText}</span>;
57
+ }
55
58
  return originalText;
56
59
  },
57
60
  };
@@ -105,6 +108,9 @@ const fromHtml = {
105
108
  if (nodeName === 'a') {
106
109
  return createEntity('LINK', 'MUTABLE', { url: node.href });
107
110
  }
111
+ if (nodeName === 'span' && node.dataset && node.dataset.mailmerge) {
112
+ return createEntity('MAILMERGE', 'IMMUTABLE', { mailmerge: node.dataset.mailmerge });
113
+ }
108
114
  },
109
115
  textToEntity: (text, createEntity) => {
110
116
  const result = [];
@@ -129,6 +135,27 @@ const fromHtml = {
129
135
  },
130
136
  };
131
137
 
138
+ function findMailmergeEntities(contentBlock, callback, contentState) {
139
+ console.log(callback);
140
+ contentBlock.findEntityRanges(
141
+ (character) => {
142
+ const entityKey = character.getEntity();
143
+ const found = entityKey !== null && contentState.getEntity(entityKey).getType() === 'MAILMERGE';
144
+ return found;
145
+ },
146
+ callback
147
+ );
148
+ }
149
+
150
+ const Mailmerge = (props) => {
151
+ const {mailmerge} = props.contentState.getEntity(props.entityKey).getData();
152
+ return (
153
+ <a href={mailmerge}>
154
+ {props.children}
155
+ </a>
156
+ );
157
+ };
158
+
132
159
  export default class InputTextarea extends Component {
133
160
  static propTypes = {
134
161
  id: PropTypes.string,
@@ -169,9 +196,15 @@ export default class InputTextarea extends Component {
169
196
  } else {
170
197
  content = '<p/>';
171
198
  }
199
+ const decorator = new CompositeDecorator([
200
+ {
201
+ strategy: findMailmergeEntities,
202
+ component: Mailmerge,
203
+ },
204
+ ]);
172
205
  const value = convertFromHTML(fromHtml)(content);
173
206
  this.state = {
174
- editorState: EditorState.createWithContent(value),
207
+ editorState: EditorState.createWithContent(value, decorator),
175
208
  toolbar: false,
176
209
  };
177
210
  this.onEditorStateChange = this.onEditorStateChange.bind(this);
@@ -6,3 +6,7 @@
6
6
  padding: 5px;
7
7
  border: 1px solid theme-color('secondary-light');
8
8
  }
9
+
10
+ .rbf-mailmerge {
11
+ color: #105a1c;
12
+ }