feat(): disable shift-keydown

This commit is contained in:
yanmao 2021-11-17 15:46:17 +08:00
parent f869c63f26
commit 38de981c70
2 changed files with 19 additions and 11 deletions

View File

@ -50,7 +50,7 @@ import Parser from '../parser';
import Language from '../language'; import Language from '../language';
import Mark from '../mark'; import Mark from '../mark';
import List from '../list'; import List from '../list';
import { EditorInterface, TypingInterface } from '../types'; import { TypingInterface } from '../types';
import Typing from '../typing'; import Typing from '../typing';
import Container from './container'; import Container from './container';
import Inline from '../inline'; import Inline from '../inline';

View File

@ -34,18 +34,26 @@ class ShitEnter implements TypingHandleInterface {
event.preventDefault(); event.preventDefault();
change.cacheRangeBeforeCommand(); change.cacheRangeBeforeCommand();
const range = change.range.get(); const range = change.range.get();
const br = $('<br />'); if (range.startNode.closest('li').length === 0) {
inline.insert(br, range); this.engine.typing
if (block.isLastOffset(range, 'end')) { .getHandleListener('enter', 'keydown')
if ( ?.trigger(event);
(!br.next() || br.next()?.name !== 'br') && return;
(!br.prev() || br.prev()?.name !== 'br') } else {
) { const br = $('<br />');
const cloneBr = br.clone(); inline.insert(br, range);
br.after(cloneBr); if (block.isLastOffset(range, 'end')) {
range.select(cloneBr).collapse(false); if (
(!br.next() || br.next()?.name !== 'br') &&
(!br.prev() || br.prev()?.name !== 'br')
) {
const cloneBr = br.clone();
br.after(cloneBr);
range.select(cloneBr).collapse(false);
}
} }
} }
for (let i = 0; i < this.listeners.length; i++) { for (let i = 0; i < this.listeners.length; i++) {
const listener = this.listeners[i]; const listener = this.listeners[i];
const result = listener(event); const result = listener(event);