Commit Graph

125 Commits

Author SHA1 Message Date
Jonatan Heyman
d5dc4760d8 Implement support for editing notes' metadata, and ability to move notes into other directories.
Create separate pinia store for the editor cache functionality.
2024-09-04 15:22:06 +02:00
Jonatan Heyman
4b39078689 WIP: Implement ability to create new notes.
Support cache of multiple Editor instances.

Change so that current note name is included in the event data dispatched by emitCursorChange.
2024-07-26 11:30:25 +02:00
Jonatan Heyman
44aed5feb0 Better error message 2024-07-25 13:21:28 +02:00
Jonatan Heyman
f11f360496 WIP: Implement support for multiple notes
Refactor Vue <-> Editor <-> CodeMirror code.
Introduce Pinia store to keep global state, in order to get rid of a lot of event juggling between Editor class/child components and the root App component.
2024-07-24 13:53:44 +02:00
Jonatan Heyman
68c741ea46 Throw error if major format version is greater than the currently supported version 2024-07-17 15:20:21 +02:00
Jonatan Heyman
86243f493d Fix race condition that could cause the editor to not scroll the cursor(s) into the viewport upon loading 2024-07-15 20:23:17 +02:00
Jonatan Heyman
2e262241c9 Add metadata to the beginning of the serialized buffer.
Store the cursors' positions in the buffer metadata and restore the cursors when loading the buffer content.
2024-07-15 10:45:25 +02:00
Jonatan Heyman
8626dcc141 Fix error on startup when cursor is moved to the end of a large buffer (caused by the syntaxTree not being parsed in time) 2024-07-14 14:51:15 +02:00
Jonatan Heyman
6363422585
Merge branch 'main' into support-dart-syntax
Signed-off-by: Jonatan Heyman <jonatan@heyman.info>
2024-07-14 12:51:14 +02:00
Jonatan Heyman
6ec20ee873 Guesslang does not support Vue 2024-07-14 12:45:35 +02:00
JongwooLee
c870a48a7e build grammar 2024-07-14 12:45:35 +02:00
JongwooLee
f9c841d19e add vue language support 2024-07-14 12:45:35 +02:00
Jonatan Heyman
d82b3920d7 Add setting for configuring the default block language and language auto detection 2024-07-14 12:19:29 +02:00
Jonatan Heyman
f33be7f3a4 Fix bug causing editing to break when there are empty blocks of a language that uses a StreamParser 2024-07-11 14:46:20 +02:00
Cris
e8971a6733 Add default redo cmd that works on all Platforms. Mod+Shift+Z 2024-07-08 22:58:18 +02:00
Jonatan Heyman
bc3a9b66a1 Add test that ensures that getBlocksFromSyntaxTree() and getBlocksFromString() functions produces the same results 2024-07-07 22:05:33 +02:00
Jonatan Heyman
016422e7db Update imports so that that they also work in playwright tests 2024-07-07 22:05:33 +02:00
Jonatan Heyman
9bcf03d00c Typo 2024-07-07 22:05:33 +02:00
Jonatan Heyman
c3892163af Remove timeout parameter for getBlocksFromSyntaxTree() since we now expect the syntax tree to already be available. 2024-07-07 22:05:33 +02:00
Jonatan Heyman
29d4eb26cc Optimize block parsing when syntax tree isn't available.
If the syntax tree isn't available, use String.indexOf to parse the blocks.
2024-07-07 22:05:33 +02:00
Donghee Lee
d943fc8015 Support Dart Syntax 2024-06-12 07:47:45 +02:00
Jonatan Heyman
d591d7ddb1 Add PowerShell language mode 2024-02-09 16:02:07 +01:00
Jonatan Heyman
9e3fc5e8e6 Add Diff language mode 2024-02-09 16:02:07 +01:00
Abhishek Maran
5eed314e32
fix: Block corruption when deleting block content using deleteLine command (#134)
* fix: cell corruption when deleting block contents

* customize deleteLine to fix cell corruption

* implemented tests for delete line

* moved deleteLine and selectedLineBlocks to delete-line.js
2024-02-07 13:03:59 +01:00
Jonatan Heyman
f9673b0954 Use explicit key bindings for copy/paste/cut, instead of just relying on default browser keys 2024-01-29 13:20:21 +01:00
Jonatan Heyman
41d9ef7025
Copy whole current line(s) when selection(s) are empty (#177)
* Copy whole current line(s) when selection(s) are empty

* Fix tests on Linux/Windows
2024-01-25 17:44:38 +01:00
Jonatan Heyman
5adbbc72ec
Add prev variable to Math blocks that holds the previous value (#156)
Moved documentation on Math blocks from the FAQ into it's own section in the Readme.
2024-01-11 21:28:11 +01:00
Jonatan Heyman
66e7082786 Set default font size to 16px in webapp for mobile devices in order to avoid auto zoom in when the keyboard appears on iOS Safari 2024-01-11 21:05:15 +01:00
Jonatan Heyman
a56a267e06 Add support for changing font family and font size 2024-01-09 00:35:33 +01:00
Jonatan Heyman
554e04ea67 Fix test on linux/windows
Change Playwright reporter when running in Github action

Change default emacs meta key to Alt on non Linux and Windows

Always set emacsMetaKey to "alt" if not on Mac, since the option is only available on Mac
2024-01-06 01:51:07 +01:00
Jonatan Heyman
957b22c70e Refactor the way we handle copy/cut/paste in Emacs mode
Previously we listened for the key bindings for copy, cut and paste in the Electron main process, and triggered the event using copy(), paste() and cut() methods on win.webContent. Now this is fully handled within the renderer process using the window.navigator.clipboard API.

This will make it simpler to implement fully customizable key bindings.
2024-01-06 01:51:07 +01:00
Jonatan Heyman
1b0b2d55b1 Support setting preventDefault to false in keymapFromSpec spec 2024-01-06 01:51:07 +01:00
Florian Labarre
d0d8f872a6
Add key bindings for inserting new blocks at the end/top of the buffer, as well as before the current block (#85)
* Add functionality to insert new block after the last block

- Update key bindings in `initial-content.ts` to include `Alt + Enter` for adding a new block after the last block.
- Implement `getLastNoteBlock` function in `block.js` to retrieve the last block in the note.
- Add `addNewBlockAfterLast` command in `commands.js` to handle the insertion of a new block after the last one.
- Integrate `addNewBlockAfterLast` command into the keymap in `keymap.js`.

* Add block insertion before/after current, before first and after last. Also, tests.

- Added `getFirstNoteBlock` in `block.js` for accessing the first text block.
- Implemented new functions in `commands.js` like `addNewBlockBeforeCurrent` and `addNewBlockBeforeFirst`.
- Updated `keymap.js` with new key bindings to facilitate block creation.
- Introduced `block-creation.spec.js` for testing the new block manipulation features.

* Fix visual bug when inserting new block at the top

* Update help text and Readme

* Fix wrong cursor position after inserting new blocks at the top of the buffer, when the previous first block's delimiter is long (e.g. Markdown)

* Make RegEx more generic

* Fix import

* Auto-generate the README.md and initial-content documentation

- Add a documentation generator
- Add an option to force the initial content to be erased with an env variable

* Add more specific tests

* Fix Mod key on Mac in test

---------

Co-authored-by: Jonatan Heyman <jonatan@heyman.info>
2024-01-04 16:11:26 +01:00
Hojun Lee
b80230454d
Add Groovy language support (#111) 2024-01-04 15:18:28 +01:00
Florian Labarre
0f3c714d56
CloseBrackets setting toggle (#102)
* Add a setting to toggle the auto bracket-closing of CodeMirror

* Move Auto-close brackets setting into new settings tab Editing

* Add tests for Auto-close bracket setting

---------

Co-authored-by: Jonatan Heyman <jonatan@heyman.info>
2024-01-04 14:52:41 +01:00
Jonatan Heyman
4274e6237b
Watch buffer file for changes, and automatically reload it if changed (#76)
* Implement Buffer class in main process that watches for changes to the file, and notifies the editor in the renderer process so that it can update the buffer.

* Add Editor.setReadOnly() method

* Add dummy onChangeCallback function

* Remove debug logging
2024-01-01 19:04:40 +01:00
Jonatan Heyman
0b6a1a49e8
Add support for specifying a custom format function within a math block (#99) 2023-12-31 10:43:42 +01:00
Laeyoung
b0f3bdd19e
Add Swift and Kotlin language support #10 (#96)
* Add Swift language support

* Add Kotlin language support
2023-12-31 10:07:21 +01:00
Jonatan Heyman
a1cad5b335
Don't display string quotes for math results that are strings. (#92)
Fix bug that could cause the cursor to be positioned immediately to the left of the widget (within its margin) making it look like there was a space character in the buffer when there was not.
Add tests for math blocks.

Fixes #21.
2023-12-29 10:47:02 +01:00
Jonatan Heyman
77ed45cfa2 Remove old, unused file 2023-12-28 14:40:01 +01:00
Jonatan Heyman
eda4981e59
Fix issue with large buffers where block delimiters wouldn't be "atomic" when first starting Heynote, before the first edit (#81)
* Increase timeout for parsing the syntax tree when it's done for the first time

* Return the already parsed blocks in the blockState facet from Editor.getBlocks() instead of parsing the syntax tree again.
Make the block extension's getBlocks() method private.
2023-12-27 12:55:24 +01:00
Jonatan Heyman
60caac45ab Add TOML support 2023-12-26 01:31:36 +01:00
Espen Jacobsson
475f3465fe
Add TypeScript, JSX and TSX language support (#64)
* Add language support for TypeScript

* Add formatter for TypeScript

* Add language autodetection for TypeScript

* Add TypeScript to list of featured languages

* Add language support for JSX and TSX

* Add JSX and TSX to list of featured languages

* Remove guesslang token from JSX and TSX

* Fix syntax error

---------

Co-authored-by: Jonatan Heyman <jonatan@heyman.info>
2023-12-26 00:47:28 +01:00
Jonatan Heyman
bb511b868b
Add support for more languages (#69)
* Contain language selection dialog in an element that can be scrolled, and automatically scroll it if needed when navigating the list with arrow keys

* Add support for more languages:

Clojure, Erlang, Golang, Lezer, Ruby, Shell, YAML

* Move prettier auto format settings for languages into Language() class

* Remove invalid import

* Fix bug that could cause auto formatting to fail for the last block.
Add tests for language auto detection and formatting.

* Fix broken tests

* Fix language auto detection on Safari Webkit which was broken

* Remove unnecessary wait time
2023-12-26 00:27:43 +01:00
Jonatan Heyman
1006fd4580
Implement tests using Playwright (#68)
* Set up Playwright and add first test

* Add npm run commands for running tests
Run tests in github actions

* Fix tests on non Mac environments

* Add method to HeynoteEditor class to set the buffer content

* Add more tests

* Set Github action job name
2023-12-25 17:41:15 +01:00
Jonatan Heyman
bbb6387581 Make sure saveFunction() is called when the page is unloaded 2023-12-24 22:21:41 +01:00
Ahmed M. Atia
96440b28ba
Add syntax highlighting support for C# (#55)
* feat: add syntax highlighting support for C#

* update README - add C# sysntac highlighting support

* restore original indentation / formatting

* Fix syntax error in Lezer grammar

* Fix language auto detection of C#

---------

Co-authored-by: Jonatan Heyman <jonatan@heyman.info>
2023-12-24 10:59:24 +01:00
Jonatan Heyman
bb9a39fe6e Fix bug where language auto detection will not trigger in some cases
E.g. if you pasted a piece of javascript, selected the whole block and deleted the text (which will change back the default language to Plaintext (auto)) and then paste the same javascript code again.
2023-12-24 00:13:17 +01:00
Jonatan Heyman
6086976dc4 Update prettier version and fix formatting bug.
Prettier currently has a bug that causes it's formatWithCursor() to be extremely slow in some cases. In Heynote, whenever you pasted a large JSON chunk and auto formatted it, with the cursor at the beginning or the start of the block, this would trigger that bug. This commit introduces a work around by using format() if the cursor is at the beginning or the end of the block.

Update to latest version of Prettier.
2023-12-21 03:09:53 +01:00
Jonatan Heyman
a88f9cc49b Update dependency versions
Explicitly add "@codemirror/*" packages instead of relying on the "codemirror" sample package.
Update to newer versions for implicit dependencies in in package-lock.json.

This should fix errors in development mode on Windows.
2023-12-10 12:18:43 +01:00