zioth / dokuwiki_fastwiki

DokuWiki plugin which speeds up user interactions by avoiding page loads, rendering content client-side and pre-loading content.
GNU General Public License v2.0
9 stars 2 forks source link

[feature request] Add CodeMirror support #18

Open PeterBurner opened 8 years ago

PeterBurner commented 8 years ago

the CodeMirror Plugin isn't loaded on inline edit

chchch commented 8 years ago

Hi,

I've managed to make them work, but it seems to require also modifying the CodeMirror plugin. The CodeMirror plugin wraps everything in an anonymous function that loads on document.ready; I've instead gave that function a name, i.e. dokuwiki_codemirror_init, and then in the fastwiki plugin, in the _initEdit function, I simply add a line to run dokuwiki_codemirror_init().

Hope that helps.

PeterBurner commented 8 years ago

cool workaround thanks am I getting this right, I have to replace function(a) by function dokuwiki_codemirror_init(a) in the scripts.min.js of codemirror? unfortunately I can't test it right now

chchch commented 8 years ago

Search for jQuery(function(){"use strict";.... and replace that with function dw_cm_init(){"use strict";...

then at the bottom of the script, you need to run the function, so add jQuery(document).ready(dw_cm_init());

Then in the fastwiki plugin, in the _initEdit() function, add dw_cm_init(); ... I put it after if($editform.length == 0) return;

Let me know if it works!

PeterBurner commented 8 years ago

great thanks i'll try that

chchch commented 8 years ago

Oh wait, also at the end of the script you need to remove the ); that corresponds to the jQuery( that we replaced.

zioth commented 8 years ago

This patch might cause problems if you go in and out of edit mode more than once. Since codemirror is distributed compressed, I can't easily make and test a pull request, but I've submitted an issue with what I think is the right fix. https://github.com/albertgasset/dokuwiki-plugin-codemirror/issues/59