mirror of
https://github.com/heyman/heynote.git
synced 2024-12-23 15:18:48 +01:00
Remove command for manually triggering language auto detection
This commit is contained in:
parent
15b86abf0f
commit
f2bff13c6e
@ -72,20 +72,3 @@ export function changeLanguageTo(state, dispatch, block, language, auto) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function autoDetectLanguage({ state, dispatch }) {
|
|
||||||
console.log("state:", state)
|
|
||||||
const block = getActiveNoteBlock(state)
|
|
||||||
|
|
||||||
//console.log("content:", state.doc.sliceString(block.content.from, block.content.to))
|
|
||||||
//console.log("langs:", hljs.listLanguages())
|
|
||||||
|
|
||||||
let startTime = new Date();
|
|
||||||
const result = hljs.highlightAuto(state.doc.sliceString(block.content.from, block.content.to), ["json", "python", "javascript", "html", "sql", "java", "plaintext"])
|
|
||||||
console.log("took:", new Date() - startTime)
|
|
||||||
console.log("highlight.js result", result)
|
|
||||||
if (result.language) {
|
|
||||||
changeLanguageTo(state, dispatch, block, HIGHLIGHTJS_TO_TOKEN[result.language], true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { keymap } from "@codemirror/view"
|
import { keymap } from "@codemirror/view"
|
||||||
import { indentWithTab, insertTab, indentLess, indentMore } from "@codemirror/commands"
|
import { indentWithTab, insertTab, indentLess, indentMore } from "@codemirror/commands"
|
||||||
import { insertNewNote, moveLineUp, selectAll, autoDetectLanguage } from "./block/commands.js";
|
import { insertNewNote, moveLineUp, selectAll } from "./block/commands.js";
|
||||||
|
|
||||||
export const heynoteKeymap = keymap.of([
|
export const heynoteKeymap = keymap.of([
|
||||||
{
|
{
|
||||||
@ -29,9 +29,4 @@ export const heynoteKeymap = keymap.of([
|
|||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: moveLineUp,
|
run: moveLineUp,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: "Mod-Shift-a",
|
|
||||||
preventDefault: true,
|
|
||||||
run: autoDetectLanguage,
|
|
||||||
},
|
|
||||||
])
|
])
|
||||||
|
Loading…
Reference in New Issue
Block a user