Skip to content

Commit

Permalink
Keep only react-diff-viewer-continued
Browse files Browse the repository at this point in the history
  • Loading branch information
banderror committed Nov 29, 2023
1 parent dc6c2cf commit 1190045
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 1,238 deletions.
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -910,9 +910,6 @@
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.2.2",
"del": "^6.1.0",
"diff-match-patch": "^1.0.5",
"diff-match-patch-line-and-word": "^0.1.3",
"diff2html": "^3.4.45",
"elastic-apm-node": "^4.1.0",
"email-addresses": "^5.0.0",
"execa": "^5.1.1",
Expand Down Expand Up @@ -1020,13 +1017,10 @@
"react": "^17.0.2",
"react-ace": "^7.0.5",
"react-color": "^2.13.8",
"react-diff-view": "^3.2.0",
"react-diff-viewer": "^3.1.1",
"react-diff-viewer-continued": "^3.3.1",
"react-dom": "^17.0.2",
"react-dropzone": "^4.2.9",
"react-fast-compare": "^2.0.4",
"react-gh-like-diff": "^2.0.2",
"react-grid-layout": "^1.3.4",
"react-hook-form": "^7.44.2",
"react-intl": "^2.8.0",
Expand Down Expand Up @@ -1084,7 +1078,6 @@
"type-detect": "^4.0.8",
"typescript-fsa": "^3.0.0",
"typescript-fsa-reducers": "^1.2.2",
"unidiff": "^1.0.4",
"unified": "9.2.2",
"use-resize-observer": "^9.1.0",
"usng.js": "^0.4.5",
Expand Down Expand Up @@ -1340,7 +1333,6 @@
"@types/dedent": "^0.7.0",
"@types/deep-freeze-strict": "^1.1.0",
"@types/delete-empty": "^2.0.0",
"@types/diff": "^5.0.8",
"@types/ejs": "^3.0.6",
"@types/enzyme": "^3.10.12",
"@types/eslint": "^8.44.2",
Expand Down
42 changes: 17 additions & 25 deletions packages/shared-ux/code_editor/code_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { useState, useRef, useCallback, useMemo, useEffect, KeyboardEvent } from 'react';
import { useResizeDetector } from 'react-resize-detector';
import ReactMonacoEditor, { MonacoDiffEditor } from 'react-monaco-editor';
import ReactMonacoEditor from 'react-monaco-editor';
import {
htmlIdGenerator,
EuiToolTip,
Expand Down Expand Up @@ -151,7 +151,6 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
}),
isCopyable = false,
allowFullScreen = false,
original,
}) => {
const { colorMode, euiTheme } = useEuiTheme();
const useDarkTheme = useDarkThemeProp ?? colorMode === 'DARK';
Expand All @@ -163,8 +162,6 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
typeof ReactMonacoEditor === 'function' && ReactMonacoEditor.name === 'JestMockEditor';
return isMockedComponent
? (ReactMonacoEditor as unknown as () => typeof ReactMonacoEditor)()
: original
? MonacoDiffEditor
: ReactMonacoEditor;
}, []);

Expand Down Expand Up @@ -389,27 +386,23 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
textboxMutationObserver.current.observe(textbox, { attributes: true });
}

if (editor.onKeyDown && editor.onDidBlurEditorText) {
editor.onKeyDown(onKeydownMonaco);
editor.onDidBlurEditorText(onBlurMonaco);
}
editor.onKeyDown(onKeydownMonaco);
editor.onDidBlurEditorText(onBlurMonaco);

if (editor.getContribution) {
// "widget" is not part of the TS interface but does exist
// @ts-expect-errors
const suggestionWidget = editor.getContribution('editor.contrib.suggestController')?.widget
?.value;

// As I haven't found official documentation for "onDidShow" and "onDidHide"
// we guard from possible changes in the underlying lib
if (suggestionWidget && suggestionWidget.onDidShow && suggestionWidget.onDidHide) {
suggestionWidget.onDidShow(() => {
isSuggestionMenuOpen.current = true;
});
suggestionWidget.onDidHide(() => {
isSuggestionMenuOpen.current = false;
});
}
// "widget" is not part of the TS interface but does exist
// @ts-expect-errors
const suggestionWidget = editor.getContribution('editor.contrib.suggestController')?.widget
?.value;

// As I haven't found official documentation for "onDidShow" and "onDidHide"
// we guard from possible changes in the underlying lib
if (suggestionWidget && suggestionWidget.onDidShow && suggestionWidget.onDidHide) {
suggestionWidget.onDidShow(() => {
isSuggestionMenuOpen.current = true;
});
suggestionWidget.onDidHide(() => {
isSuggestionMenuOpen.current = false;
});
}

editorDidMount?.(editor);
Expand Down Expand Up @@ -479,7 +472,6 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
<MonacoEditor
theme={theme}
language={languageId}
original={original ?? undefined}
value={value}
onChange={onChange}
width={isFullScreen ? '100vw' : width}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import React, { useState, useContext, useMemo } from 'react';
import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer-continued';
import { EuiSpacer, EuiSwitch, EuiRadioGroup, useEuiTheme } from '@elastic/eui';
import type { RuleResponse } from '../../../../../common/api/detection_engine/model/rule_schema/rule_schemas.gen';
import { sortAndStringifyJson } from './json_diff/sort_stringify_json';
import type { RuleResponse } from '../../../../../../common/api/detection_engine/model/rule_schema/rule_schemas.gen';
import { sortAndStringifyJson } from './sort_stringify_json';

const CustomStylesContext = React.createContext({});
const DiffMethodContext = React.createContext(DiffMethod.CHARS);
Expand Down

This file was deleted.

Loading

0 comments on commit 1190045

Please sign in to comment.