MM-53639 - fix firefox not detecting non-formatted paste action on ctrl|cmd+shift+v (#24384)
* MM-53639 - fix firefox not detecting non-formatted paste action on ctrl+shift+v * cover ctrl + cmd keypress * port the changes to advance create comment component --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3828446abd
Коммит
7a0c7a5f3f
@@ -227,6 +227,8 @@ class AdvancedCreateComment extends React.PureComponent<Props, State> {
|
|||||||
|
|
||||||
private isDraftSubmitting = false;
|
private isDraftSubmitting = false;
|
||||||
private isDraftEdited = false;
|
private isDraftEdited = false;
|
||||||
|
private isNonFormattedPaste = false;
|
||||||
|
private timeoutId: number | null = null;
|
||||||
|
|
||||||
private readonly textboxRef: React.RefObject<TextboxClass>;
|
private readonly textboxRef: React.RefObject<TextboxClass>;
|
||||||
private readonly fileUploadRef: React.RefObject<FileUploadClass>;
|
private readonly fileUploadRef: React.RefObject<FileUploadClass>;
|
||||||
@@ -306,6 +308,9 @@ class AdvancedCreateComment extends React.PureComponent<Props, State> {
|
|||||||
document.removeEventListener('keydown', this.focusTextboxIfNecessary);
|
document.removeEventListener('keydown', this.focusTextboxIfNecessary);
|
||||||
window.removeEventListener('beforeunload', this.saveDraftWithShow);
|
window.removeEventListener('beforeunload', this.saveDraftWithShow);
|
||||||
this.saveDraftOnUnmount();
|
this.saveDraftOnUnmount();
|
||||||
|
if (this.timeoutId !== null) {
|
||||||
|
clearTimeout(this.timeoutId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps: Props, prevState: State) {
|
componentDidUpdate(prevProps: Props, prevState: State) {
|
||||||
@@ -438,7 +443,7 @@ class AdvancedCreateComment extends React.PureComponent<Props, State> {
|
|||||||
|
|
||||||
const hasSelection = !isNil(selectionStart) && !isNil(selectionEnd) && selectionStart < selectionEnd;
|
const hasSelection = !isNil(selectionStart) && !isNil(selectionEnd) && selectionStart < selectionEnd;
|
||||||
const hasTextUrl = isTextUrl(clipboardData);
|
const hasTextUrl = isTextUrl(clipboardData);
|
||||||
const hasHTMLLinks = hasHtmlLink(clipboardData);
|
const hasHTMLLinks = !this.isNonFormattedPaste && hasHtmlLink(clipboardData);
|
||||||
const htmlTable = getHtmlTable(clipboardData);
|
const htmlTable = getHtmlTable(clipboardData);
|
||||||
const shouldApplyLinkMarkdown = hasSelection && hasTextUrl;
|
const shouldApplyLinkMarkdown = hasSelection && hasTextUrl;
|
||||||
const shouldApplyGithubCodeBlock = htmlTable && isGitHubCodeBlock(htmlTable.className);
|
const shouldApplyGithubCodeBlock = htmlTable && isGitHubCodeBlock(htmlTable.className);
|
||||||
@@ -838,6 +843,16 @@ class AdvancedCreateComment extends React.PureComponent<Props, State> {
|
|||||||
const ctrlAltCombo = Keyboard.cmdOrCtrlPressed(e, true) && e.altKey;
|
const ctrlAltCombo = Keyboard.cmdOrCtrlPressed(e, true) && e.altKey;
|
||||||
const shiftAltCombo = !Keyboard.cmdOrCtrlPressed(e) && e.shiftKey && e.altKey;
|
const shiftAltCombo = !Keyboard.cmdOrCtrlPressed(e) && e.shiftKey && e.altKey;
|
||||||
|
|
||||||
|
// fix for FF not capturing the paste without formatting event when using ctrl|cmd + shift + v
|
||||||
|
if (e.key === KeyCodes.V[0] && ctrlOrMetaKeyPressed) {
|
||||||
|
if (e.shiftKey) {
|
||||||
|
this.isNonFormattedPaste = true;
|
||||||
|
this.timeoutId = window.setTimeout(() => {
|
||||||
|
this.isNonFormattedPaste = false;
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// listen for line break key combo and insert new line character
|
// listen for line break key combo and insert new line character
|
||||||
if (Utils.isUnhandledLineBreakKeyCombo(e)) {
|
if (Utils.isUnhandledLineBreakKeyCombo(e)) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
@@ -266,6 +266,8 @@ class AdvancedCreatePost extends React.PureComponent<Props, State> {
|
|||||||
private lastOrientation?: string;
|
private lastOrientation?: string;
|
||||||
private saveDraftFrame?: number | null;
|
private saveDraftFrame?: number | null;
|
||||||
private isDraftSubmitting = false;
|
private isDraftSubmitting = false;
|
||||||
|
private isNonFormattedPaste = false;
|
||||||
|
private timeoutId: number | null = null;
|
||||||
|
|
||||||
private topDiv: React.RefObject<HTMLFormElement>;
|
private topDiv: React.RefObject<HTMLFormElement>;
|
||||||
private textboxRef: React.RefObject<TextboxClass>;
|
private textboxRef: React.RefObject<TextboxClass>;
|
||||||
@@ -355,6 +357,9 @@ class AdvancedCreatePost extends React.PureComponent<Props, State> {
|
|||||||
window.removeEventListener('beforeunload', this.unloadHandler);
|
window.removeEventListener('beforeunload', this.unloadHandler);
|
||||||
this.removeOrientationListeners();
|
this.removeOrientationListeners();
|
||||||
this.saveDraftWithShow();
|
this.saveDraftWithShow();
|
||||||
|
if (this.timeoutId !== null) {
|
||||||
|
clearTimeout(this.timeoutId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getChannelMemberCountsByGroup = () => {
|
getChannelMemberCountsByGroup = () => {
|
||||||
@@ -929,7 +934,7 @@ class AdvancedCreatePost extends React.PureComponent<Props, State> {
|
|||||||
|
|
||||||
const hasSelection = !isNil(selectionStart) && !isNil(selectionEnd) && selectionStart < selectionEnd;
|
const hasSelection = !isNil(selectionStart) && !isNil(selectionEnd) && selectionStart < selectionEnd;
|
||||||
const hasTextUrl = isTextUrl(clipboardData);
|
const hasTextUrl = isTextUrl(clipboardData);
|
||||||
const hasHTMLLinks = hasHtmlLink(clipboardData);
|
const hasHTMLLinks = !this.isNonFormattedPaste && hasHtmlLink(clipboardData);
|
||||||
const htmlTable = getHtmlTable(clipboardData);
|
const htmlTable = getHtmlTable(clipboardData);
|
||||||
const shouldApplyLinkMarkdown = hasSelection && hasTextUrl;
|
const shouldApplyLinkMarkdown = hasSelection && hasTextUrl;
|
||||||
const shouldApplyGithubCodeBlock = htmlTable && isGitHubCodeBlock(htmlTable.className);
|
const shouldApplyGithubCodeBlock = htmlTable && isGitHubCodeBlock(htmlTable.className);
|
||||||
@@ -1134,8 +1139,18 @@ class AdvancedCreatePost extends React.PureComponent<Props, State> {
|
|||||||
handleKeyDown = (e: React.KeyboardEvent<TextboxElement>) => {
|
handleKeyDown = (e: React.KeyboardEvent<TextboxElement>) => {
|
||||||
const messageIsEmpty = this.state.message.length === 0;
|
const messageIsEmpty = this.state.message.length === 0;
|
||||||
const draftMessageIsEmpty = this.props.draft.message.length === 0;
|
const draftMessageIsEmpty = this.props.draft.message.length === 0;
|
||||||
|
|
||||||
const ctrlOrMetaKeyPressed = e.ctrlKey || e.metaKey;
|
const ctrlOrMetaKeyPressed = e.ctrlKey || e.metaKey;
|
||||||
|
|
||||||
|
// fix for FF not capturing the paste without formatting event when using ctrl|cmd + shift + v
|
||||||
|
if (e.key === KeyCodes.V[0] && ctrlOrMetaKeyPressed) {
|
||||||
|
if (e.shiftKey) {
|
||||||
|
this.isNonFormattedPaste = true;
|
||||||
|
this.timeoutId = window.setTimeout(() => {
|
||||||
|
this.isNonFormattedPaste = false;
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ctrlEnterKeyCombo = (this.props.ctrlSend || this.props.codeBlockOnCtrlEnter) &&
|
const ctrlEnterKeyCombo = (this.props.ctrlSend || this.props.codeBlockOnCtrlEnter) &&
|
||||||
Keyboard.isKeyPressed(e, KeyCodes.ENTER) &&
|
Keyboard.isKeyPressed(e, KeyCodes.ENTER) &&
|
||||||
ctrlOrMetaKeyPressed;
|
ctrlOrMetaKeyPressed;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user