Skip to content

Commit

Permalink
Issue Source Code Pro (versions 1.1.1 - 1.1.3) not working in Moodle …
Browse files Browse the repository at this point in the history
…4.1.2 #16
  • Loading branch information
jmuletpol committed Nov 27, 2024
1 parent 058263a commit 8c778b2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion amd/build/cm6pro-lazy.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/cm6pro-lazy.min.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions amd/src/cm6pro-lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19226,7 +19226,8 @@ const treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass
/**
A default highlight style (works well with light themes).
*/
const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([
const HighlightStyleDefs = HighlightStyle.define;
const defaultHighlightStyle = /*@__PURE__*/HighlightStyleDefs([
{ tag: tags$1.meta,
color: "#404740" },
{ tag: tags$1.link,
Expand Down Expand Up @@ -28112,7 +28113,9 @@ const cm6proDarkTheme = EditorView.theme({
/**
The highlighting style for code in the CodePro Dark theme.
*/
const cm6proDarkHighlightStyle = HighlightStyle.define([
// Workaround issue requirejs Moodle4.1.2
const HighlightStyleDef = HighlightStyle.define;
const cm6proDarkHighlightStyle = HighlightStyleDef([
{ tag: tags$1.keyword, color: base_green },
{
tag: [tags$1.name, tags$1.deleted, tags$1.character, tags$1.propertyName, tags$1.macroName],
Expand Down
26 changes: 25 additions & 1 deletion libs/codemirror/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,28 @@ And run the job defined in the `rollup.config.js` file
npm run build
```

If everything runs smoothly, the file amd/src/cm6pro-lazy.js will be generated. Then, you must compile it using the command `npx grunt amd`. The resulting minified version of this file will be lazy loaded on demand when the code editor is opened.

If everything runs smoothly, the file amd/src/cm6pro-lazy.js will be generated.

Open this file and add these lines to the top
```
/** @ts-ignore */
/* eslint-disable */
````
### This is a workaround for an issue that appears when using requirejs in Moodle4.1.2
Search for `define([` in the file and do the following replacement
```
const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([
```
```
const HighlightStyleDefs = HighlightStyle.define;
const defaultHighlightStyle = /*@__PURE__*/HighlightStyleDefs([
```
Then, you must compile it using the command `npx grunt amd`. The resulting minified version of this file will be lazy loaded on demand when the code editor is opened.
4 changes: 3 additions & 1 deletion libs/codemirror/cm6pro-dark-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ const cm6proDarkTheme = EditorView.theme({
/**
The highlighting style for code in the CodePro Dark theme.
*/
const cm6proDarkHighlightStyle = HighlightStyle.define([
// Workaround issue requirejs Moodle4.1.2
const HighlightStyleDef = HighlightStyle.define;
const cm6proDarkHighlightStyle = HighlightStyleDef([
{ tag: tags.keyword, color: base_green },
{
tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
Expand Down

0 comments on commit 8c778b2

Please sign in to comment.