WeBWorK Main Forum

Ctrl + F search and replace in PG editor

Ctrl + F search and replace in PG editor

by Balagopal Pillai -
Number of replies: 2

On our 2.16 test server, pressing Ctrl + F on PG editor is not bringing up the codemirror search/replace.

 On 2.14 server, it brings up codemirror search. I checked the addons directory and it has all the relevant .js files.

The version of codemirror installed via npm is 5.62.0. For now I have set $options{PGCodeMirror} = 0 to make it behave like a text area and browser could search through the visible and invisible sections of pg code. I was wondering if it is possible to get the same behaviour as 2.14 with the PG editor that brings up search and replace within the editor with Ctrl + F. Thanks a lot. 

In reply to Balagopal Pillai

Re: Ctrl + F search and replace in PG editor

by Joseph Lo -
Open /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm. In sub output_JS, add the following inside if ($ce->{options}->{PGCodeMirror}) {...}

print '<link rel="stylesheet" type="text/css" href="$site_url/node_modules/codemirror/addon/search/matchesonscrollbar.css"/>';
print '<link rel="stylesheet" type="text/css" href="$site_url/node_modules/codemirror/addon/dialog/dialog.css"/>';
print CGI::start_script({src=>"$site_url/node_modules/codemirror/addon/search/searchcursor.js"}), CGI::end_script();
print CGI::start_script({src=>"$site_url/node_modules/codemirror/addon/search/search.js"}), CGI::end_script();
print CGI::start_script({src=>"$site_url/node_modules/codemirror/addon/search/matchesonscrollbar.js"}), CGI::end_script();
print CGI::start_script({src=>"$site_url/node_modules/codemirror/addon/search/match-highlighter.js"}), CGI::end_script();
print CGI::start_script({src=>"$site_url/node_modules/codemirror/addon/dialog/dialog.js"}), CGI::end_script();

Restart apache at the end. It seems like this will get the search back like we had in 2.14.