@elliemae/ds-wysiwygeditor 2.4.19 → 2.4.22

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.
@@ -18,6 +18,7 @@ var InsertFieldModal = require('./InsertFieldModal.js');
18
18
  var CustomToolbar = require('./CustomToolbar.js');
19
19
  var IndentStyle = require('../quillOverrides/IndentStyle.js');
20
20
  var LinkFormat = require('../quillOverrides/LinkFormat.js');
21
+ var Image = require('../quillOverrides/Image.js');
21
22
  var utils = require('../utils.js');
22
23
  var clipboardLinkWithTagMatcher = require('../quillMatchers/clipboardLinkWithTagMatcher.js');
23
24
  var jsxRuntime = require('react/jsx-runtime');
@@ -54,6 +55,7 @@ ReactQuill.Quill.register(IndentStyle, true);
54
55
  ReactQuill.Quill.register(FontStyle, true);
55
56
  ReactQuill.Quill.register(SizeStyle, true); // -----------------------------------------
56
57
 
58
+ ReactQuill.Quill.register(Image, true);
57
59
  class DSWYSIWYGEditorImpl extends React__default["default"].PureComponent {
58
60
  constructor(props) {
59
61
  super(props);
@@ -236,7 +238,7 @@ class DSWYSIWYGEditorImpl extends React__default["default"].PureComponent {
236
238
  minHeight: '200px'
237
239
  },
238
240
  onChange: this.onChangeTextArea,
239
- value: utils.formatHTML(this.quill?.getEditor()?.root?.innerHTML || value)
241
+ value: utils.formatHTML(value)
240
242
  }), imagesData && imagesData.length && /*#__PURE__*/_jsx__default["default"](ImageLibraryModal, {
241
243
  imagesData: imagesData,
242
244
  isOpen: isImageModalOpen,
@@ -6,7 +6,7 @@ require('core-js/modules/esnext.async-iterator.map.js');
6
6
  require('core-js/modules/esnext.iterator.map.js');
7
7
 
8
8
  var _this = undefined;
9
- const fields = ['Lender Name ­ «315»', 'Lender Address ­ «319»', 'Lender City ­ «313»', 'Lender State ­ «321»', 'Lender Zip ­ «323»', 'Borrower First Name ­ «4000»', 'Borrower Last Name ­ «4002»', 'Total Loan Amount ­ «2»', 'Loan Term ­ «4»', 'Loan to Value ­ «976»', 'Monthly Payment ­ «912»', 'Interest Rate ­ «3»', 'Loan Originator Name ­ «1612»', 'Loan Originator Email ­ «3968»', 'Loan Originator Phone ­ «1823»', 'NMLS Loan Originator ID ­ «3238»'];
9
+ const fields = ['Lender Name «315»', 'Lender Address «319»', 'Lender City «313»', 'Lender State «321»', 'Lender Zip «323»', 'Borrower First Name «4000»', 'Borrower Last Name «4002»', 'Total Loan Amount «2»', 'Loan Term «4»', 'Loan to Value «976»', 'Monthly Payment «912»', 'Interest Rate «3»', 'Loan Originator Name «1612»', 'Loan Originator Email «3968»', 'Loan Originator Phone «1823»', 'NMLS Loan Originator ID «3238»'];
10
10
  /**
11
11
  * Returns the fields names
12
12
  *
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ require('core-js/modules/esnext.async-iterator.for-each.js');
4
+ require('core-js/modules/esnext.iterator.constructor.js');
5
+ require('core-js/modules/esnext.iterator.for-each.js');
6
+ var ReactQuill = require('react-quill');
7
+
8
+ const BaseImage = ReactQuill.Quill.import('formats/image');
9
+ const ATTRIBUTES = ['alt', 'height', 'width', 'style'];
10
+ const WHITE_STYLE = ['margin', 'display', 'float'];
11
+
12
+ class Image extends BaseImage {
13
+ static formats(domNode) {
14
+ return ATTRIBUTES.reduce(function (formats, attribute) {
15
+ if (domNode.hasAttribute(attribute)) {
16
+ formats[attribute] = domNode.getAttribute(attribute);
17
+ }
18
+
19
+ return formats;
20
+ }, {});
21
+ }
22
+
23
+ format(name, value) {
24
+ if (ATTRIBUTES.indexOf(name) > -1) {
25
+ if (value) {
26
+ if (name === 'style') {
27
+ value = this.sanitize_style(value);
28
+ }
29
+
30
+ this.domNode.setAttribute(name, value);
31
+ } else {
32
+ this.domNode.removeAttribute(name);
33
+ }
34
+ } else {
35
+ super.format(name, value);
36
+ }
37
+ }
38
+
39
+ sanitize_style(style) {
40
+ let style_arr = style.split(';');
41
+ let allow_style = '';
42
+ style_arr.forEach((v, i) => {
43
+ if (WHITE_STYLE.indexOf(v.trim().split(':')[0]) !== -1) {
44
+ allow_style += v + ';';
45
+ }
46
+ });
47
+ return allow_style;
48
+ }
49
+
50
+ }
51
+
52
+ module.exports = Image;
@@ -16,6 +16,7 @@ import InsertFieldModal from './InsertFieldModal.js';
16
16
  import { CustomToolbar } from './CustomToolbar.js';
17
17
  import IndentStyle from '../quillOverrides/IndentStyle.js';
18
18
  import LinkFormat from '../quillOverrides/LinkFormat.js';
19
+ import Image from '../quillOverrides/Image.js';
19
20
  import { formatHTML } from '../utils.js';
20
21
  import { clipboardLinkWithTagMatcher } from '../quillMatchers/clipboardLinkWithTagMatcher.js';
21
22
  import { jsxs, jsx } from 'react/jsx-runtime';
@@ -43,6 +44,7 @@ Quill.register(IndentStyle, true);
43
44
  Quill.register(FontStyle, true);
44
45
  Quill.register(SizeStyle, true); // -----------------------------------------
45
46
 
47
+ Quill.register(Image, true);
46
48
  class DSWYSIWYGEditorImpl extends React.PureComponent {
47
49
  constructor(props) {
48
50
  super(props);
@@ -225,7 +227,7 @@ class DSWYSIWYGEditorImpl extends React.PureComponent {
225
227
  minHeight: '200px'
226
228
  },
227
229
  onChange: this.onChangeTextArea,
228
- value: formatHTML(this.quill?.getEditor()?.root?.innerHTML || value)
230
+ value: formatHTML(value)
229
231
  }), imagesData && imagesData.length && /*#__PURE__*/_jsx(ImageLibraryModal, {
230
232
  imagesData: imagesData,
231
233
  isOpen: isImageModalOpen,
@@ -2,7 +2,7 @@ import 'core-js/modules/esnext.async-iterator.map.js';
2
2
  import 'core-js/modules/esnext.iterator.map.js';
3
3
 
4
4
  var _this = undefined;
5
- const fields = ['Lender Name ­ «315»', 'Lender Address ­ «319»', 'Lender City ­ «313»', 'Lender State ­ «321»', 'Lender Zip ­ «323»', 'Borrower First Name ­ «4000»', 'Borrower Last Name ­ «4002»', 'Total Loan Amount ­ «2»', 'Loan Term ­ «4»', 'Loan to Value ­ «976»', 'Monthly Payment ­ «912»', 'Interest Rate ­ «3»', 'Loan Originator Name ­ «1612»', 'Loan Originator Email ­ «3968»', 'Loan Originator Phone ­ «1823»', 'NMLS Loan Originator ID ­ «3238»'];
5
+ const fields = ['Lender Name «315»', 'Lender Address «319»', 'Lender City «313»', 'Lender State «321»', 'Lender Zip «323»', 'Borrower First Name «4000»', 'Borrower Last Name «4002»', 'Total Loan Amount «2»', 'Loan Term «4»', 'Loan to Value «976»', 'Monthly Payment «912»', 'Interest Rate «3»', 'Loan Originator Name «1612»', 'Loan Originator Email «3968»', 'Loan Originator Phone «1823»', 'NMLS Loan Originator ID «3238»'];
6
6
  /**
7
7
  * Returns the fields names
8
8
  *
@@ -0,0 +1,50 @@
1
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.for-each.js';
4
+ import { Quill } from 'react-quill';
5
+
6
+ const BaseImage = Quill.import('formats/image');
7
+ const ATTRIBUTES = ['alt', 'height', 'width', 'style'];
8
+ const WHITE_STYLE = ['margin', 'display', 'float'];
9
+
10
+ class Image extends BaseImage {
11
+ static formats(domNode) {
12
+ return ATTRIBUTES.reduce(function (formats, attribute) {
13
+ if (domNode.hasAttribute(attribute)) {
14
+ formats[attribute] = domNode.getAttribute(attribute);
15
+ }
16
+
17
+ return formats;
18
+ }, {});
19
+ }
20
+
21
+ format(name, value) {
22
+ if (ATTRIBUTES.indexOf(name) > -1) {
23
+ if (value) {
24
+ if (name === 'style') {
25
+ value = this.sanitize_style(value);
26
+ }
27
+
28
+ this.domNode.setAttribute(name, value);
29
+ } else {
30
+ this.domNode.removeAttribute(name);
31
+ }
32
+ } else {
33
+ super.format(name, value);
34
+ }
35
+ }
36
+
37
+ sanitize_style(style) {
38
+ let style_arr = style.split(';');
39
+ let allow_style = '';
40
+ style_arr.forEach((v, i) => {
41
+ if (WHITE_STYLE.indexOf(v.trim().split(':')[0]) !== -1) {
42
+ allow_style += v + ';';
43
+ }
44
+ });
45
+ return allow_style;
46
+ }
47
+
48
+ }
49
+
50
+ export { Image as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-wysiwygeditor",
3
- "version": "2.4.19",
3
+ "version": "2.4.22",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - WYSIWYG Editor",
6
6
  "module": "./esm/index.js",
@@ -27,6 +27,10 @@
27
27
  "import": "./esm/quillOverrides/IndentStyle.js",
28
28
  "require": "./cjs/quillOverrides/IndentStyle.js"
29
29
  },
30
+ "./quillOverrides/Image": {
31
+ "import": "./esm/quillOverrides/Image.js",
32
+ "require": "./cjs/quillOverrides/Image.js"
33
+ },
30
34
  "./quillMatchers/clipboardLinkWithTagMatcher": {
31
35
  "import": "./esm/quillMatchers/clipboardLinkWithTagMatcher.js",
32
36
  "require": "./cjs/quillMatchers/clipboardLinkWithTagMatcher.js"
@@ -96,14 +100,14 @@
96
100
  "build": "node ../../scripts/build/build.js"
97
101
  },
98
102
  "dependencies": {
99
- "@elliemae/ds-button": "2.4.19",
100
- "@elliemae/ds-dropdownmenu": "2.4.19",
101
- "@elliemae/ds-icons": "2.4.19",
102
- "@elliemae/ds-imagelibrarymodal": "2.4.19",
103
- "@elliemae/ds-modal": "2.4.19",
104
- "@elliemae/ds-shared": "2.4.19",
105
- "@elliemae/ds-tooltip": "2.4.19",
106
- "@elliemae/ds-uploader": "2.4.19",
103
+ "@elliemae/ds-button": "2.4.22",
104
+ "@elliemae/ds-dropdownmenu": "2.4.22",
105
+ "@elliemae/ds-icons": "2.4.22",
106
+ "@elliemae/ds-imagelibrarymodal": "2.4.22",
107
+ "@elliemae/ds-modal": "2.4.22",
108
+ "@elliemae/ds-shared": "2.4.22",
109
+ "@elliemae/ds-tooltip": "2.4.22",
110
+ "@elliemae/ds-uploader": "2.4.22",
107
111
  "prop-types": "~15.7.2",
108
112
  "quill-blot-formatter": "~1.0.5",
109
113
  "quill-delta": "4.2.2",
@@ -0,0 +1,7 @@
1
+ declare const BaseImage: any;
2
+ declare class Image extends BaseImage {
3
+ static formats(domNode: any): {};
4
+ format(name: any, value: any): void;
5
+ sanitize_style(style: any): string;
6
+ }
7
+ export default Image;