Confluence 上的表格加宏中可以有单元格特定的背景颜色吗?

发布于 2024-08-08 21:08:56 字数 321 浏览 7 评论 0原文

我将此表加宏与 Confluence 一起使用:

http://confluence.atlassian.com/display/CONFEXT/Table-plus+macro

我可以吗有单元格级别格式化吗?我只看到列级格式。

I am using this table-plus macro with Confluence:

http://confluence.atlassian.com/display/CONFEXT/Table-plus+macro

Can I have cell level formatting? I only see column level formatting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

从来不烧饼 2024-08-15 21:08:56

如何执行此操作完全取决于您已获取并启用的插件。内置的表格单元格语法虽然简洁,但无处放置此类自定义。您可能需要查看 Adaptavist 的内容格式化宏插件,尤其是表格宏 - 您可以毫无问题地在单元格上添加 bgcolor 属性。

当然,过了一段时间,它开始看起来很像 html,在这种情况下,您可能只想启用 HTML 插件 随 Confluence 一起提供,但您应该首先意识到这样做的安全隐患;它可能不适合您的环境。

How to do this all depends on what plugins you have obtained and enabled. The built-in table cell syntax, while concise, has nowhere to put such customization. You may want to look at Adaptavist's plugin for Content Formatting Macros, especially the table macro -- you can throw bgcolor attributes on the cells with no problem.

Of course, after a point, it starts to look a lot like html, in which case you may just want to enable the HTML plugin that ships with Confluence, but you should first be aware of the security implications of doing so; it may not be appropriate for your environment.

陈独秀 2024-08-15 21:08:56

您可以使用 {html} 或用户定义的宏将样式应用于表格、表格行或表格单元格。

以下是三个用于设置表格单元格、表格行或整个表格的背景颜色的宏。

表格单元格背景颜色宏

    ## Macro Title: tblcellbg
    ## Macro Description: Set background colour for a single table cell
    ## Macro has a body: N
    ## Categories: Formatting
    ## Body Processing: No body
    ## Output Format: HTML
    ## Output: JavaScript. Sets table cell background color via CSS 
    ## Developed By: Underverse (http://stackoverflow.com/users/2093966/underverse)
    ## License: BY-NC-SA
    ## @param bgcolour:title=Background Color|type=string|required=true|desc=HTML colour or a HTML numeric #value
    ##
    ## Check for a blank first parameter
    ##

    #if ($parambgcolour && $parambgcolour.length() > 0)  ## If a parm name was used 
       #set ($bgcolor = $parambgcolour)                           ## then set the value locally
    #elseif ($param0 && $param0.length() > 0)                 ## if no parm name
       #set ($bgcolor = $param0)                                     ## then use the first value
    #else
       #set ($bgcolor = "#DDFADE")                                 ## no value so set a default
    #end

    #if ($bgcolor.contains('#'))                                     ## For HTML colours #etc 
    #set ($bgcolorclass = $bgcolor.replaceAll('#', 'A'))   ## Substritute any other char
    #else
    #set ($bgcolorclass = $bgcolor)                            ## or use the colourname itself
    #end

    <script type="text/javascript" class="$bgcolorclass$bgcolorclass">
    AJS.$(document).ready(function() {
        AJS.$(".$bgcolorclass$bgcolorclass").closest("td").css({"background-color": "$bgcolor"});
    });
    </script>

然后您可以在 wiki 标记表、wiki 宏表或 wiki 编辑器中使用此宏来设置表格单元格的背景颜色。

    || Heading 1|| Heading 2 || Heading 3 | 
    |  {tblcellbg:lightgreen} Apple | {tblcellbg:#FFFF33} Banana |  Pear | 

表格行背景颜色宏

    ## Macro Title: tblrowbg
    ## Macro Description: Set background colour for a table row
    ## Macro has a body: N
    ## Categories: Formatting
    ## Body Processing: No body
    ## Output Format: HTML
    ## Output: JavaScript. Sets table row background color via CSS 
    ## Developed By: Underverse (http://stackoverflow.com/users/2093966/underverse)
    ## License: BY-NC-SA
    ## @param bgcolour:title=Background Color|type=string|required=true|desc=HTML colour or a HTML numeric #value
    ##
    ##
    ## Check for a blank first parameter
    ##

    #if ($parambgcolour && $parambgcolour.length() > 0)  ## If a parm name was used 
       #set ($bgcolor = $parambgcolour)                           ## then set the value locally
    #elseif ($param0 && $param0.length() > 0)                 ## if no parm name
    #set ($bgcolor = $param0)                                     ## then use the first value
    #else
       #set ($bgcolor = "#DDFADE")                                 ## no value so set a default
    #end

    #if ($bgcolor.contains('#'))                                     ## For HTML colours #etc 
    #set ($bgcolorclass = $bgcolor.replaceAll('#', 'A'))   ## Substritute any other char
    #else
    #set ($bgcolorclass = $bgcolor)                            ## or use the colourname itself
    #end

    <script type="text/javascript" class="$bgcolorclass$bgcolorclass">
    AJS.$(document).ready(function() {
        AJS.$(".$bgcolorclass$bgcolorclass").closest("tr").css({"background-color": "$bgcolor"});
    });
    </script>

将宏放入要设置的行的单元格之一中。

    || Heading 1|| Heading 2 || Heading 3 | 
    |  {tblrowbg:lightblue} Apple | Banana |  Pear | 

将此宏与 {tblcellbg} 一起使用可以更好地控制单元格颜色。

    || Heading 1|| Heading 2 || Heading 3 | 
    |  {tblrowbg:lightblue} Apple | {tblcellbg:#FFFF33} Banana |  Pear | 

表背景颜色宏

    ## Macro Title: tblbg
    ## Macro Description: Set background colour for a table
    ## Macro has a body: N
    ## Categories: Formatting
    ## Body Processing: No body
    ## Output Format: HTML
    ## Output: JavaScript. Sets table background color via CSS 
    ## Developed By: Underverse (http://stackoverflow.com/users/2093966/underverse)
    ## License: BY-NC-SA
    ## @param bgcolour:title=Background Color|type=string|required=true|desc=HTML colour or a HTML numeric #value
    ##
    ##
    ## Check for a blank first parameter
    ##

    #if ($parambgcolour && $parambgcolour.length() > 0)  ## If a parm name was used 
       #set ($bgcolor = $parambgcolour)                           ## then set the value locally
    #elseif ($param0 && $param0.length() > 0)                 ## if no parm name
       #set ($bgcolor = $param0)                                     ## then use the first value
    #else
       #set ($bgcolor = "#DDFADE")                                 ## no value so set a default
    #end

    #if ($bgcolor.contains('#'))                                     ## For HTML colours #etc 
    #set ($bgcolorclass = $bgcolor.replaceAll('#', 'A'))   ## Substritute any other char
    #else
    #set ($bgcolorclass = $bgcolor)                            ## or use the colourname itself
    #end

    <script type="text/javascript" class="$bgcolorclass$bgcolorclass">
    AJS.$(document).ready(function() {
        AJS.$(".$bgcolorclass$bgcolorclass").closest("table").css({"background-color": "$bgcolor"});
    });
    </script>

将宏放入表中的单元格之一。

    || {tblbg:lightblue} Heading 1|| Heading 2 || Heading 3 | 
    |   Apple | Banana |  Pear | 

可与 {tblrowbg} 和 {tblcellbg} 一起使用。

JavaScript

或者,包装设置单元格/行/表格背景颜色 {html} 的 JavaScript 并将其作为代码放入表格中。

JS 表格单元格 BG 颜色

    || Heading 1|| Heading 2 || Heading 3 | 
    |   Apple |{html}<SCRIPT class=AFFFF33AFFFF33 type=text/javascript>
    AJS.$(document).ready(function() {
        AJS.$(".AFFFF33AFFFF33").closest("td").css({"background-color": "#FFFF33"});
    });        </SCRIPT> {html} Banana  |  Pear | 

JS 表格行 BG 颜色

    ||  Heading 1|| Heading 2 || Heading 3 | 
    |  {html}<SCRIPT class=lightbluelightblue type=text/javascript>
    AJS.$(document).ready(function() {
        AJS.$(".lightbluelightblue").closest("tr").css({"background-color": "lightblue"});
    });
    </SCRIPT>{html} Apple | Banana |  Pear | 

JS 表格 BG 颜色

    || {html}<SCRIPT class=pinkpink type=text/javascript>
    AJS.$(document).ready(function() {
        AJS.$(".pinkpink").closest("table").css({"background-color": "pink"});
    });
    </SCRIPT>{html} Heading 1|| Heading 2 || Heading 3 | 
    |   Apple | Banana |  Pear | 

You can apply a style to the table, table row or table cell using {html} or user defined macro.

Here are three macros for setting the background colour for a table cell, table row or the whole table.

Table Cell Background Colour macro

    ## Macro Title: tblcellbg
    ## Macro Description: Set background colour for a single table cell
    ## Macro has a body: N
    ## Categories: Formatting
    ## Body Processing: No body
    ## Output Format: HTML
    ## Output: JavaScript. Sets table cell background color via CSS 
    ## Developed By: Underverse (http://stackoverflow.com/users/2093966/underverse)
    ## License: BY-NC-SA
    ## @param bgcolour:title=Background Color|type=string|required=true|desc=HTML colour or a HTML numeric #value
    ##
    ## Check for a blank first parameter
    ##

    #if ($parambgcolour && $parambgcolour.length() > 0)  ## If a parm name was used 
       #set ($bgcolor = $parambgcolour)                           ## then set the value locally
    #elseif ($param0 && $param0.length() > 0)                 ## if no parm name
       #set ($bgcolor = $param0)                                     ## then use the first value
    #else
       #set ($bgcolor = "#DDFADE")                                 ## no value so set a default
    #end

    #if ($bgcolor.contains('#'))                                     ## For HTML colours #etc 
    #set ($bgcolorclass = $bgcolor.replaceAll('#', 'A'))   ## Substritute any other char
    #else
    #set ($bgcolorclass = $bgcolor)                            ## or use the colourname itself
    #end

    <script type="text/javascript" class="$bgcolorclass$bgcolorclass">
    AJS.$(document).ready(function() {
        AJS.$(".$bgcolorclass$bgcolorclass").closest("td").css({"background-color": "$bgcolor"});
    });
    </script>

You can then use this macro in a wiki markup table, wiki macro table or into the wiki editor to set the background colour of the table cell.

    || Heading 1|| Heading 2 || Heading 3 | 
    |  {tblcellbg:lightgreen} Apple | {tblcellbg:#FFFF33} Banana |  Pear | 

Table Row Background Colour macro

    ## Macro Title: tblrowbg
    ## Macro Description: Set background colour for a table row
    ## Macro has a body: N
    ## Categories: Formatting
    ## Body Processing: No body
    ## Output Format: HTML
    ## Output: JavaScript. Sets table row background color via CSS 
    ## Developed By: Underverse (http://stackoverflow.com/users/2093966/underverse)
    ## License: BY-NC-SA
    ## @param bgcolour:title=Background Color|type=string|required=true|desc=HTML colour or a HTML numeric #value
    ##
    ##
    ## Check for a blank first parameter
    ##

    #if ($parambgcolour && $parambgcolour.length() > 0)  ## If a parm name was used 
       #set ($bgcolor = $parambgcolour)                           ## then set the value locally
    #elseif ($param0 && $param0.length() > 0)                 ## if no parm name
    #set ($bgcolor = $param0)                                     ## then use the first value
    #else
       #set ($bgcolor = "#DDFADE")                                 ## no value so set a default
    #end

    #if ($bgcolor.contains('#'))                                     ## For HTML colours #etc 
    #set ($bgcolorclass = $bgcolor.replaceAll('#', 'A'))   ## Substritute any other char
    #else
    #set ($bgcolorclass = $bgcolor)                            ## or use the colourname itself
    #end

    <script type="text/javascript" class="$bgcolorclass$bgcolorclass">
    AJS.$(document).ready(function() {
        AJS.$(".$bgcolorclass$bgcolorclass").closest("tr").css({"background-color": "$bgcolor"});
    });
    </script>

Put the macro in one of the cells in the row to be set.

    || Heading 1|| Heading 2 || Heading 3 | 
    |  {tblrowbg:lightblue} Apple | Banana |  Pear | 

Use this macro with {tblcellbg} for finer control of cell colours.

    || Heading 1|| Heading 2 || Heading 3 | 
    |  {tblrowbg:lightblue} Apple | {tblcellbg:#FFFF33} Banana |  Pear | 

Table Background Colour macro

    ## Macro Title: tblbg
    ## Macro Description: Set background colour for a table
    ## Macro has a body: N
    ## Categories: Formatting
    ## Body Processing: No body
    ## Output Format: HTML
    ## Output: JavaScript. Sets table background color via CSS 
    ## Developed By: Underverse (http://stackoverflow.com/users/2093966/underverse)
    ## License: BY-NC-SA
    ## @param bgcolour:title=Background Color|type=string|required=true|desc=HTML colour or a HTML numeric #value
    ##
    ##
    ## Check for a blank first parameter
    ##

    #if ($parambgcolour && $parambgcolour.length() > 0)  ## If a parm name was used 
       #set ($bgcolor = $parambgcolour)                           ## then set the value locally
    #elseif ($param0 && $param0.length() > 0)                 ## if no parm name
       #set ($bgcolor = $param0)                                     ## then use the first value
    #else
       #set ($bgcolor = "#DDFADE")                                 ## no value so set a default
    #end

    #if ($bgcolor.contains('#'))                                     ## For HTML colours #etc 
    #set ($bgcolorclass = $bgcolor.replaceAll('#', 'A'))   ## Substritute any other char
    #else
    #set ($bgcolorclass = $bgcolor)                            ## or use the colourname itself
    #end

    <script type="text/javascript" class="$bgcolorclass$bgcolorclass">
    AJS.$(document).ready(function() {
        AJS.$(".$bgcolorclass$bgcolorclass").closest("table").css({"background-color": "$bgcolor"});
    });
    </script>

Put the macro in one of the cells in the table.

    || {tblbg:lightblue} Heading 1|| Heading 2 || Heading 3 | 
    |   Apple | Banana |  Pear | 

Can be used with {tblrowbg} and {tblcellbg}.

JavaScript

Alternatively, wrap the javascript which sets the cell/row/table background colour {html} and put it into the table as code.

JS Table Cell BG Colour

    || Heading 1|| Heading 2 || Heading 3 | 
    |   Apple |{html}<SCRIPT class=AFFFF33AFFFF33 type=text/javascript>
    AJS.$(document).ready(function() {
        AJS.$(".AFFFF33AFFFF33").closest("td").css({"background-color": "#FFFF33"});
    });        </SCRIPT> {html} Banana  |  Pear | 

JS Table Row BG Color

    ||  Heading 1|| Heading 2 || Heading 3 | 
    |  {html}<SCRIPT class=lightbluelightblue type=text/javascript>
    AJS.$(document).ready(function() {
        AJS.$(".lightbluelightblue").closest("tr").css({"background-color": "lightblue"});
    });
    </SCRIPT>{html} Apple | Banana |  Pear | 

JS Table BG Color

    || {html}<SCRIPT class=pinkpink type=text/javascript>
    AJS.$(document).ready(function() {
        AJS.$(".pinkpink").closest("table").css({"background-color": "pink"});
    });
    </SCRIPT>{html} Heading 1|| Heading 2 || Heading 3 | 
    |   Apple | Banana |  Pear | 
萌能量女王 2024-08-15 21:08:56

使用 {table-plus} 宏无法做到这一点。但是,您可以在 Confluence 中使用更高级的表格格式化插件来完成此操作,如 由扎克描述

It is not possible to do this with the {table-plus} macro. However, you can do it in Confluence with a more advanced table formatting plugin as described by Zac.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文