26

Re: Tip: full XHTML validation.

In most browsers, external Javascript files are cached unless the user stomps on their default browser cache settings. If your editor is loading often during a session or your CMS users use the CMS a lot, placing the init code in an external .js file should go close to negating the extra 15 Kb of download time in practical terms. It's not ideal, but it's not bad.

With regards to replacing tags such as <u> with style definitions, is there something wrong with a bit of code called on the save event that does the following?

<pseudo>
for each node in the DOM
  if the node tag name is <u> then
        set the selection to outer HTML
        grab the inner HTML from the selection
        remove the parent tag from the selection using DOM commands
     if the parent tag isn't a <span>
       expand the inner HTML with <span style="text-decoration: underline;">inner HTML</span>
     else
       add the "text-decoration: underline;" attribute using DOM commands
     end if
        replace the selection
   end if
next
</pseudo>

This could quite easily be expanded to handle any tag and any replacement code from a config file...

I'm new to Tiny MCE so I don't know how the edit/cleanup/save procedure works yet. Also my DOM experience comes mostly from the evil world of IE proprietary code, so I'm not sure if some of the nice built-in DOM manipulation commands are supported in other browsers. So pardon my ignorance if it is ignorance. wink These are just some thoughts that came to mind after reading this thread.

-- Rob.

27

Re: Tip: full XHTML validation.

To num #24 and #25
You could just use the cleanup callback, if you want. Either do a DOM lookup or just RegExp with the string. For the RegExp method do something like this:

value = value.replace(/align=(['"])(\w+)(['"])/,"class=$1$2$3");

Also important, take a look at:
option_cleanup_callback

Last edited by cypres (2006-06-09 10:25:55)

28

Re: Tip: full XHTML validation.

i'm sorry but this code doesn't work
The tinymce is not W3C valid
When i try this solution it always put align="center" and that's not valid for a div !!

Can someone help me ? os show me an exemple of tinymce where the code is valid XHTML

thanks

29

Re: Tip: full XHTML validation.

Hi NeoPof,

give a look at http://tinymce.moxiecode.com/tinymce/do … ments.html you may find how to valid your output to XHTML.

Have fun ;-)

30

Re: Tip: full XHTML validation.

After reading the post by rstjean I tried speeding up the validation by removing all eventHandlers from the valid_elements-list.

The list and the need for further help at speeding up TinyMCETriggerSave() can be found here.

31

Re: Tip: full XHTML validation.

Great job DewiMorgan.. * thumbs up *

" The code is out there.. "

32

Re: Tip: full XHTML validation.

Can you post an example with all requrired files?

best regards

33

Re: Tip: full XHTML validation.

why not ship this settings as the default of TinyMCE ?

34

Re: Tip: full XHTML validation.

I have a problem with getting valid xhtml for tables, the width attribute should be a style and even if I set it in the style it does not work moves it to width="" how can this be fixed?

Row

35

Re: Tip: full XHTML validation.

I've inserted the code shown at the beginning of this thread, but I'm still getting xhtml validation errors;

there is no attribute "align".

<div align="center">

# Line 84 column 16: there is no attribute "color".

<h4><font color="#ffff00">MediaBeez' comfy test-bed</font></h4>

?
# Error Line 84 column 25: element "font" undefined.

<h4><font color="#ffff00">MediaBeez' comfy test-bed</font></h4>
Error  Line 85 column 9: there is no attribute "align".

<p align="left">

Some explanation would be very much appreciated..

36

Re: Tip: full XHTML validation.

Hi!!!!
That was very helpful!!!!!!!!!!! Thanxxxxxxxxxxxxxxx

Fit 4 Europe!

37

Re: Tip: full XHTML validation.

I tried the code, but code is still unvalid when using flash plugin. The failed validation is caused by "embed" element.
I don't understand why such element is not stripped out, since it's not among the valid ones in "valid_elements" declaration...

38

Re: Tip: full XHTML validation.

Otherwise flash wouldn't play in some browsers.  I'd be interested to see if anybody has modified the flash plugin to use a valid javascript method such as swfobject.  I started to, but I just don't understand javascript enough to modify it all the way.  If you're interested in what I have so far though let me know.  Maybe someone can help modify it the rest of the way.

--------------------------------------------------------------------------------
chrisandabby.com : designsbychris.com : 100mostbeautifulbabies.com

39

Re: Tip: full XHTML validation.

Hmm.

I have tried this, and it works fine. Apart from it inserts more METAs on each edit?

<span class="doctype"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></span>

<<span class="start-tag">html</span>>
<<span class="start-tag">head</span>>
<<span class="start-tag">meta</span><span class="attribute-name"> http-equiv</span>=<span class="attribute-value">"Content-Type" </span><span class="attribute-name">content</span>=<span class="attribute-value">"text/html; charset=iso-8859-1" </span><span class="attribute-name">/</span>>
<<span class="start-tag">title</span>>blah.htm</<span class="end-tag">title</span>>
</<span class="end-tag">head</span>>

<span><<span class="start-tag">body</span>></span>

<span>
--------- INSERTED AFTER FIRST EDIT -------------------</span>
<<span class="start-tag">meta</span><span class="attribute-name"> content</span>=<span class="attribute-value">"text/html; charset=iso-8859-1" </span><span class="attribute-name">http-equiv</span>=<span class="attribute-value">"Content-Type" </span><span class="attribute-name">/</span>>
<<span class="start-tag">title</span>>blah.htm</<span class="end-tag">title</span>><span>
--------- / INSERTED AFTER FIRST EDIT -------------------</span>
<span><<span class="start-tag">p</span>>
--------- INSERTED AFTER SECOND EDIT -------------------
</span><<span class="start-tag">meta</span><span class="attribute-name"> content</span>=<span class="attribute-value">"text/html; charset=iso-8859-1" </span><span class="attribute-name">http-equiv</span>=<span class="attribute-value">"Content-Type" </span><span class="attribute-name">/</span>>
<<span class="start-tag">title</span>>blah.htm</<span class="end-tag">title</span>><span>
--------- / INSERTED AFTER SECOND EDIT -------------------</span>
etr
</<span class="end-tag">p</span>>
<<span class="start-tag">p</span>>
&<span class="entity">nbsp;</span>
</<span class="end-tag">p</span>>
<<span class="start-tag">p</span>>
xfhdf
</<span class="end-tag">p</span>>
<<span class="start-tag">p</span>>
sjhjs&<span class="entity">nbsp;</span>
</<span class="end-tag">p</span>>


</<span class="end-tag">body</span>>
</<span class="end-tag">html</span>>

I don't know if this is a problem with TinyMCE, this validation, or my code.
My code is the following for inserting HTML and METAs..:
    $html = stripslashes($_POST['html']);
    if(!strstr($html, "<html>")) {
    $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n<title>".$_POST['file']."</title>\n</head>\n\n<body>\n\n".$html."\n\n</body>\n</html>";
    }

40

Re: Tip: full XHTML validation.

Where are you guys editing this code and adding it inside the editor folder ? Please expand on where to add the code to from the beginning of this post.

41

Re: Tip: full XHTML validation.

http://wiki.moxiecode.com/index.php/Tin … d_elements

Best regards,
Spocke - Main developer of TinyMCE

42

Re: Tip: full XHTML validation.

Question:

Is it possible to use the above to generate HTML 4.01 STRICT valid code?

I'm having problems with tinymce because the generated tables aren't valid (for example, the height attribute isn't allowed in <table> tag).

43

Re: Tip: full XHTML validation.

nice job! it seems that you've duplicated the class on span -> 'span[align|class|class...' so the output gets like <span class="foo" class="foo">content</span> but just remove one of the class and its fixed

regarding the div alignment problem you could (the easy way) solve it by using content_css and include one of your own css-stylesheets and make css-classes "center", "left" etc and include the button-option styleselect. that way you could do that options via the style dropdown if you want a quickfix

Last edited by Xorath (2007-03-24 13:05:39)

44

Re: Tip: full XHTML validation.

Hello,

I have a problem with Tiny to edit full page. I've added validation elements as you showed, but Tiny still remove <head>, <html>, <body>, so the document is absolutely not valid. Is there any idea for this? Maybe I have to pass another options to initialization of Tiny? Just look, what have Tiny done with my code:

<title></title>
<meta />
<style> /* here are my styles */ </style>
<div id="top">here is my content</div>

And that's all sad Where is html, body?

Best regards,
Adrian Pawlik.

Last edited by prph (2007-04-12 20:06:38)

45

Re: Tip: full XHTML validation.

AREA tag is not working. The system leaves only "href" parameter ( 'shape" and "coords" are automatically deleted ) for that tag, and the valid elements list is

+"area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref"
  +"|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup"
  +"|shape<circle?default?poly?rect|style|tabindex|title|target],"

It seems it's a bug, right?

46

Re: Tip: full XHTML validation.

ReneVeerman wrote:

I've inserted the code shown at the beginning of this thread, but I'm still getting xhtml validation errors;

there is no attribute "align".

<div align="center">

# Line 84 column 16: there is no attribute "color".

<h4><font color="#ffff00">MediaBeez' comfy test-bed</font></h4>

?
# Error Line 84 column 25: element "font" undefined.

<h4><font color="#ffff00">MediaBeez' comfy test-bed</font></h4>
Error  Line 85 column 9: there is no attribute "align".

<p align="left">

Some explanation would be very much appreciated..

Hi folks,

I have the same problem and I really don't know how to fix it.
My config:
        mode : "exact",
        elements : "elm1",
        theme : "advanced",
        language : "en",
        theme_advanced_toolbar_location : "top",
        apply_source_formatting : true,
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "none",
        theme_advanced_buttons1 : "bold,separator,italic,separator,underline,separator,justifyleft,separator,justifycenter,separator,justifyright,separator,bullist,separator,code,separator,redo",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        verify_html : true,
        cleanup : true,
        cleanup_on_startup : true,
        extended_valid_elements : ""
+"a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name"
...


So, what have I to do, to make tinymce creating valid xhtml?

Greetings,

scy

Last edited by scy (2007-09-14 16:46:34)

47

Re: Tip: full XHTML validation.

Tried everything, nothing works. May anyone post a working code?

Last edited by scy (2007-09-14 19:49:07)

48

Re: Tip: full XHTML validation.

I don't know where to post my bug so I choose spam it, but I need to fix this urgently. I use MCE in my web page that load the content from another textarea. And my problem is when I receive content that OK but when it null I can't validate the content in MCE by using javscript. Someone has experience of this please help.

49

Re: Tip: full XHTML validation.

hi friends

I have an HTML like this

<div><embed src="http://widget-c5.slide.com/widgets/slideticker.swf" [^] type="application/x-shockwave-flash" quality="high" scale="noscale" salign="l" wmode="transparent" flashvars="cy=un&il=1&channel=360287970192958149&site=widget-c5.slide.com" style="width:600px;height:475px" name="flashticker" align="middle"></embed><div style="width:600px;text-align:left;"><a href="http://www.slide.com/pivot?cy=un&ad=0&id=360287970192958149&map=1" [^] target="_blank"><img src="http://widget-c5.slide.com/p1/360287970192958149/un_t014_v000_a000_f00/images/xslide1.gif" [^] border="0" ismap="ismap" /></a> <a href="http://www.slide.com/pivot?cy=un&ad=0&id=360287970192958149&map=2" [^] target="_blank"><img src="http://widget-c5.slide.com/p2/360287970192958149/un_t014_v000_a000_f00/images/xslide2.gif" [^] border="0" ismap="ismap" /></a></div></div>

but I am still unable to see correct view although am using TinyMce HTML editor with the configuration discussed above.

Any one knows where the problem lies ??


your response will be highly appreciated.

50

Re: Tip: full XHTML validation.

HI All,
I am new in TinyMCE, Could any one explain me that how to check user input has valid XHTML formate or not before save content into database.

I already use below code in my code but if i write invalid xhtml it does not show any message.

verify_html : true,
valid_elements : ""
+"a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name" ..............

I need the solution very urgently, Any kind of help is highly appreciated.

Thanks

Last edited by prantoor (2008-05-28 14:59:55)