Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module.exports = {
customReact: 'react',
reactRedux: 'react-redux',
PFReactCore: '@patternfly/react-core',
PFReactTable: '@patternfly/react-table'
PFReactTable: '@patternfly/react-table',
'^monaco-editor$': '<rootDir>/packages/module/src/__mocks__/monaco-editor.ts'
},
globalSetup: '<rootDir>/config/globalSetup.js',
transform: {
Expand Down
28 changes: 26 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@patternfly/react-table": "^6.1.0",
"@segment/analytics-next": "^1.76.0",
"clsx": "^2.1.0",
"monaco-editor": "^0.54.0",
"path-browserify": "^1.0.1",
"posthog-js": "^1.194.4",
"react-markdown": "^9.0.1",
Expand Down
6 changes: 5 additions & 1 deletion packages/module/src/CodeModal/CodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import type { FunctionComponent, MouseEvent } from 'react';
import { useState, useEffect, useRef } from 'react';
import path from 'path-browserify';
import type monaco from 'monaco-editor';
import * as monaco from 'monaco-editor';
import { loader } from '@monaco-editor/react';

// Import PatternFly components
import { CodeEditor } from '@patternfly/react-code-editor';
Expand All @@ -22,6 +23,9 @@ import FileDetails, { extensionToLanguage } from '../FileDetails';
import { ChatbotDisplayMode } from '../Chatbot';
import ChatbotModal from '../ChatbotModal/ChatbotModal';

// Configure Monaco loader to use the npm package instead of CDN
loader.config({ monaco });

export interface CodeModalProps {
/** Class applied to code editor */
codeEditorControlClassName?: string;
Expand Down
19 changes: 19 additions & 0 deletions packages/module/src/__mocks__/monaco-editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const mockEditor = {
layout: jest.fn(),
focus: jest.fn(),
dispose: jest.fn(),
getModel: jest.fn(),
updateOptions: jest.fn()
};

const mockModel = {
updateOptions: jest.fn(),
dispose: jest.fn()
};

module.exports = {
editor: {
create: jest.fn(() => mockEditor),
getModels: jest.fn(() => [mockModel])
}
};
Loading