init
This commit is contained in:
commit
5b00bd10d0
15 files changed
+524
No files matched your search
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><defs><style type="text/css">.skinbaseDark,.skinbaseLight,.skinthemeDark{fill-rule:evenodd;}.skinbaseDark,.skinbaseLight{opacity:0.8;}.skinbaseLight{fill:#838383;}.skinthemeDark{fill:#5789d9;}</style></defs><title>编辑文字</title><path class="skinbaseDark" d="M21,23H2a2,2,0,0,1-2-2V2A2,2,0,0,1,2,0H21a2,2,0,0,1,2,2V21A2,2,0,0,1,21,23ZM22,2a1,1,0,0,0-1-1H2A1,1,0,0,0,1,2V21a1,1,0,0,0,1,1H21a1,1,0,0,0,1-1Z"/><path class="skinbaseLight" d="M21.5,12h-3a.5.5,0,1,1,0-1h3a.5.5,0,1,1,0,1Zm-10,10a.50005.50005,0,0,1-.5-.5v-3a.5.5,0,1,1,1,0v3A.50005.50005,0,0,1,11.5,22Zm0-19a.50005.50005,0,0,1-.5-.5v-1a.5.5,0,1,1,1,0v1A.50005.50005,0,0,1,11.5,3Zm-7,9h-3a.5.5,0,1,1,0-1h3a.5.5,0,1,1,0,1Z"/><path class="skinthemeDark" d="M17.9993,18.9997H16.9367L15.27,14H7.7281L6.0617,18.9997H4.9991L8.9988,6.9993h0a2.92165,2.92165,0,0,1,2.5-2,2.75159,2.75159,0,0,1,2.5,2h0ZM12.9363,6.9993a1.2901,1.2901,0,0,0-1.4375-.9375,1.39754,1.39754,0,0,0-1.4375.9375h0L8.0613,13h6.8753L12.9362,6.9993h.0001Z"/></svg>
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><defs><style type="text/css">.skinbaseDark,.skinthemeDark{fill-rule:evenodd;}.skinbaseDark{opacity:0.8;}.skinthemeDark{fill:#5789d9;}</style></defs><title>艺术字大小</title><path class="skinbaseDark" d="M17.9993,18.9997H16.9367L15.27,14H7.7281L6.0617,18.9997H4.9991L8.9988,6.9993h0a2.92165,2.92165,0,0,1,2.5-2,2.75159,2.75159,0,0,1,2.5,2h0ZM12.9363,6.9993a1.2901,1.2901,0,0,0-1.4375-.9375,1.39754,1.39754,0,0,0-1.4375.9375h0L8.0613,13h6.8753L12.9362,6.9993h.0001Z"/><path class="skinthemeDark" d="M23,21v1a1,1,0,0,1-1,1H21a1,1,0,0,1-1-1H3a1,1,0,0,1-1,1H1a1,1,0,0,1-1-1V21a1,1,0,0,1,1-1V4A1,1,0,0,1,0,3V2A1,1,0,0,1,1,1H2A1,1,0,0,1,3,2H20a1,1,0,0,1,1-1h1a1,1,0,0,1,1,1V3a1,1,0,0,1-1,1V20A1,1,0,0,1,23,21ZM1,21.6a.4.4,0,0,0,.4.4h.2a.4.4,0,0,0,.4-.4v-.2a.4.4,0,0,0-.4-.4H1.4a.4.4,0,0,0-.4.4ZM2,2.4A.4.4,0,0,0,1.6,2H1.4a.4.4,0,0,0-.4.4v.2a.4.4,0,0,0,.4.4h.2A.4.4,0,0,0,2,2.6ZM20,3H3A1,1,0,0,1,2,4V20a1,1,0,0,1,1,1H20a1,1,0,0,1,1-1V4A1,1,0,0,1,20,3Zm2-.6a.4.4,0,0,0-.4-.4h-.2a.4.4,0,0,0-.4.4v.2a.4.4,0,0,0,.4.4h.2a.4.4,0,0,0,.4-.4ZM21.6,21h-.2a.4.4,0,0,0-.4.4v.2a.4.4,0,0,0,.4.4h.2a.4.4,0,0,0,.4-.4v-.2A.4.4,0,0,0,21.6,21Z"/></svg>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.skinbaseDark{opacity:0.8;enable-background:new ;}
|
||||
.skinthemeDark{fill:#5789D9;}
|
||||
</style>
|
||||
<path class="skinbaseDark" d="M13,23h-1.4c-0.1,0-0.2,0-0.3-0.1c-0.7-0.2-0.9-0.6-1.3-0.9l-5-5H1.6C0.7,17,0,16.3,0,15.4V8.6
|
||||
C0,7.7,0.7,7,1.6,7H5l5-5c0.4-0.4,0.6-0.8,1.3-0.9C11.4,1,11.5,1,11.6,1H12l0,0l0,0h1c0.6,0,1,0.5,1,1v20C14,22.5,13.6,23,13,23z
|
||||
M13,2.4C13,2.2,12.8,2,12.6,2H12c-0.5,0-0.9,0.2-1.1,0.4c0.1-0.1,0,0,0,0C10.8,2.6,7.3,6,5.3,8H1.6C1.3,8,1,8.3,1,8.6v6.8
|
||||
C1,15.7,1.3,16,1.6,16h3.7c2,2,5.5,5.5,5.7,5.7c0.2,0.2,0.6,0.3,1,0.3h0.6c0.2,0,0.4-0.2,0.4-0.4V2.4z M10,2C10,2,9.9,2.1,10,2
|
||||
C9.9,2,10,2,10,2z"/>
|
||||
<path class="skinthemeDark" d="M18.5,20.9c-0.1,0.1-0.2,0.1-0.4,0.1c-0.3,0-0.5-0.2-0.5-0.5c0-0.2,0.1-0.4,0.3-0.5l0,0
|
||||
c3-1.5,5.1-4.5,5.1-8.1s-2.1-6.6-5.1-8.1l0,0c-0.2-0.1-0.3-0.3-0.3-0.5c0-0.3,0.2-0.5,0.5-0.5c0.1,0,0.3,0.1,0.4,0.2
|
||||
c3.3,1.6,5.5,5,5.5,8.9S21.8,19.3,18.5,20.9z M19,12c0,1.7-0.9,3.2-2.2,4.1c-0.1,0.1-0.2,0.2-0.4,0.2c-0.3,0-0.5-0.2-0.5-0.5
|
||||
c0-0.2,0.1-0.4,0.3-0.5v0c1.1-0.7,1.8-1.9,1.8-3.3c0-1.4-0.7-2.6-1.8-3.3v0c-0.2-0.1-0.3-0.3-0.3-0.5c0-0.3,0.2-0.5,0.5-0.5
|
||||
c0.2,0,0.3,0.1,0.4,0.2C18.1,8.8,19,10.3,19,12z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="21px" height="20px" viewBox="0 0 21 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.2 (57519) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>从模版新建</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Artboard" transform="translate(-31.000000, -26.000000)">
|
||||
<g id="从模版新建" transform="translate(29.000000, 24.000000)">
|
||||
<g id="Group" stroke-width="1">
|
||||
<g id="新增节" transform="translate(2.000000, 2.000000)">
|
||||
<path d="M19.9587402,10 L18.9587402,10 L18.9587402,2 C18.9587402,1.44771525 18.511025,1 17.9587402,1 L6.0300293,1 C5.47774455,1 5.0300293,1.44771525 5.0300293,2 L5.0300293,18 C5.0300293,18.5522847 5.47774455,19 6.0300293,19 L9.95874023,19 L9.95874023,20 L6.0300293,20 C4.9254598,20 4.0300293,19.1045695 4.0300293,18 L4.0300293,2 C4.0300293,0.8954305 4.9254598,2.02906125e-16 6.0300293,0 L17.9587402,0 C19.0633097,-2.02906125e-16 19.9587402,0.8954305 19.9587402,2 L19.9587402,10 Z" id="Combined-Shape" fill="#404040" fill-rule="nonzero"></path>
|
||||
<path d="M6,1 L4,1 C3.44771525,1 3,1.44771525 3,2 L3,18 C3,18.5522847 3.44771525,19 4,19 L6,19 L6,20 L4,20 C2.8954305,20 2,19.1045695 2,18 L2,2 C2,0.8954305 2.8954305,2.02906125e-16 4,0 L6,0 L6,1 Z" id="Combined-Shape-Copy-2" fill="#404040" fill-rule="nonzero"></path>
|
||||
<path d="M4,1 L2,1 C1.44771525,1 1,1.44771525 1,2 L1,18 C1,18.5522847 1.44771525,19 2,19 L4,19 L4,20 L2,20 C0.8954305,20 1.03797111e-16,19.1045695 0,18 L0,2 C-1.10284431e-16,0.8954305 0.8954305,2.02906125e-16 2,0 L4,0 L4,1 Z" id="Combined-Shape-Copy-3" fill="#404040" fill-rule="nonzero"></path>
|
||||
<path d="M17,15 L20.5,15 C20.7761424,15 21,15.2238576 21,15.5 C21,15.7761424 20.7761424,16 20.5,16 L17,16 L17,19.5 C17,19.7761424 16.7761424,20 16.5,20 C16.2238576,20 16,19.7761424 16,19.5 L16,16 L12.5,16 C12.2238576,16 12,15.7761424 12,15.5 C12,15.2238576 12.2238576,15 12.5,15 L16,15 L16,11.5 C16,11.2238576 16.2238576,11 16.5,11 C16.7761424,11 17,11.2238576 17,11.5 L17,15 Z" id="Combined-Shape" fill="#5789D9"></path>
|
||||
</g>
|
||||
</g>
|
||||
<rect id="Rectangle-15" fill="#404040" x="9" y="6" width="10" height="1"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<script type="text/javascript" src="./main.js"></script>
|
||||
</html>
|
||||
<!--这个文件是wps加载项的入口文件,wps在启动时加载这个文件-->
|
||||
@@ -0,0 +1,69 @@
|
||||
function onbuttonclick(idStr)
|
||||
{
|
||||
switch(idStr)
|
||||
{
|
||||
case "getDocName":{
|
||||
let doc = window.Application.ActiveDocument
|
||||
let textValue = ""
|
||||
if (!doc){
|
||||
textValue = textValue + "当前没有打开任何文档"
|
||||
return
|
||||
}
|
||||
textValue = textValue + doc.Name
|
||||
document.getElementById("text_p").innerHTML = textValue
|
||||
break
|
||||
}
|
||||
case "createTaskPane":{
|
||||
let tsId = window.Application.PluginStorage.getItem("taskpane_id")
|
||||
if (!tsId){
|
||||
let tskpane = window.Application.CreateTaskPane(GetUrlPath() + "/taskpane.html")
|
||||
let id = tskpane.ID
|
||||
window.Application.PluginStorage.setItem("taskpane_id", id)
|
||||
tskpane.Visible = true
|
||||
}else{
|
||||
let tskpane = window.Application.GetTaskPane(tsId)
|
||||
tskpane.Visible = true
|
||||
}
|
||||
break
|
||||
}
|
||||
case "newDoc":{
|
||||
window.Application.Documents.Add()
|
||||
break
|
||||
}
|
||||
case "addString":{
|
||||
let doc = window.Application.ActiveDocument
|
||||
if (doc){
|
||||
doc.Range(0, 0).Text="Hello, wps加载项!"
|
||||
//好像是wps的bug, 这两句话触发wps重绘
|
||||
let rgSel = window.Application.Selection.Range
|
||||
if (rgSel)
|
||||
rgSel.Select()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "closeDoc":{
|
||||
if (window.Application.Documents.Count < 2)
|
||||
{
|
||||
alert("当前只有一个文档,别关了。")
|
||||
break
|
||||
}
|
||||
|
||||
let doc = window.Application.ActiveDocument
|
||||
if (doc)
|
||||
doc.Close()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
var xmlReq = WpsInvoke.CreateXHR();
|
||||
var url = location.origin + "/.debugTemp/NotifyDemoUrl"
|
||||
xmlReq.open("GET", url);
|
||||
xmlReq.onload = function (res) {
|
||||
var node = document.getElementById("DemoSpan");
|
||||
node.innerText = res.target.responseText;
|
||||
};
|
||||
xmlReq.send();
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
|
||||
//这个函数在整个wps加载项中是第一个执行的
|
||||
function OnAddinLoad(ribbonUI){
|
||||
if (typeof (window.Application.ribbonUI) != "object"){
|
||||
window.Application.ribbonUI = ribbonUI
|
||||
}
|
||||
|
||||
if (typeof (window.Application.Enum) != "object") { // 如果没有内置枚举值
|
||||
window.Application.Enum = WPS_Enum
|
||||
}
|
||||
|
||||
window.Application.PluginStorage.setItem("EnableFlag", false) //往PluginStorage中设置一个标记,用于控制两个按钮的置灰
|
||||
window.Application.PluginStorage.setItem("ApiEventFlag", false) //往PluginStorage中设置一个标记,用于控制ApiEvent的按钮label
|
||||
return true
|
||||
}
|
||||
|
||||
var WebNotifycount = 0;
|
||||
function OnAction(control) {
|
||||
const eleId = control.Id
|
||||
switch (eleId) {
|
||||
case "btnShowMsg":
|
||||
{
|
||||
const doc = window.Application.ActiveDocument
|
||||
if (!doc) {
|
||||
alert("当前没有打开任何文档")
|
||||
return
|
||||
}
|
||||
alert(doc.Name)
|
||||
}
|
||||
break;
|
||||
case "btnIsEnbable":
|
||||
{
|
||||
let bFlag = window.Application.PluginStorage.getItem("EnableFlag")
|
||||
window.Application.PluginStorage.setItem("EnableFlag", !bFlag)
|
||||
|
||||
//通知wps刷新以下几个按饰的状态
|
||||
window.Application.ribbonUI.InvalidateControl("btnIsEnbable")
|
||||
window.Application.ribbonUI.InvalidateControl("btnShowDialog")
|
||||
window.Application.ribbonUI.InvalidateControl("btnShowTaskPane")
|
||||
//window.Application.ribbonUI.Invalidate(); 这行代码打开则是刷新所有的按钮状态
|
||||
break
|
||||
}
|
||||
case "btnShowDialog":
|
||||
window.Application.ShowDialog(GetUrlPath() + "/ui/dialog.html", "这是一个对话框网页", 400 * window.devicePixelRatio, 400 * window.devicePixelRatio, false)
|
||||
break
|
||||
case "btnShowTaskPane":
|
||||
{
|
||||
let tsId = window.Application.PluginStorage.getItem("taskpane_id")
|
||||
if (!tsId) {
|
||||
let tskpane = window.Application.CreateTaskPane(GetUrlPath() + "/ui/taskpane.html")
|
||||
let id = tskpane.ID
|
||||
window.Application.PluginStorage.setItem("taskpane_id", id)
|
||||
tskpane.Visible = true
|
||||
} else {
|
||||
let tskpane = window.Application.GetTaskPane(tsId)
|
||||
tskpane.Visible = !tskpane.Visible
|
||||
}
|
||||
}
|
||||
break
|
||||
case "btnApiEvent":
|
||||
{
|
||||
let bFlag = window.Application.PluginStorage.getItem("ApiEventFlag")
|
||||
let bRegister = bFlag ? false : true
|
||||
window.Application.PluginStorage.setItem("ApiEventFlag", bRegister)
|
||||
if (bRegister){
|
||||
window.Application.ApiEvent.AddApiEventListener('DocumentNew', OnNewDocumentApiEvent)
|
||||
}
|
||||
else{
|
||||
window.Application.ApiEvent.RemoveApiEventListener('DocumentNew', OnNewDocumentApiEvent)
|
||||
}
|
||||
|
||||
window.Application.ribbonUI.InvalidateControl("btnApiEvent")
|
||||
}
|
||||
break
|
||||
case "btnWebNotify":
|
||||
{
|
||||
let currentTime = new Date()
|
||||
let timeStr = currentTime.getHours() + ':' + currentTime.getMinutes() + ":" + currentTime.getSeconds()
|
||||
window.Application.OAAssist.WebNotify("这行内容由wps加载项主动送达给业务系统,可以任意自定义, 比如时间值:" + timeStr + ",次数:" + (++WebNotifycount), true)
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function GetImage(control) {
|
||||
const eleId = control.Id
|
||||
switch (eleId) {
|
||||
case "btnShowMsg":
|
||||
return "images/1.svg"
|
||||
case "btnShowDialog":
|
||||
return "images/2.svg"
|
||||
case "btnShowTaskPane":
|
||||
return "images/3.svg"
|
||||
default:
|
||||
;
|
||||
}
|
||||
return "images/newFromTemp.svg"
|
||||
}
|
||||
|
||||
function OnGetEnabled(control) {
|
||||
const eleId = control.Id
|
||||
switch (eleId) {
|
||||
case "btnShowMsg":
|
||||
return true
|
||||
break
|
||||
case "btnShowDialog":
|
||||
{
|
||||
let bFlag = window.Application.PluginStorage.getItem("EnableFlag")
|
||||
return bFlag
|
||||
break
|
||||
}
|
||||
case "btnShowTaskPane":
|
||||
{
|
||||
let bFlag = window.Application.PluginStorage.getItem("EnableFlag")
|
||||
return bFlag
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function OnGetVisible(control){
|
||||
return true
|
||||
}
|
||||
|
||||
function OnGetLabel(control){
|
||||
const eleId = control.Id
|
||||
switch (eleId) {
|
||||
case "btnIsEnbable":
|
||||
{
|
||||
let bFlag = window.Application.PluginStorage.getItem("EnableFlag")
|
||||
return bFlag ? "按钮Disable" : "按钮Enable"
|
||||
break
|
||||
}
|
||||
case "btnApiEvent":
|
||||
{
|
||||
let bFlag = window.Application.PluginStorage.getItem("ApiEventFlag")
|
||||
return bFlag ? "清除新建文件事件" : "注册新建文件事件"
|
||||
break
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
function OnNewDocumentApiEvent(doc){
|
||||
alert("新建文件事件响应,取文件名: " + doc.Name)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
function openOfficeFileFromSystemDemo(param){
|
||||
let jsonObj = (typeof(param)=='string' ? JSON.parse(param) : param)
|
||||
alert("从业务系统传过来的参数为:" + JSON.stringify(jsonObj))
|
||||
return {wps加载项项返回: jsonObj.filepath + ", 这个地址给的不正确"}
|
||||
}
|
||||
|
||||
function InvokeFromSystemDemo(param){
|
||||
let jsonObj = (typeof(param)=='string' ? JSON.parse(param) : param)
|
||||
let handleInfo = jsonObj.Index
|
||||
switch (handleInfo){
|
||||
case "getDocumentName":{
|
||||
let docName = ""
|
||||
if (window.Application.ActiveDocument){
|
||||
docName = window.Application.ActiveDocument.Name
|
||||
}
|
||||
|
||||
return {当前打开的文件名为:docName}
|
||||
}
|
||||
|
||||
case "newDocument":{
|
||||
let newDocName=""
|
||||
let doc = window.Application.Documents.Add()
|
||||
newDocName = doc.Name
|
||||
|
||||
return {操作结果:"新建文档成功,文档名为:" + newDocName}
|
||||
}
|
||||
|
||||
case "OpenFile":{
|
||||
let filePath = jsonObj.filepath
|
||||
window.Application.Documents.OpenFromUrl(filePath)
|
||||
return {操作结果:"打开文件成功"}
|
||||
}
|
||||
}
|
||||
|
||||
return {其它xxx:""}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
function onbuttonclick(idStr)
|
||||
{
|
||||
if (typeof (window.Application.Enum) != "object") { // 如果没有内置枚举值
|
||||
window.Application.Enum = WPS_Enum
|
||||
}
|
||||
switch(idStr)
|
||||
{
|
||||
case "dockLeft":{
|
||||
let tsId = window.Application.PluginStorage.getItem("taskpane_id")
|
||||
if (tsId){
|
||||
let tskpane = window.Application.GetTaskPane(tsId)
|
||||
tskpane.DockPosition = window.Application.Enum.msoCTPDockPositionLeft
|
||||
}
|
||||
break
|
||||
}
|
||||
case "dockRight":{
|
||||
let tsId = window.Application.PluginStorage.getItem("taskpane_id")
|
||||
if (tsId){
|
||||
let tskpane = window.Application.GetTaskPane(tsId)
|
||||
tskpane.DockPosition = window.Application.Enum.msoCTPDockPositionRight
|
||||
}
|
||||
break
|
||||
}
|
||||
case "hideTaskPane":{
|
||||
let tsId = window.Application.PluginStorage.getItem("taskpane_id")
|
||||
if (tsId){
|
||||
let tskpane = window.Application.GetTaskPane(tsId)
|
||||
tskpane.Visible = false
|
||||
}
|
||||
break
|
||||
}
|
||||
case "addString":{
|
||||
let doc = window.Application.ActiveDocument
|
||||
if (doc){
|
||||
doc.Range(0, 0).Text="Hello, wps加载项!"
|
||||
//好像是wps的bug, 这两句话触发wps重绘
|
||||
let rgSel = window.Application.Selection.Range
|
||||
if (rgSel)
|
||||
rgSel.Select()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "getDocName":{
|
||||
let doc = window.Application.ActiveDocument
|
||||
let textValue = "";
|
||||
if (!doc){
|
||||
textValue = textValue + "当前没有打开任何文档"
|
||||
return
|
||||
}
|
||||
textValue = textValue + doc.Name
|
||||
document.getElementById("text_p").innerHTML = textValue
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
var xmlReq = WpsInvoke.CreateXHR();
|
||||
var url = location.origin + "/.debugTemp/NotifyDemoUrl"
|
||||
xmlReq.open("GET", url);
|
||||
xmlReq.onload = function (res) {
|
||||
var node = document.getElementById("DemoSpan");
|
||||
node.innerText = res.target.responseText;
|
||||
};
|
||||
xmlReq.send();
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//在后续的wps版本中,wps的所有枚举值都会通过wps.Enum对象来自动支持,现阶段先人工定义
|
||||
var WPS_Enum = {
|
||||
msoCTPDockPositionLeft: 0,
|
||||
msoCTPDockPositionRight: 2
|
||||
}
|
||||
|
||||
function GetUrlPath() {
|
||||
let e = document.location.toString()
|
||||
return -1 != (e = decodeURI(e)).indexOf("/") && (e = e.substring(0, e.lastIndexOf("/"))), e
|
||||
}
|
||||
/**
|
||||
* 通过wps提供的接口执行一段脚本
|
||||
* @param {*} param 需要执行的脚本
|
||||
*/
|
||||
function shellExecuteByOAAssist(param) {
|
||||
if (wps != null) {
|
||||
wps.OAAssist.ShellExecute(param)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
//这个文件由index.html包含
|
||||
document.write("<script language='javascript' src='js/util.js'></script>");
|
||||
document.write("<script language='javascript' src='js/ribbon.js'></script>");
|
||||
document.write("<script language='javascript' src='js/systemdemo.js'></script>");
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "XbotWps",
|
||||
"addonType": "wps",
|
||||
"version": "1.0.0",
|
||||
"description": "wps加载项示例, 执行npm install后,提供代码联想功能",
|
||||
"devDependencies": {
|
||||
"wps-jsapi-declare": "latest"
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnAddinLoad">
|
||||
<ribbon startFromScratch="false">
|
||||
<tabs>
|
||||
<tab id="wpsAddinTab" label="wps加载项示例">
|
||||
<group id="btnDemoGroup" label="group1">
|
||||
<button id="btnShowMsg" label="弹出消息框" onAction="OnAction" getEnabled="OnGetEnabled" getImage="GetImage" visible="true" size="large"/>
|
||||
<button id="btnIsEnbable" getLabel="OnGetLabel" onAction="OnAction" enabled="true" getImage="GetImage" visible="true" size="large"/>
|
||||
<button id="btnShowDialog" label="弹对话框网页" onAction="OnAction" getEnabled="OnGetEnabled" getImage="GetImage" getVisible="OnGetVisible" size="large"/>
|
||||
<button id="btnShowTaskPane" label="弹任务窗格网页" onAction="OnAction" getEnabled="OnGetEnabled" getImage="GetImage" getVisible="OnGetVisible" size="large"/>
|
||||
<button id="btnApiEvent" getLabel="OnGetLabel" onAction="OnAction" getEnabled="OnGetEnabled" getImage="GetImage" getVisible="OnGetVisible" size="large"/>
|
||||
<button id="btnWebNotify" label="给业务系统发通知" onAction="OnAction" enabled="true" getImage="GetImage" getVisible="OnGetVisible" size="large"/>
|
||||
</group>
|
||||
</tab>
|
||||
</tabs>
|
||||
</ribbon>
|
||||
</customUI>
|
||||
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<script type="text/javascript" src="../js/util.js"></script>
|
||||
<script type="text/javascript" src="../js/dialog.js"></script>
|
||||
<script type="text/javascript" src="../.debugTemp/wpsjsrpcsdk.js"></script>
|
||||
|
||||
<body>
|
||||
<div class="global">
|
||||
<div class="divItem">
|
||||
这是一个网页,按<span style="font-weight: bolder;">"F12"</span>可以打开调试器。
|
||||
</div>
|
||||
<div class="divItem">
|
||||
这个示例展示了wps加载项的相关基础能力,与B/S业务系统的交互,请用浏览器打开:
|
||||
<span style="font-weight: bolder;color: slateblue;cursor:pointer" id="DemoSpan"
|
||||
onclick="shellExecuteByOAAssist(this.innerHTML)"></span>
|
||||
</div>
|
||||
<div class="divItem">开发文档: <span style="font-weight: bolder;color: slateblue;cursor:pointer"
|
||||
onclick="shellExecuteByOAAssist(this.innerHTML)">https://open.wps.cn/docs/office</span></div>
|
||||
<hr>
|
||||
<div class="divItem">
|
||||
<button style="margin:3px;" onclick="onbuttonclick('getDocName')">取文件名</button>
|
||||
<button style="margin:3px;" onclick="onbuttonclick('createTaskPane')">创建任务窗格</button>
|
||||
<button style="margin:3px;" onclick="onbuttonclick('newDoc')">新建文件</button>
|
||||
<button style="margin:3px;" onclick="onbuttonclick('addString')">文档开头添加字符串</button>
|
||||
<button style="margin:3px;" onclick="onbuttonclick('closeDoc')">关闭文件</button>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="divItem">文档文件名为:<span id="text_p"></span></div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<style>
|
||||
.global {
|
||||
font-size: 15px;
|
||||
min-height: 95%;
|
||||
}
|
||||
|
||||
.divItem {
|
||||
margin-left: 5px;
|
||||
margin-bottom: 18px;
|
||||
font-size: 15px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<script type="text/javascript" src="../js/util.js"></script>
|
||||
<script type="text/javascript" src="../js/taskpane.js"></script>
|
||||
<script type="text/javascript" src="../.debugTemp/wpsjsrpcsdk.js"></script>
|
||||
|
||||
<body>
|
||||
<div class="global">
|
||||
<div class="divItem">
|
||||
这是一个网页,按<span style="font-weight: bolder;">"F12"</span>可以打开调试器。
|
||||
</div>
|
||||
<div class="divItem">
|
||||
这个示例展示了wps加载项的相关基础能力,与B/S业务系统的交互,请用浏览器打开:
|
||||
<span style="font-weight: bolder;color: slateblue;cursor:pointer" id="DemoSpan"
|
||||
onclick="shellExecuteByOAAssist(this.innerHTML)"></span>
|
||||
</div>
|
||||
<div class="divItem">开发文档: <span style="font-weight: bolder;color: slateblue;cursor:pointer"
|
||||
onclick="shellExecuteByOAAssist(this.innerHTML)">https://open.wps.cn/docs/office</span></div>
|
||||
<hr>
|
||||
<div class="divItem">
|
||||
<button style="margin:3px;" onclick="onbuttonclick('dockLeft')">停靠左边</button>
|
||||
<button style="margin:3px;" onclick="onbuttonclick('dockRight')">停靠右边</button>
|
||||
<button style="margin:3px;" onclick="onbuttonclick('hideTaskPane')">隐藏TaskPane</button>
|
||||
<button style="margin:3px;" onclick="onbuttonclick('addString')">文档开头添加字符串</button>
|
||||
<button style="margin:3px;" onclick="onbuttonclick('getDocName')">取文件名</button>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="divItem">文档文件名为:<span id="text_p"></span></div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<style>
|
||||
.global {
|
||||
font-size: 15px;
|
||||
min-height: 95%;
|
||||
}
|
||||
|
||||
.divItem {
|
||||
margin-left: 5px;
|
||||
margin-bottom: 18px;
|
||||
font-size: 15px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user