I’d like to propose the following behavior for how kupu deals with changes in styles for nested divs and spans. I’m asking for feedback and a go-ahead to start working on the code for this.

Right now, HTML like the following example
(*)  <div><div><p>Hello world</p></div></div>
acts strangely in kupu. In Firefox, for example, the style of “Hello world” shows as “div” in the style pulldown menu; changing the style to <h1> gets rid of one level of nesting and changes the inner paragraph tag to <h1>: <div><h1>Hello world</h1></div>.

To me it seems like the standard behavior should instead be: “Changing the paragraph/block style of text, will eliminate all nested block styles for that text, and then set the block style.” So for instance, in (*), the block style for “Hello world” would appear as “Other: Nested styles.” Then, changing the block style for “Hello world” to <h1> would remove it from the <div><div><p> nesting, and then set the style to <h1>.

A second example:
<div>
<div class=”decoy”>
<p>Hello</p>
<p>nested</p>
<p>world</p>
</div>
</div>

Changing the style of “nested” to “h1″ would remove the nested tags around it, but not around “Hello” and “world”, resulting in:
<div>
<div class=”decoy”>
<p>Hello</p>
</div>
</div>
<h1>nested</h1>
<div>
<div class=”decoy”>
<p>world</p>
</div>
</div>

This change makes sense because the styles an administrator defines for kupu’s WYSIWYG, can all be used in top-level block tags without any nested divs. Rather than choosing which level of nesting is being modified, which levels of nesting are kept, etc., which is too confusing to implement well, it makes sense to set the standard behavior to a simple “Set the new style on a single, top-level block with no nesting.”

A similar principle would guide setting character styles with <span> tags (and I think this already happens this way). Below, the character style for “Crackle!” would appear as “Other: nested”.
<p>
<span class=”food”>
<span class=”cereal”>
<span class=”medium”>Snap!</span>
<span class=”soft”>Crackle!</span>
<span class=”loud”>Pop!</span>
</span>
</span>
<p>
Then, changing hte character style for “Crackle!” would remove all nested character styles around it and set a single-level style:
<p>
<span class=”food”>
<span class=”cereal”>
<span class=”medium”>Snap!</span>
</span>
</span>
<span class=”softer”>Crackle!</span>
<span class=”food”>
<span class=”cereal”>
<span class=”loud”>Pop!</span>
</span>
</span>
</p>

In the future maybe it’s possible to allow nesting through the WYSIWYG, but I think any changes of this sort would build on or override this default beahvior.

350 Responses to “Proposed behavior for nested divs and spans.”
  1. Why kupu uses the EditorOverride.css? And isn’t it possible for kupu to load its own css in editing mode?

  2. I specify the CSS-file in the HTML template file I am editing and that
    works. Tho, I haven’t thought of links but everything else works nice.

  3. Kupu does load its own css in editing mode, but the EditorOverride.css is
    loaded automatically by Firefox and is given a higher priority than other
    stylesheets.

  4. See https://bugzilla.mozilla.org/show_bug.cgi?id=300358 for some discussion
    of this issue.

  5. George Lee says:

    Thank you for all the helpful information on using the pulldown menu
    in the WYSIWYG to choose classes within a table.

    Some more questions:

    The other option is to stop using execCommand and
    do all the styling ourselves.

    Where in the kupu code should I look for where this would need to be
    changed? A “grep” shows a whole bunch of execCommand’s which certainly
    scares me.

  6. Right, I think that is why it hasn’t been looked at before.
    Basically we depend on execCommand to take a lot of the heavy lifting out
    of the Javascript, but it introduces a lot of problems as well.

  7. George Lee says:

    Are these documented in the Kupu documentation during the development process, to know why different changes were made for what incompatibilities?

  8. Thanks for post. Nice to see such good ideas.

  9. Thanks for the review! I want to say - thank you for this!
    d5a3.com - cool!!!!

  10. I bookmarked this link. Thank you for good job!

  11. Good to see you’re doing some research to fill in the ???

  12. OMG…totally!

  13. Wow, must have been a terrifying experience! I’m glad both you and Ashley were ok, and that nothing got stolen.I hoped you gace the superheroes a good tip

  14. I am going to be doing some anal only on my site just for you!!!!

  15. The article is ver good. Write please more

  16. http://spyhistory.ru - Какие нужные слова… супер, блестящая мысль

  17. I love these stories! Keep making them!

  18. Ух сколько, на досуге почитаем.

  19. Interesting site, but much advertisments on him. Shall read as subscription, rss.
    d5a3.com - go to my favorites!!!

  20. The richest low-down i be subjected to initiate perfectly here. Keep flourishing Thanks you

  21. анекдот в тему:
    Подруга рассказала:На чемпионате мира по легкой атлетике кенийский бегун на финише запутался в финишной ленточке и заодно выиграл Художественную гимнастику.

  22. Мне показалось или как это было:про Пугачевскую дочку: Чучело выросло и превратилось в Мяучело…

  23. Вчера подруга рассказала:Ему так везло в жизни, что даже”Интернет”, у него был, “Интерда”.