Pranav Kumar
Pranav Kumar

Reputation: 87

TinyMCE4 - Issue with Parsing HTML Text

These are valid HTML which is not working in TinyMCE4 as per our expectation

<p><span style='text-decoration: line-through'>Test</span></p>

<span style="text-decoration: line-through;"><p>Test</p></span>

Here is the link of my fiddle . First HTML element is working fine but in second one strikethrough is not coming. Unable to undersatnd the reason.

Any lead or help will be appreciated. Thanks

Upvotes: 0

Views: 198

Answers (3)

Michael Fromin
Michael Fromin

Reputation: 13746

Your second HTML example is invalid HTML - a span is an inline element and cannot wrap a block element like a p tag. If you look at the HTML in the second instance its actually been reduced to:

<p>Test</p>

Your valid elements still need to be valid HTML.

Upvotes: 1

Dhaval
Dhaval

Reputation: 389

<span style="text-decoration: line-through;"><p>Test</p></span>

1) You have put the block level element(p) inside inline element(span), which is wrong by css specification.

2) You haven't added test rule for span[style], that's why it will fail test and remove that before rendering. updated fiddle

Upvotes: 1

kshetline
kshetline

Reputation: 13682

I've never worked with TinyMCE before, but it appears that a <p> element won't inherit style from a surrounding <span>.

Another thing, the valid_elements for the second textarea is different from the first. I'd guess that valid_elements for the second textarea would need p[style] added to allow a styled paragraph.

Upvotes: 1

Related Questions