jquery - 导出到 Word of Confluence 内容会丢失 CSS 样式

标签 jquery html css confluence export-to-word

您好 StackOverflow 社区,

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

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

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

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

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

第二个问题是 CSS 样式没有传递(在那个 js 中仍然是//TODO)。当我使用 CSS counter-reset/counter-increment 来获得正确的 header 增量时,没有传递 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 实现是否不包含类似的功能?

预先感谢您的帮助。

最佳答案

导出到 Word 时无法传递诸如::before 之类的伪元素。

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

关于jquery - 导出到 Word of Confluence 内容会丢失 CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56958013/

相关文章:

javascript - Bootstrap 导航栏不会与 Wordpress 切换

jquery - 使用 css3 的过渡动画 - 打开和关闭

javascript - 使用 jQuery.ajax post 函数将 javascript 数组中的数据传递到服务器?

javascript - 使用 jQuery 删除这个单击的列表元素

javascript - 如何在 CKEditor 所见即所得编辑器中保留换行符

javascript - 如何根据屏幕大小将事件监听器附加到 DOM

javascript - HTML 多个页面中的多个列

javascript - 如何将带有哈希文件名的已编译 CSS/JS 包含到网页中

JQuery scrollTop 问题

html - 如何用CSS制作尖 Angular