UNPKG

@elliemae/ds-wysiwygeditor

Version:

Ellie Mae - Dim Sum - WYSIWYG Editor

107 lines (100 loc) 5 kB
import _extends from '@babel/runtime/helpers/esm/extends'; import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray'; import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties'; import React, { useState, useEffect } from 'react'; import { PropTypes, describe } from 'react-desc'; import DSWYSIWYGEditorImpl from './components/DSWYSIWYGEditorImpl.js'; import '@babel/runtime/helpers/esm/classCallCheck'; import '@babel/runtime/helpers/esm/createClass'; import '@babel/runtime/helpers/esm/assertThisInitialized'; import '@babel/runtime/helpers/esm/inherits'; import '@babel/runtime/helpers/esm/possibleConstructorReturn'; import '@babel/runtime/helpers/esm/getPrototypeOf'; import '@babel/runtime/helpers/esm/defineProperty'; import 'react-quill'; import 'quill-blot-formatter'; import './components/ImageLibraryModal.js'; import '@elliemae/ds-imagelibrarymodal'; import 'prop-types'; import './components/InsertFieldModal.js'; import '@elliemae/ds-modal'; import 'lodash'; import '@elliemae/ds-shared/constants'; import './components/customFields.js'; import './components/CustomToolbar.js'; import '@elliemae/ds-basic/Button'; import '@elliemae/ds-icons/ArrowheadDown'; import '@elliemae/ds-dropdownmenu'; import '@elliemae/ds-basic/Tooltip'; import './constants.js'; import '@babel/runtime/helpers/esm/toConsumableArray'; import './components/colors.js'; import './quillOverrides/IndentStyle.js'; import '@babel/runtime/helpers/esm/get'; import './quillOverrides/LinkFormat.js'; import './utils.js'; var DSWYSIWYGEditor = function DSWYSIWYGEditor(_ref) { var _ref$value = _ref.value, value = _ref$value === void 0 ? '' : _ref$value, _ref$onChange = _ref.onChange, onChange = _ref$onChange === void 0 ? function () { return null; } : _ref$onChange, _ref$getQuillRef = _ref.getQuillRef, getQuillRef = _ref$getQuillRef === void 0 ? function () { return null; } : _ref$getQuillRef, _ref$quillModules = _ref.quillModules, quillModules = _ref$quillModules === void 0 ? {} : _ref$quillModules, customToolbar = _ref.customToolbar, toolbarHandlers = _ref.toolbarHandlers, _ref$showRawHTML = _ref.showRawHTML, showRawHTML = _ref$showRawHTML === void 0 ? false : _ref$showRawHTML, height = _ref.height, hideItems = _ref.hideItems, rest = _objectWithoutProperties(_ref, ["value", "onChange", "getQuillRef", "quillModules", "customToolbar", "toolbarHandlers", "showRawHTML", "height", "hideItems"]); var emptyAction = function emptyAction() {}; var _useState = useState(showRawHTML), _useState2 = _slicedToArray(_useState, 2), showHTML = _useState2[0], setShowHTML = _useState2[1]; useEffect(function () { return setShowHTML(showRawHTML); }, [showRawHTML]); return /*#__PURE__*/React.createElement(DSWYSIWYGEditorImpl, _extends({ forceHttpLink: true, handleCustomFieldClick: emptyAction, handleImageClick: emptyAction, quillOverrides: [], value: value, onChange: onChange, getQuillRef: getQuillRef, quillModules: quillModules, customToolbar: customToolbar, toolbarHandlers: toolbarHandlers, showRawHTML: showHTML, onShowHTML: function onShowHTML() { return setShowHTML(!showHTML); }, height: height, hideItems: hideItems }, rest)); }; var wysiwygEditorProps = { value: PropTypes.string.description('editors value').isRequired, onChange: PropTypes.func.description("(content, delta, source, editor) : Called back with the new contents of the editor after change. \n It will be passed the HTML contents of the editor, a delta object expressing the change, the source of the change, and finally a read-only proxy to editor accessors such as getHTML(). \n \u26A0\uFE0F Do not use this delta object as value, as it will cause a loop. \n Use editor.getContents() instead. See Using Deltas for details. \n Read more: https://github.com/zenoamaro/react-quill#props").isRequired, getQuillRef: PropTypes.func.description('function to use quill.js ref'), quillModules: PropTypes.object.description('object to override quill modules'), customToolbar: PropTypes.element.description('custom toolbar'), toolbarHandlers: PropTypes.object.description('object with toolbar handlers'), showRawHTML: PropTypes.bool.description('whether to display html view or not').defaultValue(false), height: PropTypes.string.description('heigth of the editors text area'), readOnly: PropTypes.string.description("If true, the editor won't allow changing its contents. Wraps the Quill disable API."), hideItems: PropTypes.object.description('object of defaultItems to be removed from toolbar').defaultValue({}) }; DSWYSIWYGEditor.propTypes = wysiwygEditorProps; var WYSIWYWithSchema = describe(DSWYSIWYGEditor); WYSIWYWithSchema.propTypes = wysiwygEditorProps; export default DSWYSIWYGEditor; export { WYSIWYWithSchema }; //# sourceMappingURL=DSWYSIWYGEditor.js.map