0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-01 06:59:52 +00:00

Got md shortcuts working, marked actions for update

This commit is contained in:
Dan Brown 2023-04-11 11:48:58 +01:00
parent 572037ef1f
commit da3e4f5f75
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
5 changed files with 84 additions and 48 deletions
resources/js/code

View file

@ -1,4 +1,4 @@
import {EditorView} from "@codemirror/view"
import {EditorView, keymap} from "@codemirror/view"
import Clipboard from "clipboard/dist/clipboard.min";
// Modes
@ -182,9 +182,10 @@ export function updateLayout(cmInstance) {
* @param {HTMLElement} elem
* @param {function} onChange
* @param {object} domEventHandlers
* @param {Array} keyBindings
* @returns {*}
*/
export function markdownEditor(elem, onChange, domEventHandlers) {
export function markdownEditor(elem, onChange, domEventHandlers, keyBindings) {
const content = elem.textContent;
// TODO - Change to pass something else that's useful, probably extension array?
@ -199,20 +200,11 @@ export function markdownEditor(elem, onChange, domEventHandlers) {
onChange(v);
}),
EditorView.domEventHandlers(domEventHandlers),
keymap.of(keyBindings),
],
});
elem.style.display = 'none';
return ev;
}
/**
* Get the 'meta' key dependent on the user's system.
* @returns {string}
*/
export function getMetaKey() {
// TODO - Redo, Is needed? No CodeMirror instance to use.
const mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
return mac ? "Cmd" : "Ctrl";
}