Currently there is no way to reedit a code block without editing the html source... e.g. change the language, turn the gutter off, or change anything else about it. I know that that was a flaw in the original plugin code, but it would be great if you could get that working!
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | wysiwyg_syntaxhl.tar_.gz | 10.27 KB | meecect |
Comments
Comment #1
meecect commentedYes, I would love to have this feature as well. I'm sure it's possible because other tiny plugins have the ability to do it. I'll begin working on it right away.
Comment #2
meecect commentedThis is implemented in the latest dev branch, as soon as it auto builds.
http://ftp.drupal.org/files/projects/wysiwyg_syntaxhl-6.x-1.x-dev.tar.gz
Please see if it fixes the issue.
Comment #3
mrfelton commentedNot working for me. If I click in a bit of text that already has the syntaxhl applied to it, then the syntaxhl button gets a black border, as if to say that tinymce recognises that this bit of text already has it applied. However, clicking on the button just brings up a brand new code edit popup - no code already in there, and none of my settings.
Comment #4
meecect commentedYou probably don't have the current code. Is there a CHANGELOG.txt in your module folder, because I added it at the same time. The dev branch releases only build every 12 hours and I only put new code in branches, not in head. I don't want to push a new release yet though because there is still a bug outstanding. I've attached a tar ball; Can you try it?
Comment #5
mrfelton commentedThe file you just pasted on this thread unzips into /vol/dev/drupal/contributions/modules/wysiwyg_syntaxhl and I can get to it. I just downloaded the latest -dev, whioch has today's date and the CHANGELOG.txt file in it. Now, the syntax highlighter doesn't work at all! I get the popup, but there are no languages in it. The button doesn't even highlight anymore when putting the cursor in an existing code block!
Comment #6
mrfelton commentedActually, the button does highlight if I create a NEW code block and then put the cursor in that - but doesn't for any of my pre existing code blocks. The other problems I described above are still true.
Comment #7
meecect commentedCan you tell me the version of os/browser/drupal you are testing with?
Comment #8
mrfelton commentedUbuntu, Firefox, Drupal 6.14, garland theme. No errors in firebug.
Comment #9
meecect commentedAs far as the issue of not recognizing code blocks that were created before this module, it was partly by design, but I could certainly change it.
In fact we can make the syntax button 'activate' on any PRE element, which would mean you could theoretically change plain ol pre tags into code syntax highlighted boxes. What do you think about that?
Comment #10
mrfelton commentedI have written numerous articles using the syntax highlighter, and it will be a royal pain in the ass if this new version doesn't recognise the old ones. I like the idea of associating all pre elements with the syntax highlighter button. +1 from me on that.
Comment #11
meecect commentedI've nearly got it;
It now recognizes old syntax blocks, as well as normal pre's. The one downside is that if you edit an old code block, and save the node, you will get the new behavior, which is to convert the pre tags to {}-macro blocks.
Of course, that also means we may not initially have any good way to change syntax blocks back into plain pre's.
Will that work for you?
When I'm done, I'll tag a beta release to make testing easier so we don't have to wait for the dev auto builds or pass around tarballs.
Comment #12
meecect commentedok, I think it's working. I still have a few problems:
- in ie, it sometimes messes up whitespace (it removes it when it shouldn't).
- if I dynamically add the tiny_mce_popup.js script, safari sometimes bombs out when the dialog opens. This is a known issue with safari, apparently. my current workaround for that currently is to just load it statically, like:
in dialog.htm
Note that that only works if that is where your tinymce happens to be (although it should be there).
If you'd like to test, just check out the DRUPAL-6--1 branch where the current changes are. Sample command for that is:
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d wysiwyg_syntaxhl -r DRUPAL-6--1 contributions/modules/wysiwyg_syntaxhl
Comment #13
mrfelton commentedprogress. Not quite there yet...
1) Still doesn't recognise old code blocks. Here is an example of the HTML of one of my old blocks
2) Clicking the button on a code block does indeed bring the popup with the text already in it, but the options (butter, light etc) are not set to that of the code block...
a) No gutter - not remembered
b) Light - not remembered
c) collapse - not remembered
d) highlight - turned '4' into '[4]'
e) language - ok
f) first line - reset to 1
g) font size - reset to 100%
progress though... nice work.
Comment #14
meecect commentedI just committed some changes to the DRUPAL-6--1 branch, please check it out and give it a spin. On my system, it is working fine now for the example you suggested. I have also created a 'sample.html' file in the module root that has some standard examples so we can test from some known starting position (although please try it out on your other nodes that will have more examples of what may be found in the wild). The sample.html has three cases:
a {} style block
a preexisting pre block based on your example
a plain pre
Note, the button should activate (border drawn around it) for all those cases. Actually it should have been doing this for some time now, because it's the simplest part of the whole thing and was implemented a few revisions ago...it just checks to see if your cursor is in a pre tag or not and the code is stripped right out of the sample plugin tinymce provided.
If something basic like that doesn't work for you, then you must be having a cache issue of some sort.
BTW, I tested this on firefox 3 in ubuntu 9.04
Here is the sample html I have been using to test (from sample.html):
Comment #15
meecect commentedBTW, do you have performance enabled, like javascript consolidation? Make sure those are off, or you reset your drupal cache before testing.
Comment #16
mrfelton commentedI had all the performance stuff turned off. I am testing in Firefox 3.5 ubuntu... I'll give the new code a spin in the next hour so. Thanks for your work on this, gonna be great when this is working properly!
Comment #17
mrfelton commentedSeems to be working nicely... Very cool. One thought... what do you think about being able to highlight any text and turn it into syntax highlighted text (not just pre elements)? Not sure if that would work or not - didn't give it much thought, just an idea.
What you have here is great though. Thanks again.
Comment #18
meecect commentedI think that would be pretty easy to implement, because right now, when a selection is made I just check to make sure the selection is a pre tag and then get all of it's content to populate the popup. In the general case, I would just need to code the 'if-not-pre' case and then process the highlighted section. Internet explorer will likely give me fits though. It just decides willy-nilly to force html validation when getting and setting values, so we'll probably have lots of whitespace and html encoding issues. It doesn't work very well right now in ie, but I can't be arsed to fix it. Screw ie.
Feel free to create a new issue for it though and I'll do it when I get time.
Comment #19
meecect commented