@madie/madie-design-system 1.2.64 → 1.2.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madie/madie-design-system",
3
- "version": "1.2.64",
3
+ "version": "1.2.65",
4
4
  "description": "Shared style guide across the Madie program.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/MeasureAuthoringTool/madie-design-system",
@@ -188,6 +188,11 @@
188
188
  }
189
189
  }
190
190
  }
191
+
192
+ .rich-text-editor_read_only {
193
+ white-space: pre-wrap;
194
+ }
195
+
191
196
  /* Table-specific styling */
192
197
  table {
193
198
  border-collapse: collapse;
@@ -189,6 +189,10 @@
189
189
  }
190
190
  }
191
191
 
192
+ .rich-text-editor_read_only {
193
+ white-space: pre-wrap;
194
+ }
195
+
192
196
  /* Table-specific styling */
193
197
  table {
194
198
  border-collapse: collapse;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { render, screen, fireEvent, waitFor } from "@testing-library/react";
3
3
  import RichTextEditor from "../../components/RichTextEditor/index";
4
+ import DOMPurify from "dompurify";
4
5
 
5
6
  describe("RichTextEditor Component", () => {
6
7
  const mockOnChange = jest.fn();
@@ -88,4 +89,28 @@ describe("RichTextEditor Component", () => {
88
89
  expect(editorContent).toBeInTheDocument();
89
90
  expect(editorContent).toHaveTextContent("Safe Content");
90
91
  });
92
+
93
+ it("test renders sanitized content with preserved whitespace when readOnly is true", () => {
94
+ const content = `this is a statement
95
+ this is a statement
96
+ this is a statement
97
+
98
+ ---------------------
99
+ this is a statement`;
100
+
101
+ render(
102
+ <RichTextEditor
103
+ id="test-editor"
104
+ label="Test Label"
105
+ content={content}
106
+ onChange={mockOnChange}
107
+ readOnly
108
+ />
109
+ );
110
+
111
+ const readOnlyContent = screen.getByTestId("test-editor-value");
112
+
113
+ // Ensure the innerHTML matches the sanitized version of the content
114
+ expect(readOnlyContent.innerHTML).toBe(DOMPurify.sanitize(content));
115
+ });
91
116
  });