嗨 StackOverflow 社区,
我正在尝试在 Confluence 6.10.2(使用 JQuery 1.7.2)中生成一个文档生成器,并为用户提供多种选项。
用户可以通过复选框或单选按钮隐藏/显示通过 HTML 包含的其他页面
选择文档/选项后,用户可以导出到 Word。
第一个问题是 Confluence 附带的 Export To Word 选项会导出所有内容(包括生成器和所有通常根据用户选择隐藏的部分......)。
因此,我创建了一个仅包含用户选择的元素的弹出窗口,然后添加了一个“导出到 Word”按钮,该按钮使用 jquery.wordexport.js 作为附加库。
第二个问题是CSS样式没有传递(在那个js中仍然是//TODO)。当我使用 CSS 计数器重置/计数器增量来获得正确的标题增量时,没有通过 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 实现是否不包含类似功能?
在此先感谢您的帮助。