Confluence浮动目录导航 -- 用户宏方式

宏代码出处: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 即可。

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值