sur-onlyoffice 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/onlyoffice.es.js +90 -69
- package/dist/onlyoffice.umd.js +8 -8
- package/index.html +1 -1
- package/package.json +1 -1
- package/src/package/onlyoffice.vue +43 -25
package/dist/onlyoffice.es.js
CHANGED
|
@@ -1,23 +1,41 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as S, ref as p, onMounted as v, onBeforeUnmount as L, createElementBlock as P, openBlock as Y, createCommentVNode as R, createElementVNode as B } from "vue";
|
|
2
|
+
const _ = { class: "onlyoffice-box" }, W = "asc.{91EAC419-EF8B-440C-A960-B451C7DF3A37}", M = /* @__PURE__ */ S({
|
|
3
3
|
__name: "onlyoffice",
|
|
4
|
-
|
|
4
|
+
props: {
|
|
5
|
+
config: {
|
|
6
|
+
type: Object,
|
|
7
|
+
default: () => {
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
documentServerUrl: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: ""
|
|
13
|
+
},
|
|
14
|
+
onLoadComponentError: {
|
|
15
|
+
type: Object,
|
|
16
|
+
default: () => {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
setup(b) {
|
|
5
21
|
let i = null;
|
|
6
|
-
const
|
|
7
|
-
|
|
22
|
+
const d = p(!1), c = b;
|
|
23
|
+
console.log(c, "props");
|
|
24
|
+
const s = c?.documentServerUrl || "https://test.xuandou.vip:126", r = s + "/web-apps/apps/api/documents/api.js", $ = s + "/8.3.1-10ca0f5dd35a63800b6a3956f350bf95/sdkjs-plugins/example_extended_comments/config.json";
|
|
25
|
+
function I() {
|
|
8
26
|
return new Promise((o, e) => {
|
|
9
27
|
if (window.DocsAPI) return o();
|
|
10
28
|
const n = document.createElement("script");
|
|
11
|
-
n.src =
|
|
29
|
+
n.src = r, n.onload = () => o(), n.onerror = () => e(new Error("加载 DocsAPI 失败:" + r)), document.head.appendChild(n);
|
|
12
30
|
});
|
|
13
31
|
}
|
|
14
|
-
const
|
|
32
|
+
const f = [];
|
|
15
33
|
let a = null;
|
|
16
|
-
function
|
|
34
|
+
function g() {
|
|
17
35
|
a === null && (a = window.setInterval(() => {
|
|
18
|
-
if (!(!i || typeof i.serviceCommand != "function") &&
|
|
19
|
-
for (;
|
|
20
|
-
const { cmd: o, payload: e } =
|
|
36
|
+
if (!(!i || typeof i.serviceCommand != "function") && d.value) {
|
|
37
|
+
for (; f.length; ) {
|
|
38
|
+
const { cmd: o, payload: e } = f.shift();
|
|
21
39
|
try {
|
|
22
40
|
console.log("[ONLYOFFICE] 发送排队指令:", o, e), i.serviceCommand(o, e);
|
|
23
41
|
} catch (n) {
|
|
@@ -28,54 +46,51 @@ const P = { class: "onlyoffice-box" }, f = "https://test.xuandou.vip:126", v = "
|
|
|
28
46
|
}
|
|
29
47
|
}, 300));
|
|
30
48
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
const m = {
|
|
50
|
+
document: {
|
|
51
|
+
fileType: "docx",
|
|
52
|
+
title: "Demo.docx",
|
|
53
|
+
url: "https://qiniu2.xuandou.vip/new.docx",
|
|
54
|
+
key: "test-key",
|
|
55
|
+
permissions: { edit: !0 }
|
|
56
|
+
},
|
|
57
|
+
documentType: "word",
|
|
58
|
+
editorConfig: {
|
|
59
|
+
lang: "zh-CN",
|
|
60
|
+
mode: "edit",
|
|
61
|
+
user: { id: "u1", name: "Tester" },
|
|
62
|
+
plugins: {
|
|
63
|
+
//!
|
|
64
|
+
autostart: [W],
|
|
65
|
+
pluginsData: [{ url: $ + "?v=2.0." + Date.now() }]
|
|
66
|
+
// 强刷缓存
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
width: "100%",
|
|
70
|
+
height: "100%",
|
|
71
|
+
events: {
|
|
72
|
+
onPluginsReady: () => {
|
|
73
|
+
console.log("[ONLYOFFICE] 插件资源已加载,但不代表已初始化");
|
|
42
74
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
user: { id: "u1", name: "Tester" },
|
|
48
|
-
plugins: {
|
|
49
|
-
//!
|
|
50
|
-
autostart: [Y],
|
|
51
|
-
pluginsData: [{ url: g + "?v=2.0." + Date.now() }]
|
|
52
|
-
// 强刷缓存
|
|
53
|
-
}
|
|
75
|
+
onDocumentReady: () => {
|
|
76
|
+
console.log("[ONLYOFFICE] 文档已就绪"), y(), g(), console.log("window.Asc.plugin1", window?.Asc?.plugin), setTimeout(() => {
|
|
77
|
+
console.log("window.Asc.plugin2", window), console.log("window.Asc.plugin3-editor", i.serviceCommand), i.serviceCommand("event_onAddComment", { id: 111 });
|
|
78
|
+
}, 2e3);
|
|
54
79
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
onPluginsReady: () => {
|
|
59
|
-
console.log("[ONLYOFFICE] 插件资源已加载,但不代表已初始化");
|
|
60
|
-
},
|
|
61
|
-
onDocumentReady: () => {
|
|
62
|
-
console.log("[ONLYOFFICE] 文档已就绪"), b(), r(), console.log("window.Asc.plugin1", window?.Asc?.plugin), setTimeout(() => {
|
|
63
|
-
console.log("window.Asc.plugin2", window), console.log("window.Asc.plugin3-editor", i.serviceCommand), i.serviceCommand("event_onAddComment", { id: 111 });
|
|
64
|
-
}, 2e3);
|
|
65
|
-
},
|
|
66
|
-
onInfo: (n) => {
|
|
67
|
-
const t = n?.data;
|
|
68
|
-
console.log("[ONLYOFFICE] Info 事件:", n.data), n && (t?.command === "openPlugin" && (console.log("[ONLYOFFICE] openPlugin"), i.frame?.contentWindow?.Common?.Gateway?.sendInfo(t)), n.data.command === "pluginInitialized" && (c.value = !0, console.log("[ONLYOFFICE] 插件初始化完成"), r()), n.data.command === "pluginAck" && console.log("[ONLYOFFICE] 插件确认收到:", n.data), n.data.command === "pluginError" && console.error("[ONLYOFFICE] 插件错误:", n.data), n.data.command === "linkClicked" && (console.log("[ONLYOFFICE] 链接被点击,数据:", n.data.data), p(n.data.data)), n.data.command === "wordArtInserted" && (console.log("[ONLYOFFICE] WordArt 插入成功:", n.data.data), $(n.data.data)), n.data.command === "wordArtError" && (console.error("[ONLYOFFICE] WordArt 插入失败:", n.data.data), I(n.data.data)), n.data.command === "tableClicked" && (console.log("[ONLYOFFICE] 表格被点击,数据:", n.data.data), h(n.data.data)), n.data.command === "selectionAnalyzed" && (console.log("[ONLYOFFICE] 选中内容分析结果:", n.data.data), y(n.data.data)), n.data.command === "selectionBound" && (console.log("[ONLYOFFICE] 选中内容绑定完成:", n.data.data), D(n.data.data)), n.data.command === "bindingClicked" && (console.log("[ONLYOFFICE] 绑定控件被点击:", n.data.data), T(n.data.data)), n.data.command === "elementClicked" && (console.log("[ONLYOFFICE] 元素被点击:", n.data.data), C(n.data.data)), n.data.command === "preciseTableCellClicked" && (console.log("[ONLYOFFICE] 精确表格单元格被点击:", n.data.data), E(n.data.data)), n.data.command === "chartClicked" && (console.log("[ONLYOFFICE] 图表被点击:", n.data.data), F(n.data.data)));
|
|
69
|
-
}
|
|
80
|
+
onInfo: (o) => {
|
|
81
|
+
const e = o?.data;
|
|
82
|
+
console.log("[ONLYOFFICE] Info 事件:", o.data), o && (e?.command === "openPlugin" && (console.log("[ONLYOFFICE] openPlugin"), i.frame?.contentWindow?.Common?.Gateway?.sendInfo(e)), o.data.command === "pluginInitialized" && (d.value = !0, console.log("[ONLYOFFICE] 插件初始化完成"), g()), o.data.command === "pluginAck" && console.log("[ONLYOFFICE] 插件确认收到:", o.data), o.data.command === "pluginError" && console.error("[ONLYOFFICE] 插件错误:", o.data), o.data.command === "linkClicked" && (console.log("[ONLYOFFICE] 链接被点击,数据:", o.data.data), C(o.data.data)), o.data.command === "wordArtInserted" && (console.log("[ONLYOFFICE] WordArt 插入成功:", o.data.data), D(o.data.data)), o.data.command === "wordArtError" && (console.error("[ONLYOFFICE] WordArt 插入失败:", o.data.data), E(o.data.data)), o.data.command === "tableClicked" && (console.log("[ONLYOFFICE] 表格被点击,数据:", o.data.data), O(o.data.data)), o.data.command === "selectionAnalyzed" && (console.log("[ONLYOFFICE] 选中内容分析结果:", o.data.data), F(o.data.data)), o.data.command === "selectionBound" && (console.log("[ONLYOFFICE] 选中内容绑定完成:", o.data.data), T(o.data.data)), o.data.command === "bindingClicked" && (console.log("[ONLYOFFICE] 绑定控件被点击:", o.data.data), N(o.data.data)), o.data.command === "elementClicked" && (console.log("[ONLYOFFICE] 元素被点击:", o.data.data), w(o.data.data)), o.data.command === "preciseTableCellClicked" && (console.log("[ONLYOFFICE] 精确表格单元格被点击:", o.data.data), k(o.data.data)), o.data.command === "chartClicked" && (console.log("[ONLYOFFICE] 图表被点击:", o.data.data), A(o.data.data)));
|
|
70
83
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
async function h() {
|
|
87
|
+
await I();
|
|
88
|
+
const o = window.DocsAPI;
|
|
89
|
+
i?.destroyEditor && i.destroyEditor(), d.value = !1, c.config && (m = c.config), i = new o.DocEditor("editor", m);
|
|
75
90
|
}
|
|
76
|
-
function
|
|
91
|
+
function y() {
|
|
77
92
|
try {
|
|
78
|
-
i.executeCommand && i.executeCommand("focus"), console.log("
|
|
93
|
+
i.executeCommand && i.executeCommand("focus"), console.log("autoOpenPluginSidePanel", i), i.serviceCommand && i.serviceCommand("sidePanel", {
|
|
79
94
|
action: "toggle",
|
|
80
95
|
state: !1
|
|
81
96
|
});
|
|
@@ -83,10 +98,10 @@ const P = { class: "onlyoffice-box" }, f = "https://test.xuandou.vip:126", v = "
|
|
|
83
98
|
console.error("auto-open plugin failed:", o);
|
|
84
99
|
}
|
|
85
100
|
}
|
|
86
|
-
function
|
|
101
|
+
function C(o) {
|
|
87
102
|
console.log("处理链接点击事件,收到数据:", o), o && typeof o == "object" && (`${o.controlId || "unknown"}${o.controlTitle || "无标题"}${o.tag || "无Tag"}${JSON.stringify(o.data, null, 2)}${JSON.stringify(o, null, 2)}`, o.data && o.data.name && console.log("检测到用户名:", o.data.name));
|
|
88
103
|
}
|
|
89
|
-
function
|
|
104
|
+
function D(o) {
|
|
90
105
|
if (console.log("WordArt 插入成功,数据:", o), o && o.success) {
|
|
91
106
|
const e = `WordArt 插入成功!
|
|
92
107
|
|
|
@@ -101,10 +116,10 @@ ${o.message || ""}`;
|
|
|
101
116
|
点击"确定"可继续插入更多WordArt`) && console.log("用户选择继续操作WordArt");
|
|
102
117
|
}
|
|
103
118
|
}
|
|
104
|
-
function
|
|
119
|
+
function E(o) {
|
|
105
120
|
console.error("WordArt 插入失败,错误:", o), o?.error;
|
|
106
121
|
}
|
|
107
|
-
function
|
|
122
|
+
function O(o) {
|
|
108
123
|
if (console.log("处理表格点击事件,收到数据:", o), o && o.success && o.data) {
|
|
109
124
|
const e = o.data;
|
|
110
125
|
let n = `表格被点击!
|
|
@@ -135,7 +150,7 @@ ${o.message || ""}`;
|
|
|
135
150
|
} else
|
|
136
151
|
console.log("表格点击检测失败:", o?.error || "未知错误");
|
|
137
152
|
}
|
|
138
|
-
function
|
|
153
|
+
function F(o) {
|
|
139
154
|
if (console.log("处理选中内容分析结果,收到数据:", o), o && o.success && o.data) {
|
|
140
155
|
const e = o.data;
|
|
141
156
|
let n = `选中内容分析结果!
|
|
@@ -155,7 +170,7 @@ ${o.message || ""}`;
|
|
|
155
170
|
} else
|
|
156
171
|
console.log("选中内容分析失败:", o?.error || "未知错误");
|
|
157
172
|
}
|
|
158
|
-
function
|
|
173
|
+
function T(o) {
|
|
159
174
|
if (console.log("处理选中内容绑定完成,收到数据:", o), o && o.success) {
|
|
160
175
|
const e = o.data;
|
|
161
176
|
let n = `数据绑定完成!
|
|
@@ -171,7 +186,7 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
|
|
|
171
186
|
} else
|
|
172
187
|
console.log("数据绑定失败:", o?.error || "未知错误");
|
|
173
188
|
}
|
|
174
|
-
function
|
|
189
|
+
function w(o) {
|
|
175
190
|
if (console.log("🎯 处理通用元素点击事件,收到数据:", o), o && o.success && o.data) {
|
|
176
191
|
const e = o.data;
|
|
177
192
|
let n = `🎯 元素点击检测结果!
|
|
@@ -212,7 +227,7 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
|
|
|
212
227
|
} else
|
|
213
228
|
console.log("❌ 通用元素检测失败:", o?.error || "未知错误");
|
|
214
229
|
}
|
|
215
|
-
function
|
|
230
|
+
function k(o) {
|
|
216
231
|
if (console.log("📊 处理精确表格单元格点击事件,收到数据:", o), o && o.success && o.data) {
|
|
217
232
|
const e = o.data;
|
|
218
233
|
let n = `📊 精确表格单元格点击!
|
|
@@ -237,7 +252,7 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
|
|
|
237
252
|
} else
|
|
238
253
|
console.log("❌ 精确表格单元格检测失败:", o?.error || "未知错误");
|
|
239
254
|
}
|
|
240
|
-
function
|
|
255
|
+
function A(o) {
|
|
241
256
|
if (console.log("📈 处理图表点击事件,收到数据:", o), o && o.success && o.data) {
|
|
242
257
|
const e = o.data;
|
|
243
258
|
let n = `📈 图表点击检测结果!
|
|
@@ -301,7 +316,7 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
|
|
|
301
316
|
`), console.log("📈 图表绑定数据:", e.boundData), e.boundData && (e.boundData.type === "line-chart" ? console.log("📈 这是线图,可以显示趋势分析") : e.boundData.type === "bar-chart" && console.log("📊 这是柱状图,可以显示比较分析"), e.boundData.dataSource === "ERP系统" && console.log("🔄 可以触发ERP系统数据刷新"));
|
|
302
317
|
} else o && o.success === !1 && console.log("❌ 图表检测失败或无图表:", o.error || "未知错误");
|
|
303
318
|
}
|
|
304
|
-
function
|
|
319
|
+
function N(o) {
|
|
305
320
|
if (console.log("处理绑定控件点击事件,收到数据:", o), o && o.success && o.data) {
|
|
306
321
|
const e = o.data;
|
|
307
322
|
let n = "绑定控件被点击!\\n\\n";
|
|
@@ -312,11 +327,17 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
|
|
|
312
327
|
} else
|
|
313
328
|
console.log("绑定控件点击检测失败或无绑定控件:", o?.error || "未知错误"), o?.data?.clickType === "non-binding" && console.log("当前点击位置不是绑定控件");
|
|
314
329
|
}
|
|
315
|
-
|
|
330
|
+
let u = p(!1);
|
|
331
|
+
const x = (o) => {
|
|
332
|
+
o.data.eventType === "customEventReplay" && console.info(o, "DDD11"), o.data.eventType === "customEventCommon" && console.info(o, "DDD22");
|
|
333
|
+
};
|
|
334
|
+
return v(async () => {
|
|
335
|
+
await h(), u.value ? console.warn("⚠️ 消息监听器已存在,跳过重复注册") : (window.addEventListener("message", x), u.value = !0, console.log("✅ 消息监听器已注册"));
|
|
336
|
+
}), L(() => {
|
|
316
337
|
i?.destroyEditor && i.destroyEditor(), a !== null && clearInterval(a);
|
|
317
|
-
}), (o, e) => (
|
|
318
|
-
|
|
319
|
-
e[1] || (e[1] =
|
|
338
|
+
}), (o, e) => (Y(), P("div", _, [
|
|
339
|
+
R("", !0),
|
|
340
|
+
e[1] || (e[1] = B("div", {
|
|
320
341
|
id: "editor",
|
|
321
342
|
style: { flex: "1" }
|
|
322
343
|
}, null, -1))
|
|
@@ -324,5 +345,5 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
|
|
|
324
345
|
}
|
|
325
346
|
});
|
|
326
347
|
export {
|
|
327
|
-
|
|
348
|
+
M as onlyoffice
|
|
328
349
|
};
|
package/dist/onlyoffice.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(l
|
|
1
|
+
(function(a,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],l):(a=typeof globalThis<"u"?globalThis:a||self,l(a.OnlyofficeUI={},a.Vue))})(this,(function(a,l){"use strict";const $={class:"onlyoffice-box"},I="asc.{91EAC419-EF8B-440C-A960-B451C7DF3A37}",h=l.defineComponent({__name:"onlyoffice",props:{config:{type:Object,default:()=>{}},documentServerUrl:{type:String,default:""},onLoadComponentError:{type:Object,default:()=>{}}},setup(y){let i=null;const r=l.ref(!1),s=y;console.log(s,"props");const f=s?.documentServerUrl||"https://test.xuandou.vip:126",g=f+"/web-apps/apps/api/documents/api.js",C=f+"/8.3.1-10ca0f5dd35a63800b6a3956f350bf95/sdkjs-plugins/example_extended_comments/config.json";function D(){return new Promise((o,e)=>{if(window.DocsAPI)return o();const n=document.createElement("script");n.src=g,n.onload=()=>o(),n.onerror=()=>e(new Error("加载 DocsAPI 失败:"+g)),document.head.appendChild(n)})}const u=[];let c=null;function m(){c===null&&(c=window.setInterval(()=>{if(!(!i||typeof i.serviceCommand!="function")&&r.value){for(;u.length;){const{cmd:o,payload:e}=u.shift();try{console.log("[ONLYOFFICE] 发送排队指令:",o,e),i.serviceCommand(o,e)}catch(n){console.error("[ONLYOFFICE] 队列指令发送失败:",o,n)}}c!==null&&(clearInterval(c),c=null)}},300))}const p={document:{fileType:"docx",title:"Demo.docx",url:"https://qiniu2.xuandou.vip/new.docx",key:"test-key",permissions:{edit:!0}},documentType:"word",editorConfig:{lang:"zh-CN",mode:"edit",user:{id:"u1",name:"Tester"},plugins:{autostart:[I],pluginsData:[{url:C+"?v=2.0."+Date.now()}]}},width:"100%",height:"100%",events:{onPluginsReady:()=>{console.log("[ONLYOFFICE] 插件资源已加载,但不代表已初始化")},onDocumentReady:()=>{console.log("[ONLYOFFICE] 文档已就绪"),T(),m(),console.log("window.Asc.plugin1",window?.Asc?.plugin),setTimeout(()=>{console.log("window.Asc.plugin2",window),console.log("window.Asc.plugin3-editor",i.serviceCommand),i.serviceCommand("event_onAddComment",{id:111})},2e3)},onInfo:o=>{const e=o?.data;console.log("[ONLYOFFICE] Info 事件:",o.data),o&&(e?.command==="openPlugin"&&(console.log("[ONLYOFFICE] openPlugin"),i.frame?.contentWindow?.Common?.Gateway?.sendInfo(e)),o.data.command==="pluginInitialized"&&(r.value=!0,console.log("[ONLYOFFICE] 插件初始化完成"),m()),o.data.command==="pluginAck"&&console.log("[ONLYOFFICE] 插件确认收到:",o.data),o.data.command==="pluginError"&&console.error("[ONLYOFFICE] 插件错误:",o.data),o.data.command==="linkClicked"&&(console.log("[ONLYOFFICE] 链接被点击,数据:",o.data.data),E(o.data.data)),o.data.command==="wordArtInserted"&&(console.log("[ONLYOFFICE] WordArt 插入成功:",o.data.data),F(o.data.data)),o.data.command==="wordArtError"&&(console.error("[ONLYOFFICE] WordArt 插入失败:",o.data.data),w(o.data.data)),o.data.command==="tableClicked"&&(console.log("[ONLYOFFICE] 表格被点击,数据:",o.data.data),k(o.data.data)),o.data.command==="selectionAnalyzed"&&(console.log("[ONLYOFFICE] 选中内容分析结果:",o.data.data),A(o.data.data)),o.data.command==="selectionBound"&&(console.log("[ONLYOFFICE] 选中内容绑定完成:",o.data.data),N(o.data.data)),o.data.command==="bindingClicked"&&(console.log("[ONLYOFFICE] 绑定控件被点击:",o.data.data),P(o.data.data)),o.data.command==="elementClicked"&&(console.log("[ONLYOFFICE] 元素被点击:",o.data.data),x(o.data.data)),o.data.command==="preciseTableCellClicked"&&(console.log("[ONLYOFFICE] 精确表格单元格被点击:",o.data.data),S(o.data.data)),o.data.command==="chartClicked"&&(console.log("[ONLYOFFICE] 图表被点击:",o.data.data),L(o.data.data)))}}};async function O(){await D();const o=window.DocsAPI;i?.destroyEditor&&i.destroyEditor(),r.value=!1,s.config&&(p=s.config),i=new o.DocEditor("editor",p)}function T(){try{i.executeCommand&&i.executeCommand("focus"),console.log("autoOpenPluginSidePanel",i),i.serviceCommand&&i.serviceCommand("sidePanel",{action:"toggle",state:!1})}catch(o){console.error("auto-open plugin failed:",o)}}function E(o){console.log("处理链接点击事件,收到数据:",o),o&&typeof o=="object"&&(`${o.controlId||"unknown"}${o.controlTitle||"无标题"}${o.tag||"无Tag"}${JSON.stringify(o.data,null,2)}${JSON.stringify(o,null,2)}`,o.data&&o.data.name&&console.log("检测到用户名:",o.data.name))}function F(o){if(console.log("WordArt 插入成功,数据:",o),o&&o.success){const e=`WordArt 插入成功!
|
|
2
2
|
|
|
3
3
|
文本: ${o.parameters?.text||"未知"}
|
|
4
4
|
字体大小: ${o.parameters?.fontSize||"未知"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
${o.message||""}`;confirm(e+`
|
|
9
9
|
|
|
10
|
-
点击"确定"可继续插入更多WordArt`)&&console.log("用户选择继续操作WordArt")}}function
|
|
10
|
+
点击"确定"可继续插入更多WordArt`)&&console.log("用户选择继续操作WordArt")}}function w(o){console.error("WordArt 插入失败,错误:",o),o?.error}function k(o){if(console.log("处理表格点击事件,收到数据:",o),o&&o.success&&o.data){const e=o.data;let n=`表格被点击!
|
|
11
11
|
|
|
12
12
|
`;e.clickType==="table"?(n+=`点击类型: 表格内容
|
|
13
13
|
`,n+=`表格索引: ${e.tableIndex>=0?e.tableIndex:"未知"}
|
|
@@ -25,7 +25,7 @@ ${o.message||""}`;confirm(e+`
|
|
|
25
25
|
`}),e.tableData.content.length>3&&(n+=`... 还有 ${e.tableData.content.length-3} 行
|
|
26
26
|
`)))):(n+=`点击类型: 非表格区域
|
|
27
27
|
`,n+=`点击时间: ${e.timestamp}
|
|
28
|
-
`),e.clickType==="table"&&e.tableData&&console.log("检测到表格点击,可以执行相关操作:",{tableIndex:e.tableIndex,tableData:e.tableData})}else console.log("表格点击检测失败:",o?.error||"未知错误")}function
|
|
28
|
+
`),e.clickType==="table"&&e.tableData&&console.log("检测到表格点击,可以执行相关操作:",{tableIndex:e.tableIndex,tableData:e.tableData})}else console.log("表格点击检测失败:",o?.error||"未知错误")}function A(o){if(console.log("处理选中内容分析结果,收到数据:",o),o&&o.success&&o.data){const e=o.data;let n=`选中内容分析结果!
|
|
29
29
|
|
|
30
30
|
`;n+=`选择类型: ${e.selectionType}
|
|
31
31
|
`,n+=`是否可绑定: ${e.bindable?"是":"否"}
|
|
@@ -35,7 +35,7 @@ ${o.message||""}`;confirm(e+`
|
|
|
35
35
|
`,e.suggestedBindings.slice(0,3).forEach((t,d)=>{n+=`${d+1}. ${t.description} (${t.category})
|
|
36
36
|
`}),e.suggestedBindings.length>3&&(n+=`... 还有 ${e.suggestedBindings.length-3} 种绑定方式
|
|
37
37
|
`)),n+=`
|
|
38
|
-
分析时间: ${e.timestamp}`,e.bindable&&console.log("内容可以绑定,建议绑定方式:",e.suggestedBindings)}else console.log("选中内容分析失败:",o?.error||"未知错误")}function
|
|
38
|
+
分析时间: ${e.timestamp}`,e.bindable&&console.log("内容可以绑定,建议绑定方式:",e.suggestedBindings)}else console.log("选中内容分析失败:",o?.error||"未知错误")}function N(o){if(console.log("处理选中内容绑定完成,收到数据:",o),o&&o.success){const e=o.data;let n=`数据绑定完成!
|
|
39
39
|
|
|
40
40
|
`;n+=`绑定方法: ${e.method}
|
|
41
41
|
`,n+=`绑定类型: ${e.binding?.type||"未知"}
|
|
@@ -43,7 +43,7 @@ ${o.message||""}`;confirm(e+`
|
|
|
43
43
|
`),e.binding.dataType&&(n+=`数据类型: ${e.binding.dataType}
|
|
44
44
|
`),e.binding.originalValue&&(n+=`原始值: "${e.binding.originalValue}"
|
|
45
45
|
`)),n+=`
|
|
46
|
-
${e.message}`,console.log("数据绑定成功,绑定信息:",e.binding)}else console.log("数据绑定失败:",o?.error||"未知错误")}function
|
|
46
|
+
${e.message}`,console.log("数据绑定成功,绑定信息:",e.binding)}else console.log("数据绑定失败:",o?.error||"未知错误")}function x(o){if(console.log("🎯 处理通用元素点击事件,收到数据:",o),o&&o.success&&o.data){const e=o.data;let n=`🎯 元素点击检测结果!
|
|
47
47
|
|
|
48
48
|
`;n+=`点击类型: ${e.clickType}
|
|
49
49
|
`,n+=`检测时间: ${e.timestamp}
|
|
@@ -74,7 +74,7 @@ ${e.message}`,console.log("数据绑定成功,绑定信息:",e.binding)}else c
|
|
|
74
74
|
`,n+=`- 表格: ${e.fullScanResults.tablesFound}个
|
|
75
75
|
`,n+=`- 段落: ${e.fullScanResults.paragraphsFound}个
|
|
76
76
|
`,n+=`- 图形: ${e.fullScanResults.shapesFound}个
|
|
77
|
-
`),console.log("🎯 元素类型:",e.clickType,"详细信息:",e.elementInfo)}else console.log("❌ 通用元素检测失败:",o?.error||"未知错误")}function
|
|
77
|
+
`),console.log("🎯 元素类型:",e.clickType,"详细信息:",e.elementInfo)}else console.log("❌ 通用元素检测失败:",o?.error||"未知错误")}function S(o){if(console.log("📊 处理精确表格单元格点击事件,收到数据:",o),o&&o.success&&o.data){const e=o.data;let n=`📊 精确表格单元格点击!
|
|
78
78
|
|
|
79
79
|
`;n+=`🎯 单元格位置:
|
|
80
80
|
`,n+=`- 行: 第${e.cellPosition.row}行
|
|
@@ -86,7 +86,7 @@ ${e.message}`,console.log("数据绑定成功,绑定信息:",e.binding)}else c
|
|
|
86
86
|
`,n+=`- 总列数: ${e.tableInfo.totalColumns}
|
|
87
87
|
`,n+=`- 检测方法: ${e.detectionMethod}
|
|
88
88
|
`,n+=`- 检测时间: ${e.timestamp}
|
|
89
|
-
`,console.log("📊 精确单元格信息:",{row:e.cellPosition.row,column:e.cellPosition.column,content:e.cellContent,tableInfo:e.tableInfo}),e.cellPosition.row===1?console.log("🎯 点击了表头行,可以执行排序等操作"):console.log("🎯 点击了数据行,可以执行编辑等操作")}else console.log("❌ 精确表格单元格检测失败:",o?.error||"未知错误")}function
|
|
89
|
+
`,console.log("📊 精确单元格信息:",{row:e.cellPosition.row,column:e.cellPosition.column,content:e.cellContent,tableInfo:e.tableInfo}),e.cellPosition.row===1?console.log("🎯 点击了表头行,可以执行排序等操作"):console.log("🎯 点击了数据行,可以执行编辑等操作")}else console.log("❌ 精确表格单元格检测失败:",o?.error||"未知错误")}function L(o){if(console.log("📈 处理图表点击事件,收到数据:",o),o&&o.success&&o.data){const e=o.data;let n=`📈 图表点击检测结果!
|
|
90
90
|
|
|
91
91
|
`;if(n+=`点击类型: ${e.clickType}
|
|
92
92
|
`,n+=`检测时间: ${e.timestamp}
|
|
@@ -126,4 +126,4 @@ ${e.message}`,console.log("数据绑定成功,绑定信息:",e.binding)}else c
|
|
|
126
126
|
`,n+=`- 文档中图表总数: ${e.detectionSummary.totalChartsFound}
|
|
127
127
|
`,n+=`- 有数据的图表: ${e.detectionSummary.chartsWithData}
|
|
128
128
|
`,n+=`- 有选区: ${e.detectionSummary.hasSelection?"是":"否"}
|
|
129
|
-
`),console.log("📈 图表绑定数据:",e.boundData),e.boundData&&(e.boundData.type==="line-chart"?console.log("📈 这是线图,可以显示趋势分析"):e.boundData.type==="bar-chart"&&console.log("📊 这是柱状图,可以显示比较分析"),e.boundData.dataSource==="ERP系统"&&console.log("🔄 可以触发ERP系统数据刷新"))}else o&&o.success===!1&&console.log("❌ 图表检测失败或无图表:",o.error||"未知错误")}function
|
|
129
|
+
`),console.log("📈 图表绑定数据:",e.boundData),e.boundData&&(e.boundData.type==="line-chart"?console.log("📈 这是线图,可以显示趋势分析"):e.boundData.type==="bar-chart"&&console.log("📊 这是柱状图,可以显示比较分析"),e.boundData.dataSource==="ERP系统"&&console.log("🔄 可以触发ERP系统数据刷新"))}else o&&o.success===!1&&console.log("❌ 图表检测失败或无图表:",o.error||"未知错误")}function P(o){if(console.log("处理绑定控件点击事件,收到数据:",o),o&&o.success&&o.data){const e=o.data;let n="绑定控件被点击!\\n\\n";n+=`点击类型: ${e.clickType}\\n`,n+=`绑定类型: ${e.bindingType}\\n`,n+=`控件索引: ${e.controlIndex}\\n`,n+=`控件别名: ${e.controlAlias||"无"}\\n`,n+=`控件内容: "${e.controlContent||"空"}"\\n`,n+=`点击时间: ${e.timestamp}\\n`,e.bindingData&&(n+="\\n绑定数据详情:\\n",e.bindingType==="data-binding"?(n+=`- 字段名称: ${e.bindingData.fieldName}\\n`,n+=`- 数据类型: ${e.bindingData.dataType}\\n`,n+=`- 原始值: "${e.bindingData.originalValue}"\\n`,n+=`- 绑定时间: ${e.bindingData.boundAt}\\n`):e.bindingType==="template-variable"?(n+=`- 变量名: ${e.bindingData.variableName}\\n`,n+=`- 原始值: "${e.bindingData.originalValue}"\\n`,n+=`- 绑定时间: ${e.bindingData.boundAt}\\n`):e.bindingType==="table-data-binding"?(n+=`- 表格名称: ${e.bindingData.tableName}\\n`,n+=`- 绑定模式: ${e.bindingData.bindingMode}\\n`,n+=`- 绑定时间: ${e.bindingData.boundAt}\\n`):e.bindingType==="paragraph-template"?(n+=`- 模板名称: ${e.bindingData.templateName}\\n`,n+=`- 原始内容: "${e.bindingData.originalContent?.substring(0,50)}${e.bindingData.originalContent?.length>50?"...":""}"\\n`,n+=`- 绑定时间: ${e.bindingData.boundAt}\\n`):e.bindingType==="custom-binding"&&(n+=`- 自定义类型: ${e.bindingData.customType}\\n`,n+=`- 字段名称: ${e.bindingData.fieldName}\\n`,n+=`- 原始值: "${e.bindingData.originalValue}"\\n`,n+=`- 绑定时间: ${e.bindingData.boundAt}\\n`)),console.log("检测到绑定控件点击,可以执行相关操作:",{bindingType:e.bindingType,bindingData:e.bindingData}),e.bindingType==="data-binding"?console.log("数据字段绑定被点击,可以打开数据编辑界面"):e.bindingType==="template-variable"?console.log("模板变量绑定被点击,可以打开变量设置界面"):e.bindingType==="table-data-binding"&&console.log("表格数据源绑定被点击,可以打开数据源配置界面")}else console.log("绑定控件点击检测失败或无绑定控件:",o?.error||"未知错误"),o?.data?.clickType==="non-binding"&&console.log("当前点击位置不是绑定控件")}let b=l.ref(!1);const v=o=>{o.data.eventType==="customEventReplay"&&console.info(o,"DDD11"),o.data.eventType==="customEventCommon"&&console.info(o,"DDD22")};return l.onMounted(async()=>{await O(),b.value?console.warn("⚠️ 消息监听器已存在,跳过重复注册"):(window.addEventListener("message",v),b.value=!0,console.log("✅ 消息监听器已注册"))}),l.onBeforeUnmount(()=>{i?.destroyEditor&&i.destroyEditor(),c!==null&&clearInterval(c)}),(o,e)=>(l.openBlock(),l.createElementBlock("div",$,[l.createCommentVNode("",!0),e[1]||(e[1]=l.createElementVNode("div",{id:"editor",style:{flex:"1"}},null,-1))]))}});a.onlyoffice=h,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
package/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<!-- 替换为你自己的 DocumentServer 地址 -->
|
|
8
8
|
<!-- 例如: http://222.187.11.98:8918/web-apps/apps/api/documents/api.js -->
|
|
9
9
|
<!-- <script src="http://192.168.1.103:9998/web-apps/apps/api/documents/api.js"></script> -->
|
|
10
|
-
<script src="https://test.xuandou.vip:126/web-apps/apps/api/documents/api.js"></script>
|
|
10
|
+
<!-- <script src="https://test.xuandou.vip:126/web-apps/apps/api/documents/api.js"></script> -->
|
|
11
11
|
<!-- <script src="https://prev.xuandou.vip:126/web-apps/apps/api/documents/api.js"></script> -->
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
package/package.json
CHANGED
|
@@ -89,13 +89,31 @@ import { onMounted, onBeforeUnmount, ref } from 'vue'
|
|
|
89
89
|
let editor: any = null
|
|
90
90
|
const pluginReady = ref(false)
|
|
91
91
|
|
|
92
|
+
|
|
93
|
+
const props = defineProps({
|
|
94
|
+
config: {
|
|
95
|
+
type: Object,
|
|
96
|
+
default: () => {}
|
|
97
|
+
},
|
|
98
|
+
documentServerUrl: {
|
|
99
|
+
type: String,
|
|
100
|
+
default: ''
|
|
101
|
+
},
|
|
102
|
+
onLoadComponentError: {
|
|
103
|
+
type: Object,
|
|
104
|
+
default: () => {}
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
console.log(props,'props')
|
|
109
|
+
|
|
92
110
|
// === 按你的环境修改 ===
|
|
93
|
-
|
|
94
|
-
const DOCUMENT_SERVER = 'https://test.xuandou.vip:126'
|
|
111
|
+
const DOCUMENT_SERVER = props?.documentServerUrl || 'https://test.xuandou.vip:126'
|
|
95
112
|
// const DOCUMENT_SERVER = 'https://prev.xuandou.vip:126'
|
|
96
113
|
//const DOCUMENT_SERVER = 'http://222.187.11.98:8918'
|
|
114
|
+
|
|
115
|
+
|
|
97
116
|
const DOCS_API = DOCUMENT_SERVER + '/web-apps/apps/api/documents/api.js'
|
|
98
|
-
const FILE_URL = 'https://badges-1302420147.cos.ap-shanghai.myqcloud.com/test1.docx'
|
|
99
117
|
// https://badges-1302420147.cos.ap-shanghai.myqcloud.com/test1.docx
|
|
100
118
|
// 插件 GUID(需与插件 config.json 一致)
|
|
101
119
|
//9.0.4-9ade76efaf7465c8db6be392804370a8
|
|
@@ -192,20 +210,11 @@ function scheduleFlush() {
|
|
|
192
210
|
}, 300)
|
|
193
211
|
}
|
|
194
212
|
|
|
195
|
-
|
|
196
|
-
async function createEditor() {
|
|
197
|
-
await loadDocsApi()
|
|
198
|
-
// @ts-ignore
|
|
199
|
-
const DocsAPI = (window as any).DocsAPI
|
|
200
|
-
|
|
201
|
-
if (editor?.destroyEditor) editor.destroyEditor()
|
|
202
|
-
pluginReady.value = false
|
|
203
|
-
|
|
204
|
-
const cfg = {
|
|
213
|
+
const cfg = {
|
|
205
214
|
document: {
|
|
206
215
|
fileType: 'docx',
|
|
207
216
|
title: 'Demo.docx',
|
|
208
|
-
url:
|
|
217
|
+
url: 'https://qiniu2.xuandou.vip/new.docx',
|
|
209
218
|
key: 'test-key',
|
|
210
219
|
permissions: { edit: true }
|
|
211
220
|
},
|
|
@@ -310,9 +319,21 @@ async function createEditor() {
|
|
|
310
319
|
}
|
|
311
320
|
}
|
|
312
321
|
|
|
313
|
-
|
|
322
|
+
// ---- 创建编辑器 ----
|
|
323
|
+
async function createEditor() {
|
|
324
|
+
await loadDocsApi()
|
|
325
|
+
// @ts-ignore
|
|
326
|
+
const DocsAPI = (window as any).DocsAPI
|
|
327
|
+
|
|
328
|
+
if (editor?.destroyEditor) editor.destroyEditor()
|
|
329
|
+
pluginReady.value = false
|
|
314
330
|
|
|
331
|
+
|
|
332
|
+
if(props.config){
|
|
333
|
+
cfg = props.config
|
|
334
|
+
}
|
|
315
335
|
|
|
336
|
+
editor = new DocsAPI.DocEditor('editor', cfg)
|
|
316
337
|
|
|
317
338
|
}
|
|
318
339
|
|
|
@@ -366,7 +387,6 @@ function insertLink() {
|
|
|
366
387
|
json:{name:'gm'}
|
|
367
388
|
});
|
|
368
389
|
}
|
|
369
|
-
|
|
370
390
|
// ---- WordArt 相关功能 ----
|
|
371
391
|
function insertCustomWordArt() {
|
|
372
392
|
// 自定义 WordArt 参数
|
|
@@ -386,14 +406,12 @@ function insertCustomWordArt() {
|
|
|
386
406
|
rotation: 0
|
|
387
407
|
});
|
|
388
408
|
}
|
|
389
|
-
|
|
390
409
|
function insertClassicWordArt() {
|
|
391
410
|
serviceCommandSafe('insertPresetWordArt', {
|
|
392
411
|
preset: 'classic',
|
|
393
412
|
text: 'CLASSIC'
|
|
394
413
|
});
|
|
395
414
|
}
|
|
396
|
-
|
|
397
415
|
function insertModernWordArt() {
|
|
398
416
|
serviceCommandSafe('insertPresetWordArt', {
|
|
399
417
|
preset: 'modern',
|
|
@@ -1127,26 +1145,26 @@ function handleBindingClicked(data: any) {
|
|
|
1127
1145
|
|
|
1128
1146
|
|
|
1129
1147
|
// 使用标志确保监听器只注册一次
|
|
1130
|
-
let messageListenerRegistered = false;
|
|
1148
|
+
let messageListenerRegistered = ref(false);
|
|
1131
1149
|
const messageHandler = (event) => {
|
|
1132
1150
|
// 您的业务逻辑...
|
|
1133
1151
|
if (event.data.eventType === 'customEventReplay') {
|
|
1134
|
-
console.info(event,'
|
|
1152
|
+
console.info(event,'DDD11')
|
|
1135
1153
|
}
|
|
1136
1154
|
|
|
1137
1155
|
if (event.data.eventType === 'customEventCommon') {
|
|
1138
|
-
console.info(event,'
|
|
1156
|
+
console.info(event,'DDD22')
|
|
1139
1157
|
}
|
|
1140
1158
|
};
|
|
1141
1159
|
|
|
1142
1160
|
|
|
1143
|
-
onMounted(() =>{
|
|
1161
|
+
onMounted(async() =>{
|
|
1144
1162
|
|
|
1145
|
-
createEditor()
|
|
1163
|
+
await createEditor()
|
|
1146
1164
|
|
|
1147
|
-
if (!messageListenerRegistered) {
|
|
1165
|
+
if (!messageListenerRegistered.value) {
|
|
1148
1166
|
window.addEventListener('message', messageHandler);
|
|
1149
|
-
messageListenerRegistered = true;
|
|
1167
|
+
messageListenerRegistered.value = true;
|
|
1150
1168
|
console.log('✅ 消息监听器已注册');
|
|
1151
1169
|
} else {
|
|
1152
1170
|
console.warn('⚠️ 消息监听器已存在,跳过重复注册');
|