Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent | Mozilla FireFox (3.6) ContentEditable -- applies CSS to the editable container instead of it's content
    primarykey
    data
    text
    <p>I have some page with something like this:</p> <pre><code>&lt;div id="editor" contenteditable="true"&gt;SomeText&lt;/div&gt; </code></pre> <p>I have an selfmade JS editor which actually issues </p> <pre><code>document.execCommand(some_command,false,optional_value); </code></pre> <p>when user presses a button in the editor. (For example I have plain, simple [Bold] button).</p> <p>Everything is fine as long as I apply editing to part of "SomeText". For example selecting "Text" with mouse and pressing [Bold] button (which leads to document.execCommand("bold",false,false);) will produce:</p> <pre><code>&lt;div id="editor" contenteditable="true"&gt;Some&lt;span style="some-css-here"&gt;Text&lt;/span&gt;&lt;/div&gt; </code></pre> <p>but when I select entire content of the div ("SomeText" in this example) and press [Bold] in my editor, FF will not produce expected</p> <pre><code>&lt;div id="editor" contenteditable="true"&gt;&lt;span style="some-css-here"&gt;SomeText&lt;/span&gt;&lt;/div&gt; </code></pre> <p>but rather</p> <pre><code>&lt;div id="editor" contenteditable="true" style="some-css-here"&gt;SomeText&lt;/div&gt; </code></pre> <p>Notice the "style" attribute went into the editable div!</p> <p>Why this makes a difference to me? --It's because after editing is done I would like to take the content of the editable div, along with all styles, formating etc and further use it on the page. But I can't -- all the styling now sits inside the div. A solution when I would be advised to extract styles from the div is not acceptable -- the div during its life takes a lot of styles from other active elements of the page (heavy jQuery usage)</p> <p><strong>So in brief: How to tell FF to never touch editable div and apply all styling to its inner contents only?</strong></p> <p>Sincere thanks for you time. (just pulled last of my hair, browsing FF dev site along with many others(((( )</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload