diff --git a/resources/js/components/markdown-editor.js b/resources/js/components/markdown-editor.js index 21cf37bb4..3290fc300 100644 --- a/resources/js/components/markdown-editor.js +++ b/resources/js/components/markdown-editor.js @@ -211,13 +211,15 @@ class MarkdownEditor { extraKeys[`${metaKey}-3`] = cm => {replaceLineStart('####');}; extraKeys[`${metaKey}-4`] = cm => {replaceLineStart('#####');}; extraKeys[`${metaKey}-5`] = cm => {replaceLineStart('');}; - extraKeys[`${metaKey}-d`] = cm => {replaceLineStart('');}; + extraKeys[`${metaKey}-D`] = cm => {replaceLineStart('');}; extraKeys[`${metaKey}-6`] = cm => {replaceLineStart('>');}; - extraKeys[`${metaKey}-q`] = cm => {replaceLineStart('>');}; + extraKeys[`${metaKey}-Q`] = cm => {replaceLineStart('>');}; extraKeys[`${metaKey}-7`] = cm => {wrapSelection('\n```\n', '\n```');}; extraKeys[`${metaKey}-8`] = cm => {wrapSelection('`', '`');}; extraKeys[`Shift-${metaKey}-E`] = cm => {wrapSelection('`', '`');}; extraKeys[`${metaKey}-9`] = cm => {wrapSelection('
', '
');}; + extraKeys[`${metaKey}-P`] = cm => {replaceLineStart('-')} + extraKeys[`${metaKey}-O`] = cm => {replaceLineStartForOrderedList()} cm.setOption('extraKeys', extraKeys); // Update data on content change @@ -366,6 +368,19 @@ class MarkdownEditor { cm.setSelections([selections]); } + function replaceLineStartForOrderedList() { + const cursor = cm.getCursor(); + const prevLineContent = cm.getLine(cursor.line - 1) || ''; + const listMatch = prevLineContent.match(/^(\s*)(\d)([).])\s/) || []; + + const number = (Number(listMatch[2]) || 0) + 1; + const whiteSpace = listMatch[1] || ''; + const listMark = listMatch[3] || '.' + + const prefix = `${whiteSpace}${number}${listMark}`; + return replaceLineStart(prefix); + } + // Handle image upload and add image into markdown content function uploadImage(file) { if (file === null || file.type.indexOf('image') !== 0) return; diff --git a/resources/js/wysiwyg/config.js b/resources/js/wysiwyg/config.js index 148a4125b..52c52592c 100644 --- a/resources/js/wysiwyg/config.js +++ b/resources/js/wysiwyg/config.js @@ -166,13 +166,13 @@ function getSetupCallback(options) { return function(editor) { editor.on('ExecCommand change input NodeChange ObjectResized', editorChange); listenForCommonEvents(editor); - registerShortcuts(editor); listenForDragAndPaste(editor, options); editor.on('init', () => { editorChange(); scrollToQueryString(editor); window.editor = editor; + registerShortcuts(editor); }); editor.on('PreInit', () => { diff --git a/resources/js/wysiwyg/shortcuts.js b/resources/js/wysiwyg/shortcuts.js index 8b51437f1..b42851a46 100644 --- a/resources/js/wysiwyg/shortcuts.js +++ b/resources/js/wysiwyg/shortcuts.js @@ -16,6 +16,8 @@ export function register(editor) { editor.shortcuts.add('meta+e', '', ['codeeditor', false, 'pre']); editor.shortcuts.add('meta+8', '', ['FormatBlock', false, 'code']); editor.shortcuts.add('meta+shift+E', '', ['FormatBlock', false, 'code']); + editor.shortcuts.add('meta+o', '', 'InsertOrderedList'); + editor.shortcuts.add('meta+p', '', 'InsertUnorderedList'); // Save draft shortcut editor.shortcuts.add('meta+S', '', () => { diff --git a/resources/views/help/wysiwyg.blade.php b/resources/views/help/wysiwyg.blade.php index 30fdc18de..8fc091258 100644 --- a/resources/views/help/wysiwyg.blade.php +++ b/resources/views/help/wysiwyg.blade.php @@ -1,10 +1,10 @@ @extends('layouts.plain') -@section('document-class', setting()->getForCurrentUser('dark-mode-enabled') ? 'dark-mode ' : '') +@section('document-class', 'bg-white ' . (setting()->getForCurrentUser('dark-mode-enabled') ? 'dark-mode ' : '')) @section('content') -
{!! trans('editor.editor_tiny_license', ['tinyLink' => 'TinyMCE']) !!}
@@ -112,7 +112,21 @@
Cmd
+9
Ctrl
+O
Ctrl
+P
+ Cmd
+O
Cmd
+P
+