@rhc-shared-components/rich-text-editor 0.3.5 → 0.5.1

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.4.0](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.12...@rhc-shared-components/rich-text-editor@0.4.0) (2022-06-14)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * added touched flag to validation ([e69be69](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/e69be69c901cd84f9f53c1ce2ef7047cd8ead04e))
12
+ * fixed max length bug ([c63c798](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/c63c79891c16ff23919f09ba681470432a2b3301))
13
+ * fixed re init bugs ([b208de0](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/b208de0ac998c4fb814cbee4e3e3a8b4c6fe4b05))
14
+ * fixing validation errors ([e2d4e61](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/e2d4e610ddeefdef6dd39d9cf6000dfab84916c7))
15
+ * validation bugs ([cee65e1](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/cee65e142bf2dbae06914a4add9915f11118c6af))
16
+
17
+
18
+ ### Features
19
+
20
+ * added maxlength feature ([564c8fa](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/564c8fa69ce2abfdc6eeb01d07330ebcfcbad4a1))
21
+
22
+
23
+
24
+
25
+
6
26
  ## [0.2.12](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.11...@rhc-shared-components/rich-text-editor@0.2.12) (2021-11-01)
7
27
 
8
28
  **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
@@ -1,10 +1,9 @@
1
1
  import * as React from 'react';
2
- import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
3
- declare type RichTextEditorFunctionType = (value: string, event?: Event, editor?: ClassicEditor) => void;
2
+ declare type RichTextEditorFunctionType = (value: string, event?: Event, editor?: any) => void;
4
3
  export interface RichTextEditorProps {
5
4
  value: string;
6
5
  disabled?: boolean;
7
- onReady?: (editor: ClassicEditor) => void;
6
+ onReady?: (editor: any) => void;
8
7
  onChange?: RichTextEditorFunctionType;
9
8
  onBlur?: RichTextEditorFunctionType;
10
9
  onFocus?: RichTextEditorFunctionType;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var React = require('react');
2
2
  var ckeditor5React = require('@ckeditor/ckeditor5-react');
3
- var ClassicEditor = require('@ckeditor/ckeditor5-build-classic');
3
+ var ClassicEditor = require('@rhc-shared-components/rhc-ckeditor');
4
4
  var reactCore = require('@patternfly/react-core');
5
5
  var formik = require('formik');
6
6
 
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
28
  var ClassicEditor__default = /*#__PURE__*/_interopDefaultLegacy(ClassicEditor);
29
29
 
30
- var css_248z$1 = ".rich-text-editor-custom {\n --pf-c-title--m-2xl--LineHeight: var(--pf-global--LineHeight--sm);\n --pf-c-title--m-2xl--FontSize: var(--pf-global--FontSize--2xl);\n --pf-c-title--m-2xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-xl--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-xl--FontSize: var(--pf-global--FontSize--xl);\n --pf-c-title--m-xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-lg--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-lg--FontSize: var(--pf-global--FontSize--lg);\n --pf-c-title--m-lg--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-md--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-md--FontSize: var(--pf-global--FontSize--md);\n --pf-c-title--m-md--FontWeight: var(--pf-global--FontWeight--normal); }\n .rich-text-editor-custom h1 {\n font-size: var(--pf-c-title--m-2xl--FontSize);\n font-weight: var(--pf-c-title--m-2xl--FontWeight);\n line-height: var(--pf-c-title--m-2xl--LineHeight); }\n .rich-text-editor-custom h2 {\n font-size: var(--pf-c-title--m-xl--FontSize);\n font-weight: var(--pf-c-title--m-xl--FontWeight);\n line-height: var(--pf-c-title--m-xl--LineHeight); }\n .rich-text-editor-custom h3 {\n font-size: var(--pf-c-title--m-lg--FontSize);\n font-weight: var(--pf-c-title--m-lg--FontWeight);\n line-height: var(--pf-c-title--m-lg--LineHeight); }\n .rich-text-editor-custom h4 {\n font-size: var(--pf-c-title--m-md--FontSize);\n font-weight: var(--pf-c-title--m-md--FontWeight);\n line-height: var(--pf-c-title--m-md--LineHeight); }\n .rich-text-editor-custom ul {\n display: block;\n list-style-type: disc;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px; }\n .rich-text-editor-custom ul li {\n display: list-item; }\n .rich-text-editor-custom ul ul {\n list-style-type: circle;\n -webkit-margin-before: 0px;\n margin-block-start: 0px;\n -webkit-margin-after: 0px;\n margin-block-end: 0px; }\n .rich-text-editor-custom ol {\n display: block;\n list-style-type: decimal;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px; }\n";
30
+ var css_248z$1 = ".rich-text-editor-custom {\n --pf-c-title--m-2xl--LineHeight: var(--pf-global--LineHeight--sm);\n --pf-c-title--m-2xl--FontSize: var(--pf-global--FontSize--2xl);\n --pf-c-title--m-2xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-xl--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-xl--FontSize: var(--pf-global--FontSize--xl);\n --pf-c-title--m-xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-lg--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-lg--FontSize: var(--pf-global--FontSize--lg);\n --pf-c-title--m-lg--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-md--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-md--FontSize: var(--pf-global--FontSize--md);\n --pf-c-title--m-md--FontWeight: var(--pf-global--FontWeight--normal); }\n .rich-text-editor-custom .ck-editor__main {\n word-break: break-all; }\n .rich-text-editor-custom .ck-code-block-dropdown .ck-splitbutton__arrow {\n display: none; }\n .rich-text-editor-custom h1 {\n font-size: var(--pf-c-title--m-2xl--FontSize);\n font-weight: var(--pf-c-title--m-2xl--FontWeight);\n line-height: var(--pf-c-title--m-2xl--LineHeight); }\n .rich-text-editor-custom h2 {\n font-size: var(--pf-c-title--m-xl--FontSize);\n font-weight: var(--pf-c-title--m-xl--FontWeight);\n line-height: var(--pf-c-title--m-xl--LineHeight); }\n .rich-text-editor-custom h3 {\n font-size: var(--pf-c-title--m-lg--FontSize);\n font-weight: var(--pf-c-title--m-lg--FontWeight);\n line-height: var(--pf-c-title--m-lg--LineHeight); }\n .rich-text-editor-custom h4 {\n font-size: var(--pf-c-title--m-md--FontSize);\n font-weight: var(--pf-c-title--m-md--FontWeight);\n line-height: var(--pf-c-title--m-md--LineHeight); }\n .rich-text-editor-custom ul {\n display: block;\n list-style-type: disc;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px; }\n .rich-text-editor-custom ul li {\n display: list-item; }\n .rich-text-editor-custom ul ul {\n list-style-type: circle;\n -webkit-margin-before: 0px;\n margin-block-start: 0px;\n -webkit-margin-after: 0px;\n margin-block-end: 0px; }\n .rich-text-editor-custom ol {\n display: block;\n list-style-type: decimal;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px; }\n";
31
31
 
32
32
  var RichTextEditor = function RichTextEditor(_ref) {
33
33
  var value = _ref.value,
@@ -50,46 +50,17 @@ var RichTextEditor = function RichTextEditor(_ref) {
50
50
  return React__namespace.createElement("div", {
51
51
  className: 'rich-text-editor-custom'
52
52
  }, React__namespace.createElement(ckeditor5React.CKEditor, Object.assign({
53
- disabled: disabled,
54
53
  editor: ClassicEditor__default["default"],
55
54
  data: value,
56
55
  config: {
57
- heading: {
58
- options: [{
59
- model: 'paragraph',
60
- title: 'Paragraph'
61
- }, {
62
- model: 'heading1',
63
- view: {
64
- name: 'h1'
65
- },
66
- title: 'Heading 1'
67
- }, {
68
- model: 'heading2',
69
- view: {
70
- name: 'h2'
71
- },
72
- title: 'Heading 2'
73
- }, {
74
- model: 'heading3',
75
- view: {
76
- name: 'h3'
77
- },
78
- title: 'Heading 3'
79
- }, {
80
- model: 'heading4',
81
- view: {
82
- name: 'h4'
83
- },
84
- title: 'Heading 4'
56
+ codeBlock: {
57
+ languages: [{
58
+ language: 'code',
59
+ label: 'Code',
60
+ forceValue: true
85
61
  }]
86
62
  },
87
- toolbar: {
88
- items: ['heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', '|', 'blockQuote', 'insertTable', 'undo', 'redo']
89
- },
90
- table: {
91
- contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells']
92
- }
63
+ isReadOnly: disabled
93
64
  },
94
65
  onReady: onReady,
95
66
  onChange: function onChange(event, editor) {
@@ -225,8 +196,12 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
225
196
  }, [value, maxLength]);
226
197
  return React__namespace.createElement(FormGroupContainer, {
227
198
  validated: meta.touched && meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
228
- onClick: function onClick() {
229
- if (editorRef) {
199
+ onClick: function onClick(event) {
200
+ var _event$target;
201
+
202
+ // filtering out just the form event
203
+ if ( // @ts-ignore
204
+ event != null && (_event$target = event.target) != null && _event$target.classList.contains('pf-c-form__label-text') && editorRef.current) {
230
205
  // @ts-ignore
231
206
  editorRef.current.editing.view.focus();
232
207
  }
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { CKEditor } from '@ckeditor/ckeditor5-react';
3
- import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
3
+ import ClassicEditor from '@rhc-shared-components/rhc-ckeditor';
4
4
  import { FormGroup, ValidatedOptions } from '@patternfly/react-core';
5
5
  import { useField, useFormikContext } from 'formik';
6
6
 
7
- var css_248z$1 = ".rich-text-editor-custom {\n --pf-c-title--m-2xl--LineHeight: var(--pf-global--LineHeight--sm);\n --pf-c-title--m-2xl--FontSize: var(--pf-global--FontSize--2xl);\n --pf-c-title--m-2xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-xl--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-xl--FontSize: var(--pf-global--FontSize--xl);\n --pf-c-title--m-xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-lg--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-lg--FontSize: var(--pf-global--FontSize--lg);\n --pf-c-title--m-lg--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-md--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-md--FontSize: var(--pf-global--FontSize--md);\n --pf-c-title--m-md--FontWeight: var(--pf-global--FontWeight--normal); }\n .rich-text-editor-custom h1 {\n font-size: var(--pf-c-title--m-2xl--FontSize);\n font-weight: var(--pf-c-title--m-2xl--FontWeight);\n line-height: var(--pf-c-title--m-2xl--LineHeight); }\n .rich-text-editor-custom h2 {\n font-size: var(--pf-c-title--m-xl--FontSize);\n font-weight: var(--pf-c-title--m-xl--FontWeight);\n line-height: var(--pf-c-title--m-xl--LineHeight); }\n .rich-text-editor-custom h3 {\n font-size: var(--pf-c-title--m-lg--FontSize);\n font-weight: var(--pf-c-title--m-lg--FontWeight);\n line-height: var(--pf-c-title--m-lg--LineHeight); }\n .rich-text-editor-custom h4 {\n font-size: var(--pf-c-title--m-md--FontSize);\n font-weight: var(--pf-c-title--m-md--FontWeight);\n line-height: var(--pf-c-title--m-md--LineHeight); }\n .rich-text-editor-custom ul {\n display: block;\n list-style-type: disc;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px; }\n .rich-text-editor-custom ul li {\n display: list-item; }\n .rich-text-editor-custom ul ul {\n list-style-type: circle;\n -webkit-margin-before: 0px;\n margin-block-start: 0px;\n -webkit-margin-after: 0px;\n margin-block-end: 0px; }\n .rich-text-editor-custom ol {\n display: block;\n list-style-type: decimal;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px; }\n";
7
+ var css_248z$1 = ".rich-text-editor-custom {\n --pf-c-title--m-2xl--LineHeight: var(--pf-global--LineHeight--sm);\n --pf-c-title--m-2xl--FontSize: var(--pf-global--FontSize--2xl);\n --pf-c-title--m-2xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-xl--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-xl--FontSize: var(--pf-global--FontSize--xl);\n --pf-c-title--m-xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-lg--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-lg--FontSize: var(--pf-global--FontSize--lg);\n --pf-c-title--m-lg--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-md--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-md--FontSize: var(--pf-global--FontSize--md);\n --pf-c-title--m-md--FontWeight: var(--pf-global--FontWeight--normal); }\n .rich-text-editor-custom .ck-editor__main {\n word-break: break-all; }\n .rich-text-editor-custom .ck-code-block-dropdown .ck-splitbutton__arrow {\n display: none; }\n .rich-text-editor-custom h1 {\n font-size: var(--pf-c-title--m-2xl--FontSize);\n font-weight: var(--pf-c-title--m-2xl--FontWeight);\n line-height: var(--pf-c-title--m-2xl--LineHeight); }\n .rich-text-editor-custom h2 {\n font-size: var(--pf-c-title--m-xl--FontSize);\n font-weight: var(--pf-c-title--m-xl--FontWeight);\n line-height: var(--pf-c-title--m-xl--LineHeight); }\n .rich-text-editor-custom h3 {\n font-size: var(--pf-c-title--m-lg--FontSize);\n font-weight: var(--pf-c-title--m-lg--FontWeight);\n line-height: var(--pf-c-title--m-lg--LineHeight); }\n .rich-text-editor-custom h4 {\n font-size: var(--pf-c-title--m-md--FontSize);\n font-weight: var(--pf-c-title--m-md--FontWeight);\n line-height: var(--pf-c-title--m-md--LineHeight); }\n .rich-text-editor-custom ul {\n display: block;\n list-style-type: disc;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px; }\n .rich-text-editor-custom ul li {\n display: list-item; }\n .rich-text-editor-custom ul ul {\n list-style-type: circle;\n -webkit-margin-before: 0px;\n margin-block-start: 0px;\n -webkit-margin-after: 0px;\n margin-block-end: 0px; }\n .rich-text-editor-custom ol {\n display: block;\n list-style-type: decimal;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px; }\n";
8
8
 
9
9
  const RichTextEditor = ({
10
10
  value,
@@ -27,46 +27,17 @@ const RichTextEditor = ({
27
27
  return React.createElement("div", {
28
28
  className: 'rich-text-editor-custom'
29
29
  }, React.createElement(CKEditor, Object.assign({
30
- disabled: disabled,
31
30
  editor: ClassicEditor,
32
31
  data: value,
33
32
  config: {
34
- heading: {
35
- options: [{
36
- model: 'paragraph',
37
- title: 'Paragraph'
38
- }, {
39
- model: 'heading1',
40
- view: {
41
- name: 'h1'
42
- },
43
- title: 'Heading 1'
44
- }, {
45
- model: 'heading2',
46
- view: {
47
- name: 'h2'
48
- },
49
- title: 'Heading 2'
50
- }, {
51
- model: 'heading3',
52
- view: {
53
- name: 'h3'
54
- },
55
- title: 'Heading 3'
56
- }, {
57
- model: 'heading4',
58
- view: {
59
- name: 'h4'
60
- },
61
- title: 'Heading 4'
33
+ codeBlock: {
34
+ languages: [{
35
+ language: 'code',
36
+ label: 'Code',
37
+ forceValue: true
62
38
  }]
63
39
  },
64
- toolbar: {
65
- items: ['heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', '|', 'blockQuote', 'insertTable', 'undo', 'redo']
66
- },
67
- table: {
68
- contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells']
69
- }
40
+ isReadOnly: disabled
70
41
  },
71
42
  onReady: onReady,
72
43
  onChange: (event, editor) => {
@@ -204,8 +175,12 @@ const RichTextEditorFormComponent = _ref => {
204
175
  }, [value, maxLength]);
205
176
  return React.createElement(FormGroupContainer, {
206
177
  validated: meta.touched && meta.error ? ValidatedOptions.error : ValidatedOptions.default,
207
- onClick: () => {
208
- if (editorRef) {
178
+ onClick: event => {
179
+ var _event$target;
180
+
181
+ // filtering out just the form event
182
+ if ( // @ts-ignore
183
+ event != null && (_event$target = event.target) != null && _event$target.classList.contains('pf-c-form__label-text') && editorRef.current) {
209
184
  // @ts-ignore
210
185
  editorRef.current.editing.view.focus();
211
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhc-shared-components/rich-text-editor",
3
- "version": "0.3.5",
3
+ "version": "0.5.1",
4
4
  "description": "WYSWYG Editor for Red Hat Certified Apps",
5
5
  "author": "gautamkrishnar",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "react-dom": ">=16.13.1"
33
33
  },
34
34
  "devDependencies": {
35
- "@rhc-shared-components/form-group-container": "^0.3.0",
35
+ "@rhc-shared-components/form-group-container": "^0.3.1",
36
36
  "@testing-library/jest-dom": "^4.2.4",
37
37
  "@testing-library/react": "^9.5.0",
38
38
  "@testing-library/user-event": "^7.2.1",
@@ -69,9 +69,9 @@
69
69
  "dist"
70
70
  ],
71
71
  "dependencies": {
72
- "@ckeditor/ckeditor5-build-classic": "^29.2.0",
73
72
  "@ckeditor/ckeditor5-react": "^3.0.2",
74
73
  "@patternfly/react-core": "^4.101.3",
74
+ "@rhc-shared-components/rhc-ckeditor": "^1.0.2",
75
75
  "formik": "^2.1.4",
76
76
  "react": "^16.13.1",
77
77
  "react-dom": "^16.13.1"