Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-23544

default macro parameter not accessible within EditorImagePlaceholder#getImagePlaceholder

XMLWordPrintable

      Consider macro:

      {macro|val1|param=val2}

      . val1 is a content of default parameter (without a name), val2 is a content of parameter named param.

      All parameters are passed to execute(). Default parameter is NOT passed to getImagePlaceholder().

      Code:

      public class ScreenSnipeMacro implements Macro, ResourceAware, EditorImagePlaceholder {
      
      	@Override
      	public String execute(final Map<String, String> parameters, final String body, final ConversionContext context)
      			throws MacroExecutionException {
      		assertEquals("val2", parameters.get("param")); // PASS
      		assertEquals("val1", parameters.get("0"));     // PASS
      		assertEquals(2, parameters.size());            // PASS
      	}
      
      	@Override
      	public ImagePlaceholder getImagePlaceholder(final Map<String, String> parameters, final ConversionContext context) {
      		assertEquals("val2", parameters.get("param")); // PASS
      		assertEquals("val1", parameters.get("0"));     // FAIL
      		assertEquals(2, parameters.size());            // WOULD FAIL
      	}
      }
      

      atlassian-plugin.xml

      	<xhtml-macro key="screenshot" name="screenshot" class="com.screensnipe.confluence.macro.ScreenSnipeMacro"
      			icon="/download/resources/${project.groupId}.${project.artifactId}:icons/macro-icon.png">
      		<!-- Name attribute specifies the macro tag, it's {screenshot}. -->
      		<!-- Description is displayed in macro browser below the title. -->
      		<description>Snipe a screenshot, add arrows and texts and put directly on page.</description>
      		<category name="confluence-content"/>
      		<category name="visuals"/>
      		<parameters>
      			<parameter name="" type="string" multiple="false"/>
      			<parameter name="align" type="enum" multiple="false" default="none">
      				<value name="none"/>
      				<value name="center"/>
      				<value name="left"/>
      				<value name="right"/>
      			</parameter>
      			<parameter name="zoom" type="string"/>
      			<parameter name="width" type="string"/>
      			<parameter name="height" type="string"/>
      			<parameter name="border" type="string"/>
      			<parameter name="border-color" type="string"/>
      		</parameters>
      		<resource type="velocity" name="help" location="/com/screensnipe/confluence/macro/help.vm">
      			<param name="help-section" value="images"/>
      		</resource>
      		<resource type="i18n" name="i18n" location="com/screensnipe/confluence/macro/i18n"/>
      	</xhtml-macro>
      

              pcurren Paul Curren
              37db95e9e870 Damian Nowak
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: