Skip to content

Commit

Permalink
feat(fireShortcutKey): 正则调整
Browse files Browse the repository at this point in the history
  • Loading branch information
ufec committed Sep 4, 2023
1 parent 163f725 commit 179d806
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Cherry.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ export default class Cherry extends CherryStatic {
const lineContent = this.editor.editor.getLine(cursor.line);
// shift + tab 已经被绑定为缩进,所以这里不做处理
if (!evt.shiftKey && evt.key === 'Tab' && LIST_CONTENT.test(lineContent)) {
evt.preventDefault();
// 每按一次Tab,如果当前光标在行首或者行尾,就在行首加一个\t
if (cursor.ch === 0 || cursor.ch === lineContent.length) {
if (cursor.ch === 0 || cursor.ch === lineContent.length || cursor.ch === lineContent.length + 1) {
evt.preventDefault();
this.editor.editor.setSelection({ line: cursor.line, ch: 0 }, { line: cursor.line, ch: lineContent.length });
this.editor.editor.replaceSelection(`\t${lineContent}`, 'around');
const newCursor = this.editor.editor.getCursor();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const URL_NO_SLASH = new RegExp(`^${URL_INLINE_NO_SLASH.source}$`);
export const URL = new RegExp(`^${URL_INLINE.source}$`);

// 正则结果[全部, 判定符之前的空格或者tab, 判定符, checkbox内容(没有就是undefined), 列表内容]
export const LIST_CONTENT = /([ \t]*)([*+-][ ](\[[ x]\])?|[a-z0-9I一二三四五六七八九十零]+\.)([^\r\n]+)/;
export const LIST_CONTENT = /([ \t]*)([*+-][ ](\[[ x]\])?|[a-z0-9I一二三四五六七八九十零]+\.)([^\r\n]*)/;

export function getTableRule(merge = false) {
// ^(\|[^\n]+\|\r?\n)((?:\|:?[-]+:?)+\|)(\n(?:\|[^\n]+\|\r?\n?)*)?$
Expand Down

0 comments on commit 179d806

Please sign in to comment.