Send shortcut
This commit is contained in:
parent
469b389518
commit
aaff5e9948
@ -11,7 +11,7 @@ import apiManager from "../../lib/mtproto/mtprotoworker";
|
||||
//import Recorder from '../opus-recorder/dist/recorder.min';
|
||||
import opusDecodeController from "../../lib/opusDecodeController";
|
||||
import RichTextProcessor from "../../lib/richtextprocessor";
|
||||
import { attachClickEvent, blurActiveElement, cancelEvent, cancelSelection, findUpClassName, getRichValue, getSelectedNodes, isInputEmpty, markdownTags, MarkdownType, placeCaretAtEnd } from "../../helpers/dom";
|
||||
import { attachClickEvent, blurActiveElement, cancelEvent, cancelSelection, findUpClassName, getRichValue, getSelectedNodes, isInputEmpty, markdownTags, MarkdownType, placeCaretAtEnd, isSendShortcutPressed } from "../../helpers/dom";
|
||||
import { ButtonMenuItemOptions } from '../buttonMenu';
|
||||
import emoticonsDropdown from "../emoticonsDropdown";
|
||||
import PopupCreatePoll from "../popups/createPoll";
|
||||
@ -32,6 +32,7 @@ import PopupSchedule from '../popups/schedule';
|
||||
import SendMenu from './sendContextMenu';
|
||||
import rootScope from '../../lib/rootScope';
|
||||
import PopupPinMessage from '../popups/unpinMessage';
|
||||
import { isApple } from '../../helpers/userAgent';
|
||||
|
||||
const RECORD_MIN_TIME = 500;
|
||||
const POSTING_MEDIA_NOT_ALLOWED = 'Posting media content isn\'t allowed in this group.';
|
||||
@ -560,17 +561,7 @@ export default class ChatInput {
|
||||
|
||||
private attachMessageInputListeners() {
|
||||
this.listenerSetter.add(this.messageInput, 'keydown', (e: KeyboardEvent) => {
|
||||
if(e.key == 'Enter' && !isTouchSupported) {
|
||||
/* if(e.ctrlKey || e.metaKey) {
|
||||
this.messageInput.innerHTML += '<br>';
|
||||
placeCaretAtEnd(this.message)
|
||||
return;
|
||||
} */
|
||||
|
||||
if(e.shiftKey || e.ctrlKey || e.metaKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(isSendShortcutPressed(e)) {
|
||||
this.sendMessage();
|
||||
} else if(e.ctrlKey || e.metaKey) {
|
||||
this.handleMarkdownShortcut(e);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getRichValue } from "../helpers/dom";
|
||||
import { getRichValue, isInputEmpty } from "../helpers/dom";
|
||||
import { checkRTL } from "../helpers/string";
|
||||
import RichTextProcessor from "../lib/richtextprocessor";
|
||||
|
||||
@ -95,7 +95,7 @@ class InputField {
|
||||
|
||||
// * because if delete all characters there will br left
|
||||
input.addEventListener('input', () => {
|
||||
if(!this.value.trim()) {
|
||||
if(isInputEmpty(input)) {
|
||||
input.innerHTML = '';
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type Chat from "../chat/chat";
|
||||
import { isTouchSupported } from "../../helpers/touchSupport";
|
||||
import { calcImageInBox, placeCaretAtEnd } from "../../helpers/dom";
|
||||
import { calcImageInBox, placeCaretAtEnd, isSendShortcutPressed } from "../../helpers/dom";
|
||||
import InputField from "../inputField";
|
||||
import PopupElement from ".";
|
||||
import Scrollable from "../scrollable";
|
||||
@ -118,7 +118,7 @@ export default class PopupNewMedia extends PopupElement {
|
||||
placeCaretAtEnd(this.input);
|
||||
}
|
||||
|
||||
if(e.key == 'Enter' && !isTouchSupported) {
|
||||
if(isSendShortcutPressed(e)) {
|
||||
this.btnConfirm.click();
|
||||
}
|
||||
};
|
||||
|
@ -7,6 +7,7 @@ import CheckboxField from "../../checkbox";
|
||||
import RadioField from "../../radioField";
|
||||
import appStateManager from "../../../lib/appManagers/appStateManager";
|
||||
import rootScope from "../../../lib/rootScope";
|
||||
import { isApple } from "../../../helpers/userAgent";
|
||||
|
||||
export class RangeSettingSelector {
|
||||
public container: HTMLDivElement;
|
||||
@ -164,7 +165,7 @@ export default class AppGeneralSettingsTab extends SliderSuperTab {
|
||||
});
|
||||
|
||||
const ctrlEnterRow = new Row({
|
||||
radioField: RadioField('Send by Ctrl + Enter', 'send-shortcut', 'ctrlEnter', 'settings.sendShortcut'),
|
||||
radioField: RadioField(`Send by ${isApple ? '⌘' : 'Ctrl'} + Enter`, 'send-shortcut', 'ctrlEnter', 'settings.sendShortcut'),
|
||||
subtitle: 'New line by Enter',
|
||||
});
|
||||
|
||||
|
@ -3,7 +3,8 @@ import { MOUNT_CLASS_TO } from "../lib/mtproto/mtproto_config";
|
||||
import RichTextProcessor from "../lib/richtextprocessor";
|
||||
import ListenerSetter from "./listenerSetter";
|
||||
import { isTouchSupported } from "./touchSupport";
|
||||
import { isSafari } from "./userAgent";
|
||||
import { isSafari, isApple } from "./userAgent";
|
||||
import rootScope from "../lib/rootScope";
|
||||
|
||||
/* export function isInDOM(element: Element, parentNode?: HTMLElement): boolean {
|
||||
if(!element) {
|
||||
@ -682,3 +683,32 @@ export function radiosHandleChange(inputs: HTMLInputElement[], onChange: (value:
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function isSendShortcutPressed(e: KeyboardEvent) {
|
||||
if(e.key == 'Enter' && !isTouchSupported) {
|
||||
/* if(e.ctrlKey || e.metaKey) {
|
||||
this.messageInput.innerHTML += '<br>';
|
||||
placeCaretAtEnd(this.message)
|
||||
return;
|
||||
} */
|
||||
|
||||
if(rootScope.settings.sendShortcut === 'enter') {
|
||||
if(e.shiftKey || e.ctrlKey || e.metaKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
const secondaryKey = isApple ? e.metaKey : e.ctrlKey;
|
||||
if(e.shiftKey || (isApple ? e.ctrlKey : e.metaKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(secondaryKey) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -147,9 +147,9 @@
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
html.is-safari & {
|
||||
/* html.is-safari & {
|
||||
margin-right: 4px;
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user