-
Notifications
You must be signed in to change notification settings - Fork 0
CRDCDH-3760 Implement Rich Text Editor and add to SRF review comments #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Alejandro-Vega
wants to merge
61
commits into
3.7.0
Choose a base branch
from
CRDCDH-3760
base: 3.7.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,101
−67
Open
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
6425a6a
chore(deps): install slate and rehype-raw
Alejandro-Vega 13392f9
add custom editor types and utilities for list formatting
Alejandro-Vega 86b5c56
feat: create editor toolbar
Alejandro-Vega 0be3e48
add keyboard handlers and utils
Alejandro-Vega a8cdc42
add markdown handlers and utils
Alejandro-Vega 72b705b
add: EditorLeaf to render Slate leaf nodes
Alejandro-Vega a85562f
add: EditorElement for for rendering element types
Alejandro-Vega c7b9ae1
added hook for handling editor keydown
Alejandro-Vega f0f2bd3
add: document utilities for Slate editor and update markdown parser
Alejandro-Vega d7f3536
fix: documentation wording
Alejandro-Vega ed6e0bf
add: useRichTextEditor hook for Slate editor handling
Alejandro-Vega 773ffa1
add: RichTextEditor component entry
Alejandro-Vega bf58a3f
created rich text viewer component
Alejandro-Vega 9fe4bfe
update review form dialog to include rich text editor
Alejandro-Vega 61187e0
update review comments dialog to include rich text viewer
Alejandro-Vega 66fb3ff
fix: incorrect import path
Alejandro-Vega b9f879d
Merge branch '3.7.0' of https://github.com/CBIIT/crdc-datahub-codebas…
Alejandro-Vega 80a60ee
add storybook support for rich text editor and viewer
Alejandro-Vega 29ed575
refactor: toolbar components and add test coverage
Alejandro-Vega 6b76941
fix: whitespace causing issues when formatting
Alejandro-Vega dcbb6a0
refactor: lazy load component and add test coverage for rich text editor
Alejandro-Vega 2a60235
refactor: clean up component and add test coverage to EditorLeaf
Alejandro-Vega d56010e
refactor: clean up EditorElement component and add test coverage
Alejandro-Vega 549701d
refactor: document utils and add test coverage
Alejandro-Vega d0d14fb
add test coverage for useRichTextEditor hook
Alejandro-Vega 7f995d7
refactor: cleanup documentation for utils
Alejandro-Vega 42eec14
add test coverage for editor transformation utils
Alejandro-Vega 603d7fe
refactor: cleanup docs for editor guards and add test coverage
Alejandro-Vega 0e4c24e
refactor: move functions to relevant utils file and add test coverage
Alejandro-Vega 8a361b2
refactor: centralize mark definitions
Alejandro-Vega 56d0a5f
refactor: combine util files, update docs, and add test coverage for …
Alejandro-Vega d85156a
add pattern to config and adjust type definition
Alejandro-Vega b954614
refactor: update documentation and add test coverage for keyboard hot…
Alejandro-Vega d4cfde4
refactor: keyboard list handlers and add test coverage
Alejandro-Vega d9e5ffc
refactor: add documentation to keyboard selection utils and test cove…
Alejandro-Vega 54fe78e
refactor: delete extra file and move keydown logic to hook
Alejandro-Vega d63a5dc
refactor: markdown inline parser utils and add test coverage
Alejandro-Vega daeaa89
refactor: markdown deserializer and add test coverage
Alejandro-Vega 31f1347
fix: use editor config instead of repeating patterns
Alejandro-Vega 52d6603
fix: delete line when backspacing and return previous list item
Alejandro-Vega 5019514
feat: add ability to enable/disable toolbar actions
Alejandro-Vega b707028
fix: border styling to be consistent with other fields
Alejandro-Vega d27cd2e
fix: failing tests due to mock
Alejandro-Vega d434f9d
fix: new lines not being preserved in rich text viewer
Alejandro-Vega b66d6ca
fix: clearing all in editor resulting in invalid cursor state
Alejandro-Vega e866a49
Merge branch '3.7.0' into CRDCDH-3760
Alejandro-Vega 07cf640
fix: type error
Alejandro-Vega 8eaee7c
Merge branch 'CRDCDH-3760' of https://github.com/CBIIT/crdc-datahub-c…
Alejandro-Vega f59cffd
refactor: general cleanup and reduce regex usage
Alejandro-Vega e226be1
add basic test coverage for rich text viewer
Alejandro-Vega 29ec4ab
update rich text viewer story
Alejandro-Vega 7142fdf
fix: storybook titles
Alejandro-Vega c7bf022
fix: remove export causing bundle size increase
Alejandro-Vega 37cea9f
fix: lazy load pdf generation lib
Alejandro-Vega 0c2ac62
fix: optimize bundle to avoid loading unecessary deps
Alejandro-Vega f34db61
fix: strip attributes from components in rich text viewer for security
Alejandro-Vega 68bc482
fix: incorrect text length calculation
Alejandro-Vega 42213a6
revert: lazy load causing failing tests
Alejandro-Vega 1097c00
Merge branch '3.7.0' into CRDCDH-3760
Alejandro-Vega 826e8da
fix: hide placeholder when list item and update background color
Alejandro-Vega 3a9ea21
fix: new lines in between causing incorrect character count
Alejandro-Vega File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/frontend/src/components/RichTextEditor/Controller.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { createEditor } from "slate"; | ||
| import { withHistory } from "slate-history"; | ||
| import { withReact } from "slate-react"; | ||
|
|
||
| import { render } from "../../test-utils"; | ||
|
|
||
| import Controller from "./Controller"; | ||
|
|
||
| const mockReset = vi.fn(); | ||
|
|
||
| vi.mock("./hooks/useRichTextEditor", () => ({ | ||
| useRichTextEditor: () => ({ | ||
| editor: withHistory(withReact(createEditor())), | ||
| initialValue: [{ type: "paragraph", children: [{ text: "" }] }], | ||
| handleChange: vi.fn(), | ||
| handleKeyDown: vi.fn(), | ||
| renderElement: ({ children }: { children: React.ReactNode }) => <div>{children}</div>, | ||
| renderLeaf: ({ children }: { children: React.ReactNode }) => <span>{children}</span>, | ||
| reset: mockReset, | ||
| }), | ||
| })); | ||
|
|
||
| vi.mock("./Toolbar", () => ({ | ||
| default: () => <div data-testid="toolbar" />, | ||
| })); | ||
|
|
||
| describe("RichTextEditor Controller", () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| it("should render without crashing", () => { | ||
| expect(() => render(<Controller value="" onChange={vi.fn()} />)).not.toThrow(); | ||
| }); | ||
|
|
||
| it("should render the toolbar when not disabled", () => { | ||
| const { getByTestId } = render(<Controller value="" onChange={vi.fn()} />); | ||
|
|
||
| expect(getByTestId("toolbar")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("should not render the toolbar when disabled", () => { | ||
| const { queryByTestId } = render(<Controller value="" onChange={vi.fn()} disabled />); | ||
|
|
||
| expect(queryByTestId("toolbar")).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("should apply aria-label to the editable area", () => { | ||
| const { getByRole } = render( | ||
| <Controller value="" onChange={vi.fn()} aria-label="Comment input" /> | ||
| ); | ||
|
|
||
| expect(getByRole("textbox", { name: "Comment input" })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("should set the editable to read-only when disabled", () => { | ||
| const { getByLabelText } = render( | ||
| <Controller value="" onChange={vi.fn()} disabled aria-label="Comment input" /> | ||
| ); | ||
|
|
||
| expect(getByLabelText("Comment input")).toHaveAttribute("contenteditable", "false"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.