Ok, Jim answered me via email, not via the group, and it seems that I've 
fixed the issue.

Once again, the problem was that only *global* settings from the 
CodeMirrorConfig were read, and I wasn't able to set, say, lineNumbers: true 
for the javascript mode, but not for the tiddlywiki mode. According to [1] 
(thanks, Jim),

The CodeMirror.listModes and CodeMirror.listMIMEs functions, used for 
listing defined modes, are gone. You are now encouraged to simply inspect 
CodeMirror.modes (mapping mode names to mode constructors) and 
CodeMirror.mimeModes (mapping MIME strings to mode specs).


So, I took the (already implemented) collecting of modes from 
config.macros.cmModes (.handler) and brought it to the init method:

        init: function() {
            var cm = 'CodeMirrorConfig', modes = [];
            var secSep = config.textPrimitives.sectionSeparator;
            
            // global settings need to be read seperately    
            me.conf['global'] = me.rdSettings(cm + secSep + 'global');

            // check CM for installed modes and get user config if available
            *for(var m in CodeMirror.modes)*
                *if(CodeMirror.modes.propertyIsEnumerable(m))* // looks 
like this is excessive
                    *modes.push(m);*

            for (var i = 0; i < modes.length; i++)
                me.conf[modes[i]] = me.rdSettings(cm + secSep + modes[i]);
        },

Now, all the settings are read and everything works fine, I'm not only sure 
if the *propertyIsEnumerable* thing is really needed (without it, the 
result is the same, and alerting the properties of *CodeMirror.modes* shows 
only modes' names, nothing more). A side note: this enumerating is done in 
the plugin in several places, so it may be worth creating a method, may be 
re-implementing CodeMirror.listModes and CodeMirror.listMIMEs.


There's another problem, which I've fixed.. sort of. tiddlywiki.js from 
Mario's repository doesn't support strike-throught styling, the version 
from the Jim's TW does, but creates incorrect DOM for list items' bullets 
(marks them as comments, .cm-comment instead of .cm-list). That's why I 
took tiddlywiki.css from Jim's TW, tiddlywiki.js from Mario's repository 
and in tiddlywiki.js changed line-through to strikethrough (there's only 
one such piece) which fixed the DOM. So now I have both correct DOM for 
list bullets and strike-through syntax striked-throuth. Unfortunately, I'm 
not aware of any other differences between "Mario's" and "Jim's" versions 
of tiddlywiki.js and other .js and .css tiddlers.


Still, I have a number of problems. A major one is: on zCodeMirrorPlugin 
0.4.2 (0.4.3, with the fix above), I've got no alerts when I press esc when 
I'm in the cmEdit mode and have made some changes. I haven't dug this deep 
yet, but this isn't a fine thing for development. I think it's better to 
discuss this and then I'll go on with the less important issues.

Best regards,
Yakov.

[1] http://codemirror.net/doc/upgrade_v3.html, "Mode management" section

четверг, 12 июня 2014 г., 1:32:49 UTC+4 пользователь Yakov написал:
>
> Hello Mario and Jim,
>
> I've found a bug that prevents the settings for modes (but not the 
> "global" ones) to be read. The problem is in the init method of the 
> config.tools.cm object: in Mario's 0.2.9 version it reads
>
>         init: function() {
>             var cm = 'CodeMirrorConfig', modes;
>             var secSep = config.textPrimitives.sectionSeparator;
>             
>             // global settings need to be read seperately   
>             me.conf['global'] = me.rdSettings(cm + secSep + 'global');
>
>             // check CM for installed modes and get usre config if 
> available
>             modes = CodeMirror.*listModes*();
>             for (var i=0; i < modes.length; i += 1) {
>                 me.conf[modes[i]] = me.rdSettings(cm + secSep + modes[i]);
>             }
>         },
>
> for some reason, the listModes method stopped working, probably that's 
> why in Jim's 0.4.2 version the method reads:
>
>         init: function() {
>             var cm = 'CodeMirrorConfig', modes;
>             var secSep = config.textPrimitives.sectionSeparator;
>             
>             // global settings need to be read seperately   
>             me.conf['global'] = me.rdSettings(cm + secSep + 'global');
>
>             // check CM for installed modes and get user config if 
> available
>             modes = CodeMirror.*getMode*();
>             for (var i=0; i < modes.length; i += 1) {
>                 me.conf[modes[i]] = me.rdSettings(cm + secSep + modes[i]);
>             }
>
> and uses the getMode method. But:
> 1. the method returns a mode object, not a mode name, so there should be 
> something like
>             modes = CodeMirror.getMode().*name*;
> 2. it returns only one mode, not a set (and modes.length is undefined), 
> so there should be something like
>             var cm = 'CodeMirrorConfig', *mode*;
>             [...]
>             *mode* = CodeMirror.getMode().name;
>             me.conf[*mode*] = me.rdSettings(cm + secSep + *mode*);
> 3. still, this doesn't work for me: the getMode method somewhy always 
> returns an object with name:"null", -- I've added an alert to see what it 
> returns, and when I open tiddlers in the "javascript" mode, it still 
> returns "null".
>
> Any ideas how to fix this?
>
> By the way, any progress in maintaining the plugin? (there's CM 4.2 out 
> there already)
>
> Best regards,
> Yakov.
>
> среда, 18 декабря 2013 г., 18:35:31 UTC+4 пользователь Jim написал:
>>
>>  Gosh – found a bug in IE8.  Here’s the fix…
>>
>>  
>>
>>  
>>
>> Jim
>>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to