Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM] [Case] Insert timeline into case textarea #59586

Merged
merged 22 commits into from
Mar 10, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PR changes
  • Loading branch information
stephmilovic committed Mar 10, 2020
commit 24c67f13c5a35c0391438163e7aad04e9cbcdf4f
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import {
EuiTabbedContent,
EuiTextArea,
} from '@elastic/eui';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import React, { useMemo, useCallback, ChangeEvent } from 'react';
import styled, { css } from 'styled-components';

import { Markdown } from '../markdown';
@@ -71,7 +71,7 @@ export interface CursorPosition {
export const MarkdownEditor = React.memo<{
bottomRightContent?: React.ReactNode;
topRightContent?: React.ReactNode;
initialContent: string;
content: string;
isDisabled?: boolean;
onChange: (description: string) => void;
onCursorPositionUpdate?: (cursorPosition: CursorPosition) => void;
@@ -80,16 +80,18 @@ export const MarkdownEditor = React.memo<{
({
bottomRightContent,
topRightContent,
initialContent,
content,
isDisabled = false,
onChange,
placeholder,
onCursorPositionUpdate,
}) => {
const [content, setContent] = useState(initialContent);
useEffect(() => {
onChange(content);
}, [content]);
const handleOnChange = useCallback(
(evt: ChangeEvent<HTMLTextAreaElement>) => {
onChange(evt.target.value);
},
[onChange]
);

const setCursorPosition = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
if (onCursorPositionUpdate) {
@@ -101,22 +103,14 @@ export const MarkdownEditor = React.memo<{
return false;
};

const handleSetContent = useCallback(e => {
handleSetContent(e.target.value);
}, []);

useEffect(() => {
setContent(initialContent);
}, [initialContent]);

const tabs = useMemo(
() => [
{
id: 'comment',
name: i18n.MARKDOWN,
content: (
<TextArea
onChange={handleSetContent}
onChange={handleOnChange}
onBlur={setCursorPosition}
aria-label={`markdown-editor-comment`}
fullWidth={true}