-
Notifications
You must be signed in to change notification settings - Fork 1
fix: improve editor UI #347
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d42d60d
fix: link color
vitonsky 1213fd8
fix: css custom props name
vitonsky 19539a2
fix: consistent selection style
vitonsky 719e55f
chore: update packages
vitonsky 80da843
chore: improve CSS
vitonsky 1d496c6
chore: update imports
vitonsky cbd5660
test: implement Playwright unit tests
vitonsky 10ee5c4
test: add text with few paragraphs
vitonsky 5f52f6e
chore: update tsconfig types
vitonsky acbecca
test: preserve empty paragraphs
vitonsky d629334
feat: ensure empty paragraph in Lexical
vitonsky eae00e5
feat: convert each 2 lines into 1 paragraph
vitonsky e0fd1e0
feat: serialize empty paragraph as empty line
vitonsky bc00410
fix: stabilize empty lines strategy
vitonsky a9395e7
test: fix dom test
vitonsky 3e573fc
test: update serialization cases
vitonsky e79bec4
chore: fix list styles
vitonsky 436558d
ci: install playwright
vitonsky d403848
fix: header styles
vitonsky 57787e1
docs: add readme
vitonsky 96f8f18
ci: build the app
vitonsky 995e814
ci: build the app
vitonsky 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| .transly | ||
| chakra-config.json | ||
| chakra-config.json | ||
| .vitest-attachments |
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
107 changes: 107 additions & 0 deletions
107
packages/app/src/features/NoteEditor/RichEditor/__tests__/utils/renderEditorInDOM.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,107 @@ | ||
| import React, { act, createRef } from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
| import { Provider } from 'react-redux'; | ||
| import { createEvent } from 'effector'; | ||
| import { LexicalEditor } from 'lexical'; | ||
| import { FilesController } from '@core/features/files/FilesController'; | ||
| import { | ||
| FilesRegistryContext, | ||
| NotesContext, | ||
| NotesRegistryContext, | ||
| } from '@features/App/Workspace/WorkspaceProvider'; | ||
| import { | ||
| editorPanelContext, | ||
| InsertingPayload, | ||
| TextFormat, | ||
| } from '@features/NoteEditor/EditorPanel'; | ||
| import { RichEditor } from '@features/NoteEditor/RichEditor/RichEditor'; | ||
| import { RichEditorContentProps } from '@features/NoteEditor/RichEditor/RichEditorContent'; | ||
| import { ThemeProvider } from '@features/ThemeProvider'; | ||
| import { createTestStore } from '@tests/utils/redux'; | ||
|
|
||
| // Mock useUrlOpener to avoid importing monaco-editor-core in tests, | ||
| // which causes Vite module resolution errors during test setup | ||
| vi.mock('@hooks/useUrlOpener', () => ({ | ||
| useUrlOpener: () => vi.fn(), | ||
| })); | ||
|
|
||
| export const MockWorkspaceProvider = ({ children }: { children: React.ReactNode }) => { | ||
| const filesRegistry = { | ||
| add: vi.fn(), | ||
| get: vi.fn(), | ||
| delete: vi.fn(), | ||
| query: vi.fn(), | ||
| } as unknown as FilesController; | ||
|
|
||
| const notesControl = { | ||
| get: vi.fn(), | ||
| updateBatch: vi.fn(), | ||
| getById: vi.fn(), | ||
| getLength: vi.fn(), | ||
| query: vi.fn(), | ||
| add: vi.fn(), | ||
| update: vi.fn(), | ||
| updateMeta: vi.fn(), | ||
| delete: vi.fn(), | ||
| }; | ||
|
|
||
| const notesApi = { | ||
| openNote: vi.fn(), | ||
| noteUpdated: vi.fn(), | ||
| noteClosed: vi.fn(), | ||
| }; | ||
|
|
||
| return ( | ||
| <NotesContext.Provider value={notesApi}> | ||
| <FilesRegistryContext.Provider value={filesRegistry}> | ||
| <NotesRegistryContext.Provider value={notesControl}> | ||
| {children} | ||
| </NotesRegistryContext.Provider> | ||
| </FilesRegistryContext.Provider> | ||
| </NotesContext.Provider> | ||
| ); | ||
| }; | ||
|
|
||
| export const renderRichEditorInDOM = async (props: RichEditorContentProps) => { | ||
| const { store } = createTestStore(); | ||
| const onFormatting = createEvent<TextFormat>(); | ||
| const onInserting = createEvent<InsertingPayload>(); | ||
|
|
||
| const editorRef = createRef<LexicalEditor>(); | ||
|
|
||
| const renderEditor = (props: RichEditorContentProps) => ( | ||
| <Provider store={store}> | ||
| <ThemeProvider> | ||
| <MockWorkspaceProvider> | ||
| <editorPanelContext.Provider value={{ onInserting, onFormatting }}> | ||
| <RichEditor placeholder="Enter text" {...props} /> | ||
| </editorPanelContext.Provider> | ||
| </MockWorkspaceProvider> | ||
| </ThemeProvider> | ||
| </Provider> | ||
| ); | ||
|
|
||
| const container = document.createElement('div'); | ||
| document.body.appendChild(container); | ||
|
|
||
| const root = createRoot(container); | ||
| act(() => root.render(renderEditor({ ...props, editorRef }))); | ||
|
|
||
| return { | ||
| root, | ||
| container, | ||
|
|
||
| destroy() { | ||
| act(() => { | ||
| root.unmount(); | ||
| }); | ||
| container.remove(); | ||
| }, | ||
|
|
||
| getEditor() { | ||
| const editor = editorRef.current; | ||
| if (!editor) throw new Error('Error instance is not set'); | ||
| return editor; | ||
| }, | ||
| }; | ||
| }; | ||
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
5 changes: 3 additions & 2 deletions
5
packages/app/src/features/NoteEditor/RichEditor/plugins/CodeHighlightPlugin.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
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
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.