-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add more props to the codemirror editor to ease migration from older version #178
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0eced7b
support toggling line numbers
OskarDamkjaer b8a86c3
ensure min-height works as intended
OskarDamkjaer 81016b5
add changeset
OskarDamkjaer 36a779c
merge main
OskarDamkjaer 3fad5a0
fix e2e test
OskarDamkjaer a1b4ac0
fix test with overlapping panels
OskarDamkjaer d6752b5
fix changeset typo
OskarDamkjaer 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
This file contains 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,5 @@ | ||
--- | ||
'@neo4j-cypher/react-codemirror': patch | ||
--- | ||
|
||
Adds more props the CypherEditor component | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
97 changes: 97 additions & 0 deletions
97
packages/react-codemirror/src/e2e_tests/configuration.spec.tsx
This file contains 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,97 @@ | ||
import { expect, test } from '@playwright/experimental-ct-react'; | ||
import { CypherEditor } from '../CypherEditor'; | ||
|
||
test.use({ viewport: { width: 500, height: 500 } }); | ||
|
||
test('prompt shows up', async ({ mount, page }) => { | ||
const component = await mount(<CypherEditor prompt="neo4j>" />); | ||
|
||
await expect(component).toContainText('neo4j>'); | ||
|
||
await component.update(<CypherEditor prompt="test>" />); | ||
await expect(component).toContainText('test>'); | ||
|
||
const textField = page.getByRole('textbox'); | ||
await textField.press('a'); | ||
|
||
await expect(textField).toHaveText('a'); | ||
}); | ||
|
||
test('line numbers can be turned on/off', async ({ mount }) => { | ||
const component = await mount(<CypherEditor lineNumbers />); | ||
|
||
await expect(component).toContainText('1'); | ||
|
||
await component.update(<CypherEditor lineNumbers={false} />); | ||
await expect(component).not.toContainText('1'); | ||
}); | ||
|
||
test('can configure readonly', async ({ mount, page }) => { | ||
const component = await mount(<CypherEditor readonly />); | ||
|
||
const textField = page.getByRole('textbox'); | ||
await textField.press('a'); | ||
await expect(textField).not.toHaveText('a'); | ||
|
||
await component.update(<CypherEditor readonly={false} />); | ||
await textField.press('b'); | ||
await expect(textField).toHaveText('b'); | ||
}); | ||
|
||
test('can set placeholder ', async ({ mount, page }) => { | ||
const component = await mount(<CypherEditor placeholder="bulbasaur" />); | ||
|
||
const textField = page.getByRole('textbox'); | ||
await expect(textField).toHaveText('bulbasaur'); | ||
|
||
await component.update(<CypherEditor placeholder="venusaur" />); | ||
await expect(textField).not.toHaveText('bulbasaur'); | ||
await expect(textField).toHaveText('venusaur'); | ||
|
||
await textField.fill('abc'); | ||
await expect(textField).not.toHaveText('venusaur'); | ||
await expect(textField).toHaveText('abc'); | ||
}); | ||
|
||
test('can set/unset onFocus/onBlur', async ({ mount, page }) => { | ||
const component = await mount(<CypherEditor />); | ||
|
||
let focusFireCount = 0; | ||
let blurFireCount = 0; | ||
|
||
const focus = () => { | ||
focusFireCount += 1; | ||
}; | ||
const blur = () => { | ||
blurFireCount += 1; | ||
}; | ||
|
||
await component.update(<CypherEditor domEventHandlers={{ blur, focus }} />); | ||
|
||
const textField = page.getByRole('textbox'); | ||
await textField.click(); | ||
await expect(textField).toBeFocused(); | ||
|
||
// this is to give the events time to fire | ||
await expect(() => { | ||
expect(focusFireCount).toBe(1); | ||
expect(blurFireCount).toBe(0); | ||
}).toPass(); | ||
|
||
await textField.blur(); | ||
|
||
await expect(() => { | ||
expect(focusFireCount).toBe(1); | ||
expect(blurFireCount).toBe(1); | ||
}).toPass(); | ||
|
||
await component.update(<CypherEditor />); | ||
await textField.click(); | ||
await expect(textField).toBeFocused(); | ||
await textField.blur(); | ||
|
||
await expect(() => { | ||
expect(focusFireCount).toBe(1); | ||
expect(blurFireCount).toBe(1); | ||
}).toPass(); | ||
}); |
This file contains 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 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 |
---|---|---|
|
@@ -61,8 +61,9 @@ export const createCypherTheme = ({ | |
color: settings.gutterForeground, | ||
border: 'none', | ||
}, | ||
'&.cm-editor .cm-scroller': { | ||
'&.cm-editor': { | ||
fontFamily: 'Fira Code, Menlo, Monaco, Lucida Console, monospace', | ||
height: '100%', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is so that consumers can set a minimum height via the |
||
}, | ||
'.cm-content': { | ||
caretColor: settings.cursor, | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: to the CyherEditor component?