Javascript Rich Text Editor w/ Syntax Highlighting
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Javascript Rich Text Editor w/ Syntax Highlighting
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.
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.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
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.
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.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Look around our code snipplet board, we have one around somewhereOriginally, 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.
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)And as far as I'm concerned you can't have multiple colors for text in a textarea.. Sorry to ruin the party.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England