Remove command for manually triggering language auto detection

This commit is contained in:
Jonatan Heyman 2023-01-16 12:57:26 +01:00
parent 15b86abf0f
commit f2bff13c6e
2 changed files with 1 additions and 23 deletions

View File

@ -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)
}
}

View File

@ -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,
},
]) ])