Re-add search addon to CodeMirror
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 3 Jun 2022 07:52:15 +0000 (09:52 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 3 Jun 2022 07:52:15 +0000 (09:52 +0200)
The browser search does not work well with CodeMirror, re-add the search addon
to make Ctrl+F work more or less as expected.

This got lost when CodeMirror was adjusted to make use of require.js in
480b6b11d0822015d4fe4515e7a72b495fe78a69.

wcfsetup/install/files/acp/templates/codemirror.tpl

index a383947801fdf1ba3aed4be307ade6e20b8e5440..1abaf8ffa568defe3f38357d1f706eec38642439 100644 (file)
                                'codemirror/mode/{@$codemirrorMode}/{@$codemirrorMode}',
                        {/if}
                {/if}
+               'codemirror/addon/search/search',
                'EventHandler',
                'Dom/Traverse',
                'Dom/Util'
        ], (
                CodeMirror,
                {if $codemirrorMode|isset}
-                       CoreMirrorMode,
+                       CodeMirrorMode,
                {/if}
+               CodeMirrorSearchAddon,
                EventHandler,
                DomTraverse,
                DomUtil,
        ) => {
                const codemirrorCss = document.head.querySelector('link[href$="codemirror.css"]');
                if (codemirrorCss === null) {
-                       const link = document.createElement('link');
+                       let link = document.createElement('link');
                        link.rel = 'stylesheet';
                        link.href = '{@$__wcf->getPath()}js/3rdParty/codemirror/codemirror.css';
                        document.head.appendChild(link);
+
+                       link = document.createElement('link');
+                       link.rel = 'stylesheet';
+                       link.href = '{@$__wcf->getPath()}js/3rdParty/codemirror/addon/dialog/dialog.css';
+                       document.head.appendChild(link);
                }
                
                var elements = document.querySelectorAll('{@$codemirrorSelector|encodeJS}');