Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.props.suggestionActions.setActive(newItemID, newIndex);
event.preventDefault();
event.stopPropagation();
break;
}
case Keyboard.match(event, Keyboard.keys.ENTER): {
if (suggestions.data.length > 0 && !currentItemIsLoader) {
this.confirmActiveMention();
event.preventDefault();
event.stopPropagation();
} else {
this.cancelActiveMention();
}
break;
}
case Keyboard.match(event, Keyboard.keys.TAB): {
if (!currentItemIsLoader) {
this.confirmActiveMention();
event.preventDefault();
event.stopPropagation();
}
break;
}
case Keyboard.match(event, Keyboard.keys.ESCAPE): {
this.cancelActiveMention();
event.preventDefault();
event.stopPropagation();
break;
}
}
}
};
private addBlockArrowKeyHandlers() {
const commonCriteria = {
collapsed: true,
format: KeyboardBindings.MULTI_LINE_BLOTS,
};
this.bindings["Block Up"] = {
...commonCriteria,
key: KeyboardModule.keys.UP,
handler: this.insertNewlineBeforeRange,
};
this.bindings["Block Left"] = {
...commonCriteria,
key: KeyboardModule.keys.LEFT,
handler: this.insertNewlineBeforeRange,
};
this.bindings["Block Down"] = {
...commonCriteria,
key: KeyboardModule.keys.DOWN,
handler: this.insertNewlineAfterRange,
};
this.bindings["Block Right"] = {
private isKeyCodeArrowKey(keyCode: number) {
const { UP, DOWN, LEFT, RIGHT } = KeyboardModule.keys;
return [UP, DOWN, LEFT, RIGHT].includes(keyCode as any);
}
public escapeMobileFullScreen = (event: KeyboardEvent) => {
const position = window.getComputedStyle(this.editorRoot).getPropertyValue("position");
const editorIsFullscreen = this.editorRoot.classList.contains("isFocused") && position === "fixed";
if (editorIsFullscreen && KeyboardModule.match(event, { key: KeyboardModule.keys.ESCAPE, shiftKey: false })) {
this.quill.root.focus();
const tabHandler = new TabHandler(this.formWrapper);
const nextEl = tabHandler.getNext();
if (nextEl) {
nextEl.focus();
this.editorRoot.classList.toggle("isFocused", false);
}
}
};
this.bindings["Block Up"] = {
...commonCriteria,
key: KeyboardModule.keys.UP,
handler: this.insertNewlineBeforeRange,
};
this.bindings["Block Left"] = {
...commonCriteria,
key: KeyboardModule.keys.LEFT,
handler: this.insertNewlineBeforeRange,
};
this.bindings["Block Down"] = {
...commonCriteria,
key: KeyboardModule.keys.DOWN,
handler: this.insertNewlineAfterRange,
};
this.bindings["Block Right"] = {
...commonCriteria,
key: KeyboardModule.keys.RIGHT,
handler: this.insertNewlineAfterRange,
};
}
}