【问题标题】:Export to Word of Confluence content loses CSS styling导出到 Word of Confluence 内容会丢失 CSS 样式
【发布时间】:2019-07-12 17:43:49
【问题描述】:

您好 StackOverflow 社区,

我正在尝试在 Confluence 6.10.2(使用 JQuery 1.7.2)中生成一个文档生成器,并为用户提供多种选项。

用户可以通过复选框或单选按钮隐藏/显示通过 HTML 包含的其他页面

选择文档/选项后,用户可以导出到 Word。

第一个问题是 Confluence 附带的 Export To Word 选项会导出所有内容(包括生成器和所有通常根据用户选择隐藏的部分......)。

因此,我创建了一个仅包含用户选择的元素的弹出窗口,然后添加了一个“导出到 Word”按钮,该按钮使用 jquery.wordexport.js 作为附加库。

第二个问题是CSS样式没有传递(在那个js中仍然是//TODO)。当我使用 CSS counter-reset/counter-increment 来获得正确的标头增量时,没有通过 CSS 会破坏这一点。

我尝试将整个 jquery.wordexport.js 导出脚本手动写入我的 HTML 并硬编码 CSS 样式,但这也不起作用。

<script src="https://www.jqueryscript.net/demo/Export-Html-To-Word-Document-With-Images-Using-jQuery-Word-Export-Plugin/FileSaver.js"></script>
<script src="https://www.jqueryscript.net/demo/Export-Html-To-Word-Document-With-Images-Using-jQuery-Word-Export-Plugin/jquery.wordexport.js"></script>

...
    // Open popup
    $("button#submit").click(function(){
        var htmlContent = $( "#schedMaster" ).html();
        $( "#schedulesDiv" ).html(htmlContent);
        $( "#schedulesDiv" ).find(".noprint").remove();
        //$( "#schedulesDiv table, #schedulesDiv td" ).css("border", "1px solid black");
        $( "#schedulePopup" ).show();
    });

    $("button#exportWord").click(function(event){
        $("#schedulesDiv").wordExport();
    });

});
</script>

<div id="schedulesOverlay" style="display: none;" tabindex="0" class="aui-blanket"></div>
<div style="margin-top: -265px; margin-left: -433px; width: 1065px; height: 530px; z-index: 3004; display: none;" id="schedulePopup" class="aui-popup aui-dialog">
    <h2 class="dialog-title">Schedules</h2>
    <div class="dialog-page-body">
        <div style="height: 413px; padding: 20px;" class="dialog-panel-body">
            <div id="schedulesDiv">...</div>
        </div>
        <div class="dialog-button-panel">
            <button id="exportWord">Export to Word</button> <button id="close">Close</button>
        </div>
    </div>
</div>

注意:如果我删除 FileSaver.js 和 jquery.wordexport.js,导出到 Word 按钮仍然会生成一个文件...不知道为什么,但想知道 Atlassian JQuery 实现是否不包含类似功能?

提前感谢您的帮助。

【问题讨论】:

    标签: jquery html css confluence export-to-word


    【解决方案1】:

    导出到 Word 时无法传递 ::before 等伪元素。

    因此,在导出到 Word 之前,我正在使用此答案中的函数https://stackoverflow.com/a/5127570/11760815 用字母/数值重写标题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-11
      • 1970-01-01
      • 2019-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      相关资源
      最近更新 更多