From dccacda5d808717576f49e76c75953286cb6ca74 Mon Sep 17 00:00:00 2001
From: tangjie <122778500@qq.com>
Date: Mon, 20 Jul 2026 11:16:32 +0800
Subject: [PATCH] feat
---
src/api/safetyEvalBusiness/index.js | 0
src/enumerate/namespace/index.js | 1 +
src/pages/Container/Layout/menuConfig.js | 17 +
.../SafetyEvalBusiness/MyProject/index.js | 146 ++++++
.../SafetyEvalBusiness/ProjectFlow/index.js | 72 +++
.../Container/SafetyEvalBusiness/index.js | 12 +
src/pages/Container/Test/edtior/index.js | 27 --
src/pages/Container/Test/edtior/index.less | 4 -
src/pages/Container/WpsEditor/index.js | 176 ++++++++
src/pages/Container/WpsEditor/index.less | 132 ++++++
src/web-office-sdk-solution-v2.0.7/index.d.ts | 415 ++++++++++++++++++
.../web-office-sdk-solution-v2.0.7.cjs.js | 1 +
.../web-office-sdk-solution-v2.0.7.es.js | 1 +
.../web-office-sdk-solution-v2.0.7.umd.js | 1 +
14 files changed, 974 insertions(+), 31 deletions(-)
create mode 100644 src/api/safetyEvalBusiness/index.js
create mode 100644 src/pages/Container/SafetyEvalBusiness/MyProject/index.js
create mode 100644 src/pages/Container/SafetyEvalBusiness/ProjectFlow/index.js
create mode 100644 src/pages/Container/SafetyEvalBusiness/index.js
delete mode 100644 src/pages/Container/Test/edtior/index.js
delete mode 100644 src/pages/Container/Test/edtior/index.less
create mode 100644 src/pages/Container/WpsEditor/index.js
create mode 100644 src/pages/Container/WpsEditor/index.less
create mode 100644 src/web-office-sdk-solution-v2.0.7/index.d.ts
create mode 100644 src/web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.cjs.js
create mode 100644 src/web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.es.js
create mode 100644 src/web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.umd.js
diff --git a/src/api/safetyEvalBusiness/index.js b/src/api/safetyEvalBusiness/index.js
new file mode 100644
index 0000000..e69de29
diff --git a/src/enumerate/namespace/index.js b/src/enumerate/namespace/index.js
index 5d741e1..a1b9996 100644
--- a/src/enumerate/namespace/index.js
+++ b/src/enumerate/namespace/index.js
@@ -22,3 +22,4 @@ export const NS_QUAL_REVIEW = defineNamespace("qualReview");
export const NS_QUAL_EXPERT = defineNamespace("qualExpert");
export const NS_DRIVER = defineNamespace("driver");
export const NS_RISK_CENTER = defineNamespace("riskCenter");
+export const NS_SAFETY_EVAL_BUSINESS = defineNamespace("safetyEvalBusiness");
diff --git a/src/pages/Container/Layout/menuConfig.js b/src/pages/Container/Layout/menuConfig.js
index 1bb5140..d400498 100644
--- a/src/pages/Container/Layout/menuConfig.js
+++ b/src/pages/Container/Layout/menuConfig.js
@@ -192,6 +192,23 @@ const menuItems = [
},
],
},
+ {
+ key: "/safetyEval/container/SafetyEvalBusiness",
+ label: "安评业务管理",
+ icon: ,
+ children: [
+ {
+ key: "/safetyEval/container/SafetyEvalBusiness/MyProject",
+ label: "我的项目",
+ icon: ,
+ },
+ {
+ key: "/safetyEval/container/SafetyEvalBusiness/ProjectFlow",
+ label: "项目流程",
+ icon: ,
+ },
+ ],
+ },
{
key: "/safetyEval/container/test",
label: "测试",
diff --git a/src/pages/Container/SafetyEvalBusiness/MyProject/index.js b/src/pages/Container/SafetyEvalBusiness/MyProject/index.js
new file mode 100644
index 0000000..88a2bf4
--- /dev/null
+++ b/src/pages/Container/SafetyEvalBusiness/MyProject/index.js
@@ -0,0 +1,146 @@
+import React from "react";
+import { Form, Table, Tag, Button, Card, Row, Col, Statistic, Select } from "antd";
+import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
+import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm";
+import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper";
+import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction";
+import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd";
+import { NS_SAFETY_EVAL_BUSINESS } from "~/enumerate/namespace";
+
+import { Connect } from "@cqsjjb/jjb-dva-runtime";
+
+const MOCK_LIST = [
+ {
+ id: 1, projectName: "华安化工园区安全预评价", projectCode: "XP-2026-001",
+ myRole: "项目负责人", leader: "张建国",
+ startDate: "2026-03-01", endDate: "2026-09-30", phase: "正常",
+ },
+ {
+ id: 2, projectName: "鼎信建设安全验收评价", projectCode: "XP-2026-002",
+ myRole: "报告编制人", leader: "李明华",
+ startDate: "2026-05-15", endDate: "2026-11-15", phase: "正常",
+ },
+ {
+ id: 3, projectName: "安环检测年度安全现状评价", projectCode: "XP-2025-045",
+ myRole: "过程控制负责人", leader: "陈志强",
+ startDate: "2025-08-01", endDate: "2026-05-30", phase: "延期",
+ },
+];
+
+const MyProject = (props) => {
+ const [form] = Form.useForm();
+
+ const columns = [
+ {
+ title: "序号", dataIndex: "id", width: 60, fixed: "left",
+ render: (_, __, index) => index + 1,
+ },
+ {
+ title: "项目名称", dataIndex: "projectName", width: 220, ellipsis: true,
+ render: (text, record) => (
+
+
{text}
+
{record.projectCode}
+
+ ),
+ },
+ { title: "我的角色", dataIndex: "myRole", width: 130 },
+ { title: "项目负责人", dataIndex: "leader", width: 100 },
+ { title: "项目开始时间", dataIndex: "startDate", width: 120 },
+ { title: "项目结束时间", dataIndex: "endDate", width: 120 },
+ {
+ title: "项目阶段", dataIndex: "phase", width: 100,
+ render: (phase) => (
+ {phase}
+ ),
+ },
+ {
+ title: "操作", width: 140, fixed: "right",
+ render: (_, record) => (
+
+
+
+
+ ),
+ },
+ ];
+
+ return (
+
+
+
+
+
+ 负责人/编制人/审核人
+
+
+
+
+
+ 当前角色可操作节点
+
+
+
+
+
+ 需定位打卡和人脸识别
+
+
+
+
+
+ 需优先处理
+
+
+
+
+
+
+ ,
+
+
+ 项目负责人
+ 报告编制人
+ 技术负责人
+ 过程控制负责人
+
+ ,
+
+
+ 正常
+ 延期
+ 作废
+
+ ,
+ ]}
+ onFinish={() => {}}
+ onReset={() => form.resetFields()}
+ />
+
+ `共 ${total} 条`,
+ pageSize: 10,
+ }}
+ />
+
+ );
+};
+
+
+export default Connect(
+ [NS_SAFETY_EVAL_BUSINESS],
+ true,
+)(AntdTableFuncControl(MyProject));
\ No newline at end of file
diff --git a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/index.js b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/index.js
new file mode 100644
index 0000000..f0e6909
--- /dev/null
+++ b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/index.js
@@ -0,0 +1,72 @@
+import React, { useState } from "react";
+import { Tabs, Tag, Alert, Button, Card } from "antd";
+import { ArrowLeftOutlined } from "@ant-design/icons";
+import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
+import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd";
+
+const PROCESS_TABS = [
+ { key: "risk", index: "01", label: "风险分析", state: "已完成", stateType: "success" },
+ { key: "contract", index: "02", label: "业务合同", state: "已完成", stateType: "success" },
+ { key: "team", index: "03", label: "项目组", state: "已完成", stateType: "success" },
+ { key: "survey", index: "04", label: "现场踏勘", state: "已完成", stateType: "success" },
+ { key: "report", index: "05", label: "报告编制", state: "编制中", stateType: "processing" },
+ { key: "internal", index: "06", label: "内部审核", state: "待办理", stateType: "default" },
+ { key: "technical", index: "07", label: "技术审核", state: "待办理", stateType: "default" },
+ { key: "control", index: "08", label: "过程控制", state: "前置未完成", stateType: "warning", locked: true },
+];
+
+const ProjectFlow = (props) => {
+ const [activeKey, setActiveKey] = useState("risk");
+
+ const tabItems = PROCESS_TABS.map((item) => ({
+ key: item.key,
+ disabled: item.locked,
+ label: (
+
+ {item.index} {item.label}
+ {item.state}
+
+ ),
+ children: (
+
+
+ {item.index} {item.label} 子流程页面
+
+
+ ),
+ }));
+
+ return (
+
+ }
+ onClick={() => props.history.push("MyProject")}
+ style={{ paddingLeft: 0 }}
+ >
+ 返回
+
+ 项目法定流程工作台
+
+ }
+ extra={全量项目管理}
+ >
+
+ 华安化工园区安全预评价 | XP-2026-001
+
+
+
+
+
+
+ );
+};
+
+export default AntdTableFuncControl(ProjectFlow);
\ No newline at end of file
diff --git a/src/pages/Container/SafetyEvalBusiness/index.js b/src/pages/Container/SafetyEvalBusiness/index.js
new file mode 100644
index 0000000..baee37d
--- /dev/null
+++ b/src/pages/Container/SafetyEvalBusiness/index.js
@@ -0,0 +1,12 @@
+
+import React from "react";
+
+function SafetyEvalBusiness(props) {
+ return (
+
+ props.children
+
+ );
+}
+
+export default SafetyEvalBusiness;
diff --git a/src/pages/Container/Test/edtior/index.js b/src/pages/Container/Test/edtior/index.js
deleted file mode 100644
index b6f2626..0000000
--- a/src/pages/Container/Test/edtior/index.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// App.tsx
-import { useRef, useState, useEffect } from "react";
-import WebOfficeSDK from "web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.es.js";
-
-export default function App() {
- useEffect(() => {
- window.onload = async function () {
- const instance = WebOfficeSDK.init({
- // 必填项
- officeType: WebOfficeSDK.OfficeType.Writer,
- appId: "SX20260717TSGKEA",
- mount: document.getElementById("app-sbsb"),
- fileId: "EOCVQPCDCCE4ZJ2X6MTF",
- });
-
- // 需要等待实例 ready 之后再调用 API
- await instance.ready();
- };
- }, []);
-
- return ;
-}
diff --git a/src/pages/Container/Test/edtior/index.less b/src/pages/Container/Test/edtior/index.less
deleted file mode 100644
index 9c6eda3..0000000
--- a/src/pages/Container/Test/edtior/index.less
+++ /dev/null
@@ -1,4 +0,0 @@
-.pick-word-container{
- height: 100%;
- width: 200px;
-}
\ No newline at end of file
diff --git a/src/pages/Container/WpsEditor/index.js b/src/pages/Container/WpsEditor/index.js
new file mode 100644
index 0000000..60115e8
--- /dev/null
+++ b/src/pages/Container/WpsEditor/index.js
@@ -0,0 +1,176 @@
+import { useState, useEffect } from "react";
+import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
+import { Flex, Button, Tabs, Input, Tag, Progress, Typography } from "antd";
+import WebOfficeSDK from "~/web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.es.js";
+import { createPortal } from "react-dom";
+import "./index.less";
+
+const App = () => {
+ const [expandedMap, setExpandedMap] = useState({});
+
+ const toggleExpand = (index) => {
+ setExpandedMap((prev) => ({ ...prev, [index]: !prev[index] }));
+ };
+ useEffect(() => {
+ (async function () {
+ const instance = WebOfficeSDK.init({
+ // 必填项
+ officeType: WebOfficeSDK.OfficeType.Writer,
+ appId: "SX20260717TSGKEA",
+ mount: document.getElementById("app-sbsb"),
+ fileId: "123",
+ token: sessionStorage.getItem("token"),
+ });
+ await instance.ready();
+ const app = instance.Application;
+ })();
+ }, []);
+
+ return (
+
+
+
+
+
+
+ }
+ >
+
+
+
+
+
+
+ {["推荐", "法规标准", "危险因素", "评价方法", "事故案例"].map((cat) => (
+
+ ))}
+
+
+ {[
+ { cat: "法规标准", title: "中华人民共和国安全生产法",
+ desc: "2021年修正,当前有效。可引用至评价依据章节发多少个给梵蒂换个房间官方电话冈的是非观大使馆反对给多少给多少规范化的。" },
+ { cat: "危险因素", title: "液氨泄漏事故场景", desc: "包含泄漏扩散、中毒窒息、次生火灾及应急处置要点。" },
+ { cat: "评价方法", title: "安全检查表法", desc: "适用于法规符合性、设施状态和安全管理制度逐项检查。" },
+ { cat: "评价方法", title: "安全检查表法", desc: "适用于法规符合性、设施状态和安全管理制度逐项检查。" },
+ { cat: "评价方法", title: "安全检查表法", desc: "适用于法规符合性、设施状态和安全管理制度逐项检查。" },
+ { cat: "评价方法", title: "安全检查表法", desc: "适用于法规符合性、设施状态和安全管理制度逐项检查。" },
+ { cat: "评价方法", title: "安全检查表法", desc: "适用于法规符合性、设施状态和安全管理制度逐项检查。" },
+ ].map((item, i) => {
+ const expanded = expandedMap[i];
+ return (
+
+ {item.cat}
+ {item.title}
+
+ {item.desc}
+
+
+
+ );
+ })}
+
+
+ ),
+ },
+ {
+ label: "模板",
+ key: "2",
+ children: (
+
+
+ 机构报告模板
+
+
+
+ {[
+ { name: "安全预评价报告", desc: "AQ 8001 / AQ 8002 · V3.2", active: true },
+ { name: "安全验收评价报告", desc: "AQ 8001 / AQ 8003 · V2.8", active: false },
+ { name: "安全现状评价报告", desc: "机构标准模板 · V4.1", active: false },
+ ].map((tmpl, i) => (
+
+
+ {tmpl.name}
+ {tmpl.desc}
+
+ {tmpl.active ?
使用中 :
}
+
+ ))}
+
+
+ 模板包含
+ 封面、责任页、目录、章节结构、页眉页脚、表格样式、附件与附图目录。
+
+
+ ),
+ },
+ {
+ label: "签字",
+ key: "3",
+ children: (
+
+
+ 责任页签字
+ 1 / 5 已完成
+
+
+
+ {[
+ { initial: "张", name: "张建国", role: "项目负责人", status: "signed" },
+ { initial: "李", name: "李明华", role: "报告编制人", status: "pending" },
+ { initial: "王", name: "王丽萍", role: "内部审核人", status: "locked" },
+ { initial: "陈", name: "陈志强", role: "技术负责人", status: "locked" },
+ { initial: "王", name: "王丽萍", role: "过程控制负责人", status: "locked" },
+ ].map((signer, i) => (
+
+
{signer.initial}
+
+ {signer.name}
+ {signer.role}
+
+ {signer.status === "signed" &&
已签字}
+ {signer.status === "pending" &&
}
+ {signer.status === "locked" &&
待内审}
+
+ ))}
+
+
+
+ 签字由 PC 端下发至本人 APP,手写签署后自动回传。各版本签字独立留痕。
+
+
+
+ ),
+ },
+ ]}
+ />
+
+
+
+
+ );
+};
+
+export default function WpsEditor() {
+ return createPortal(, document.body);
+}
diff --git a/src/pages/Container/WpsEditor/index.less b/src/pages/Container/WpsEditor/index.less
new file mode 100644
index 0000000..24854d6
--- /dev/null
+++ b/src/pages/Container/WpsEditor/index.less
@@ -0,0 +1,132 @@
+.WpsEditor-container {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ z-index: 99;
+}
+
+.WpsEditor-flexContainer {
+ display: flex;
+ height: 100%;
+ overflow: hidden;
+}
+
+.WpsEditor-editorArea {
+ height: 99%;
+ min-width: 1100px;
+ width: 100%;
+}
+
+.WpsEditor-sidePanel {
+ overflow-x: auto;
+ width: 425px;
+ scrollbar-width: thin;
+
+
+ .WpsEditor-dock {
+ padding-left: 10px;
+ padding-right: 3px;
+ }
+
+ .WpsEditor-dock-cats {
+ margin: 8px 0;
+ overflow-x: auto;
+ scrollbar-width: thin;
+ }
+
+ .WpsEditor-dock-heading {
+ margin-bottom: 8px;
+ }
+
+ .WpsEditor-dock-list {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ }
+
+ .WpsEditor-resourceCard {
+ border: 1px solid #e8e8e8;
+ border-radius: 6px;
+ padding: 10px;
+ }
+
+ .WpsEditor-resourceTitle {
+ display: block;
+ margin: 4px 0;
+ }
+
+ .WpsEditor-resourceDesc {
+ margin: 0 0 4px 0 !important;
+ font-size: 12px;
+ }
+
+ .WpsEditor-templateCard {
+ border: 1px solid #e8e8e8;
+ border-radius: 6px;
+ padding: 10px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ &.active {
+ border-color: #1677ff;
+ background: #f0f5ff;
+ }
+ }
+
+ .WpsEditor-templateNote {
+ margin-top: 8px;
+ padding: 8px;
+ background: #fafafa;
+ border-radius: 6px;
+ }
+
+ .WpsEditor-signProgress {
+ font-size: 12px;
+ color: #1677ff;
+ }
+
+ .WpsEditor-signer {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 8px 0;
+ border-bottom: 1px solid #f0f0f0;
+
+ &:last-child {
+ border-bottom: none;
+ }
+
+ &.locked {
+ opacity: 0.5;
+ }
+ }
+
+ .WpsEditor-signerAvatar {
+ width: 32px;
+ height: 32px;
+ border-radius: 50%;
+ background: #1677ff;
+ color: #fff;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 14px;
+ flex-shrink: 0;
+ }
+
+ .WpsEditor-signerInfo {
+ flex: 1;
+ min-width: 0;
+ }
+
+ .WpsEditor-signRule {
+ margin-top: 8px;
+ padding: 8px;
+ background: #fffbe6;
+ border: 1px solid #ffe58f;
+ border-radius: 6px;
+ }
+}
\ No newline at end of file
diff --git a/src/web-office-sdk-solution-v2.0.7/index.d.ts b/src/web-office-sdk-solution-v2.0.7/index.d.ts
new file mode 100644
index 0000000..c161531
--- /dev/null
+++ b/src/web-office-sdk-solution-v2.0.7/index.d.ts
@@ -0,0 +1,415 @@
+/**
+ * 定义用户头部其它按钮菜单
+ */
+interface IUserHeaderSubItemsConf {
+ /**
+ * 类型
+ */
+ type: 'export_img' | 'split_line' | 'custom';
+ /**
+ * 文本
+ */
+ text?: string;
+ /**
+ * 事件订阅
+ */
+ subscribe?: ((arg0?: any) => any) | string;
+}
+
+/**
+ * 定义用户头部按钮配置
+ */
+interface IUserHeaderButtonConf {
+ /**
+ * 提示
+ */
+ tooltip?: string;
+ /**
+ * 事件订阅
+ */
+ subscribe?: ((arg0?: any) => any) | string;
+
+ /**
+ * 菜单项
+ */
+ items?: IUserHeaderSubItemsConf[];
+}
+
+/**
+ * 用于保存iframe原始尺寸
+ */
+interface IIframeWH {
+ width: string;
+ height: string;
+}
+
+/**
+ * 定义用户头部配置
+ */
+interface IUserHeadersConf {
+ /**
+ * 返回按钮
+ */
+ backBtn?: IUserHeaderButtonConf;
+ /**
+ * 分享按钮
+ */
+ shareBtn?: IUserHeaderButtonConf;
+ /**
+ * 其他按钮
+ */
+ otherMenuBtn?: IUserHeaderButtonConf;
+}
+interface ICommonOptions {
+ /**
+ * 是否显示顶部区域,头部和工具栏
+ */
+ isShowTopArea: boolean;
+ /**
+ * 是否显示头部
+ */
+ isShowHeader: boolean;
+ /**
+ * 是否需要父级全屏
+ */
+ isParentFullscreen: boolean;
+ /**
+ * 是否在iframe区域内全屏
+ */
+ isIframeViewFullscreen: boolean;
+ /**
+ * 是否在浏览器区域内全屏
+ */
+ isBrowserViewFullscreen: boolean;
+}
+/**
+ * 文字自定义配置
+ */
+interface IWpsOptions {
+ /**
+ * 是否显示目录
+ */
+ isShowDocMap?: boolean;
+ /**
+ * 默认以最佳显示比例打开
+ */
+ isBestScale?: boolean;
+ /**
+ * pc-是否展示底部状态栏
+ */
+ isShowBottomStatusBar?: boolean;
+}
+
+/**
+ * 表格自定义配置
+ */
+interface IEtOptions {
+ /**
+ * pc-是否展示底部状态栏
+ */
+ isShowBottomStatusBar?: boolean;
+}
+
+/**
+ * pdf自定义配置
+ */
+interface IPDFOptions {
+ isShowComment?: boolean;
+ isInSafeMode?: boolean;
+ /**
+ * pc-是否展示底部状态栏
+ */
+ isShowBottomStatusBar?: boolean;
+}
+
+/**
+ * 演示自定义配置
+ */
+interface IWppOptions {
+ /**
+ * pc-是否展示底部状态栏
+ */
+ isShowBottomStatusBar?: boolean;
+}
+
+/**
+ * 数据表自定义配置
+ */
+ interface IDBOptions {
+ /**
+ * 是否显示使用反馈按钮
+ */
+ isShowFeedback?: boolean
+}
+
+/**
+ * 定义用户通用事件订阅
+ */
+interface ISubscriptionsConf {
+ [key: string]: any;
+ /**
+ * 导航事件
+ */
+ navigate: (arg0?: any) => any;
+ /**
+ * WPSWEB ready 事件
+ */
+ ready: (arg0?: any) => any;
+ /**
+ * 打印事件
+ */
+ print?: {
+ custom?: boolean,
+ subscribe: (arg0?: any) => any,
+ };
+ /**
+ * 导出 PDF 事件
+ */
+ exportPdf?: (arg0?: any) => any;
+}
+
+interface ITokenData {
+ token: string;
+ timeout: number;
+}
+
+interface IClipboardData {
+ text: string;
+ html: string;
+}
+
+/**
+ * 用户配置
+ */
+interface IConfig {
+ /**
+ * WPSWEB iframe 挂载点
+ */
+ mount?: HTMLElement;
+ /**
+ * url参数
+ */
+ url?: string;
+ wpsUrl?: string; // 即将废弃
+ /**
+ * 头部
+ */
+ headers?: IUserHeadersConf;
+ /**
+ * 头部
+ */
+ mode?: 'nomal' | 'simple';
+ /**
+ * 通用配置
+ */
+ commonOptions?: ICommonOptions;
+ /**
+ * 文字自定义配置
+ */
+ wpsOptions?: IWpsOptions;
+ wordOptions?: IWppOptions;
+ /**
+ * 表格自定义配置
+ */
+ etOptions?: IEtOptions;
+ excelOptions?: IEtOptions;
+ /**
+ * 演示自定义配置
+ */
+ wppOptions?: IWppOptions;
+ pptOptions?: IWppOptions;
+ /**
+ * pdf自定义配置
+ */
+ pdfOptions?: IPDFOptions;
+ /**
+ * db自定义配置
+ */
+ dbOptions?: IDBOptions;
+ /**
+ * 事件订阅
+ */
+ subscriptions?: ISubscriptionsConf;
+ // 调试模式
+ debug?: boolean;
+ commandBars?: IWpsCommandBars[];
+ print?: {
+ custom?: boolean,
+ callback?: string,
+ };
+
+ exportPdf?: {
+ callback?: string,
+ };
+
+ // 获取token
+ refreshToken?: TRefreshToken;
+
+ cooperUserAttribute?: {
+ isCooperUsersAvatarVisible?: boolean,
+ cooperUsersColor?: [{
+ userId: string | number,
+ color: string,
+ }],
+ };
+}
+
+// type eventConfig = {
+// eventName: cbEventNames,
+// }
+
+/** ============================= */
+interface IMessage {
+ eventName: string;
+ msgId?: string;
+ callbackId?: number;
+ data?: any;
+ url?: any;
+ result?: any;
+ error?: any;
+ _self?: boolean;
+ sdkInstanceId?: number
+}
+
+/**
+ * WPSWEBAPI
+ */
+interface IWpsWebApi {
+ WpsApplication?: () => any;
+}
+
+/**
+ * 工具栏
+ */
+interface IWpsCommandBars {
+ cmbId: string;
+ attributes: IWpsCommandBarAttr[] | IWpsCommandBarObjectAttr;
+}
+
+/**
+ * 工具栏属性
+ */
+interface IWpsCommandBarAttr {
+ name: string;
+ value: any;
+}
+/**
+ * 工具栏属性
+ */
+interface IWpsCommandBarObjectAttr {
+ [propName: string]: any;
+}
+
+/**
+ * D.IWPS 定义
+ */
+
+interface IWps extends IWpsCompatible {
+ version: string;
+ url: string;
+ iframe: any;
+ Enum? : any; // 即将废弃
+ Events?: any; // 即将废弃
+ Props?: string;
+ advancedApiReady: () => Promise;
+ /**
+ * 兼容1.x用法
+ */
+ ready?:() => Promise;
+ destroy: () => Promise;
+ WpsApplication?: () => any;
+ WordApplication?: () => any;
+ EtApplication?: () => any;
+ ExcelApplication?: () => any;
+ WppApplication?: () => any;
+ PPTApplication?: () => any;
+ PDFApplication?: () => any;
+ Application?: any;
+ CommonApi?: any;
+ commonApiReady: () => Promise;
+ setToken: (tokenData: {
+ token: string, timeout?: number, hasRefreshTokenConfig: boolean,
+ }) => Promise;
+ tokenData?: { token: string } | null;
+ commandBars?: IWpsCommandBars[] | null;
+ iframeReady?: boolean;
+ on: (eventName: string, handle: (event?: any) => void) => void;
+ off: (eventName: string, handle: (event?: any) => void) => void;
+ Stack?: any;
+ Free?: (objId: any) => Promise;
+}
+
+/**
+ * 兼容1.x用法
+ */
+interface IWpsCompatible {
+ tabs?: {
+ getTabs: () => Promise>
+ switchTab: (tabKey: number) => Promise,
+ }
+ setCommandBars?: (args: Array) => Promise;
+ save?: () => Promise;
+ ApiEvent?: {
+ AddApiEventListener: (eventName: string, handle: (event?: any) => void) => void
+ RemoveApiEventListener: (eventName: string, handle: (event?: any) => void) => void
+ }
+ executeCommandBar?: (id: string) => void
+}
+
+interface IFlag {
+ advancedApiReadySended: boolean;
+ advancedApiReadySendedJust: boolean;
+ commonApiReadySended: boolean;
+ commonApiReadySendedJust: boolean;
+}
+
+interface ICbEvent {
+ refreshToken?: TRefreshToken;
+}
+
+interface IWebOfficeSDK {
+ config: (conf: IConfig) => IWps | undefined;
+ init: (conf: IAppConfig) => IWps | undefined;
+ OfficeType: OfficeType;
+}
+
+interface IReadyEvent {
+ event: string;
+ callback?: (...args: any) => void;
+ after?: boolean;
+}
+
+type TRefreshToken = () => ITokenData | Promise;
+
+type sendMsgToWps = (msg: IMessage) => void;
+type getId = () => string;
+
+interface IAppConfig extends IConfig {
+ appId: string;
+ fileId: string | number;
+ officeType: string;
+ /**
+ * @deprecated use token instead
+ */
+ fileToken?: string | ITokenData;
+ token?: string | ITokenData;
+ endpoint?: string;
+ customArgs?: Record;
+ /**
+ * @deprecated A config item for WebOfficeSDK.config
+ */
+ url?: string;
+ mount?: any;
+ attrAllow: string | string[];
+ isListenResize?: boolean; // sdk内部是否监听resize变化,默认监听
+}
+
+type OfficeType = {
+ Spreadsheet: string,
+ Writer: string,
+ Presentation: string,
+ Pdf: string,
+ Otl: string
+}
+
+export { IAppConfig, ICbEvent, IClipboardData, ICommonOptions, IConfig, IDBOptions, IEtOptions, IFlag, IIframeWH, IMessage, IPDFOptions, IReadyEvent, ISubscriptionsConf, ITokenData, IUserHeaderButtonConf, IUserHeaderSubItemsConf, IUserHeadersConf, IWebOfficeSDK, IWppOptions, IWps, IWpsCommandBarAttr, IWpsCommandBarObjectAttr, IWpsCommandBars, IWpsCompatible, IWpsOptions, IWpsWebApi, OfficeType, TRefreshToken, getId, sendMsgToWps };
diff --git a/src/web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.cjs.js b/src/web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.cjs.js
new file mode 100644
index 0000000..6956b81
--- /dev/null
+++ b/src/web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.cjs.js
@@ -0,0 +1 @@
+"use strict";var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function __extends(e,t){function n(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var ECbConfigEventNames,EOfficeTypes,EModeTypes,EFullScreenStatus,__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&s[s.length-1])&&(6===r[0]||2===r[0])){o=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]=0&&this.HANDLE_LIST.splice(t,1),window.removeEventListener("message",e,!1)},e.prototype.empty=function(){for(;this.HANDLE_LIST.length;){var e=this.HANDLE_LIST.shift();window.removeEventListener("message",e,!1)}},e.prototype.parse=function(e){try{return"object"==typeof e?e:e?JSON.parse(e):e}catch(t){return e}},e}(),Base=function(){function e(e,t){var n=this;this.collectObjIdHandlers=new Set,this.polyfillApi=["ExportAsFixedFormat","GetOperatorsInfo","ImportDataIntoFields","ReplaceText","ReplaceBookmark","GetBookmarkText","GetComments"],this.getId=function(){return""},this.setterCallbacks={idMap:{}},this.sendMsgToWps=function(){},this.objId=0,this.origin="",this.apiChannel=function(e,t,i,s){return __awaiter(n,void 0,void 0,function(){var n,r,o,a,c,l,u,d,f,p=this;return __generator(this,function(h){switch(h.label){case 0:return n=this.getId(),a=new Promise(function(e,t){r=e,o=t}),c={},t.args?[4,this.reduceArgs(t.args)]:[3,2];case 1:l=h.sent(),u=l[0],d=l[1],t.args=u,c=d,h.label=2;case 2:return e!==this.prefix+"setter"?[3,4]:[4,this.handleApiSetter(t)];case 3:h.sent(),h.label=4;case 4:return f=function(){var t=function(a){return __awaiter(p,void 0,void 0,function(){var l,u,d;return __generator(this,function(f){switch(f.label){case 0:return this.instance.originWhiteList.includes(a.origin)||this.origin===a.origin?(l=this.message.parse(a.data)).eventName===this.prefix+"callback"&&l.callbackId&&c[l.callbackId]?[4,c[l.callbackId].apply(c,l.data.args)]:[3,2]:[2];case 1:u=f.sent(),this.sendMsgToWps({result:u,eventName:this.prefix+"callback.reply",callbackId:l.callbackId}),f.label=2;case 2:return l.eventName===e+".reply"&&l.msgId===n&&(l.error?((d=new Error("")).stack=l.error+"\n"+i,s&&s(),o(d)):r(l.result),this.message.remove(t)),[2]}})})};return p.message.add(t),a},this.handleSendApiChannel([{eventName:e,data:t,msgId:n},f]),[2,a]}})})},this.handleApiSetter=function(e){return __awaiter(n,void 0,void 0,function(){var t,n,i,s,r,o,a,c,l,u,d=this;return __generator(this,function(f){switch(f.label){case 0:return t=function(){return Object.keys(d.setterCallbacks.idMap).find(function(e){return d.setterCallbacks.idMap[e]===i+":"+n})},n=e.prop,i=e.parentObjId,s=e.value,[4,this.reduceArgs([s])];case 1:return r=f.sent(),o=r[0],a=r[1],e.value=o[0],c=Object.keys(a)[0],l=this.setterCallbacks[i],null===s&&l&&l[n]&&((u=t())&&delete this.setterCallbacks.idMap[u],delete l[n],Object.keys(l).length||delete this.setterCallbacks[i],Object.keys(this.setterCallbacks.idMap).length||this.message.remove(this.setterCallbackSubscribe.bind(this))),c&&(Object.keys(this.setterCallbacks.idMap).length||this.message.add(this.setterCallbackSubscribe.bind(this)),this.setterCallbacks[i]||(this.setterCallbacks[i]={}),this.setterCallbacks[i][n]={callbackId:c,callback:a[c]},(u=t())&&delete this.setterCallbacks.idMap[u],this.setterCallbacks.idMap[c]=i+":"+n),[2]}})})},this.prefix=t,this.origin=e.origin,this.sendMsgToWps=e.sendMsgToWps.bind(e),this.getId=e.getId.bind(e),this.message=e.message,this.sdkInstanceId=e.instanceId,this.instance=e}return e.prototype.destroyApplication=function(){this.collectObjIdHandlers=new Set,this.objId=0},e.prototype.subEventHandle=function(e,t){var n=this,i={};this.message.add(function(e){return __awaiter(n,void 0,void 0,function(){var t,n,s,r,o,a;return __generator(this,function(c){switch(c.label){case 0:return this.instance.originWhiteList.includes(e.origin)||this.origin===e.origin?(t=this.message.parse(e.data),n=t.sdkInstanceId,t.eventName===this.prefix+"event"&&Number(n)===this.sdkInstanceId&&t.data?(s=t.data,r=s.eventName,o=s.data,(a=i[r])?[4,a(o)]:[3,2]):[3,2]):[2];case 1:c.sent(),c.label=2;case 2:return[2]}})})});var s=function(s){var r=t[s];Object.defineProperty(e,r,{set:function(e){i[r]=e,n.sendMsgToWps({eventName:n.prefix+"event.register",data:{eventName:r,register:!!e,objId:n.objId+=1},sdkInstanceId:n.sdkInstanceId})}})};for(var r in t)s(r)},e.prototype.mixinProto=function(e,t){Object.assign(e,t)},e.prototype.makeCollectObjIdHandle=function(e){var t=this;return function(){var n=[],i=function(e){n.push(e)};return t.collectObjIdHandlers.add(i),{End:function(){e(n),t.collectObjIdHandlers.delete(i)}}}},e.prototype.assign=function(e,t,n){for(var i=this,s=t.slice(0),r=function(){var t=s.shift();!t.alias&&~o.polyfillApi.indexOf(t.prop)&&s.push(__assign(__assign({},t),{alias:t.prop+"Async"})),Object.defineProperty(e,t.alias||t.prop,{get:function(){var s=1===t.cache,r=s&&e["__"+t.prop+"CacheValue"];if(!r){var o=i.getError(),a=i.createObjId(s),c=function(){for(var s,r=[],a=0;a=0?(t.then=null,t.catch=null,c.then(function(){e(t)}).catch(function(e){return n(e)})):c.then(e,n)},t.catch=function(e){return c.catch(e)},t.Destroy=function(){return this.apiChannel(this.prefix+"free",{objId:t.objId},"")}},e.prototype.handleSendApiChannel=function(e){var t=e[0],n=e[1];"function"==typeof(t=__assign({},t)).data&&(t.data=t.data()),n(),this.sendMsgToWps(t)},e.prototype.setterCallbackSubscribe=function(e){return __awaiter(this,void 0,void 0,function(){var t,n,i,s,r,o,a,c,l,u;return __generator(this,function(d){switch(d.label){case 0:return this.instance.originWhiteList.includes(e.origin)||this.origin===e.origin?(t=this.message.parse(e.data),n=t.eventName,i=t.callbackId,s=t.data,i&&(r=this.setterCallbacks.idMap[i])?(o=r.split(":"),a=o[0],c=o[1],n===this.prefix+"callback"&&this.setterCallbacks[a]&&this.setterCallbacks[a][c]?[4,(u=this.setterCallbacks[a][c]).callback.apply(u,s.args)]:[3,2]):[3,2]):[2];case 1:l=d.sent(),this.sendMsgToWps({result:l,callbackId:i,eventName:this.prefix+"callback.reply"}),d.label=2;case 2:return[2]}})})},e.prototype.reduceArgs=function(e){return __awaiter(this,void 0,void 0,function(){var t,n,i,s,r,o,a,c,l,u,d;return __generator(this,function(f){switch(f.label){case 0:t={},n=[],i=e.slice(0),f.label=1;case 1:return i.length?(s=void 0,[4,i.shift()]):[3,13];case 2:return(r=f.sent())&&r.done?[4,r.done()]:[3,4];case 3:f.sent(),f.label=4;case 4:if(!isPlainObject(s))return[3,11];for(a in s={},o=[],r)o.push(a);c=0,f.label=5;case 5:return c>>0,1)},emit:function(t,n){(e[t]||[]).slice().map(function(e){e(n)}),(e["*"]||[]).slice().map(function(e){e(t,n)})}}}var WebOfficeSDK=function(){function e(t){var n=this;this.id=0,this.origin="",this.originWhiteList=[],this.realOrigin="",this.iframeWH=null,this.cbConfigsSub={},this.readyEventNames=[{event:"ready",callback:function(){n.handleBaseReady()},after:!0},{event:"open.result"},{event:"api.ready",callback:function(){for(var e=[],t=0;t=0?"&":"?")+c.join("&")),l},e.prototype.handleCommandBarsConfig=function(e,t){void 0===t&&(t=!0);var n=e.map(function(e){var t=e.attributes;if(!Array.isArray(t)){var n=[];for(var i in t)if(t.hasOwnProperty(i)){var s={name:i,value:t[i]};n.push(s)}e.attributes=n}return e});return t&&this.sendMsgToWps({data:n,eventName:"setCommandBars"}),n},e.prototype.sendMsgToWps=function(e){var t,n,i=__assign(__assign({},e),{sdkInstanceId:this.instanceId});null===(n=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===n||n.postMessage(JSON.stringify(i),this.realOrigin)},e.prototype.makeReady=function(e){var t=this,n=e.event,i=e.callback,s=e.after;return new Promise(function(e){var r=function(o){if(t.realOrigin=o.origin,t.originWhiteList.includes(o.origin)||t.origin===o.origin){var a=t.message.parse(o.data),c=a.eventName,l=a.data,u=a.sdkInstanceId;if(!t.isOtherEvent(u)&&c===n){var d=void 0;!s&&i&&(d=i(l)),e(d),s&&i&&i(l),"ready"!==n&&t.message.remove(r)}}};t.message.add(r)})},e.prototype.getId=function(){return this.id+=1,this.instanceId+"-"+this.id},e.instanceId=1,e}(),CommonApiMaps={executeCommandBar:"ExecuteCommandBar",off:"Off",save:"Save",setCommandBars:"SetCommandBars",setCooperUserColor:"SetCooperUserColor",tabs:"Tabs",Stack:"Stack",WhenStacksEmpty:"WhenStacksEmpty"};function ProxyTabs(e){var t=this;return{switchTab:function(n){return __awaiter(t,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,e.commonApiReady()];case 1:return t.sent(),[4,e.CommonApi.Tabs.SwitchTab(n.tabKey)];case 2:return[2,t.sent()]}})})},getTabs:function(){return __awaiter(t,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,e.commonApiReady()];case 1:return t.sent(),[4,e.CommonApi.Tabs.GetTabs()];case 2:return[2,t.sent()]}})})}}}function CompatibleProxy(e,t){var n=this;return void 0===t&&(t={}),new Proxy(e,__assign(__assign({},{get:function(e,t){if(Object.keys(CommonApiMaps).includes(t)){var i=CommonApiMaps[t];return"Tabs"===i?ProxyTabs(e):e.CommonApi?Reflect.get(e.CommonApi,i):function(){return __awaiter(n,void 0,void 0,function(){var t;return __generator(this,function(n){switch(n.label){case 0:return[4,e.commonApiReady()];case 1:return n.sent(),[4,e.commonApiPromise];case 2:return n.sent(),"function"!=typeof e.CommonApi[i]?[3,4]:[4,e.CommonApi[i]()];case 3:return t=n.sent(),[3,5];case 4:t=e.CommonApi[i],n.label=5;case 5:return[2,t]}})})}}return Reflect.get(e,t)},set:function(e,t,n){return!!Reflect.has(e,t)&&Reflect.set(e,t,n)}}),t))}function addHooksFun(e,t){return __awaiter(this,void 0,void 0,function(){var n,i,s,r;return __generator(this,function(o){switch(o.label){case 0:return[4,e.commonApiReady()];case 1:for(i in o.sent(),n=[],t)n.push(i);s=0,o.label=2;case 2:if(!(s0&&r[r.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]=0&&this.HANDLE_LIST.splice(t,1),window.removeEventListener("message",e,!1)},e.prototype.empty=function(){for(;this.HANDLE_LIST.length;){var e=this.HANDLE_LIST.shift();window.removeEventListener("message",e,!1)}},e.prototype.parse=function(e){try{return"object"==typeof e?e:e?JSON.parse(e):e}catch(t){return e}},e}(),p=function(){function e(e,t){var n=this;this.collectObjIdHandlers=new Set,this.polyfillApi=["ExportAsFixedFormat","GetOperatorsInfo","ImportDataIntoFields","ReplaceText","ReplaceBookmark","GetBookmarkText","GetComments"],this.getId=function(){return""},this.setterCallbacks={idMap:{}},this.sendMsgToWps=function(){},this.objId=0,this.origin="",this.apiChannel=function(e,t,i,r){return a(n,void 0,void 0,function(){var n,s,o,l,u,d,h,f,p,m=this;return c(this,function(v){switch(v.label){case 0:return n=this.getId(),l=new Promise(function(e,t){s=e,o=t}),u={},t.args?[4,this.reduceArgs(t.args)]:[3,2];case 1:d=v.sent(),h=d[0],f=d[1],t.args=h,u=f,v.label=2;case 2:return e!==this.prefix+"setter"?[3,4]:[4,this.handleApiSetter(t)];case 3:v.sent(),v.label=4;case 4:return p=function(){var t=function(l){return a(m,void 0,void 0,function(){var a,d,h;return c(this,function(c){switch(c.label){case 0:return this.instance.originWhiteList.includes(l.origin)||this.origin===l.origin?(a=this.message.parse(l.data)).eventName===this.prefix+"callback"&&a.callbackId&&u[a.callbackId]?[4,u[a.callbackId].apply(u,a.data.args)]:[3,2]:[2];case 1:d=c.sent(),this.sendMsgToWps({result:d,eventName:this.prefix+"callback.reply",callbackId:a.callbackId}),c.label=2;case 2:return a.eventName===e+".reply"&&a.msgId===n&&(a.error?((h=new Error("")).stack=a.error+"\n"+i,r&&r(),o(h)):s(a.result),this.message.remove(t)),[2]}})})};return m.message.add(t),l},this.handleSendApiChannel([{eventName:e,data:t,msgId:n},p]),[2,l]}})})},this.handleApiSetter=function(e){return a(n,void 0,void 0,function(){var t,n,i,r,s,o,a,l,u,d,h=this;return c(this,function(c){switch(c.label){case 0:return t=function(){return Object.keys(h.setterCallbacks.idMap).find(function(e){return h.setterCallbacks.idMap[e]===i+":"+n})},n=e.prop,i=e.parentObjId,r=e.value,[4,this.reduceArgs([r])];case 1:return s=c.sent(),o=s[0],a=s[1],e.value=o[0],l=Object.keys(a)[0],u=this.setterCallbacks[i],null===r&&u&&u[n]&&((d=t())&&delete this.setterCallbacks.idMap[d],delete u[n],Object.keys(u).length||delete this.setterCallbacks[i],Object.keys(this.setterCallbacks.idMap).length||this.message.remove(this.setterCallbackSubscribe.bind(this))),l&&(Object.keys(this.setterCallbacks.idMap).length||this.message.add(this.setterCallbackSubscribe.bind(this)),this.setterCallbacks[i]||(this.setterCallbacks[i]={}),this.setterCallbacks[i][n]={callbackId:l,callback:a[l]},(d=t())&&delete this.setterCallbacks.idMap[d],this.setterCallbacks.idMap[l]=i+":"+n),[2]}})})},this.prefix=t,this.origin=e.origin,this.sendMsgToWps=e.sendMsgToWps.bind(e),this.getId=e.getId.bind(e),this.message=e.message,this.sdkInstanceId=e.instanceId,this.instance=e}return e.prototype.destroyApplication=function(){this.collectObjIdHandlers=new Set,this.objId=0},e.prototype.subEventHandle=function(e,t){var n=this,i={};this.message.add(function(e){return a(n,void 0,void 0,function(){var t,n,r,s,o,a;return c(this,function(c){switch(c.label){case 0:return this.instance.originWhiteList.includes(e.origin)||this.origin===e.origin?(t=this.message.parse(e.data),n=t.sdkInstanceId,t.eventName===this.prefix+"event"&&Number(n)===this.sdkInstanceId&&t.data?(r=t.data,s=r.eventName,o=r.data,(a=i[s])?[4,a(o)]:[3,2]):[3,2]):[2];case 1:c.sent(),c.label=2;case 2:return[2]}})})});var r=function(r){var s=t[r];Object.defineProperty(e,s,{set:function(e){i[s]=e,n.sendMsgToWps({eventName:n.prefix+"event.register",data:{eventName:s,register:!!e,objId:n.objId+=1},sdkInstanceId:n.sdkInstanceId})}})};for(var s in t)r(s)},e.prototype.mixinProto=function(e,t){Object.assign(e,t)},e.prototype.makeCollectObjIdHandle=function(e){var t=this;return function(){var n=[],i=function(e){n.push(e)};return t.collectObjIdHandlers.add(i),{End:function(){e(n),t.collectObjIdHandlers.delete(i)}}}},e.prototype.assign=function(e,t,n){for(var i=this,r=t.slice(0),s=function(){var t=r.shift();!t.alias&&~a.polyfillApi.indexOf(t.prop)&&r.push(o(o({},t),{alias:t.prop+"Async"})),Object.defineProperty(e,t.alias||t.prop,{get:function(){var r=1===t.cache,s=r&&e["__"+t.prop+"CacheValue"];if(!s){var o=i.getError(),a=i.createObjId(r),c=function(){for(var r,s=[],a=0;a=0?(t.then=null,t.catch=null,c.then(function(){e(t)}).catch(function(e){return n(e)})):c.then(e,n)},t.catch=function(e){return c.catch(e)},t.Destroy=function(){return this.apiChannel(this.prefix+"free",{objId:t.objId},"")}},e.prototype.handleSendApiChannel=function(e){var t=e[0],n=e[1];"function"==typeof(t=o({},t)).data&&(t.data=t.data()),n(),this.sendMsgToWps(t)},e.prototype.setterCallbackSubscribe=function(e){return a(this,void 0,void 0,function(){var t,n,i,r,s,o,a,l,u,d;return c(this,function(c){switch(c.label){case 0:return this.instance.originWhiteList.includes(e.origin)||this.origin===e.origin?(t=this.message.parse(e.data),n=t.eventName,i=t.callbackId,r=t.data,i&&(s=this.setterCallbacks.idMap[i])?(o=s.split(":"),a=o[0],l=o[1],n===this.prefix+"callback"&&this.setterCallbacks[a]&&this.setterCallbacks[a][l]?[4,(d=this.setterCallbacks[a][l]).callback.apply(d,r.args)]:[3,2]):[3,2]):[2];case 1:u=c.sent(),this.sendMsgToWps({result:u,callbackId:i,eventName:this.prefix+"callback.reply"}),c.label=2;case 2:return[2]}})})},e.prototype.reduceArgs=function(e){return a(this,void 0,void 0,function(){var t,n,i,r,s,o,a,l,u,h,f;return c(this,function(c){switch(c.label){case 0:t={},n=[],i=e.slice(0),c.label=1;case 1:return i.length?(r=void 0,[4,i.shift()]):[3,13];case 2:return(s=c.sent())&&s.done?[4,s.done()]:[3,4];case 3:c.sent(),c.label=4;case 4:if(!d(r))return[3,11];for(a in r={},o=[],s)o.push(a);l=0,c.label=5;case 5:return l>>0,1)},emit:function(e,t){(n[e]||[]).slice().map(function(e){e(t)}),(n["*"]||[]).slice().map(function(n){n(e,t)})}}),this.handleConfig(t)}return e.config=function(t){return void 0===t&&(t={}),e.singleInstance||(e.singleInstance=new e(t)),e.singleInstance},e.prototype.setToken=function(e){return a(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.basicReady()];case 1:return t.sent(),this.tokenData=e,this.sendMsgToWps({eventName:"setToken",data:e}),[2]}})})},e.prototype.advancedApiReady=function(){return a(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return this.flag.advancedApiReadySendedJust?[3,2]:(this.flag.advancedApiReadySendedJust=!0,[4,this.fileOpenPromise]);case 1:e.sent(),this.flag.advancedApiReadySended||(this.flag.advancedApiReadySended=!0,this.sendMsgToWps({eventName:"api.ready"})),e.label=2;case 2:return[4,this.advancedReadyPromise];case 3:return[2,e.sent()]}})})},e.prototype.commonApiReady=function(){return a(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return this.flag.commonApiReadySendedJust?[3,2]:(this.flag.commonApiReadySendedJust=!0,[4,this.basicReady()]);case 1:e.sent(),this.flag.commonApiReadySended||(this.flag.commonApiReadySended=!0,this.sendMsgToWps({eventName:"commonApi.ready"})),e.label=2;case 2:return[4,this.commonApiPromise];case 3:return[2,e.sent()]}})})},e.prototype.destroy=function(){this.iframeInstance.destroy(),this.message.empty(),this.destroyApplication&&this.destroyApplication(),this.destroyCommonApp&&this.destroyCommonApp(),this.removeFullscreenEventListener()},e.prototype.on=function(e,t){return a(this,void 0,void 0,function(){var n;return c(this,function(i){switch(i.label){case 0:return[4,this.basicReady()];case 1:return i.sent(),n=e,"fullscreenChange"===e&&(n="fullscreenchange"),this.handleBasicEvent(n,"on"),this.mittInstance.on(e,t),[2]}})})},e.prototype.off=function(e,t){return a(this,void 0,void 0,function(){return c(this,function(n){switch(n.label){case 0:return[4,this.basicReady()];case 1:return n.sent(),this.handleBasicEvent(e,"off"),this.mittInstance.off(e,t),[2]}})})},e.prototype.handleConfig=function(e){var t,n=this;void 0===e&&(e={});try{var i=this.userConfHandler(e),r=i.subscriptions,s=void 0===r?{}:r,o=i.mount,a=void 0===o?null:o,c=i.url,l=i.originWhiteList;this.origin=(c.match(/https*:\/\/[^\/]+/g)||[])[0],this.originWhiteList=l||[];var u=this.readyEventNames.map(function(e){return n.makeReady(e)}),d=u[0],f=u[1],p=u[2],m=u[3];this.baseReadyPromise=d,this.fileOpenPromise=f,this.advancedReadyPromise=p,this.commonApiPromise=m,this.iframeWH=a?{width:a.clientWidth+"px",height:a.clientHeight+"px"}:{width:"100vw",height:"100vh"},delete i.mount,c&&delete i.url,this.url=c,delete i.subscriptions,this.sdkConfig=i,this.iframeInstance=new h(this,this.instanceId,c,a,null===(t=i.isListenResize)||void 0===t||t,!1,{allow:i.attrAllow}),this.iframe=this.iframeInstance.iframe,this.listener(s)}catch(e){return console.error(e),null}},e.prototype.listener=function(e){var t=this;this.message.add(function(n){return a(t,void 0,void 0,function(){var t,i,r,s,o,a,l,u,d;return c(this,function(c){return t=this.message.parse(n.data),i=t.eventName,r=void 0===i?"":i,s=t.data,o=void 0===s?null:s,a=t.url,l=void 0===a?null:a,u=t.sdkInstanceId,this.isOtherEvent(u)?[2]:-1!==["wps.jssdk.api"].indexOf(r)?[2]:((d=this.handleListenEvent(r,o))?d():Object.keys(this.onEventNames).includes(r)&&("open.result"===r&&(this.officeType=o.fileInfo.officeType),this.mittInstance.emit(this.onEventNames[r],o)),"function"==typeof e[r]&&e[r](this,l||o),[2])})})})},e.prototype.handleListenEvent=function(e,t){var i,r=this;return((i={"api.scroll":function(){return window.scrollTo(t.x,t.y)},"event.callback":function(){return a(r,void 0,void 0,function(){var e,n,i,r,s,o,a;return c(this,function(c){return e=t.eventName,n=t.data,i=e,"fullScreenChange"===e&&(i="fullscreenChange"),((null===(o=this.sdkConfig.commonOptions)||void 0===o?void 0:o.isBrowserViewFullscreen)||(null===(a=this.sdkConfig.commonOptions)||void 0===a?void 0:a.isParentFullscreen))&&"fullscreenchange"===i&&(r=n.status,s=n.isDispatchEvent,this.sdkConfig.commonOptions.isBrowserViewFullscreen?this.iframeWH&&function(e,t,n,i){0===e?t.style="position: static; width: "+n.width+"; height: "+n.height:1===e&&(t.style="position: absolute; width: 100%; height: 100%"),i&&function(e){["fullscreen","fullscreenElement"].forEach(function(t){Object.defineProperty(document,t,{get:function(){return!!e.status},configurable:!0})});var t=new CustomEvent("fullscreenchange");document.dispatchEvent(t)}({status:e})}(r,this.iframe,this.iframeWH,s):this.sdkConfig.commonOptions.isParentFullscreen&&function(e,t){if(0===e){var n=document,i=n.exitFullscreen||n.mozCancelFullScreen||n.msExitFullscreen||n.webkitCancelFullScreen||n.webkitExitFullscreen;i.call(document)}else if(1===e){var r=t.requestFullscreen||t.mozRequestFullScreen||t.msRequestFullscreen||t.webkitRequestFullscreen;r.call(t)}}(r,this.iframe)),this.mittInstance.emit(i,n),[2]})})}})[n.refreshToken]=function(){return a(r,void 0,void 0,function(){var t,n;return c(this,function(i){switch(i.label){case 0:t={token:!1},i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.cbConfigsSub.refreshToken()];case 2:return t=i.sent(),[3,4];case 3:return n=i.sent(),console.error("refreshToken: "+(n||"fail to get")),[3,4];case 4:return this.sendMsgToWps({eventName:e+".reply",data:t}),[2]}})})},i)[e]},e.prototype.basicReady=function(){return this.baseReadyPromise},e.prototype.userConfHandler=function(e,t){var i=this;void 0===t&&(t=!0);var s=o({},e),a=s.headers,c=void 0===a?{}:a,l=s.subscriptions,u=void 0===l?{}:l,d=s.commonOptions,h=s.url,f=void 0===h?"":h,p=s.wpsUrl,m=void 0===p?"":p,v=s.mode,b=void 0===v?r.nomal:v,g=s.debug,y=s.disablePlugins,w=s.hideGuide,k=s.readOnly;return Object.assign(s,this.handleHeadersAndSubscriptionsConfig(c,u,t)),s.url=this.handleUrlConfig(d,b,g,f,m,y,w,k),d&&(d.isParentFullscreen||d.isBrowserViewFullscreen)&&document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.polyfillConfigName.map(function(e){var t=e[0],n=e[1];s[n]&&(s[t]=s[n])}),this.cbConfigs.map(function(e){var t,r,o=s[e];o&&(t=o,r="Function",{}.toString.call(t)==="[object "+r+"]")&&(i.cbConfigsSub[e]=o,s[e]={eventName:n[e]})}),s.commandBars&&this.handleCommandBarsConfig(s.commandBars,!1),o({},s)},e.prototype.handleBasicEvent=function(e,t){if(!["error","fileOpen"].includes(e)){var n={eventName:"basic.event",data:{eventName:e,action:t}};this.sendMsgToWps(n)}},e.prototype.removeFullscreenEventListener=function(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange)},e.prototype.handleHeadersAndSubscriptionsConfig=function(e,t,n){var i=e.backBtn,r=void 0===i?{}:i,s=e.shareBtn,o=void 0===s?{}:s,a=e.otherMenuBtn,c=void 0===a?{}:a,l=[["wpsconfig_back_btn",r],["wpsconfig_share_btn",o],["wpsconfig_other_menu_btn",c]],u=[];return c.items&&Array.isArray(c.items)&&c.items.forEach(function(e,t){void 0===e&&(e={}),"custom"===e.type&&u.push(["wpsconfig_other_menu_btn_"+t,e])}),l.concat(u).forEach(function(e){var i,r;i=e[1],r=e[0],i.subscribe&&"function"==typeof i.subscribe&&(i.callback=r,t[r]=i.subscribe,n&&delete i.subscribe)}),{}},e.prototype.handleUrlConfig=function(e,t,n,i,s,o,a,c){var l=[];l.push("sdkId="+this.instanceId),t===r.simple||e&&!1===e.isShowTopArea?l.push("simple","hidecmb"):t===r.embed&&l.push("simple=1","hidecmb=1","embed=1"),o&&l.push("disablePlugins"),a&&l.push("hideguide"),c&&l.push("readonly"),n&&l.push("debugger");var u=i||s;return u&&l.length&&(u=u+(u.indexOf("?")>=0?"&":"?")+l.join("&")),u},e.prototype.handleCommandBarsConfig=function(e,t){void 0===t&&(t=!0);var n=e.map(function(e){var t=e.attributes;if(!Array.isArray(t)){var n=[];for(var i in t)if(t.hasOwnProperty(i)){var r={name:i,value:t[i]};n.push(r)}e.attributes=n}return e});return t&&this.sendMsgToWps({data:n,eventName:"setCommandBars"}),n},e.prototype.sendMsgToWps=function(e){var t,n,i=o(o({},e),{sdkInstanceId:this.instanceId});null===(n=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===n||n.postMessage(JSON.stringify(i),this.realOrigin)},e.prototype.makeReady=function(e){var t=this,n=e.event,i=e.callback,r=e.after;return new Promise(function(e){var s=function(o){if(t.realOrigin=o.origin,t.originWhiteList.includes(o.origin)||t.origin===o.origin){var a=t.message.parse(o.data),c=a.eventName,l=a.data,u=a.sdkInstanceId;if(!t.isOtherEvent(u)&&c===n){var d=void 0;!r&&i&&(d=i(l)),e(d),r&&i&&i(l),"ready"!==n&&t.message.remove(s)}}};t.message.add(s)})},e.prototype.getId=function(){return this.id+=1,this.instanceId+"-"+this.id},e.instanceId=1,e}(),g={executeCommandBar:"ExecuteCommandBar",off:"Off",save:"Save",setCommandBars:"SetCommandBars",setCooperUserColor:"SetCooperUserColor",tabs:"Tabs",Stack:"Stack",WhenStacksEmpty:"WhenStacksEmpty"};function y(e,t){var n=this;return void 0===t&&(t={}),new Proxy(e,o(o({},{get:function(e,t){if(Object.keys(g).includes(t)){var i=g[t];return"Tabs"===i?function(e){var t=this;return{switchTab:function(n){return a(t,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,e.commonApiReady()];case 1:return t.sent(),[4,e.CommonApi.Tabs.SwitchTab(n.tabKey)];case 2:return[2,t.sent()]}})})},getTabs:function(){return a(t,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,e.commonApiReady()];case 1:return t.sent(),[4,e.CommonApi.Tabs.GetTabs()];case 2:return[2,t.sent()]}})})}}}(e):e.CommonApi?Reflect.get(e.CommonApi,i):function(){return a(n,void 0,void 0,function(){var t;return c(this,function(n){switch(n.label){case 0:return[4,e.commonApiReady()];case 1:return n.sent(),[4,e.commonApiPromise];case 2:return n.sent(),"function"!=typeof e.CommonApi[i]?[3,4]:[4,e.CommonApi[i]()];case 3:return t=n.sent(),[3,5];case 4:t=e.CommonApi[i],n.label=5;case 5:return[2,t]}})})}}return Reflect.get(e,t)},set:function(e,t,n){return!!Reflect.has(e,t)&&Reflect.set(e,t,n)}}),t))}var w;!function(e){e.Spreadsheet="s",e.Writer="w",e.Presentation="p",e.Pdf="f",e.Otl="o",e.Dbt="d",e.KSheet="k"}(w||(w={}));var k=function(e){function n(t){var n=e.call(this,t)||this;return t.token&&(d(t.token)?n.setToken(o({},t.token)):n.setToken({token:t.token})),n.ApiEvent={AddApiEventListener:function(e,t){n.on(e,t)},RemoveApiEventListener:function(e,t){n.off(e,t)}},n}return t(n,e),n.init=function(e){var t=o({},e);if(t.endpoint=t.endpoint||"https://o.wpsgo.com","string"==typeof t.mount){var i=document.querySelector(t.mount);i?t.mount=i:(console.warn("[WebOfficeSDK.init] mount挂载节点未找到"),delete t.mount)}if(t.url)throw Error("[WebOfficeSDK.init] 不支持传递url,请使用appId、fileId、officeType、token等参数初始化!");if(!t.appId||!t.fileId||!t.officeType)throw Error("[WebOfficeSDK.init] appId、fileId、officeType为必选项!");if("string"!=typeof t.endpoint)throw Error("[WebOfficeSDK.init] endpoint期望为字符串");if(t.endpoint&&!t.endpoint.startsWith("http"))throw Error("[WebOfficeSDK.init] endpoint仅支持http、https的地址");var r=new n(function(e){var t=o({},e);t.token=t.token||t.fileToken;var n=t.appId,i=t.fileId,r=t.officeType,s=t.token,a=t.endpoint,c=t.customArgs,l=void 0===c?"":c;if(!Object.values(w).includes(r))throw Error("[WebOfficeSDK.init] officeType属性值错误,可选值参考WebOfficeSDK.OfficeType: "+JSON.stringify(w));var u=s?1:0,h={token:""};if("string"==typeof s?h.token=s:d(s)&&(h=o({tokenData:h},s)),u&&!h.token)return console.error("[WebOfficeSDK.init] token设置无效"),t;if(t.url=a+"/office/"+r+"/"+i+"?_w_appid="+n+"&_w_tokentype="+u,d(l)){var f=Object.entries(l).map(function(e){var t=e[0],n=e[1];return t+"="+encodeURIComponent(n)}).join("&");t.url=t.url+"&"+f}return o({},t)}(t));return function(e,t){a(this,void 0,void 0,function(){var n,i,r,s;return c(this,function(o){switch(o.label){case 0:return[4,e.commonApiReady()];case 1:for(i in o.sent(),n=[],t)n.push(i);r=0,o.label=2;case 2:if(!(r0&&r[r.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]=0&&this.HANDLE_LIST.splice(t,1),window.removeEventListener("message",e,!1)},e.prototype.empty=function(){for(;this.HANDLE_LIST.length;){var e=this.HANDLE_LIST.shift();window.removeEventListener("message",e,!1)}},e.prototype.parse=function(e){try{return"object"==typeof e?e:e?JSON.parse(e):e}catch(t){return e}},e}(),p=function(){function e(e,t){var n=this;this.collectObjIdHandlers=new Set,this.polyfillApi=["ExportAsFixedFormat","GetOperatorsInfo","ImportDataIntoFields","ReplaceText","ReplaceBookmark","GetBookmarkText","GetComments"],this.getId=function(){return""},this.setterCallbacks={idMap:{}},this.sendMsgToWps=function(){},this.objId=0,this.origin="",this.apiChannel=function(e,t,i,r){return a(n,void 0,void 0,function(){var n,s,o,l,u,d,h,f,p,m=this;return c(this,function(v){switch(v.label){case 0:return n=this.getId(),l=new Promise(function(e,t){s=e,o=t}),u={},t.args?[4,this.reduceArgs(t.args)]:[3,2];case 1:d=v.sent(),h=d[0],f=d[1],t.args=h,u=f,v.label=2;case 2:return e!==this.prefix+"setter"?[3,4]:[4,this.handleApiSetter(t)];case 3:v.sent(),v.label=4;case 4:return p=function(){var t=function(l){return a(m,void 0,void 0,function(){var a,d,h;return c(this,function(c){switch(c.label){case 0:return this.instance.originWhiteList.includes(l.origin)||this.origin===l.origin?(a=this.message.parse(l.data)).eventName===this.prefix+"callback"&&a.callbackId&&u[a.callbackId]?[4,u[a.callbackId].apply(u,a.data.args)]:[3,2]:[2];case 1:d=c.sent(),this.sendMsgToWps({result:d,eventName:this.prefix+"callback.reply",callbackId:a.callbackId}),c.label=2;case 2:return a.eventName===e+".reply"&&a.msgId===n&&(a.error?((h=new Error("")).stack=a.error+"\n"+i,r&&r(),o(h)):s(a.result),this.message.remove(t)),[2]}})})};return m.message.add(t),l},this.handleSendApiChannel([{eventName:e,data:t,msgId:n},p]),[2,l]}})})},this.handleApiSetter=function(e){return a(n,void 0,void 0,function(){var t,n,i,r,s,o,a,l,u,d,h=this;return c(this,function(c){switch(c.label){case 0:return t=function(){return Object.keys(h.setterCallbacks.idMap).find(function(e){return h.setterCallbacks.idMap[e]===i+":"+n})},n=e.prop,i=e.parentObjId,r=e.value,[4,this.reduceArgs([r])];case 1:return s=c.sent(),o=s[0],a=s[1],e.value=o[0],l=Object.keys(a)[0],u=this.setterCallbacks[i],null===r&&u&&u[n]&&((d=t())&&delete this.setterCallbacks.idMap[d],delete u[n],Object.keys(u).length||delete this.setterCallbacks[i],Object.keys(this.setterCallbacks.idMap).length||this.message.remove(this.setterCallbackSubscribe.bind(this))),l&&(Object.keys(this.setterCallbacks.idMap).length||this.message.add(this.setterCallbackSubscribe.bind(this)),this.setterCallbacks[i]||(this.setterCallbacks[i]={}),this.setterCallbacks[i][n]={callbackId:l,callback:a[l]},(d=t())&&delete this.setterCallbacks.idMap[d],this.setterCallbacks.idMap[l]=i+":"+n),[2]}})})},this.prefix=t,this.origin=e.origin,this.sendMsgToWps=e.sendMsgToWps.bind(e),this.getId=e.getId.bind(e),this.message=e.message,this.sdkInstanceId=e.instanceId,this.instance=e}return e.prototype.destroyApplication=function(){this.collectObjIdHandlers=new Set,this.objId=0},e.prototype.subEventHandle=function(e,t){var n=this,i={};this.message.add(function(e){return a(n,void 0,void 0,function(){var t,n,r,s,o,a;return c(this,function(c){switch(c.label){case 0:return this.instance.originWhiteList.includes(e.origin)||this.origin===e.origin?(t=this.message.parse(e.data),n=t.sdkInstanceId,t.eventName===this.prefix+"event"&&Number(n)===this.sdkInstanceId&&t.data?(r=t.data,s=r.eventName,o=r.data,(a=i[s])?[4,a(o)]:[3,2]):[3,2]):[2];case 1:c.sent(),c.label=2;case 2:return[2]}})})});var r=function(r){var s=t[r];Object.defineProperty(e,s,{set:function(e){i[s]=e,n.sendMsgToWps({eventName:n.prefix+"event.register",data:{eventName:s,register:!!e,objId:n.objId+=1},sdkInstanceId:n.sdkInstanceId})}})};for(var s in t)r(s)},e.prototype.mixinProto=function(e,t){Object.assign(e,t)},e.prototype.makeCollectObjIdHandle=function(e){var t=this;return function(){var n=[],i=function(e){n.push(e)};return t.collectObjIdHandlers.add(i),{End:function(){e(n),t.collectObjIdHandlers.delete(i)}}}},e.prototype.assign=function(e,t,n){for(var i=this,r=t.slice(0),s=function(){var t=r.shift();!t.alias&&~a.polyfillApi.indexOf(t.prop)&&r.push(o(o({},t),{alias:t.prop+"Async"})),Object.defineProperty(e,t.alias||t.prop,{get:function(){var r=1===t.cache,s=r&&e["__"+t.prop+"CacheValue"];if(!s){var o=i.getError(),a=i.createObjId(r),c=function(){for(var r,s=[],a=0;a=0?(t.then=null,t.catch=null,c.then(function(){e(t)}).catch(function(e){return n(e)})):c.then(e,n)},t.catch=function(e){return c.catch(e)},t.Destroy=function(){return this.apiChannel(this.prefix+"free",{objId:t.objId},"")}},e.prototype.handleSendApiChannel=function(e){var t=e[0],n=e[1];"function"==typeof(t=o({},t)).data&&(t.data=t.data()),n(),this.sendMsgToWps(t)},e.prototype.setterCallbackSubscribe=function(e){return a(this,void 0,void 0,function(){var t,n,i,r,s,o,a,l,u,d;return c(this,function(c){switch(c.label){case 0:return this.instance.originWhiteList.includes(e.origin)||this.origin===e.origin?(t=this.message.parse(e.data),n=t.eventName,i=t.callbackId,r=t.data,i&&(s=this.setterCallbacks.idMap[i])?(o=s.split(":"),a=o[0],l=o[1],n===this.prefix+"callback"&&this.setterCallbacks[a]&&this.setterCallbacks[a][l]?[4,(d=this.setterCallbacks[a][l]).callback.apply(d,r.args)]:[3,2]):[3,2]):[2];case 1:u=c.sent(),this.sendMsgToWps({result:u,callbackId:i,eventName:this.prefix+"callback.reply"}),c.label=2;case 2:return[2]}})})},e.prototype.reduceArgs=function(e){return a(this,void 0,void 0,function(){var t,n,i,r,s,o,a,l,u,h,f;return c(this,function(c){switch(c.label){case 0:t={},n=[],i=e.slice(0),c.label=1;case 1:return i.length?(r=void 0,[4,i.shift()]):[3,13];case 2:return(s=c.sent())&&s.done?[4,s.done()]:[3,4];case 3:c.sent(),c.label=4;case 4:if(!d(r))return[3,11];for(a in r={},o=[],s)o.push(a);l=0,c.label=5;case 5:return l>>0,1)},emit:function(e,t){(n[e]||[]).slice().map(function(e){e(t)}),(n["*"]||[]).slice().map(function(n){n(e,t)})}}),this.handleConfig(t)}return e.config=function(t){return void 0===t&&(t={}),e.singleInstance||(e.singleInstance=new e(t)),e.singleInstance},e.prototype.setToken=function(e){return a(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.basicReady()];case 1:return t.sent(),this.tokenData=e,this.sendMsgToWps({eventName:"setToken",data:e}),[2]}})})},e.prototype.advancedApiReady=function(){return a(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return this.flag.advancedApiReadySendedJust?[3,2]:(this.flag.advancedApiReadySendedJust=!0,[4,this.fileOpenPromise]);case 1:e.sent(),this.flag.advancedApiReadySended||(this.flag.advancedApiReadySended=!0,this.sendMsgToWps({eventName:"api.ready"})),e.label=2;case 2:return[4,this.advancedReadyPromise];case 3:return[2,e.sent()]}})})},e.prototype.commonApiReady=function(){return a(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return this.flag.commonApiReadySendedJust?[3,2]:(this.flag.commonApiReadySendedJust=!0,[4,this.basicReady()]);case 1:e.sent(),this.flag.commonApiReadySended||(this.flag.commonApiReadySended=!0,this.sendMsgToWps({eventName:"commonApi.ready"})),e.label=2;case 2:return[4,this.commonApiPromise];case 3:return[2,e.sent()]}})})},e.prototype.destroy=function(){this.iframeInstance.destroy(),this.message.empty(),this.destroyApplication&&this.destroyApplication(),this.destroyCommonApp&&this.destroyCommonApp(),this.removeFullscreenEventListener()},e.prototype.on=function(e,t){return a(this,void 0,void 0,function(){var n;return c(this,function(i){switch(i.label){case 0:return[4,this.basicReady()];case 1:return i.sent(),n=e,"fullscreenChange"===e&&(n="fullscreenchange"),this.handleBasicEvent(n,"on"),this.mittInstance.on(e,t),[2]}})})},e.prototype.off=function(e,t){return a(this,void 0,void 0,function(){return c(this,function(n){switch(n.label){case 0:return[4,this.basicReady()];case 1:return n.sent(),this.handleBasicEvent(e,"off"),this.mittInstance.off(e,t),[2]}})})},e.prototype.handleConfig=function(e){var t,n=this;void 0===e&&(e={});try{var i=this.userConfHandler(e),r=i.subscriptions,s=void 0===r?{}:r,o=i.mount,a=void 0===o?null:o,c=i.url,l=i.originWhiteList;this.origin=(c.match(/https*:\/\/[^\/]+/g)||[])[0],this.originWhiteList=l||[];var u=this.readyEventNames.map(function(e){return n.makeReady(e)}),d=u[0],f=u[1],p=u[2],m=u[3];this.baseReadyPromise=d,this.fileOpenPromise=f,this.advancedReadyPromise=p,this.commonApiPromise=m,this.iframeWH=a?{width:a.clientWidth+"px",height:a.clientHeight+"px"}:{width:"100vw",height:"100vh"},delete i.mount,c&&delete i.url,this.url=c,delete i.subscriptions,this.sdkConfig=i,this.iframeInstance=new h(this,this.instanceId,c,a,null===(t=i.isListenResize)||void 0===t||t,!1,{allow:i.attrAllow}),this.iframe=this.iframeInstance.iframe,this.listener(s)}catch(e){return console.error(e),null}},e.prototype.listener=function(e){var t=this;this.message.add(function(n){return a(t,void 0,void 0,function(){var t,i,r,s,o,a,l,u,d;return c(this,function(c){return t=this.message.parse(n.data),i=t.eventName,r=void 0===i?"":i,s=t.data,o=void 0===s?null:s,a=t.url,l=void 0===a?null:a,u=t.sdkInstanceId,this.isOtherEvent(u)?[2]:-1!==["wps.jssdk.api"].indexOf(r)?[2]:((d=this.handleListenEvent(r,o))?d():Object.keys(this.onEventNames).includes(r)&&("open.result"===r&&(this.officeType=o.fileInfo.officeType),this.mittInstance.emit(this.onEventNames[r],o)),"function"==typeof e[r]&&e[r](this,l||o),[2])})})})},e.prototype.handleListenEvent=function(e,t){var i,r=this;return((i={"api.scroll":function(){return window.scrollTo(t.x,t.y)},"event.callback":function(){return a(r,void 0,void 0,function(){var e,n,i,r,s,o,a;return c(this,function(c){return e=t.eventName,n=t.data,i=e,"fullScreenChange"===e&&(i="fullscreenChange"),((null===(o=this.sdkConfig.commonOptions)||void 0===o?void 0:o.isBrowserViewFullscreen)||(null===(a=this.sdkConfig.commonOptions)||void 0===a?void 0:a.isParentFullscreen))&&"fullscreenchange"===i&&(r=n.status,s=n.isDispatchEvent,this.sdkConfig.commonOptions.isBrowserViewFullscreen?this.iframeWH&&function(e,t,n,i){0===e?t.style="position: static; width: "+n.width+"; height: "+n.height:1===e&&(t.style="position: absolute; width: 100%; height: 100%"),i&&function(e){["fullscreen","fullscreenElement"].forEach(function(t){Object.defineProperty(document,t,{get:function(){return!!e.status},configurable:!0})});var t=new CustomEvent("fullscreenchange");document.dispatchEvent(t)}({status:e})}(r,this.iframe,this.iframeWH,s):this.sdkConfig.commonOptions.isParentFullscreen&&function(e,t){if(0===e){var n=document,i=n.exitFullscreen||n.mozCancelFullScreen||n.msExitFullscreen||n.webkitCancelFullScreen||n.webkitExitFullscreen;i.call(document)}else if(1===e){var r=t.requestFullscreen||t.mozRequestFullScreen||t.msRequestFullscreen||t.webkitRequestFullscreen;r.call(t)}}(r,this.iframe)),this.mittInstance.emit(i,n),[2]})})}})[n.refreshToken]=function(){return a(r,void 0,void 0,function(){var t,n;return c(this,function(i){switch(i.label){case 0:t={token:!1},i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.cbConfigsSub.refreshToken()];case 2:return t=i.sent(),[3,4];case 3:return n=i.sent(),console.error("refreshToken: "+(n||"fail to get")),[3,4];case 4:return this.sendMsgToWps({eventName:e+".reply",data:t}),[2]}})})},i)[e]},e.prototype.basicReady=function(){return this.baseReadyPromise},e.prototype.userConfHandler=function(e,t){var i=this;void 0===t&&(t=!0);var s=o({},e),a=s.headers,c=void 0===a?{}:a,l=s.subscriptions,u=void 0===l?{}:l,d=s.commonOptions,h=s.url,f=void 0===h?"":h,p=s.wpsUrl,m=void 0===p?"":p,v=s.mode,b=void 0===v?r.nomal:v,g=s.debug,y=s.disablePlugins,w=s.hideGuide,k=s.readOnly;return Object.assign(s,this.handleHeadersAndSubscriptionsConfig(c,u,t)),s.url=this.handleUrlConfig(d,b,g,f,m,y,w,k),d&&(d.isParentFullscreen||d.isBrowserViewFullscreen)&&document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.polyfillConfigName.map(function(e){var t=e[0],n=e[1];s[n]&&(s[t]=s[n])}),this.cbConfigs.map(function(e){var t,r,o=s[e];o&&(t=o,r="Function",{}.toString.call(t)==="[object "+r+"]")&&(i.cbConfigsSub[e]=o,s[e]={eventName:n[e]})}),s.commandBars&&this.handleCommandBarsConfig(s.commandBars,!1),o({},s)},e.prototype.handleBasicEvent=function(e,t){if(!["error","fileOpen"].includes(e)){var n={eventName:"basic.event",data:{eventName:e,action:t}};this.sendMsgToWps(n)}},e.prototype.removeFullscreenEventListener=function(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange)},e.prototype.handleHeadersAndSubscriptionsConfig=function(e,t,n){var i=e.backBtn,r=void 0===i?{}:i,s=e.shareBtn,o=void 0===s?{}:s,a=e.otherMenuBtn,c=void 0===a?{}:a,l=[["wpsconfig_back_btn",r],["wpsconfig_share_btn",o],["wpsconfig_other_menu_btn",c]],u=[];return c.items&&Array.isArray(c.items)&&c.items.forEach(function(e,t){void 0===e&&(e={}),"custom"===e.type&&u.push(["wpsconfig_other_menu_btn_"+t,e])}),l.concat(u).forEach(function(e){var i,r;i=e[1],r=e[0],i.subscribe&&"function"==typeof i.subscribe&&(i.callback=r,t[r]=i.subscribe,n&&delete i.subscribe)}),{}},e.prototype.handleUrlConfig=function(e,t,n,i,s,o,a,c){var l=[];l.push("sdkId="+this.instanceId),t===r.simple||e&&!1===e.isShowTopArea?l.push("simple","hidecmb"):t===r.embed&&l.push("simple=1","hidecmb=1","embed=1"),o&&l.push("disablePlugins"),a&&l.push("hideguide"),c&&l.push("readonly"),n&&l.push("debugger");var u=i||s;return u&&l.length&&(u=u+(u.indexOf("?")>=0?"&":"?")+l.join("&")),u},e.prototype.handleCommandBarsConfig=function(e,t){void 0===t&&(t=!0);var n=e.map(function(e){var t=e.attributes;if(!Array.isArray(t)){var n=[];for(var i in t)if(t.hasOwnProperty(i)){var r={name:i,value:t[i]};n.push(r)}e.attributes=n}return e});return t&&this.sendMsgToWps({data:n,eventName:"setCommandBars"}),n},e.prototype.sendMsgToWps=function(e){var t,n,i=o(o({},e),{sdkInstanceId:this.instanceId});null===(n=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===n||n.postMessage(JSON.stringify(i),this.realOrigin)},e.prototype.makeReady=function(e){var t=this,n=e.event,i=e.callback,r=e.after;return new Promise(function(e){var s=function(o){if(t.realOrigin=o.origin,t.originWhiteList.includes(o.origin)||t.origin===o.origin){var a=t.message.parse(o.data),c=a.eventName,l=a.data,u=a.sdkInstanceId;if(!t.isOtherEvent(u)&&c===n){var d=void 0;!r&&i&&(d=i(l)),e(d),r&&i&&i(l),"ready"!==n&&t.message.remove(s)}}};t.message.add(s)})},e.prototype.getId=function(){return this.id+=1,this.instanceId+"-"+this.id},e.instanceId=1,e}(),g={executeCommandBar:"ExecuteCommandBar",off:"Off",save:"Save",setCommandBars:"SetCommandBars",setCooperUserColor:"SetCooperUserColor",tabs:"Tabs",Stack:"Stack",WhenStacksEmpty:"WhenStacksEmpty"};function y(e,t){var n=this;return void 0===t&&(t={}),new Proxy(e,o(o({},{get:function(e,t){if(Object.keys(g).includes(t)){var i=g[t];return"Tabs"===i?function(e){var t=this;return{switchTab:function(n){return a(t,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,e.commonApiReady()];case 1:return t.sent(),[4,e.CommonApi.Tabs.SwitchTab(n.tabKey)];case 2:return[2,t.sent()]}})})},getTabs:function(){return a(t,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,e.commonApiReady()];case 1:return t.sent(),[4,e.CommonApi.Tabs.GetTabs()];case 2:return[2,t.sent()]}})})}}}(e):e.CommonApi?Reflect.get(e.CommonApi,i):function(){return a(n,void 0,void 0,function(){var t;return c(this,function(n){switch(n.label){case 0:return[4,e.commonApiReady()];case 1:return n.sent(),[4,e.commonApiPromise];case 2:return n.sent(),"function"!=typeof e.CommonApi[i]?[3,4]:[4,e.CommonApi[i]()];case 3:return t=n.sent(),[3,5];case 4:t=e.CommonApi[i],n.label=5;case 5:return[2,t]}})})}}return Reflect.get(e,t)},set:function(e,t,n){return!!Reflect.has(e,t)&&Reflect.set(e,t,n)}}),t))}var w;!function(e){e.Spreadsheet="s",e.Writer="w",e.Presentation="p",e.Pdf="f",e.Otl="o",e.Dbt="d",e.KSheet="k"}(w||(w={}));var k=function(e){function n(t){var n=e.call(this,t)||this;return t.token&&(d(t.token)?n.setToken(o({},t.token)):n.setToken({token:t.token})),n.ApiEvent={AddApiEventListener:function(e,t){n.on(e,t)},RemoveApiEventListener:function(e,t){n.off(e,t)}},n}return t(n,e),n.init=function(e){var t=o({},e);if(t.endpoint=t.endpoint||"https://o.wpsgo.com","string"==typeof t.mount){var i=document.querySelector(t.mount);i?t.mount=i:(console.warn("[WebOfficeSDK.init] mount挂载节点未找到"),delete t.mount)}if(t.url)throw Error("[WebOfficeSDK.init] 不支持传递url,请使用appId、fileId、officeType、token等参数初始化!");if(!t.appId||!t.fileId||!t.officeType)throw Error("[WebOfficeSDK.init] appId、fileId、officeType为必选项!");if("string"!=typeof t.endpoint)throw Error("[WebOfficeSDK.init] endpoint期望为字符串");if(t.endpoint&&!t.endpoint.startsWith("http"))throw Error("[WebOfficeSDK.init] endpoint仅支持http、https的地址");var r=new n(function(e){var t=o({},e);t.token=t.token||t.fileToken;var n=t.appId,i=t.fileId,r=t.officeType,s=t.token,a=t.endpoint,c=t.customArgs,l=void 0===c?"":c;if(!Object.values(w).includes(r))throw Error("[WebOfficeSDK.init] officeType属性值错误,可选值参考WebOfficeSDK.OfficeType: "+JSON.stringify(w));var u=s?1:0,h={token:""};if("string"==typeof s?h.token=s:d(s)&&(h=o({tokenData:h},s)),u&&!h.token)return console.error("[WebOfficeSDK.init] token设置无效"),t;if(t.url=a+"/office/"+r+"/"+i+"?_w_appid="+n+"&_w_tokentype="+u,d(l)){var f=Object.entries(l).map(function(e){var t=e[0],n=e[1];return t+"="+encodeURIComponent(n)}).join("&");t.url=t.url+"&"+f}return o({},t)}(t));return function(e,t){a(this,void 0,void 0,function(){var n,i,r,s;return c(this,function(o){switch(o.label){case 0:return[4,e.commonApiReady()];case 1:for(i in o.sent(),n=[],t)n.push(i);r=0,o.label=2;case 2:if(!(r