From e30171727f469d2fdb43bf0479097d89f775179f Mon Sep 17 00:00:00 2001 From: Jeremy Goecks Date: Mon, 24 May 2010 10:53:55 -0400 Subject: [PATCH] In Page editor, prevent extra paragraphs from being inserted with embedded items. --- templates/page/editor.mako | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/templates/page/editor.mako b/templates/page/editor.mako index 0876acc307a..b46346451bc 100644 --- a/templates/page/editor.mako +++ b/templates/page/editor.mako @@ -474,20 +474,39 @@ // Embedded item HTML; item class is embedded in div container classes; this is necessary because the editor strips // all non-standard attributes when it returns its content (e.g. it will not return an element attribute of the form // item_class='History'). + var item_elt_id = item_info.iclass + "-" + item_id; var item_embed_html = "\ -
\

Embedded Galaxy " + item_info.singular + " '" + item_name + "'

\

\ [Do not edit this block; Galaxy will fill it in with the annotated " + - item_info.singular.toLowerCase() + " when it is displayed.]

\ + item_info.singular.toLowerCase() + " when it is displayed.] \

\ -

"; +

"; - // Insert embedded representation into document. - // TODO: maybe try replace() instead to handle indenting? + // Insert embedded item into document. wym.insert(item_embed_html); + + // TODO: can we fix this? + // Due to oddities of wym.insert() [likely due to inserting a
and/or a complete paragraph], an + // empty paragraph may be included either before or after an embedded item. Remove these paragraphs. + $("#" + item_elt_id, wym._doc.body).each( function() { + // Remove previous empty paragraphs. + var prev_elt = $(this).prev(); + if ( prev_elt.length != 0 && jQuery.trim(prev_elt.text()) == "" ) + prev_elt.remove(); + + // Remove subsequent empty paragraphs. + /* + var next_elt = $(this).next(); + var next_next_elt = next_elt.next(); + if (next_next_elt.length != 0) + next_elt.remove(); + */ + }); + }); hide_modal(); },