@panneau/field-html 3.0.223 → 3.0.225

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.
Files changed (2) hide show
  1. package/package.json +10 -7
  2. package/lib/index.js +0 -153
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/field-html",
3
- "version": "3.0.223",
3
+ "version": "3.0.225",
4
4
  "description": "A HTML field, using either Quill or CK Editor",
5
5
  "keywords": [
6
6
  "javascript"
@@ -33,8 +33,11 @@
33
33
  }
34
34
  ],
35
35
  "license": "ISC",
36
- "main": "lib/index.js",
36
+ "type": "module",
37
37
  "module": "es/index.js",
38
+ "exports": {
39
+ ".": "./es/index.js"
40
+ },
38
41
  "files": [
39
42
  "lib",
40
43
  "es",
@@ -56,10 +59,10 @@
56
59
  "@babel/runtime": "^7.12.5",
57
60
  "@ckeditor/ckeditor5-editor-multi-root": "^41.3.1",
58
61
  "@ckeditor/ckeditor5-react": "^6.2.0",
59
- "@panneau/ckeditor": "^3.0.223",
60
- "@panneau/core": "^3.0.223",
61
- "@panneau/field-input-group": "^3.0.223",
62
- "@panneau/themes": "^3.0.223",
62
+ "@panneau/ckeditor": "^3.0.225",
63
+ "@panneau/core": "^3.0.224",
64
+ "@panneau/field-input-group": "^3.0.224",
65
+ "@panneau/themes": "^3.0.224",
63
66
  "classnames": "^2.5.1",
64
67
  "prop-types": "^15.7.2"
65
68
  },
@@ -69,5 +72,5 @@
69
72
  "publishConfig": {
70
73
  "access": "public"
71
74
  },
72
- "gitHead": "14196bd955b0e44cbc214e00f3189b3216f3fa53"
75
+ "gitHead": "5603d68b2a7c406ea856abccc332318814d53fc3"
73
76
  }
package/lib/index.js DELETED
@@ -1,153 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- var ckeditor5React = require('@ckeditor/ckeditor5-react');
7
- var classNames = require('classnames');
8
- var PropTypes = require('prop-types');
9
- var React = require('react');
10
- var InputGroup = require('@panneau/field-input-group');
11
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
12
-
13
- var useCKEditorBuild = function useCKEditorBuild() {
14
- var _useState = React.useState(false),
15
- _useState2 = _slicedToArray(_useState, 2),
16
- loaded = _useState2[0],
17
- setLoaded = _useState2[1];
18
- var ref = React.useRef(null);
19
- React.useEffect(function () {
20
- var canceled = false;
21
- if (loaded) {
22
- return function () {
23
- canceled = true;
24
- };
25
- }
26
- import('@panneau/ckeditor/build').then(function (_ref) {
27
- var _ref$Editor = _ref.Editor,
28
- Editor = _ref$Editor === void 0 ? null : _ref$Editor;
29
- if (!canceled) {
30
- ref.current = Editor;
31
- setLoaded(true);
32
- }
33
- })
34
- // eslint-disable-next-line no-console
35
- ["catch"](function (e) {
36
- return console.log('err loading editor', e);
37
- });
38
- return function () {
39
- canceled = true;
40
- };
41
- }, [loaded, setLoaded]);
42
- return ref.current;
43
- };
44
-
45
- var styles = {"container":"panneau-field-html-container"};
46
-
47
- var propTypes = {
48
- feedback: PropTypes.oneOf(['valid', 'invalid', 'loading']),
49
- errors: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
50
- value: PropTypes.string,
51
- placeholder: PropTypes.string,
52
- inline: PropTypes.bool,
53
- disabled: PropTypes.bool,
54
- onChange: PropTypes.func,
55
- onFocus: PropTypes.func,
56
- onBlur: PropTypes.func,
57
- ckConfig: PropTypes.object,
58
- // eslint-disable-line react/forbid-prop-types
59
- ckOptions: PropTypes.object,
60
- // eslint-disable-line react/forbid-prop-types
61
- className: PropTypes.string
62
- };
63
- var defaultProps = {
64
- feedback: null,
65
- errors: null,
66
- value: null,
67
- placeholder: null,
68
- inline: false,
69
- disabled: false,
70
- onChange: null,
71
- onFocus: null,
72
- onBlur: null,
73
- ckConfig: {
74
- toolbar: ['heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList'
75
- // 'blockQuote',
76
- // 'mediaEmbed',
77
- ],
78
- heading: {
79
- options: [{
80
- model: 'paragraph',
81
- title: 'Paragraph'
82
- }, {
83
- model: 'heading1',
84
- view: 'h1',
85
- title: 'Heading 1'
86
- }, {
87
- model: 'heading2',
88
- view: 'h2',
89
- title: 'Heading 2'
90
- }, {
91
- model: 'heading3',
92
- view: 'h3',
93
- title: 'Heading 3'
94
- }]
95
- },
96
- link: {
97
- addTargetToExternalLinks: true
98
- }
99
- // mediaEmbed: {
100
- // previewsInData: true,
101
- // },
102
- },
103
- ckOptions: null,
104
- className: null
105
- };
106
- var HtmlField = function HtmlField(_ref) {
107
- var feedback = _ref.feedback,
108
- errors = _ref.errors,
109
- value = _ref.value,
110
- inline = _ref.inline,
111
- disabled = _ref.disabled,
112
- onChange = _ref.onChange,
113
- onFocus = _ref.onFocus,
114
- onBlur = _ref.onBlur,
115
- ckConfig = _ref.ckConfig,
116
- ckOptions = _ref.ckOptions,
117
- className = _ref.className;
118
- var CKEditorBuild = useCKEditorBuild() || null;
119
- var CKValue = value !== null ? value : '';
120
- var finalClassName = inline ? classNames([styles.container, 'form-control', _defineProperty(_defineProperty(_defineProperty({}, className, className !== null), 'is-valid', feedback === 'valid'), 'is-invalid', feedback === 'invalid' || errors !== null && errors.length > 0)]) : classNames([styles.container, _defineProperty({}, className, className !== null)]);
121
- var onCkEditorChange = React.useCallback(function (event, editor) {
122
- var data = editor !== null ? editor.getData() : null;
123
- if (editor !== null && onChange !== null) {
124
- onChange(data === '' ? null : data);
125
- }
126
- }, [onChange]);
127
- var commonProps = {
128
- onFocus: onFocus,
129
- onBlur: onBlur
130
- };
131
- var ckElement = CKEditorBuild !== null ? /*#__PURE__*/React.createElement("div", {
132
- className: finalClassName
133
- }, /*#__PURE__*/React.createElement(ckeditor5React.CKEditor, Object.assign({
134
- editor: CKEditorBuild,
135
- data: CKValue,
136
- config: ckConfig,
137
- onChange: onCkEditorChange
138
- }, commonProps, ckOptions, {
139
- disabled: disabled
140
- }))) : null;
141
- return inline ? /*#__PURE__*/React.createElement(InputGroup, null, ckElement) : ckElement;
142
- };
143
- HtmlField.propTypes = propTypes;
144
- HtmlField.defaultProps = defaultProps;
145
- var HtmlField$1 = HtmlField;
146
-
147
- var definition = {
148
- id: 'html',
149
- component: 'Html'
150
- };
151
-
152
- exports.default = HtmlField$1;
153
- exports.definition = definition;