sur-onlyoffice 1.0.8 → 1.0.9

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.
@@ -1,5 +1,5 @@
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({
1
+ import { defineComponent as v, ref as b, onMounted as P, onBeforeUnmount as L, createElementBlock as Y, openBlock as R, createCommentVNode as B, createElementVNode as _ } from "vue";
2
+ const j = { class: "onlyoffice-box" }, M = "asc.{91EAC419-EF8B-440C-A960-B451C7DF3A37}", U = /* @__PURE__ */ v({
3
3
  __name: "onlyoffice",
4
4
  props: {
5
5
  config: {
@@ -17,36 +17,42 @@ const _ = { class: "onlyoffice-box" }, W = "asc.{91EAC419-EF8B-440C-A960-B451C7D
17
17
  }
18
18
  }
19
19
  },
20
- setup(b) {
20
+ setup($) {
21
21
  let i = null;
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() {
22
+ const d = b(!1), a = $;
23
+ console.log(a, "props", a?.documentServerUrl);
24
+ const r = a?.documentServerUrl || "https://test.xuandou.vip:126", f = r + "/web-apps/apps/api/documents/api.js", I = r + "/8.3.1-10ca0f5dd35a63800b6a3956f350bf95/sdkjs-plugins/example_extended_comments/config.json";
25
+ function y() {
26
26
  return new Promise((o, e) => {
27
27
  if (window.DocsAPI) return o();
28
28
  const n = document.createElement("script");
29
- n.src = r, n.onload = () => o(), n.onerror = () => e(new Error("加载 DocsAPI 失败:" + r)), document.head.appendChild(n);
29
+ n.src = f, n.onload = () => o(), n.onerror = () => e(new Error("加载 DocsAPI 失败:" + f)), document.head.appendChild(n);
30
30
  });
31
31
  }
32
- const f = [];
33
- let a = null;
34
- function g() {
35
- a === null && (a = window.setInterval(() => {
32
+ const g = [];
33
+ let l = null;
34
+ function m() {
35
+ l === null && (l = window.setInterval(() => {
36
36
  if (!(!i || typeof i.serviceCommand != "function") && d.value) {
37
- for (; f.length; ) {
38
- const { cmd: o, payload: e } = f.shift();
37
+ for (; g.length; ) {
38
+ const { cmd: o, payload: e } = g.shift();
39
39
  try {
40
40
  console.log("[ONLYOFFICE] 发送排队指令:", o, e), i.serviceCommand(o, e);
41
41
  } catch (n) {
42
42
  console.error("[ONLYOFFICE] 队列指令发送失败:", o, n);
43
43
  }
44
44
  }
45
- a !== null && (clearInterval(a), a = null);
45
+ l !== null && (clearInterval(l), l = null);
46
46
  }
47
47
  }, 300));
48
48
  }
49
- const m = {
49
+ function u(o, e) {
50
+ const n = { ...o };
51
+ for (const t in e)
52
+ e.hasOwnProperty(t) && (n.hasOwnProperty(t) && typeof n[t] == "object" && n[t] !== null && !Array.isArray(n[t]) && typeof e[t] == "object" && e[t] !== null && !Array.isArray(e[t]) ? n[t] = u(n[t], e[t]) : n[t] = e[t]);
53
+ return n;
54
+ }
55
+ let s = {
50
56
  document: {
51
57
  fileType: "docx",
52
58
  title: "Demo.docx",
@@ -61,8 +67,8 @@ const _ = { class: "onlyoffice-box" }, W = "asc.{91EAC419-EF8B-440C-A960-B451C7D
61
67
  user: { id: "u1", name: "Tester" },
62
68
  plugins: {
63
69
  //!
64
- autostart: [W],
65
- pluginsData: [{ url: $ + "?v=2.0." + Date.now() }]
70
+ autostart: [M],
71
+ pluginsData: [{ url: I + "?v=2.0." + Date.now() }]
66
72
  // 强刷缓存
67
73
  }
68
74
  },
@@ -73,22 +79,22 @@ const _ = { class: "onlyoffice-box" }, W = "asc.{91EAC419-EF8B-440C-A960-B451C7D
73
79
  console.log("[ONLYOFFICE] 插件资源已加载,但不代表已初始化");
74
80
  },
75
81
  onDocumentReady: () => {
76
- console.log("[ONLYOFFICE] 文档已就绪"), y(), g(), console.log("window.Asc.plugin1", window?.Asc?.plugin), setTimeout(() => {
82
+ console.log("[ONLYOFFICE] 文档已就绪"), C(), m(), console.log("window.Asc.plugin1", window?.Asc?.plugin), setTimeout(() => {
77
83
  console.log("window.Asc.plugin2", window), console.log("window.Asc.plugin3-editor", i.serviceCommand), i.serviceCommand("event_onAddComment", { id: 111 });
78
84
  }, 2e3);
79
85
  },
80
86
  onInfo: (o) => {
81
87
  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)));
88
+ 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] 插件初始化完成"), 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), D(o.data.data)), o.data.command === "wordArtInserted" && (console.log("[ONLYOFFICE] WordArt 插入成功:", o.data.data), O(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), w(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), x(o.data.data)), o.data.command === "elementClicked" && (console.log("[ONLYOFFICE] 元素被点击:", o.data.data), A(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), N(o.data.data)));
83
89
  }
84
90
  }
85
91
  };
86
92
  async function h() {
87
- await I();
93
+ await y();
88
94
  const o = window.DocsAPI;
89
- i?.destroyEditor && i.destroyEditor(), d.value = !1, c.config && (m = c.config), i = new o.DocEditor("editor", m);
95
+ i?.destroyEditor && i.destroyEditor(), d.value = !1, a.config && (s = u(s, a.config)), i = new o.DocEditor("editor", s);
90
96
  }
91
- function y() {
97
+ function C() {
92
98
  try {
93
99
  i.executeCommand && i.executeCommand("focus"), console.log("autoOpenPluginSidePanel", i), i.serviceCommand && i.serviceCommand("sidePanel", {
94
100
  action: "toggle",
@@ -98,10 +104,10 @@ const _ = { class: "onlyoffice-box" }, W = "asc.{91EAC419-EF8B-440C-A960-B451C7D
98
104
  console.error("auto-open plugin failed:", o);
99
105
  }
100
106
  }
101
- function C(o) {
107
+ function D(o) {
102
108
  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));
103
109
  }
104
- function D(o) {
110
+ function O(o) {
105
111
  if (console.log("WordArt 插入成功,数据:", o), o && o.success) {
106
112
  const e = `WordArt 插入成功!
107
113
 
@@ -119,7 +125,7 @@ ${o.message || ""}`;
119
125
  function E(o) {
120
126
  console.error("WordArt 插入失败,错误:", o), o?.error;
121
127
  }
122
- function O(o) {
128
+ function w(o) {
123
129
  if (console.log("处理表格点击事件,收到数据:", o), o && o.success && o.data) {
124
130
  const e = o.data;
125
131
  let n = `表格被点击!
@@ -137,8 +143,8 @@ ${o.message || ""}`;
137
143
  `, n += `- 列数: ${e.tableData.columns}
138
144
  `, e.tableData.content && e.tableData.content.length > 0 && (n += `
139
145
  表格内容预览:
140
- `, e.tableData.content.slice(0, 3).forEach((t, l) => {
141
- n += `第${l + 1}行: [${t.join(", ")}]
146
+ `, e.tableData.content.slice(0, 3).forEach((t, c) => {
147
+ n += `第${c + 1}行: [${t.join(", ")}]
142
148
  `;
143
149
  }), e.tableData.content.length > 3 && (n += `... 还有 ${e.tableData.content.length - 3} 行
144
150
  `)))) : (n += `点击类型: 非表格区域
@@ -161,8 +167,8 @@ ${o.message || ""}`;
161
167
  `, n += `选中内容: "${e.content.substring(0, 50)}${e.content.length > 50 ? "..." : ""}"
162
168
 
163
169
  `, e.suggestedBindings && e.suggestedBindings.length > 0 && (n += `建议的绑定方式:
164
- `, e.suggestedBindings.slice(0, 3).forEach((t, l) => {
165
- n += `${l + 1}. ${t.description} (${t.category})
170
+ `, e.suggestedBindings.slice(0, 3).forEach((t, c) => {
171
+ n += `${c + 1}. ${t.description} (${t.category})
166
172
  `;
167
173
  }), e.suggestedBindings.length > 3 && (n += `... 还有 ${e.suggestedBindings.length - 3} 种绑定方式
168
174
  `)), n += `
@@ -186,7 +192,7 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
186
192
  } else
187
193
  console.log("数据绑定失败:", o?.error || "未知错误");
188
194
  }
189
- function w(o) {
195
+ function A(o) {
190
196
  if (console.log("🎯 处理通用元素点击事件,收到数据:", o), o && o.success && o.data) {
191
197
  const e = o.data;
192
198
  let n = `🎯 元素点击检测结果!
@@ -203,8 +209,8 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
203
209
  `, n += `- 单元格内容: "${e.elementInfo.clickedCellInfo?.content || "空"}"
204
210
  `), e.elementInfo.sampleContent && e.elementInfo.sampleContent.length > 0 && (n += `
205
211
  📋 表格内容预览:
206
- `, e.elementInfo.sampleContent.slice(0, 2).forEach((t, l) => {
207
- n += `第${l + 1}行: [${t.slice(0, 3).join(", ")}${t.length > 3 ? "..." : ""}]
212
+ `, e.elementInfo.sampleContent.slice(0, 2).forEach((t, c) => {
213
+ n += `第${c + 1}行: [${t.slice(0, 3).join(", ")}${t.length > 3 ? "..." : ""}]
208
214
  `;
209
215
  }))) : e.clickType === "paragraph" ? (n += `📝 段落信息:
210
216
  `, n += `- 段落索引: ${e.elementInfo.paragraphIndex}
@@ -252,7 +258,7 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
252
258
  } else
253
259
  console.log("❌ 精确表格单元格检测失败:", o?.error || "未知错误");
254
260
  }
255
- function A(o) {
261
+ function N(o) {
256
262
  if (console.log("📈 处理图表点击事件,收到数据:", o), o && o.success && o.data) {
257
263
  const e = o.data;
258
264
  let n = `📈 图表点击检测结果!
@@ -316,7 +322,7 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
316
322
  `), 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系统数据刷新"));
317
323
  } else o && o.success === !1 && console.log("❌ 图表检测失败或无图表:", o.error || "未知错误");
318
324
  }
319
- function N(o) {
325
+ function x(o) {
320
326
  if (console.log("处理绑定控件点击事件,收到数据:", o), o && o.success && o.data) {
321
327
  const e = o.data;
322
328
  let n = "绑定控件被点击!\\n\\n";
@@ -327,17 +333,17 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
327
333
  } else
328
334
  console.log("绑定控件点击检测失败或无绑定控件:", o?.error || "未知错误"), o?.data?.clickType === "non-binding" && console.log("当前点击位置不是绑定控件");
329
335
  }
330
- let u = p(!1);
331
- const x = (o) => {
336
+ let p = b(!1);
337
+ const S = (o) => {
332
338
  o.data.eventType === "customEventReplay" && console.info(o, "DDD11"), o.data.eventType === "customEventCommon" && console.info(o, "DDD22");
333
339
  };
334
- return v(async () => {
335
- await h(), u.value ? console.warn("⚠️ 消息监听器已存在,跳过重复注册") : (window.addEventListener("message", x), u.value = !0, console.log("✅ 消息监听器已注册"));
340
+ return P(async () => {
341
+ await h(), p.value ? console.warn("⚠️ 消息监听器已存在,跳过重复注册") : (window.addEventListener("message", S), p.value = !0, console.log("✅ 消息监听器已注册"));
336
342
  }), L(() => {
337
- i?.destroyEditor && i.destroyEditor(), a !== null && clearInterval(a);
338
- }), (o, e) => (Y(), P("div", _, [
339
- R("", !0),
340
- e[1] || (e[1] = B("div", {
343
+ i?.destroyEditor && i.destroyEditor(), l !== null && clearInterval(l);
344
+ }), (o, e) => (R(), Y("div", j, [
345
+ B("", !0),
346
+ e[1] || (e[1] = _("div", {
341
347
  id: "editor",
342
348
  style: { flex: "1" }
343
349
  }, null, -1))
@@ -345,5 +351,5 @@ ${e.message}`, console.log("数据绑定成功,绑定信息:", e.binding);
345
351
  }
346
352
  });
347
353
  export {
348
- M as onlyoffice
354
+ U as onlyoffice
349
355
  };
@@ -1,4 +1,4 @@
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 插入成功!
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 y={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(C){let i=null;const r=l.ref(!1),d=C;console.log(d,"props",d?.documentServerUrl);const g=d?.documentServerUrl||"https://test.xuandou.vip:126",u=g+"/web-apps/apps/api/documents/api.js",D=g+"/8.3.1-10ca0f5dd35a63800b6a3956f350bf95/sdkjs-plugins/example_extended_comments/config.json";function O(){return new Promise((o,e)=>{if(window.DocsAPI)return o();const n=document.createElement("script");n.src=u,n.onload=()=>o(),n.onerror=()=>e(new Error("加载 DocsAPI 失败:"+u)),document.head.appendChild(n)})}const m=[];let c=null;function p(){c===null&&(c=window.setInterval(()=>{if(!(!i||typeof i.serviceCommand!="function")&&r.value){for(;m.length;){const{cmd:o,payload:e}=m.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))}function b(o,e){const n={...o};for(const t in e)e.hasOwnProperty(t)&&(n.hasOwnProperty(t)&&typeof n[t]=="object"&&n[t]!==null&&!Array.isArray(n[t])&&typeof e[t]=="object"&&e[t]!==null&&!Array.isArray(e[t])?n[t]=b(n[t],e[t]):n[t]=e[t]);return n}let f={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:D+"?v=2.0."+Date.now()}]}},width:"100%",height:"100%",events:{onPluginsReady:()=>{console.log("[ONLYOFFICE] 插件资源已加载,但不代表已初始化")},onDocumentReady:()=>{console.log("[ONLYOFFICE] 文档已就绪"),E(),p(),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] 插件初始化完成"),p()),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),w(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),A(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),N(o.data.data)),o.data.command==="selectionBound"&&(console.log("[ONLYOFFICE] 选中内容绑定完成:",o.data.data),S(o.data.data)),o.data.command==="bindingClicked"&&(console.log("[ONLYOFFICE] 绑定控件被点击:",o.data.data),v(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),P(o.data.data)),o.data.command==="chartClicked"&&(console.log("[ONLYOFFICE] 图表被点击:",o.data.data),L(o.data.data)))}}};async function T(){await O();const o=window.DocsAPI;i?.destroyEditor&&i.destroyEditor(),r.value=!1,d.config&&(f=b(f,d.config)),i=new o.DocEditor("editor",f)}function E(){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 w(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 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=`表格被点击!
10
+ 点击"确定"可继续插入更多WordArt`)&&console.log("用户选择继续操作WordArt")}}function A(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:"未知"}
@@ -21,21 +21,21 @@ ${o.message||""}`;confirm(e+`
21
21
  `,n+=`- 列数: ${e.tableData.columns}
22
22
  `,e.tableData.content&&e.tableData.content.length>0&&(n+=`
23
23
  表格内容预览:
24
- `,e.tableData.content.slice(0,3).forEach((t,d)=>{n+=`第${d+1}行: [${t.join(", ")}]
24
+ `,e.tableData.content.slice(0,3).forEach((t,s)=>{n+=`第${s+1}行: [${t.join(", ")}]
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 A(o){if(console.log("处理选中内容分析结果,收到数据:",o),o&&o.success&&o.data){const e=o.data;let n=`选中内容分析结果!
28
+ `),e.clickType==="table"&&e.tableData&&console.log("检测到表格点击,可以执行相关操作:",{tableIndex:e.tableIndex,tableData:e.tableData})}else console.log("表格点击检测失败:",o?.error||"未知错误")}function N(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?"是":"否"}
32
32
  `,n+=`选中内容: "${e.content.substring(0,50)}${e.content.length>50?"...":""}"
33
33
 
34
34
  `,e.suggestedBindings&&e.suggestedBindings.length>0&&(n+=`建议的绑定方式:
35
- `,e.suggestedBindings.slice(0,3).forEach((t,d)=>{n+=`${d+1}. ${t.description} (${t.category})
35
+ `,e.suggestedBindings.slice(0,3).forEach((t,s)=>{n+=`${s+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 N(o){if(console.log("处理选中内容绑定完成,收到数据:",o),o&&o.success){const e=o.data;let n=`数据绑定完成!
38
+ 分析时间: ${e.timestamp}`,e.bindable&&console.log("内容可以绑定,建议绑定方式:",e.suggestedBindings)}else console.log("选中内容分析失败:",o?.error||"未知错误")}function S(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||"未知"}
@@ -56,7 +56,7 @@ ${e.message}`,console.log("数据绑定成功,绑定信息:",e.binding)}else c
56
56
  `,n+=`- 单元格内容: "${e.elementInfo.clickedCellInfo?.content||"空"}"
57
57
  `),e.elementInfo.sampleContent&&e.elementInfo.sampleContent.length>0&&(n+=`
58
58
  📋 表格内容预览:
59
- `,e.elementInfo.sampleContent.slice(0,2).forEach((t,d)=>{n+=`第${d+1}行: [${t.slice(0,3).join(", ")}${t.length>3?"...":""}]
59
+ `,e.elementInfo.sampleContent.slice(0,2).forEach((t,s)=>{n+=`第${s+1}行: [${t.slice(0,3).join(", ")}${t.length>3?"...":""}]
60
60
  `}))):e.clickType==="paragraph"?(n+=`📝 段落信息:
61
61
  `,n+=`- 段落索引: ${e.elementInfo.paragraphIndex}
62
62
  `,n+=`- 对齐方式: ${e.elementInfo.alignment}
@@ -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 S(o){if(console.log("📊 处理精确表格单元格点击事件,收到数据:",o),o&&o.success&&o.data){const e=o.data;let n=`📊 精确表格单元格点击!
77
+ `),console.log("🎯 元素类型:",e.clickType,"详细信息:",e.elementInfo)}else console.log("❌ 通用元素检测失败:",o?.error||"未知错误")}function P(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}行
@@ -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 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"})}));
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 v(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 $=l.ref(!1);const Y=o=>{o.data.eventType==="customEventReplay"&&console.info(o,"DDD11"),o.data.eventType==="customEventCommon"&&console.info(o,"DDD22")};return l.onMounted(async()=>{await T(),$.value?console.warn("⚠️ 消息监听器已存在,跳过重复注册"):(window.addEventListener("message",Y),$.value=!0,console.log("✅ 消息监听器已注册"))}),l.onBeforeUnmount(()=>{i?.destroyEditor&&i.destroyEditor(),c!==null&&clearInterval(c)}),(o,e)=>(l.openBlock(),l.createElementBlock("div",y,[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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sur-onlyoffice",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "文档",
5
5
  "main": "dist/onlyoffice.umd.js",
6
6
  "module": "dist/onlyoffice.es.js",
package/src/App.vue ADDED
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <div class="onlyoffice-test">
3
+ <onlyoffice :documentServerUrl="'https://test.xuandou.vip:126'" />
4
+ </div>
5
+ </template>
6
+
7
+ <script lang="ts" setup>
8
+ import onlyoffice from './package/onlyoffice.vue'
9
+ </script>
package/src/index.ts CHANGED
@@ -8,9 +8,11 @@
8
8
 
9
9
  // 测试
10
10
  // import { createApp } from 'vue'
11
- // import App from './package/onlyoffice.vue'
11
+ // import App from './App.vue'
12
12
  // createApp(App).mount('#app')
13
13
 
14
+
15
+
14
16
  import onlyoffice from "./package/onlyoffice.vue";
15
17
  export { onlyoffice };
16
18
 
@@ -105,7 +105,7 @@ const props = defineProps({
105
105
  },
106
106
  })
107
107
 
108
- console.log(props,'props')
108
+ console.log(props,'props',props?.documentServerUrl)
109
109
 
110
110
  // === 按你的环境修改 ===
111
111
  const DOCUMENT_SERVER = props?.documentServerUrl || 'https://test.xuandou.vip:126'
@@ -210,7 +210,34 @@ function scheduleFlush() {
210
210
  }, 300)
211
211
  }
212
212
 
213
- const cfg = {
213
+
214
+ function deepMerge(original, updates) {
215
+ const result = { ...original };
216
+
217
+ for (const key in updates) {
218
+ if (updates.hasOwnProperty(key)) {
219
+ // 如果原对象有该属性且都是对象类型,则递归合并
220
+ if (
221
+ result.hasOwnProperty(key) &&
222
+ typeof result[key] === 'object' &&
223
+ result[key] !== null &&
224
+ !Array.isArray(result[key]) &&
225
+ typeof updates[key] === 'object' &&
226
+ updates[key] !== null &&
227
+ !Array.isArray(updates[key])
228
+ ) {
229
+ result[key] = deepMerge(result[key], updates[key]);
230
+ } else {
231
+ // 否则直接替换(包括数组和基本类型)
232
+ result[key] = updates[key];
233
+ }
234
+ }
235
+ }
236
+
237
+ return result;
238
+ }
239
+
240
+ let cfg = {
214
241
  document: {
215
242
  fileType: 'docx',
216
243
  title: 'Demo.docx',
@@ -330,7 +357,7 @@ async function createEditor() {
330
357
 
331
358
 
332
359
  if(props.config){
333
- cfg = props.config
360
+ cfg = deepMerge(cfg, props.config);
334
361
  }
335
362
 
336
363
  editor = new DocsAPI.DocEditor('editor', cfg)