Javascript Rich Text Editor w/ Syntax Highlighting

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Javascript Rich Text Editor w/ Syntax Highlighting

Post by jayshields »

I'm wanting to take my file management system to the next level by adding a file editor, this wouldn't be so hard, as I'd just check the MIME type and if it contains "text", show the text in a HTML textarea and let it be editted and overwritten.

Then I got an idea. This sort of thing would enable me to code via a browser, and as soon as I click save, it will be online and ready to test; like working on a local development server. I found a file manager that already does all the above stuff, and it's very good, apart from it's hard to code PHP (or infact anything) without decent syntax highlighting.

I know there are scripts around to display PHP (and other languages) with syntax highlighting, but I'm looking for something that will display PHP (and possibly other languages if it goes well) in some sort of JavaScript (or AJAX) rich text editor. The syntax highlighting will ofcourse need to be dynamic, hence the need for a client side element.

Does such a thing already exist? I imagine it would be out of my reach to code something like this from scratch.

Thanks.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

the idea of having the code display in a textarea is for you to copy it to a text editor of your choice, then paste it back when you want to save. :)
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

That defeats the object though :(

I want it to sort of simulate working on a local development server, so I can just bring up syntax highlighted code, edit it, click save, and refresh the URL.

So is there no such thing?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

is it possible to change colours in a textarea?

And it doesn't defeat the object at all.. it just doesn't achieve what you want it to achieve :P
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

You can change the text colour in a textarea, but only the whole area at once, as far as I'm aware. I don't know how they do it in those online Rich Text Editors.

Not achieving what I want it to achieve and defeating the object are the same things as far as I'm concerned :P
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

I assume they're using lots of <span></span> tags with specific styles attached for changing colours. The output is still part of an HTML doc afterall...
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

That's such a magnificent idea, Jay. It's very nice. I tried to search something for you but to no prevail so far.
And as far as I'm concerned you can't have multiple colors for text in a textarea.. Sorry to ruin the party.
Maybe you could put each different-colored-text in a text field? :P
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

I think putting seperately coloured text in different fields would spoilt it a bit.

I'm sure there is a JavaScript Rich Text Editor somewhere, I mean, some of the CMS's I've heard about have Administration pages where you can use an in-built WYSIWYG editor, that must be close to what I want.

Originally, the only problem I thought I would have was implementing a syntax highlighter, because I doubt I could code one, so I would need to find an open-source one, and I thought an existing PHP syntax highlighter (not meant for editting, only displaying) could be adapted with a bit of work.

I've just found one on Dynamic Drive: http://www.dynamicdrive.com/dynamicinde ... exteditor/

I knew there were such things already, but I don't really want all that functionality, that link just proves Rich Text Editors are available.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Originally, the only problem I thought I would have was implementing a syntax highlighter, because I doubt I could code one, so I would need to find an open-source one, and I thought an existing PHP syntax highlighter (not meant for editting, only displaying) could be adapted with a bit of work.
Look around our code snipplet board, we have one around somewhere :P
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

jayshields wrote:I think putting seperately coloured text in different fields would spoilt it a bit.
I was joking.
jayshields wrote: [...] I would have was [...]
Can you say that in English?? "I would have was", is that ok grammer-wise? I mean, what tence is it?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

And as far as I'm concerned you can't have multiple colors for text in a textarea.. Sorry to ruin the party.
However it's possible to edit an iframe ( http://developer.mozilla.org/en/docs/Ri ... in_Mozilla )and then on form submit load the innerHTML of that iframe into some hidden field. After running strip_tags on the received data you should get proper plain text (without the html tags that were used on client-side to colorize the source)
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

pilau wrote:
jayshields wrote: [...] I would have was [...]
Can you say that in English?? "I would have was", is that ok grammer-wise?
He said that '...he thought he would have a problem, the problem was....'
I mean, what tence is it?
It's... hm... feature-in-the-past perhaps.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

It's very tense, temple vein throbbing tense. (I know it's a different spelling, but I am bored dammit.)
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

Weirdan wrote:
pilau wrote:He said that '...he thought he would have a problem, the problem was....'
Oh, now I get it thanks a lot! I can't believe I didn;t realize it on my own, :(
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

lol I just read your post and thought, hhmm, not usually like to me to use bad grammar, read over my post, and you did misinterpret it a little.

It's only a forum anyway, I cna tpye hwo i wana ok!?
Post Reply