From 672a520048208e48bab738ace29170076167c594 Mon Sep 17 00:00:00 2001 From: sunhao Date: Mon, 21 Jul 2025 09:58:34 +0800 Subject: [PATCH] * [misc] support append widget js to docViewer. --- lib/zin/wg/docviewer/js/v1.js | 18 ++++++++++++++++++ lib/zin/wg/docviewer/v1.php | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 lib/zin/wg/docviewer/js/v1.js diff --git a/lib/zin/wg/docviewer/js/v1.js b/lib/zin/wg/docviewer/js/v1.js new file mode 100644 index 0000000000..c4a4a51eb7 --- /dev/null +++ b/lib/zin/wg/docviewer/js/v1.js @@ -0,0 +1,18 @@ +/** + * 处理保存文档的操作请求,向服务器发送请求并返回保存的文档对象。 + * Handle the save doc operation request, send a request to the server and return the saved doc object. + */ +function handleSaveDoc(doc) +{ + /* See lib/zin/wg/docapp/js/v1.js */ +} + +window._setDocViwerOptions = window.setDocAppOptions; +window.setDocAppOptions = function(_, options) +{ + options = window._setDocViwerOptions(_, options); + return $.extend(options, + { + handleSaveDoc: handleSaveDoc + }); +}; diff --git a/lib/zin/wg/docviewer/v1.php b/lib/zin/wg/docviewer/v1.php index a7e89c87c0..623fc70013 100644 --- a/lib/zin/wg/docviewer/v1.php +++ b/lib/zin/wg/docviewer/v1.php @@ -20,7 +20,9 @@ class docViewer extends wg public static function getPageJS(): ?string { - return file_get_contents(dirname(__DIR__) . DS . 'docapp' . DS . 'js' . DS . 'v1.js'); + $docAppJS = file_get_contents(dirname(__DIR__) . DS . 'docapp' . DS . 'js' . DS . 'v1.js'); + $appendJS = file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js'); + return $docAppJS . js::scope($appendJS); } public static function getPageCSS(): ?string