• Unwatch
  • Fork

/react-draft-wysiwyg

Imge : Add default size override #228

Merged
merged 1 commit into from 6 hours ago
Commits
+25 −4
Split
Finish your review

Attach files by dragging & dropping, selecting them, or pasting from the clipboard. Uploading your files… We don’t support that file type. with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, PDF, or ZIP. Attaching documents requires write permission to this repository. with a PNG, GIF, or JPG. We don’t support that file type. with a PNG, GIF, or JPG. Yowza, that’s a big file. with a file smaller than 10MB. This file is empty. with a file that’s not empty. This file is hidden. with another file. Something went really wrong, and we can’t process that file.

Nothing to preview

@@ -319,6 +319,7 @@ export default class Demo2 extends Component {
&nbsp;&nbsp;&nbsp;&nbsp;uploadEnabled: true,<br />
&nbsp;&nbsp;&nbsp;&nbsp;alignmentEnabled: false,<br />
&nbsp;&nbsp;&nbsp;&nbsp;uploadCallback: undefined,<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;defaultSize: {"{ height: 'auto', width: '100%' }"}, <br />
&nbsp;&nbsp;{'}'}, <br />
&nbsp;&nbsp;remove: {'{ icon: eraser, className: undefined }'}, <br />
&nbsp;&nbsp;history: {'{'} <br />
@@ -353,6 +354,9 @@ export default class Demo2 extends Component {
</div>
<div className="docs-section">
<div className="docs-label">
+ Image
+ </div>
+ <div className="docs-sub-label">
Uploading Image
</div>
<div className="docs-desc">
@@ -374,6 +378,12 @@ export default class Demo2 extends Component {
<div className="docs-desc top-margined">
PLEASE NOTE: Property uploadCallback of editor component has been deprecated and will be removed in release 2.0. Its now recommended to pass uploadCallback inside toolbar property.
</div>
+ <div className="docs-sub-label">
+ Set DefaultSize for images
+ </div>
+ <div className="docs-desc">
+ Override default image size (height : auto, width : 100%).
+ </div>
</div>
<div className="docs-section">
<div className="docs-label">
@@ -1117,10 +1117,11 @@ textarea {
background: #ece9e9;
}
.rdw-embedded-modal-size {
+ align-items: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
- margin: 5px 0 10px;
+ margin: 8px 0 ;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
@@ -82,8 +82,9 @@
background: #ece9e9;
}
.rdw-embedded-modal-size {
+ align-items: center;
display: flex;
- margin: 5px 0 10px;
+ margin: 8px 0;
justify-content: space-between;
}
.rdw-embedded-modal-size-input {
@@ -7,6 +7,8 @@ import Option from '../../Option';
import Spinner from '../../Spinner';
import styles from './styles.css'; // eslint-disable-line no-unused-vars
+const lengthRegex = new RegExp(/^auto$|^[+-]?[0-9]+\.?([0-9]+)?(px|em|ex|%|in|cm|mm|pt|pc)?$/);
+
export default class ImageControl extends Component {
static propTypes: Object = {
@@ -16,14 +18,15 @@ export default class ImageControl extends Component {
config: PropTypes.object,
};
+
state: Object = {
imgSrc: '',
showModal: false,
dragEnter: false,
uploadHighlighted: this.props.config.uploadEnabled && !!this.props.config.uploadCallback,
showImageLoading: false,
- height: 'auto',
- width: '100%',
+ height: lengthRegex.test(this.props.config.defaultSize.height) ? this.props.config.defaultSize.height : 'auto',
+ width: lengthRegex.test(this.props.config.defaultSize.width) ? this.props.config.defaultSize.width : '100%',
};
componentWillMount(): void {
@@ -261,6 +264,7 @@ export default class ImageControl extends Component {
</div>
}
<div className="rdw-embedded-modal-size">
+ &#8597;&nbsp;
<input
ref={this.setHeightInputReference}
onChange={this.updateHeight}
@@ -269,6 +273,7 @@ export default class ImageControl extends Component {
className="rdw-embedded-modal-size-input"
placeholder="Height"
/>
+ &nbsp;&#8596;&nbsp;
<input
ref={this.setWidthInputReference}
onChange={this.updateWidth}
@@ -124,6 +124,10 @@ export default {
uploadEnabled: true,
alignmentEnabled: true,
uploadCallback: undefined,
+ defaultSize: {
+ height: 'auto',
+ width: '100%',
+ },
},
remove: { icon: eraser, className: undefined },
history: {