"use strict";
/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackJsonp_bos-platform"] = self["webpackJsonp_bos-platform"] || []).push([[4956],{

/***/ "./src/component/common/onlyoffice/OnlyOfficeEditor.jsx":
/*!**************************************************************!*\
  !*** ./src/component/common/onlyoffice/OnlyOfficeEditor.jsx ***!
  \**************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

eval("\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"../../node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"../../node_modules/core-js/modules/es.symbol.description.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"../../node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"../../node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.array.filter.js */ \"../../node_modules/core-js/modules/es.array.filter.js\");\n__webpack_require__(/*! core-js/modules/es.array.from.js */ \"../../node_modules/core-js/modules/es.array.from.js\");\n__webpack_require__(/*! core-js/modules/es.array.index-of.js */ \"../../node_modules/core-js/modules/es.array.index-of.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"../../node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.slice.js */ \"../../node_modules/core-js/modules/es.array.slice.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"../../node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-string.js */ \"../../node_modules/core-js/modules/es.date.to-string.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"../../node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.object.define-properties.js */ \"../../node_modules/core-js/modules/es.object.define-properties.js\");\n__webpack_require__(/*! core-js/modules/es.object.define-property.js */ \"../../node_modules/core-js/modules/es.object.define-property.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ \"../../node_modules/core-js/modules/es.object.get-own-property-descriptor.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptors.js */ \"../../node_modules/core-js/modules/es.object.get-own-property-descriptors.js\");\n__webpack_require__(/*! core-js/modules/es.object.keys.js */ \"../../node_modules/core-js/modules/es.object.keys.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ \"../../node_modules/core-js/modules/es.regexp.to-string.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"../../node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.weak-map.js */ \"../../node_modules/core-js/modules/es.weak-map.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"../../node_modules/core-js/modules/web.dom-collections.iterator.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n  value: true\n}));\nexports[\"default\"] = void 0;\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"../../node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.array.for-each.js */ \"../../node_modules/core-js/modules/es.array.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.array.is-array.js */ \"../../node_modules/core-js/modules/es.array.is-array.js\");\n__webpack_require__(/*! core-js/modules/es.function.name.js */ \"../../node_modules/core-js/modules/es.function.name.js\");\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"../../node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"../../node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"../../node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"../../node_modules/core-js/modules/web.dom-collections.for-each.js\");\nvar _react = _interopRequireWildcard(__webpack_require__(/*! react */ \"webpack/sharing/consume/default/react/react?dca2\"));\nvar _global = __webpack_require__(/*! @/global */ \"./src/global/index.js\");\nvar _memoryCacher = __webpack_require__(/*! @/model/memoryCacher */ \"./src/model/memoryCacher.js\");\nvar _server = __webpack_require__(/*! @/action/actionname/control/weboffice/server */ \"./src/action/actionname/control/weboffice/server/index.js\");\nvar _appModelFunction = __webpack_require__(/*! @/model/appModelFunction */ \"./src/model/appModelFunction.js\");\nvar _loadjs = _interopRequireDefault(__webpack_require__(/*! @/util/loadjs */ \"./src/util/loadjs.js\"));\nvar _componentutil = __webpack_require__(/*! @/util/componentutil */ \"./src/util/componentutil.js\");\nvar directives = _interopRequireWildcard(__webpack_require__(/*! @/component/common/onlyoffice/onlyOfficeDirective */ \"./src/component/common/onlyoffice/onlyOfficeDirective.js\"));\nvar _storage = _interopRequireDefault(__webpack_require__(/*! @/util/storage */ \"./src/util/storage.js\"));\nvar _webOffice = __webpack_require__(/*! @/constant/webOffice */ \"./src/constant/webOffice.js\");\nvar _intlApi = __webpack_require__(/*! @/i18n/intlApi */ \"./src/i18n/intlApi.js\");\nvar _const = __webpack_require__(/*! @/constant/const */ \"./src/constant/const.js\");\nvar _excluded = [\"accountId\", \"className\", \"ctrlKey\", \"pageId\", \"documentServerUrl\", \"documentUrl\", \"style\", \"save\", \"getToken\", \"sendValidResult\", \"showMessage\", \"showNoChangeTip\"];\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { \"default\": obj }; }\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != _typeof(e) && \"function\" != typeof e) return { \"default\": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n[\"default\"] = e, t && t.set(e, n), n; }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : String(i); }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\nvar encrypt = function encrypt() {\n  var fileKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n  var res = 0;\n  for (var index = 0; index < fileKey.length; index++) {\n    res += fileKey.charCodeAt(index) * index;\n  }\n  return res;\n};\nvar OnlyOfficeEditor = function OnlyOfficeEditor(_ref) {\n  var accountId = _ref.accountId,\n    className = _ref.className,\n    ctrlKey = _ref.ctrlKey,\n    pageId = _ref.pageId,\n    documentServerUrl = _ref.documentServerUrl,\n    documentUrl = _ref.documentUrl,\n    style = _ref.style,\n    save = _ref.save,\n    getToken = _ref.getToken,\n    sendValidResult = _ref.sendValidResult,\n    showMessage = _ref.showMessage,\n    showNoChangeTip = _ref.showNoChangeTip,\n    other = _objectWithoutProperties(_ref, _excluded);\n  var _useState = (0, _react.useState)(false),\n    _useState2 = _slicedToArray(_useState, 2),\n    compactToolbar = _useState2[0],\n    setCompactToolbar = _useState2[1];\n  var _useState3 = (0, _react.useState)(documentUrl),\n    _useState4 = _slicedToArray(_useState3, 2),\n    fileUrl = _useState4[0],\n    setFileUrl = _useState4[1];\n  var _useState5 = (0, _react.useState)(''),\n    _useState6 = _slicedToArray(_useState5, 2),\n    userName = _useState6[0],\n    setUserName = _useState6[1];\n  var _useState7 = (0, _react.useState)(null),\n    _useState8 = _slicedToArray(_useState7, 2),\n    token = _useState8[0],\n    setToken = _useState8[1];\n  var cacheDirectiveRef = (0, _react.useRef)([]);\n  var isDocumentReady = (0, _react.useRef)(false);\n  var isDocumentChange = (0, _react.useRef)(false);\n  var editor = (0, _react.useRef)();\n  var saveInfo = (0, _react.useRef)({});\n  var fileKey$ = (0, _react.useRef)('');\n  (0, _react.useEffect)(function () {\n    (0, _memoryCacher.setControlMount)(pageId, \"\".concat(ctrlKey, \"_\").concat(_webOffice.OnlyOfficeCtrlKey), true);\n    return function () {\n      (0, _memoryCacher.setControlMount)(pageId, \"\".concat(ctrlKey, \"_\").concat(_webOffice.OnlyOfficeCtrlKey), false);\n    };\n  }, [pageId, ctrlKey]);\n  (0, _react.useEffect)(function () {\n    var removeDataChangeListener = (0, _memoryCacher.subscribeControlMethod)(pageId, \"\".concat(ctrlKey, \"_\").concat(_webOffice.OnlyOfficeCtrlKey), 'directives', executeControlMethod);\n    return function () {\n      return removeDataChangeListener();\n    };\n  }, [pageId, ctrlKey]);\n  var getJWTParams = (0, _react.useCallback)(function (key) {\n    var rootPageId = (0, _appModelFunction.getRootPageId)()((0, _global.getGlobalState)());\n    var _window$location = window.location,\n      origin = _window$location.origin,\n      pathname = _window$location.pathname;\n    var path = pathname.replace('/index.html', '').replace('/index', '');\n    return {\n      document: {\n        fileType: 'docx',\n        key: key,\n        title: '',\n        url: fileUrl,\n        permissions: {\n          print: false,\n          download: false\n        }\n      },\n      documentType: 'word',\n      editorConfig: {\n        callbackUrl: \"\".concat(origin).concat(path, \"attachment/v1/3rd/file/onlyoffice?p=\").concat(rootPageId, \"&f=\").concat(encrypt(key), \"&accountId=\").concat(accountId),\n        lang: 'zh',\n        customization: {\n          compactHeader: true,\n          compactToolbar: compactToolbar,\n          feedback: false,\n          forcesave: true,\n          autosave: true,\n          toolbarHideFileName: true,\n          toolbarNoTabs: true\n        },\n        user: {\n          name: userName\n        }\n      }\n    };\n  }, [compactToolbar, userName, fileUrl, accountId]);\n  (0, _react.useEffect)(function () {\n    fileKey$.current = (0, _componentutil.createNewId)();\n    _storage[\"default\"].set(fileKey$.current, \"\".concat(pageId, \"$$\").concat(ctrlKey));\n  }, [pageId, ctrlKey]);\n  (0, _react.useEffect)(function () {\n    if (fileUrl) {\n      getToken === null || getToken === void 0 || getToken(getJWTParams(fileKey$.current));\n    }\n  }, [fileUrl]);\n  (0, _react.useEffect)(function () {\n    var jwtParams = getJWTParams(fileKey$.current);\n    if (!jwtParams.document.key || !jwtParams.document.url || token === undefined || token === null) return;\n    var handleDocumentReady = function handleDocumentReady() {\n      var _window$DocEditor;\n      if (cacheDirectiveRef.current.length === 0) return;\n      isDocumentReady.current = true;\n      var connector = (_window$DocEditor = window.DocEditor) === null || _window$DocEditor === void 0 || (_window$DocEditor = _window$DocEditor.instances) === null || _window$DocEditor === void 0 ? void 0 : _window$DocEditor.docxEditor.createConnector();\n      cacheDirectiveRef.current.forEach(function (directive) {\n        var methodName = directive.methodName,\n          data = directive.data;\n        var eventFun = directives[methodName];\n        eventFun && eventFun(connector, data, {\n          sendValidResult: sendValidResult\n        });\n      });\n      cacheDirectiveRef.current = [];\n    };\n    var handleDocumentStateChange = function handleDocumentStateChange() {\n      isDocumentChange.current = true;\n    };\n    var loadScriptSuccess = function loadScriptSuccess() {\n      if (editor.current) {\n        editor.current.destroyEditor();\n      }\n      var params = _objectSpread(_objectSpread({}, getJWTParams(fileKey$.current)), {}, {\n        events: {\n          onDocumentReady: handleDocumentReady,\n          onDocumentStateChange: handleDocumentStateChange\n        }\n      });\n      if (token) {\n        params.token = token;\n      }\n      try {\n        editor.current = new DocsAPI.DocEditor(\"\".concat(pageId, \"_\").concat(ctrlKey, \"_editor\"), params);\n      } catch (err) {\n        console.log(err);\n      }\n    };\n    var loadScriptFailed = function loadScriptFailed() {\n      showMessage === null || showMessage === void 0 || showMessage((0, _intlApi.getLangMsg)({\n        key: 'webOffice.key0022'\n      }));\n    };\n    (0, _loadjs[\"default\"])(\"\".concat(documentServerUrl, \"web-apps/apps/api/documents/api.js\"), {\n      success: loadScriptSuccess,\n      error: loadScriptFailed\n    });\n    return function () {\n      _storage[\"default\"].remove(fileKey$.current);\n    };\n  }, [token]);\n  var executeControlMethod = (0, _react.useCallback)(function (event) {\n    if (event === undefined || Array.isArray(event) && event.length === 0) return;\n    if (event[0].methodname === _server.WEB_OFFICE_ACTION) {\n      var _editor$current;\n      var methodName = event[0].args[0].event;\n      var data = Array.isArray(event[0].args[0]) ? event[0].args[0] : event[0].args[0].data;\n      var connector = (_editor$current = editor.current) === null || _editor$current === void 0 ? void 0 : _editor$current.createConnector();\n      if (methodName === 'openNew') {\n        var templateUrlForOnlyOffice = data.templateUrlForOnlyOffice;\n        // setFileUrl('http://172.19.105.200:3000/ierp/采购合同终止协议模板.docx')\n        setFileUrl(templateUrlForOnlyOffice);\n      } else if (methodName === 'setToolbars') {\n        var showToolbars = data.value;\n        // 展示工具栏时，工具栏应为非紧凑模式，故取反\n        setCompactToolbar(!showToolbars);\n        return;\n      } else if (methodName === 'open') {\n        var url = data.url,\n          name = data.userName,\n          onlyOfficeDownloadUrl = data.onlyOfficeDownloadUrl;\n        setFileUrl(onlyOfficeDownloadUrl || url);\n        setUserName(name);\n      } else if (methodName === 'sendIsDocChange') {\n        sendValidResult([{\n          data: isDocumentChange.current,\n          id: data.id,\n          type: 'isDocChange'\n        }]);\n      } else if (methodName === 'saveSuccess') {\n        var _url = data.url,\n          uid = data.fileKey;\n        save === null || save === void 0 || save([_objectSpread({\n          uid: uid,\n          url: _url\n        }, saveInfo.current)]);\n        return;\n      } else if (methodName === 'save') {\n        var _directives$save;\n        saveInfo.current = {\n          name: data.name,\n          id: data.id\n        };\n        var showNotification = function showNotification(msg) {\n          return showMessage(msg, _const.AlertType.WARNING);\n        };\n        var param = {\n          url: documentServerUrl,\n          uid: fileKey$.current,\n          showNotification: showNotification,\n          showNoChangeTip: showNoChangeTip\n        };\n        (_directives$save = directives.save) === null || _directives$save === void 0 || _directives$save.call(directives, connector, param);\n        return;\n      } else if (methodName === 'getOfficeToken') {\n        var _token = data.token;\n        setToken(_token);\n        return;\n      }\n      if (!isDocumentReady.current || !connector) {\n        cacheDirectiveRef.current.push({\n          methodName: methodName,\n          data: data\n        });\n      } else {\n        var eventFun = directives[methodName];\n        eventFun && eventFun(connector, data, {\n          sendValidResult: sendValidResult\n        });\n      }\n    }\n  }, [documentServerUrl, showNoChangeTip, showMessage]);\n  return /*#__PURE__*/_react[\"default\"].createElement(\"div\", {\n    style: _objectSpread({\n      height: '100%'\n    }, style),\n    className: className\n  }, /*#__PURE__*/_react[\"default\"].createElement(\"div\", {\n    id: \"\".concat(pageId, \"_\").concat(ctrlKey, \"_editor\")\n  }));\n};\nvar _default = exports[\"default\"] = OnlyOfficeEditor;\n\n//# sourceURL=webpack://bos-platform/./src/component/common/onlyoffice/OnlyOfficeEditor.jsx?");

/***/ }),

/***/ "./src/component/common/onlyoffice/onlyOfficeDirective.js":
/*!****************************************************************!*\
  !*** ./src/component/common/onlyoffice/onlyOfficeDirective.js ***!
  \****************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

eval("\n\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"../../node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"../../node_modules/core-js/modules/es.symbol.description.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"../../node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.from.js */ \"../../node_modules/core-js/modules/es.array.from.js\");\n__webpack_require__(/*! core-js/modules/es.array.is-array.js */ \"../../node_modules/core-js/modules/es.array.is-array.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"../../node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.slice.js */ \"../../node_modules/core-js/modules/es.array.slice.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-string.js */ \"../../node_modules/core-js/modules/es.date.to-string.js\");\n__webpack_require__(/*! core-js/modules/es.function.name.js */ \"../../node_modules/core-js/modules/es.function.name.js\");\n__webpack_require__(/*! core-js/modules/es.object.define-property.js */ \"../../node_modules/core-js/modules/es.object.define-property.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ \"../../node_modules/core-js/modules/es.regexp.to-string.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"../../node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"../../node_modules/core-js/modules/web.dom-collections.iterator.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n  value: true\n}));\nexports.addCommentDialog = addCommentDialog;\nexports.addMark = addMark;\nexports.addTableColumns = addTableColumns;\nexports.addTableRows = addTableRows;\nexports.addTextMark = addTextMark;\nexports.callEditorFunction = callEditorFunction;\nexports.cancelSelectionEditArea = cancelSelectionEditArea;\nexports.close = close;\nexports.delMark = delMark;\nexports.deleteMark = deleteMark;\nexports.docCompare = docCompare;\nexports.docProtect = docProtect;\nexports.forceSave = forceSave;\nexports.insertPictures = insertPictures;\nexports.insertValue = insertValue;\nexports.locateMark = locateMark;\nexports.mergeDocs = mergeDocs;\nexports.save = save;\nexports.saveAsLocal = saveAsLocal;\nexports.sendAllCheckBox = sendAllCheckBox;\nexports.sendAllField = sendAllField;\nexports.sendFieldExist = sendFieldExist;\nexports.sendIsDocChange = void 0;\nexports.sendIsFieldRevise = sendIsFieldRevise;\nexports.sendOpenStatus = sendOpenStatus;\nexports.sendTextByField = sendTextByField;\nexports.setCaption = setCaption;\nexports.setCheckBoxValue = setCheckBoxValue;\nexports.setDocAsField = setDocAsField;\nexports.setDocLimit = setDocLimit;\nexports.setDocLimitByRole = setDocLimitByRole;\nexports.setDocUnLimit = setDocUnLimit;\nexports.setDocUnLimitByRole = setDocUnLimitByRole;\nexports.setDynamicTable = setDynamicTable;\nexports.setMenubar = setMenubar;\nexports.setSelectionAsField = setSelectionAsField;\nexports.setSelectionEditArea = setSelectionEditArea;\nexports.setTextAsTitle = setTextAsTitle;\nexports.setTitlebar = setTitlebar;\nexports.setTrackingMode = setTrackingMode;\nexports.showTracesByRole = showTracesByRole;\nexports.toggleShowTraces = toggleShowTraces;\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"../../node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.array.filter.js */ \"../../node_modules/core-js/modules/es.array.filter.js\");\n__webpack_require__(/*! core-js/modules/es.array.find.js */ \"../../node_modules/core-js/modules/es.array.find.js\");\n__webpack_require__(/*! core-js/modules/es.array.for-each.js */ \"../../node_modules/core-js/modules/es.array.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.array.includes.js */ \"../../node_modules/core-js/modules/es.array.includes.js\");\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"../../node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/es.promise.js */ \"../../node_modules/core-js/modules/es.promise.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"../../node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.includes.js */ \"../../node_modules/core-js/modules/es.string.includes.js\");\n__webpack_require__(/*! core-js/modules/es.string.match.js */ \"../../node_modules/core-js/modules/es.string.match.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"../../node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/web.timers.js */ \"../../node_modules/core-js/modules/web.timers.js\");\nvar _intlApi = __webpack_require__(/*! @/i18n/intlApi */ \"./src/i18n/intlApi.js\");\nvar _webOffice = __webpack_require__(/*! @/constant/webOffice */ \"./src/constant/webOffice.js\");\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\n/**\n * TODO: 可能无法实现\n * 设置是否显示标题栏\n * @param {object} data {value:true\\false}\n */\nfunction setTitlebar(connector, data) {}\n\n/**\n * TODO: 可能无法实现\n * 设置是否显示菜单栏\n * @param {object} data {value:true\\false}\n * @param {object} props webOffice\n */\nfunction setMenubar(data, props) {}\n\n/**\n * TODO: 可能无法实现\n * 添加控件标题栏文字\n * @param {object} data {value:\"标题栏文字\"}\n * @param {object} props webOffice\n */\nfunction setCaption(data, props) {}\n\n/**\n * 保存文档\n * TODO: 实现方式有待确认\n */\nfunction save(connector, data) {\n  connector.callCommand(function () {\n    Api.Save();\n  });\n  forceSave(data.url, data.uid, data.showNotification, data.showNoChangeTip);\n}\nfunction forceSave(url, uid, showNotification, showNoChangeTip) {\n  var param = {\n    method: 'post',\n    body: JSON.stringify({\n      c: 'forcesave',\n      key: uid\n    }),\n    mode: 'cors',\n    credentials: 'same-origin'\n  };\n  window.fetch(\"\".concat(url, \"coauthoring/CommandService.ashx\"), param).then(function (response) {\n    return response.json();\n  }).then(function (data) {\n    if (data.error === 4 && showNoChangeTip) {\n      showNotification((0, _intlApi.getLangMsg)({\n        key: 'webOffice.key0021'\n      }));\n    } else if (data.error !== 0) {\n      console.error(\"\\u4FDD\\u5B58\\u5931\\u8D25: \".concat(data.error));\n    }\n  })[\"catch\"](function (err) {\n    showNotification(err);\n  });\n}\n\n/**\n * 关闭文档\n * @param {object} data\n * @param {object} props webOffice\n */\nfunction close() {}\n\n/**\n * 在光标位置或选中文字处插入批注\n * TODO: OnlyOffice 支持动态插入批注，但是没有找到接口方法可以打开批注窗口\n */\nfunction addCommentDialog() {}\n\n/**\n * TODO: 可能无法实现\n * 文档比较\n * @param {object} data {\"currentFile\":\"原文档名称.doc\",currentFileUrl：\"原文档url\",\"compareFile\":\"比较文档名称.doc\",\"compareFileUrl\":\"比较文档url\"}\n */\nfunction docCompare(data) {}\n\n/**\n * 插入书签\n * @param {object} data 数据\n */\nfunction addMark(connector, data) {\n  Asc.scope.bookmark = data;\n  connector.callCommand(function () {\n    var _Asc$scope$bookmark = Asc.scope.bookmark,\n      value = _Asc$scope$bookmark.value,\n      field = _Asc$scope$bookmark.field;\n    var oDocument = Api.GetDocument();\n    var oParagraph = Api.CreateParagraph();\n    var oRun = Api.CreateRun();\n    oRun.AddText(value);\n    oParagraph.AddElement(oRun);\n    var beforeInsert = oDocument.Search(value);\n    // 行内插入\n    oDocument.InsertContent([oParagraph], true);\n    setTimeout(function () {\n      var afterInsert = oDocument.Search(value);\n      var bookmarkRange;\n      for (var i = 0; i < beforeInsert.length; i++) {\n        if (beforeInsert[i].Element !== afterInsert[i].Element) {\n          bookmarkRange = afterInsert[i];\n          break;\n        }\n      }\n      if (!bookmarkRange) {\n        bookmarkRange = afterInsert[afterInsert.length - 1];\n      }\n      bookmarkRange && bookmarkRange.AddBookmark(field);\n    }, 0);\n  });\n  delete Asc.scope.bookmark;\n}\n\n/**\n * 定位书签\n * @param {object} connector 连接器\n * @param {object} data 数据\n */\nfunction locateMark(connector, data) {\n  Asc.scope.bookmark = data;\n  connector.callCommand(function () {\n    var field = Asc.scope.bookmark.field;\n    var oDocument = Api.GetDocument();\n    var range = oDocument.GetBookmarkRange(field);\n    range.Select();\n  });\n  delete Asc.scope.bookmark;\n}\n\n/**\n * 删除书签\n * @param {object} connector 连接器\n * @param {object} data 数据\n */\nfunction deleteMark(connector, data) {\n  Asc.scope.bookmark = data;\n  connector.callCommand(function () {\n    var fields = Asc.scope.bookmark;\n    var oDocument = Api.GetDocument();\n    fields.forEach(function (fieldObj) {\n      var field = fieldObj.field;\n      var oRange = oDocument.GetBookmarkRange(field);\n      oRange.Delete();\n      oDocument.DeleteBookmark(field);\n    });\n  });\n}\n\n/**\n * 获取当前文档所有书签，并将结果发送给后端\n * @param {object} data\n * @param {object} props webOffice\n */\nfunction sendAllField(connector, data, props) {\n  var sendValidResult = props.sendValidResult;\n  var id = data.id;\n  var oDocument = Api.GetDocument();\n  var result = oDocument.GetAllBookmarksNames();\n  sendValidResult([{\n    data: result,\n    id: id,\n    type: 'allField'\n  }]);\n}\n\n/**\n * TODO: 不一定能实现\n * 保护文档\n * @param {object} connector\n * @param {object} data\n */\nfunction docProtect(connector, data) {}\n\n/**\n * TODO: 不一定能实现\n * 限制编辑\n * @param {object} connector\n * @param {object} data { password: '密码' }\n */\nfunction setDocLimit(connector, data) {}\n\n/**\n * TODO: 不一定能实现\n * 解除区域限制\n * @param {object} connector\n * @param {object} data { password: '密码' }\n */\nfunction setDocUnLimit(connector, data) {}\n\n/**\n * TODO: 不一定能实现\n * 设置选中区域为可编辑区域，编辑模板时使用（选中区域将被设置为书签）\n * @param {object} connector\n * @param {object} data { field: '书签名称' }\n */\nfunction setSelectionEditArea(connector, data) {}\n\n/**\n * TODO: 不一定能实现\n * 取消选中区域的第一个书签内容的编辑状态（对应书签将被删除）\n * @param {object} connector\n * @param {object} data { field: '书签名称' }\n */\nfunction cancelSelectionEditArea(connector, data) {}\n\n/**\n * 批量设置书签内容为可编辑，并开启区域限制，其他区域将被锁定\n * @param {object} data {\"field\":[\"书签名称1\",\"书签名称2\"],\"password\":\"密码\"}\n * @param {object} props webOffice\n */\nfunction setDocLimitByRole(connector, data, props) {}\n\n/**\n * 批量设置书签内容为可编辑，并开启区域限制，其他区域将被锁定\n * @param {object} data {\"field\":[\"书签名称1\",\"书签名称2\"],\"password\":\"密码\"}\n * @param {object} props webOffice\n */\nfunction setDocUnLimitByRole(connector, data, props) {}\n\n/**\n * 根据书签名称获取文本内容并发送后端\n * @param {object} data {\"field\":\"书签名称\",\"id\":\"回调的id\"}\n * @param {object} props webOffice\n */\nfunction sendTextByField(connector, data, props) {\n  Asc.scope.field = data;\n  Asc.scope.resultCb = props.sendValidResult;\n  connector.callCommand(function () {\n    var _Asc$scope$resultCb, _Asc$scope;\n    var _Asc$scope$field = Asc.scope.field,\n      field = _Asc$scope$field.field,\n      id = _Asc$scope$field.id;\n    var oDocument = Api.GetDocument();\n    var range = oDocument.GetBookmarkRange(field);\n    var result = (range === null || range === void 0 ? void 0 : range.GetText()) || '';\n    (_Asc$scope$resultCb = (_Asc$scope = Asc.scope).resultCb) === null || _Asc$scope$resultCb === void 0 || _Asc$scope$resultCb.call(_Asc$scope, [{\n      data: {\n        result: result,\n        field: field\n      },\n      id: id,\n      type: 'getTextByField'\n    }]);\n  });\n  delete Asc.scope.field;\n  delete Asc.scope.resultCb;\n}\n\n/**\n * 书签内容是否有任意改动（包含样式、批注等），并将结果发给后端\n * @param {object} data {\"field\":\"书签名称\"}\n * @param {object} props webOffice\n */\nfunction sendIsFieldRevise(connector, data, props) {}\nvar sendIsDocChange = exports.sendIsDocChange = function sendIsDocChange(connector, data, props) {\n  var sendValidResult = props.sendValidResult;\n  var id = data.id;\n  sendValidResult([{\n    data: true,\n    id: id,\n    type: 'isDocChange'\n  }]);\n};\n\n/**\n * 判断当前书签是否存在，并将结果发送给后端\n * @param {object} data {\"field\":\"书签名称\"}\n * @param {object} props webOffice\n */\nfunction sendFieldExist(connector, data, props) {\n  Asc.scope.bookmark = data;\n  Asc.scope.resultCb = props.sendValidResult;\n  connector.callCommand(function () {\n    var _Asc$scope$resultCb2, _Asc$scope2;\n    var oDocument = Api.GetDocument();\n    var bookmarks = oDocument.GetAllBookmarksNames();\n    var _Asc$scope$bookmark2 = Asc.scope.bookmark,\n      field = _Asc$scope$bookmark2.field,\n      id = _Asc$scope$bookmark2.id;\n    var isBookmarkExist = bookmarks.includes(field);\n    (_Asc$scope$resultCb2 = (_Asc$scope2 = Asc.scope).resultCb) === null || _Asc$scope$resultCb2 === void 0 || _Asc$scope$resultCb2.call(_Asc$scope2, [{\n      data: [isBookmarkExist, field],\n      id: id,\n      type: 'fieldExist'\n    }]);\n  });\n  delete Asc.scope.bookmark;\n  delete Asc.scope.resultCb;\n}\n\n/**\n * 开启强制留痕模式,开启后所有修改痕迹将被记录\n * @param {object} data {\"userName\":\"\",\"trackType\":1开启留痕模式并开始修订\\0关闭留痕模式\\4接受当前所有修订}\n * @param {object} props webOffice\n */\nfunction setTrackingMode(connector, data, props) {}\n\n/**\n * 切换显示痕迹（显示或隐藏修改痕迹）\n * @param {object} data\n * @param {object} props webOffice\n */\nfunction toggleShowTraces(connector, data, props) {}\n\n/**\n * 按用户名称显示、隐藏修改痕迹\n * @param {object} data {userName: '用户名'，isShow:true}\n * @param {object} props webOffice\n */\nfunction showTracesByRole(connector, data, props) {}\n\n/**\n * 在书签位置插入表格（tableData：表格数据，{\"row\":1,\"column\":2,\"value\":\"123123\"}表示第1行第2列的表格值为123123；tableSize：表格规格，{\"row\":3,\"column\":2}}表示表格规格为3行2列）\n * @param {object} data {\"field\":\"书签名称\",\"tableData\":[{\"row\":1,\"column\":2,\"value\":\"123123\"},{\"row\":1,\"column\":1,\"value\":\"123123\"}],\"tableSize\":{\"row\":3,\"column\":2}}\n * @param {object} props webOffice\n */\nfunction setDynamicTable(connector, data, props) {\n  Asc.scope.dynamicTable = data;\n  connector.callCommand(function () {\n    var _Asc$scope$dynamicTab = Asc.scope.dynamicTable,\n      tableSize = _Asc$scope$dynamicTab.tableSize,\n      field = _Asc$scope$dynamicTab.field,\n      tableData = _Asc$scope$dynamicTab.tableData;\n    var row = tableSize.row,\n      column = tableSize.column;\n    var oDocument = Api.GetDocument();\n    var range = oDocument.GetBookmarkRange(field);\n    range === null || range === void 0 || range.Delete();\n    var oTable = Api.CreateTable(column, row);\n    tableData.forEach(function (tableVal) {\n      var value = tableVal.value,\n        row = tableVal.row,\n        column = tableVal.column;\n      var oCell = oTable.GetCell(row, column);\n      oCell.GetContent().GetElement(0).AddText(value);\n    });\n    oDocument.InsertContent([oTable]);\n    oTable.Select();\n    var oRange = oDocument.GetRangeBySelect();\n    oRange.AddBookmark(field);\n  });\n  delete Asc.scope.dynamicTable;\n}\n\n/**\n * 为指定表格新增多行数据，需先将表格设为书签，否则默认是第一个表格\n * @param {object} data {\"field\":'表格所在的书签名', \"newRows\":2, \"newRowsData\":[['123123' , '123123' ], ['123123' , '123123' ]]}\n * @param {object} props webOffice\n */\nfunction addTableRows(connector, data, props) {\n  Asc.scope.rows = data;\n  connector.callCommand(function () {\n    var _Asc$scope$rows = Asc.scope.rows,\n      field = _Asc$scope$rows.field,\n      newRowsData = _Asc$scope$rows.newRowsData,\n      newRows = _Asc$scope$rows.newRows;\n    var oDocument = Api.GetDocument();\n    var oRange = Api.GetBookmarkRange(field);\n    var _oDocument$GetStatist = oDocument.GetStatistics(),\n      PageCount = _oDocument$GetStatist.PageCount;\n    var table;\n    for (var i = 0; i < PageCount; i++) {\n      var tables = oDocument.GetAllTableOnPage(i);\n      table = tables.find(function (table) {\n        table.Select();\n        var tableRange = oDocument.GetRangeBySelect();\n        if (tableRange === oRange) {\n          return true;\n        }\n        return false;\n      });\n      if (table) break;\n    }\n    var tableData = [];\n    for (var _i = 0; _i < newRows; _i++) {\n      for (var j = 0; j < newRowsData[0].length; j++) {\n        tableData.push({\n          row: _i + 1,\n          column: j + 1,\n          value: newRowsData[_i][j]\n        });\n      }\n    }\n    if (table) {\n      table.AddRow();\n    } else {\n      var tableSize = {\n        row: newRows,\n        column: newRowsData[0].length\n      };\n      var row = tableSize.row,\n        column = tableSize.column;\n      var _oDocument = Api.GetDocument();\n      var range = _oDocument.GetBookmarkRange(field);\n      range === null || range === void 0 || range.Delete();\n      var oTable = Api.CreateTable(column, row);\n      tableData.forEach(function (tableVal) {\n        var value = tableVal.value,\n          row = tableVal.row,\n          column = tableVal.column;\n        var oCell = oTable.GetCell(row, column);\n        oCell.GetContent().GetElement(0).AddText(value);\n      });\n      _oDocument.InsertContent([oTable]);\n      oTable.Select();\n      var _oRange = _oDocument.GetRangeBySelect();\n      _oRange.AddBookmark(field);\n    }\n  });\n  delete Asc.scope.rows;\n}\n\n/**\n * 为指定的表格新增多列数据，需先将表格设为书签，否则默认是第一个表格\n * @param {object} data {\"field\":'表格所在的书签名', \"newColumns\":2, \"newRowsData\":[['123123' , '123123' ], ['123123' , '123123' ]]}\n * @param {object} props webOffice\n */\nfunction addTableColumns(connector, data, props) {\n  Asc.scope.rows = data;\n  connector.callCommand(function () {\n    var _Asc$scope$rows2 = Asc.scope.rows,\n      field = _Asc$scope$rows2.field,\n      newRowsData = _Asc$scope$rows2.newRowsData,\n      newRows = _Asc$scope$rows2.newRows;\n    var oDocument = Api.GetDocument();\n    var oRange = Api.GetBookmarkRange(field);\n    var _oDocument$GetStatist2 = oDocument.GetStatistics(),\n      PageCount = _oDocument$GetStatist2.PageCount;\n    var table;\n    for (var i = 0; i < PageCount; i++) {\n      var tables = oDocument.GetAllTableOnPage(i);\n      table = tables.find(function (table) {\n        table.Select();\n        var tableRange = oDocument.GetRangeBySelect();\n        if (tableRange === oRange) {\n          return true;\n        }\n        return false;\n      });\n      if (table) break;\n    }\n    var tableData = [];\n    for (var _i2 = 0; _i2 < newRows; _i2++) {\n      for (var j = 0; j < newRowsData[0].length; j++) {\n        tableData.push({\n          row: _i2 + 1,\n          column: j + 1,\n          value: newRowsData[_i2][j]\n        });\n      }\n    }\n    if (table) {\n      table.AddColumn();\n    } else {\n      var tableSize = {\n        row: newRows,\n        column: newRowsData[0].length\n      };\n      var row = tableSize.row,\n        column = tableSize.column;\n      var _oDocument2 = Api.GetDocument();\n      var range = _oDocument2.GetBookmarkRange(field);\n      range === null || range === void 0 || range.Delete();\n      var oTable = Api.CreateTable(column, row);\n      tableData.forEach(function (tableVal) {\n        var value = tableVal.value,\n          row = tableVal.row,\n          column = tableVal.column;\n        var oCell = oTable.GetCell(row, column);\n        oCell.GetContent().GetElement(0).AddText(value);\n      });\n      _oDocument2.InsertContent([oTable]);\n      oTable.Select();\n      var _oRange2 = _oDocument2.GetRangeBySelect();\n      _oRange2.AddBookmark(field);\n    }\n  });\n  delete Asc.scope.rows;\n}\n\n/**\n * TODO: 可能无法实现\n * 合并文档，即在指定位置插入文档（原文档和合并文档的书签和复选框合并后仍可用）\n * @param {object} data {\"field\":书签名称\",\"mergeType\":0光标位置\\1文档开头\\2文档结尾\\3书签位置,\"docsUrl\":[\"文档的url\"]}\n * @param {object} props webOffice\n */\nfunction mergeDocs(connector, data, props) {}\n\n/**\n * 设置选中区域内容为书签\n * @param {object} data {\"field\":\"书签名称\"}\n * @param {object} props webOffice\n */\nfunction setSelectionAsField(connector, data, props) {\n  Asc.scope.checkbox = data;\n  connector.callCommand(function () {\n    var oDocument = Api.GetDocument();\n    var range = oDocument.GetRangeBySelect();\n    var field = Asc.scope.checkbox.field;\n    range.addMark(field);\n  });\n  delete Asc.scope.checkbox;\n}\n\n/**\n * TODO: 可能无法实现，onlyoffice 中没有获取所有文档内容的接口\n * 设置整个文档内容为书签\n * @param {object} data {\"field\":\"书签名称\"}\n * @param {object} props webOffice\n */\nfunction setDocAsField(connector, data, props) {}\n\n/**\n * 查找所有复选框，并将结果发送给后端\n * @param {object} data {\"fileType\":\"\"}\n * @param {object} props webOffice\n */\nfunction sendAllCheckBox(connector, data, props) {\n  Asc.scope.checkbox = data;\n  Asc.scope.resultCb = props.sendValidResult;\n  connector.callCommand(function () {\n    var _Asc$scope$resultCb3, _Asc$scope3;\n    var oDocument = Api.GetDocument();\n    var forms = oDocument.GetAllForms();\n    var checkbox = [];\n    forms.forEach(function (form) {\n      if (form.GetFormType() === 'checkBoxForm') {\n        checkbox.push({\n          id: form.GetFormKey(),\n          value: form.IsChecked(),\n          title: form.GetText()\n        });\n      }\n    });\n    var id = Asc.scope.checkbox.id;\n    (_Asc$scope$resultCb3 = (_Asc$scope3 = Asc.scope).resultCb) === null || _Asc$scope$resultCb3 === void 0 || _Asc$scope$resultCb3.call(_Asc$scope3, [{\n      data: forms,\n      id: id,\n      type: 'allCheckBox'\n    }]);\n  });\n  delete Asc.scope.checkbox;\n  delete Asc.scope.resultCb;\n}\n\n/**\n * 获取当前文档的打开状态，并将结果发送给后端\n * @param {object} data {\"fileType\":\"\"}\n * @param {object} props webOffice\n */\nfunction sendOpenStatus(connector, data, props) {\n  var _props$sendValidResul;\n  var id = data.id;\n  (_props$sendValidResul = props.sendValidResult) === null || _props$sendValidResul === void 0 || _props$sendValidResul.call(props, [{\n    data: true,\n    id: id,\n    type: 'openStatus'\n  }]);\n}\n\n/**\n * 批量修改复选框的值\n * @param {object} data [{\"id\":复选框id1,\"value\":true\\false},{\"id\":复选框id2,\"value\":true\\false}]\n * @param {object} props webOffice\n */\nfunction setCheckBoxValue(connector, data, props) {\n  Asc.scope.checkbox = data.data;\n  connector.callCommand(function () {\n    var oDocument = Api.GetDocument();\n    var checkBoxForms = oDocument.GetAllForms().filter(function (form) {\n      return form.GetFormType() === 'checkBoxForm';\n    });\n    Asc.scope.checkbox.forEach(function (checkbox) {\n      var checkboxForm = checkBoxForms.find(function (form) {\n        return form.GetFormKey() === checkbox.id;\n      });\n      checkboxForm === null || checkboxForm === void 0 || checkboxForm.SetChecked(checkbox.value);\n    });\n  });\n  delete Asc.scope.checkbox;\n}\n\n/**\n * 设置书签内容为标题1样式\n * @param {object} data {\"field\":\"书签名称\",\"style\":\"标题 1\"}\n * @param {object} props webOffice\n */\nfunction setTextAsTitle(connector, data, props) {\n  Asc.scope.text = data;\n  Asc.scope.getFontSize = function (style) {\n    if (style === '标题 1') return 20;else if (style === '标题 2') return 17;else if (style === '标题 3') return 15;else if (style === '标题 4') return 13;else if (style === '标题 5') return 12;else if (style === '标题 6') return 11;else if (style === '标题 7') return 11;else if (style === '标题 8') return 11;else if (style === '标题 9') return 10.5;else return 11;\n  };\n  connector.callCommand(function () {\n    var _Asc$scope$text = Asc.scope.text,\n      field = _Asc$scope$text.field,\n      style = _Asc$scope$text.style;\n    var oDocument = Api.GetDocument();\n    var allBookmarksNames = oDocument.GetAllBookmarksNames();\n    if (!allBookmarksNames.includes(field)) return;\n    var range = oDocument.GetBookmarkRange(field);\n    var fontSize = Asc.scope.getFontSize(style);\n    range === null || range === void 0 || range.SetFontSize(fontSize);\n  });\n  delete Asc.scope.text;\n  delete Asc.scope.getFontSize;\n}\n\n/**\n * TODO: 可能不需要支持\n * 保存到本地对话框\n * @param {object} data\n * @param {object} props webOffice\n */\nfunction saveAsLocal(connector, data, props) {}\n\n/**\n * 插入图片\n * @param {object} data\n * @param {object} props webOffice\n */\nfunction insertPictures(connector, data, props) {\n  var items = data.data;\n  Asc.scope.pictures = items;\n  connector.callCommand(function () {\n    var pictures = Asc.scope.pictures;\n    var oDocument = Api.GetDocument();\n    pictures.forEach(function (picture) {\n      var field = picture.field,\n        imageUrl = picture.imageUrl;\n      var oParagraph = Api.CreateParagraph();\n      var oPictureForm = Api.CreatePictureForm({\n        key: field,\n        required: true,\n        placeholder: 'Photo',\n        scaleFlag: 'tooBig',\n        lockAspectRatio: true,\n        respectBorders: false,\n        shiftX: 50,\n        shiftY: 50\n      });\n      oParagraph.AddElement(oPictureForm);\n      oPictureForm.SetImage(imageUrl);\n      oDocument.InsertContent([oParagraph], true);\n    });\n  });\n  delete Asc.scope.pictures;\n}\n\n/**\n * TODO: 水印与 weboffice 的会有较大区别\n * 添加文字水印\n * @param {object} data\n * @param {object} props webOffice\n */\nfunction addTextMark(connector, data, props) {\n  Asc.scope.mark = data;\n  connector.callCommand(function () {\n    var text = Asc.scope.mark.text;\n    var oDocument = Api.GetDocument();\n    oDocument.InsertMark(text);\n  });\n  delete Asc.scope.mark;\n}\n\n/**\n * TODO: 无法实现，OnlyOffice 没有删除水印的方法\n * 删除水印\n * @param {object} data\n * @param {object} props webOffice\n */\nfunction delMark(connector, data, props) {}\n\n/**\n * 在光标位置插入文本内容\n * @param {object} data {\"needEnterBefore\":true\\false是否需要在插入文本前添加回车换行}\n * @param {object} props webOffice\n */\nfunction insertValue(connector, data, props) {\n  Asc.scope.value = data;\n  connector.callCommand(function () {\n    var _Asc$scope$value = Asc.scope.value,\n      needEnterBefore = _Asc$scope$value.needEnterBefore,\n      value = _Asc$scope$value.value;\n    var oDocument = Api.GetDocument();\n    var oParagraph = Api.CreateParagraph();\n    var text = needEnterBefore ? '\\r\\n' : '';\n    oParagraph.AddText(\"\".concat(text).concat(value));\n    oDocument.InsertContent([oParagraph], true);\n  });\n  delete Asc.scope.value;\n}\n\n/**\n * 通用指令，用于后端自行传入方法调用 api\n * @param {object} connector onlyoffice 连接器对象\n * @param {object} data 后端发送的数据\n * @param {object} props\n */\nfunction callEditorFunction(connector) {\n  var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var props = arguments.length > 2 ? arguments[2] : undefined;\n  if (data.editorType !== _webOffice.OfficeEditMode.OnlyOffice) return;\n  Asc.scope.customMethods = data.methods;\n  Asc.scope.getResult = props.sendValidResult;\n  connector.callCommand(function () {\n    var result = Api;\n    var methods = Asc.scope.customMethods;\n    var getResult = Asc.scope.getResult;\n    methods.forEach(function (_ref) {\n      var params = _ref.params,\n        func = _ref.func,\n        id = _ref.id;\n      var keys = func.split('.');\n      for (var i = 0; i < keys.length; i++) {\n        var currentKey = keys[i];\n        var isFunction = false;\n        var paramKey = '';\n        if (/(\\w+)\\((\\$\\d+)?\\)/.test(currentKey)) {\n          var matchRes = currentKey.match(/(\\w+)\\((\\$\\d+)?\\)/);\n          currentKey = matchRes[1];\n          paramKey = matchRes[2];\n          isFunction = true;\n        }\n        try {\n          if (isFunction) {\n            var _result;\n            result = paramKey ? (_result = result)[currentKey].apply(_result, _toConsumableArray(params[paramKey])) : result[currentKey]();\n          } else {\n            result = result[currentKey];\n          }\n        } catch (err) {\n          console.log(err);\n          console.error(\"\".concat(currentKey, \"\\u8C03\\u7528\\u51FA\\u9519\"));\n        }\n      }\n      if (id && result) {\n        getResult === null || getResult === void 0 || getResult([{\n          data: {\n            result: result\n          },\n          id: id,\n          type: 'getEditorResult'\n        }]);\n      }\n    });\n  });\n\n  // delete Asc.scope.customMethods\n  // delete Asc.scope.resultCb\n}\n\n//# sourceURL=webpack://bos-platform/./src/component/common/onlyoffice/onlyOfficeDirective.js?");

/***/ })

}]);