@pega/cosmos-react-rte 9.0.0-build.29.26 → 9.0.0-build.29.27

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 (111) hide show
  1. package/lib/components/Editor/Editor.d.ts +1 -1
  2. package/lib/components/Editor/Editor.d.ts.map +1 -1
  3. package/lib/components/Editor/Editor.js +78 -5
  4. package/lib/components/Editor/Editor.js.map +1 -1
  5. package/lib/components/Editor/Editor.styles.d.ts +6 -0
  6. package/lib/components/Editor/Editor.styles.d.ts.map +1 -1
  7. package/lib/components/Editor/Editor.styles.js +39 -3
  8. package/lib/components/Editor/Editor.styles.js.map +1 -1
  9. package/lib/components/Editor/Editor.test-ids.d.ts +1 -1
  10. package/lib/components/Editor/Editor.test-ids.d.ts.map +1 -1
  11. package/lib/components/Editor/Editor.types.d.ts +6 -0
  12. package/lib/components/Editor/Editor.types.d.ts.map +1 -1
  13. package/lib/components/Editor/Editor.types.js.map +1 -1
  14. package/lib/components/Editor/IframeTiptapEditor.d.ts +5 -1
  15. package/lib/components/Editor/IframeTiptapEditor.d.ts.map +1 -1
  16. package/lib/components/Editor/IframeTiptapEditor.js +290 -11
  17. package/lib/components/Editor/IframeTiptapEditor.js.map +1 -1
  18. package/lib/components/Editor/TableCellMenu.d.ts +35 -0
  19. package/lib/components/Editor/TableCellMenu.d.ts.map +1 -0
  20. package/lib/components/Editor/TableCellMenu.js +120 -0
  21. package/lib/components/Editor/TableCellMenu.js.map +1 -0
  22. package/lib/components/Editor/Toolbar/AlignmentSelect.d.ts +8 -0
  23. package/lib/components/Editor/Toolbar/AlignmentSelect.d.ts.map +1 -0
  24. package/lib/components/Editor/Toolbar/AlignmentSelect.js +137 -0
  25. package/lib/components/Editor/Toolbar/AlignmentSelect.js.map +1 -0
  26. package/lib/components/Editor/Toolbar/AnchorButton.d.ts.map +1 -1
  27. package/lib/components/Editor/Toolbar/AnchorButton.js +105 -71
  28. package/lib/components/Editor/Toolbar/AnchorButton.js.map +1 -1
  29. package/lib/components/Editor/Toolbar/ColorPickerButton.d.ts +9 -0
  30. package/lib/components/Editor/Toolbar/ColorPickerButton.d.ts.map +1 -0
  31. package/lib/components/Editor/Toolbar/ColorPickerButton.js +190 -0
  32. package/lib/components/Editor/Toolbar/ColorPickerButton.js.map +1 -0
  33. package/lib/components/Editor/Toolbar/FontFamilySelect.d.ts +8 -0
  34. package/lib/components/Editor/Toolbar/FontFamilySelect.d.ts.map +1 -0
  35. package/lib/components/Editor/Toolbar/FontFamilySelect.js +150 -0
  36. package/lib/components/Editor/Toolbar/FontFamilySelect.js.map +1 -0
  37. package/lib/components/Editor/Toolbar/FontSizeSelect.d.ts +8 -0
  38. package/lib/components/Editor/Toolbar/FontSizeSelect.d.ts.map +1 -0
  39. package/lib/components/Editor/Toolbar/FontSizeSelect.js +145 -0
  40. package/lib/components/Editor/Toolbar/FontSizeSelect.js.map +1 -0
  41. package/lib/components/Editor/Toolbar/ImageButton.d.ts.map +1 -1
  42. package/lib/components/Editor/Toolbar/ImageButton.js +9 -1
  43. package/lib/components/Editor/Toolbar/ImageButton.js.map +1 -1
  44. package/lib/components/Editor/Toolbar/SourceCodeButton.d.ts +8 -0
  45. package/lib/components/Editor/Toolbar/SourceCodeButton.d.ts.map +1 -0
  46. package/lib/components/Editor/Toolbar/SourceCodeButton.js +49 -0
  47. package/lib/components/Editor/Toolbar/SourceCodeButton.js.map +1 -0
  48. package/lib/components/Editor/Toolbar/TableButton.d.ts +8 -0
  49. package/lib/components/Editor/Toolbar/TableButton.d.ts.map +1 -0
  50. package/lib/components/Editor/Toolbar/TableButton.js +291 -0
  51. package/lib/components/Editor/Toolbar/TableButton.js.map +1 -0
  52. package/lib/components/Editor/Toolbar/TextSelect.d.ts.map +1 -1
  53. package/lib/components/Editor/Toolbar/TextSelect.js +30 -17
  54. package/lib/components/Editor/Toolbar/TextSelect.js.map +1 -1
  55. package/lib/components/Editor/Toolbar/Toolbar.d.ts +4 -2
  56. package/lib/components/Editor/Toolbar/Toolbar.d.ts.map +1 -1
  57. package/lib/components/Editor/Toolbar/Toolbar.js +140 -31
  58. package/lib/components/Editor/Toolbar/Toolbar.js.map +1 -1
  59. package/lib/components/Editor/Toolbar/Toolbar.test-ids.d.ts +2 -2
  60. package/lib/components/Editor/Toolbar/Toolbar.test-ids.d.ts.map +1 -1
  61. package/lib/components/Editor/Toolbar/Toolbar.test-ids.js +16 -1
  62. package/lib/components/Editor/Toolbar/Toolbar.test-ids.js.map +1 -1
  63. package/lib/components/Editor/Toolbar/WordCount.d.ts +8 -0
  64. package/lib/components/Editor/Toolbar/WordCount.d.ts.map +1 -0
  65. package/lib/components/Editor/Toolbar/WordCount.js +31 -0
  66. package/lib/components/Editor/Toolbar/WordCount.js.map +1 -0
  67. package/lib/components/Editor/extensions/FontSize.d.ts +21 -0
  68. package/lib/components/Editor/extensions/FontSize.d.ts.map +1 -0
  69. package/lib/components/Editor/extensions/FontSize.js +42 -0
  70. package/lib/components/Editor/extensions/FontSize.js.map +1 -0
  71. package/lib/components/Editor/extensions/TableCellSelection.d.ts +4 -0
  72. package/lib/components/Editor/extensions/TableCellSelection.d.ts.map +1 -0
  73. package/lib/components/Editor/extensions/TableCellSelection.js +53 -0
  74. package/lib/components/Editor/extensions/TableCellSelection.js.map +1 -0
  75. package/lib/components/Editor/hooks/useCloseOnEditorClick.d.ts +5 -0
  76. package/lib/components/Editor/hooks/useCloseOnEditorClick.d.ts.map +1 -0
  77. package/lib/components/Editor/hooks/useCloseOnEditorClick.js +18 -0
  78. package/lib/components/Editor/hooks/useCloseOnEditorClick.js.map +1 -0
  79. package/lib/components/Editor/hooks/useEscapeKey.d.ts +4 -0
  80. package/lib/components/Editor/hooks/useEscapeKey.d.ts.map +1 -0
  81. package/lib/components/Editor/hooks/useEscapeKey.js +24 -0
  82. package/lib/components/Editor/hooks/useEscapeKey.js.map +1 -0
  83. package/lib/components/Editor/hooks/useIframeSetup.d.ts +5 -1
  84. package/lib/components/Editor/hooks/useIframeSetup.d.ts.map +1 -1
  85. package/lib/components/Editor/hooks/useIframeSetup.js +13 -52
  86. package/lib/components/Editor/hooks/useIframeSetup.js.map +1 -1
  87. package/lib/components/Editor/hooks/useTableCellMenu.d.ts +22 -0
  88. package/lib/components/Editor/hooks/useTableCellMenu.d.ts.map +1 -0
  89. package/lib/components/Editor/hooks/useTableCellMenu.js +120 -0
  90. package/lib/components/Editor/hooks/useTableCellMenu.js.map +1 -0
  91. package/lib/components/Editor/iframeContentStyles.d.ts +10 -0
  92. package/lib/components/Editor/iframeContentStyles.d.ts.map +1 -0
  93. package/lib/components/Editor/iframeContentStyles.js +162 -0
  94. package/lib/components/Editor/iframeContentStyles.js.map +1 -0
  95. package/lib/components/Editor/sanitize.d.ts +3 -0
  96. package/lib/components/Editor/sanitize.d.ts.map +1 -0
  97. package/lib/components/Editor/sanitize.js +11 -0
  98. package/lib/components/Editor/sanitize.js.map +1 -0
  99. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.d.ts +4 -4
  100. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.d.ts.map +1 -1
  101. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.js.map +1 -1
  102. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.d.ts.map +1 -1
  103. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js +41 -26
  104. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js.map +1 -1
  105. package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts.map +1 -1
  106. package/lib/components/RichTextEditor/utils/interactionRenderer.js +20 -19
  107. package/lib/components/RichTextEditor/utils/interactionRenderer.js.map +1 -1
  108. package/lib/components/RichTextEditor/utils/markdownConverter.d.ts.map +1 -1
  109. package/lib/components/RichTextEditor/utils/markdownConverter.js +9 -0
  110. package/lib/components/RichTextEditor/utils/markdownConverter.js.map +1 -1
  111. package/package.json +17 -2
@@ -1,7 +1,7 @@
1
1
  import type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
2
2
  import type { EditorProps } from './Editor.types';
3
3
  declare const _default: ForwardRefForwardPropsComponent<EditorProps> & {
4
- getTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["iframe", "toolbar", "text-styles", "bold", "italic", "strike-through", "bulleted-list", "numbered-list", "indent", "unindent", "link", "image", "ai-rewrite", "label", "info", "additional-info", "suggestion-accept", "suggestion-reject"]>;
4
+ getTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["iframe", "toolbar", "text-styles", "bold", "italic", "strike-through", "underline", "subscript", "superscript", "font-family", "font-size", "text-color", "background-color", "alignment", "align-left", "align-center", "align-right", "bulleted-list", "numbered-list", "indent", "unindent", "table", "link", "image", "source-code", "ai-rewrite", "overflow", "word-count", "label", "info", "additional-info", "suggestion-accept", "suggestion-reject"]>;
5
5
  };
6
6
  export default _default;
7
7
  //# sourceMappingURL=Editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../../src/components/Editor/Editor.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAM/E,OAAO,KAAK,EAAE,WAAW,EAAgC,MAAM,gBAAgB,CAAC;;;;AA+fhF,wBAAqD"}
1
+ {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../../src/components/Editor/Editor.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAM/E,OAAO,KAAK,EAAE,WAAW,EAAgC,MAAM,gBAAgB,CAAC;;;;AA2oBhF,wBAAqD"}
@@ -1,17 +1,22 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { forwardRef, useEffect, useRef, useState, useImperativeHandle, useMemo, useCallback } from 'react';
3
3
  import { css } from 'styled-components';
4
4
  import { FormControl, Progress, HiddenText, useAfterInitialEffect, useTheme, useUID, useConsolidatedRef, useTestIds, withTestIds, useConfiguration, useI18n } from '@pega/cosmos-react-core';
5
5
  import StyledRichTextEditor from '../RichTextEditor/RichTextEditor.styles';
6
6
  import EditorContext from './Editor.context';
7
- import { StyledEditorContainer, StyledEditorIframe, StyledEditorRoot } from './Editor.styles';
7
+ import { StyledEditorContainer, StyledEditorIframe, StyledEditorRoot, StyledSourceTextarea } from './Editor.styles';
8
8
  import { getEditorTestIds } from './Editor.test-ids';
9
9
  import Toolbar from './Toolbar/Toolbar';
10
+ import WordCount from './Toolbar/WordCount';
10
11
  import { ImageEditDialog } from './ImageEditDialog';
11
12
  import ImageActionButtons from './ImageActionButtons';
13
+ import TableCellMenu from './TableCellMenu';
12
14
  import createFileItemElement from './FileItemElement';
13
15
  import useIframeSetup from './hooks/useIframeSetup';
14
16
  import useImageActions from './hooks/useImageActions';
17
+ import useTableCellMenu from './hooks/useTableCellMenu';
18
+ import { dispatchEditorClickEvent } from './hooks/useCloseOnEditorClick';
19
+ import sanitizeHtml from './sanitize';
15
20
  // Suggestion editor has no toolbar — formatting controls are intentionally omitted
16
21
  const SUGGESTION_TOOLBAR = [];
17
22
  const SuggestionEditor = ({ defaultValue, onGetContent, onContentChange, renderEditor }) => {
@@ -34,14 +39,17 @@ const SuggestionEditor = ({ defaultValue, onGetContent, onContentChange, renderE
34
39
  });
35
40
  };
36
41
  const Editor = forwardRef(function ForwardedEditor(props, ref) {
37
- const { testId, id, label, labelHidden, info, status, required, disabled, readOnly, onChange, onKeyDown, onFocus, onBlur, onImageAdded, onResolveSuggestion, onInit, onUnload, defaultValue, placeholder, children, additionalInfo, toolbar, customActions, customComponents = [], spellcheck = true, imageInsertionMode = 'all', initOptions, onRewriteClick, progress, autoFocus, height, autoResize = true, ...restProps } = props;
42
+ const { testId, id, label, labelHidden, info, status, required, disabled, readOnly, onChange, onKeyDown, onFocus, onBlur, onImageAdded, onResolveSuggestion, onInit, onUnload, defaultValue, placeholder, children, additionalInfo, toolbar, customActions, customComponents = [], spellcheck = true, imageInsertionMode = 'all', initOptions, onRewriteClick, progress, autoFocus, height, autoResize = true, secure = false, ...restProps } = props;
38
43
  const theme = useTheme();
39
44
  const { styleSheetTarget } = useConfiguration();
40
45
  const t = useI18n();
41
46
  const [focused, setFocused] = useState(false);
42
47
  const [tiptapEditor, setTiptapEditor] = useState(null);
43
48
  const [imageEditDialog, setImageEditDialog] = useState({ isOpen: false, attributes: null });
49
+ const [sourceMode, setSourceMode] = useState(false);
50
+ const [sourceCode, setSourceCode] = useState('');
44
51
  const editButtonRef = useRef(null);
52
+ const tableCellMenuButtonRef = useRef(null);
45
53
  const editorContainerRef = useRef(null);
46
54
  const generatedId = useUID();
47
55
  const editorId = id ?? generatedId;
@@ -54,6 +62,10 @@ const Editor = forwardRef(function ForwardedEditor(props, ref) {
54
62
  const testIds = useTestIds(testId, getEditorTestIds);
55
63
  // Check if images feature is enabled
56
64
  const imagesEnabled = toolbar?.includes('images') ?? false;
65
+ // Check if tables feature is enabled
66
+ const tablesEnabled = toolbar?.includes('tables') ?? false;
67
+ // Check if links feature is enabled (controls autolink behavior)
68
+ const linksEnabled = toolbar?.includes('links') ?? false;
57
69
  // Define built-in custom components and merge with user-provided ones
58
70
  const customElements = useMemo(() => {
59
71
  const FileItemStyle = css `
@@ -84,6 +96,8 @@ const Editor = forwardRef(function ForwardedEditor(props, ref) {
84
96
  }
85
97
  });
86
98
  }, [customElements]);
99
+ // Sanitize defaultValue if secure mode is enabled
100
+ const sanitizedDefaultValue = useMemo(() => (secure && defaultValue ? sanitizeHtml(defaultValue) : defaultValue), [secure, defaultValue]);
87
101
  // Mount Tiptap inside iframe using custom hook
88
102
  const { iframeEditorRef } = useIframeSetup({
89
103
  iframeRef,
@@ -91,7 +105,7 @@ const Editor = forwardRef(function ForwardedEditor(props, ref) {
91
105
  styleSheetTarget,
92
106
  customElements,
93
107
  placeholder,
94
- defaultValue,
108
+ defaultValue: sanitizedDefaultValue,
95
109
  disabled,
96
110
  readOnly,
97
111
  onChange,
@@ -103,6 +117,7 @@ const Editor = forwardRef(function ForwardedEditor(props, ref) {
103
117
  initOptions,
104
118
  onImageAdded,
105
119
  imagesEnabled,
120
+ linksEnabled,
106
121
  imageInsertionMode,
107
122
  pastedImages,
108
123
  editorId,
@@ -110,6 +125,7 @@ const Editor = forwardRef(function ForwardedEditor(props, ref) {
110
125
  setTiptapEditor,
111
126
  setFocused,
112
127
  autoResize,
128
+ secure,
113
129
  onTabOut: () => {
114
130
  // Focus first toolbar button when Tab is pressed in editor
115
131
  const toolbarEl = editorContainerRef.current?.querySelector('[data-testid$="toolbar"]');
@@ -117,6 +133,18 @@ const Editor = forwardRef(function ForwardedEditor(props, ref) {
117
133
  if (firstButton) {
118
134
  firstButton.focus();
119
135
  }
136
+ },
137
+ onFocusTableMenu: () => {
138
+ tableCellMenuButtonRef.current?.focus();
139
+ },
140
+ onFocusPreviousCellMenu: () => {
141
+ // Go to previous cell and then focus its menu
142
+ if (tiptapEditor) {
143
+ tiptapEditor.commands.goToPreviousCell();
144
+ setTimeout(() => {
145
+ tableCellMenuButtonRef.current?.focus();
146
+ }, 0);
147
+ }
120
148
  }
121
149
  });
122
150
  // Set up unload event listener to save content before iframe is destroyed
@@ -133,12 +161,40 @@ const Editor = forwardRef(function ForwardedEditor(props, ref) {
133
161
  abortController.abort();
134
162
  };
135
163
  }, [onUnload]);
164
+ // Dispatch event on iframe mousedown to close all open popovers/menus
165
+ useEffect(() => {
166
+ const iframeDoc = iframeRef.current?.contentDocument;
167
+ if (!iframeDoc)
168
+ return;
169
+ const handleMouseDown = () => {
170
+ dispatchEditorClickEvent();
171
+ };
172
+ iframeDoc.addEventListener('mousedown', handleMouseDown);
173
+ return () => iframeDoc.removeEventListener('mousedown', handleMouseDown);
174
+ }, [tiptapEditor]);
136
175
  // Set up image action buttons (edit and delete) using custom hook
137
176
  const { hoveredImagePosition, currentImageAttrs, currentImageElement, handleDelete: handleImageDelete, setIsOverButtons } = useImageActions({
138
177
  tiptapEditor,
139
178
  iframeRef,
140
179
  isDialogOpen: imageEditDialog.isOpen
141
180
  });
181
+ // Set up table cell menu using custom hook (only when tables are active)
182
+ const tableMenuEnabled = tablesEnabled && !readOnly && !disabled;
183
+ const { cellPosition, setIsOverMenu: setIsOverTableMenu, addRowBelow, addRowAbove, addColumnAfter, addColumnBefore, deleteRow, deleteColumn, deleteTable } = useTableCellMenu({
184
+ tiptapEditor: tableMenuEnabled ? tiptapEditor : null,
185
+ iframeRef
186
+ });
187
+ // Handle keyboard navigation from table menu to next cell (start of content)
188
+ const goToNextCell = useCallback(() => {
189
+ if (tiptapEditor) {
190
+ tiptapEditor.commands.focus();
191
+ tiptapEditor.commands.goToNextCell();
192
+ }
193
+ }, [tiptapEditor]);
194
+ // Handle keyboard navigation from table menu back to current cell
195
+ const returnToCell = useCallback(() => {
196
+ tiptapEditor?.commands.focus();
197
+ }, [tiptapEditor]);
142
198
  // Store the image element when opening the dialog to target the correct node on save
143
199
  const editingImageElementRef = useRef(null);
144
200
  // Handle edit button click from ImageActionButtons
@@ -263,7 +319,24 @@ const Editor = forwardRef(function ForwardedEditor(props, ref) {
263
319
  }
264
320
  }), [tiptapEditor, onImageAdded]);
265
321
  const renderSuggestionEditor = useCallback((suggestionProps) => (_jsx(SuggestionEditor, { defaultValue: suggestionProps.defaultValue, disabled: suggestionProps.disabled, readOnly: suggestionProps.readOnly, onGetContent: suggestionProps.onGetContent, onContentChange: suggestionProps.onContentChange, renderEditor: ({ ref: suggestionEditorRef, onInit: suggestionOnInit, onChange: suggestionOnChange }) => (_jsx(Editor, { ref: suggestionEditorRef, label: t('ai_rewrite_result_label'), labelHidden: true, toolbar: SUGGESTION_TOOLBAR, defaultValue: suggestionProps.defaultValue, disabled: suggestionProps.disabled, readOnly: suggestionProps.readOnly, height: height, onInit: suggestionOnInit, onChange: suggestionOnChange })) })), [height, t]);
266
- return (_jsxs(EditorContext.Provider, { value: ctx, children: [_jsx(StyledEditorRoot, { testId: testIds, label: label, labelFor: '', labelId: labelId, labelHidden: labelHidden, id: editorId, info: info, status: status, required: required, disabled: disabled, readOnly: readOnly, onResolveSuggestion: onResolveSuggestion, ref: formFieldRef, additionalInfo: additionalInfo, children: _jsx(FormControl, { ...restProps, ref: editorRef, required: required, disabled: disabled, readOnly: readOnly, status: status, as: StyledRichTextEditor, focused: focused, hasSuggestion: status === 'pending', children: _jsxs(StyledEditorContainer, { ref: editorContainerRef, children: [progress && (_jsx(Progress, { placement: 'local', message: typeof progress === 'string' ? progress : undefined })), _jsx(StyledEditorIframe, { "data-testid": testIds.iframe, role: 'application', "aria-label": typeof label === 'string' ? label : t('rte_text_formatting_toolbar'), "aria-describedby": required ? requiredDescriptionId : undefined, ref: iframeRef, tabIndex: 0, "$minHeight": height?.min, "$maxHeight": height?.max }), required && _jsx(HiddenText, { id: requiredDescriptionId, children: t('required') }), (toolbar?.length || customActions?.length) && tiptapEditor && (_jsx(Toolbar, { testId: testIds, features: toolbar || [], editor: tiptapEditor, customActions: customActions, imageInsertionMode: imageInsertionMode, onRewriteClick: onRewriteClick, renderSuggestionEditor: renderSuggestionEditor })), imagesEnabled && !readOnly && !disabled && (_jsx(ImageActionButtons, { ref: editButtonRef, position: hoveredImagePosition, containerRef: editorContainerRef, onEdit: onEditButtonClick, onDelete: handleImageDelete, onMouseEnter: () => setIsOverButtons(true), onMouseLeave: () => setIsOverButtons(false), editLabel: t('rte_edit_image', [currentImageAttrs?.alt || '']), deleteLabel: t('rte_delete_image', [currentImageAttrs?.alt || '']) }))] }) }) }), children, imageEditDialog.attributes && (_jsx(ImageEditDialog, { isOpen: imageEditDialog.isOpen, onClose: () => {
322
+ return (_jsxs(EditorContext.Provider, { value: ctx, children: [_jsx(StyledEditorRoot, { testId: testIds, label: label, labelFor: '', labelId: labelId, labelHidden: labelHidden, id: editorId, info: info, status: status, required: required, disabled: disabled, readOnly: readOnly, onResolveSuggestion: onResolveSuggestion, ref: formFieldRef, additionalInfo: additionalInfo, children: _jsxs(_Fragment, { children: [_jsx(FormControl, { ...restProps, ref: editorRef, required: required, disabled: disabled, readOnly: readOnly, status: status, as: StyledRichTextEditor, focused: focused, hasSuggestion: status === 'pending', children: _jsxs(StyledEditorContainer, { ref: editorContainerRef, children: [progress ? (_jsx(Progress, { placement: 'local', message: typeof progress === 'string' ? progress : undefined })) : null, _jsx(StyledEditorIframe, { "data-testid": testIds.iframe, title: typeof label === 'string' ? label : t('rte_text_formatting_toolbar'), role: 'application', "aria-label": typeof label === 'string' ? label : t('rte_text_formatting_toolbar'), "aria-describedby": required ? requiredDescriptionId : undefined, ref: iframeRef, tabIndex: sourceMode ? -1 : 0, "$minHeight": height?.min, "$maxHeight": height?.max, "$hidden": sourceMode }), required ? (_jsx(HiddenText, { id: requiredDescriptionId, children: t('required') })) : null, sourceMode ? (_jsx(StyledSourceTextarea, { value: sourceCode, onChange: e => setSourceCode(e.target.value), spellCheck: false, "aria-label": t('rte_source_code'), "$minHeight": height?.min, "$maxHeight": height?.max })) : null, (toolbar?.length || customActions?.length) && tiptapEditor ? (_jsx(Toolbar, { testId: testIds, features: toolbar || [], editor: tiptapEditor, customActions: customActions, imageInsertionMode: imageInsertionMode, onRewriteClick: onRewriteClick, renderSuggestionEditor: renderSuggestionEditor, sourceMode: sourceMode, onSourceModeToggle: (isSourceMode) => {
323
+ if (isSourceMode) {
324
+ setSourceCode(tiptapEditor.getHTML());
325
+ }
326
+ else {
327
+ tiptapEditor.commands.setContent(sourceCode);
328
+ }
329
+ setSourceMode(isSourceMode);
330
+ } })) : null, imagesEnabled && !readOnly && !disabled ? (_jsx(ImageActionButtons, { ref: editButtonRef, position: hoveredImagePosition, containerRef: editorContainerRef, onEdit: onEditButtonClick, onDelete: handleImageDelete, onMouseEnter: () => setIsOverButtons(true), onMouseLeave: () => setIsOverButtons(false), editLabel: t('rte_edit_image', [currentImageAttrs?.alt || '']), deleteLabel: t('rte_delete_image', [currentImageAttrs?.alt || '']) })) : null, tablesEnabled && !readOnly && !disabled && !sourceMode ? (_jsx(TableCellMenu, { ref: tableCellMenuButtonRef, position: cellPosition, containerRef: editorContainerRef, onAddRowBelow: addRowBelow, onAddRowAbove: addRowAbove, onAddColumnAfter: addColumnAfter, onAddColumnBefore: addColumnBefore, onDeleteRow: deleteRow, onDeleteColumn: deleteColumn, onDeleteTable: deleteTable, onGoToNextCell: goToNextCell, onReturnToCell: returnToCell, onMouseEnter: () => setIsOverTableMenu(true), onMouseLeave: () => setIsOverTableMenu(false), labels: {
331
+ tableOptions: t('rte_table_options'),
332
+ addRowBelow: t('rte_add_row_below'),
333
+ addRowAbove: t('rte_add_row_above'),
334
+ addColumnAfter: t('rte_add_column_after'),
335
+ addColumnBefore: t('rte_add_column_before'),
336
+ deleteRow: t('rte_delete_row'),
337
+ deleteColumn: t('rte_delete_column'),
338
+ deleteTable: t('rte_delete_table')
339
+ } })) : null] }) }), toolbar?.includes('word-count') && tiptapEditor ? (_jsx(WordCount, { "data-testid": testIds.wordCount, editor: tiptapEditor })) : null] }) }), children, imageEditDialog.attributes && (_jsx(ImageEditDialog, { isOpen: imageEditDialog.isOpen, onClose: () => {
267
340
  setImageEditDialog({ isOpen: false, attributes: null });
268
341
  }, onSave: handleImageEditSave, initialAttributes: imageEditDialog.attributes, target: editButtonRef.current }))] }));
269
342
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/components/Editor/Editor.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,WAAW,EACZ,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,qBAAqB,EACrB,Q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{ Editor as TiptapEditor } from '@tiptap/core';\nimport {\n forwardRef,\n useEffect,\n useRef,\n useState,\n useImperativeHandle,\n useMemo,\n useCallback\n} from 'react';\nimport type { PropsWithoutRef, ReactNode, RefObject } from 'react';\nimport { css } from 'styled-components';\n\nimport {\n FormControl,\n Progress,\n HiddenText,\n useAfterInitialEffect,\n useTheme,\n useUID,\n useConsolidatedRef,\n useTestIds,\n withTestIds,\n useConfiguration,\n useI18n\n} from '@pega/cosmos-react-core';\nimport type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';\n\nimport StyledRichTextEditor from '../RichTextEditor/RichTextEditor.styles';\nimport type { Features } from '../RichTextEditor/Toolbar/Toolbar.types';\n\nimport EditorContext from './Editor.context';\nimport type { EditorProps, EditorState, CustomComponent } from './Editor.types';\nimport { StyledEditorContainer, StyledEditorIframe, StyledEditorRoot } from './Editor.styles';\nimport { getEditorTestIds } from './Editor.test-ids';\nimport Toolbar from './Toolbar/Toolbar';\nimport { ImageEditDialog } from './ImageEditDialog';\nimport type { ImageAttributes } from './ImageEditDialog';\nimport ImageActionButtons from './ImageActionButtons';\nimport createFileItemElement from './FileItemElement';\nimport useIframeSetup from './hooks/useIframeSetup';\nimport useImageActions from './hooks/useImageActions';\n\n// Suggestion editor has no toolbar — formatting controls are intentionally omitted\nconst SUGGESTION_TOOLBAR: Features[] = [];\n\ninterface SuggestionEditorRenderProps {\n ref: RefObject<EditorState>;\n onInit: (tiptapEditor: TiptapEditor) => void;\n onChange: (editor?: TiptapEditor) => void;\n}\n\ninterface SuggestionEditorProps {\n defaultValue?: string;\n disabled: boolean;\n readOnly: boolean;\n onGetContent: (getContent: () => string) => void;\n onContentChange: (hasContent: boolean) => void;\n /** Render prop — receives ref and callbacks; must render an Editor-like element */\n renderEditor: (renderProps: SuggestionEditorRenderProps) => ReactNode;\n}\n\nconst SuggestionEditor = ({\n defaultValue,\n onGetContent,\n onContentChange,\n renderEditor\n}: SuggestionEditorProps) => {\n const editorRef = useRef<EditorState>(null);\n\n useEffect(() => {\n onGetContent(() => editorRef.current?.getEditor()?.getHTML() ?? '');\n }, [onGetContent]);\n\n useAfterInitialEffect(() => {\n editorRef.current?.getEditor()?.commands.setContent(defaultValue ?? '');\n }, [defaultValue]);\n\n return renderEditor({\n ref: editorRef,\n onInit: tiptapEditor => {\n // Signal initial content state so submit button enables correctly\n onContentChange(tiptapEditor.getText().trim() !== '');\n },\n onChange: editor => {\n onContentChange((editor?.getText() ?? '').trim() !== '');\n }\n });\n};\n\nconst Editor: ForwardRefForwardPropsComponent<EditorProps> = forwardRef(function ForwardedEditor(\n props: PropsWithoutRef<EditorProps>,\n ref: EditorProps['ref']\n) {\n const {\n testId,\n id,\n label,\n labelHidden,\n info,\n status,\n required,\n disabled,\n readOnly,\n onChange,\n onKeyDown,\n onFocus,\n onBlur,\n onImageAdded,\n onResolveSuggestion,\n onInit,\n onUnload,\n defaultValue,\n placeholder,\n children,\n additionalInfo,\n toolbar,\n customActions,\n customComponents = [],\n spellcheck = true,\n imageInsertionMode = 'all',\n initOptions,\n onRewriteClick,\n progress,\n autoFocus,\n height,\n autoResize = true,\n ...restProps\n } = props;\n\n const theme = useTheme();\n const { styleSheetTarget } = useConfiguration();\n const t = useI18n();\n const [focused, setFocused] = useState(false);\n const [tiptapEditor, setTiptapEditor] = useState<TiptapEditor | null>(null);\n const [imageEditDialog, setImageEditDialog] = useState<{\n isOpen: boolean;\n attributes: ImageAttributes | null;\n }>({ isOpen: false, attributes: null });\n const editButtonRef = useRef<HTMLButtonElement>(null);\n const editorContainerRef = useRef<HTMLDivElement>(null);\n const generatedId = useUID();\n const editorId = id ?? generatedId;\n const labelId = useUID();\n const requiredDescriptionId = `${editorId}-required`;\n const editorRef = useConsolidatedRef(ref);\n const formFieldRef = useRef<HTMLElement>(null);\n const pastedImages = useRef<File[]>([]);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n\n const testIds = useTestIds(testId, getEditorTestIds);\n\n // Check if images feature is enabled\n const imagesEnabled = toolbar?.includes('images') ?? false;\n\n // Define built-in custom components and merge with user-provided ones\n const customElements: CustomComponent[] = useMemo(() => {\n const FileItemStyle = css`\n /* stylelint-disable-next-line selector-type-no-unknown */\n pega-file {\n display: inline-block;\n width: ${theme.base['content-width'].md};\n }\n `;\n\n return [\n {\n createCustomElement: createFileItemElement,\n name: 'pega-file',\n style: FileItemStyle.toString(),\n extensionAttributes: ['contenteditable']\n },\n ...customComponents\n ];\n }, [customComponents, theme]);\n\n // Register custom elements in the main window (needed for Tiptap to recognize them)\n useEffect(() => {\n customElements.forEach((component: CustomComponent) => {\n if (\n component.name &&\n component.createCustomElement &&\n !window.customElements.get(component.name)\n ) {\n const CustomElement = component.createCustomElement(window);\n window.customElements.define(component.name, CustomElement);\n }\n });\n }, [customElements]);\n\n // Mount Tiptap inside iframe using custom hook\n const { iframeEditorRef } = useIframeSetup({\n iframeRef,\n theme,\n styleSheetTarget,\n customElements,\n placeholder,\n defaultValue,\n disabled,\n readOnly,\n onChange,\n onKeyDown,\n onFocus,\n onBlur,\n onInit,\n spellcheck,\n initOptions,\n onImageAdded,\n imagesEnabled,\n imageInsertionMode,\n pastedImages,\n editorId,\n required,\n setTiptapEditor,\n setFocused,\n autoResize,\n onTabOut: () => {\n // Focus first toolbar button when Tab is pressed in editor\n const toolbarEl = editorContainerRef.current?.querySelector('[data-testid$=\"toolbar\"]');\n const firstButton = toolbarEl?.querySelector<HTMLElement>('button:not([disabled])');\n if (firstButton) {\n firstButton.focus();\n }\n }\n });\n\n // Set up unload event listener to save content before iframe is destroyed\n useEffect(() => {\n if (!iframeRef.current?.contentWindow || !onUnload) return;\n\n const iframeWindow = iframeRef.current.contentWindow;\n const abortController = new AbortController();\n\n iframeWindow.addEventListener(\n 'unload',\n () => {\n const html = iframeEditorRef.current?.getHtml() ?? '';\n onUnload(html);\n },\n { signal: abortController.signal }\n );\n\n return () => {\n abortController.abort();\n };\n }, [onUnload]);\n\n // Set up image action buttons (edit and delete) using custom hook\n const {\n hoveredImagePosition,\n currentImageAttrs,\n currentImageElement,\n handleDelete: handleImageDelete,\n setIsOverButtons\n } = useImageActions({\n tiptapEditor,\n iframeRef,\n isDialogOpen: imageEditDialog.isOpen\n });\n\n // Store the image element when opening the dialog to target the correct node on save\n const editingImageElementRef = useRef<HTMLImageElement | null>(null);\n\n // Handle edit button click from ImageActionButtons\n const onEditButtonClick = () => {\n if (currentImageAttrs && currentImageElement) {\n // Store the element reference to target the correct node on save\n editingImageElementRef.current = currentImageElement;\n setImageEditDialog({\n isOpen: true,\n attributes: currentImageAttrs\n });\n // Don't call handleImageEdit() here - keep buttons visible while dialog is open\n }\n };\n\n // Handle image edit save\n const handleImageEditSave = (attrs: ImageAttributes) => {\n if (!tiptapEditor || !editingImageElementRef.current) return;\n\n // Get exact position from DOM element to handle duplicate images correctly\n const pos = tiptapEditor.view.posAtDOM(editingImageElementRef.current, 0);\n\n if (pos >= 0) {\n const { state } = tiptapEditor;\n const node = state.doc.nodeAt(pos);\n if (!node || node.type.name !== 'image') return;\n\n const nodeEnd = pos + node.nodeSize;\n const tr = state.tr;\n\n // Update image attributes\n tr.setNodeMarkup(pos, undefined, {\n src: attrs.src,\n alt: attrs.alt,\n ...(attrs.width && { width: attrs.width }),\n ...(attrs.height && { height: attrs.height })\n });\n\n // Handle action URL (links are marks in ProseMirror, not nodes)\n // Always remove existing link mark first, then add new one if needed\n tr.removeMark(pos, nodeEnd, state.schema.marks.link);\n if (attrs.actionUrl) {\n const linkMark = state.schema.marks.link.create({\n href: attrs.actionUrl,\n target: '_blank'\n });\n tr.addMark(pos, nodeEnd, linkMark);\n }\n\n tiptapEditor.view.dispatch(tr);\n }\n\n // Clear the ref after save\n editingImageElementRef.current = null;\n };\n\n // Update editor when props change\n useAfterInitialEffect(() => {\n iframeEditorRef.current?.setEditable(!readOnly && !disabled);\n }, [readOnly, disabled]);\n\n // Handle autoFocus\n useEffect(() => {\n if (autoFocus && tiptapEditor) {\n tiptapEditor.commands.focus();\n }\n }, [autoFocus, tiptapEditor]);\n\n // Expose methods via ref\n useImperativeHandle(\n editorRef,\n () => ({\n focus: () => iframeEditorRef.current?.focus(),\n getPlainText: () => iframeEditorRef.current?.getPlainText() ?? '',\n getRichText: () => iframeEditorRef.current?.getRichText() ?? '',\n getHtml: () => iframeEditorRef.current?.getHtml() ?? '',\n clear: () => iframeEditorRef.current?.clear(),\n updateAttachmentAttributes: (imageId: string, uploadProgress?: number, error?: string) => {\n if (!iframeRef.current?.contentDocument) return;\n\n const iframeDoc = iframeRef.current.contentDocument;\n const imageCustomEl = iframeDoc.querySelector(`pega-file[data-id=\"${imageId}\"]`);\n\n if (imageCustomEl) {\n if (error) {\n imageCustomEl.setAttribute('data-error', error);\n } else if (uploadProgress !== undefined) {\n imageCustomEl.setAttribute('data-progress', `${uploadProgress}`);\n }\n }\n },\n appendImage: (\n imageData: { src: string; alt: string; attachmentId?: string },\n imageId: string\n ) => {\n if (!iframeRef.current?.contentDocument || !tiptapEditor) return;\n\n const iframeDoc = iframeRef.current.contentDocument;\n const imageUploadEl = iframeDoc.querySelector(`pega-file[data-id=\"${imageId}\"]`);\n\n if (imageUploadEl) {\n // Create img element\n const imgEl = iframeDoc.createElement('img');\n imgEl.setAttribute('src', imageData.src);\n imgEl.setAttribute('alt', imageData.alt);\n if (imageData.attachmentId) {\n imgEl.setAttribute('data-attachment-id', imageData.attachmentId);\n }\n\n // Replace pega-file with img in the DOM\n imageUploadEl.replaceWith(imgEl);\n\n // Also update the Tiptap document\n const html = tiptapEditor.getHTML();\n const updatedHtml = html.replace(\n new RegExp(`<pega-file[^>]*data-id=[\"']${imageId}[\"'][^>]*>.*?</pega-file>`, 'g'),\n imgEl.outerHTML\n );\n\n if (updatedHtml !== html) {\n tiptapEditor.commands.setContent(updatedHtml, { emitUpdate: false });\n }\n }\n },\n insertText: (text: string) => iframeEditorRef.current?.insertText(text),\n setCursorLocationToStart: () => iframeEditorRef.current?.setCursorLocationToStart(),\n insertHtml: (html: string, overwrite?: boolean) =>\n iframeEditorRef.current?.insertHtml(html, overwrite),\n getEditor: () => iframeEditorRef.current?.getEditor() ?? null,\n element: formFieldRef.current || undefined\n }),\n [tiptapEditor]\n );\n\n const ctx = useMemo(\n () => ({\n editor: tiptapEditor,\n addImage: (image: File, imageId?: string, alt?: string) => {\n if (!tiptapEditor || !image) return;\n\n const imgId = imageId || `img-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;\n\n // Create pega-file element to show upload progress\n const pegaFileHtml = `<br/><pega-file data-id='${imgId}' data-progress='0' data-name='${image.name}' data-alt='${alt || image.name}' contenteditable='false'></pega-file><br/>`;\n\n // Insert the pega-file element\n tiptapEditor.chain().focus().insertContent(pegaFileHtml).run();\n\n // Trigger the onImageAdded callback so consumer can upload and call appendImage\n onImageAdded?.(image, imgId, alt);\n }\n }),\n [tiptapEditor, onImageAdded]\n );\n\n const renderSuggestionEditor = useCallback(\n (suggestionProps: {\n defaultValue?: string;\n disabled: boolean;\n readOnly: boolean;\n onGetContent: (getContent: () => string) => void;\n onContentChange: (hasContent: boolean) => void;\n }) => (\n <SuggestionEditor\n defaultValue={suggestionProps.defaultValue}\n disabled={suggestionProps.disabled}\n readOnly={suggestionProps.readOnly}\n onGetContent={suggestionProps.onGetContent}\n onContentChange={suggestionProps.onContentChange}\n renderEditor={({\n ref: suggestionEditorRef,\n onInit: suggestionOnInit,\n onChange: suggestionOnChange\n }) => (\n <Editor\n ref={suggestionEditorRef}\n label={t('ai_rewrite_result_label')}\n labelHidden\n toolbar={SUGGESTION_TOOLBAR}\n defaultValue={suggestionProps.defaultValue}\n disabled={suggestionProps.disabled}\n readOnly={suggestionProps.readOnly}\n height={height}\n onInit={suggestionOnInit}\n onChange={suggestionOnChange}\n />\n )}\n />\n ),\n [height, t]\n );\n\n return (\n <EditorContext.Provider value={ctx}>\n <StyledEditorRoot\n testId={testIds}\n label={label}\n labelFor=''\n labelId={labelId}\n labelHidden={labelHidden}\n id={editorId}\n info={info}\n status={status}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n onResolveSuggestion={onResolveSuggestion}\n ref={formFieldRef}\n additionalInfo={additionalInfo}\n >\n <FormControl\n {...restProps}\n ref={editorRef}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={status}\n as={StyledRichTextEditor}\n focused={focused}\n hasSuggestion={status === 'pending'}\n >\n <StyledEditorContainer ref={editorContainerRef}>\n {progress && (\n <Progress\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n )}\n <StyledEditorIframe\n data-testid={testIds.iframe}\n role='application'\n aria-label={typeof label === 'string' ? label : t('rte_text_formatting_toolbar')}\n aria-describedby={required ? requiredDescriptionId : undefined}\n ref={iframeRef}\n tabIndex={0}\n $minHeight={height?.min}\n $maxHeight={height?.max}\n />\n {required && <HiddenText id={requiredDescriptionId}>{t('required')}</HiddenText>}\n {(toolbar?.length || customActions?.length) && tiptapEditor && (\n <Toolbar\n testId={testIds}\n features={toolbar || []}\n editor={tiptapEditor}\n customActions={customActions}\n imageInsertionMode={imageInsertionMode}\n onRewriteClick={onRewriteClick}\n renderSuggestionEditor={renderSuggestionEditor}\n />\n )}\n {imagesEnabled && !readOnly && !disabled && (\n <ImageActionButtons\n ref={editButtonRef}\n position={hoveredImagePosition}\n containerRef={editorContainerRef}\n onEdit={onEditButtonClick}\n onDelete={handleImageDelete}\n onMouseEnter={() => setIsOverButtons(true)}\n onMouseLeave={() => setIsOverButtons(false)}\n editLabel={t('rte_edit_image', [currentImageAttrs?.alt || ''])}\n deleteLabel={t('rte_delete_image', [currentImageAttrs?.alt || ''])}\n />\n )}\n </StyledEditorContainer>\n </FormControl>\n </StyledEditorRoot>\n {children}\n {imageEditDialog.attributes && (\n <ImageEditDialog\n isOpen={imageEditDialog.isOpen}\n onClose={() => {\n setImageEditDialog({ isOpen: false, attributes: null });\n }}\n onSave={handleImageEditSave}\n initialAttributes={imageEditDialog.attributes}\n target={editButtonRef.current}\n />\n )}\n </EditorContext.Provider>\n );\n});\n\nexport default withTestIds(Editor, getEditorTestIds);\n"]}
1
+ {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/components/Editor/Editor.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,WAAW,EACZ,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,OAAO,EACR,MAAM,yBAAyB,CAAC;AAGjC,OAAO,oBAAoB,MAAM,yCAAyC,CAAC;AAG3E,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,qBAAqB,MAAM,mBAAmB,CAAC;AACtD,OAAO,cAAc,MAAM,wBAAwB,CAAC;AACpD,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,YAAY,MAAM,YAAY,CAAC;AAEtC,mFAAmF;AACnF,MAAM,kBAAkB,GAAe,EAAE,CAAC;AAkB1C,MAAM,gBAAgB,GAAG,CAAC,EACxB,YAAY,EACZ,YA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wardRef,\n useEffect,\n useRef,\n useState,\n useImperativeHandle,\n useMemo,\n useCallback\n} from 'react';\nimport type { PropsWithoutRef, ReactNode, RefObject } from 'react';\nimport { css } from 'styled-components';\n\nimport {\n FormControl,\n Progress,\n HiddenText,\n useAfterInitialEffect,\n useTheme,\n useUID,\n useConsolidatedRef,\n useTestIds,\n withTestIds,\n useConfiguration,\n useI18n\n} from '@pega/cosmos-react-core';\nimport type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';\n\nimport StyledRichTextEditor from '../RichTextEditor/RichTextEditor.styles';\nimport type { Features } from '../RichTextEditor/Toolbar/Toolbar.types';\n\nimport EditorContext from './Editor.context';\nimport type { EditorProps, EditorState, CustomComponent } from './Editor.types';\nimport {\n StyledEditorContainer,\n StyledEditorIframe,\n StyledEditorRoot,\n StyledSourceTextarea\n} from './Editor.styles';\nimport { getEditorTestIds } from './Editor.test-ids';\nimport Toolbar from './Toolbar/Toolbar';\nimport WordCount from './Toolbar/WordCount';\nimport { ImageEditDialog } from './ImageEditDialog';\nimport type { ImageAttributes } from './ImageEditDialog';\nimport ImageActionButtons from './ImageActionButtons';\nimport TableCellMenu from './TableCellMenu';\nimport createFileItemElement from './FileItemElement';\nimport useIframeSetup from './hooks/useIframeSetup';\nimport useImageActions from './hooks/useImageActions';\nimport useTableCellMenu from './hooks/useTableCellMenu';\nimport { dispatchEditorClickEvent } from './hooks/useCloseOnEditorClick';\nimport sanitizeHtml from './sanitize';\n\n// Suggestion editor has no toolbar — formatting controls are intentionally omitted\nconst SUGGESTION_TOOLBAR: Features[] = [];\n\ninterface SuggestionEditorRenderProps {\n ref: RefObject<EditorState>;\n onInit: (tiptapEditor: TiptapEditor) => void;\n onChange: (editor?: TiptapEditor) => void;\n}\n\ninterface SuggestionEditorProps {\n defaultValue?: string;\n disabled: boolean;\n readOnly: boolean;\n onGetContent: (getContent: () => string) => void;\n onContentChange: (hasContent: boolean) => void;\n /** Render prop — receives ref and callbacks; must render an Editor-like element */\n renderEditor: (renderProps: SuggestionEditorRenderProps) => ReactNode;\n}\n\nconst SuggestionEditor = ({\n defaultValue,\n onGetContent,\n onContentChange,\n renderEditor\n}: SuggestionEditorProps) => {\n const editorRef = useRef<EditorState>(null);\n\n useEffect(() => {\n onGetContent(() => editorRef.current?.getEditor()?.getHTML() ?? '');\n }, [onGetContent]);\n\n useAfterInitialEffect(() => {\n editorRef.current?.getEditor()?.commands.setContent(defaultValue ?? '');\n }, [defaultValue]);\n\n return renderEditor({\n ref: editorRef,\n onInit: tiptapEditor => {\n // Signal initial content state so submit button enables correctly\n onContentChange(tiptapEditor.getText().trim() !== '');\n },\n onChange: editor => {\n onContentChange((editor?.getText() ?? '').trim() !== '');\n }\n });\n};\n\nconst Editor: ForwardRefForwardPropsComponent<EditorProps> = forwardRef(function ForwardedEditor(\n props: PropsWithoutRef<EditorProps>,\n ref: EditorProps['ref']\n) {\n const {\n testId,\n id,\n label,\n labelHidden,\n info,\n status,\n required,\n disabled,\n readOnly,\n onChange,\n onKeyDown,\n onFocus,\n onBlur,\n onImageAdded,\n onResolveSuggestion,\n onInit,\n onUnload,\n defaultValue,\n placeholder,\n children,\n additionalInfo,\n toolbar,\n customActions,\n customComponents = [],\n spellcheck = true,\n imageInsertionMode = 'all',\n initOptions,\n onRewriteClick,\n progress,\n autoFocus,\n height,\n autoResize = true,\n secure = false,\n ...restProps\n } = props;\n\n const theme = useTheme();\n const { styleSheetTarget } = useConfiguration();\n const t = useI18n();\n const [focused, setFocused] = useState(false);\n const [tiptapEditor, setTiptapEditor] = useState<TiptapEditor | null>(null);\n const [imageEditDialog, setImageEditDialog] = useState<{\n isOpen: boolean;\n attributes: ImageAttributes | null;\n }>({ isOpen: false, attributes: null });\n const [sourceMode, setSourceMode] = useState(false);\n const [sourceCode, setSourceCode] = useState('');\n const editButtonRef = useRef<HTMLButtonElement>(null);\n const tableCellMenuButtonRef = useRef<HTMLButtonElement>(null);\n const editorContainerRef = useRef<HTMLDivElement>(null);\n const generatedId = useUID();\n const editorId = id ?? generatedId;\n const labelId = useUID();\n const requiredDescriptionId = `${editorId}-required`;\n const editorRef = useConsolidatedRef(ref);\n const formFieldRef = useRef<HTMLElement>(null);\n const pastedImages = useRef<File[]>([]);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n\n const testIds = useTestIds(testId, getEditorTestIds);\n\n // Check if images feature is enabled\n const imagesEnabled = toolbar?.includes('images') ?? false;\n\n // Check if tables feature is enabled\n const tablesEnabled = toolbar?.includes('tables') ?? false;\n\n // Check if links feature is enabled (controls autolink behavior)\n const linksEnabled = toolbar?.includes('links') ?? false;\n\n // Define built-in custom components and merge with user-provided ones\n const customElements: CustomComponent[] = useMemo(() => {\n const FileItemStyle = css`\n /* stylelint-disable-next-line selector-type-no-unknown */\n pega-file {\n display: inline-block;\n width: ${theme.base['content-width'].md};\n }\n `;\n\n return [\n {\n createCustomElement: createFileItemElement,\n name: 'pega-file',\n style: FileItemStyle.toString(),\n extensionAttributes: ['contenteditable']\n },\n ...customComponents\n ];\n }, [customComponents, theme]);\n\n // Register custom elements in the main window (needed for Tiptap to recognize them)\n useEffect(() => {\n customElements.forEach((component: CustomComponent) => {\n if (\n component.name &&\n component.createCustomElement &&\n !window.customElements.get(component.name)\n ) {\n const CustomElement = component.createCustomElement(window);\n window.customElements.define(component.name, CustomElement);\n }\n });\n }, [customElements]);\n\n // Sanitize defaultValue if secure mode is enabled\n const sanitizedDefaultValue = useMemo(\n () => (secure && defaultValue ? sanitizeHtml(defaultValue) : defaultValue),\n [secure, defaultValue]\n );\n\n // Mount Tiptap inside iframe using custom hook\n const { iframeEditorRef } = useIframeSetup({\n iframeRef,\n theme,\n styleSheetTarget,\n customElements,\n placeholder,\n defaultValue: sanitizedDefaultValue,\n disabled,\n readOnly,\n onChange,\n onKeyDown,\n onFocus,\n onBlur,\n onInit,\n spellcheck,\n initOptions,\n onImageAdded,\n imagesEnabled,\n linksEnabled,\n imageInsertionMode,\n pastedImages,\n editorId,\n required,\n setTiptapEditor,\n setFocused,\n autoResize,\n secure,\n onTabOut: () => {\n // Focus first toolbar button when Tab is pressed in editor\n const toolbarEl = editorContainerRef.current?.querySelector('[data-testid$=\"toolbar\"]');\n const firstButton = toolbarEl?.querySelector<HTMLElement>('button:not([disabled])');\n if (firstButton) {\n firstButton.focus();\n }\n },\n onFocusTableMenu: () => {\n tableCellMenuButtonRef.current?.focus();\n },\n onFocusPreviousCellMenu: () => {\n // Go to previous cell and then focus its menu\n if (tiptapEditor) {\n tiptapEditor.commands.goToPreviousCell();\n setTimeout(() => {\n tableCellMenuButtonRef.current?.focus();\n }, 0);\n }\n }\n });\n\n // Set up unload event listener to save content before iframe is destroyed\n useEffect(() => {\n if (!iframeRef.current?.contentWindow || !onUnload) return;\n\n const iframeWindow = iframeRef.current.contentWindow;\n const abortController = new AbortController();\n\n iframeWindow.addEventListener(\n 'unload',\n () => {\n const html = iframeEditorRef.current?.getHtml() ?? '';\n onUnload(html);\n },\n { signal: abortController.signal }\n );\n\n return () => {\n abortController.abort();\n };\n }, [onUnload]);\n\n // Dispatch event on iframe mousedown to close all open popovers/menus\n useEffect(() => {\n const iframeDoc = iframeRef.current?.contentDocument;\n if (!iframeDoc) return;\n\n const handleMouseDown = () => {\n dispatchEditorClickEvent();\n };\n\n iframeDoc.addEventListener('mousedown', handleMouseDown);\n return () => iframeDoc.removeEventListener('mousedown', handleMouseDown);\n }, [tiptapEditor]);\n\n // Set up image action buttons (edit and delete) using custom hook\n const {\n hoveredImagePosition,\n currentImageAttrs,\n currentImageElement,\n handleDelete: handleImageDelete,\n setIsOverButtons\n } = useImageActions({\n tiptapEditor,\n iframeRef,\n isDialogOpen: imageEditDialog.isOpen\n });\n\n // Set up table cell menu using custom hook (only when tables are active)\n const tableMenuEnabled = tablesEnabled && !readOnly && !disabled;\n const {\n cellPosition,\n setIsOverMenu: setIsOverTableMenu,\n addRowBelow,\n addRowAbove,\n addColumnAfter,\n addColumnBefore,\n deleteRow,\n deleteColumn,\n deleteTable\n } = useTableCellMenu({\n tiptapEditor: tableMenuEnabled ? tiptapEditor : null,\n iframeRef\n });\n\n // Handle keyboard navigation from table menu to next cell (start of content)\n const goToNextCell = useCallback(() => {\n if (tiptapEditor) {\n tiptapEditor.commands.focus();\n tiptapEditor.commands.goToNextCell();\n }\n }, [tiptapEditor]);\n\n // Handle keyboard navigation from table menu back to current cell\n const returnToCell = useCallback(() => {\n tiptapEditor?.commands.focus();\n }, [tiptapEditor]);\n\n // Store the image element when opening the dialog to target the correct node on save\n const editingImageElementRef = useRef<HTMLImageElement | null>(null);\n\n // Handle edit button click from ImageActionButtons\n const onEditButtonClick = () => {\n if (currentImageAttrs && currentImageElement) {\n // Store the element reference to target the correct node on save\n editingImageElementRef.current = currentImageElement;\n setImageEditDialog({\n isOpen: true,\n attributes: currentImageAttrs\n });\n // Don't call handleImageEdit() here - keep buttons visible while dialog is open\n }\n };\n\n // Handle image edit save\n const handleImageEditSave = (attrs: ImageAttributes) => {\n if (!tiptapEditor || !editingImageElementRef.current) return;\n\n // Get exact position from DOM element to handle duplicate images correctly\n const pos = tiptapEditor.view.posAtDOM(editingImageElementRef.current, 0);\n\n if (pos >= 0) {\n const { state } = tiptapEditor;\n const node = state.doc.nodeAt(pos);\n if (!node || node.type.name !== 'image') return;\n\n const nodeEnd = pos + node.nodeSize;\n const tr = state.tr;\n\n // Update image attributes\n tr.setNodeMarkup(pos, undefined, {\n src: attrs.src,\n alt: attrs.alt,\n ...(attrs.width && { width: attrs.width }),\n ...(attrs.height && { height: attrs.height })\n });\n\n // Handle action URL (links are marks in ProseMirror, not nodes)\n // Always remove existing link mark first, then add new one if needed\n tr.removeMark(pos, nodeEnd, state.schema.marks.link);\n if (attrs.actionUrl) {\n const linkMark = state.schema.marks.link.create({\n href: attrs.actionUrl,\n target: '_blank'\n });\n tr.addMark(pos, nodeEnd, linkMark);\n }\n\n tiptapEditor.view.dispatch(tr);\n }\n\n // Clear the ref after save\n editingImageElementRef.current = null;\n };\n\n // Update editor when props change\n useAfterInitialEffect(() => {\n iframeEditorRef.current?.setEditable(!readOnly && !disabled);\n }, [readOnly, disabled]);\n\n // Handle autoFocus\n useEffect(() => {\n if (autoFocus && tiptapEditor) {\n tiptapEditor.commands.focus();\n }\n }, [autoFocus, tiptapEditor]);\n\n // Expose methods via ref\n useImperativeHandle(\n editorRef,\n () => ({\n focus: () => iframeEditorRef.current?.focus(),\n getPlainText: () => iframeEditorRef.current?.getPlainText() ?? '',\n getRichText: () => iframeEditorRef.current?.getRichText() ?? '',\n getHtml: () => iframeEditorRef.current?.getHtml() ?? '',\n clear: () => iframeEditorRef.current?.clear(),\n updateAttachmentAttributes: (imageId: string, uploadProgress?: number, error?: string) => {\n if (!iframeRef.current?.contentDocument) return;\n\n const iframeDoc = iframeRef.current.contentDocument;\n const imageCustomEl = iframeDoc.querySelector(`pega-file[data-id=\"${imageId}\"]`);\n\n if (imageCustomEl) {\n if (error) {\n imageCustomEl.setAttribute('data-error', error);\n } else if (uploadProgress !== undefined) {\n imageCustomEl.setAttribute('data-progress', `${uploadProgress}`);\n }\n }\n },\n appendImage: (\n imageData: { src: string; alt: string; attachmentId?: string },\n imageId: string\n ) => {\n if (!iframeRef.current?.contentDocument || !tiptapEditor) return;\n\n const iframeDoc = iframeRef.current.contentDocument;\n const imageUploadEl = iframeDoc.querySelector(`pega-file[data-id=\"${imageId}\"]`);\n\n if (imageUploadEl) {\n // Create img element\n const imgEl = iframeDoc.createElement('img');\n imgEl.setAttribute('src', imageData.src);\n imgEl.setAttribute('alt', imageData.alt);\n if (imageData.attachmentId) {\n imgEl.setAttribute('data-attachment-id', imageData.attachmentId);\n }\n\n // Replace pega-file with img in the DOM\n imageUploadEl.replaceWith(imgEl);\n\n // Also update the Tiptap document\n const html = tiptapEditor.getHTML();\n const updatedHtml = html.replace(\n new RegExp(`<pega-file[^>]*data-id=[\"']${imageId}[\"'][^>]*>.*?</pega-file>`, 'g'),\n imgEl.outerHTML\n );\n\n if (updatedHtml !== html) {\n tiptapEditor.commands.setContent(updatedHtml, { emitUpdate: false });\n }\n }\n },\n insertText: (text: string) => iframeEditorRef.current?.insertText(text),\n setCursorLocationToStart: () => iframeEditorRef.current?.setCursorLocationToStart(),\n insertHtml: (html: string, overwrite?: boolean) =>\n iframeEditorRef.current?.insertHtml(html, overwrite),\n getEditor: () => iframeEditorRef.current?.getEditor() ?? null,\n element: formFieldRef.current || undefined\n }),\n [tiptapEditor]\n );\n\n const ctx = useMemo(\n () => ({\n editor: tiptapEditor,\n addImage: (image: File, imageId?: string, alt?: string) => {\n if (!tiptapEditor || !image) return;\n\n const imgId = imageId || `img-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;\n\n // Create pega-file element to show upload progress\n const pegaFileHtml = `<br/><pega-file data-id='${imgId}' data-progress='0' data-name='${image.name}' data-alt='${alt || image.name}' contenteditable='false'></pega-file><br/>`;\n\n // Insert the pega-file element\n tiptapEditor.chain().focus().insertContent(pegaFileHtml).run();\n\n // Trigger the onImageAdded callback so consumer can upload and call appendImage\n onImageAdded?.(image, imgId, alt);\n }\n }),\n [tiptapEditor, onImageAdded]\n );\n\n const renderSuggestionEditor = useCallback(\n (suggestionProps: {\n defaultValue?: string;\n disabled: boolean;\n readOnly: boolean;\n onGetContent: (getContent: () => string) => void;\n onContentChange: (hasContent: boolean) => void;\n }) => (\n <SuggestionEditor\n defaultValue={suggestionProps.defaultValue}\n disabled={suggestionProps.disabled}\n readOnly={suggestionProps.readOnly}\n onGetContent={suggestionProps.onGetContent}\n onContentChange={suggestionProps.onContentChange}\n renderEditor={({\n ref: suggestionEditorRef,\n onInit: suggestionOnInit,\n onChange: suggestionOnChange\n }) => (\n <Editor\n ref={suggestionEditorRef}\n label={t('ai_rewrite_result_label')}\n labelHidden\n toolbar={SUGGESTION_TOOLBAR}\n defaultValue={suggestionProps.defaultValue}\n disabled={suggestionProps.disabled}\n readOnly={suggestionProps.readOnly}\n height={height}\n onInit={suggestionOnInit}\n onChange={suggestionOnChange}\n />\n )}\n />\n ),\n [height, t]\n );\n\n return (\n <EditorContext.Provider value={ctx}>\n <StyledEditorRoot\n testId={testIds}\n label={label}\n labelFor=''\n labelId={labelId}\n labelHidden={labelHidden}\n id={editorId}\n info={info}\n status={status}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n onResolveSuggestion={onResolveSuggestion}\n ref={formFieldRef}\n additionalInfo={additionalInfo}\n >\n <>\n <FormControl\n {...restProps}\n ref={editorRef}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={status}\n as={StyledRichTextEditor}\n focused={focused}\n hasSuggestion={status === 'pending'}\n >\n <StyledEditorContainer ref={editorContainerRef}>\n {progress ? (\n <Progress\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n ) : null}\n {/* Title attribute is required for iframe accessibility (WCAG) */}\n <StyledEditorIframe\n data-testid={testIds.iframe}\n title={typeof label === 'string' ? label : t('rte_text_formatting_toolbar')}\n role='application'\n aria-label={typeof label === 'string' ? label : t('rte_text_formatting_toolbar')}\n aria-describedby={required ? requiredDescriptionId : undefined}\n ref={iframeRef}\n tabIndex={sourceMode ? -1 : 0}\n $minHeight={height?.min}\n $maxHeight={height?.max}\n $hidden={sourceMode}\n />\n {required ? (\n <HiddenText id={requiredDescriptionId}>{t('required')}</HiddenText>\n ) : null}\n {sourceMode ? (\n <StyledSourceTextarea\n value={sourceCode}\n onChange={e => setSourceCode(e.target.value)}\n spellCheck={false}\n aria-label={t('rte_source_code')}\n $minHeight={height?.min}\n $maxHeight={height?.max}\n />\n ) : null}\n {(toolbar?.length || customActions?.length) && tiptapEditor ? (\n <Toolbar\n testId={testIds}\n features={toolbar || []}\n editor={tiptapEditor}\n customActions={customActions}\n imageInsertionMode={imageInsertionMode}\n onRewriteClick={onRewriteClick}\n renderSuggestionEditor={renderSuggestionEditor}\n sourceMode={sourceMode}\n onSourceModeToggle={(isSourceMode: boolean) => {\n if (isSourceMode) {\n setSourceCode(tiptapEditor.getHTML());\n } else {\n tiptapEditor.commands.setContent(sourceCode);\n }\n setSourceMode(isSourceMode);\n }}\n />\n ) : null}\n {imagesEnabled && !readOnly && !disabled ? (\n <ImageActionButtons\n ref={editButtonRef}\n position={hoveredImagePosition}\n containerRef={editorContainerRef}\n onEdit={onEditButtonClick}\n onDelete={handleImageDelete}\n onMouseEnter={() => setIsOverButtons(true)}\n onMouseLeave={() => setIsOverButtons(false)}\n editLabel={t('rte_edit_image', [currentImageAttrs?.alt || ''])}\n deleteLabel={t('rte_delete_image', [currentImageAttrs?.alt || ''])}\n />\n ) : null}\n {tablesEnabled && !readOnly && !disabled && !sourceMode ? (\n <TableCellMenu\n ref={tableCellMenuButtonRef}\n position={cellPosition}\n containerRef={editorContainerRef}\n onAddRowBelow={addRowBelow}\n onAddRowAbove={addRowAbove}\n onAddColumnAfter={addColumnAfter}\n onAddColumnBefore={addColumnBefore}\n onDeleteRow={deleteRow}\n onDeleteColumn={deleteColumn}\n onDeleteTable={deleteTable}\n onGoToNextCell={goToNextCell}\n onReturnToCell={returnToCell}\n onMouseEnter={() => setIsOverTableMenu(true)}\n onMouseLeave={() => setIsOverTableMenu(false)}\n labels={{\n tableOptions: t('rte_table_options'),\n addRowBelow: t('rte_add_row_below'),\n addRowAbove: t('rte_add_row_above'),\n addColumnAfter: t('rte_add_column_after'),\n addColumnBefore: t('rte_add_column_before'),\n deleteRow: t('rte_delete_row'),\n deleteColumn: t('rte_delete_column'),\n deleteTable: t('rte_delete_table')\n }}\n />\n ) : null}\n </StyledEditorContainer>\n </FormControl>\n {toolbar?.includes('word-count') && tiptapEditor ? (\n <WordCount data-testid={testIds.wordCount} editor={tiptapEditor} />\n ) : null}\n </>\n </StyledEditorRoot>\n {children}\n {imageEditDialog.attributes && (\n <ImageEditDialog\n isOpen={imageEditDialog.isOpen}\n onClose={() => {\n setImageEditDialog({ isOpen: false, attributes: null });\n }}\n onSave={handleImageEditSave}\n initialAttributes={imageEditDialog.attributes}\n target={editButtonRef.current}\n />\n )}\n </EditorContext.Provider>\n );\n});\n\nexport default withTestIds(Editor, getEditorTestIds);\n"]}
@@ -2,6 +2,7 @@ export declare const StyledEditorContainer: import("styled-components/dist/types
2
2
  interface StyledEditorIframeProps {
3
3
  $minHeight?: number;
4
4
  $maxHeight?: number;
5
+ $hidden?: boolean;
5
6
  }
6
7
  export declare const StyledEditorIframe: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>, StyledEditorIframeProps>> & string;
7
8
  export declare const StyledEditorRoot: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("@pega/cosmos-react-core").FormFieldProps & import("@pega/cosmos-react-core").ForwardProps, never>> & string & Omit<import("react").FC<import("@pega/cosmos-react-core").FormFieldProps & import("@pega/cosmos-react-core").ForwardProps> & {
@@ -29,5 +30,10 @@ export declare const StyledFormDialog: import("styled-components/dist/types").IS
29
30
  } & Omit<import("@pega/cosmos-react-core").Attributes<"div">, "aria-label" | "onSubmit" | "onCancel" | "heading" | keyof import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").BaseDialogProps | "onDismiss" | "additionalInfo">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
30
31
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
31
32
  }), import("styled-components/dist/types").BaseObject>> & string & Omit<import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<import("@pega/cosmos-react-core").FormDialogProps> & import("react").RefAttributes<HTMLDivElement>>, keyof import("react").Component<any, {}, any>>;
33
+ interface StyledSourceTextareaProps {
34
+ $minHeight?: number;
35
+ $maxHeight?: number;
36
+ }
37
+ export declare const StyledSourceTextarea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, StyledSourceTextareaProps>> & string;
32
38
  export {};
33
39
  //# sourceMappingURL=Editor.styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Editor/Editor.styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,6NAOjC,CAAC;AAIF,UAAU,uBAAuB;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,wQAmB9B,CAAC;AAIF,eAAO,MAAM,gBAAgB;2BAeogF,CAAC;iDAf/+E,CAAC;AAIpD,eAAO,MAAM,iBAAiB,0dAE7B,CAAC;AAIF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;qSAE5B,CAAC"}
1
+ {"version":3,"file":"Editor.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Editor/Editor.styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,6NAOjC,CAAC;AAIF,UAAU,uBAAuB;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,kBAAkB,wQAyB9B,CAAC;AAIF,eAAO,MAAM,gBAAgB;2BAuDk1C,CAAC;iDAvD7zC,CAAC;AAIpD,eAAO,MAAM,iBAAiB,0dAE7B,CAAC;AAIF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;qSAE5B,CAAC;AAIF,UAAU,yBAAyB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,oBAAoB,gRA+BhC,CAAC"}
@@ -9,11 +9,11 @@ export const StyledEditorContainer = styled.div `
9
9
  }
10
10
  `;
11
11
  StyledEditorContainer.defaultProps = defaultThemeProp;
12
- export const StyledEditorIframe = styled.iframe(({ theme, $minHeight, $maxHeight }) => {
12
+ export const StyledEditorIframe = styled.iframe(({ theme, $minHeight, $maxHeight, $hidden }) => {
13
13
  const minHeightValue = $minHeight
14
- ? `${$minHeight / 16}rem`
14
+ ? `${$minHeight}px`
15
15
  : theme.components['text-area']['min-height'];
16
- const maxHeightValue = $maxHeight ? `${$maxHeight / 16}rem` : undefined;
16
+ const maxHeightValue = $maxHeight ? `${$maxHeight}px` : undefined;
17
17
  return css `
18
18
  display: block;
19
19
  width: 100%;
@@ -24,6 +24,12 @@ export const StyledEditorIframe = styled.iframe(({ theme, $minHeight, $maxHeight
24
24
  max-height: ${maxHeightValue};
25
25
  overflow: auto;
26
26
  `}
27
+ ${$hidden &&
28
+ css `
29
+ position: absolute;
30
+ visibility: hidden;
31
+ pointer-events: none;
32
+ `}
27
33
  `;
28
34
  });
29
35
  StyledEditorIframe.defaultProps = defaultThemeProp;
@@ -37,4 +43,34 @@ export const StyledFormDialog = styled(FormDialog) `
37
43
  overflow: auto;
38
44
  `;
39
45
  StyledFormDialog.defaultProps = defaultThemeProp;
46
+ export const StyledSourceTextarea = styled.textarea(({ theme, $minHeight, $maxHeight }) => {
47
+ const minHeightValue = $minHeight
48
+ ? `${$minHeight}px`
49
+ : theme.components['text-area']['min-height'];
50
+ const maxHeightValue = $maxHeight ? `${$maxHeight}px` : undefined;
51
+ return css `
52
+ display: block;
53
+ width: 100%;
54
+ border: none;
55
+ min-height: ${minHeightValue};
56
+ font-family: monospace;
57
+ font-size: ${theme.base['font-size']};
58
+ padding: ${theme.base.spacing};
59
+ resize: none;
60
+ background-color: ${theme.components['form-control']['background-color']};
61
+ color: ${theme.base.palette['foreground-color']};
62
+
63
+ ${maxHeightValue &&
64
+ css `
65
+ max-height: ${maxHeightValue};
66
+ overflow: auto;
67
+ `}
68
+
69
+ &:focus {
70
+ outline: none;
71
+ box-shadow: ${theme.base.shadow.focus};
72
+ }
73
+ `;
74
+ });
75
+ StyledSourceTextarea.defaultProps = defaultThemeProp;
40
76
  //# sourceMappingURL=Editor.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.styles.js","sourceRoot":"","sources":["../../../src/components/Editor/Editor.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3F,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;CAO9C,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAOtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAC7C,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE;IACpC,MAAM,cAAc,GAAG,UAAU;QAC/B,CAAC,CAAC,GAAG,UAAU,GAAG,EAAE,KAAK;QACzB,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAExE,OAAO,GAAG,CAAA;;;;oBAIM,cAAc;QAC1B,cAAc;QAChB,GAAG,CAAA;sBACa,cAAc;;OAE7B;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA,EAAE,CAAC;AAEpD,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;;CAE/C,CAAC;AAEF,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;;CAEjD,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { FormDialog, FormField, Popover, defaultThemeProp } from '@pega/cosmos-react-core';\n\nexport const StyledEditorContainer = styled.div`\n position: relative;\n cursor: text;\n\n .ProseMirror:focus {\n outline: none;\n }\n`;\n\nStyledEditorContainer.defaultProps = defaultThemeProp;\n\ninterface StyledEditorIframeProps {\n $minHeight?: number;\n $maxHeight?: number;\n}\n\nexport const StyledEditorIframe = styled.iframe<StyledEditorIframeProps>(\n ({ theme, $minHeight, $maxHeight }) => {\n const minHeightValue = $minHeight\n ? `${$minHeight / 16}rem`\n : theme.components['text-area']['min-height'];\n const maxHeightValue = $maxHeight ? `${$maxHeight / 16}rem` : undefined;\n\n return css`\n display: block;\n width: 100%;\n border: none;\n min-height: ${minHeightValue};\n ${maxHeightValue &&\n css`\n max-height: ${maxHeightValue};\n overflow: auto;\n `}\n `;\n }\n);\n\nStyledEditorIframe.defaultProps = defaultThemeProp;\n\nexport const StyledEditorRoot = styled(FormField)``;\n\nStyledEditorRoot.defaultProps = defaultThemeProp;\n\nexport const StyledEditPopover = styled(Popover)`\n overflow: auto;\n`;\n\nStyledEditPopover.defaultProps = defaultThemeProp;\n\nexport const StyledFormDialog = styled(FormDialog)`\n overflow: auto;\n`;\n\nStyledFormDialog.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"Editor.styles.js","sourceRoot":"","sources":["../../../src/components/Editor/Editor.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,O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G,MAAM,CAAC,QAAQ,CACjD,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE;IACpC,MAAM,cAAc,GAAG,UAAU;QAC/B,CAAC,CAAC,GAAG,UAAU,IAAI;QACnB,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAElE,OAAO,GAAG,CAAA;;;;oBAIM,cAAc;;mBAEf,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;iBACzB,KAAK,CAAC,IAAI,CAAC,OAAO;;0BAET,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,kBAAkB,CAAC;eAC/D,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;QAE7C,cAAc;QAChB,GAAG,CAAA;sBACa,cAAc;;OAE7B;;;;sBAIe,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;;KAExC,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { FormDialog, FormField, Popover, defaultThemeProp } from '@pega/cosmos-react-core';\n\nexport const StyledEditorContainer = styled.div`\n position: relative;\n cursor: text;\n\n .ProseMirror:focus {\n outline: none;\n }\n`;\n\nStyledEditorContainer.defaultProps = defaultThemeProp;\n\ninterface StyledEditorIframeProps {\n $minHeight?: number;\n $maxHeight?: number;\n $hidden?: boolean;\n}\n\nexport const StyledEditorIframe = styled.iframe<StyledEditorIframeProps>(\n ({ theme, $minHeight, $maxHeight, $hidden }) => {\n const minHeightValue = $minHeight\n ? `${$minHeight}px`\n : theme.components['text-area']['min-height'];\n const maxHeightValue = $maxHeight ? `${$maxHeight}px` : undefined;\n\n return css`\n display: block;\n width: 100%;\n border: none;\n min-height: ${minHeightValue};\n ${maxHeightValue &&\n css`\n max-height: ${maxHeightValue};\n overflow: auto;\n `}\n ${$hidden &&\n css`\n position: absolute;\n visibility: hidden;\n pointer-events: none;\n `}\n `;\n }\n);\n\nStyledEditorIframe.defaultProps = defaultThemeProp;\n\nexport const StyledEditorRoot = styled(FormField)``;\n\nStyledEditorRoot.defaultProps = defaultThemeProp;\n\nexport const StyledEditPopover = styled(Popover)`\n overflow: auto;\n`;\n\nStyledEditPopover.defaultProps = defaultThemeProp;\n\nexport const StyledFormDialog = styled(FormDialog)`\n overflow: auto;\n`;\n\nStyledFormDialog.defaultProps = defaultThemeProp;\n\ninterface StyledSourceTextareaProps {\n $minHeight?: number;\n $maxHeight?: number;\n}\n\nexport const StyledSourceTextarea = styled.textarea<StyledSourceTextareaProps>(\n ({ theme, $minHeight, $maxHeight }) => {\n const minHeightValue = $minHeight\n ? `${$minHeight}px`\n : theme.components['text-area']['min-height'];\n const maxHeightValue = $maxHeight ? `${$maxHeight}px` : undefined;\n\n return css`\n display: block;\n width: 100%;\n border: none;\n min-height: ${minHeightValue};\n font-family: monospace;\n font-size: ${theme.base['font-size']};\n padding: ${theme.base.spacing};\n resize: none;\n background-color: ${theme.components['form-control']['background-color']};\n color: ${theme.base.palette['foreground-color']};\n\n ${maxHeightValue &&\n css`\n max-height: ${maxHeightValue};\n overflow: auto;\n `}\n\n &:focus {\n outline: none;\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n }\n);\n\nStyledSourceTextarea.defaultProps = defaultThemeProp;\n"]}
@@ -1,3 +1,3 @@
1
1
  export declare const elements: readonly ["iframe"];
2
- export declare const getEditorTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["iframe", "toolbar", "text-styles", "bold", "italic", "strike-through", "bulleted-list", "numbered-list", "indent", "unindent", "link", "image", "ai-rewrite", "label", "info", "additional-info", "suggestion-accept", "suggestion-reject"]>;
2
+ export declare const getEditorTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["iframe", "toolbar", "text-styles", "bold", "italic", "strike-through", "underline", "subscript", "superscript", "font-family", "font-size", "text-color", "background-color", "alignment", "align-left", "align-center", "align-right", "bulleted-list", "numbered-list", "indent", "unindent", "table", "link", "image", "source-code", "ai-rewrite", "overflow", "word-count", "label", "info", "additional-info", "suggestion-accept", "suggestion-reject"]>;
3
3
  //# sourceMappingURL=Editor.test-ids.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Editor/Editor.test-ids.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,qBAAsB,CAAC;AAE5C,eAAO,MAAM,gBAAgB,kXAIlB,CAAC"}
1
+ {"version":3,"file":"Editor.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Editor/Editor.test-ids.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,qBAAsB,CAAC;AAE5C,eAAO,MAAM,gBAAgB,qkBAIlB,CAAC"}
@@ -98,5 +98,11 @@ export interface EditorProps extends FormControlProps, BaseProps, TestIdProp {
98
98
  onRewriteClick?: (originalText: string, rewriteAction: AIAction, additionalInstructions: string, onSuccess: (rewrittenText: string) => void) => void;
99
99
  /** If there is a progress state (e.g. AI rewrite in progress), you must indicate as such. Shows a Progress overlay on the editor. */
100
100
  progress?: boolean | string;
101
+ /**
102
+ * Enables secure mode which sanitizes content to prevent XSS attacks.
103
+ * Strips scripts, iframes, event handlers, and dangerous URLs.
104
+ * @default false
105
+ */
106
+ secure?: boolean;
101
107
  }
102
108
  //# sourceMappingURL=Editor.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.types.d.ts","sourceRoot":"","sources":["../../../src/components/Editor/Editor.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,GAAG,E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6CAA6C;IAC7C,WAAW,CAAC,EAAE;QACZ,sDAAsD;QACtD,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,yDAAyD;QACzD,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,2GAA2G;QAC3G,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,2EAA2E;QAC3E,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;QACtD,iDAAiD;QACjD,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,2BAA2B;IAC3B,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACvB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAC5C,8HAA8H;IAC9H,cAAc,CAAC,EAAE,CACf,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,QAAQ,EACvB,sBAAsB,EAAE,MAAM,EAC9B,SAAS,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,KACvC,IAAI,CAAC;IACV,qIAAqI;IACrI,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.types.js","sourceRoot":"","sources":["../../../src/components/Editor/Editor.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ReactNode,\n Ref,\n MouseEvent as ReactMouseEvent,\n KeyboardEvent as ReactKeyboardEvent\n} from 'react';\nimport type { Editor as TiptapEditor } from '@tiptap/core';\n\nimport type {\n Action,\n BaseProps,\n FormControlProps,\n TestIdProp,\n AIAction\n} from '@pega/cosmos-react-core';\n\nimport type { Features } from '../RichTextEditor/Toolbar/Toolbar.types';\nimport type { RichTextEditorState } from '../RichTextEditor';\n\nexport type EditorState = RichTextEditorState & {\n getEditor: () => TiptapEditor | null;\n element?: HTMLElement;\n setCursorLocationToStart?: () => void;\n updateAttachmentAttributes: (id: string, progress?: number, error?: string) => void;\n};\n\nexport type CustomAction = {\n text: Action['text'];\n icon: NonNullable<Action['icon']>;\n onMouseDown: (e: ReactMouseEvent | ReactKeyboardEvent) => void;\n active?: (editor: TiptapEditor) => boolean;\n shortcut?: {\n pattern: string;\n description: string;\n command: (editor: TiptapEditor) => void;\n };\n 'data-testid'?: string;\n};\n\nexport type CustomComponent = {\n createCustomElement: (window: typeof globalThis) => CustomElementConstructor;\n name: string;\n extensionAttributes?: string[];\n style?: string;\n};\n\nexport interface EditorProps extends FormControlProps, BaseProps, TestIdProp {\n /** An array of strings that activate features on the toolbar */\n toolbar?: Features[];\n /** Children content */\n children?: ReactNode;\n /** A callback that supplies an object with functions that can manipulate the editor and retrieve it's content/state */\n onChange?: (editor?: TiptapEditor) => void;\n /** KeyDown event custom handlers for the editor */\n onKeyDown?: (event?: KeyboardEvent) => void;\n /** A callback that runs if the editor is focused */\n onFocus?: () => void;\n /** A callback that runs if the editor loses focus */\n onBlur?: () => void;\n /** A callback when an image is added through the toolbar image feature */\n onImageAdded?: (image: File, id: string, altText?: string) => void;\n /** A callback for when the editor is finished initializing */\n onInit?: (editor: TiptapEditor) => void;\n /** A callback that runs when the iframe is about to unload, useful for saving editor state */\n onUnload?: (value: string) => void;\n /** Standard placeholder for an input */\n placeholder?: string;\n /** Default value for the RTE - HTML String */\n defaultValue?: string;\n /** Will automatically focus the RTE on render if true */\n autoFocus?: boolean;\n /** Sets the height for the RTE. If no max height is set the RTE will continue to expand, otherwise an overflow will be applied */\n height?: {\n min?: number;\n max?: number;\n };\n /**\n * Determines if the editor resizes its height based on content and user interactions.\n * @default true;\n */\n autoResize?: boolean;\n /** An array of custom components, custom components must use web component API */\n customComponents?: CustomComponent[];\n /** An array of custom buttons to be inserted into the toolbar */\n customActions?: CustomAction[];\n /**\n * Enables browser spellcheck.\n * @default true\n */\n spellcheck?: boolean;\n /** Options used during init of the editor */\n initOptions?: {\n /** Disables pasting of images in editor when false */\n pasteDataImages?: boolean;\n /** Converts formatted text to plain text upon pasting */\n pasteAsText?: boolean;\n /** Disables inline, block, and replacement text patterns when false and can be array of allowed formats */\n textPatterns?: boolean;\n /** Function called during init_instance_callback as part of editor init */\n initInstanceCallback?: (editor: TiptapEditor) => void;\n /** Styles to set within the iframe's document */\n contentStyle?: string;\n };\n /** Handle to the state. */\n ref?: Ref<EditorState>;\n /**\n * Determines the image insertion mode for the editor.\n * - 'file': Only allows uploading image files from local system\n * - 'url': Only allows adding images via URL/link\n * - 'all': Allows all image files upload options\n * @default 'all'\n */\n imageInsertionMode?: 'file' | 'url' | 'all';\n /** A callback when the AI rewrite toolbar button is used. The onSuccess callback should be called with the rewritten text. */\n onRewriteClick?: (\n originalText: string,\n rewriteAction: AIAction,\n additionalInstructions: string,\n onSuccess: (rewrittenText: string) => void\n ) => void;\n /** If there is a progress state (e.g. AI rewrite in progress), you must indicate as such. Shows a Progress overlay on the editor. */\n progress?: boolean | string;\n}\n"]}
1
+ {"version":3,"file":"Editor.types.js","sourceRoot":"","sources":["../../../src/components/Editor/Editor.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ReactNode,\n Ref,\n MouseEvent as ReactMouseEvent,\n KeyboardEvent as ReactKeyboardEvent\n} from 'react';\nimport type { Editor as TiptapEditor } from '@tiptap/core';\n\nimport type {\n Action,\n BaseProps,\n FormControlProps,\n TestIdProp,\n AIAction\n} from '@pega/cosmos-react-core';\n\nimport type { Features } from '../RichTextEditor/Toolbar/Toolbar.types';\nimport type { RichTextEditorState } from '../RichTextEditor';\n\nexport type EditorState = RichTextEditorState & {\n getEditor: () => TiptapEditor | null;\n element?: HTMLElement;\n setCursorLocationToStart?: () => void;\n updateAttachmentAttributes: (id: string, progress?: number, error?: string) => void;\n};\n\nexport type CustomAction = {\n text: Action['text'];\n icon: NonNullable<Action['icon']>;\n onMouseDown: (e: ReactMouseEvent | ReactKeyboardEvent) => void;\n active?: (editor: TiptapEditor) => boolean;\n shortcut?: {\n pattern: string;\n description: string;\n command: (editor: TiptapEditor) => void;\n };\n 'data-testid'?: string;\n};\n\nexport type CustomComponent = {\n createCustomElement: (window: typeof globalThis) => CustomElementConstructor;\n name: string;\n extensionAttributes?: string[];\n style?: string;\n};\n\nexport interface EditorProps extends FormControlProps, BaseProps, TestIdProp {\n /** An array of strings that activate features on the toolbar */\n toolbar?: Features[];\n /** Children content */\n children?: ReactNode;\n /** A callback that supplies an object with functions that can manipulate the editor and retrieve it's content/state */\n onChange?: (editor?: TiptapEditor) => void;\n /** KeyDown event custom handlers for the editor */\n onKeyDown?: (event?: KeyboardEvent) => void;\n /** A callback that runs if the editor is focused */\n onFocus?: () => void;\n /** A callback that runs if the editor loses focus */\n onBlur?: () => void;\n /** A callback when an image is added through the toolbar image feature */\n onImageAdded?: (image: File, id: string, altText?: string) => void;\n /** A callback for when the editor is finished initializing */\n onInit?: (editor: TiptapEditor) => void;\n /** A callback that runs when the iframe is about to unload, useful for saving editor state */\n onUnload?: (value: string) => void;\n /** Standard placeholder for an input */\n placeholder?: string;\n /** Default value for the RTE - HTML String */\n defaultValue?: string;\n /** Will automatically focus the RTE on render if true */\n autoFocus?: boolean;\n /** Sets the height for the RTE. If no max height is set the RTE will continue to expand, otherwise an overflow will be applied */\n height?: {\n min?: number;\n max?: number;\n };\n /**\n * Determines if the editor resizes its height based on content and user interactions.\n * @default true;\n */\n autoResize?: boolean;\n /** An array of custom components, custom components must use web component API */\n customComponents?: CustomComponent[];\n /** An array of custom buttons to be inserted into the toolbar */\n customActions?: CustomAction[];\n /**\n * Enables browser spellcheck.\n * @default true\n */\n spellcheck?: boolean;\n /** Options used during init of the editor */\n initOptions?: {\n /** Disables pasting of images in editor when false */\n pasteDataImages?: boolean;\n /** Converts formatted text to plain text upon pasting */\n pasteAsText?: boolean;\n /** Disables inline, block, and replacement text patterns when false and can be array of allowed formats */\n textPatterns?: boolean;\n /** Function called during init_instance_callback as part of editor init */\n initInstanceCallback?: (editor: TiptapEditor) => void;\n /** Styles to set within the iframe's document */\n contentStyle?: string;\n };\n /** Handle to the state. */\n ref?: Ref<EditorState>;\n /**\n * Determines the image insertion mode for the editor.\n * - 'file': Only allows uploading image files from local system\n * - 'url': Only allows adding images via URL/link\n * - 'all': Allows all image files upload options\n * @default 'all'\n */\n imageInsertionMode?: 'file' | 'url' | 'all';\n /** A callback when the AI rewrite toolbar button is used. The onSuccess callback should be called with the rewritten text. */\n onRewriteClick?: (\n originalText: string,\n rewriteAction: AIAction,\n additionalInstructions: string,\n onSuccess: (rewrittenText: string) => void\n ) => void;\n /** If there is a progress state (e.g. AI rewrite in progress), you must indicate as such. Shows a Progress overlay on the editor. */\n progress?: boolean | string;\n /**\n * Enables secure mode which sanitizes content to prevent XSS attacks.\n * Strips scripts, iframes, event handlers, and dangerous URLs.\n * @default false\n */\n secure?: boolean;\n}\n"]}
@@ -14,6 +14,7 @@ export interface IframeTiptapEditorProps {
14
14
  onInit?: (editor: TiptapEditor) => void;
15
15
  onImageAdded?: (image: File, id: string, altText?: string) => void;
16
16
  imagesEnabled?: boolean;
17
+ linksEnabled?: boolean;
17
18
  imageInsertionMode?: 'file' | 'url' | 'all';
18
19
  pastedImagesRef?: MutableRefObject<File[]>;
19
20
  editorId?: string;
@@ -21,6 +22,9 @@ export interface IframeTiptapEditorProps {
21
22
  spellcheck?: boolean;
22
23
  customElements?: CustomComponent[];
23
24
  initOptions?: EditorProps['initOptions'];
25
+ secure?: boolean;
26
+ onFocusTableMenu?: () => void;
27
+ onFocusPreviousCellMenu?: () => void;
24
28
  }
25
- export declare const IframeTiptapEditor: ({ placeholder, defaultValue, disabled, readOnly, onChange, onKeyDown, onFocus, onBlur, onInit, editorRef, spellcheck, customElements, initOptions, onImageAdded, imagesEnabled, imageInsertionMode, pastedImagesRef, editorId }: IframeTiptapEditorProps) => import("react/jsx-runtime").JSX.Element;
29
+ export declare const IframeTiptapEditor: ({ placeholder, defaultValue, disabled, readOnly, onChange, onKeyDown, onFocus, onBlur, onInit, editorRef, spellcheck, customElements, initOptions, onImageAdded, imagesEnabled, linksEnabled, imageInsertionMode, pastedImagesRef, editorId, secure, onFocusTableMenu, onFocusPreviousCellMenu }: IframeTiptapEditorProps) => import("react/jsx-runtime").JSX.Element;
26
30
  //# sourceMappingURL=IframeTiptapEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IframeTiptapEditor.d.ts","sourceRoot":"","sources":["../../../src/components/Editor/IframeTiptapEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AAU3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAI9C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AA2FjE,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,GAAG,KAAK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