@pega/cosmos-react-rte 5.0.0-dev.4.7 → 5.0.0-dev.4.8

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 (193) hide show
  1. package/package.json +2 -2
  2. package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts +0 -12
  3. package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts.map +0 -1
  4. package/lib/components/DynamicContentEditor/DynamicContentEditor.js +0 -252
  5. package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +0 -1
  6. package/lib/components/DynamicContentEditor/DynamicContentEditor.test-ids.d.ts +0 -2
  7. package/lib/components/DynamicContentEditor/DynamicContentEditor.test-ids.d.ts.map +0 -1
  8. package/lib/components/DynamicContentEditor/DynamicContentEditor.test-ids.js +0 -8
  9. package/lib/components/DynamicContentEditor/DynamicContentEditor.test-ids.js.map +0 -1
  10. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts +0 -35
  11. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts.map +0 -1
  12. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js +0 -3
  13. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js.map +0 -1
  14. package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts +0 -329
  15. package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts.map +0 -1
  16. package/lib/components/DynamicContentEditor/PegaCustomElement.js +0 -27
  17. package/lib/components/DynamicContentEditor/PegaCustomElement.js.map +0 -1
  18. package/lib/components/DynamicContentEditor/index.d.ts +0 -3
  19. package/lib/components/DynamicContentEditor/index.d.ts.map +0 -1
  20. package/lib/components/DynamicContentEditor/index.js +0 -2
  21. package/lib/components/DynamicContentEditor/index.js.map +0 -1
  22. package/lib/components/Editor/Editor.context.d.ts +0 -10
  23. package/lib/components/Editor/Editor.context.d.ts.map +0 -1
  24. package/lib/components/Editor/Editor.context.js +0 -10
  25. package/lib/components/Editor/Editor.context.js.map +0 -1
  26. package/lib/components/Editor/Editor.d.ts +0 -19
  27. package/lib/components/Editor/Editor.d.ts.map +0 -1
  28. package/lib/components/Editor/Editor.js +0 -369
  29. package/lib/components/Editor/Editor.js.map +0 -1
  30. package/lib/components/Editor/Editor.styles.d.ts +0 -5
  31. package/lib/components/Editor/Editor.styles.d.ts.map +0 -1
  32. package/lib/components/Editor/Editor.styles.js +0 -50
  33. package/lib/components/Editor/Editor.styles.js.map +0 -1
  34. package/lib/components/Editor/Editor.test-ids.d.ts +0 -2
  35. package/lib/components/Editor/Editor.test-ids.d.ts.map +0 -1
  36. package/lib/components/Editor/Editor.test-ids.js +0 -8
  37. package/lib/components/Editor/Editor.test-ids.js.map +0 -1
  38. package/lib/components/Editor/Editor.types.d.ts +0 -69
  39. package/lib/components/Editor/Editor.types.d.ts.map +0 -1
  40. package/lib/components/Editor/Editor.types.js +0 -2
  41. package/lib/components/Editor/Editor.types.js.map +0 -1
  42. package/lib/components/Editor/ImageEditor.d.ts +0 -10
  43. package/lib/components/Editor/ImageEditor.d.ts.map +0 -1
  44. package/lib/components/Editor/ImageEditor.js +0 -276
  45. package/lib/components/Editor/ImageEditor.js.map +0 -1
  46. package/lib/components/Editor/Toolbar/AnchorButton.d.ts +0 -10
  47. package/lib/components/Editor/Toolbar/AnchorButton.d.ts.map +0 -1
  48. package/lib/components/Editor/Toolbar/AnchorButton.js +0 -161
  49. package/lib/components/Editor/Toolbar/AnchorButton.js.map +0 -1
  50. package/lib/components/Editor/Toolbar/ImageButton.d.ts +0 -8
  51. package/lib/components/Editor/Toolbar/ImageButton.d.ts.map +0 -1
  52. package/lib/components/Editor/Toolbar/ImageButton.js +0 -30
  53. package/lib/components/Editor/Toolbar/ImageButton.js.map +0 -1
  54. package/lib/components/Editor/Toolbar/TextSelect.d.ts +0 -14
  55. package/lib/components/Editor/Toolbar/TextSelect.d.ts.map +0 -1
  56. package/lib/components/Editor/Toolbar/TextSelect.js +0 -131
  57. package/lib/components/Editor/Toolbar/TextSelect.js.map +0 -1
  58. package/lib/components/Editor/Toolbar/Toolbar.d.ts +0 -17
  59. package/lib/components/Editor/Toolbar/Toolbar.d.ts.map +0 -1
  60. package/lib/components/Editor/Toolbar/Toolbar.js +0 -164
  61. package/lib/components/Editor/Toolbar/Toolbar.js.map +0 -1
  62. package/lib/components/Editor/Toolbar/Toolbar.test-ids.d.ts +0 -3
  63. package/lib/components/Editor/Toolbar/Toolbar.test-ids.d.ts.map +0 -1
  64. package/lib/components/Editor/Toolbar/Toolbar.test-ids.js +0 -16
  65. package/lib/components/Editor/Toolbar/Toolbar.test-ids.js.map +0 -1
  66. package/lib/components/Editor/index.d.ts +0 -4
  67. package/lib/components/Editor/index.d.ts.map +0 -1
  68. package/lib/components/Editor/index.js +0 -3
  69. package/lib/components/Editor/index.js.map +0 -1
  70. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.d.ts +0 -4
  71. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.d.ts.map +0 -1
  72. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.js +0 -15
  73. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.js.map +0 -1
  74. package/lib/components/RichTextEditor/DecoratorComponents/Image.d.ts +0 -4
  75. package/lib/components/RichTextEditor/DecoratorComponents/Image.d.ts.map +0 -1
  76. package/lib/components/RichTextEditor/DecoratorComponents/Image.js +0 -7
  77. package/lib/components/RichTextEditor/DecoratorComponents/Image.js.map +0 -1
  78. package/lib/components/RichTextEditor/DecoratorComponents/Link.d.ts +0 -4
  79. package/lib/components/RichTextEditor/DecoratorComponents/Link.d.ts.map +0 -1
  80. package/lib/components/RichTextEditor/DecoratorComponents/Link.js +0 -8
  81. package/lib/components/RichTextEditor/DecoratorComponents/Link.js.map +0 -1
  82. package/lib/components/RichTextEditor/DecoratorComponents/Table.d.ts +0 -6
  83. package/lib/components/RichTextEditor/DecoratorComponents/Table.d.ts.map +0 -1
  84. package/lib/components/RichTextEditor/DecoratorComponents/Table.js +0 -24
  85. package/lib/components/RichTextEditor/DecoratorComponents/Table.js.map +0 -1
  86. package/lib/components/RichTextEditor/RichTextEditor.context.d.ts +0 -15
  87. package/lib/components/RichTextEditor/RichTextEditor.context.d.ts.map +0 -1
  88. package/lib/components/RichTextEditor/RichTextEditor.context.js +0 -11
  89. package/lib/components/RichTextEditor/RichTextEditor.context.js.map +0 -1
  90. package/lib/components/RichTextEditor/RichTextEditor.d.ts +0 -6
  91. package/lib/components/RichTextEditor/RichTextEditor.d.ts.map +0 -1
  92. package/lib/components/RichTextEditor/RichTextEditor.js +0 -346
  93. package/lib/components/RichTextEditor/RichTextEditor.js.map +0 -1
  94. package/lib/components/RichTextEditor/RichTextEditor.styles.d.ts +0 -10
  95. package/lib/components/RichTextEditor/RichTextEditor.styles.d.ts.map +0 -1
  96. package/lib/components/RichTextEditor/RichTextEditor.styles.js +0 -73
  97. package/lib/components/RichTextEditor/RichTextEditor.styles.js.map +0 -1
  98. package/lib/components/RichTextEditor/RichTextEditor.types.d.ts +0 -72
  99. package/lib/components/RichTextEditor/RichTextEditor.types.d.ts.map +0 -1
  100. package/lib/components/RichTextEditor/RichTextEditor.types.js +0 -2
  101. package/lib/components/RichTextEditor/RichTextEditor.types.js.map +0 -1
  102. package/lib/components/RichTextEditor/RichTextTreeRenderer.d.ts +0 -9
  103. package/lib/components/RichTextEditor/RichTextTreeRenderer.d.ts.map +0 -1
  104. package/lib/components/RichTextEditor/RichTextTreeRenderer.js +0 -15
  105. package/lib/components/RichTextEditor/RichTextTreeRenderer.js.map +0 -1
  106. package/lib/components/RichTextEditor/RichTextViewer.d.ts +0 -7
  107. package/lib/components/RichTextEditor/RichTextViewer.d.ts.map +0 -1
  108. package/lib/components/RichTextEditor/RichTextViewer.js +0 -38
  109. package/lib/components/RichTextEditor/RichTextViewer.js.map +0 -1
  110. package/lib/components/RichTextEditor/RichTextViewer.types.d.ts +0 -33
  111. package/lib/components/RichTextEditor/RichTextViewer.types.d.ts.map +0 -1
  112. package/lib/components/RichTextEditor/RichTextViewer.types.js +0 -2
  113. package/lib/components/RichTextEditor/RichTextViewer.types.js.map +0 -1
  114. package/lib/components/RichTextEditor/Toolbar/AnchorButton.d.ts +0 -8
  115. package/lib/components/RichTextEditor/Toolbar/AnchorButton.d.ts.map +0 -1
  116. package/lib/components/RichTextEditor/Toolbar/AnchorButton.js +0 -156
  117. package/lib/components/RichTextEditor/Toolbar/AnchorButton.js.map +0 -1
  118. package/lib/components/RichTextEditor/Toolbar/ImageButton.d.ts +0 -5
  119. package/lib/components/RichTextEditor/Toolbar/ImageButton.d.ts.map +0 -1
  120. package/lib/components/RichTextEditor/Toolbar/ImageButton.js +0 -30
  121. package/lib/components/RichTextEditor/Toolbar/ImageButton.js.map +0 -1
  122. package/lib/components/RichTextEditor/Toolbar/IndentButton.d.ts +0 -8
  123. package/lib/components/RichTextEditor/Toolbar/IndentButton.d.ts.map +0 -1
  124. package/lib/components/RichTextEditor/Toolbar/IndentButton.js +0 -31
  125. package/lib/components/RichTextEditor/Toolbar/IndentButton.js.map +0 -1
  126. package/lib/components/RichTextEditor/Toolbar/TableButton.d.ts +0 -5
  127. package/lib/components/RichTextEditor/Toolbar/TableButton.d.ts.map +0 -1
  128. package/lib/components/RichTextEditor/Toolbar/TableButton.js +0 -20
  129. package/lib/components/RichTextEditor/Toolbar/TableButton.js.map +0 -1
  130. package/lib/components/RichTextEditor/Toolbar/TextSelect.d.ts +0 -6
  131. package/lib/components/RichTextEditor/Toolbar/TextSelect.d.ts.map +0 -1
  132. package/lib/components/RichTextEditor/Toolbar/TextSelect.js +0 -119
  133. package/lib/components/RichTextEditor/Toolbar/TextSelect.js.map +0 -1
  134. package/lib/components/RichTextEditor/Toolbar/Toolbar.d.ts +0 -10
  135. package/lib/components/RichTextEditor/Toolbar/Toolbar.d.ts.map +0 -1
  136. package/lib/components/RichTextEditor/Toolbar/Toolbar.js +0 -155
  137. package/lib/components/RichTextEditor/Toolbar/Toolbar.js.map +0 -1
  138. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.d.ts +0 -9
  139. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.d.ts.map +0 -1
  140. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.js +0 -2
  141. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.js.map +0 -1
  142. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.d.ts +0 -14
  143. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.d.ts.map +0 -1
  144. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js +0 -67
  145. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js.map +0 -1
  146. package/lib/components/RichTextEditor/Toolbar/utils.d.ts +0 -7
  147. package/lib/components/RichTextEditor/Toolbar/utils.d.ts.map +0 -1
  148. package/lib/components/RichTextEditor/Toolbar/utils.js +0 -13
  149. package/lib/components/RichTextEditor/Toolbar/utils.js.map +0 -1
  150. package/lib/components/RichTextEditor/index.d.ts +0 -9
  151. package/lib/components/RichTextEditor/index.d.ts.map +0 -1
  152. package/lib/components/RichTextEditor/index.js +0 -6
  153. package/lib/components/RichTextEditor/index.js.map +0 -1
  154. package/lib/components/RichTextEditor/utils/EditorCommands.d.ts +0 -34
  155. package/lib/components/RichTextEditor/utils/EditorCommands.d.ts.map +0 -1
  156. package/lib/components/RichTextEditor/utils/EditorCommands.js +0 -447
  157. package/lib/components/RichTextEditor/utils/EditorCommands.js.map +0 -1
  158. package/lib/components/RichTextEditor/utils/ListCommands.d.ts +0 -10
  159. package/lib/components/RichTextEditor/utils/ListCommands.d.ts.map +0 -1
  160. package/lib/components/RichTextEditor/utils/ListCommands.js +0 -346
  161. package/lib/components/RichTextEditor/utils/ListCommands.js.map +0 -1
  162. package/lib/components/RichTextEditor/utils/htmlConverter.d.ts +0 -29
  163. package/lib/components/RichTextEditor/utils/htmlConverter.d.ts.map +0 -1
  164. package/lib/components/RichTextEditor/utils/htmlConverter.js +0 -156
  165. package/lib/components/RichTextEditor/utils/htmlConverter.js.map +0 -1
  166. package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts +0 -6
  167. package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts.map +0 -1
  168. package/lib/components/RichTextEditor/utils/interactionRenderer.js +0 -132
  169. package/lib/components/RichTextEditor/utils/interactionRenderer.js.map +0 -1
  170. package/lib/components/RichTextEditor/utils/markdownConverter.d.ts +0 -6
  171. package/lib/components/RichTextEditor/utils/markdownConverter.d.ts.map +0 -1
  172. package/lib/components/RichTextEditor/utils/markdownConverter.js +0 -130
  173. package/lib/components/RichTextEditor/utils/markdownConverter.js.map +0 -1
  174. package/lib/components/RichTextEditor/utils/renderers.d.ts +0 -22
  175. package/lib/components/RichTextEditor/utils/renderers.d.ts.map +0 -1
  176. package/lib/components/RichTextEditor/utils/renderers.js +0 -163
  177. package/lib/components/RichTextEditor/utils/renderers.js.map +0 -1
  178. package/lib/components/RichTextEditor/utils/search.d.ts +0 -11
  179. package/lib/components/RichTextEditor/utils/search.d.ts.map +0 -1
  180. package/lib/components/RichTextEditor/utils/search.js +0 -37
  181. package/lib/components/RichTextEditor/utils/search.js.map +0 -1
  182. package/lib/components/RichTextEditor/utils/slateConverter.d.ts +0 -25
  183. package/lib/components/RichTextEditor/utils/slateConverter.d.ts.map +0 -1
  184. package/lib/components/RichTextEditor/utils/slateConverter.js +0 -88
  185. package/lib/components/RichTextEditor/utils/slateConverter.js.map +0 -1
  186. package/lib/components/RichTextEditor/utils/utils.types.d.ts +0 -3
  187. package/lib/components/RichTextEditor/utils/utils.types.d.ts.map +0 -1
  188. package/lib/components/RichTextEditor/utils/utils.types.js +0 -3
  189. package/lib/components/RichTextEditor/utils/utils.types.js.map +0 -1
  190. package/lib/index.d.ts +0 -5
  191. package/lib/index.d.ts.map +0 -1
  192. package/lib/index.js +0 -6
  193. package/lib/index.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-rte",
3
- "version": "5.0.0-dev.4.7",
3
+ "version": "5.0.0-dev.4.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/pegasystems/cosmos-react.git",
@@ -20,7 +20,7 @@
20
20
  "build": "tsc -b"
21
21
  },
22
22
  "dependencies": {
23
- "@pega/cosmos-react-core": "5.0.0-dev.4.7",
23
+ "@pega/cosmos-react-core": "5.0.0-dev.4.8",
24
24
  "@popperjs/core": "^2.11.6",
25
25
  "@types/marked": "^4.0.2",
26
26
  "@types/parse5": "^6.0.0",
@@ -1,12 +0,0 @@
1
- import { FunctionComponent } from 'react';
2
- import { ForwardProps } from '@pega/cosmos-react-core';
3
- import { DynamicContentEditorProps } from './DynamicContentEditor.types';
4
- export declare const StyledSearchPopover: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
5
- offset?: number | undefined;
6
- portal?: boolean | undefined;
7
- }, never>;
8
- declare const _default: FunctionComponent<DynamicContentEditorProps & ForwardProps> & {
9
- getTestIds: (testIdProp?: string | undefined) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["insert-field", "insert-field-modal", "insert-field-modal-cancel", "insert-field-modal-submit"]>;
10
- };
11
- export default _default;
12
- //# sourceMappingURL=DynamicContentEditor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicContentEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAgD,MAAM,OAAO,CAAC;AAIpG,OAAO,EAGL,YAAY,EAcb,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EACL,yBAAyB,EAI1B,MAAM,8BAA8B,CAAC;AAQtC,eAAO,MAAM,mBAAmB;;;SAE/B,CAAC;;;;AA4VF,wBAAiF"}
@@ -1,252 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useRef, useEffect, useState } from 'react';
3
- import styled from 'styled-components';
4
- import { Button, defaultThemeProp, Menu, menuHelpers, Modal, Popover, StyledPopover, useModalManager, useConsolidatedRef, useI18n, useUID, useTestIds, withTestIds } from '@pega/cosmos-react-core';
5
- import { getKeyCommand } from '@pega/cosmos-react-rte/lib/components/RichTextEditor/Toolbar/utils';
6
- import { Editor } from '../Editor';
7
- import { isFieldMenuItem } from './DynamicContentEditor.types';
8
- import { pegaReferenceElementStyle, createPegaReferenceElement } from './PegaCustomElement';
9
- import { getDynamicContentEditorTestIds } from './DynamicContentEditor.test-ids';
10
- const StyledDynamicContentEditor = styled.div ``;
11
- export const StyledSearchPopover = styled(StyledPopover) `
12
- min-width: 20rem;
13
- `;
14
- StyledDynamicContentEditor.defaultProps = defaultThemeProp;
15
- const DynamicContentEditor = forwardRef(function DynamicContentEditor({ testId, form: { dynamicContentPicker, onSubmit }, onActiveFieldChange, label, toolbar, fieldItems, defaultValue, onBlur, ...restProps }, ref) {
16
- const menuID = useUID();
17
- const { create } = useModalManager();
18
- const t = useI18n();
19
- const testIds = useTestIds(testId, getDynamicContentEditorTestIds);
20
- const modalMethods = useRef();
21
- const [editor, setEditor] = useState();
22
- const [bookmark, setBookmark] = useState();
23
- const [fieldMenuItems, setFieldMenuItems] = useState(fieldItems || []);
24
- const [currentElementId, setCurrentElementId] = useState('');
25
- const [currentElementContent, setCurrentElementContent] = useState('');
26
- const [currentElementNamespace, setCurrentElementNamespace] = useState('');
27
- const [currentCursorPosition, setCurrentCursorPosition] = useState({
28
- bottom: 0,
29
- height: 0,
30
- left: 0,
31
- right: 0,
32
- top: 0,
33
- width: 0,
34
- x: 0,
35
- y: 0,
36
- toJSON: () => { }
37
- });
38
- const [showFieldsPopover, setShowFieldsPopover] = useState(false);
39
- const fieldPopoverRef = useRef(null);
40
- const editorRef = useConsolidatedRef(ref);
41
- const tooltip = getKeyCommand(navigator.appVersion.includes('Mac'), ({ ctrl }) => `${t('rte_insert_field')} (${ctrl}/)`);
42
- const insertField = (field) => {
43
- if (!editor)
44
- return;
45
- const fieldContent = `<pega-reference role="button" contenteditable="false" data-rule-type='field' data-rule-id=${field.id} ${field.namespace && `data-rule-namespace=${field.namespace}`}>${field.text}</pega-reference>`;
46
- if (bookmark) {
47
- editor.selection.moveToBookmark(bookmark);
48
- editor.selection.setContent(fieldContent);
49
- }
50
- else {
51
- editor.insertContent(fieldContent);
52
- }
53
- modalMethods.current?.dismiss();
54
- };
55
- const modalProps = {
56
- 'data-testid': testIds.insertFieldModal,
57
- children: dynamicContentPicker,
58
- heading: t('rte_insert_field'),
59
- actions: (_jsxs(_Fragment, { children: [_jsx(Button, { "data-testid": testIds.insertFieldModalCancel, variant: 'secondary', onClick: () => modalMethods.current?.dismiss(), children: t('cancel') }), _jsx(Button, { "data-testid": testIds.insertFieldModalSubmit, variant: 'primary', onClick: () => onSubmit(insertField), children: t('submit') })] })),
60
- center: true,
61
- onAfterClose: () => {
62
- setBookmark(undefined);
63
- setCurrentElementId('');
64
- setCurrentElementContent('');
65
- setCurrentElementNamespace('');
66
- onActiveFieldChange({ id: '', text: '', namespace: '' });
67
- },
68
- onBeforeOpen: () => {
69
- if (currentElementId) {
70
- onActiveFieldChange({
71
- id: currentElementId,
72
- text: currentElementContent,
73
- namespace: currentElementNamespace
74
- });
75
- }
76
- }
77
- };
78
- const findAndRenameField = (fieldId) => {
79
- if (!editor || !fieldMenuItems)
80
- return;
81
- const selectedRange = editor.selection.getRng();
82
- const endOffset = selectedRange.endOffset;
83
- const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(0, endOffset);
84
- if (stringToSearch === undefined)
85
- return;
86
- const splitSearch = stringToSearch.split(' ');
87
- const fieldString = splitSearch[splitSearch.length - 1];
88
- const range = editor.getDoc().createRange();
89
- const startPos = stringToSearch.lastIndexOf(fieldString);
90
- const endPos = startPos + fieldString.length;
91
- range.setStart(selectedRange.commonAncestorContainer, startPos);
92
- range.setEnd(selectedRange.commonAncestorContainer, endPos);
93
- editor.getDoc().getSelection()?.removeAllRanges();
94
- editor.getDoc().getSelection()?.addRange(range);
95
- const selectedField = menuHelpers.getItem(fieldMenuItems, fieldId);
96
- if (selectedField && isFieldMenuItem(selectedField)) {
97
- editor.selection.setContent(`<pega-reference role="button" contenteditable="false" data-rule-type="field" data-rule-id="${selectedField.id}" ${selectedField.namespace && `data-rule-namespace=${selectedField.namespace}`}>${selectedField.primary}</pega-reference>`);
98
- setShowFieldsPopover(false);
99
- }
100
- };
101
- const hidePopover = () => {
102
- if (fieldPopoverRef)
103
- setShowFieldsPopover(false);
104
- };
105
- const filterFieldMenu = (searchString) => {
106
- setShowFieldsPopover(true);
107
- setFieldMenuItems(fieldItems || []);
108
- if (/\s/.test(searchString)) {
109
- setShowFieldsPopover(false);
110
- return;
111
- }
112
- if (searchString && fieldMenuItems) {
113
- const newFieldMenuItems = menuHelpers
114
- .flatten(fieldMenuItems)
115
- .filter(({ primary }) => primary.toLowerCase().startsWith(searchString.toLocaleLowerCase()));
116
- if (newFieldMenuItems) {
117
- setShowFieldsPopover(true);
118
- setFieldMenuItems(newFieldMenuItems);
119
- }
120
- else
121
- setShowFieldsPopover(false);
122
- }
123
- };
124
- const updateBookmarkAndCurrentElement = (editorSelection) => {
125
- const targetEl = editorSelection.getNode();
126
- const fieldId = targetEl.getAttribute('data-rule-id');
127
- const fieldNamespace = targetEl.getAttribute('data-rule-namespace');
128
- const fieldValue = targetEl.innerText;
129
- setBookmark(editorSelection.getBookmark());
130
- setCurrentElementId(fieldId || '');
131
- setCurrentElementContent(fieldValue);
132
- setCurrentElementNamespace(fieldNamespace || '');
133
- };
134
- const handleElementClick = ({ target }) => {
135
- if (editor && target && target.tagName === 'PEGA-REFERENCE') {
136
- updateBookmarkAndCurrentElement(editor.selection);
137
- }
138
- hidePopover();
139
- };
140
- const onInsertField = (incEditor) => {
141
- const targetEl = incEditor.selection.getNode();
142
- if (targetEl.tagName === 'PEGA-REFERENCE') {
143
- updateBookmarkAndCurrentElement(incEditor.selection);
144
- }
145
- else {
146
- modalMethods.current = create(Modal, modalProps);
147
- }
148
- };
149
- const isPegaRefActive = (incEditor) => {
150
- const targetEl = incEditor.selection.getNode();
151
- return targetEl.tagName === 'PEGA-REFERENCE';
152
- };
153
- const fieldSelectionPopover = (_jsx(Popover, { show: showFieldsPopover, strategy: 'fixed', ref: fieldPopoverRef, target: {
154
- getBoundingClientRect() {
155
- return currentCursorPosition;
156
- }
157
- }, modifiers: [
158
- {
159
- name: 'offset',
160
- options: {
161
- offset: () => {
162
- const iframe = editorRef.current?.element?.querySelector('iframe');
163
- const iframeRect = iframe?.getBoundingClientRect();
164
- const x = iframeRect?.x ?? 0;
165
- const y = iframeRect?.y ?? 0;
166
- return [x, y];
167
- }
168
- }
169
- }
170
- ], placement: 'bottom-start', children: fieldMenuItems && (_jsx(Menu, { id: menuID, items: fieldMenuItems, as: StyledSearchPopover, focusControlEl: editor?.getBody() || undefined, mode: 'action', onItemClick: findAndRenameField, variant: 'drill-down' })) }));
171
- useEffect(() => {
172
- if (currentElementId && currentElementContent)
173
- modalMethods.current = create(Modal, modalProps);
174
- }, [currentElementId, currentElementContent]);
175
- useEffect(() => {
176
- editor?.getDoc().addEventListener('click', handleElementClick);
177
- return () => {
178
- editor?.getDoc().removeEventListener('click', handleElementClick);
179
- };
180
- }, [editor, editorRef.current]);
181
- useEffect(() => {
182
- if (modalMethods.current) {
183
- modalMethods.current.update(modalProps);
184
- }
185
- }, [modalProps]);
186
- const onEditorChange = (formEditor) => {
187
- if (formEditor) {
188
- const targetEl = formEditor.selection.getBoundingClientRect();
189
- const { left = 0, top = 0 } = targetEl ?? {};
190
- setCurrentCursorPosition({
191
- ...formEditor.selection.getBoundingClientRect(),
192
- x: left,
193
- y: top,
194
- toJSON: () => { }
195
- });
196
- if (formEditor.selection.isCollapsed()) {
197
- // get the full line string
198
- const selectedRange = formEditor.selection.getRng();
199
- const endOffset = selectedRange.endOffset;
200
- const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(0, endOffset);
201
- const fieldString = stringToSearch?.split(' ')[stringToSearch.split(' ').length - 1];
202
- if (fieldString?.startsWith('@') &&
203
- fieldString.indexOf('@') === fieldString.lastIndexOf('@')) {
204
- filterFieldMenu(fieldString.slice(1));
205
- }
206
- else
207
- setShowFieldsPopover(false);
208
- }
209
- }
210
- };
211
- const onKeyDown = event => {
212
- if ((event?.key === 'Enter' ||
213
- event?.key === 'ArrowLeft' ||
214
- event?.key === 'ArrowRight' ||
215
- event?.key === 'ArrowDown' ||
216
- event?.key === 'ArrowUp') &&
217
- !!fieldPopoverRef.current) {
218
- event?.preventDefault();
219
- }
220
- if (event?.key === 'Escape' && !!fieldPopoverRef.current) {
221
- hidePopover();
222
- }
223
- };
224
- return (_jsx(Editor, { "data-testid": testIds.root, ref: editorRef, ...restProps, label: label, toolbar: toolbar, customComponents: [
225
- {
226
- createCustomElement: createPegaReferenceElement,
227
- name: 'pega-reference',
228
- extensionAttributes: ['contenteditable'],
229
- style: pegaReferenceElementStyle
230
- }
231
- ], customActions: [
232
- {
233
- 'data-testid': testIds.insertField,
234
- icon: 'code',
235
- text: tooltip,
236
- onMouseDown: () => {
237
- modalMethods.current = create(Modal, modalProps);
238
- },
239
- active: isPegaRefActive,
240
- shortcut: {
241
- pattern: 'meta+191',
242
- description: tooltip,
243
- command: onInsertField
244
- }
245
- }
246
- ], onInit: setEditor, onChange: onEditorChange, onBlur: () => {
247
- onBlur?.();
248
- hidePopover();
249
- }, onKeyDown: onKeyDown, defaultValue: defaultValue, children: fieldSelectionPopover }));
250
- });
251
- export default withTestIds(DynamicContentEditor, getDynamicContentEditorTestIds);
252
- //# sourceMappingURL=DynamicContentEditor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicContentEditor.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpG,OAAO,MAAM,MAA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AC,KAAK,EAAE,UAAU,CAAC,CAAC;gBACnD,CAAC;gBACD,MAAM,EAAE,eAAe;gBACvB,QAAQ,EAAE;oBACR,OAAO,EAAE,UAAU;oBACnB,WAAW,EAAE,OAAO;oBACpB,OAAO,EAAE,aAAa;iBACvB;aACF;SACF,EACD,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,GAAG,EAAE;YACX,MAAM,EAAE,EAAE,CAAC;YACX,WAAW,EAAE,CAAC;QAChB,CAAC,EACD,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,YAEzB,qBAAqB,GACf,CACV,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,eAAe,WAAW,CAAC,oBAAoB,EAAE,8BAA8B,CAAC,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, useRef, useEffect, useState } from 'react';\nimport styled from 'styled-components';\nimport { Bookmark, Editor as TinyMCEEditor, EditorSelection } from 'tinymce';\n\nimport {\n Button,\n defaultThemeProp,\n ForwardProps,\n Menu,\n menuHelpers,\n Modal,\n ModalMethods,\n Popover,\n PropsWithDefaults,\n StyledPopover,\n useModalManager,\n useConsolidatedRef,\n useI18n,\n useUID,\n useTestIds,\n withTestIds\n} from '@pega/cosmos-react-core';\nimport { getKeyCommand } from '@pega/cosmos-react-rte/lib/components/RichTextEditor/Toolbar/utils';\n\nimport { Editor, EditorProps } from '../Editor';\n\nimport {\n DynamicContentEditorProps,\n FieldItems,\n ItemType,\n isFieldMenuItem\n} from './DynamicContentEditor.types';\nimport { pegaReferenceElementStyle, createPegaReferenceElement } from './PegaCustomElement';\nimport { getDynamicContentEditorTestIds } from './DynamicContentEditor.test-ids';\n\ntype DynamicContentEditorPropsWithDefaults = PropsWithDefaults<DynamicContentEditorProps>;\n\nconst StyledDynamicContentEditor = styled.div<DynamicContentEditorPropsWithDefaults>``;\n\nexport const StyledSearchPopover = styled(StyledPopover)`\n min-width: 20rem;\n`;\n\nStyledDynamicContentEditor.defaultProps = defaultThemeProp;\n\nconst DynamicContentEditor: FunctionComponent<DynamicContentEditorProps & ForwardProps> =\n forwardRef(function DynamicContentEditor(\n {\n testId,\n form: { dynamicContentPicker, onSubmit },\n onActiveFieldChange,\n label,\n toolbar,\n fieldItems,\n defaultValue,\n onBlur,\n ...restProps\n }: PropsWithoutRef<DynamicContentEditorProps>,\n ref: DynamicContentEditorProps['ref']\n ) {\n const menuID = useUID();\n const { create } = useModalManager();\n const t = useI18n();\n const testIds = useTestIds(testId, getDynamicContentEditorTestIds);\n\n const modalMethods = useRef<ModalMethods>();\n const [editor, setEditor] = useState<TinyMCEEditor | undefined>();\n const [bookmark, setBookmark] = useState<Bookmark | undefined>();\n const [fieldMenuItems, setFieldMenuItems] = useState<FieldItems[]>(fieldItems || []);\n const [currentElementId, setCurrentElementId] = useState('');\n const [currentElementContent, setCurrentElementContent] = useState('');\n const [currentElementNamespace, setCurrentElementNamespace] = useState('');\n const [currentCursorPosition, setCurrentCursorPosition] = useState({\n bottom: 0,\n height: 0,\n left: 0,\n right: 0,\n top: 0,\n width: 0,\n x: 0,\n y: 0,\n toJSON: () => {}\n });\n const [showFieldsPopover, setShowFieldsPopover] = useState<boolean>(false);\n\n const fieldPopoverRef = useRef<HTMLDivElement>(null);\n const editorRef = useConsolidatedRef(ref);\n\n const tooltip = getKeyCommand(\n navigator.appVersion.includes('Mac'),\n ({ ctrl }) => `${t('rte_insert_field')} (${ctrl}/)`\n );\n\n const insertField = (field: ItemType) => {\n if (!editor) return;\n\n const fieldContent = `<pega-reference role=\"button\" contenteditable=\"false\" data-rule-type='field' data-rule-id=${\n field.id\n } ${field.namespace && `data-rule-namespace=${field.namespace}`}>${\n field.text\n }</pega-reference>`;\n if (bookmark) {\n editor.selection.moveToBookmark(bookmark);\n editor.selection.setContent(fieldContent);\n } else {\n editor.insertContent(fieldContent);\n }\n\n modalMethods.current?.dismiss();\n };\n\n const modalProps = {\n 'data-testid': testIds.insertFieldModal,\n children: dynamicContentPicker,\n heading: t('rte_insert_field'),\n actions: (\n <>\n <Button\n data-testid={testIds.insertFieldModalCancel}\n variant='secondary'\n onClick={() => modalMethods.current?.dismiss()}\n >\n {t('cancel')}\n </Button>\n <Button\n data-testid={testIds.insertFieldModalSubmit}\n variant='primary'\n onClick={() => onSubmit(insertField)}\n >\n {t('submit')}\n </Button>\n </>\n ),\n center: true,\n onAfterClose: () => {\n setBookmark(undefined);\n setCurrentElementId('');\n setCurrentElementContent('');\n setCurrentElementNamespace('');\n onActiveFieldChange({ id: '', text: '', namespace: '' });\n },\n onBeforeOpen: () => {\n if (currentElementId) {\n onActiveFieldChange({\n id: currentElementId,\n text: currentElementContent,\n namespace: currentElementNamespace\n });\n }\n }\n };\n\n const findAndRenameField = (fieldId: string) => {\n if (!editor || !fieldMenuItems) return;\n\n const selectedRange = editor.selection.getRng();\n const endOffset = selectedRange.endOffset;\n const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(0, endOffset);\n if (stringToSearch === undefined) return;\n\n const splitSearch = stringToSearch.split(' ');\n const fieldString = splitSearch[splitSearch.length - 1];\n const range = editor.getDoc().createRange();\n\n const startPos = stringToSearch.lastIndexOf(fieldString);\n const endPos = startPos + fieldString.length;\n range.setStart(selectedRange.commonAncestorContainer, startPos);\n range.setEnd(selectedRange.commonAncestorContainer, endPos);\n editor.getDoc().getSelection()?.removeAllRanges();\n editor.getDoc().getSelection()?.addRange(range);\n\n const selectedField = menuHelpers.getItem(fieldMenuItems, fieldId);\n if (selectedField && isFieldMenuItem(selectedField)) {\n editor.selection.setContent(\n `<pega-reference role=\"button\" contenteditable=\"false\" data-rule-type=\"field\" data-rule-id=\"${\n selectedField.id\n }\" ${selectedField.namespace && `data-rule-namespace=${selectedField.namespace}`}>${\n selectedField.primary\n }</pega-reference>`\n );\n setShowFieldsPopover(false);\n }\n };\n\n const hidePopover = () => {\n if (fieldPopoverRef) setShowFieldsPopover(false);\n };\n\n const filterFieldMenu = (searchString: string) => {\n setShowFieldsPopover(true);\n setFieldMenuItems(fieldItems || []);\n if (/\\s/.test(searchString)) {\n setShowFieldsPopover(false);\n return;\n }\n if (searchString && fieldMenuItems) {\n const newFieldMenuItems: FieldItems[] = menuHelpers\n .flatten(fieldMenuItems)\n .filter(({ primary }) =>\n primary.toLowerCase().startsWith(searchString.toLocaleLowerCase())\n );\n if (newFieldMenuItems) {\n setShowFieldsPopover(true);\n setFieldMenuItems(newFieldMenuItems);\n } else setShowFieldsPopover(false);\n }\n };\n\n const updateBookmarkAndCurrentElement = (editorSelection: EditorSelection) => {\n const targetEl = editorSelection.getNode() as HTMLElement;\n const fieldId = targetEl.getAttribute('data-rule-id');\n const fieldNamespace = targetEl.getAttribute('data-rule-namespace');\n const fieldValue = targetEl.innerText;\n setBookmark(editorSelection.getBookmark());\n setCurrentElementId(fieldId || '');\n setCurrentElementContent(fieldValue);\n setCurrentElementNamespace(fieldNamespace || '');\n };\n\n const handleElementClick = ({ target }: MouseEvent) => {\n if (editor && target && (target as HTMLElement).tagName === 'PEGA-REFERENCE') {\n updateBookmarkAndCurrentElement(editor.selection);\n }\n hidePopover();\n };\n\n const onInsertField = (incEditor: TinyMCEEditor) => {\n const targetEl = incEditor.selection.getNode();\n if (targetEl.tagName === 'PEGA-REFERENCE') {\n updateBookmarkAndCurrentElement(incEditor.selection);\n } else {\n modalMethods.current = create(Modal, modalProps);\n }\n };\n\n const isPegaRefActive = (incEditor: TinyMCEEditor) => {\n const targetEl = incEditor.selection.getNode();\n return targetEl.tagName === 'PEGA-REFERENCE';\n };\n\n const fieldSelectionPopover = (\n <Popover\n show={showFieldsPopover}\n strategy='fixed'\n ref={fieldPopoverRef}\n target={{\n getBoundingClientRect() {\n return currentCursorPosition;\n }\n }}\n modifiers={[\n {\n name: 'offset',\n options: {\n offset: () => {\n const iframe = editorRef.current?.element?.querySelector('iframe');\n const iframeRect = iframe?.getBoundingClientRect();\n const x = iframeRect?.x ?? 0;\n const y = iframeRect?.y ?? 0;\n return [x, y];\n }\n }\n }\n ]}\n placement='bottom-start'\n >\n {fieldMenuItems && (\n <Menu\n id={menuID}\n items={fieldMenuItems}\n as={StyledSearchPopover}\n focusControlEl={editor?.getBody() || undefined}\n mode='action'\n onItemClick={findAndRenameField}\n variant='drill-down'\n />\n )}\n </Popover>\n );\n\n useEffect(() => {\n if (currentElementId && currentElementContent)\n modalMethods.current = create(Modal, modalProps);\n }, [currentElementId, currentElementContent]);\n\n useEffect(() => {\n editor?.getDoc().addEventListener('click', handleElementClick);\n return () => {\n editor?.getDoc().removeEventListener('click', handleElementClick);\n };\n }, [editor, editorRef.current]);\n\n useEffect(() => {\n if (modalMethods.current) {\n modalMethods.current.update(modalProps);\n }\n }, [modalProps]);\n\n const onEditorChange: EditorProps['onChange'] = (formEditor?: TinyMCEEditor) => {\n if (formEditor) {\n const targetEl = formEditor.selection.getBoundingClientRect();\n const { left = 0, top = 0 } = targetEl ?? {};\n setCurrentCursorPosition({\n ...formEditor.selection.getBoundingClientRect(),\n x: left,\n y: top,\n toJSON: () => {}\n });\n\n if (formEditor.selection.isCollapsed()) {\n // get the full line string\n const selectedRange = formEditor.selection.getRng();\n const endOffset = selectedRange.endOffset;\n const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(\n 0,\n endOffset\n );\n const fieldString = stringToSearch?.split(' ')[stringToSearch.split(' ').length - 1];\n if (\n fieldString?.startsWith('@') &&\n fieldString.indexOf('@') === fieldString.lastIndexOf('@')\n ) {\n filterFieldMenu(fieldString.slice(1));\n } else setShowFieldsPopover(false);\n }\n }\n };\n\n const onKeyDown: EditorProps['onKeyDown'] = event => {\n if (\n (event?.key === 'Enter' ||\n event?.key === 'ArrowLeft' ||\n event?.key === 'ArrowRight' ||\n event?.key === 'ArrowDown' ||\n event?.key === 'ArrowUp') &&\n !!fieldPopoverRef.current\n ) {\n event?.preventDefault();\n }\n if (event?.key === 'Escape' && !!fieldPopoverRef.current) {\n hidePopover();\n }\n };\n\n return (\n <Editor\n data-testid={testIds.root}\n ref={editorRef}\n {...restProps}\n label={label}\n toolbar={toolbar}\n customComponents={[\n {\n createCustomElement: createPegaReferenceElement,\n name: 'pega-reference',\n extensionAttributes: ['contenteditable'],\n style: pegaReferenceElementStyle\n }\n ]}\n customActions={[\n {\n 'data-testid': testIds.insertField,\n icon: 'code',\n text: tooltip,\n onMouseDown: () => {\n modalMethods.current = create(Modal, modalProps);\n },\n active: isPegaRefActive,\n shortcut: {\n pattern: 'meta+191',\n description: tooltip,\n command: onInsertField\n }\n }\n ]}\n onInit={setEditor}\n onChange={onEditorChange}\n onBlur={() => {\n onBlur?.();\n hidePopover();\n }}\n onKeyDown={onKeyDown}\n defaultValue={defaultValue}\n >\n {fieldSelectionPopover}\n </Editor>\n );\n });\n\nexport default withTestIds(DynamicContentEditor, getDynamicContentEditorTestIds);\n"]}
@@ -1,2 +0,0 @@
1
- export declare const getDynamicContentEditorTestIds: (testIdProp?: string | undefined) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["insert-field", "insert-field-modal", "insert-field-modal-cancel", "insert-field-modal-submit"]>;
2
- //# sourceMappingURL=DynamicContentEditor.test-ids.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicContentEditor.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,8BAA8B,iMAKhC,CAAC"}
@@ -1,8 +0,0 @@
1
- import { createTestIds } from '@pega/cosmos-react-core';
2
- export const getDynamicContentEditorTestIds = createTestIds('dynamic-content-editor', [
3
- 'insert-field',
4
- 'insert-field-modal',
5
- 'insert-field-modal-cancel',
6
- 'insert-field-modal-submit'
7
- ]);
8
- //# sourceMappingURL=DynamicContentEditor.test-ids.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicContentEditor.test-ids.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,8BAA8B,GAAG,aAAa,CAAC,wBAAwB,EAAE;IACpF,cAAc;IACd,oBAAoB;IACpB,2BAA2B;IAC3B,2BAA2B;CACnB,CAAC,CAAC","sourcesContent":["import { createTestIds } from '@pega/cosmos-react-core';\n\nexport const getDynamicContentEditorTestIds = createTestIds('dynamic-content-editor', [\n 'insert-field',\n 'insert-field-modal',\n 'insert-field-modal-cancel',\n 'insert-field-modal-submit'\n] as const);\n"]}
@@ -1,35 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { MenuGroupProps, MenuItemProps } from '@pega/cosmos-react-core/lib/components/Menu/Menu.types';
3
- import { TestIdProp } from '@pega/cosmos-react-core';
4
- import { EditorProps } from '../Editor';
5
- export type ItemType = {
6
- id: string;
7
- text: string;
8
- namespace?: string;
9
- };
10
- export type FieldMenuItem = MenuItemProps & {
11
- namespace?: string;
12
- items?: FieldItems[];
13
- };
14
- export type FieldMenuGroup = MenuGroupProps & {
15
- namespace?: string;
16
- items?: FieldItems[];
17
- };
18
- export type FieldItems = FieldMenuItem | FieldMenuGroup;
19
- export declare const isFieldMenuItem: (item: FieldItems) => item is FieldMenuItem;
20
- export interface DynamicContentEditorProps extends EditorProps, TestIdProp {
21
- /** Insert field form */
22
- form: {
23
- onSubmit: (insertField: (selectedField: ItemType) => void) => void;
24
- dynamicContentPicker: ReactNode;
25
- };
26
- onActiveFieldChange: (field: ItemType) => void;
27
- /** Property selection array */
28
- fieldItems?: FieldItems[];
29
- defaultValue?: string;
30
- onBlur?: () => void;
31
- }
32
- export interface DynamicContentEditorContextProps extends DynamicContentEditorProps {
33
- updateProperties?: (selectedfield: ItemType) => void;
34
- }
35
- //# sourceMappingURL=DynamicContentEditor.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicContentEditor.types.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.types.ts"],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AAa,EAAE,QAAQ,KAAK,IAAI,CAAC;CACtD"}
@@ -1,3 +0,0 @@
1
- import { hasProp } from '@pega/cosmos-react-core';
2
- export const isFieldMenuItem = (item) => hasProp(item, 'primary');
3
- //# sourceMappingURL=DynamicContentEditor.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicContentEditor.types.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.types.ts"],"names":[],"mappings":"AAMA,OAAO,EAAc,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAsB9D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAgB,EAAyB,EAAE,CACzE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { ReactNode } from 'react';\n\nimport {\n MenuGroupProps,\n MenuItemProps\n} from '@pega/cosmos-react-core/lib/components/Menu/Menu.types';\nimport { TestIdProp, hasProp } from '@pega/cosmos-react-core';\n\nimport { EditorProps } from '../Editor';\n\nexport type ItemType = {\n id: string;\n text: string;\n namespace?: string;\n};\n\nexport type FieldMenuItem = MenuItemProps & {\n namespace?: string;\n items?: FieldItems[];\n};\n\nexport type FieldMenuGroup = MenuGroupProps & {\n namespace?: string;\n items?: FieldItems[];\n};\n\nexport type FieldItems = FieldMenuItem | FieldMenuGroup;\n\nexport const isFieldMenuItem = (item: FieldItems): item is FieldMenuItem =>\n hasProp(item, 'primary');\n\nexport interface DynamicContentEditorProps extends EditorProps, TestIdProp {\n /** Insert field form */\n form: {\n onSubmit: (insertField: (selectedField: ItemType) => void) => void;\n dynamicContentPicker: ReactNode;\n };\n onActiveFieldChange: (field: ItemType) => void;\n /** Property selection array */\n fieldItems?: FieldItems[];\n defaultValue?: string;\n onBlur?: () => void;\n}\n\nexport interface DynamicContentEditorContextProps extends DynamicContentEditorProps {\n updateProperties?: (selectedfield: ItemType) => void;\n}\n"]}