mirror of
https://github.com/heyman/heynote.git
synced 2025-06-26 20:41:44 +02:00
Change note separator to include a new line both at the start and end. This fixes a bug with hitting End/Home keys putting the cursor within the atomic block around the separator.
This commit is contained in:
parent
fc4c7c8145
commit
f1038ce696
@ -4,7 +4,8 @@ oj∞∞∞prutt
|
|||||||
hej∞∞∞python
|
hej∞∞∞python
|
||||||
f = lambda: 2 +1`;*/
|
f = lambda: 2 +1`;*/
|
||||||
|
|
||||||
export default `∞∞∞python
|
export default `
|
||||||
|
∞∞∞python
|
||||||
# hmm
|
# hmm
|
||||||
def my_func():
|
def my_func():
|
||||||
print("hejsan")
|
print("hejsan")
|
||||||
@ -14,7 +15,8 @@ import {basicSetup} from "codemirror"
|
|||||||
import {EditorView, keymap} from "@codemirror/view"
|
import {EditorView, keymap} from "@codemirror/view"
|
||||||
import {javascript} from "@codemirror/lang-javascript"
|
import {javascript} from "@codemirror/lang-javascript"
|
||||||
import {indentWithTab, insertTab, indentLess, indentMore} from "@codemirror/commands"
|
import {indentWithTab, insertTab, indentLess, indentMore} from "@codemirror/commands"
|
||||||
import {nord} from "./nord.mjs"∞∞∞javascript
|
import {nord} from "./nord.mjs"
|
||||||
|
∞∞∞javascript
|
||||||
let editor = new EditorView({
|
let editor = new EditorView({
|
||||||
//extensions: [basicSetup, javascript()],
|
//extensions: [basicSetup, javascript()],
|
||||||
extensions: [
|
extensions: [
|
||||||
|
@ -13,10 +13,10 @@ export const noteContent = new ExternalTokenizer((input) => {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
let potentialLang = "";
|
let potentialLang = "";
|
||||||
for (let i=0; i<15; i++) {
|
for (let i=0; i<16; i++) {
|
||||||
potentialLang += String.fromCharCode(input.peek(i));
|
potentialLang += String.fromCharCode(input.peek(i));
|
||||||
}
|
}
|
||||||
if (potentialLang.match(/^∞∞∞(text|javascript|json|python|html|sql|markdown|java|lezer|php)\n/g)) {
|
if (potentialLang.match(/^\n∞∞∞(text|javascript|json|python|html|sql|markdown|java|lezer|php)\n/g)) {
|
||||||
input.acceptToken(NoteContent);
|
input.acceptToken(NoteContent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ Note {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NoteDelimiter {
|
NoteDelimiter {
|
||||||
noteDelimiterMark NoteLanguage noteDelimiterEnter
|
noteDelimiterEnter noteDelimiterMark NoteLanguage noteDelimiterEnter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,14 +3,14 @@ import {LRParser} from "@lezer/lr"
|
|||||||
import {noteContent} from "./external-tokens.js"
|
import {noteContent} from "./external-tokens.js"
|
||||||
export const parser = LRParser.deserialize({
|
export const parser = LRParser.deserialize({
|
||||||
version: 14,
|
version: 14,
|
||||||
states: "!WQQOPOOOVOPO'#C`O[OQO'#C_OOOO'#Cb'#CbQQOPOOOaOPO,58zOOOO,58y,58yOOOO-E6`-E6`OOOQ1G.f1G.f",
|
states: "!^QQOPOOOVOPO'#C`O[OQO'#C_OOOO'#Cb'#CbQQOPOOOaOPO,58zOOOO,58y,58yOOOO-E6`-E6`OfOPO1G.fOOOQ7+$Q7+$Q",
|
||||||
stateData: "f~OWPO~OTTO~OPUO~OXWO~O",
|
stateData: "k~OWPO~OXTO~OPUO~OTWO~OWXO~O",
|
||||||
goto: "fVPPPW[P`TROSTQOSQSORVS",
|
goto: "fVPPPW[P`TROSTQOSQSORVS",
|
||||||
nodeNames: "⚠ NoteContent Document Note NoteDelimiter NoteLanguage",
|
nodeNames: "⚠ NoteContent Document Note NoteDelimiter NoteLanguage",
|
||||||
maxTerm: 9,
|
maxTerm: 9,
|
||||||
skippedNodes: [0],
|
skippedNodes: [0],
|
||||||
repeatNodeCount: 1,
|
repeatNodeCount: 1,
|
||||||
tokenData: "&e~RXYZn#[#]s#^#_![#`#a#u#a#b$_#d#e%T#g#h%p#h#i%v%&x%&y&S~sOX~~vP#h#iy~|P#a#b!P~!SP#`#a!V~![OT~~!_Q#T#U!e#g#h#i~!hP#j#k!k~!nP#T#U!q~!vPT~#g#h!y~!|P#V#W#P~#SP#f#g#V~#YP#]#^#]~#`P#d#e#c~#fP#h#i!V~#lP#c#d#o~#rP#b#c!V~#xP#X#Y#{~$OP#n#o$R~$UP#X#Y$X~$[P#f#g!V~$bP#T#U$e~$hP#f#g$k~$nP#_#`$q~$tP#W#X$w~$zP#c#d$}~%QP#k#l#o~%WQ#[#]%^#m#n%d~%aP#d#e!V~%gP#h#i%j~%mP#[#]#i~%sP#e#f!P~%yP#X#Y%|~&PP#l#m#c~&VP%&x%&y&Y~&]P%&x%&y&`~&eOW~",
|
tokenData: "&e~RXYZn#[#]s#^#_![#`#a#u#a#b$_#d#e%T#g#h%p#h#i%v%&x%&y&S~sOW~~vP#h#iy~|P#a#b!P~!SP#`#a!V~![OT~~!_Q#T#U!e#g#h#i~!hP#j#k!k~!nP#T#U!q~!vPT~#g#h!y~!|P#V#W#P~#SP#f#g#V~#YP#]#^#]~#`P#d#e#c~#fP#h#i!V~#lP#c#d#o~#rP#b#c!V~#xP#X#Y#{~$OP#n#o$R~$UP#X#Y$X~$[P#f#g!V~$bP#T#U$e~$hP#f#g$k~$nP#_#`$q~$tP#W#X$w~$zP#c#d$}~%QP#k#l#o~%WQ#[#]%^#m#n%d~%aP#d#e!V~%gP#h#i%j~%mP#[#]#i~%sP#e#f!P~%yP#X#Y%|~&PP#l#m#c~&VP%&x%&y&Y~&]P%&x%&y&`~&eOX~",
|
||||||
tokenizers: [0, noteContent],
|
tokenizers: [0, noteContent],
|
||||||
topRules: {"Document":[0,2]},
|
topRules: {"Document":[0,2]},
|
||||||
tokenPrec: 0
|
tokenPrec: 0
|
||||||
|
@ -43,7 +43,6 @@ class FirstNoteBlockStart extends WidgetType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const noteBlockWidget = () => {
|
const noteBlockWidget = () => {
|
||||||
const decorate = (state) => {
|
const decorate = (state) => {
|
||||||
const widgets = [];
|
const widgets = [];
|
||||||
@ -54,11 +53,11 @@ const noteBlockWidget = () => {
|
|||||||
//console.log("found!", type.name, type.from, type.to)
|
//console.log("found!", type.name, type.from, type.to)
|
||||||
let deco = Decoration.replace({
|
let deco = Decoration.replace({
|
||||||
widget: type.from === 0 ? new FirstNoteBlockStart() : new NoteBlockStart(),
|
widget: type.from === 0 ? new FirstNoteBlockStart() : new NoteBlockStart(),
|
||||||
inclusive: false,
|
inclusive: true,
|
||||||
block: type.from === 0 ? false : true,
|
block: type.from === 0 ? false : true,
|
||||||
side: 0,
|
side: 0,
|
||||||
});
|
});
|
||||||
widgets.push(deco.range(type.from, type.from === 0 ? type.to :type.to-1));
|
widgets.push(deco.range(type.from === 0 ? type.from : type.from+1, type.from === 0 ? type.to : type.to-1));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mode: IterMode.IgnoreMounts,
|
mode: IterMode.IgnoreMounts,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user