Skip to content

Commit

Permalink
Improve Tab handling in code block
Browse files Browse the repository at this point in the history
  • Loading branch information
luin authored and jhchen committed Jun 10, 2022
1 parent 2e138a0 commit fdaa793
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,17 @@ function makeCodeBlockHandler(indent) {
key: 'Tab',
shiftKey: !indent,
format: { 'code-block': true },
handler(range) {
handler(range, { event }) {
const CodeBlock = this.quill.scroll.query('code-block');
if (range.length === 0 && !event.shiftKey) {
this.quill.insertText(range.index, CodeBlock.TAB, Quill.sources.USER);
this.quill.setSelection(
range.index + CodeBlock.TAB.length,
Quill.sources.SILENT,
);
return;
}

const lines =
range.length === 0
? this.quill.getLines(range.index, 1)
Expand Down

0 comments on commit fdaa793

Please sign in to comment.