amper
06-27-2006, 08:16 PM
Some questions about WYSIWYG editor.
1) How to assign default style (font, size, background) for textarea when editable text doesnt have any style tags (plain-text)?
2) Is there any way to filter MS Word 2003 tags when pasting text via clipboard? Cause it adds a lot of tags like that:
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt;
TEXT-ALIGN: center" align=center>
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<o:wrapblock>
3) How to hide some buttons from toolbar? I need only few (bold, underline, italic, copy\paste\cut, undo\redo).
djr33
06-27-2006, 08:34 PM
Don't use this script if you want to customize it. Really.
The script is written by someone outside DD and is just hosted here.
I had a couple questions, and found some bugs in it, but as of yet, no one here seems to be able to answer them.
The code is very complex. There is one javascript function called by the textarea, and in that function, it outputs all of the formatting, and the buttons with their own new functions, etc. etc. As I said, very complex.
You are posting this in html, (and it should be in the dynamic drive scripts forum), but this is a javascript question. you are asking partly about style which is CSS, but it's also almost entirely javascript because the JS in this script controls the CSS.
Now, for your specific questions:
1. CSS is a way to assign a default style. That's probably what you want to look into for that. Wouldn't be hard to integrate with the editor... just use an external stylesheet and include it, similarly to how you would an external javascript file. There's lots of info on that around; I suggest jus finding a script on DD that has an external .css file, and using that as an example to learn.
2. NEVER, EVER use Word to edit webpages. It screws stuff up. Frontpage has a huge number of problems, and it's microsoft's official webpage editor. Now, if THAT has so many problems, just imagine how bad a webpage editor their word processing application is.
You could, yes, write javascript that would filter those, but you would need to use logic, as with all programming... you could filter everything that exactly matches the tags you're used to, but if even a single character varied, it wouldn't replace that. You could even code it to remove "?xml" and everything around it to the < and >, but that might give you issues, and would be a LOT of work coding... advanced javascript.
PLUS you would still need to access the complex script and find where this stuff happens to add your functions.
3. To hide buttons from the toolbar, as mentioned above, would be very hard because you would be rewriting the script. The JS is so complex that I wouldn't bother trying, myself. I guess it wouldn't be that bad; you'd just need to do it and set it up so that the layout still worked, find the part (fairly obvious) where the buttons are generated, and remove the ones you don't want. (just comment them out, with "//" before them.)
However, functionality of the script might change and it might just be weird.
In the end, it might make more sense to, before changing this one, just write your own if you really need it to be so customized.
I'm not trying to discourage you on this.... but you picked a bad script to want to customize.
Also, you could contact the script's creator(s), but I did so with a couple (quite valid) questions, and have yet to get a response. (It's been a few months.)
For what it is, the script is very nice. However, customizing it is an issue, and there are a couple problems with it. (And fixing would count as customizing... so... yeah...)
Also, I made a couple improvements you could check out... find the thread near the top about it in the dynamic drive scripts forum. They fix a couple little bugs.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.