Skip to content

Commit

Permalink
Adds keyboard shortcut for strikethrough
Browse files Browse the repository at this point in the history
  • Loading branch information
DougReeder committed Feb 16, 2024
1 parent d184343 commit 7cee69f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,12 @@ function Detail({noteId, searchWords = new Set(), focusOnLoadCB, setMustShowPane
toggleMark(editor, 'bold');
}
break;
case '\\':
if (isHotkey('mod+\\', { byKey: true }, evt)) {
evt.preventDefault()
toggleMark(editor, 'strikethrough');
}
break;
case '`': {
if (isHotkey('mod+`', { byKey: true }, evt)) {
evt.preventDefault()
Expand Down
21 changes: 21 additions & 0 deletions src/Detail.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,27 @@ it('renders error if note missing', async () => {
expect(screen.getAllByRole('menuitem')).toHaveLength(12);
});

it("shows text style menu for rich text notes", async () => {
const noteId = uuidv4();
const noteText = "<p>some text</p>";
const noteDate = new Date(2022, 8, 5);
getNote.mockResolvedValue(Promise.resolve(new SerializedNote(noteId, 'text/html;hint=SEMANTIC', '', noteText, noteDate)));

render(<Detail noteId={noteId}></Detail>);
await screen.findByRole('textbox');
await userEvent.click(screen.getByRole('button', {name: "Open text style menu"}));
expect(screen.getByRole('menuitem', {name: "Italic"})).toBeVisible();
expect(screen.getByRole('menuitem', {name: "Bold"})).toBeVisible();
expect(screen.getByRole('menuitem', {name: "Monospaced"})).toBeVisible();
expect(screen.getByRole('menuitem', {name: /Superscript/i})).toBeVisible();
expect(screen.getByRole('menuitem', {name: /Subscript/i})).toBeVisible();
expect(screen.getByRole('menuitem', {name: "Underlined"})).toBeVisible();
expect(screen.getByRole('menuitem', {name: "Strikethrough"})).toBeVisible();
expect(screen.getByRole('menuitem', {name: "Deleted"})).toBeVisible();
expect(screen.getByRole('menuitem', {name: "Inserted"})).toBeVisible();
expect(screen.getAllByRole('menuitem')).toHaveLength(9);
});

// it('allows typing enter in blank item to end list', async () => {
// const noteId = uuidv4();
// const noteText = "<ol><li>first</li><li>second</li></ol>";
Expand Down

0 comments on commit 7cee69f

Please sign in to comment.