宏代码出处:https://github.com/Poil/confluence-usermacro/blob/master/toc-right
设置 > 一般配置 > 用户宏 > 创建用户宏
在模板中添加以下代码:
## Macro title: toc-right
## Macro has a body: N
##
## Developed by: Benjamin DUPUIS
## Date created: 05/08/2011
## Date Updated: 30/11/2016
## Installed by: Benjamin DUPUIS
## @param Maxlvl:title=MaxLvl|type=int|required=true|desc=Max Level|default=5
## @param Float:title=Float|type=boolean|required=true|desc=Float/Fixed Position|default=true
## @param Hidable:title=Hidable|type=boolean|required=true|desc=Hidable (Float menu only)|default=true#set($globalHelper=$action.getHelper())
#if ($content.id == $globalHelper.getPage().id)
#if (!$paramMaxlvl)
#set ($paramMaxlvl=5)
#end#set($mytoc=$globalHelper.renderConfluenceMacro("{toc:maxLevel=$paramMaxlvl}"))
#if ($paramFloat == true)
#if ($paramHidable == true)
<div id="show_customtoc" style="right:5px; top:120px; position:fixed; z-index:99; margin-left:8px; padding:10px; background:#ae0015; border-radius: 3px; writing-mode: vertical-lr; display: none">
<a style="color:white; cursor:pointer" οnclick="jQuery('#customtoc').toggle(true); jQuery('#show_customtoc').toggle(false)">显 示 目 录</a>
</div>
#end
<div id="customtoc" style="right:10px; top:120px; position:fixed; max-height: 80%; z-index:99; overflow: auto; margin-left:8px;background:rgba(229, 232, 232, 0.4);">
#else
#if ($paramHidable == true)
<div id="show_customtoc" style="float:right; margin-left:8px; padding:10px; background:#ae0015; border-radius: 3px; writing-mode: vertical-lr; display: none">
<a style="color:white; cursor:pointer" οnclick="jQuery('#customtoc').toggle(true); jQuery('#show_customtoc').toggle(false)">显 示 目 录</a>
</div>
#end
<div id="customtoc" style="float:right; margin-left:8px;background:rgba(229, 232, 232, 0.4)">
#end
<table>
<thead>
<tr>
<th style="text-align:center;">目 录
#if ($paramHidable == true)
<a style="margin: -5px; padding: 0; float: right; font-weight:bold; font-size:2em; line-height: 1em" οnclick="jQuery('#customtoc').toggle(false); jQuery('#show_customtoc').toggle(true)">×</a>
#end
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
$mytoc
</td>
</tr>
</tbody>
</table>
</div>#if ($paramHidable == true)
<script type="text/javascript">
$(document).ready(function(){
$("#customtoc a").click(function(event) {
## jQuery('#customtoc').toggle(false);
## jQuery('#show_customtoc').toggle(true);
});
});
</script>
#end
#end
编辑文章时,插入宏,选择Float table of content 即可。