Skip to content

Commit

Permalink
Try using monaco-editor npm package instead of CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
thom4parisot committed Apr 15, 2023
1 parent bbb97a5 commit 66c0c79
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 23 deletions.
43 changes: 26 additions & 17 deletions front/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 front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"js-yaml": "^4.1.0",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"monaco-editor": "^0.37.1",
"object-path-immutable": "^4.1.0",
"pagedjs": "^0.4.0",
"react": "^16.13.1",
Expand Down
4 changes: 3 additions & 1 deletion front/src/components/Write/providers/monaco/BibtexEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { useCallback, useMemo } from 'react'
import Editor from '@monaco-editor/react'
import * as monaco from 'monaco-editor'
import Editor, { loader } from '@monaco-editor/react'

import styles from '../../../field.module.scss'
loader.config({ monaco })

// Taken from https://github.com/koka-lang/madoko/blob/master/styles/lang/bibtex.json
import languageDefinition from './lang/bibtex.json'
Expand Down
7 changes: 4 additions & 3 deletions front/src/components/Write/providers/monaco/DiffEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useCallback, useEffect, useState } from 'react'
import React, { useCallback, useEffect, useMemo, useState } from 'react'

import CompareSelect from "./CompareSelect";
import styles from "./DiffEditor.module.scss";
import { DiffEditor } from '@monaco-editor/react'
import * as monaco from 'monaco-editor'
import { DiffEditor, loader } from '@monaco-editor/react'
import { useGraphQL } from '../../../../helpers/graphQL'
import { compareVersion as query } from '../../Write.graphql'
import { defineFlippedDiffTheme } from './support'
import { useMemo } from 'react';
loader.config({ monaco })

export default function MonacoDiffEditor ({ text, compareTo, articleId, selectedVersion, currentArticleVersion, readOnly, onTextUpdate }) {
const [modifiedText, setModifiedText] = useState('')
Expand Down
4 changes: 3 additions & 1 deletion front/src/components/Write/providers/monaco/TextEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { useRef, useEffect, useMemo, useCallback } from 'react'
import { useSelector, shallowEqual } from 'react-redux'

import Editor from '@monaco-editor/react'
import * as monaco from 'monaco-editor'
import Editor, { loader } from '@monaco-editor/react'
import { registerBibliographyCompletion, registerReadOnlyTheme } from './support'

import styles from './TextEditor.module.scss'
loader.config({ monaco })

export default function MonacoTextEditor ({ text, readOnly, onTextUpdate }) {
const articleBibTeXEntries = useSelector(state => state.workingArticle.bibliography.entries, shallowEqual)
Expand Down
4 changes: 3 additions & 1 deletion front/src/components/Write/providers/monaco/YamlEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { useMemo } from 'react'
import Editor from '@monaco-editor/react'
import * as monaco from 'monaco-editor'
import Editor, { loader } from '@monaco-editor/react'

import styles from './YamlEditor.module.scss'
loader.config({ monaco })

export default function MonacoYamlEditor ({ text, height, onTextUpdate, fontSize = 16 }) {
const options = useMemo(() => ({
Expand Down

0 comments on commit 66c0c79

Please sign in to comment.