@darwino/darwino-react-bootstrap
Version:
A set of Javascript classes and utilities
83 lines (75 loc) • 2.12 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
/*
* (c) Copyright Darwino Inc. 2014-2017.
*/
import React, { Component } from "react";
import ReactQuill from "react-quill"; // CSS
import 'react-quill/dist/quill.snow.css';
var _quillModules = {
toolbar: [[{
'header': [1, 2, 3, 4, false]
}], [{
'font': []
}], [{
'size': ['small', false, 'large']
}], ['bold', 'italic', 'underline', 'strike', 'blockquote'], [{
'color': []
}, {
'background': []
}], [{
'script': 'sub'
}, {
'script': 'super'
}], [{
'align': []
}], [{
'list': 'ordered'
}, {
'list': 'bullet'
}, {
'indent': '-1'
}, {
'indent': '+1'
}], ['link', 'image'], ['clean']]
};
class FieldRichText extends Component {
render() {
var _this$props = this.props,
{
input,
meta,
disabled,
readOnly,
label
} = _this$props,
props = _objectWithoutProperties(_this$props, ["input", "meta", "disabled", "readOnly", "label"]);
if (readOnly) {
return /*#__PURE__*/React.createElement("div", {
dangerouslySetInnerHTML: {
__html: input.value
}
});
} else {
// React-quill issue that sets the form dirty when the value is set
// See: https://github.com/zenoamaro/react-quill/issues/259
function onChange(content, delta, source, editor) {
if (source !== "api") {
input.onChange(content);
}
} // This generates an issue where the content gets empty when there is a click on a combobox within the toolbar */}
// We only pass 'value' & 'onchange'
// onBlur={input.onBlur}
return /*#__PURE__*/React.createElement(ReactQuill, _extends({
theme: "snow"
}, props, {
readOnly: disabled,
onChange: onChange,
value: input.value,
modules: _quillModules
}));
}
}
}
export default FieldRichText;
//# sourceMappingURL=FieldRichText.js.map