heynote/electron/initial-content.ts

119 lines
2.6 KiB
TypeScript
Raw Permalink Normal View History

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
import os from "os";
import { keyHelpStr } from "../shared-utils/key-helper";
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
export const eraseInitialContent = !!process.env.ERASE_INITIAL_CONTENT
2023-01-19 00:20:50 +01:00
2023-07-12 18:20:29 +02:00
export const initialContent = `
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
markdown
2023-07-12 18:20:29 +02:00
Welcome to Heynote! 👋
2023-01-19 00:20:50 +01:00
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
${keyHelpStr(os.platform())}
2023-03-02 18:40:44 +01:00
math
This is a Math block. Here, rows are evaluated as math expressions.
radius = 5
area = radius^2 * PI
2023-03-02 18:40:44 +01:00
sqrt(9)
It also supports some basic unit conversions, including currencies:
2023-03-02 18:40:44 +01:00
13 inches in cm
time = 3900 seconds to minutes
time * 2
1 EUR in USD
markdown
In Markdown blocks, lists with [x] and [ ] are rendered as checkboxes:
- [x] Download Heynote
- [ ] Try out Heynote
2023-01-19 00:20:50 +01:00
text-a
`
2023-03-03 13:28:36 +01:00
export const initialDevContent = initialContent + `
python-a
2022-12-28 12:49:26 +01:00
# hmm
def my_func():
print("hejsan")
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
javascript-a
2022-12-28 12:49:26 +01:00
import {basicSetup} from "codemirror"
import {EditorView, keymap} from "@codemirror/view"
import {javascript} from "@codemirror/lang-javascript"
import {indentWithTab, insertTab, indentLess, indentMore} from "@codemirror/commands"
import {nord} from "./nord.mjs"
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
2022-12-28 12:49:26 +01:00
let editor = new EditorView({
//extensions: [basicSetup, javascript()],
extensions: [
basicSetup,
javascript(),
//keymap.of([indentWithTab]),
keymap.of([
{
key: 'Tab',
preventDefault: true,
//run: insertTab,
run: indentMore,
},
{
key: 'Shift-Tab',
preventDefault: true,
run: indentLess,
},
]),
nord,
],
parent: document.getElementById("editor"),
})
json
{
"name": "heynote-codemirror",
"type": "module",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@codemirror/commands": "^6.1.2",
"@codemirror/lang-javascript": "^6.1.2",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-python": "^6.1.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"codemirror": "^6.0.1",
"i": "^0.3.7",
"npm": "^9.2.0",
"rollup": "^3.8.1",
"rollup-plugin-typescript2": "^0.34.1",
"typescript": "^4.9.4"
}
}
html
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
<script>
console.log("hej")
</script>
</body>
</html>
sql
SELECT * FROM table WHERE id = 1;
2022-12-28 15:27:03 +01:00
text
Shopping list:
2022-12-28 12:49:26 +01:00
2022-12-28 15:27:03 +01:00
- Milk
- Eggs
- Bread
- Cheese`