Bug 24025 - Make CodeMirror content searchable
Summary: Make CodeMirror content searchable
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 21582
Blocks:
  Show dependency treegraph
 
Reported: 2019-11-12 17:36 UTC by George Williams (NEKLS)
Modified: 2020-02-14 03:21 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.03, 19.05.08


Attachments
Bug 24025: Make CodeMirror content searchable (1.06 KB, patch)
2020-01-22 16:32 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 24025: Make CodeMirror content searchable (1.12 KB, patch)
2020-01-22 17:37 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 24025: Make CodeMirror content searchable (1.17 KB, patch)
2020-01-22 22:12 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description George Williams (NEKLS) 2019-11-12 17:36:02 UTC
Bug 21582 added CodeMirror to the system preferences IntranetUserJS and  OPACUserJS.

Prior to this addition, if you wanted to search for something in one of these preferences you could use Firefox's built in "Find in This Page..." functions to search for content anywhere inside of the two UserJS system preferences.  Since the addition of CodeMirror, you can only search for content in the two UserJS system preferences if the content is displayed on the screen.

This makes it difficult to search for something on, say, line 500 of IntranetUserJS, unless you've already scrolled down to line 500 - or you've opened up CodeMirror to show every line in the preference you want to search through.

It looks like CodeMirror has an addon for searching through CodeMirror content, so I'm wondering if this addon could be incorporated into Koha wherever we're using CodeMirror.
Comment 1 Jonathan Druart 2019-11-14 11:59:58 UTC
It seems to work on their demo, without additional addon: https://codemirror.net/demo/complete.html

Maybe we need to upgrade (no idea how big it could be) to the newest version, but I do not see something in the changelog.
Comment 2 Owen Leonard 2019-11-15 13:22:14 UTC
(In reply to George Williams (NEKLS) from comment #0)
> you can only search for
> content in the two UserJS system preferences if the content is displayed on
> the screen.

I don't see how this is connected to the addition of CodeMirror. It has always been the case that you can't search the page for text which is hidden.
Comment 3 George Williams (NEKLS) 2019-11-15 15:42:29 UTC
Owen,

If you're in 18.05 and you go to preferences.pl?tab=opac and hit the "Click to edit" link for OPACUserJS and then search for a word that appears in the 	textarea for #pref_OPACUserJS using the browser's built in "Find in this page..." feature, Firefox will search all of #pref_OPACUserJS - even if the text you're searching for is not visible on the page.  When you hit "Click to edit" you get about 16 lines of OPACUserJS on the screen, but if you've got 500 lines in OPACUserJS and the text your searching for is on line 300, "Find in this page..." will scroll you down to line 300.

If you're in 19.05 and follow these same steps, when you "Click to edit" you're no longer opening the textarea for #pref_OPACUserJS.  The Code Mirror input area is a div styled as .CodeMirror.cm-s-default.CodeMirror-wrap and when you hit "Click to edit" you will get about 18 lines of OPACUserJS and only those 18 lines are searchable using "Find in this page...".

Code Mirror has two searh addons (search.js and searchcursor.js) that could be added that would allow users to put the cursor in the Code Mirror div, type CTRL-F and search through all lines in the Code Mirror div.  I think those addons would be a good addition to Koha.

George
Comment 4 Owen Leonard 2019-11-15 16:50:44 UTC
(In reply to George Williams (NEKLS) from comment #3)

> when you hit "Click to edit" you will get about 18 lines of OPACUserJS and
> only those 18 lines are searchable using "Find in this page...".

Thanks for the clarification!
Comment 5 Lucas Gass 2020-01-22 16:32:52 UTC
Created attachment 97747 [details] [review]
Bug 24025: Make CodeMirror content searchable

TEST PLAN:
1. Have a system pref like OPACUserJS will plenty of content.
2. Search for some with CTRL + F that is below the scroll
3. It is not findable.
4. Apply patch, restart_all, and clear your browser cache. 
5. Reload the sys pref and try again, you should be able to search through everything.
6. Rejoice!
Comment 6 ByWater Sandboxes 2020-01-22 17:37:17 UTC
Created attachment 97748 [details] [review]
Bug 24025: Make CodeMirror content searchable

Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>
Comment 7 Barbara Johnson 2020-01-22 17:39:20 UTC
I tested this patch with OPACUserJS, OPACUserCSS, IntranetUserJS, IntranetUserCSS and RestrictedPageContent.  It worked for all of them.
Comment 8 Katrin Fischer 2020-01-22 22:12:38 UTC
Created attachment 97755 [details] [review]
Bug 24025: Make CodeMirror content searchable

Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 9 Martin Renvoize 2020-01-23 10:35:58 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 10 Joy Nelson 2020-02-06 23:25:21 UTC
Pushed to 19.11.x branch for 19.11.03
Comment 11 Lucas Gass 2020-02-13 20:58:57 UTC
backported to 19.05.x for 19.05.08
Comment 12 Hayley Mapley 2020-02-14 03:21:49 UTC
Enhancement will not be backported to 18.11.x series.