On Mon, Sep 8, 2008 at 9:12 AM, Alexander Back <[EMAIL PROTECTED]>wrote:
> How do you like this idea: implementing a method that returns the
> content as a documentFragment which can be used as input for any
> post-processing. The fragment needs to be looped again, but the
> application developer has the choice whatever he likes to modify. And
> the methods inside the basic HtmlArea component stay clean.
> I already filed a bug report to implement this feature (see Bug #1385)
I wonder if a simple patch like this solves the problem for both of you:
diff --git
a/trunk/qooxdoo-contrib/HtmlArea/0.3-pre/source/class/htmlarea/HtmlArea.js
b/trunk/qooxdoo-contrib/HtmlArea/0.3-pre/source/class/htmlarea/HtmlArea.js
index 7321df7..c4ae8de 100644
---
a/trunk/qooxdoo-contrib/HtmlArea/0.3-pre/source/class/htmlarea/HtmlArea.js
+++
b/trunk/qooxdoo-contrib/HtmlArea/0.3-pre/source/class/htmlarea/HtmlArea.js
@@ -270,9 +270,14 @@ qx.Class.define("htmlarea.HtmlArea",
* @type static
* @param root {Node} Root node (starting point)
* @param outputRoot {Boolean} Controls whether the root node is also
added to the output
+ * @param postprocess {Map|null}
+ * If this map exists and contains a member of the tag name, then
that
+ * member's value, a function, is called to post-process the data.
The
+ * function is passed the tag and the styles array. The function is
+ * expected to modify the styles array if desired.
* @return {String} Content of current node
*/
- __getHtml : function(root, outputRoot)
+ __getHtml : function(root, outputRoot, postprocess)
{
// String builder is array for large text content
var html = [];
@@ -421,54 +426,11 @@ qx.Class.define("htmlarea.HtmlArea",
//
--------------------------------------------------------------
// Postprocess
//
--------------------------------------------------------------
-
- // Everything parsed. Here we can postprocess this element. Let
me
- // introduce variables:
- // - tag - tag name
- // - attrMap - attributes map (stored name and value pairs)
- // - attrArray - attributes array. Here are stored attribute
- // names. If attribute is removed from the attrMap, it's
- // also needed to remove it from attrArray!
- // - styles - styles map (stored name and value pairs)
- //
- // Q: Why attrMap and attrArray ?
- // A: Because it can be easily checked whether element contains
- // a given attribute and it's value.
-
- if (tag === "span")
+ if (postprocess && postprocess[tag])
{
- // TODO: Must be optional
- if (0)
- {
- // Create <b> from <span style="font-weight: bold;">
- if (styles["font-weight"] === "bold")
- {
- tag = "b"; delete styles["font-weight"];
- }
- // Create <i> from <span style="font-style: italic;">
- else if (styles["font-style"] === "italic")
- {
- tag = "i"; delete styles["font-style"];
- }
- // Create <u> from <span style="font-style: italic;">
- else if (styles["text-decoration"] === "underline")
- {
- tag = "u"; delete styles["text-decoration"];
- }
- // Create <s> from <span style="text-decoration:
line-through;">
- else if (styles["text-decoration"] === "line-through")
- {
- tag = "strike"; delete styles["text-decoration"];
- }
- }
-
- // Remove empty tag <span></span>, but this also removes
generated <b></b>, ...
- if (qx.lang.Object.isEmpty(attrMap) &&
qx.lang.Object.isEmpty(styles) && !root.hasChildNodes())
- {
- tag = "";
- }
+ postprocess[tag].func(tag, styles);
}
-
+
//
--------------------------------------------------------------
// Generate Html
//
--------------------------------------------------------------
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel