@elliemae/ds-wysiwygeditor 1.58.0-rc.2 → 1.58.0

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.
@@ -8,13 +8,12 @@ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProp
8
8
  var React = require('react');
9
9
  var reactDesc = require('react-desc');
10
10
  var components_DSWYSIWYGEditorImpl = require('./components/DSWYSIWYGEditorImpl.js');
11
+ require('@babel/runtime/helpers/defineProperty');
11
12
  require('@babel/runtime/helpers/classCallCheck');
12
13
  require('@babel/runtime/helpers/createClass');
13
- require('@babel/runtime/helpers/assertThisInitialized');
14
14
  require('@babel/runtime/helpers/inherits');
15
15
  require('@babel/runtime/helpers/possibleConstructorReturn');
16
16
  require('@babel/runtime/helpers/getPrototypeOf');
17
- require('@babel/runtime/helpers/defineProperty');
18
17
  require('react-quill');
19
18
  require('quill-blot-formatter');
20
19
  require('./components/ImageLibraryModal.js');
@@ -1 +1 @@
1
- {"version":3,"file":"DSWYSIWYGEditor.js","sources":["../../src/DSWYSIWYGEditor.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport DSWYSIWYGEditorImpl from './components/DSWYSIWYGEditorImpl';\n\nconst DSWYSIWYGEditor = ({\n value = '',\n onChange = () => null,\n getQuillRef = () => null,\n quillModules = {},\n customToolbar,\n toolbarHandlers,\n showRawHTML = false,\n height,\n hideItems,\n ...rest\n}) => {\n const emptyAction = () => {};\n const [showHTML, setShowHTML] = useState(showRawHTML);\n\n useEffect(() => setShowHTML(showRawHTML), [showRawHTML]);\n\n return (\n <DSWYSIWYGEditorImpl\n forceHttpLink\n handleCustomFieldClick={emptyAction}\n handleImageClick={emptyAction}\n quillOverrides={[]}\n value={value}\n onChange={onChange}\n getQuillRef={getQuillRef}\n quillModules={quillModules}\n customToolbar={customToolbar}\n toolbarHandlers={toolbarHandlers}\n showRawHTML={showHTML}\n onShowHTML={() => setShowHTML(!showHTML)}\n height={height}\n hideItems={hideItems}\n {...rest}\n />\n );\n};\n\nconst wysiwygEditorProps = {\n value: PropTypes.string.description('editors value').isRequired,\n onChange: PropTypes.func.description(\n `(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 ⚠️ 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`,\n ).isRequired,\n getQuillRef: PropTypes.func.description('function to use quill.js ref'),\n quillModules: PropTypes.object.description('object to override quill modules'),\n customToolbar: PropTypes.element.description('custom toolbar'),\n toolbarHandlers: PropTypes.object.description('object with toolbar handlers'),\n showRawHTML: PropTypes.bool.description('whether to display html view or not').defaultValue(false),\n height: PropTypes.string.description('heigth of the editors text area'),\n readOnly: PropTypes.string.description(\n \"If true, the editor won't allow changing its contents. Wraps the Quill disable API.\",\n ),\n hideItems: PropTypes.object.description('object of defaultItems to be removed from toolbar').defaultValue({}),\n zIndex: PropTypes.number.description(\n 'zIndex to be used (required when used in a modal for correct tooltips displaying)',\n ),\n};\n\nDSWYSIWYGEditor.propTypes = wysiwygEditorProps;\n\nconst WYSIWYWithSchema = describe(DSWYSIWYGEditor);\nWYSIWYWithSchema.propTypes = wysiwygEditorProps;\n\nexport { WYSIWYWithSchema };\nexport default DSWYSIWYGEditor;\n"],"names":["DSWYSIWYGEditor","value","onChange","getQuillRef","quillModules","customToolbar","toolbarHandlers","showRawHTML","height","hideItems","rest","emptyAction","useState","showHTML","setShowHTML","useEffect","React","DSWYSIWYGEditorImpl","wysiwygEditorProps","PropTypes","string","description","isRequired","func","object","element","bool","defaultValue","readOnly","zIndex","number","propTypes","WYSIWYWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIMA,eAAe,GAAG,SAAlBA,eAAkB,OAWlB;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WYSIWYGEditor.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport DSWYSIWYGEditorImpl from './components/DSWYSIWYGEditorImpl';\n\nconst DSWYSIWYGEditor = ({\n value = '',\n onChange = () => null,\n getQuillRef = () => null,\n quillModules = {},\n customToolbar,\n toolbarHandlers,\n showRawHTML = false,\n height,\n hideItems,\n ...rest\n}) => {\n const emptyAction = () => {};\n const [showHTML, setShowHTML] = useState(showRawHTML);\n\n useEffect(() => setShowHTML(showRawHTML), [showRawHTML]);\n\n return (\n <DSWYSIWYGEditorImpl\n forceHttpLink\n handleCustomFieldClick={emptyAction}\n handleImageClick={emptyAction}\n quillOverrides={[]}\n value={value}\n onChange={onChange}\n getQuillRef={getQuillRef}\n quillModules={quillModules}\n customToolbar={customToolbar}\n toolbarHandlers={toolbarHandlers}\n showRawHTML={showHTML}\n onShowHTML={() => setShowHTML(!showHTML)}\n height={height}\n hideItems={hideItems}\n {...rest}\n />\n );\n};\n\nconst wysiwygEditorProps = {\n value: PropTypes.string.description('editors value').isRequired,\n onChange: PropTypes.func.description(\n `(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 ⚠️ 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`,\n ).isRequired,\n getQuillRef: PropTypes.func.description('function to use quill.js ref'),\n quillModules: PropTypes.object.description('object to override quill modules'),\n customToolbar: PropTypes.element.description('custom toolbar'),\n toolbarHandlers: PropTypes.object.description('object with toolbar handlers'),\n showRawHTML: PropTypes.bool.description('whether to display html view or not').defaultValue(false),\n height: PropTypes.string.description('heigth of the editors text area'),\n readOnly: PropTypes.string.description(\n \"If true, the editor won't allow changing its contents. Wraps the Quill disable API.\",\n ),\n hideItems: PropTypes.object.description('object of defaultItems to be removed from toolbar').defaultValue({}),\n zIndex: PropTypes.number.description(\n 'zIndex to be used (required when used in a modal for correct tooltips displaying)',\n ),\n};\n\nDSWYSIWYGEditor.propTypes = wysiwygEditorProps;\n\nconst WYSIWYWithSchema = describe(DSWYSIWYGEditor);\nWYSIWYWithSchema.propTypes = wysiwygEditorProps;\n\nexport { WYSIWYWithSchema };\nexport default DSWYSIWYGEditor;\n"],"names":["DSWYSIWYGEditor","value","onChange","getQuillRef","quillModules","customToolbar","toolbarHandlers","showRawHTML","height","hideItems","rest","emptyAction","useState","showHTML","setShowHTML","useEffect","React","DSWYSIWYGEditorImpl","wysiwygEditorProps","PropTypes","string","description","isRequired","func","object","element","bool","defaultValue","readOnly","zIndex","number","propTypes","WYSIWYWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIMA,eAAe,GAAG,SAAlBA,eAAkB,OAWlB;AAAA,wBAVJC,KAUI;AAAA,MAVJA,KAUI,2BAVI,EAUJ;AAAA,2BATJC,QASI;AAAA,MATJA,QASI,8BATO;AAAA,WAAM,IAAN;AAAA,GASP;AAAA,8BARJC,WAQI;AAAA,MARJA,WAQI,iCARU;AAAA,WAAM,IAAN;AAAA,GAQV;AAAA,+BAPJC,YAOI;AAAA,MAPJA,YAOI,kCAPW,EAOX;AAAA,MANJC,aAMI,QANJA,aAMI;AAAA,MALJC,eAKI,QALJA,eAKI;AAAA,8BAJJC,WAII;AAAA,MAJJA,WAII,iCAJU,KAIV;AAAA,MAHJC,MAGI,QAHJA,MAGI;AAAA,MAFJC,SAEI,QAFJA,SAEI;AAAA,MADDC,IACC;;AACJ,MAAMC,WAAW,GAAG,SAAdA,WAAc,GAAM,EAA1B;;AACA,kBAAgCC,cAAQ,CAACL,WAAD,CAAxC;AAAA;AAAA,MAAOM,QAAP;AAAA,MAAiBC,WAAjB;;AAEAC,EAAAA,eAAS,CAAC;AAAA,WAAMD,WAAW,CAACP,WAAD,CAAjB;AAAA,GAAD,EAA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EAAAA,MAAM,EAAEW,mBAAS,CAACC,MAAV,CAAiBC,WAAjB,CAA6B,iCAA7B,CAdiB;AAezBO,EAAAA,QAAQ,EAAET,mBAAS,CAACC,MAAV,CAAiBC,WAAjB,CACR,qFADQ,CAfe;AAkBzBZ,EAAAA,SAAS,EAAEU,mBAAS,CAACK,MAAV,CAAiBH,WAAjB,CAA6B,mDAA7B,EAAkFM,YAAlF,CAA+F,EAA/F,CAlBc;AAmBzBE,EAAAA,MAAM,EAAEV,mBAAS,CAACW,MAAV,CAAiBT,WAAjB,CACN,mFADM;AAnBiB,CAA3B;AAwBArB,eAAe,CAAC+B,SAAhB,GAA4Bb,kBAA5B;IAEMc,gBAAgB,GAAGC,kBAAQ,CAACjC,eAAD;AACjCgC,gBAAgB,CAACD,SAAjB,GAA6Bb,kBAA7B;;;;;"}
@@ -2,13 +2,12 @@
2
2
 
3
3
  var _extends = require('@babel/runtime/helpers/extends');
4
4
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
5
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
5
6
  var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
6
7
  var _createClass = require('@babel/runtime/helpers/createClass');
7
- var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
8
8
  var _inherits = require('@babel/runtime/helpers/inherits');
9
9
  var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
10
10
  var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
11
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
12
11
  var React = require('react');
13
12
  var ReactQuill = require('react-quill');
14
13
  var BlotFormatter = require('quill-blot-formatter');
@@ -41,13 +40,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
41
40
 
42
41
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
43
42
  var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
43
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
44
44
  var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
45
45
  var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
46
- var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
47
46
  var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
48
47
  var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
49
48
  var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
50
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
51
49
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
52
50
  var ReactQuill__default = /*#__PURE__*/_interopDefaultLegacy(ReactQuill);
53
51
  var BlotFormatter__default = /*#__PURE__*/_interopDefaultLegacy(BlotFormatter);
@@ -90,8 +88,7 @@ var DSWYSIWYGEditorImpl = /*#__PURE__*/function (_React$PureComponent) {
90
88
  _classCallCheck__default['default'](this, DSWYSIWYGEditorImpl);
91
89
 
92
90
  _this = _super.call(this, props);
93
-
94
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "quillModules", _objectSpread({
91
+ _this.quillModules = _objectSpread({
95
92
  toolbar: {
96
93
  container: _this.props.toolbarContainer ? "#".concat(_this.props.toolbarContainer) : '#toolbar',
97
94
  handlers: _objectSpread({}, _this.props.toolbarHandlers)
@@ -102,30 +99,30 @@ var DSWYSIWYGEditorImpl = /*#__PURE__*/function (_React$PureComponent) {
102
99
  },
103
100
  blotFormatter: {// options... https://github.com/Fandom-OSS/quill-blot-formatter
104
101
  }
105
- }, _this.props.quillModules));
102
+ }, _this.props.quillModules);
106
103
 
107
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onChangeQuill", function (html, delta, source, editor) {
104
+ _this.onChangeQuill = function (html, delta, source, editor) {
108
105
  var _this$props = _this.props,
109
106
  showRawHTML = _this$props.showRawHTML,
110
107
  onChange = _this$props.onChange;
111
108
  if (!showRawHTML) onChange(html, delta, source, editor);
112
- });
109
+ };
113
110
 
114
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onChangeTextArea", function (e) {
111
+ _this.onChangeTextArea = function (e) {
115
112
  var _this$props2 = _this.props,
116
113
  showRawHTML = _this$props2.showRawHTML,
117
114
  onChange = _this$props2.onChange;
118
115
  if (showRawHTML) onChange(e.target.value);
119
- });
116
+ };
120
117
 
121
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onInserFieldConfirm", function (fieldCode) {
118
+ _this.onInserFieldConfirm = function (fieldCode) {
122
119
  var editor = _this.getEditor();
123
120
 
124
121
  var range = editor.getSelection(true);
125
122
  editor.insertText(range.index, fieldCode);
126
- });
123
+ };
127
124
 
128
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onImageConfirm", function (image) {
125
+ _this.onImageConfirm = function (image) {
129
126
  if (!image) {
130
127
  return;
131
128
  }
@@ -134,23 +131,23 @@ var DSWYSIWYGEditorImpl = /*#__PURE__*/function (_React$PureComponent) {
134
131
 
135
132
  var range = editor.getSelection(true);
136
133
  editor.insertEmbed(range.index, 'image', image.url);
137
- });
134
+ };
138
135
 
139
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onFieldModalClose", function () {
136
+ _this.onFieldModalClose = function () {
140
137
  _this.setState({
141
138
  isFieldModalOpen: false
142
139
  });
143
- });
140
+ };
144
141
 
145
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onImageModalClose", function () {
142
+ _this.onImageModalClose = function () {
146
143
  _this.setState({
147
144
  isImageModalOpen: false
148
145
  });
149
- });
146
+ };
150
147
 
151
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "quillRef", function (ref) {
148
+ _this.quillRef = function (ref) {
152
149
  _this.quill = ref;
153
- });
150
+ };
154
151
 
155
152
  ReactQuill.Quill.register(quillOverrides_LinkFormat, true);
156
153
 
@@ -1 +1 @@
1
- {"version":3,"file":"DSWYSIWYGEditorImpl.js","sources":["../../../src/components/DSWYSIWYGEditorImpl.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport ReactQuill, { Quill } from 'react-quill';\nimport BlotFormatter from 'quill-blot-formatter';\n\nimport ImageLibraryModal from './ImageLibraryModal';\nimport InsertFieldModal from './InsertFieldModal';\nimport { CustomToolbar } from './CustomToolbar';\nimport IndentStyle from '../quillOverrides/IndentStyle';\nimport LinkFormat from '../quillOverrides/LinkFormat';\nimport { formatHTML } from '../utils';\nimport { clipboardLinkWithTagMatcher } from '../quillMatchers/clipboardLinkWithTagMatcher';\n\nQuill.register('modules/blotFormatter', BlotFormatter);\n\n// Fix block styled formats ----------------\nconst AlignStyle = Quill.import('attributors/style/align');\nconst FontStyle = Quill.import('attributors/style/font');\nFontStyle.whitelist = [\n // allow ONLY these fonts and the default\n 'serif',\n 'monospace',\n 'arial',\n 'comic-sans',\n 'courier-new',\n 'georgia',\n 'helvetica',\n 'lucida',\n];\nconst SizeStyle = Quill.import('attributors/style/size');\nSizeStyle.whitelist = [\n // allow ONLY these sizes and the default\n 'x-small',\n 'large',\n 'x-large',\n];\n\n// Fix Doc Viewer p tags extra margin issue ---------\nconst Block = Quill.import('blots/block');\nBlock.tagName = 'p';\nQuill.register(Block);\n\nQuill.register(AlignStyle, true);\nQuill.register(IndentStyle, true);\nQuill.register(FontStyle, true);\nQuill.register(SizeStyle, true);\n// -----------------------------------------\n\nexport default class DSWYSIWYGEditorImpl extends React.PureComponent {\n quillModules = {\n toolbar: {\n container: this.props.toolbarContainer ? `#${this.props.toolbarContainer}` : '#toolbar',\n handlers: {\n ...this.props.toolbarHandlers,\n },\n },\n clipboard: {\n // toggle to add extra line breaks when pasting HTML:\n matchVisual: false,\n },\n blotFormatter: {\n // options... https://github.com/Fandom-OSS/quill-blot-formatter\n },\n ...this.props.quillModules,\n };\n\n constructor(props) {\n super(props);\n Quill.register(LinkFormat, true);\n if (props.quillOverrides.length) {\n props.quillOverrides.map((override) => Quill.register(override, true));\n }\n this.state = {\n isImageModalOpen: false,\n isFieldModalOpen: false,\n };\n const { toolbar } = this.quillModules;\n if (props.imagesData) {\n toolbar.handlers.image = (value) => {\n const { imagesData, handleImageClick } = this.props;\n if (!imagesData.length) {\n return;\n }\n this.setState({ isImageModalOpen: !!value });\n handleImageClick(value);\n };\n }\n if (props.customFields) {\n toolbar.handlers.customFields = (value) => {\n const { customFields, handleCustomFieldClick } = this.props;\n if (!customFields.length) {\n return;\n }\n this.setState({ isFieldModalOpen: !!value });\n handleCustomFieldClick(value);\n };\n }\n }\n\n componentDidMount() {\n // this.quill doesn't exist untill the full call-stack execute\n // we need to \"setTimeout\" so this componentDidMount work as expected\n setTimeout(() => {\n const quillDomRef = this.quill;\n const editor = quillDomRef.getEditor();\n this.props.getQuillRef(quillDomRef);\n // https://github.com/quilljs/quill/issues/2677\n editor.clipboard.addMatcher('a', clipboardLinkWithTagMatcher);\n });\n }\n\n // eslint-disable-next-line max-params\n onChangeQuill = (html, delta, source, editor) => {\n const { showRawHTML, onChange } = this.props;\n if (!showRawHTML) onChange(html, delta, source, editor);\n };\n\n onChangeTextArea = (e) => {\n const { showRawHTML, onChange } = this.props;\n if (showRawHTML) onChange(e.target.value);\n };\n\n onInserFieldConfirm = (fieldCode) => {\n const editor = this.getEditor();\n const range = editor.getSelection(true);\n editor.insertText(range.index, fieldCode);\n };\n\n onImageConfirm = (image) => {\n if (!image) {\n return;\n }\n const editor = this.getEditor();\n const range = editor.getSelection(true);\n editor.insertEmbed(range.index, 'image', image.url);\n };\n\n onFieldModalClose = () => {\n this.setState({ isFieldModalOpen: false });\n };\n\n onImageModalClose = () => {\n this.setState({ isImageModalOpen: false });\n };\n\n getEditor() {\n return this.quill.getEditor();\n }\n\n quillRef = (ref) => {\n this.quill = ref;\n };\n\n render() {\n const { isFieldModalOpen, isImageModalOpen } = this.state;\n const {\n containerProps = {},\n customFields,\n imagesData,\n customToolbar,\n handleImageClick,\n handleCustomFieldClick,\n height,\n value,\n showRawHTML,\n onShowHTML,\n onChange,\n hideItems,\n ...editorProps\n } = this.props;\n\n return (\n <div\n // data-testid=\"wysiwyg-text-container\"\n {...containerProps}\n className={`quill-wysiwyg-editor ${showRawHTML ? 'show-raw' : ''}`}\n >\n {customToolbar || (\n <CustomToolbar\n customFields={customFields}\n onShowHTML={onShowHTML}\n hideItems={hideItems}\n userProps={this.props}\n />\n )}\n <ReactQuill\n ref={this.quillRef}\n modules={this.quillModules}\n onChange={this.onChangeQuill}\n value={value}\n style={{\n height,\n borderBottom: '1px solid #ccc',\n }}\n {...editorProps}\n id=\"wysiwyg-text-container\"\n />\n <textarea\n className=\"raw-editor ql-container ql-snow ql-editor\"\n style={{\n width: '100%',\n resize: 'none',\n height,\n minHeight: '200px',\n }}\n onChange={this.onChangeTextArea}\n value={formatHTML(value)}\n />\n {imagesData && imagesData.length && (\n <ImageLibraryModal\n imagesData={imagesData}\n isOpen={isImageModalOpen}\n onClose={this.onImageModalClose}\n onConfirm={this.onImageConfirm}\n />\n )}\n {customFields && customFields.length && (\n <InsertFieldModal\n customFields={customFields}\n isOpen={isFieldModalOpen}\n onClose={this.onFieldModalClose}\n onConfirm={this.onInserFieldConfirm}\n />\n )}\n </div>\n );\n }\n}\n"],"names":["Quill","register","BlotFormatter","AlignStyle","import","FontStyle","whitelist","SizeStyle","Block","tagName","IndentStyle","DSWYSIWYGEditorImpl","props","toolbar","container","toolbarContainer","handlers","toolbarHandlers","clipboard","matchVisual","blotFormatter","quillModules","html","delta","source","editor","showRawHTML","onChange","e","target","value","fieldCode","getEditor","range","getSelection","insertText","index","image","insertEmbed","url","setState","isFieldModalOpen","isImageModalOpen","ref","quill","LinkFormat","quillOverrides","length","map","override","state","imagesData","handleImageClick","customFields","handleCustomFieldClick","setTimeout","quillDomRef","getQuillRef","addMatcher","clipboardLinkWithTagMatcher","containerProps","customToolbar","height","onShowHTML","hideItems","editorProps","React","CustomToolbar","ReactQuill","quillRef","onChangeQuill","borderBottom","width","resize","minHeight","onChangeTextArea","formatHTML","ImageLibraryModal","onImageModalClose","onImageConfirm","InsertFieldModal","onFieldModalClose","onInserFieldConfirm","PureComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcAA,gBAAK,CAACC,QAAN,CAAe,uBAAf,EAAwCC,iCAAxC;;AAGA,IAAMC,UAAU,GAAGH,gBAAK,CAACI,MAAN,CAAa,yBAAb,CAAnB;AACA,IAAMC,SAAS,GAAGL,gBAAK,CAACI,MAAN,CAAa,wBAAb,CAAlB;AACAC,SAAS,CAACC,SAAV,GAAsB;AAEpB,OAFoB,EAGpB,WAHoB,EAIpB,OAJoB,EAKpB,YALoB,EAMpB,aANoB,EAOpB,SAPoB,EAQpB,WARoB,EASpB,QAToB,CAAtB;AAWA,IAAMC,SAAS,GAAGP,gBAAK,CAACI,MAAN,CAAa,wBAAb,CAAlB;AACAG,SAAS,CAACD,SAAV,GAAsB;AAEpB,SAFoB,EAGpB,OAHoB,EAIpB,SAJoB,CAAtB;;AAQA,IAAME,KAAK,GAAGR,gBAAK,CAACI,MAAN,CAAa,aAAb,CAAd;AACAI,KAAK,CAACC,OAAN,GAAgB,GAAhB;AACAT,gBAAK,CAACC,QAAN,CAAeO,KAAf;AAEAR,gBAAK,CAACC,QAAN,CAAeE,UAAf,EAA2B,IAA3B;AACAH,gBAAK,CAACC,QAAN,CAAeS,0BAAf,EAA4B,IAA5B;AACAV,gBAAK,CAACC,QAAN,CAAeI,SAAf,EAA0B,IAA1B;AACAL,gBAAK,CAACC,QAAN,CAAeM,SAAf,EAA0B,IAA1B;;IAGqBI;;;;;AAkBnB,+BAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB;AAhBjBC,MAAAA,OAAO,EAAE;AACPC,QAAAA,SAAS,EAAE,MA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,EA4CG1B,YAAY,IAAIA,YAAY,CAACN,MAA7B,iBACCmB,wCAACc,2BAAD;AACE,QAAA,YAAY,EAAE3B,YADhB;AAEE,QAAA,MAAM,EAAEZ,gBAFV;AAGE,QAAA,OAAO,EAAE,KAAKwC,iBAHhB;AAIE,QAAA,SAAS,EAAE,KAAKC;AAJlB,QA7CJ,CADF;AAuDD;;;;EAlL8ChB,yBAAK,CAACiB;;;;"}
1
+ {"version":3,"file":"DSWYSIWYGEditorImpl.js","sources":["../../../src/components/DSWYSIWYGEditorImpl.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport ReactQuill, { Quill } from 'react-quill';\nimport BlotFormatter from 'quill-blot-formatter';\n\nimport ImageLibraryModal from './ImageLibraryModal';\nimport InsertFieldModal from './InsertFieldModal';\nimport { CustomToolbar } from './CustomToolbar';\nimport IndentStyle from '../quillOverrides/IndentStyle';\nimport LinkFormat from '../quillOverrides/LinkFormat';\nimport { formatHTML } from '../utils';\nimport { clipboardLinkWithTagMatcher } from '../quillMatchers/clipboardLinkWithTagMatcher';\n\nQuill.register('modules/blotFormatter', BlotFormatter);\n\n// Fix block styled formats ----------------\nconst AlignStyle = Quill.import('attributors/style/align');\nconst FontStyle = Quill.import('attributors/style/font');\nFontStyle.whitelist = [\n // allow ONLY these fonts and the default\n 'serif',\n 'monospace',\n 'arial',\n 'comic-sans',\n 'courier-new',\n 'georgia',\n 'helvetica',\n 'lucida',\n];\nconst SizeStyle = Quill.import('attributors/style/size');\nSizeStyle.whitelist = [\n // allow ONLY these sizes and the default\n 'x-small',\n 'large',\n 'x-large',\n];\n\n// Fix Doc Viewer p tags extra margin issue ---------\nconst Block = Quill.import('blots/block');\nBlock.tagName = 'p';\nQuill.register(Block);\n\nQuill.register(AlignStyle, true);\nQuill.register(IndentStyle, true);\nQuill.register(FontStyle, true);\nQuill.register(SizeStyle, true);\n// -----------------------------------------\n\nexport default class DSWYSIWYGEditorImpl extends React.PureComponent {\n quillModules = {\n toolbar: {\n container: this.props.toolbarContainer ? `#${this.props.toolbarContainer}` : '#toolbar',\n handlers: {\n ...this.props.toolbarHandlers,\n },\n },\n clipboard: {\n // toggle to add extra line breaks when pasting HTML:\n matchVisual: false,\n },\n blotFormatter: {\n // options... https://github.com/Fandom-OSS/quill-blot-formatter\n },\n ...this.props.quillModules,\n };\n\n constructor(props) {\n super(props);\n Quill.register(LinkFormat, true);\n if (props.quillOverrides.length) {\n props.quillOverrides.map((override) => Quill.register(override, true));\n }\n this.state = {\n isImageModalOpen: false,\n isFieldModalOpen: false,\n };\n const { toolbar } = this.quillModules;\n if (props.imagesData) {\n toolbar.handlers.image = (value) => {\n const { imagesData, handleImageClick } = this.props;\n if (!imagesData.length) {\n return;\n }\n this.setState({ isImageModalOpen: !!value });\n handleImageClick(value);\n };\n }\n if (props.customFields) {\n toolbar.handlers.customFields = (value) => {\n const { customFields, handleCustomFieldClick } = this.props;\n if (!customFields.length) {\n return;\n }\n this.setState({ isFieldModalOpen: !!value });\n handleCustomFieldClick(value);\n };\n }\n }\n\n componentDidMount() {\n // this.quill doesn't exist untill the full call-stack execute\n // we need to \"setTimeout\" so this componentDidMount work as expected\n setTimeout(() => {\n const quillDomRef = this.quill;\n const editor = quillDomRef.getEditor();\n this.props.getQuillRef(quillDomRef);\n // https://github.com/quilljs/quill/issues/2677\n editor.clipboard.addMatcher('a', clipboardLinkWithTagMatcher);\n });\n }\n\n // eslint-disable-next-line max-params\n onChangeQuill = (html, delta, source, editor) => {\n const { showRawHTML, onChange } = this.props;\n if (!showRawHTML) onChange(html, delta, source, editor);\n };\n\n onChangeTextArea = (e) => {\n const { showRawHTML, onChange } = this.props;\n if (showRawHTML) onChange(e.target.value);\n };\n\n onInserFieldConfirm = (fieldCode) => {\n const editor = this.getEditor();\n const range = editor.getSelection(true);\n editor.insertText(range.index, fieldCode);\n };\n\n onImageConfirm = (image) => {\n if (!image) {\n return;\n }\n const editor = this.getEditor();\n const range = editor.getSelection(true);\n editor.insertEmbed(range.index, 'image', image.url);\n };\n\n onFieldModalClose = () => {\n this.setState({ isFieldModalOpen: false });\n };\n\n onImageModalClose = () => {\n this.setState({ isImageModalOpen: false });\n };\n\n getEditor() {\n return this.quill.getEditor();\n }\n\n quillRef = (ref) => {\n this.quill = ref;\n };\n\n render() {\n const { isFieldModalOpen, isImageModalOpen } = this.state;\n const {\n containerProps = {},\n customFields,\n imagesData,\n customToolbar,\n handleImageClick,\n handleCustomFieldClick,\n height,\n value,\n showRawHTML,\n onShowHTML,\n onChange,\n hideItems,\n ...editorProps\n } = this.props;\n\n return (\n <div\n // data-testid=\"wysiwyg-text-container\"\n {...containerProps}\n className={`quill-wysiwyg-editor ${showRawHTML ? 'show-raw' : ''}`}\n >\n {customToolbar || (\n <CustomToolbar\n customFields={customFields}\n onShowHTML={onShowHTML}\n hideItems={hideItems}\n userProps={this.props}\n />\n )}\n <ReactQuill\n ref={this.quillRef}\n modules={this.quillModules}\n onChange={this.onChangeQuill}\n value={value}\n style={{\n height,\n borderBottom: '1px solid #ccc',\n }}\n {...editorProps}\n id=\"wysiwyg-text-container\"\n />\n <textarea\n className=\"raw-editor ql-container ql-snow ql-editor\"\n style={{\n width: '100%',\n resize: 'none',\n height,\n minHeight: '200px',\n }}\n onChange={this.onChangeTextArea}\n value={formatHTML(value)}\n />\n {imagesData && imagesData.length && (\n <ImageLibraryModal\n imagesData={imagesData}\n isOpen={isImageModalOpen}\n onClose={this.onImageModalClose}\n onConfirm={this.onImageConfirm}\n />\n )}\n {customFields && customFields.length && (\n <InsertFieldModal\n customFields={customFields}\n isOpen={isFieldModalOpen}\n onClose={this.onFieldModalClose}\n onConfirm={this.onInserFieldConfirm}\n />\n )}\n </div>\n );\n }\n}\n"],"names":["Quill","register","BlotFormatter","AlignStyle","import","FontStyle","whitelist","SizeStyle","Block","tagName","IndentStyle","DSWYSIWYGEditorImpl","props","quillModules","toolbar","container","toolbarContainer","handlers","toolbarHandlers","clipboard","matchVisual","blotFormatter","onChangeQuill","html","delta","source","editor","showRawHTML","onChange","onChangeTextArea","e","target","value","onInserFieldConfirm","fieldCode","getEditor","range","getSelection","insertText","index","onImageConfirm","image","insertEmbed","url","onFieldModalClose","setState","isFieldModalOpen","onImageModalClose","isImageModalOpen","quillRef","ref","quill","LinkFormat","quillOverrides","length","map","override","state","imagesData","handleImageClick","customFields","handleCustomFieldClick","setTimeout","quillDomRef","getQuillRef","addMatcher","clipboardLinkWithTagMatcher","containerProps","customToolbar","height","onShowHTML","hideItems","editorProps","React","CustomToolbar","ReactQuill","borderBottom","width","resize","minHeight","formatHTML","ImageLibraryModal","InsertFieldModal","PureComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcAA,gBAAK,CAACC,QAAN,CAAe,uBAAf,EAAwCC,iCAAxC;;AAGA,IAAMC,UAAU,GAAGH,gBAAK,CAACI,MAAN,CAAa,yBAAb,CAAnB;AACA,IAAMC,SAAS,GAAGL,gBAAK,CAACI,MAAN,CAAa,wBAAb,CAAlB;AACAC,SAAS,CAACC,SAAV,GAAsB;AAEpB,OAFoB,EAGpB,WAHoB,EAIpB,OAJoB,EAKpB,YALoB,EAMpB,aANoB,EAOpB,SAPoB,EAQpB,WARoB,EASpB,QAToB,CAAtB;AAWA,IAAMC,SAAS,GAAGP,gBAAK,CAACI,MAAN,CAAa,wBAAb,CAAlB;AACAG,SAAS,CAACD,SAAV,GAAsB;AAEpB,SAFoB,EAGpB,OAHoB,EAIpB,SAJoB,CAAtB;;AAQA,IAAME,KAAK,GAAGR,gBAAK,CAACI,MAAN,CAAa,aAAb,CAAd;AACAI,KAAK,CAACC,OAAN,GAAgB,GAAhB;AACAT,gBAAK,CAACC,QAAN,CAAeO,KAAf;AAEAR,gBAAK,CAACC,QAAN,CAAeE,UAAf,EAA2B,IAA3B;AACAH,gBAAK,CAACC,QAAN,CAAeS,0BAAf,EAA4B,IAA5B;AACAV,g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MAFH;AAGLT,UAAAA,MAAM,EAANA,MAHK;AAILU,UAAAA,SAAS,EAAE;AAJN,SAFT;AAQE,QAAA,QAAQ,EAAE,KAAKlD,gBARjB;AASE,QAAA,KAAK,EAAEmD,gBAAU,CAAChD,KAAD;AATnB,QAzBF,EAoCG0B,UAAU,IAAIA,UAAU,CAACJ,MAAzB,iBACCmB,wCAACQ,4BAAD;AACE,QAAA,UAAU,EAAEvB,UADd;AAEE,QAAA,MAAM,EAAEV,gBAFV;AAGE,QAAA,OAAO,EAAE,KAAKD,iBAHhB;AAIE,QAAA,SAAS,EAAE,KAAKP;AAJlB,QArCJ,EA4CGoB,YAAY,IAAIA,YAAY,CAACN,MAA7B,iBACCmB,wCAACS,2BAAD;AACE,QAAA,YAAY,EAAEtB,YADhB;AAEE,QAAA,MAAM,EAAEd,gBAFV;AAGE,QAAA,OAAO,EAAE,KAAKF,iBAHhB;AAIE,QAAA,SAAS,EAAE,KAAKX;AAJlB,QA7CJ,CADF;AAuDD;;;;EAlL8CwC,yBAAK,CAACU;;;;"}
@@ -3,11 +3,9 @@
3
3
  var _extends = require('@babel/runtime/helpers/extends');
4
4
  var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
5
5
  var _createClass = require('@babel/runtime/helpers/createClass');
6
- var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
7
6
  var _inherits = require('@babel/runtime/helpers/inherits');
8
7
  var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
9
8
  var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
10
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
9
  var React = require('react');
12
10
  var DSImageLibraryModal = require('@elliemae/ds-imagelibrarymodal');
13
11
  var PropTypes = require('prop-types');
@@ -17,11 +15,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
17
15
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
18
16
  var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
19
17
  var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
20
- var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
21
18
  var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
22
19
  var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
23
20
  var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
24
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
25
21
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
26
22
  var DSImageLibraryModal__default = /*#__PURE__*/_interopDefaultLegacy(DSImageLibraryModal);
27
23
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
@@ -42,20 +38,20 @@ var ImageLibraryModal = /*#__PURE__*/function (_React$PureComponent) {
42
38
 
43
39
  _this = _super.call(this, props);
44
40
 
45
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onSelect", function (selectedImage) {
41
+ _this.onSelect = function (selectedImage) {
46
42
  _this.setState({
47
43
  selectedImage: selectedImage
48
44
  });
49
- });
45
+ };
50
46
 
51
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onConfirm", function () {
47
+ _this.onConfirm = function () {
52
48
  var selectedImage = _this.state.selectedImage;
53
49
  var _this$props = _this.props,
54
50
  onConfirm = _this$props.onConfirm,
55
51
  onClose = _this$props.onClose;
56
52
  onConfirm(selectedImage);
57
53
  onClose();
58
- });
54
+ };
59
55
 
60
56
  _this.state = {
61
57
  selectedImage: undefined
@@ -76,7 +72,7 @@ var ImageLibraryModal = /*#__PURE__*/function (_React$PureComponent) {
76
72
  return ImageLibraryModal;
77
73
  }(React__default['default'].PureComponent);
78
74
 
79
- _defineProperty__default['default'](ImageLibraryModal, "propTypes", {
75
+ ImageLibraryModal.propTypes = {
80
76
  onConfirm: PropTypes__default['default'].func.isRequired,
81
77
  onClose: PropTypes__default['default'].func.isRequired,
82
78
  onReject: PropTypes__default['default'].func,
@@ -89,9 +85,8 @@ _defineProperty__default['default'](ImageLibraryModal, "propTypes", {
89
85
  createdDate: PropTypes__default['default'].string.isRequired
90
86
  })),
91
87
  isOpen: PropTypes__default['default'].bool.isRequired
92
- });
93
-
94
- _defineProperty__default['default'](ImageLibraryModal, "defaultProps", {
88
+ };
89
+ ImageLibraryModal.defaultProps = {
95
90
  onReject: undefined,
96
91
  imagesData: [{
97
92
  url: 'https://www.freeiconspng.com/minicovers/no-image-icon-6.png',
@@ -104,7 +99,7 @@ _defineProperty__default['default'](ImageLibraryModal, "defaultProps", {
104
99
  createdBy: 'user:Jane Doe',
105
100
  createdDate: '0000-01-01 00:00 AM UTC'
106
101
  }]
107
- });
102
+ };
108
103
 
109
104
  module.exports = ImageLibraryModal;
110
105
  //# sourceMappingURL=ImageLibraryModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImageLibraryModal.js","sources":["../../../src/components/ImageLibraryModal.tsx"],"sourcesContent":["import React from 'react';\nimport DSImageLibraryModal from '@elliemae/ds-imagelibrarymodal';\nimport PropTypes from 'prop-types';\n\nexport default class ImageLibraryModal extends React.PureComponent {\n static propTypes = {\n onConfirm: PropTypes.func.isRequired,\n onClose: PropTypes.func.isRequired,\n onReject: PropTypes.func,\n imagesData: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string,\n url: PropTypes.string.isRequired,\n name: PropTypes.string.isRequired,\n description: PropTypes.string,\n createdBy: PropTypes.string.isRequired,\n createdDate: PropTypes.string.isRequired,\n }),\n ),\n isOpen: PropTypes.bool.isRequired,\n };\n\n static defaultProps = {\n onReject: undefined,\n imagesData: [\n {\n url: 'https://www.freeiconspng.com/minicovers/no-image-icon-6.png',\n name: 'no image',\n createdBy: 'user:John Doe',\n createdDate: '0000-01-01 00:00 AM UTC',\n },\n {\n url:\n 'https://asset-service-bucket-int.s3.us-west-2.amazonaws.com/bd527d8c-472f-4dff-b8c5-1c90d5bae01e',\n name: 'no image 2',\n createdBy: 'user:Jane Doe',\n createdDate: '0000-01-01 00:00 AM UTC',\n },\n ],\n };\n\n constructor(props) {\n super(props);\n this.state = {\n selectedImage: undefined,\n };\n }\n\n onSelect = selectedImage => {\n this.setState({ selectedImage });\n };\n\n onConfirm = () => {\n const { selectedImage } = this.state;\n const { onConfirm, onClose } = this.props;\n onConfirm(selectedImage);\n onClose();\n };\n\n render() {\n return (\n <DSImageLibraryModal\n {...this.props}\n onConfirm={this.onConfirm}\n onSelect={this.onSelect}\n />\n );\n }\n}\n"],"names":["ImageLibraryModal","props","selectedImage","setState","state","onConfirm","onClose","undefined","React","DSImageLibraryModal","onSelect","PureComponent","PropTypes","func","isRequired","onReject","imagesData","arrayOf","shape","id","string","url","name","description","createdBy","createdDate","isOpen","bool"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIqBA;;;;;AAqCnB,6BAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,uGAOR,UAAAC,aAAa,EAAI;AAC1B,YAAKC,QAAL,CAAc;AAAED,QAAAA,aAAa,EAAbA;AAAF,OAAd;AACD,KATkB;;AAAA,wGAWP,YAAM;AAChB,UAAQA,aAAR,GAA0B,MAAKE,KAA/B,CAAQF,aAAR;AACA,wBAA+B,MAAKD,KAApC;AAAA,UAAQI,SAAR,eAAQA,SAAR;AAAA,UAAmBC,OAAnB,eAAmBA,OAAnB;AACAD,MAAAA,SAAS,CAACH,aAAD,CAAT;AACAI,MAAAA,OAAO;AACR,KAhBkB;;AAEjB,UAAKF,KAAL,GAAa;AACXF,MAAAA,aAAa,EAAEK;AADJ,KAAb;AAFiB;AAKlB;;;;WAaD,kBAAS;AACP,0BACEC,wCAACC,uCAAD,mCACM,KAAKR,KADX;AAEE,QAAA,SAAS,EAAE,KAAKI,SAFlB;AAGE,QAAA,QAAQ,EAAE,KAAKK;AAHjB,SADF;AAOD;;;;EA/D4CF,yBAAK,CAACG;;oCAAhCX,gCACA;AACjBK,EAAAA,SAAS,EAAEO,6BAAS,CAACC,IAAV,CAAeC,UADT;AAEjBR,EAAAA,OAAO,EAAEM,6BAAS,CAACC,IAAV,CAAeC,UAFP;AAGjBC,EAAAA,QAAQ,EAAEH,6BAAS,CAACC,IAHH;AAIjBG,EAAAA,UAAU,EAAEJ,6BAAS,CAACK,OAAV,CACVL,6BAAS,CAACM,KAAV,CAAgB;AACdC,IAAAA,EAAE,EAAEP,6BAAS,CAACQ,MADA;AAEdC,IAAAA,GAAG,EAAET,6BAAS,CAACQ,MAAV,CAAiBN,UAFR;AAGdQ,IAAAA,IAAI,EAAEV,6BAAS,CAACQ,MAAV,CAAiBN,UAHT;AAIdS,IAAAA,WAAW,EAAEX,6BAAS,CAACQ,MAJT;AAKdI,IAAAA,SAAS,EAAEZ,6BAAS,CAACQ,MAAV,CAAiBN,UALd;AAMdW,IAAAA,WAAW,EAAEb,6BAAS,CAACQ,MAAV,CAAiBN;AANhB,GAAhB,CADU,CAJK;AAcjBY,EAAAA,MAAM,EAAEd,6BAAS,CAACe,IAAV,CAAeb;AAdN;;oCADAd,mCAkBG;AACpBe,EAAAA,QAAQ,EAAER,SADU;AAEpBS,EAAAA,UAAU,EAAE,CACV;AACEK,IAAAA,GAAG,EAAE,6DADP;AAEEC,IAAAA,IAAI,EAAE,UAFR;AAGEE,IAAAA,SAAS,EAAE,eAHb;AAIEC,IAAAA,WAAW,EAAE;AAJf,GADU,EAOV;AACEJ,IAAAA,GAAG,EACD,kGAFJ;AAGEC,IAAAA,IAAI,EAAE,YAHR;AAIEE,IAAAA,SAAS,EAAE,eAJb;AAKEC,IAAAA,WAAW,EAAE;AALf,GAPU;AAFQ;;;;"}
1
+ {"version":3,"file":"ImageLibraryModal.js","sources":["../../../src/components/ImageLibraryModal.tsx"],"sourcesContent":["import React from 'react';\nimport DSImageLibraryModal from '@elliemae/ds-imagelibrarymodal';\nimport PropTypes from 'prop-types';\n\nexport default class ImageLibraryModal extends React.PureComponent {\n static propTypes = {\n onConfirm: PropTypes.func.isRequired,\n onClose: PropTypes.func.isRequired,\n onReject: PropTypes.func,\n imagesData: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string,\n url: PropTypes.string.isRequired,\n name: PropTypes.string.isRequired,\n description: PropTypes.string,\n createdBy: PropTypes.string.isRequired,\n createdDate: PropTypes.string.isRequired,\n }),\n ),\n isOpen: PropTypes.bool.isRequired,\n };\n\n static defaultProps = {\n onReject: undefined,\n imagesData: [\n {\n url: 'https://www.freeiconspng.com/minicovers/no-image-icon-6.png',\n name: 'no image',\n createdBy: 'user:John Doe',\n createdDate: '0000-01-01 00:00 AM UTC',\n },\n {\n url:\n 'https://asset-service-bucket-int.s3.us-west-2.amazonaws.com/bd527d8c-472f-4dff-b8c5-1c90d5bae01e',\n name: 'no image 2',\n createdBy: 'user:Jane Doe',\n createdDate: '0000-01-01 00:00 AM UTC',\n },\n ],\n };\n\n constructor(props) {\n super(props);\n this.state = {\n selectedImage: undefined,\n };\n }\n\n onSelect = selectedImage => {\n this.setState({ selectedImage });\n };\n\n onConfirm = () => {\n const { selectedImage } = this.state;\n const { onConfirm, onClose } = this.props;\n onConfirm(selectedImage);\n onClose();\n };\n\n render() {\n return (\n <DSImageLibraryModal\n {...this.props}\n onConfirm={this.onConfirm}\n onSelect={this.onSelect}\n />\n );\n }\n}\n"],"names":["ImageLibraryModal","props","onSelect","selectedImage","setState","onConfirm","state","onClose","undefined","React","DSImageLibraryModal","PureComponent","propTypes","PropTypes","func","isRequired","onReject","imagesData","arrayOf","shape","id","string","url","name","description","createdBy","createdDate","isOpen","bool","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIqBA;;;;;AAqCnB,6BAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,UAOnBC,QAPmB,GAOR,UAAAC,aAAa,EAAI;AAC1B,YAAKC,QAAL,C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,6BAAS,CAACe,IAAV,CAAeb;AAdN;AADAf,kBAkBZ6B,eAAe;AACpBb,EAAAA,QAAQ,EAAER,SADU;AAEpBS,EAAAA,UAAU,EAAE,CACV;AACEK,IAAAA,GAAG,EAAE,6DADP;AAEEC,IAAAA,IAAI,EAAE,UAFR;AAGEE,IAAAA,SAAS,EAAE,eAHb;AAIEC,IAAAA,WAAW,EAAE;AAJf,GADU,EAOV;AACEJ,IAAAA,GAAG,EACD,kGAFJ;AAGEC,IAAAA,IAAI,EAAE,YAHR;AAIEE,IAAAA,SAAS,EAAE,eAJb;AAKEC,IAAAA,WAAW,EAAE;AALf,GAPU;AAFQ;;;;"}
@@ -4,11 +4,9 @@ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProp
4
4
  var _extends = require('@babel/runtime/helpers/extends');
5
5
  var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
6
6
  var _createClass = require('@babel/runtime/helpers/createClass');
7
- var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
8
7
  var _inherits = require('@babel/runtime/helpers/inherits');
9
8
  var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
10
9
  var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
11
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
12
10
  var React = require('react');
13
11
  var PropTypes = require('prop-types');
14
12
  var DSModal = require('@elliemae/ds-modal');
@@ -22,11 +20,9 @@ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_obje
22
20
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
23
21
  var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
24
22
  var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
25
- var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
26
23
  var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
27
24
  var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
28
25
  var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
29
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
30
26
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
31
27
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
32
28
  var DSModal__default = /*#__PURE__*/_interopDefaultLegacy(DSModal);
@@ -51,16 +47,16 @@ var InsertFieldModal = /*#__PURE__*/function (_React$PureComponent) {
51
47
 
52
48
  _this = _super.call(this, props);
53
49
 
54
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onConfirm", function () {
50
+ _this.onConfirm = function () {
55
51
  var _this$props = _this.props,
56
52
  onConfirm = _this$props.onConfirm,
57
53
  onClose = _this$props.onClose;
58
54
  var selectedFieldCode = _this.state.selectedFieldCode;
59
55
  onConfirm(selectedFieldCode);
60
56
  onClose();
61
- });
57
+ };
62
58
 
63
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onReject", function () {
59
+ _this.onReject = function () {
64
60
  var _this$props2 = _this.props,
65
61
  onReject = _this$props2.onReject,
66
62
  onClose = _this$props2.onClose;
@@ -70,15 +66,15 @@ var InsertFieldModal = /*#__PURE__*/function (_React$PureComponent) {
70
66
  } else {
71
67
  onClose();
72
68
  }
73
- });
69
+ };
74
70
 
75
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "drawDiv", function (className, content, content2) {
71
+ _this.drawDiv = function (className, content, content2) {
76
72
  return /*#__PURE__*/React__default['default'].createElement("div", {
77
73
  className: className
78
74
  }, /*#__PURE__*/React__default['default'].createElement("span", null, content), /*#__PURE__*/React__default['default'].createElement("span", null, content2));
79
- });
75
+ };
80
76
 
81
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "drawLabel", function (className, label, value) {
77
+ _this.drawLabel = function (className, label, value) {
82
78
  return /*#__PURE__*/React__default['default'].createElement("div", {
83
79
  className: className
84
80
  }, /*#__PURE__*/React__default['default'].createElement("span", {
@@ -86,9 +82,9 @@ var InsertFieldModal = /*#__PURE__*/function (_React$PureComponent) {
86
82
  }, label), /*#__PURE__*/React__default['default'].createElement("span", {
87
83
  className: "value"
88
84
  }, value));
89
- });
85
+ };
90
86
 
91
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "handleElementClick", function (e, selectedFieldCode) {
87
+ _this.handleElementClick = function (e, selectedFieldCode) {
92
88
  if (e.key && e.key !== ' ') {
93
89
  return;
94
90
  }
@@ -111,9 +107,9 @@ var InsertFieldModal = /*#__PURE__*/function (_React$PureComponent) {
111
107
  if (onSelect) {
112
108
  onSelect(selectedFieldCode);
113
109
  }
114
- });
110
+ };
115
111
 
116
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "preventSpacebarScroll", function () {
112
+ _this.preventSpacebarScroll = function () {
117
113
  document.onkeypress = function (e) {
118
114
  if (!lodash.includes(e.target.className, elementClassName)) {
119
115
  return true;
@@ -129,9 +125,9 @@ var InsertFieldModal = /*#__PURE__*/function (_React$PureComponent) {
129
125
 
130
126
  return true;
131
127
  };
132
- });
128
+ };
133
129
 
134
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "renderElements", function () {
130
+ _this.renderElements = function () {
135
131
  var customFields = _this.props.customFields;
136
132
 
137
133
  if (!customFields) {
@@ -168,7 +164,7 @@ var InsertFieldModal = /*#__PURE__*/function (_React$PureComponent) {
168
164
  tabIndex: 0
169
165
  }, extras), _this.drawLabel('content', components_customFields.getFieldName(customField), fieldCode));
170
166
  });
171
- });
167
+ };
172
168
 
173
169
  _this.state = {
174
170
  selectedFieldCode: components_customFields.getFieldCode(components_customFields.fields[0])
@@ -223,7 +219,7 @@ var InsertFieldModal = /*#__PURE__*/function (_React$PureComponent) {
223
219
  return InsertFieldModal;
224
220
  }(React__default['default'].PureComponent);
225
221
 
226
- _defineProperty__default['default'](InsertFieldModal, "propTypes", {
222
+ InsertFieldModal.propTypes = {
227
223
  onConfirm: PropTypes__default['default'].func.isRequired,
228
224
  onClose: PropTypes__default['default'].func.isRequired,
229
225
  confirmLabel: PropTypes__default['default'].string,
@@ -236,9 +232,8 @@ _defineProperty__default['default'](InsertFieldModal, "propTypes", {
236
232
  shouldCloseOnOverlayClick: PropTypes__default['default'].bool,
237
233
  size: PropTypes__default['default'].string,
238
234
  onSelect: PropTypes__default['default'].func
239
- });
240
-
241
- _defineProperty__default['default'](InsertFieldModal, "defaultProps", {
235
+ };
236
+ InsertFieldModal.defaultProps = {
242
237
  confirmLabel: 'Add',
243
238
  customFields: components_customFields.fields,
244
239
  disableDoubleClick: false,
@@ -249,7 +244,7 @@ _defineProperty__default['default'](InsertFieldModal, "defaultProps", {
249
244
  shouldCloseOnOverlayClick: true,
250
245
  size: constants.sizeOptions[1],
251
246
  onSelect: undefined
252
- });
247
+ };
253
248
 
254
249
  module.exports = InsertFieldModal;
255
250
  //# sourceMappingURL=InsertFieldModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InsertFieldModal.js","sources":["../../../src/components/InsertFieldModal.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable react/static-property-placement */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport DSModal, { MODAL_TYPE } from '@elliemae/ds-modal';\nimport { sizeOptions } from '@elliemae/ds-shared/constants';\nimport { includes } from 'lodash';\nimport { fields, getFieldName, getFieldCode } from './customFields';\n\nconst modalTypes = Object.values(MODAL_TYPE);\nconst elementClassName = 'insertfieldmodal-element';\n\nexport default class InsertFieldModal extends React.PureComponent {\n static propTypes = {\n onConfirm: PropTypes.func.isRequired,\n onClose: PropTypes.func.isRequired,\n confirmLabel: PropTypes.string,\n customFields: PropTypes.arrayOf(PropTypes.string),\n disableDoubleClick: PropTypes.bool,\n isOpen: PropTypes.bool,\n modalTitle: PropTypes.string,\n modalType: PropTypes.string,\n rejectLabel: PropTypes.string,\n shouldCloseOnOverlayClick: PropTypes.bool,\n size: PropTypes.string,\n onSelect: PropTypes.func,\n };\n\n static defaultProps = {\n confirmLabel: 'Add',\n customFields: fields,\n disableDoubleClick: false,\n isOpen: true,\n modalTitle: 'Add Field',\n modalType: modalTypes[1],\n rejectLabel: 'Cancel',\n shouldCloseOnOverlayClick: true,\n size: sizeOptions[1],\n onSelect: undefined,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n selectedFieldCode: getFieldCode(fields[0]),\n };\n this.preventSpacebarScroll();\n }\n\n componentDidMount() {\n const { customFields } = this.props;\n if (customFields) {\n this.handleElementClick({}, customFields[0]);\n this.focusFirst = true;\n }\n }\n\n getDerivedStateFromProps(nextProps) {\n const { customFields } = this.props;\n if (!customFields && nextProps.customFields) {\n this.setState({ selectedFieldCode: customFields[0] });\n }\n }\n\n onConfirm = () => {\n const { onConfirm, onClose } = this.props;\n const { selectedFieldCode } = this.state;\n onConfirm(selectedFieldCode);\n onClose();\n };\n\n onReject = () => {\n const { onReject, onClose } = this.props;\n if (onReject) {\n onReject();\n } else {\n onClose();\n }\n };\n\n drawDiv = (className, content, content2) => (\n <div className={className}>\n <span>{content}</span>\n <span>{content2}</span>\n </div>\n );\n\n drawLabel = (className, label, value) => (\n <div className={className}>\n <span className=\"label\">{label}</span>\n <span className=\"value\">{value}</span>\n </div>\n );\n\n handleElementClick = (e, selectedFieldCode) => {\n if (e.key && e.key !== ' ') {\n return;\n }\n const { selectedFieldCode: fCode } = this.state;\n const { disableDoubleClick } = this.props;\n if (selectedFieldCode === fCode && !disableDoubleClick) {\n this.onConfirm();\n return;\n }\n this.setState({\n selectedFieldCode,\n });\n const { onSelect } = this.props;\n if (onSelect) {\n onSelect(selectedFieldCode);\n }\n };\n\n preventSpacebarScroll = () => {\n document.onkeypress = function (e) {\n if (!includes(e.target.className, elementClassName)) {\n return true;\n }\n e = e || window.event;\n const charCode = e.keyCode || e.which;\n if (charCode === 32) {\n e.preventDefault();\n return false;\n }\n return true;\n };\n };\n\n renderElements = () => {\n const { customFields } = this.props;\n if (!customFields) {\n return 'Empty';\n }\n const { selectedFieldCode } = this.state;\n return customFields.map((customField, idx) => {\n const extras = {};\n const fieldCode = getFieldCode(customField);\n if (this.focusFirst && idx === 0) {\n extras.ref = (element) => element && element.focus();\n this.focusFirst = undefined;\n } else if (fieldCode === selectedFieldCode) {\n extras.ref = (element) => element && element.focus();\n }\n return (\n <div\n key={fieldCode}\n className={elementClassName}\n onClick={(e) => this.handleElementClick(e, fieldCode)}\n onKeyUp={(e) => this.handleElementClick(e, fieldCode)}\n role=\"button\"\n tabIndex={0}\n {...extras}\n >\n {this.drawLabel('content', getFieldName(customField), fieldCode)}\n </div>\n );\n });\n };\n\n render() {\n const { customFields, onSelect, ...modalProps } = this.props;\n return (\n <DSModal {...modalProps} className=\"insert-field-modal\" onConfirm={this.onConfirm} onReject={this.onReject}>\n <div className=\"wrapper\">\n <div className=\"col-1\">\n {this.drawDiv('title', 'Field Name', '« Field ID »')}\n {this.renderElements()}\n </div>\n </div>\n </DSModal>\n );\n }\n}\n"],"names":["modalTypes","Object","values","MODAL_TYPE","elementClassName","InsertFieldModal","props","onConfirm","onClose","selectedFieldCode","state","onReject","className","content","content2","React","label","value","e","key","fCode","disableDoubleClick","setState","onSelect","document","onkeypress","includes","target","window","event","charCode","keyCode","which","preventDefault","customFields","map","customField","idx","extras","fieldCode","getFieldCode","focusFirst","ref","element","focus","undefined","handleElementClick","drawLabel","getFieldName","fields","preventSpacebarScroll","nextProps","modalProps","DSModal","drawDiv","renderElements","PureComponent","PropTypes","func","isRequired","confirmLabel","string","arrayOf","bool","isOpen","modalTitle","modalType","rejectLabel","shouldCloseOnOverlayClick","size","sizeOptions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAMA,UAAU,GAAGC,MAAM,CAACC,MAAP,CAAcC,kBAAd,CAAnB;AACA,IAAMC,gBAAgB,GAAG,0BAAzB;;IAEqB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,CAACI,MAXC;AAYjBtC,EAAAA,QAAQ,EAAEkC,6BAAS,CAACC;AAZH;;oCADArD,kCAgBG;AACpBuD,EAAAA,YAAY,EAAE,KADM;AAEpB1B,EAAAA,YAAY,EAAEe,8BAFM;AAGpB5B,EAAAA,kBAAkB,EAAE,KAHA;AAIpB2C,EAAAA,MAAM,EAAE,IAJY;AAKpBC,EAAAA,UAAU,EAAE,WALQ;AAMpBC,EAAAA,SAAS,EAAElE,UAAU,CAAC,CAAD,CAND;AAOpBmE,EAAAA,WAAW,EAAE,QAPO;AAQpBC,EAAAA,yBAAyB,EAAE,IARP;AASpBC,EAAAA,IAAI,EAAEC,qBAAW,CAAC,CAAD,CATG;AAUpB/C,EAAAA,QAAQ,EAAEsB;AAVU;;;;"}
1
+ {"version":3,"file":"InsertFieldModal.js","sources":["../../../src/components/InsertFieldModal.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable react/static-property-placement */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport DSModal, { MODAL_TYPE } from '@elliemae/ds-modal';\nimport { sizeOptions } from '@elliemae/ds-shared/constants';\nimport { includes } from 'lodash';\nimport { fields, getFieldName, getFieldCode } from './customFields';\n\nconst modalTypes = Object.values(MODAL_TYPE);\nconst elementClassName = 'insertfieldmodal-element';\n\nexport default class InsertFieldModal extends React.PureComponent {\n static propTypes = {\n onConfirm: PropTypes.func.isRequired,\n onClose: PropTypes.func.isRequired,\n confirmLabel: PropTypes.string,\n customFields: PropTypes.arrayOf(PropTypes.string),\n disableDoubleClick: PropTypes.bool,\n isOpen: PropTypes.bool,\n modalTitle: PropTypes.string,\n modalType: PropTypes.string,\n rejectLabel: PropTypes.string,\n shouldCloseOnOverlayClick: PropTypes.bool,\n size: PropTypes.string,\n onSelect: PropTypes.func,\n };\n\n static defaultProps = {\n confirmLabel: 'Add',\n customFields: fields,\n disableDoubleClick: false,\n isOpen: true,\n modalTitle: 'Add Field',\n modalType: modalTypes[1],\n rejectLabel: 'Cancel',\n shouldCloseOnOverlayClick: true,\n size: sizeOptions[1],\n onSelect: undefined,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n selectedFieldCode: getFieldCode(fields[0]),\n };\n this.preventSpacebarScroll();\n }\n\n componentDidMount() {\n const { customFields } = this.props;\n if (customFields) {\n this.handleElementClick({}, customFields[0]);\n this.focusFirst = true;\n }\n }\n\n getDerivedStateFromProps(nextProps) {\n const { customFields } = this.props;\n if (!customFields && nextProps.customFields) {\n this.setState({ selectedFieldCode: customFields[0] });\n }\n }\n\n onConfirm = () => {\n const { onConfirm, onClose } = this.props;\n const { selectedFieldCode } = this.state;\n onConfirm(selectedFieldCode);\n onClose();\n };\n\n onReject = () => {\n const { onReject, onClose } = this.props;\n if (onReject) {\n onReject();\n } else {\n onClose();\n }\n };\n\n drawDiv = (className, content, content2) => (\n <div className={className}>\n <span>{content}</span>\n <span>{content2}</span>\n </div>\n );\n\n drawLabel = (className, label, value) => (\n <div className={className}>\n <span className=\"label\">{label}</span>\n <span className=\"value\">{value}</span>\n </div>\n );\n\n handleElementClick = (e, selectedFieldCode) => {\n if (e.key && e.key !== ' ') {\n return;\n }\n const { selectedFieldCode: fCode } = this.state;\n const { disableDoubleClick } = this.props;\n if (selectedFieldCode === fCode && !disableDoubleClick) {\n this.onConfirm();\n return;\n }\n this.setState({\n selectedFieldCode,\n });\n const { onSelect } = this.props;\n if (onSelect) {\n onSelect(selectedFieldCode);\n }\n };\n\n preventSpacebarScroll = () => {\n document.onkeypress = function (e) {\n if (!includes(e.target.className, elementClassName)) {\n return true;\n }\n e = e || window.event;\n const charCode = e.keyCode || e.which;\n if (charCode === 32) {\n e.preventDefault();\n return false;\n }\n return true;\n };\n };\n\n renderElements = () => {\n const { customFields } = this.props;\n if (!customFields) {\n return 'Empty';\n }\n const { selectedFieldCode } = this.state;\n return customFields.map((customField, idx) => {\n const extras = {};\n const fieldCode = getFieldCode(customField);\n if (this.focusFirst && idx === 0) {\n extras.ref = (element) => element && element.focus();\n this.focusFirst = undefined;\n } else if (fieldCode === selectedFieldCode) {\n extras.ref = (element) => element && element.focus();\n }\n return (\n <div\n key={fieldCode}\n className={elementClassName}\n onClick={(e) => this.handleElementClick(e, fieldCode)}\n onKeyUp={(e) => this.handleElementClick(e, fieldCode)}\n role=\"button\"\n tabIndex={0}\n {...extras}\n >\n {this.drawLabel('content', getFieldName(customField), fieldCode)}\n </div>\n );\n });\n };\n\n render() {\n const { customFields, onSelect, ...modalProps } = this.props;\n return (\n <DSModal {...modalProps} className=\"insert-field-modal\" onConfirm={this.onConfirm} onReject={this.onReject}>\n <div className=\"wrapper\">\n <div className=\"col-1\">\n {this.drawDiv('title', 'Field Name', '« Field ID »')}\n {this.renderElements()}\n </div>\n </div>\n </DSModal>\n );\n }\n}\n"],"names":["modalTypes","Object","values","MODAL_TYPE","elementClassName","InsertFieldModal","props","onConfirm","onClose","selectedFieldCode","state","onReject","drawDiv","className","content","content2","React","drawLabel","label","value","handleElementClick","e","key","fCode","disableDoubleClick","setState","onSelect","preventSpacebarScroll","document","onkeypress","includes","target","window","event","charCode","keyCode","which","preventDefault","renderElements","customFields","map","customField","idx","extras","fieldCode","getFieldCode","focusFirst","ref","element","focus","undefined","getFieldName","fields","nextProps","modalProps","DSModal","PureComponent","propTypes","PropTypes","func","isRequired","confirmLabel","string","arrayOf","bool","isOpen","modalTitle","modalType","rejectLabel","shouldCloseOnOverlayClick","size","defaultProps","sizeOptions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAMA,UAAU,GAAGC,MAAM,CAACC,MAAP,CAAcC,kBAAd,CAAnB;AACA,IAAMC,gBAAgB,GAAG,0BAAzB;;IAEqBC;;;;;AA6BnB,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,UAuBnBC,SAvBmB,GAuBP,YAAM;AAChB,wBAA+B,MAAKD,KAApC;AAAA,UAA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jBpC,EAAAA,QAAQ,EAAEgC,6BAAS,CAACC;AAZH;AADAtD,iBAgBZkE,eAAe;AACpBV,EAAAA,YAAY,EAAE,KADM;AAEpBtB,EAAAA,YAAY,EAAEa,8BAFM;AAGpB5B,EAAAA,kBAAkB,EAAE,KAHA;AAIpByC,EAAAA,MAAM,EAAE,IAJY;AAKpBC,EAAAA,UAAU,EAAE,WALQ;AAMpBC,EAAAA,SAAS,EAAEnE,UAAU,CAAC,CAAD,CAND;AAOpBoE,EAAAA,WAAW,EAAE,QAPO;AAQpBC,EAAAA,yBAAyB,EAAE,IARP;AASpBC,EAAAA,IAAI,EAAEE,qBAAW,CAAC,CAAD,CATG;AAUpB9C,EAAAA,QAAQ,EAAEwB;AAVU;;;;"}
package/cjs/index.js CHANGED
@@ -12,13 +12,12 @@ require('@babel/runtime/helpers/objectWithoutProperties');
12
12
  require('react');
13
13
  require('react-desc');
14
14
  require('./components/DSWYSIWYGEditorImpl.js');
15
+ require('@babel/runtime/helpers/defineProperty');
15
16
  require('@babel/runtime/helpers/classCallCheck');
16
17
  require('@babel/runtime/helpers/createClass');
17
- require('@babel/runtime/helpers/assertThisInitialized');
18
18
  require('@babel/runtime/helpers/inherits');
19
19
  require('@babel/runtime/helpers/possibleConstructorReturn');
20
20
  require('@babel/runtime/helpers/getPrototypeOf');
21
- require('@babel/runtime/helpers/defineProperty');
22
21
  require('react-quill');
23
22
  require('quill-blot-formatter');
24
23
  require('./components/ImageLibraryModal.js');
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2,24 +2,20 @@
2
2
 
3
3
  var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
4
4
  var _createClass = require('@babel/runtime/helpers/createClass');
5
- var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
6
5
  var _get = require('@babel/runtime/helpers/get');
7
6
  var _inherits = require('@babel/runtime/helpers/inherits');
8
7
  var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
9
8
  var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
10
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
9
  var ReactQuill = require('react-quill');
12
10
 
13
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
12
 
15
13
  var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
16
14
  var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
17
- var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
18
15
  var _get__default = /*#__PURE__*/_interopDefaultLegacy(_get);
19
16
  var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
20
17
  var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
21
18
  var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
22
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
23
19
 
24
20
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
25
21
 
@@ -62,15 +58,10 @@ var LinkFormat = /*#__PURE__*/function (_Link) {
62
58
  }
63
59
 
64
60
  _this = _super.call.apply(_super, [this].concat(args));
65
-
66
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "blotName", 'link');
67
-
68
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "tagName", 'A');
69
-
70
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "SANITIZED_URL", 'about:blank');
71
-
72
- _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "PROTOCOL_WHITELIST", ['http', 'ftp', 'https', 'mailto', 'tel']);
73
-
61
+ _this.blotName = 'link';
62
+ _this.tagName = 'A';
63
+ _this.SANITIZED_URL = 'about:blank';
64
+ _this.PROTOCOL_WHITELIST = ['http', 'ftp', 'https', 'mailto', 'tel'];
74
65
  return _this;
75
66
  }
76
67
 
@@ -1 +1 @@
1
- {"version":3,"file":"LinkFormat.js","sources":["../../../src/quillOverrides/LinkFormat.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { Quill } from 'react-quill';\n\nconst sanitizeProtocol = (value) => {\n if (typeof value === 'boolean') return value;\n let newVal = value;\n if (\n !value.startsWith('http') &&\n !value.startsWith('ftp') &&\n !value.startsWith('mailto:') &&\n !value.startsWith('{{')\n ) {\n if (!value.startsWith('www')) {\n newVal = `https://www.${value}`;\n } else newVal = `https://${value}`;\n }\n return newVal;\n};\n\nfunction getIsValidProtocol(url, protocols) {\n const anchor = document.createElement('a');\n anchor.href = url;\n const protocol = anchor.href.slice(0, anchor.href.indexOf(':'));\n return protocols.indexOf(protocol) > -1;\n}\n\nconst Link = Quill.import('formats/link');\n\nclass LinkFormat extends Link {\n blotName = 'link';\n\n tagName = 'A';\n\n SANITIZED_URL = 'about:blank';\n\n PROTOCOL_WHITELIST = ['http', 'ftp', 'https', 'mailto', 'tel'];\n\n static create(value) {\n const newVal = sanitizeProtocol(value);\n const node = super.create(newVal);\n node.setAttribute('href', newVal);\n return node;\n }\n\n static formats(domNode) {\n return domNode?.getAttribute?.('href');\n }\n\n static sanitize(url) {\n return getIsValidProtocol(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;\n }\n\n format(name, value) {\n const newVal = sanitizeProtocol(value);\n // Remove link case\n if (name === 'link' && value === false) {\n this.domNode.removeAttribute('href');\n } else if (name !== this.statics.blotName || !newVal) {\n super.format(name, newVal);\n } else {\n this.domNode.setAttribute('href', this.constructor.sanitize(newVal));\n }\n }\n}\n\nexport default LinkFormat;\n"],"names":["sanitizeProtocol","value","newVal","startsWith","getIsValidProtocol","url","protocols","anchor","document","createElement","href","protocol","slice","indexOf","Link","Quill","import","LinkFormat","name","domNode","removeAttribute","statics","blotName","setAttribute","constructor","sanitize","node","getAttribute","PROTOCOL_WHITELIST","SANITIZED_URL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,KAAD,EAAW;AAClC,MAAI,OAAOA,KAAP,KAAiB,SAArB,EAAgC,OAAOA,KAAP;AAChC,MAAIC,MAAM,GAAGD,KAAb;;AACA,MACE,CAACA,KAAK,CAACE,UAAN,CAAiB,MAAjB,CAAD,IACA,CAACF,KAAK,CAACE,UAAN,CAAiB,KAAjB,CADD,IAEA,CAACF,KAAK,CAACE,UAAN,CAAiB,SAAjB,CAFD,IAGA,CAACF,KAAK,CAACE,UAAN,CAAiB,IAAjB,CAJH,EAKE;AACA,QAAI,CAACF,KAAK,CAACE,UAAN,CAAiB,KAAjB,CAAL,EAA8B;AAC5BD,MAAAA,MAAM,yBAAkBD,KAAlB,CAAN;AACD,KAFD,MAEOC,MAAM,qBAAcD,KAAd,CAAN;AACR;;AACD,SAAOC,MAAP;AACD,CAdD;;AAgBA,SAASE,kBAAT,CAA4BC,GAA5B,EAAiCC,SAAjC,EAA4C;AAC1C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAT,CAAuB,GAAvB,CAAf;AACAF,EAAAA,MAAM,CAACG,IAAP,GAAcL,GAAd;AACA,MAAMM,QAAQ,GAAGJ,MAAM,CAACG,IAAP,CAAYE,KAAZ,CAAkB,CA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,kBAAkB,CAACC,GAAD,EAAM,KAAKuB,kBAAX,CAAlB,GAAmDvB,GAAnD,GAAyD,KAAKwB,aAArE;AACD;;;;EAtBsBf;;;;"}
1
+ {"version":3,"file":"LinkFormat.js","sources":["../../../src/quillOverrides/LinkFormat.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { Quill } from 'react-quill';\n\nconst sanitizeProtocol = (value) => {\n if (typeof value === 'boolean') return value;\n let newVal = value;\n if (\n !value.startsWith('http') &&\n !value.startsWith('ftp') &&\n !value.startsWith('mailto:') &&\n !value.startsWith('{{')\n ) {\n if (!value.startsWith('www')) {\n newVal = `https://www.${value}`;\n } else newVal = `https://${value}`;\n }\n return newVal;\n};\n\nfunction getIsValidProtocol(url, protocols) {\n const anchor = document.createElement('a');\n anchor.href = url;\n const protocol = anchor.href.slice(0, anchor.href.indexOf(':'));\n return protocols.indexOf(protocol) > -1;\n}\n\nconst Link = Quill.import('formats/link');\n\nclass LinkFormat extends Link {\n blotName = 'link';\n\n tagName = 'A';\n\n SANITIZED_URL = 'about:blank';\n\n PROTOCOL_WHITELIST = ['http', 'ftp', 'https', 'mailto', 'tel'];\n\n static create(value) {\n const newVal = sanitizeProtocol(value);\n const node = super.create(newVal);\n node.setAttribute('href', newVal);\n return node;\n }\n\n static formats(domNode) {\n return domNode?.getAttribute?.('href');\n }\n\n static sanitize(url) {\n return getIsValidProtocol(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;\n }\n\n format(name, value) {\n const newVal = sanitizeProtocol(value);\n // Remove link case\n if (name === 'link' && value === false) {\n this.domNode.removeAttribute('href');\n } else if (name !== this.statics.blotName || !newVal) {\n super.format(name, newVal);\n } else {\n this.domNode.setAttribute('href', this.constructor.sanitize(newVal));\n }\n }\n}\n\nexport default LinkFormat;\n"],"names":["sanitizeProtocol","value","newVal","startsWith","getIsValidProtocol","url","protocols","anchor","document","createElement","href","protocol","slice","indexOf","Link","Quill","import","LinkFormat","blotName","tagName","SANITIZED_URL","PROTOCOL_WHITELIST","name","domNode","removeAttribute","statics","setAttribute","constructor","sanitize","node","getAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,KAAD,EAAW;AAClC,MAAI,OAAOA,KAAP,KAAiB,SAArB,EAAgC,OAAOA,KAAP;AAChC,MAAIC,MAAM,GAAGD,KAAb;;AACA,MACE,CAACA,KAAK,CAACE,UAAN,CAAiB,MAAjB,CAAD,IACA,CAACF,KAAK,CAACE,UAAN,CAAiB,KAAjB,CADD,IAEA,CAACF,KAAK,CAACE,UAAN,CAAiB,SAAjB,CAFD,IAGA,CAACF,KAAK,CAACE,UAAN,CAAiB,IAAjB,CAJH,EAKE;AACA,QAAI,CAACF,KAAK,CAACE,UAAN,CAAiB,KAAjB,CAAL,EAA8B;AAC5BD,MAAAA,MAAM,yBAAkBD,KAAlB,CAAN;AACD,KAFD,MAEOC,MAAM,qBAAcD,KAAd,CAAN;AACR;;AACD,SAAOC,MAAP;AACD,CAdD;;AAgBA,SAASE,kBAAT,CAA4BC,GAA5B,EAAiCC,SAAjC,EAA4C;AAC1C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAT,CAAuB,GAAvB,CAAf;AACAF,EAAAA,MAAM,CAACG,IAAP,GAAcL,GAAd;AACA,MAAMM,QAAQ,GAAGJ,MAAM,CAACG,IAAP,CAAYE,KAAZ,CAAkB,CAAlB,EAAqBL,MAAM,CAACG,IAAP,CAAYG,OAAZ,CAAoB,GAApB,CAArB,CAAjB;AACA,SAAOP,SAAS,CAACO,OAAV,CAAkBF,QAAlB,IAA8B,CAAC,CAAtC;AACD;;AAED,IAAMG,IAAI,GAAGC,gBAAK,CAACC,MAAN,CAAa,cAAb,CAAb;;IAEMC;;;;;;;;;;;;;;;UACJC,WAAW;UAEXC,UAAU;UAEVC,gBAAgB;UAEhBC,qBAAqB,CAAC,MAAD,EAAS,KAAT,EAAg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