<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Symphonious &#187; Editors</title> <atom:link href="http://www.symphonious.net/category/code-and-geek-stuff/editors/feed/" rel="self" type="application/rss+xml" /><link>http://www.symphonious.net</link> <description>Living in a state of accord.</description> <lastBuildDate>Wed, 25 Jan 2012 21:25:34 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>contentEditable in Mobile WebKit Update</title><link>http://www.symphonious.net/2011/06/10/contenteditable-in-mobile-webkit-update/</link> <comments>http://www.symphonious.net/2011/06/10/contenteditable-in-mobile-webkit-update/#comments</comments> <pubDate>Fri, 10 Jun 2011 18:30:03 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Code and Geek Stuff]]></category> <category><![CDATA[Editors]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1534</guid> <description><![CDATA[Joyously, it looks like iOS 5 fixes the issues with contentEditable not working correctly in Mobile WebKit. A patch has landed in TinyMCE to enable the editor to work there. Great news. Hopefully the changes to WebKit can flow through to Android as well.]]></description> <content:encoded><![CDATA[<p> Joyously, it looks like iOS 5 fixes the <a
href="http://www.symphonious.net/2010/09/13/contenteditable-in-mobile-webkit/">issues with contentEditable not working correctly in Mobile WebKit</a>. A <a
href="https://github.com/tinymce/tinymce/commit/77d9e5577d6ad13bcb0512608359837f31e1e7b2">patch has landed in TinyMCE</a> to enable the editor to work there. Great news.</p><p> Hopefully the changes to WebKit can flow through to Android as well.</p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2011/06/10/contenteditable-in-mobile-webkit-update/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Canvas-based Editors</title><link>http://www.symphonious.net/2010/09/29/canvas-based-editors/</link> <comments>http://www.symphonious.net/2010/09/29/canvas-based-editors/#comments</comments> <pubDate>Wed, 29 Sep 2010 09:05:46 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Accessibility]]></category> <category><![CDATA[Code and Geek Stuff]]></category> <category><![CDATA[Editors]]></category> <category><![CDATA[JavaScript]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1442</guid> <description><![CDATA[Over the weekend I went to JSConf EU and every time I met someone and told them I was working on TinyMCE the conversation rapidly veered off into why contentEditable is too hard/buggy to work with and how it would be so much better if it was all built on top of canvas or just [...]]]></description> <content:encoded><![CDATA[<p> Over the weekend I went to JSConf EU and every time I met someone and told them I was working on TinyMCE the conversation rapidly veered off into why contentEditable is too hard/buggy to work with and how it would be so much better if it was all built on top of canvas or just used the DOM with a custom selection API. This matched the thinking throughout the conference that it doesn’t really matter how messed up browsers are because JavaScript can be used to work around it.</p><p> What disturbs me is that incredibly few people realise just how much work is involved in implementing caret and selection handling correctly, let alone most of the other infrastructure provided by contentEditable. I wound up talking to <a
href="http://twitter.com/novemberborn">Mark Wubben</a> who actually does have a pretty good idea &#8211; he implemented a DOM based selection system for the <a
href="http://xopus.com/">Xopus editor</a>. Needless to say he had quite the war story to tell, but despite doing what sounded like a very impressive bit of work, the selection code is still very broken in a couple of key ways: accessibility and international inputs<a
class="footnote" id="footlink1:1285748951881" href="#footnote1:1285748951881">1</a>.</p><h3> Accessibility</h3><p> Accessibility support was my first response to anyone suggesting using canvas as an editor &#8211; no-one had considered it. If you play around with a screen reader for a while, you start to realise just how important the selection is to accessibility. Selecting text generally causes it to be read out for example. It’s not just screen readers either, screen magnifiers will move the screen along to keep up with the caret, ensuring the user can see what they’re typing. If the caret is fake, none of these features will work and the editor becomes inaccessible.</p><h3> International Inputs</h3><p> Even I’d forgotten about this one, but it’s likely an even bigger problem to solve than accessibility. The array of input devices, keyboard shortcuts and other ways that people input characters is pretty amazing when you start exploring it. People in English speaking countries don’t tend to notice this because they have quite a small number of characters in use which all fit on the keyboard. Even Western European countries have the vast majority of characters required available with a direct key sequence. However there are far more complex types of inputs around. The simplest of these is the use of “dead keys” such as acute on a US or British keyboard. To type é actually takes multiple keystrokes on a UK Mac keyboard:</p><ol><li> Option-e. This is a dead-key so only a placeholder appears in the output (<img
alt="Placeholder for acute shown with a yellow background." src="http://www.symphonious.net/wp-content/uploads/2010/09/acutePlaceholder.png" />).</li><li> e. Now the e-acute character actually appears and is inserted into the document content.</li></ol><p> Not to pick on Xopus but at least in Firefox on Mac, I can’t type é at all in the editor because it doesn’t correctly support dead-keys<a
class="footnote" id="footlink2:1285750195458" href="#footnote2:1285750195458">2</a>.</p><p> Asian languages can have even more keystrokes required to type a character and much more complex input methods that to be usable, require changes to the caret, underlining content etc. Plus the methods and UI is different on different OS’s. While users can handle some variation, they shouldn’t have to learn a whole new input method to be able to use your application<a
class="footnote" id="footlink3:1285750501513" href="#footnote3:1285750501513">3</a>.</p><h3> The Way Forward</h3><p> Instead of trying to work around the limitations in contentEditable we need to be pushing browser vendors to fix it and make it usable.  Where the current APIs aren’t good enough, standardise better ones &#8211; we’re dealing with multiple incompatible APIs already so the backwards compatibility problems are limited. This needs to be a focus so that we don’t wind up in a world where online editors only work for fully-abled, English speaking users. Most if not all of what’s required is already there, it just needs some love and care to remove the bugs and better handle corner-cases.</p><p
class="footnote"> <a
href="#footlink1:1285748951881" id="footnote1:1285748951881">1</a> &#8211; There is some <a
href="http://lists.w3.org/Archives/Public/public-canvas-api/2010JulSep/0040.html">good discussion of the complexities involved here from the W3C canvas list</a> as they struggle with the accessibility implications of canvas.<a
class="footnotereturn" href="#footlink1:1285748951881">↩</a></p><p
class="footnote"> <a
href="#footlink2:1285750195458" id="footnote2:1285750195458">2</a> &#8211; and to be completely fair, EditLive! fails to paint the placeholder, though the character does type correctly. <a
class="footnotereturn" href="#footlink2:1285750195458">↩</a></p><p
class="footnote"> <a
href="#footlink3:1285750501513" id="footnote3:1285750501513">3</a> &#8211; So no, <a
href="http://code.google.com/apis/ajaxlanguage/documentation/referenceKeyboard.html">Google Virtual Keyboard</a> is not a real solution, however good an idea it is for people using things like internet kiosks with foreign keyboard layouts. Besides, would you like to be stuck typing only with your mouse? <a
class="footnotereturn" href="#footlink3:1285750501513">↩</a></p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/29/canvas-based-editors/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>FireFox is Picky About Clipboard HTML, Java is Sloppy</title><link>http://www.symphonious.net/2010/09/21/firefox-is-picky-about-clipboard-html-java-is-sloppy/</link> <comments>http://www.symphonious.net/2010/09/21/firefox-is-picky-about-clipboard-html-java-is-sloppy/#comments</comments> <pubDate>Tue, 21 Sep 2010 10:06:38 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Code and Geek Stuff]]></category> <category><![CDATA[Editors]]></category> <category><![CDATA[Java]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1436</guid> <description><![CDATA[Windows uses a particularly ugly format for putting HTML on the clipboard, called CF_HTML. Basically, it adds a header to the content with pretty useless information essentially declaring how many bytes in the header (and yes you have to pad the byte counts since they themselves are included in the count). The problem between Java [...]]]></description> <content:encoded><![CDATA[<p> Windows uses a particularly ugly format for putting HTML on the clipboard, called <a
href="http://msdn.microsoft.com/en-us/library/aa767917(VS.85).aspx">CF_HTML</a>. Basically, it adds a header to the content with pretty useless information essentially declaring how many bytes in the header (and yes you have to pad the byte counts since they themselves are included in the count).</p><p> The problem between Java and Firefox is that Java always sets the ‘StartHTML’ and ‘EndHTML’ fields to -1 to indicate there is no context and Firefox will refuse to paste HTML from the clipboard if StartHTML or EndHTML is set to -1. As such, if you copy HTML from Java it will be impossible to paste into Firefox. It works perfectly with Word and IE.</p><p> I’m not 100% clear on whether the clipboard data Java is generating is valid but I consider it a bug in both Java and Firefox &#8211; Java for not being strict about what it outputs and Firefox for being too strict about what it accepts. Bug reports shall be made<a
class="footnote" id="footlink1:1285065920040" href="#footnote1:1285065920040">1</a>.</p><p> On the Java side, the problem is in sun.awt.windows.WDataTrasferer.HTMLSupport.convertToHTMLFormat which sadly is Sun-specific, private and loaded from the bootclasspath so a little difficult to work around. There is however a <a
href="http://www.peterbuettner.de/develop/javasnippets/clipHtml/index.html">nasty, but effective, hack from Peter Buettner</a> which does indeed get around the problem. I’ve chosen to avoid the need to copy/paste HTML in this particular application but the approach is worth saving a reference to in case it’s needed later.</p><p
class="footnote"> <a
href="#footlink1:1285065920040" id="footnote1:1285065920040">1</a> &#8211; <a
href="https://bugzilla.mozilla.org/show_bug.cgi?id=598289">Bug 598289</a> with Mozilla and there’s a <a
href="/firefoxPasteBug.zip">simple test case available</a>. The bug report has also been filed with Oracle and is <a
href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6986348">now available in the bug parade</a>. <a
class="footnotereturn" href="#footlink1:1285065920040">↩</a></p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/21/firefox-is-picky-about-clipboard-html-java-is-sloppy/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>The Importance and Practicalities of P Tags</title><link>http://www.symphonious.net/2010/09/13/the-importance-and-practicalities-of-p-tags/</link> <comments>http://www.symphonious.net/2010/09/13/the-importance-and-practicalities-of-p-tags/#comments</comments> <pubDate>Mon, 13 Sep 2010 14:56:59 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Code and Geek Stuff]]></category> <category><![CDATA[Editors]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1425</guid> <description><![CDATA[The issue of P tags vs BR tags comes up very often and since my response to it has become a series of 5 articles, this post is here to provide a convenient index to point to in future. General Primer Why P Tags are Your Friends P Tags in Word Solutions for Specific Situations [...]]]></description> <content:encoded><![CDATA[<p> <img
alt="" src="http://www.symphonious.net/wp-content/uploads/2010/09/ParagraphMarker_1786812506017956051.png" height="113" width="84" style=" float: right;" />The issue of P tags vs BR tags comes up very often and since my response to it has become a series of 5 articles, this post is here to provide a convenient index to point to in future.</p><h4> General Primer</h4><ul><li> <a
href="http://www.symphonious.net/2010/09/07/why-p-tags-are-your-friends/">Why P Tags are Your Friends</a></li><li> <a
href="http://www.symphonious.net/2010/09/08/p-tags-in-word/">P Tags in Word</a></li></ul><h4> Solutions for Specific Situations</h4><ul><li> <a
href="http://www.symphonious.net/2010/09/09/p-tags-and-single-line-fields/">P Tags and Single Line Fields</a></li><li> <a
href="http://www.symphonious.net/2010/09/10/p-tags-and-flash/">P tags and Flash</a></li><li> <a
href="http://www.symphonious.net/2010/09/02/the-email-and-p-myth/">The Email and P Myth</a></li></ul>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/13/the-importance-and-practicalities-of-p-tags/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>contentEditable in Mobile WebKit</title><link>http://www.symphonious.net/2010/09/13/contenteditable-in-mobile-webkit/</link> <comments>http://www.symphonious.net/2010/09/13/contenteditable-in-mobile-webkit/#comments</comments> <pubDate>Mon, 13 Sep 2010 13:12:21 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Code and Geek Stuff]]></category> <category><![CDATA[Content Management]]></category> <category><![CDATA[Editors]]></category> <category><![CDATA[JavaScript]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1379</guid> <description><![CDATA[What Is contentEditable? JavaScript editors are all fundamentally based on a technology called contentEditable which makes a part of the web page become editable by the user. While there is a lot of functionality that’s usually bundled under the “contentEditable” title, there are a few core parts which are essential for a browser to support [...]]]></description> <content:encoded><![CDATA[<h3> What Is contentEditable?</h3><p> JavaScript editors are all fundamentally based on a technology called contentEditable which makes a part of the web page become editable by the user. While there is a lot of functionality that’s usually bundled under the “contentEditable” title, there are a few core parts which are essential for a browser to support correctly<a
id="footlink1:1278939007857" class="footnote" href="#footnote1:1278939007857">1</a>:</p><ul><li> Selection &#8211; allowing the user to position a text caret in the content and select various parts of it.</li><li> Content entry and deletion &#8211; allowing the user to type basic text and to delete selected content.</li></ul><p> Without these two key components of contentEditable it’s impossible to create a high-quality, WYSIWYG editor with JavaScript. Despite some variations in how things work, this functionality is available on all common desktop browsers and has been for quite a few years.</p><h3> The Problem</h3><p> On mobile WebKit, for both iOS and Android, the basics of contentEditable support aren’t working correctly. The problem is two fold:</p><ol><li> While the user can position a text caret and change the selection, the actual caret (the blinking vertical line), never renders so users don’t know where their typing will appear.</li><li> The on-screen keyboard doesn’t appear when the caret is placed in an editable section. On devices without a real keyboard it’s then impossible to type.</li></ol><p> WebKit is actually surprisingly close to getting this working, with a lot of the underpinning functionality appearing to work but these two issues prevent editors from being usable<a
class="footnote" id="footlink2:1278940183669" href="#footnote2:1278940183669">2</a>.</p><h3> Why Does It Matter?</h3><p> While geeks may feel at home writing HTML code by hand or using a markup language like markdown or textile, non-technical users find it significantly easier to use a WYSIWYG editor. Currently, it’s not possible to offer such an editor on mobile devices due to the lack of contentEditable support.</p><p> Even worse is that many sites are already using a WYSIWYG editor which then prevents users on a mobile devices from contributing content &#8211; even when the rest of the site works perfectly. With mobile browsers improving so rapidly, most sites now work without needing special adjustments so the lack of contentEditable support is one of the few major incompatibilities.</p><h3> How Might it be Fixed?</h3><p> To be honest, I don’t know and don’t have the experience with the code involved to find the source of the problem and fix it. However, with both the source to WebKit and Android being open, hopefully someone does have the experience knowledge and a bit of time to solve this.</p><p> With WebKit being the browser engine of choice on so many devices,  the fix may even flow around to a bunch of mobile OS’s.</p><h3> Relevant Bug Reports</h3><h4> Android</h4><ul><li> <a
href="http://code.google.com/p/android/issues/detail?id=9515">9515 &#8211; No onscreen keyboard when inside a contentEditable area</a></li><li> <a
href="http://code.google.com/p/android/issues/detail?id=9513">9513 &#8211; Unable to select text in contentEditable field</a></li><li> <a
href="http://code.google.com/p/android/issues/detail?id=9512">9512 &#8211; contentEditable field shows no caret</a></li><li> For some background see also: <a
href="http://code.google.com/p/android/issues/detail?id=8253">8253 &#8211; isContentEditable returns true even if the browser doesn’t really support it</a></li></ul><h4> iPhone</h4><p> Apple don’t provide a public bug list, but this issue is logged as Radar #8399288.  Apple do use the number of bug reports for an issue to adjust priority so if this issue is important to you, please do log an issue and cite Radar #8399288.</p><h4> Others</h4><p> I don’t currently have bug reports against other systems but would appreciate pointers to any relevant bugs for other systems (whether they use WebKit or not) so they can be tracked.</p><p
class="footnote"> <a
id="footnote1:1278939007857" href="#footlink1:1278939007857">1</a> &#8211; The other major component is the execCommand function which provides built-in implementations of a number of common commands like bold, italic, etc. While it’s certainly useful to have these, they can generally be replaced by pure-JavaScript implementations without sacrificing quality or performance. <a
class="footnotereturn" href="#footlink1:1278939007857">↩</a></p><p
class="footnote"> <a
href="#footlink2:1278940183669" id="footnote2:1278940183669">2</a> &#8211; I’m unaware of any mobile browser that supports contentEditable well enough to make an editor feasible. In fact, WebKit appears to be the closest to that milestone. <a
class="footnotereturn" href="#footlink2:1278940183669">↩</a></p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/13/contenteditable-in-mobile-webkit/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>P Tags and Flash</title><link>http://www.symphonious.net/2010/09/10/p-tags-and-flash/</link> <comments>http://www.symphonious.net/2010/09/10/p-tags-and-flash/#comments</comments> <pubDate>Fri, 10 Sep 2010 13:34:43 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Editors]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1418</guid> <description><![CDATA[One of the most difficult situations to work with is when your output needs to be rendered using Flash. The HTML support in Flash is absolutely horrendous &#8211; worse even than in most email clients. Contrary to popular belief, Flash does support P tags. You will however need to ensure the text field is set [...]]]></description> <content:encoded><![CDATA[<p> <img
alt="" src="http://www.symphonious.net/wp-content/uploads/2010/09/ParagraphMarker_1786812506017956051.png" width="84" height="113" style=" float: right;" />One of the most difficult situations to work with is when your output needs to be rendered using Flash. The HTML support in Flash is absolutely horrendous &#8211; worse even than in most email clients. Contrary to popular belief, <a
href="http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&#38;file=00000930.html">Flash </a><em><a
href="http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&#38;file=00000930.html">does </a></em><a
href="http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&#38;file=00000930.html">support P tags</a>. You will however need to ensure the text field is set to multiline. The BR tag is also only supported in multiline fields. The problem most people hit is that Flash doesn’t support the margin-top and margin-bottom attributes so you can’t get rid of the blank line between paragraphs.</p><p> The list of HTML tags supported by flash is <em>very</em> short, so you will need to disable most of the editor functionality, however since flash does support things like bullet lists, for the most intuitive editing experience, it’s best to use P tags to break up the paragraphs rather than BRs.</p><p> Instead of avoiding P tags to avoid the extra white space, use a two part approach.  In the editor, use P tags for paragraphs, and include the CSS:</p><pre>
p { margin-top: 0; margin-bottom: 0; }
</pre><p> Then before passing the HTML into Flash, filter it to replace &#60;p&#62; with &#60;span&#62;<a
class="footnote" id="footlink1:1283791519502" href="#footnote1:1283791519502">1</a>. Store the original content, with the P tags, in the database so that they are still present when the user goes back to edit existing content. You will need to disable any formatting that applies to the paragraph element &#8211; most notably alignment. There is no way to support alignment without a block tag and P is the only available block tag within Flash. If you need alignment support, you will have to use P tags and put up with the extra white space.  Lists will still work correctly<a
class="footnote" id="footlink2:1283791760407" href="#footnote2:1283791760407">2</a> because the editor is working with the P tags, and the Flash renderer</p><p> In any case for Flash you will need to disable a lot of functionality to ensure only the supported elements are inserted. Essentially, bold, italic, underline, font face, font size and font color, images and hyperlinks. There are a few other CSS properties supported, but still very limited.</p><p> The limitations in Flash do provide significant challenges to providing a powerful and intuitive HTML editor, but the user experience will almost always be better if the editor works <em>with</em> P tags, and then they are replaced before rendering, using CSS within the editor to ensure consistent rendering. In all cases, it is vitally important to heavily restrict the functionality that is available in the editor. If at all possible, avoiding the need to render HTML within Flash is usually the best option, but not always feasible.</p><p
class="footnote"> <a
href="#footlink1:1283791519502" id="footnote1:1283791519502">1</a> &#8211; Flash 9 doesn’t support the DIV tag, otherwise that would be the ideal alternative. <a
class="footnotereturn" href="#footlink1:1283791519502">↩</a></p><p
class="footnote"> <a
href="#footlink2:1283791760407" id="footnote2:1283791760407">2</a> &#8211; tables are not supported by Flash anyway<a
class="footnotereturn" href="#footlink2:1283791760407">↩</a></p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/10/p-tags-and-flash/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>P Tags and Single Line Fields</title><link>http://www.symphonious.net/2010/09/09/p-tags-and-single-line-fields/</link> <comments>http://www.symphonious.net/2010/09/09/p-tags-and-single-line-fields/#comments</comments> <pubDate>Thu, 09 Sep 2010 16:03:24 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Editors]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1415</guid> <description><![CDATA[One of the common reasons people want to avoid P tags in content is because the field is designed to hold just a single paragraph, so having multiple P tags inside the content would break the template layout when it’s rendered. Usually the template renders the content as something like: &#60;p&#62;&#60;%= fieldContent %&#62;&#60;/p&#62; In that [...]]]></description> <content:encoded><![CDATA[<p> <img
alt="" width="84" height="113" src="http://www.symphonious.net/wp-content/uploads/2010/09/ParagraphMarker_1786812506017956051.png" style=" float: right;" />One of the common reasons people want to avoid P tags in content is because the field is designed to hold just a single paragraph, so having multiple P tags inside the content would break the template layout when it’s rendered.  Usually the template renders the content as something like:</p><pre>
&#60;p&#62;&#60;%= fieldContent %&#62;&#60;/p&#62;
</pre><p> In that case, where the output is the only thing within the paragraph, the best solution is to leave the paragraph tags in editor content and remove them from the rendering template. That gives the editor the context it needs to work well and avoids a lot of potential problems with rendering the content. If however, you’re including some extra content in the same paragraph then the situation is more difficult, e.g. your rendering template is more like:</p><pre>
&#60;p&#62;Summary: &#60;%= fieldContent%&#62;&#60;/p&#62;
</pre><p> In this case, you need to include the P tags within the rendering template and need to ensure that any functionality in the editor which requires inserting a block tag is disabled.  Many people think that just switching to insert BR on enter will achieve that, but it’s quite a long way short. For example, if the user creates a list, the template would output:</p><pre>
&#60;p&#62;Summary: &#60;ol&#62;&#60;li&#62;Content&#60;/li&#62;&#60;/ol&#62;&#60;/p&#62;
</pre><p> which is invalid. Similarly since alignment must be on a block tag, it would create:</p><pre>
&#60;p&#62;Summary: &#60;div style=”text-align: center;”&#62;Content&#60;/div&#62;&#60;/p&#62;
</pre><p> which is also invalid. Headings, tables, margins, blockquotes and many other functions will cause these problems. Instead of trying to disable the problematic things, it’s much simpler to only enable the inline formatting options that you need &#8211; it should be very limited since you’re only editing a small snippet of content:</p><ul><li> Bold</li><li> Italic</li><li> Underline</li><li> Strike-through</li><li> Font face</li><li> Font size</li><li> Font color</li><li> Background color</li><li> Superscript</li><li> Subscript</li><li> Images</li><li> Hyperlinks</li></ul><p> Depending on your editor, there may be a couple of other functions that can work, but most things will need to be disabled. Notably, all these functions work regardless of whether there’s a P tag present or not, because they work “inline”, directly on the text.</p><p> Once you’ve restricted yourself to these functions, it’s usually ok to switch the enter key to insert a BR instead of a P, but carefully consider whether having line breaks in the content makes sense with your template anyway.  If you want users to be able to insert multiple paragraphs, you should design your template to let them use P tags rather than using BR as a substitute. Consider using a plugin to disable the enter key altogether since the field is designed for a single line response.</p><p> Finally, using a plugin or validation when the user submits, check that the content has only one paragraph and isn’t too long to fit within your template. With many editors it will be better to work with the content inside a P tag within the editor and then use JavaScript or server-side filtering to remove them when saving the content.</p><p> The bottom line is that when restricting content to a single paragraph, you should ensure that all functionality which works at the paragraph level is disabled in the editor as it cannot be made to function correctly. You should also carefully consider whether users should be allowed to insert line breaks in the content and if they are, whether these are really paragraphs and users would be better served with a slight change to the rendering template, allowing them to use the full functionality of the editor.</p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/09/p-tags-and-single-line-fields/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>P Tags in Word</title><link>http://www.symphonious.net/2010/09/08/p-tags-in-word/</link> <comments>http://www.symphonious.net/2010/09/08/p-tags-in-word/#comments</comments> <pubDate>Wed, 08 Sep 2010 13:53:04 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Editors]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1412</guid> <description><![CDATA[One thing that many people don’t realise, is that the distinction between paragraphs and line breaks isn’t unique to HTML. In fact, it’s a distinction that people have been working with quite happily for a very long time &#8211; Microsoft Word has supported the two concepts right from it’s very first version. With the more [...]]]></description> <content:encoded><![CDATA[<p> <img
alt="" width="84" height="113" src="http://www.symphonious.net/wp-content/uploads/2010/09/ParagraphMarker_1786812506017956051.png" style=" float: right;" />One thing that many people don’t realise, is that the distinction between paragraphs and line breaks isn’t unique to HTML. In fact, it’s a distinction that people have been working with quite happily for a very long time &#8211; Microsoft Word has supported the two concepts right from it’s very first version. With the more recent versions of Word, the default paragraph spacing is zero, so line breaks and paragraphs look the same, even though there is an important semantic difference. You can still see the difference if you show the non-printing characters:</p><p> <img
alt="Example from word showing a paragraph and line ending." src="http://www.symphonious.net/wp-content/uploads/2010/09/wordParagraphExample_3354597428978381461.png" /></p><p> The first line is a paragraph, note that it ends with the invisible paragraph marker character (¶). The second line ends with a line break character instead (¬) so the end of the line is <em>not</em> the end of the paragraph. There are actually only two paragraphs in this document. You can see this in action when we position the caret at the end of the text and apply a heading style.</p><p> <img
alt="Example of Word applying a heading style to a complete paragraph." src="http://www.symphonious.net/wp-content/uploads/2010/09/wordApplyingHeading_6928726641640170600.png" /></p><p> The heading style is a paragraph level style, so it applies to the entire paragraph, even though there’s a line break. In fact, if you save that original document as HTML, you get the structure:</p><pre>
&#60;p&#62;Paragraph 1&#60;/p&#62;
&#60;p&#62;First line of paragraph 2&#60;br&#62;
Second line of paragraph 2&#60;/p&#62;
</pre><p> Just like any good HTML editor would create. You can try this yourself in Word, typing enter will create a new paragraph, typing shift-enter will instead insert a line break. The same keystrokes apply to most HTML editors as well.</p><h2> Rendering Differences</h2><p> When copying and pasting content from Word into a HTML editor, it’s possible that there will be extra space added between each paragraph. This is a result of having different settings for what Word calls paragraph spacing (called margin-top and margin-bottom in HTML/CSS).</p><p> With the more recent versions of Word (last 10 years worth on Windows, last 5 years or so on Mac) the default is to have no paragraph spacing which effectively makes a paragraph marker and a line break (P and BR) look the same, simply moving to the line immediately below<a
class="footnote" id="footlink1:1287657038154" href="#footnote1:1287657038154">1</a>.  In any case, in browsers the default is to apply a 12pt paragraph spacing through the CSS margin-top and margin-bottom attributes which are set in the browser&#39;s default stylesheet.</p><p> So to get the same rendering as Word, you should keep using paragraphs but add the CSS:</p><p> p { margin-top: 0; margin-bottom: 0; }</p><p> Make sure you add it both to the rendered page and to the styles used by the editor. There is more detail on this and other ways to make HTML behave more like Word in the Ephox article, <a
href="http://liveworks.ephox.com/hints-tips/making-editlive-content-behave-more-like-word">Making EditLive! Content Behave More Like Word</a>, which is applicable to all editors.</p><p
class="footnote"> <a
href="#footlink1:1287657038154" id="footnote1:1287657038154">1</a> &#8211; I&#39;ve never quite understood why they made this change as it has led to users inserting a new paragraph by pressing enter twice which effectively adds an empty paragraph to get the paragraph spacing they want. <a
class="footnotereturn" href="#footlink1:1287657038154">↩</a></p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/08/p-tags-in-word/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Why P Tags are Your Friends</title><link>http://www.symphonious.net/2010/09/07/why-p-tags-are-your-friends/</link> <comments>http://www.symphonious.net/2010/09/07/why-p-tags-are-your-friends/#comments</comments> <pubDate>Tue, 07 Sep 2010 13:31:19 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Editors]]></category> <category><![CDATA[Email]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1408</guid> <description><![CDATA[A few days ago I talked about the Email and P Myth, but didn’t explain why it’s so frustrating for editor developers that people keep wanting to use BR tags instead of P tags. It’s not actually because we’re fastidious about using the correct semantic HTML, though obviously we do recommend that, it’s because a [...]]]></description> <content:encoded><![CDATA[<p> <img
alt="" src="http://www.symphonious.net/wp-content/uploads/2010/09/ParagraphMarker_387764802665706626.png" style=" float: right;" />A few days ago I talked about <a
href="http://www.symphonious.net/2010/09/02/the-email-and-p-myth/">the Email and P Myth</a>, but didn’t explain why it’s so frustrating for editor developers that people keep wanting to use BR tags instead of P tags. It’s not actually because we’re fastidious about using the correct semantic HTML, though obviously we do recommend that, it’s because a lot of concepts that user’s expect simply aren’t possible to implement sensibly if you don’t use the correct paragraph level elements.</p><p> Take for example, a simple function like alignment. In Word and any other sensible editor, when you click the right align button, the current paragraph becomes aligned right. Which pretty clearly highlights the problem &#8211; if you don’t have paragraphs, what should become aligned? Typically what happens is the entire document, being one paragraph, gets aligned right and user’s unsurprisingly complain. So why not just change the alignment of the current line? Think about it in HTML terms, if you have:</p><pre>
Line 1&#60;br&#62;
Line 2
</pre><p> Where do you apply the text-align style exactly? You can’t apply text-align to inline elements so:</p><pre>
&#60;span style=”text-align: right;”&#62;Line 1&#60;/span&#62;&#60;br&#62;
Line 2
</pre><p> doesn’t work. Further, we’ve been told that inserting P tags isn’t allowed, so we can’t just make it:</p><pre>
&#60;p style=”text-align: right;”&#62;Line 1&#60;/p&#62;
Line 2
</pre><p> because that would introduce “extra whitespace”<a
class="footnote" id="footlink1:1283780342216" href="#footnote1:1283780342216">1</a>. So the only option is to insert a DIV tag which makes the HTML structure quite complex. DIVs aren’t just a meaningless element, they add structure to the document and the editor can’t tell which DIVs are important structure and which are just pretending to be paragraphs<a
class="footnote" id="footlink2:1283780468469" href="#footnote2:1283780468469">2</a>.</p><p> This problem crops up in a huge number of different places &#8211; applying headings, style classes, lists, indenting and more. All these special cases need to be handled, adding to the download size for the editor and reducing performance &#8211; not to mention taking up a huge amount of development time that could have been put into something more useful.</p><p> WYSIWYG editors do such a good job of hiding the way that HTML and CSS work, that people often forget that in the end we’re still trying to generate high quality, standards-compliant HTML output. We’re limited by what those standards and browsers can actually do, so removing important concepts like paragraphs makes it incredibly difficult to create an editor that works intuitively.</p><p> Ultimately, it’s not that we developers don’t want to support your use case, it’s just that the restrictions you’re asking us to abide by dramatically reduce our ability to deliver a high quality authoring experience.</p><p
class="footnote"> <a
href="#footlink1:1283780342216" id="footnote1:1283780342216">1</a> &#8211; which can and should be removed using CSS in the first place <a
class="footnotereturn" href="#footlink1:1283780342216">↩</a></p><p
class="footnote"> <a
href="#footlink2:1283780468469" id="footnote2:1283780468469">2</a> &#8211; remembering that what was once an unimportant DIV may become important at some point because of a change to scripts or CSS that the editor isn’t aware of <a
class="footnotereturn" href="#footlink2:1283780468469">↩</a></p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/07/why-p-tags-are-your-friends/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>The Email and P Myth</title><link>http://www.symphonious.net/2010/09/02/the-email-and-p-myth/</link> <comments>http://www.symphonious.net/2010/09/02/the-email-and-p-myth/#comments</comments> <pubDate>Thu, 02 Sep 2010 13:46:20 +0000</pubDate> <dc:creator>Adrian Sutton</dc:creator> <category><![CDATA[Code and Geek Stuff]]></category> <category><![CDATA[Editors]]></category> <category><![CDATA[Email]]></category> <guid
isPermaLink="false">http://www.symphonious.net/?p=1403</guid> <description><![CDATA[One of the greatest frustrations for anyone who develops an HTML editor is the constant supply of people who are convinced they want to use BR tags instead of P tags. Most of these are just people who don’t want “double spacing” and they’re happy once you give them the magical CSS incantation: p { [...]]]></description> <content:encoded><![CDATA[<p> One of the greatest frustrations for anyone who develops an HTML editor is the constant supply of people who are convinced they want to use BR tags instead of P tags. Most of these are just people who don’t want “double spacing” and they’re happy once you give them the magical CSS incantation:</p><pre>
p {
  margin-top: 0;
  margin-bottom: 0;
}
</pre><p> The other group however are people writing HTML emails who insist that P tags are completely incompatible with some email clients and cause rendering problems. At one point it seems that Yahoo! Mail really did strip them entirely but now it just applies a different default CSS styling (ironically, the magical CSS above that removes the extra spacing). So if you naively use P without specifying the padding you want, some clients will display a blank line between paragraphs, others, notably Yahoo!, will push all the lines immediately under each other. The solution is of course the opposite magical CSS incantation:</p><pre>
p {
  margin-top: 0;
  margin-bottom: 1em;
}
</pre><p> Solved right? Nope. This runs straight into the <em>where the heck do I define styles? </em>problem. In HTML, it should be:</p><pre>
&#60;html&#62;
&#60;head&#62;
&#60;style&#62;
p {
  margin-top: 0;
  margin-bottom: 1em;
}
&#60;/style&#62;
&#60;/head&#62;
&#60;body&#62;
…
&#60;/body&#62;
&#60;/html&#62;
</pre><p> However while this works in some clients, it has no effect in most. Instead, the common wisdom is to move the style tag into the body tag:</p><pre>
&#60;html&#62;
&#60;head&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;style&#62;
p {
  margin-top: 0;
  margin-bottom: 1em;
}
&#60;/style&#62;
…
&#60;/body&#62;
&#60;/html&#62;
</pre><p> Which works almost everywhere. Enter GMail. GMail <em>never </em>respects the style tag, only inline styles. So now you need to write your paragraphs as:</p><pre>
&#60;p style=”margin-top: 0; margin-bottom: 1em;”&#62;…&#60;/p&#62;
</pre><p> Thankfully you can use the margin shorthand if you know what you want the left and right margins to be as well:</p><pre>
&#60;p style=”margin: 0 0 1em 0;”&#62;…&#60;/p&#62;
</pre><p> I would strongly recommend using embedded styles while editing and then just use post processing to inline all the styles &#8211; <a
href="http://premailer.dialect.ca">Premailer</a> can do that for you.</p><p> As far as I can tell, there is no need to avoid P tags in email anymore and sampling a number of emails from various clients that happened to be in my inbox, they turned out to appear in emails from a few different clients though that’s far from scientific and it was still intermingled with a lot of &#60;br&#62; and &#60;div&#62;&#60;br&#62;&#60;/div&#62; hacks. I would be very keen to hear from anyone who knows of an email client that cannot be made to render P tags correctly.</p><p> With a bit of luck we may be able to start moving away from the horrific abuses of &#60;br&#62; tags…</p>]]></content:encoded> <wfw:commentRss>http://www.symphonious.net/2010/09/02/the-email-and-p-myth/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
