Skip to content

Commit 21b0735

Browse files
committed
fix slab#1723
1 parent be41c2b commit 21b0735

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/keyboard.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ Keyboard.DEFAULTS = {
253253
prefix: /^\s*?(1\.|-|\[ ?\]|\[x\])$/,
254254
handler: function(range, context) {
255255
let length = context.prefix.length;
256+
let [line, offset] = this.quill.getLine(range.index);
257+
if (offset > length) return true;
256258
let value;
257259
switch (context.prefix.trim()) {
258260
case '[]': case '[ ]':
@@ -269,10 +271,9 @@ Keyboard.DEFAULTS = {
269271
}
270272
this.quill.insertText(range.index, ' ', Quill.sources.USER);
271273
this.quill.history.cutoff();
272-
let [line, offset] = this.quill.getLine(range.index + 1);
273-
let delta = new Delta().retain(range.index + 1 - offset)
274+
let delta = new Delta().retain(range.index - offset)
274275
.delete(length + 1)
275-
.retain(line.length() - 1 - offset)
276+
.retain(line.length() - 2 - offset)
276277
.retain(1, { list: value });
277278
this.quill.updateContents(delta, Quill.sources.USER);
278279
this.quill.history.cutoff();

0 commit comments

Comments
 (0)