This example demonstrates how to write a user macro that creates a panel that is preformatted with specific colours. It will create a panel that looks like this:

(タイトル)

 

Note: The panel's title will be empty if the user does not give a value for the title parameter.

Before you start, see Writing user macros for an introduction to creating your own user macros. 

Defining the 'Formatted Panel' user macro

To create the 'Formatted Panel' user macro:

  1. Go to  > General Configuration > User Macros.
  2. Choose Create a User Macro.
  3. マクロの詳細を入力します (以下の表を参照)。
  4. Choose Add.

フィールド
macroNameformpanel
表示方法Visible to all users in the Macro Browser
マクロ タイトル書式設定済みパネル
説明 Creates a panel preformatted with specific colours
カテゴリFormatting
アイコンの URLこのフィールドは空白のまま残すことができます
ドキュメント URLこのフィールドは空白のまま残すことができます
マクロ本文処理エスケープ済み
テンプレート

テンプレート フィールドに以下のコードを入力します。詳細は、以下のコードの詳細な説明を参照してください。

## @param Title:title=Title|type=string|desc=Title
<ac:structured-macro ac:name="panel">
        <ac:parameter ac:name="titleBGColor">#ccc</ac:parameter>
        <ac:parameter ac:name="borderStyle">solid</ac:parameter>
        <ac:parameter ac:name="borderColor">#6699CC</ac:parameter>
        <ac:parameter ac:name="borderWidth">2</ac:parameter>
        <ac:parameter ac:name="titleColor">#000000</ac:parameter>
    <ac:parameter ac:name="title">$!paramTitle</ac:parameter>
    <ac:rich-text-body>$body</ac:rich-text-body>
</ac:structured-macro>

マクロ テンプレートのコードの例

ユーザー マクロ テンプレート コードの内訳を以下に示します。 

項目説明
## @param Title:title=Title|type=string|desc=Title

@param defines the metadata for your macro parameters.

@param Title

このパラメーターは "Title" ト呼ばれます。

title=Title

マクロ ブラウザーに "Title" として表示されるパラメーター タイトルを定義します。

type=string

は、パラメーターのフィールド タイプをテキスト フィールドとして定義します。

desc=Title

は、マクロ ブラウザー内のパラメーターの説明を定義します。

<ac:structured-macro ac:name="panel">

This calls the Confluence Panel macro.

Confluence マウロのコード名を見つける最も簡単な方法は、マクロを含むページのストレージ形式を表示することです。ストレージ形式を見るには、Confluence 管理者権限が必要になります。

<ac:parameter ac:name="titleBGColor">#ccc</ac:parameter>
<ac:parameter ac:name="borderStyle">solid</ac:parameter>
<ac:parameter ac:name="borderColor">#6699CC</ac:parameter>
<ac:parameter ac:name="borderWidth">2</ac:parameter>
<ac:parameter ac:name="titleColor">#000000</ac:parameter>

Sets the parameters for the macro: the background colour, border style, border colour, border width and title colour.

Confluence マクロのパラメーター名を見つけるには、上記のようにストレージ形式を確認してください。

<ac:parameter ac:name="title">$!paramTitle</ac:parameter>

'Title' パラメーターに保存されている値を、マクロの title セクションに入力します。

「!」は、「タイトル」パラメーターにデータがないときに、タイトルを空白のまま残すようマクロに伝えます。

<ac:rich-text-body>$body</ac:rich-text-body>

ユーザーは、マクロの本文に保存されているデータを使用できます。この行により、マクロはマクロに渡された本文コンテンツへのアクセスと保存が可能になります。

</ac:structured-macro>

このコマンドは、マクロの終了を示します。

  • ラベルなし