Compare commits
3 Commits
b1540e8374
...
v2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
5f18c0b791
|
|||
|
94b7277b3a
|
|||
|
99251b4748
|
@@ -5,6 +5,7 @@
|
||||
"words": [
|
||||
"blankspace",
|
||||
"docxtemplater",
|
||||
"errback",
|
||||
"Heiti",
|
||||
"Kaku",
|
||||
"kintone",
|
||||
|
||||
147
package-lock.json
generated
147
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "kintone-plugin-docx",
|
||||
"version": "1.0.2",
|
||||
"version": "2.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "kintone-plugin-docx",
|
||||
"version": "1.0.2",
|
||||
"version": "2.0.0",
|
||||
"dependencies": {
|
||||
"@kintone/rest-api-client": "^5.7.5",
|
||||
"angular-expressions": "^1.5.1",
|
||||
@@ -14,11 +14,11 @@
|
||||
"dayjs": "^1.11.18",
|
||||
"docxtemplater": "^3.66.4",
|
||||
"file-saver": "^2.0.5",
|
||||
"i18next": "^25.5.2",
|
||||
"i18next": "^25.5.3",
|
||||
"moize": "^6.1.6",
|
||||
"pizzip": "^3.2.0",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-error-boundary": "^6.0.0",
|
||||
"react-i18next": "^16.0.0",
|
||||
"tiny-invariant": "^1.3.3"
|
||||
@@ -31,9 +31,9 @@
|
||||
"@rspack/cli": "^1.5.8",
|
||||
"@rspack/core": "^1.5.8",
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/node": "^24.6.0",
|
||||
"@types/react": "^19.1.16",
|
||||
"@types/react-dom": "^19.1.9",
|
||||
"@types/node": "^24.6.2",
|
||||
"@types/react": "^19.2.0",
|
||||
"@types/react-dom": "^19.2.0",
|
||||
"cross-env": "^10.1.0",
|
||||
"cspell": "^9.2.1",
|
||||
"env-cmd": "^11.0.0",
|
||||
@@ -41,7 +41,7 @@
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^3.6.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.2"
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
@@ -1322,9 +1322,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@inquirer/core/node_modules/@types/node": {
|
||||
"version": "22.18.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.7.tgz",
|
||||
"integrity": "sha512-3E97nlWEVp2V6J7aMkR8eOnw/w0pArPwf/5/W0865f+xzBoGL/ZuHkTAKAGN7cOWNwd+sG+hZOqj+fjzeHS75g==",
|
||||
"version": "22.18.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.8.tgz",
|
||||
"integrity": "sha512-pAZSHMiagDR7cARo/cch1f3rXy0AEXwsVsVH09FcyeJVAzCnGgmYis7P3JidtTUjyadhTeSo8TgRPswstghDaw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2428,9 +2428,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.6.0.tgz",
|
||||
"integrity": "sha512-F1CBxgqwOMc4GKJ7eY22hWhBVQuMYTtqI8L0FcszYcpYX0fzfDGpez22Xau8Mgm7O9fI+zA/TYIdq3tGWfweBA==",
|
||||
"version": "24.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.6.2.tgz",
|
||||
"integrity": "sha512-d2L25Y4j+W3ZlNAeMKcy7yDsK425ibcAOO2t7aPTz6gNMH0z2GThtwENCDc0d/Pw9wgyRqE5Px1wkV7naz8ang==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2469,9 +2469,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/react": {
|
||||
"version": "19.1.16",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.16.tgz",
|
||||
"integrity": "sha512-WBM/nDbEZmDUORKnh5i1bTnAz6vTohUf9b8esSMu+b24+srbaxa04UbJgWx78CVfNXA20sNu0odEIluZDFdCog==",
|
||||
"version": "19.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.0.tgz",
|
||||
"integrity": "sha512-1LOH8xovvsKsCBq1wnT4ntDUdCJKmnEakhsuoUSy6ExlHCkGP2hqnatagYTgFk6oeL0VU31u7SNjunPN+GchtA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2479,13 +2479,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/react-dom": {
|
||||
"version": "19.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.1.9.tgz",
|
||||
"integrity": "sha512-qXRuZaOsAdXKFyOhRBg6Lqqc0yay13vN7KrIg4L7N4aaHN68ma9OK3NE1BoDFgFOTfM7zg+3/8+2n8rLUH3OKQ==",
|
||||
"version": "19.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.0.tgz",
|
||||
"integrity": "sha512-brtBs0MnE9SMx7px208g39lRmC5uHZs96caOJfTjFcYSLHNamvaSMfJNagChVNkup2SdtOxKX1FDBkRSJe1ZAg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@types/react": "^19.0.0"
|
||||
"@types/react": "^19.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/retry": {
|
||||
@@ -3698,15 +3698,7 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz",
|
||||
"integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/async-generator-function": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/async-generator-function/-/async-generator-function-1.0.0.tgz",
|
||||
"integrity": "sha512-+NAXNqgCrB95ya4Sr66i1CL2hqLVckAk7xwRYWdcm39/ELQ6YNn1aw5r0bdQtqNZgQpEWzc5yc/igXc7aL5SLA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -3898,9 +3890,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/baseline-browser-mapping": {
|
||||
"version": "2.8.9",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.9.tgz",
|
||||
"integrity": "sha512-hY/u2lxLrbecMEWSB0IpGzGyDyeoMFQhCvZd2jGFSE5I17Fh01sYUBPCJtkWERw7zrac9+cIghxm/ytJa2X8iA==",
|
||||
"version": "2.8.10",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.10.tgz",
|
||||
"integrity": "sha512-uLfgBi+7IBNay8ECBO2mVMGZAc1VgZWEChxm4lv+TobGdG82LnXMjuNGo/BSSZZL4UmkWhxEHP2f5ziLNwGWMA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
@@ -4031,9 +4023,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/browserslist": {
|
||||
"version": "4.26.2",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.26.2.tgz",
|
||||
"integrity": "sha512-ECFzp6uFOSB+dcZ5BK/IBaGWssbSYBHvuMeMt3MMFyhI0Z8SqGgEkBLARgpRH3hutIgPVsALcMwbDrJqPxQ65A==",
|
||||
"version": "4.26.3",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.26.3.tgz",
|
||||
"integrity": "sha512-lAUU+02RFBuCKQPj/P6NgjlbCnLBMp4UtgTx7vNHd3XSIJF87s9a5rA3aH2yw3GS9DqZAUbOtZdCCiZeVRqt0w==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -4052,9 +4044,9 @@
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"baseline-browser-mapping": "^2.8.3",
|
||||
"caniuse-lite": "^1.0.30001741",
|
||||
"electron-to-chromium": "^1.5.218",
|
||||
"baseline-browser-mapping": "^2.8.9",
|
||||
"caniuse-lite": "^1.0.30001746",
|
||||
"electron-to-chromium": "^1.5.227",
|
||||
"node-releases": "^2.0.21",
|
||||
"update-browserslist-db": "^1.1.3"
|
||||
},
|
||||
@@ -5283,9 +5275,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.5.227",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.227.tgz",
|
||||
"integrity": "sha512-ITxuoPfJu3lsNWUi2lBM2PaBPYgH3uqmxut5vmBxgYvyI4AlJ6P3Cai1O76mOrkJCBzq0IxWg/NtqOrpu/0gKA==",
|
||||
"version": "1.5.228",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.228.tgz",
|
||||
"integrity": "sha512-nxkiyuqAn4MJ1QbobwqJILiDtu/jk14hEAWaMiJmNPh1Z+jqoFlBFZjdXwLWGeVSeu9hGLg6+2G9yJaW8rBIFA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"peer": true
|
||||
@@ -6764,9 +6756,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/generator-function": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.0.tgz",
|
||||
"integrity": "sha512-xPypGGincdfyl/AiSGa7GjXLkvld9V7GjZlowup9SHIJnQnHLFiLODCd/DqKOp0PBagbHJ68r1KJI9Mut7m4sA==",
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz",
|
||||
"integrity": "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -6793,19 +6786,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.1.tgz",
|
||||
"integrity": "sha512-fk1ZVEeOX9hVZ6QzoBNEC55+Ucqg4sTVwrVuigZhuRPESVFpMyXnd3sbXvPOwp7Y9riVyANiqhEuRF0G1aVSeQ==",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"async-function": "^1.0.0",
|
||||
"async-generator-function": "^1.0.0",
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"generator-function": "^2.0.0",
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
@@ -7337,9 +7327,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/i18next": {
|
||||
"version": "25.5.2",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-25.5.2.tgz",
|
||||
"integrity": "sha512-lW8Zeh37i/o0zVr+NoCHfNnfvVw+M6FQbRp36ZZ/NyHDJ3NJVpp2HhAUyU9WafL5AssymNoOjMRB48mmx2P6Hw==",
|
||||
"version": "25.5.3",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-25.5.3.tgz",
|
||||
"integrity": "sha512-joFqorDeQ6YpIXni944upwnuHBf5IoPMuqAchGVeQLdWC2JOjxgM9V8UGLhNIIH/Q8QleRxIi0BSRQehSrDLcg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
@@ -7755,14 +7745,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/is-generator-function": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.0.tgz",
|
||||
"integrity": "sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ==",
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz",
|
||||
"integrity": "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.3",
|
||||
"get-proto": "^1.0.0",
|
||||
"call-bound": "^1.0.4",
|
||||
"generator-function": "^2.0.0",
|
||||
"get-proto": "^1.0.1",
|
||||
"has-tostringtag": "^1.0.2",
|
||||
"safe-regex-test": "^1.1.0"
|
||||
},
|
||||
@@ -8457,9 +8448,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/memfs": {
|
||||
"version": "4.47.0",
|
||||
"resolved": "https://registry.npmjs.org/memfs/-/memfs-4.47.0.tgz",
|
||||
"integrity": "sha512-Xey8IZA57tfotV/TN4d6BmccQuhFP+CqRiI7TTNdipZdZBzF2WnzUcH//Cudw6X4zJiUbo/LTuU/HPA/iC/pNg==",
|
||||
"version": "4.48.1",
|
||||
"resolved": "https://registry.npmjs.org/memfs/-/memfs-4.48.1.tgz",
|
||||
"integrity": "sha512-vWO+1ROkhOALF1UnT9aNOOflq5oFDlqwTXaPg6duo07fBLxSH0+bcF0TY1lbA1zTNKyGgDxgaDdKx5MaewLX5A==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -9785,7 +9776,7 @@
|
||||
"version": "23.11.1",
|
||||
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.11.1.tgz",
|
||||
"integrity": "sha512-53uIX3KR5en8l7Vd8n5DUv90Ae9QDQsyIthaUFVzwV6yU750RjqRznEtNMBT20VthqAdemnJN+hxVdmMHKt7Zw==",
|
||||
"deprecated": "< 24.10.2 is no longer supported",
|
||||
"deprecated": "< 24.15.0 is no longer supported",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
@@ -9906,24 +9897,24 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "19.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz",
|
||||
"integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==",
|
||||
"version": "19.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz",
|
||||
"integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-dom": {
|
||||
"version": "19.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.1.tgz",
|
||||
"integrity": "sha512-Dlq/5LAZgF0Gaz6yiqZCf6VCcZs1ghAJyrsu84Q/GT0gV+mCxbfmKNoGRKBYMJ8IEdGPqu49YWXD02GCknEDkw==",
|
||||
"version": "19.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.0.tgz",
|
||||
"integrity": "sha512-UlbRu4cAiGaIewkPyiRGJk0imDN2T3JjieT6spoL2UeSf5od4n5LB/mQ4ejmxhCFT1tYe8IvaFulzynWovsEFQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"scheduler": "^0.26.0"
|
||||
"scheduler": "^0.27.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^19.1.1"
|
||||
"react": "^19.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-error-boundary": {
|
||||
@@ -10491,9 +10482,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/scheduler": {
|
||||
"version": "0.26.0",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz",
|
||||
"integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==",
|
||||
"version": "0.27.0",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
|
||||
"integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/schema-utils": {
|
||||
@@ -11936,9 +11927,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
|
||||
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"devOptional": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
|
||||
16
package.json
16
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "kintone-plugin-docx",
|
||||
"version": "1.0.2",
|
||||
"version": "2.0.0",
|
||||
"scripts": {
|
||||
"gen": "run-s gen:*",
|
||||
"gen:key": "node scripts/generate-private-key.js",
|
||||
@@ -22,11 +22,11 @@
|
||||
"dayjs": "^1.11.18",
|
||||
"docxtemplater": "^3.66.4",
|
||||
"file-saver": "^2.0.5",
|
||||
"i18next": "^25.5.2",
|
||||
"i18next": "^25.5.3",
|
||||
"moize": "^6.1.6",
|
||||
"pizzip": "^3.2.0",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-error-boundary": "^6.0.0",
|
||||
"react-i18next": "^16.0.0",
|
||||
"tiny-invariant": "^1.3.3"
|
||||
@@ -39,9 +39,9 @@
|
||||
"@rspack/cli": "^1.5.8",
|
||||
"@rspack/core": "^1.5.8",
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/node": "^24.6.0",
|
||||
"@types/react": "^19.1.16",
|
||||
"@types/react-dom": "^19.1.9",
|
||||
"@types/node": "^24.6.2",
|
||||
"@types/react": "^19.2.0",
|
||||
"@types/react-dom": "^19.2.0",
|
||||
"cross-env": "^10.1.0",
|
||||
"cspell": "^9.2.1",
|
||||
"env-cmd": "^11.0.0",
|
||||
@@ -49,6 +49,6 @@
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^3.6.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.2"
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/kintone/js-sdk/%40kintone/plugin-manifest-validator%4010.2.0/packages/plugin-manifest-validator/manifest-schema.json",
|
||||
"manifest_version": 1,
|
||||
"version": "1.0.2",
|
||||
"version": "2.0.0",
|
||||
"type": "APP",
|
||||
"desktop": {
|
||||
"js": ["js/desktop.js"],
|
||||
@@ -15,8 +15,7 @@
|
||||
"config": {
|
||||
"html": "html/config.html",
|
||||
"js": ["js/config.js"],
|
||||
"css": ["js/config.css"],
|
||||
"required_params": ["template"]
|
||||
"css": ["js/config.css"]
|
||||
},
|
||||
"name": {
|
||||
"en": "Word output plugin",
|
||||
|
||||
@@ -8,11 +8,6 @@ interface Props {
|
||||
|
||||
const ErrorFallback: React.FC<Props> = (props) => {
|
||||
const { error } = props;
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
<p>Something went wrong:</p>
|
||||
<pre>{error.message}</pre>
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
return <KintonePluginAlert>{error.message}</KintonePluginAlert>;
|
||||
};
|
||||
export default ErrorFallback;
|
||||
|
||||
41
src/common/config.ts
Normal file
41
src/common/config.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
export const PluginConfigDataSource = {
|
||||
SELF: 'self',
|
||||
APP: 'app',
|
||||
} as const;
|
||||
export type PluginConfigDataSource = (typeof PluginConfigDataSource)[keyof typeof PluginConfigDataSource];
|
||||
|
||||
export interface PluginConfigSelf {
|
||||
dataSource: typeof PluginConfigDataSource.SELF;
|
||||
fieldCode: string;
|
||||
}
|
||||
export interface PluginConfigApp {
|
||||
dataSource: typeof PluginConfigDataSource.APP;
|
||||
appId: string;
|
||||
recordId: string;
|
||||
fieldCode: string;
|
||||
}
|
||||
|
||||
export type PluginConfig = PluginConfigSelf | PluginConfigApp;
|
||||
|
||||
const DEFAULT_CONFIG: PluginConfig = {
|
||||
dataSource: PluginConfigDataSource.SELF,
|
||||
fieldCode: '',
|
||||
} as const;
|
||||
|
||||
export const saveConfig = (config: PluginConfig, callback?: () => void): void => {
|
||||
kintone.plugin.app.setConfig(config, callback);
|
||||
};
|
||||
|
||||
export const loadConfig = (pluginId: string): PluginConfig => {
|
||||
const config = kintone.plugin.app.getConfig(pluginId);
|
||||
if (!config || Object.keys(config).length === 0) {
|
||||
// initial state
|
||||
return { ...DEFAULT_CONFIG };
|
||||
}
|
||||
if (config.dataSource != null) {
|
||||
// current version of config format
|
||||
return config as PluginConfig;
|
||||
}
|
||||
// old version of config format
|
||||
return { dataSource: PluginConfigDataSource.SELF, fieldCode: config.template || '' };
|
||||
};
|
||||
46
src/common/ui/KintonePluginInputText.tsx
Normal file
46
src/common/ui/KintonePluginInputText.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import clsx from 'clsx';
|
||||
// biome-ignore lint/style/useImportType: React is required in scope for the old JSX transform.
|
||||
import React from 'react';
|
||||
|
||||
export type KintonePluginInputTextProps = {
|
||||
id?: string;
|
||||
className?: string;
|
||||
value: string;
|
||||
size?: number;
|
||||
maxLength?: number;
|
||||
disabled?: boolean;
|
||||
required?: boolean;
|
||||
placeholder?: string;
|
||||
onChange: (value: string) => void;
|
||||
};
|
||||
|
||||
const KintonePluginInputText: React.FC<KintonePluginInputTextProps> = (props) => {
|
||||
const { id, className, value, size, maxLength, disabled, required, placeholder, onChange } = props;
|
||||
const handleOnChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||
onChange(e.target.value);
|
||||
};
|
||||
return (
|
||||
<div className={clsx('kintoneplugin-input-outer', className)}>
|
||||
<input
|
||||
id={id}
|
||||
className="kintoneplugin-input-text"
|
||||
type="text"
|
||||
value={value}
|
||||
size={size}
|
||||
maxLength={maxLength}
|
||||
disabled={disabled}
|
||||
required={required}
|
||||
placeholder={placeholder}
|
||||
aria-required={required}
|
||||
aria-disabled={disabled}
|
||||
aria-invalid={required && value === ''}
|
||||
autoComplete="off"
|
||||
autoCorrect="off"
|
||||
autoCapitalize="off"
|
||||
spellCheck={false}
|
||||
onChange={handleOnChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default KintonePluginInputText;
|
||||
@@ -1,19 +1,34 @@
|
||||
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
import moize from 'moize';
|
||||
import React from 'react';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import invariant from 'tiny-invariant';
|
||||
import ErrorFallback from '../common/ErrorFallback';
|
||||
import Loading from '../common/Loading';
|
||||
import type { KintoneFormFieldProperties } from '../common/types';
|
||||
import Settings from './Settings';
|
||||
|
||||
interface ConfigAppProps {
|
||||
pluginId: string;
|
||||
}
|
||||
|
||||
const cachedFormFieldsProperties = moize.promise(async (appId: number): Promise<KintoneFormFieldProperties> => {
|
||||
const client = new KintoneRestAPIClient();
|
||||
const { properties } = await client.app.getFormFields({ app: appId, preview: true });
|
||||
return properties;
|
||||
});
|
||||
|
||||
const ConfigApp: React.FC<ConfigAppProps> = (props) => {
|
||||
const { pluginId } = props;
|
||||
|
||||
const appId = kintone.app.getId();
|
||||
invariant(appId, 'The app ID is not available. Please ensure you are on a Kintone app page.');
|
||||
const propertiesPromise = cachedFormFieldsProperties(appId);
|
||||
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
||||
<React.Suspense fallback={<Loading />}>
|
||||
<Settings pluginId={pluginId} />
|
||||
<Settings pluginId={pluginId} appId={appId} propertiesPromise={propertiesPromise} />
|
||||
</React.Suspense>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
.settings .app {
|
||||
display: flex;
|
||||
gap: 2em;
|
||||
align-items: center;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.buttons > *:not(:last-child) {
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
import moize from 'moize';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import invariant from 'tiny-invariant';
|
||||
import type { PluginConfig } from '../common/config';
|
||||
import { loadConfig, PluginConfigDataSource, saveConfig } from '../common/config';
|
||||
import { naturalCompare } from '../common/stringUtils';
|
||||
import type { KintoneFormFieldProperties } from '../common/types';
|
||||
import KintonePluginAlert from '../common/ui/KintonePluginAlert';
|
||||
import KintonePluginButton from '../common/ui/KintonePluginButton';
|
||||
import KintonePluginDesc from '../common/ui/KintonePluginDesc';
|
||||
import KintonePluginInputText from '../common/ui/KintonePluginInputText';
|
||||
import KintonePluginLabel from '../common/ui/KintonePluginLabel';
|
||||
import KintonePluginRequire from '../common/ui/KintonePluginRequire';
|
||||
import KintonePluginRow from '../common/ui/KintonePluginRow';
|
||||
@@ -16,70 +16,161 @@ import KintonePluginTitle from '../common/ui/KintonePluginTitle';
|
||||
|
||||
import styles from './Settings.module.css';
|
||||
|
||||
const cachedFormFieldsProperties = moize.promise(async (appId: number): Promise<KintoneFormFieldProperties> => {
|
||||
const client = new KintoneRestAPIClient();
|
||||
const { properties } = await client.app.getFormFields({ app: appId, preview: true });
|
||||
return properties;
|
||||
});
|
||||
|
||||
interface SettingsProps {
|
||||
pluginId: string;
|
||||
appId: number;
|
||||
propertiesPromise: Promise<KintoneFormFieldProperties>;
|
||||
}
|
||||
|
||||
const Settings: React.FC<SettingsProps> = (props) => {
|
||||
const { pluginId } = props;
|
||||
const { pluginId, appId, propertiesPromise } = props;
|
||||
const { t } = useTranslation();
|
||||
const config = kintone.plugin.app.getConfig(pluginId);
|
||||
const appId = kintone.app.getId();
|
||||
invariant(appId, 'The app ID is not available. Please ensure you are on a Kintone app page.');
|
||||
const properties = React.use(cachedFormFieldsProperties(appId));
|
||||
const config = loadConfig(pluginId);
|
||||
const properties = React.use(propertiesPromise);
|
||||
// data source options
|
||||
const dataSourceOptions = [
|
||||
{ value: PluginConfigDataSource.SELF, label: t('settings.datasource.labels.self') },
|
||||
{ value: PluginConfigDataSource.APP, label: t('settings.datasource.labels.app') },
|
||||
];
|
||||
const [dataSource, setDataSource] = React.useState<
|
||||
(typeof PluginConfigDataSource)[keyof typeof PluginConfigDataSource]
|
||||
>(config.dataSource);
|
||||
|
||||
// states for SELF data source
|
||||
const fileFields = Object.values(properties)
|
||||
.filter((property) => property.type === 'FILE')
|
||||
.sort((a, b) => naturalCompare(`${a.label} (${a.code})`, `${b.label} (${b.code})`));
|
||||
const options: KintonePluginSelectOptionData[] = [
|
||||
{ value: '', label: t('settings.template.messages.select-an-attachment-fields'), disabled: true }, // Default option
|
||||
{ value: '', label: t('settings.self.messages.select-an-attachment-fields'), disabled: true }, // Default option
|
||||
...fileFields.map((property) => ({
|
||||
value: property.code,
|
||||
label: `${property.label} (${property.code})`,
|
||||
})),
|
||||
];
|
||||
const [fieldCode, setFieldCode] = React.useState<string>(
|
||||
() =>
|
||||
options.find((option) => config.dataSource === PluginConfigDataSource.SELF && option.value === config.fieldCode)
|
||||
?.value ?? '',
|
||||
);
|
||||
|
||||
const [template, setTemplate] = React.useState<string>(
|
||||
() => options.find((option) => option.value === (config.template ?? ''))?.value ?? '',
|
||||
// states for APP data source
|
||||
const [otherAppId, setOtherAppId] = React.useState<string>(
|
||||
config.dataSource === PluginConfigDataSource.APP ? config.appId : '',
|
||||
);
|
||||
const [otherRecordId, setOtherRecordId] = React.useState<string>(
|
||||
config.dataSource === PluginConfigDataSource.APP ? config.recordId : '',
|
||||
);
|
||||
const [otherFieldCode, setOtherFieldCode] = React.useState<string>(
|
||||
config.dataSource === PluginConfigDataSource.APP ? config.fieldCode : '',
|
||||
);
|
||||
|
||||
const handleOnSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
kintone.plugin.app.setConfig({ template }, () => {
|
||||
let configToSave: PluginConfig;
|
||||
if (dataSource === PluginConfigDataSource.SELF) {
|
||||
configToSave = { dataSource: PluginConfigDataSource.SELF, fieldCode };
|
||||
} else if (dataSource === PluginConfigDataSource.APP) {
|
||||
configToSave = {
|
||||
dataSource: PluginConfigDataSource.APP,
|
||||
appId: otherAppId,
|
||||
fieldCode: otherFieldCode,
|
||||
recordId: otherRecordId,
|
||||
};
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
saveConfig(configToSave, () => {
|
||||
alert(t('on-saved'));
|
||||
window.location.href = `../../flow?app=${appId}`;
|
||||
});
|
||||
};
|
||||
|
||||
const handleOnChangeTemplate = (value: string) => {
|
||||
setTemplate(value);
|
||||
};
|
||||
|
||||
const handleOnClickCancel = () => {
|
||||
window.location.href = `../../${appId}/plugin/`;
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="settings">
|
||||
<div className={styles.settings}>
|
||||
<KintonePluginLabel>{t('title')}</KintonePluginLabel>
|
||||
<form onSubmit={handleOnSubmit}>
|
||||
<KintonePluginRow>
|
||||
<KintonePluginTitle>
|
||||
{t('settings.template.title')}
|
||||
{t('settings.datasource.title')}
|
||||
<KintonePluginRequire>*</KintonePluginRequire>
|
||||
</KintonePluginTitle>
|
||||
<KintonePluginDesc> {t('settings.template.description')}</KintonePluginDesc>
|
||||
{fileFields.length === 0 ? (
|
||||
<KintonePluginAlert>{t('settings.template.errors.no-attachment-field-found')}</KintonePluginAlert>
|
||||
) : (
|
||||
<KintonePluginSelect value={template} onChange={handleOnChangeTemplate} options={options} />
|
||||
)}
|
||||
<KintonePluginDesc>{t('settings.datasource.description')}</KintonePluginDesc>
|
||||
<KintonePluginSelect
|
||||
value={String(dataSource)}
|
||||
onChange={(value) => {
|
||||
const newDataSource = value as PluginConfigDataSource;
|
||||
if (Object.values(PluginConfigDataSource).includes(newDataSource)) {
|
||||
setDataSource(newDataSource);
|
||||
}
|
||||
}}
|
||||
options={dataSourceOptions.map((opt) => ({ value: String(opt.value), label: opt.label }))}
|
||||
/>
|
||||
</KintonePluginRow>
|
||||
{dataSource === PluginConfigDataSource.SELF && (
|
||||
<KintonePluginRow>
|
||||
<KintonePluginTitle>
|
||||
{t('settings.self.title')}
|
||||
<KintonePluginRequire>*</KintonePluginRequire>
|
||||
</KintonePluginTitle>
|
||||
<KintonePluginDesc>{t('settings.self.description')}</KintonePluginDesc>
|
||||
{fileFields.length === 0 ? (
|
||||
<KintonePluginAlert>{t('settings.self.errors.no-attachment-field-found')}</KintonePluginAlert>
|
||||
) : (
|
||||
<KintonePluginSelect value={fieldCode} onChange={(value) => setFieldCode(value)} options={options} />
|
||||
)}
|
||||
</KintonePluginRow>
|
||||
)}
|
||||
{dataSource === PluginConfigDataSource.APP && (
|
||||
<KintonePluginRow>
|
||||
<KintonePluginTitle>
|
||||
{t('settings.app.title')}
|
||||
<KintonePluginRequire>*</KintonePluginRequire>
|
||||
</KintonePluginTitle>
|
||||
<KintonePluginDesc>{t('settings.app.description')}</KintonePluginDesc>
|
||||
<div className={styles.app}>
|
||||
<label htmlFor="otherAppIdInput">
|
||||
{t('settings.app.labels.app-id')} <KintonePluginRequire>*</KintonePluginRequire>
|
||||
<br />
|
||||
<KintonePluginInputText
|
||||
id="otherAppIdInput"
|
||||
value={otherAppId}
|
||||
required
|
||||
onChange={(value) => {
|
||||
setOtherAppId(value);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<label htmlFor="otherRecordIdInput">
|
||||
{t('settings.app.labels.record-id')} <KintonePluginRequire>*</KintonePluginRequire>
|
||||
<br />
|
||||
<KintonePluginInputText
|
||||
id="otherRecordIdInput"
|
||||
value={otherRecordId}
|
||||
required
|
||||
onChange={(value) => {
|
||||
setOtherRecordId(value);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<label htmlFor="otherFieldCodeInput">
|
||||
{t('settings.app.labels.field-code')} <KintonePluginRequire>*</KintonePluginRequire>
|
||||
<br />
|
||||
<KintonePluginInputText
|
||||
id="otherFieldCodeInput"
|
||||
value={otherFieldCode}
|
||||
required
|
||||
onChange={(value) => {
|
||||
setOtherFieldCode(value);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</KintonePluginRow>
|
||||
)}
|
||||
<KintonePluginRow className={styles.buttons}>
|
||||
<KintonePluginButton variant="dialog-cancel" type="button" onClick={handleOnClickCancel}>
|
||||
{t('buttons.cancel')}
|
||||
@@ -89,7 +180,7 @@ const Settings: React.FC<SettingsProps> = (props) => {
|
||||
</KintonePluginButton>
|
||||
</KintonePluginRow>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default Settings;
|
||||
|
||||
@@ -1,15 +1,32 @@
|
||||
{
|
||||
"title": "Settings for the Kintone Word output plugin",
|
||||
"settings": {
|
||||
"template": {
|
||||
"datasource": {
|
||||
"title": "Select data source for Word template file",
|
||||
"description": "Please select the data source for the Word template file.",
|
||||
"labels": {
|
||||
"self": "Own record",
|
||||
"app": "Record from another app"
|
||||
}
|
||||
},
|
||||
"self": {
|
||||
"title": "Template",
|
||||
"description": "Select a attachment field that contains the Word template file.",
|
||||
"description": "Select an attachment field that contains the Word template file.",
|
||||
"messages": {
|
||||
"select-an-attachment-fields": "(Select an attachment field)"
|
||||
},
|
||||
"errors": {
|
||||
"no-attachment-field-found": "No attachment fields found in the app. Please add an attachment field to use this plugin."
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"title": "Attachment file info from another app",
|
||||
"description": "Enter App ID, Record ID, and Attachment Field Code.",
|
||||
"labels": {
|
||||
"app-id": "App ID",
|
||||
"record-id": "Record ID",
|
||||
"field-code": "Attachment Field Code"
|
||||
}
|
||||
}
|
||||
},
|
||||
"buttons": {
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
{
|
||||
"title": "Word出力プラグイン設定",
|
||||
"settings": {
|
||||
"template": {
|
||||
"datasource": {
|
||||
"title": "WORD雛形ファイルのデータソース選択",
|
||||
"description": "WORD雛形ファイルのデータソースを選択してください。",
|
||||
"labels": {
|
||||
"self": "自レコード",
|
||||
"app": "他アプリのレコード"
|
||||
}
|
||||
},
|
||||
"self": {
|
||||
"title": "雛形ファイル",
|
||||
"description": "Word雛形ファイルを保存する添付ファイルフィールドを選択してください。",
|
||||
"messages": {
|
||||
@@ -10,6 +18,15 @@
|
||||
"errors": {
|
||||
"no-attachment-field-found": "このアプリに添付ファイルフィールドが見つかりません。フォームに添付ファイルフィールドを追加してください。"
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"title": "他アプリの添付ファイル情報",
|
||||
"description": "アプリID・レコード番号・添付ファイルフィールドコードを入力してください。",
|
||||
"labels": {
|
||||
"app-id": "アプリID",
|
||||
"record-id": "レコード番号",
|
||||
"field-code": "添付ファイルフィールドコード"
|
||||
}
|
||||
}
|
||||
},
|
||||
"buttons": {
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
import moize from 'moize';
|
||||
import React from 'react';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import { loadConfig, type PluginConfig } from '../common/config';
|
||||
import ErrorFallback from '../common/ErrorFallback';
|
||||
import Loading from '../common/Loading';
|
||||
import type { KintoneFormFieldProperties } from '../common/types';
|
||||
import { checkConfig } from './checkConfig';
|
||||
import MenuPanel from './MenuPanel';
|
||||
|
||||
interface DesktopAppProps {
|
||||
@@ -9,12 +14,34 @@ interface DesktopAppProps {
|
||||
event: kintone.events.AppRecordDetailShowEvent | kintone.events.MobileAppRecordDetailShowEvent;
|
||||
}
|
||||
|
||||
const cachedFormFieldsProperties = moize.promise(async (appId: number): Promise<KintoneFormFieldProperties> => {
|
||||
const client = new KintoneRestAPIClient();
|
||||
const { properties } = await client.app.getFormFields({ app: appId, preview: false });
|
||||
return properties;
|
||||
});
|
||||
|
||||
const cachedConfigCheck = moize.promise(
|
||||
async (config: PluginConfig, record: kintone.types.SavedFields): Promise<string> => {
|
||||
return await checkConfig(config, record);
|
||||
},
|
||||
);
|
||||
|
||||
const DesktopApp: React.FC<DesktopAppProps> = (props) => {
|
||||
const { pluginId, event } = props;
|
||||
|
||||
const config = loadConfig(pluginId);
|
||||
const propertiesPromise = cachedFormFieldsProperties(event.appId);
|
||||
const fileKeyPromise = cachedConfigCheck(config, event.record);
|
||||
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
||||
<React.Suspense fallback={<Loading />}>
|
||||
<MenuPanel pluginId={pluginId} event={event} />
|
||||
<MenuPanel
|
||||
pluginId={pluginId}
|
||||
event={event}
|
||||
propertiesPromise={propertiesPromise}
|
||||
fileKeyPromise={fileKeyPromise}
|
||||
/>
|
||||
</React.Suspense>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
||||
@@ -1,78 +1,24 @@
|
||||
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
import saveAs from 'file-saver';
|
||||
import moize from 'moize';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { DOCX_CONTENT_TYPE } from '../common/constants';
|
||||
import type { KintoneFormFieldProperties } from '../common/types';
|
||||
import KintonePluginAlert from '../common/ui/KintonePluginAlert';
|
||||
import KintonePluginButton from '../common/ui/KintonePluginButton';
|
||||
import generateWordFileData from './generateWordFileData';
|
||||
|
||||
export interface MenuPanelProps {
|
||||
pluginId: string;
|
||||
event: kintone.events.AppRecordDetailShowEvent | kintone.events.MobileAppRecordDetailShowEvent;
|
||||
propertiesPromise: Promise<KintoneFormFieldProperties>;
|
||||
fileKeyPromise: Promise<string>;
|
||||
}
|
||||
|
||||
const cachedFormFieldsProperties = moize.promise(async (appId: number): Promise<KintoneFormFieldProperties> => {
|
||||
const client = new KintoneRestAPIClient();
|
||||
const { properties } = await client.app.getFormFields({ app: appId, preview: false });
|
||||
return properties;
|
||||
});
|
||||
|
||||
const MenuPanel: React.FC<MenuPanelProps> = (props) => {
|
||||
const { pluginId, event } = props;
|
||||
const { event, propertiesPromise, fileKeyPromise } = props;
|
||||
const { t } = useTranslation();
|
||||
const appId = event.appId;
|
||||
const properties = React.use(cachedFormFieldsProperties(appId));
|
||||
const language = kintone.getLoginUser().language;
|
||||
const config = kintone.plugin.app.getConfig(pluginId);
|
||||
const template: string = config.template ?? '';
|
||||
|
||||
if (template === '') {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-field-is-not-set')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
const record = event.record[template];
|
||||
if (record == null) {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-field-is-not-available')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
if (record.type !== 'FILE') {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-field-must-be-an-attachment-field')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
if (record.value.length === 0) {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-field-does-not-contain-any-files')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
if (record.value.length > 1) {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-field-contains-multiple-files')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
const { fileKey, contentType } = record.value[0];
|
||||
if (contentType !== DOCX_CONTENT_TYPE) {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-file-must-be-a-docx', { contentType })}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
const properties = React.use(propertiesPromise);
|
||||
const fileKey = React.use(fileKeyPromise);
|
||||
|
||||
const handleOnClickOutputButton = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
78
src/desktop/checkConfig.ts
Normal file
78
src/desktop/checkConfig.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
import i18n from 'i18next';
|
||||
import {
|
||||
type PluginConfig,
|
||||
type PluginConfigApp,
|
||||
PluginConfigDataSource,
|
||||
type PluginConfigSelf,
|
||||
} from '../common/config';
|
||||
import { DOCX_CONTENT_TYPE } from '../common/constants';
|
||||
|
||||
const checkConfigSelf = (config: PluginConfigSelf, record: kintone.types.SavedFields): string => {
|
||||
const { fieldCode } = config;
|
||||
if (fieldCode === '') {
|
||||
throw new Error(i18n.t('errors.template-field-is-required'));
|
||||
}
|
||||
const field = record[fieldCode];
|
||||
if (!field) {
|
||||
throw new Error(i18n.t('errors.template-field-is-not-available'));
|
||||
}
|
||||
if (field.type !== 'FILE') {
|
||||
throw new Error(i18n.t('errors.template-field-must-be-an-attachment-field'));
|
||||
}
|
||||
const files = Array.isArray(field.value) ? (field.value as kintone.fieldTypes.File['value']) : [];
|
||||
if (files.length === 0) {
|
||||
throw new Error(i18n.t('errors.template-field-does-not-contain-any-files'));
|
||||
}
|
||||
if (files.length > 1) {
|
||||
throw new Error(i18n.t('errors.template-field-contains-multiple-files'));
|
||||
}
|
||||
if (files[0].contentType !== DOCX_CONTENT_TYPE) {
|
||||
throw new Error(i18n.t('errors.template-file-must-be-a-docx', { contentType: files[0].contentType }));
|
||||
}
|
||||
return files[0].fileKey;
|
||||
};
|
||||
|
||||
const checkConfigApp = async (config: PluginConfigApp): Promise<string> => {
|
||||
const { appId, fieldCode, recordId } = config;
|
||||
if (appId === '') {
|
||||
throw new Error(i18n.t('errors.app-id-is-required'));
|
||||
}
|
||||
if (recordId === '') {
|
||||
throw new Error(i18n.t('errors.record-id-is-required'));
|
||||
}
|
||||
if (fieldCode === '') {
|
||||
throw new Error(i18n.t('errors.template-field-is-required'));
|
||||
}
|
||||
const client = new KintoneRestAPIClient();
|
||||
const { record } = await client.record.getRecord({ app: appId, id: recordId }).catch((_error) => {
|
||||
throw new Error(i18n.t('errors.record-is-not-available'));
|
||||
});
|
||||
const field = record[fieldCode];
|
||||
if (!field) {
|
||||
throw new Error(i18n.t('errors.template-field-is-not-available'));
|
||||
}
|
||||
if (field.type !== 'FILE') {
|
||||
throw new Error(i18n.t('errors.template-field-must-be-an-attachment-field'));
|
||||
}
|
||||
const files = Array.isArray(field.value) ? (field.value as kintone.fieldTypes.File['value']) : [];
|
||||
if (files.length === 0) {
|
||||
throw new Error(i18n.t('errors.template-field-does-not-contain-any-files'));
|
||||
}
|
||||
if (files.length > 1) {
|
||||
throw new Error(i18n.t('errors.template-field-contains-multiple-files'));
|
||||
}
|
||||
if (files[0].contentType !== DOCX_CONTENT_TYPE) {
|
||||
throw new Error(i18n.t('errors.template-file-must-be-a-docx', { contentType: files[0].contentType }));
|
||||
}
|
||||
return files[0].fileKey;
|
||||
};
|
||||
|
||||
export const checkConfig = async (config: PluginConfig, record: kintone.types.SavedFields): Promise<string> => {
|
||||
if (config.dataSource === PluginConfigDataSource.SELF) {
|
||||
return checkConfigSelf(config, record);
|
||||
} else if (config.dataSource === PluginConfigDataSource.APP) {
|
||||
return checkConfigApp(config);
|
||||
}
|
||||
throw new Error(i18n.t('errors.unexpected-error-occurred'));
|
||||
};
|
||||
@@ -179,10 +179,41 @@ const generateWordFileData = (
|
||||
language: string,
|
||||
) => {
|
||||
const zip = new PizZip(content);
|
||||
const parser = expressionParser.configure({
|
||||
filters: {
|
||||
toUpperCase: (str: string): string => str.toUpperCase(),
|
||||
toLowerCase: (str: string): string => str.toLowerCase(),
|
||||
regexMatch: (str: string, regex: string): boolean | string[] => {
|
||||
const pattern = new RegExp(regex);
|
||||
return pattern.test(str);
|
||||
},
|
||||
regexFilter: (arr: string[], regex: string): string[] => {
|
||||
const pattern = new RegExp(regex);
|
||||
if (Array.isArray(arr)) {
|
||||
return arr.filter((item) => pattern.test(item));
|
||||
}
|
||||
return [];
|
||||
},
|
||||
includes: (arr: string[] | string, str: string): boolean => {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr.includes(str);
|
||||
} else {
|
||||
return arr === str;
|
||||
}
|
||||
},
|
||||
indexOf: (arr: string[] | string, str: string): number => {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr.indexOf(str);
|
||||
} else {
|
||||
return arr === str ? 0 : -1;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const doc = new Docxtemplater(zip, {
|
||||
paragraphLoop: true,
|
||||
linebreaks: true,
|
||||
parser: expressionParser,
|
||||
parser: parser,
|
||||
nullGetter: () => '',
|
||||
});
|
||||
doc.render(record2templateData(properties, record, language));
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
{
|
||||
"name": "Word output plugin",
|
||||
"errors": {
|
||||
"template-field-is-not-set": "Template field is not set. Please configure the plugin.",
|
||||
"template-field-is-not-available": "Template field is not available in this app.",
|
||||
"template-field-must-be-an-attachment-field": "Template field must be an attachment field.",
|
||||
"template-field-does-not-contain-any-files": "Template field does not contain any files.",
|
||||
"template-field-contains-multiple-files": "Template field contains multiple files. Please ensure it contains only one file.",
|
||||
"template-file-must-be-a-docx": "The template file must be a Word (.docx) file. 'Mime-Type: {{contentType}}'."
|
||||
"template-field-is-required": "The template field is not configured. Please check the plugin settings.",
|
||||
"template-field-is-not-available": "The template field is not available. Please check the plugin settings.",
|
||||
"template-field-must-be-an-attachment-field": "The template field must be an attachment field. Please check the plugin settings.",
|
||||
"template-field-does-not-contain-any-files": "The template field does not contain any files.",
|
||||
"template-field-contains-multiple-files": "The template field contains multiple files. Please attach only one file.",
|
||||
"template-file-must-be-a-docx": "The template file must be a Word (.docx) file. 'Mime-Type: {{contentType}}'.",
|
||||
"app-id-is-required": "The app ID for the template file is required. Please check the plugin settings.",
|
||||
"record-id-is-required": "The record ID for the template file is required. Please check the plugin settings.",
|
||||
"record-is-not-available": "The record is not available. Please check the plugin settings.",
|
||||
"unexpected-error-occurred": "An unexpected error occurred."
|
||||
},
|
||||
"buttons": {
|
||||
"output": "Output Word"
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
{
|
||||
"name": "Word出力プラグイン",
|
||||
"errors": {
|
||||
"template-field-is-not-set": "雛形ファイルが設定されていません。プラグインの設定を見直してください。",
|
||||
"template-field-is-required": "雛形ファイルが設定されていません。プラグインの設定を見直してください。",
|
||||
"template-field-is-not-available": "雛形ファイルに設定された添付ファイルフィールドが見つかりませんでした。プラグインの設定を見直してください。",
|
||||
"template-field-must-be-an-attachment-field": "雛形ファイルに設定されたフィールド型が添付ファイルフィールドではありません。プラグインの設定を見直してください。",
|
||||
"template-field-does-not-contain-any-files": "雛形ファイルが添付されていません。",
|
||||
"template-field-contains-multiple-files": "雛形ファイルとして複数登録されています。1つのみを指定してください。",
|
||||
"template-file-must-be-a-docx": "雛形ファイルがWord形式(.docx)ではありません。'Mime-Type: {{contentType}}'"
|
||||
"template-field-contains-multiple-files": "雛形ファイルとして複数のファイルが添付されています。1つだけ添付してください。",
|
||||
"template-file-must-be-a-docx": "雛形ファイルがWord形式(.docx)ではありません。'Mime-Type: {{contentType}}'",
|
||||
"app-id-is-required": "雛形ファイルを格納するアプリIDが設定されていません。プラグインの設定を見直してください。",
|
||||
"record-id-is-required": "雛形ファイルを格納するアプリのレコードIDが設定されていません。プラグインの設定を見直してください。",
|
||||
"record-is-not-available": "雛形ファイルを格納されたアプリのレコードが取得できません。プラグインの設定を見直してください。",
|
||||
"unexpected-error-occurred": "予期しないエラーが発生しました。"
|
||||
},
|
||||
"buttons": {
|
||||
"output": "Word出力"
|
||||
|
||||
16
src/types/kintone.d.ts
vendored
16
src/types/kintone.d.ts
vendored
@@ -98,4 +98,20 @@ declare namespace kintone {
|
||||
function getFormFields(): Promise<unknown>;
|
||||
function getFormLayout(): Promise<unknown>;
|
||||
}
|
||||
|
||||
function proxy(
|
||||
url: string,
|
||||
method: string,
|
||||
headers: Record<string, string>,
|
||||
data: Record<string, unknown> | string,
|
||||
): Promise<[string, number, Record<string, string>]>;
|
||||
|
||||
function proxy(
|
||||
url: string,
|
||||
method: string,
|
||||
headers: Record<string, string>,
|
||||
data: Record<string, unknown> | string,
|
||||
callback: (resp: [string, number, Record<string, string>]) => void,
|
||||
errback: (err: Error) => void,
|
||||
): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user