odant-work 1.0.91 → 1.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/#system/certs/russian_trusted_root_ca.pem +32 -32
  2. package/#system/mail.json.example +9 -9
  3. package/#system/package-manifest.json +332 -373
  4. package/#system/settings.json.example +3 -3
  5. package/$server/$folder/$class/$data/handlers/pages/form/objects/$handler/class.js +2158 -0
  6. package/$server/$folder/$class/$data/handlers/pages/form/objects/object/$handler/class.js +1377 -0
  7. package/$server/$folder/$class/$domain/class.js +4 -4
  8. package/$server/$folder/$class/$handler/$trigger/class.js +3 -3
  9. package/$server/$folder/$class/$handler/class.js +9 -9
  10. package/$server/$folder/$class/$handler/handlers/pages/editor/$handler/class.js +5 -5
  11. package/$server/$folder/$class/$handler/readme.md +23 -23
  12. package/$server/$folder/$class/$module/handlers/pages/form/system/{$handler/tabs/mcp/$handler/mcp.js → mcp/$handler/class.js} +251 -210
  13. package/$server/$folder/$class/$module/handlers/pages/form/system/{$handler/tabs/modules → modules}/$handler/class.js +1 -0
  14. package/$server/$folder/$class/$structure/$organization/handlers/pages/site/$handler/{site.js → class.js} +351 -364
  15. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/{$handler/tabs/license/$handler/license.js → license/$handler/class.js} +104 -103
  16. package/$server/$folder/$class/$structure/$server/handlers/pages/site/$handler/{site.js → class.js} +45 -30
  17. package/$server/$folder/$class/$structure/$user/class.js +2 -2
  18. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +3 -0
  19. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +3 -0
  20. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/modules/$handler/class.js +3 -0
  21. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/{$handler/tabs/profile/$handler/profile.js → profile/$handler/class.js} +6 -2
  22. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +308 -5
  23. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +14 -3
  24. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1281 -7
  25. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/readme.md +40 -40
  26. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2216 -6
  27. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1304 -6
  28. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +305 -5
  29. package/$server/$folder/$class/$structure/handlers/pages/form/system/{$handler/tabs/agent/$handler/agent.js → agent/$handler/class.js} +329 -320
  30. package/$server/$folder/$class/$structure/handlers/pages/form/system/{$handler/tabs/database/$handler/database.js → database/$handler/class.js} +510 -577
  31. package/$server/$folder/$class/$structure/handlers/pages/form/system/{$handler/tabs/messengers/$handler/messengers.js → messengers/$handler/class.js} +142 -143
  32. package/$server/$folder/$class/$structure/handlers/pages/form/system/modules/$handler/class.js +270 -0
  33. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2114 -0
  34. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +229 -4
  35. package/$server/$folder/$class/ai/config.js +19 -19
  36. package/$server/$folder/$class/ai/prompt/$method/class.js +41 -41
  37. package/$server/$folder/$class/ai/skills/approval-flow.md +14 -14
  38. package/$server/$folder/$class/ai/skills/backup-check.md +13 -13
  39. package/$server/$folder/$class/ai/skills/computer.md +27 -27
  40. package/$server/$folder/$class/ai/skills/delegate-task.md +15 -15
  41. package/$server/$folder/$class/ai/skills/external-signup.md +14 -14
  42. package/$server/$folder/$class/ai/skills/onboarding.md +15 -15
  43. package/$server/$folder/$class/ai/skills/orchestration.md +41 -41
  44. package/$server/$folder/$class/ai/system.md +1 -1
  45. package/$server/$folder/$class/class.js +0 -3
  46. package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +3 -0
  47. package/$server/$folder/$class/handlers/pages/form/system/$handler/class.js +2 -4
  48. package/$server/$folder/$class/handlers/pages/form/system/{$handler/tabs/files → files}/$handler/class.js +2 -0
  49. package/$server/$folder/$class/handlers/pages/form/system/{$handler/tabs/requisites/$handler/requisites.js → requisites/$handler/class.js} +43 -36
  50. package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +25 -6
  51. package/$server/$folder/$file/$audio/handlers/preview/$handler/class.js +3 -3
  52. package/$server/$folder/$file/$audio/handlers/preview/$handler/preview.js +88 -88
  53. package/$server/$folder/$file/$call/class.js +10 -10
  54. package/$server/$folder/$file/$call/handlers/preview/$handler/class.js +4 -4
  55. package/$server/$folder/$file/$call/triggers/on_save/$trigger/class.js +48 -48
  56. package/$server/$folder/$file/$data/class.js +16 -16
  57. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +31 -4
  58. package/$server/$folder/$file/$devs/$js/class.js +2 -2
  59. package/$server/$folder/$file/$devs/$json/class.js +2 -2
  60. package/$server/$folder/$file/$devs/$ts/class.js +2 -2
  61. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +30 -2
  62. package/$server/$folder/$file/$eml/class.js +17 -17
  63. package/$server/$folder/$file/$ics/class.js +44 -44
  64. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +10 -2
  65. package/$server/$folder/$file/$ics/handlers/preview/$handler/class.js +3 -3
  66. package/$server/$folder/$file/$ics/handlers/preview/$handler/preview.js +67 -67
  67. package/$server/$folder/$file/$ics/readme.md +21 -21
  68. package/$server/$folder/$file/$image/$svg/class.js +11 -11
  69. package/$server/$folder/$file/$image/handlers/preview/$handler/class.js +3 -3
  70. package/$server/$folder/$file/$image/handlers/preview/$handler/preview.js +33 -33
  71. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +82 -2
  72. package/$server/$folder/$file/$logs/class.js +39 -39
  73. package/$server/$folder/$file/$logs/handlers/methods/txt-test/$handler/class.js +4 -4
  74. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +60 -2
  75. package/$server/$folder/$file/$office/$outlook/$ics/class.js +227 -227
  76. package/$server/$folder/$file/$office/$word/$rtf/template.rtf +159 -159
  77. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/class.js +1699 -2
  78. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +827 -2
  79. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +1 -1
  80. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js +17 -0
  81. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/panel.js +7 -1
  82. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/util.js +1 -0
  83. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/voice-policy.js +6 -2
  84. package/$server/$folder/$file/$task/handlers/preview/$handler/class.js +3 -3
  85. package/$server/$folder/$file/$task/readme.md +32 -32
  86. package/$server/$folder/$file/$txt/handlers/preview/$handler/class.js +3 -3
  87. package/$server/$folder/$file/$txt/handlers/preview/$handler/preview.js +41 -41
  88. package/$server/$folder/$file/$video/handlers/preview/$handler/class.js +4 -4
  89. package/$server/$folder/$file/$video/handlers/preview/$handler/preview.js +13 -13
  90. package/$server/$folder/$file/class.js +2 -2
  91. package/$server/$folder/$file/handlers/methods/download/$handler/class.js +2 -2
  92. package/$server/$folder/$file/handlers/methods/download/$handler/download.js +4 -4
  93. package/$server/$folder/$file/handlers/pages/form/$handler/class.js +2 -2
  94. package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +32 -2
  95. package/$server/$folder/$file/handlers/pages/form/folder/$handler/class.js +3 -0
  96. package/$server/$folder/$file/readme.md +31 -31
  97. package/$server/$folder/class.js +11 -11
  98. package/$server/$folder/handlers/pages/form/$handler/class.js +2469 -5
  99. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +22 -0
  100. package/$server/$folder/lib/chat-item/chat-item.js +2 -2
  101. package/$server/$folder/lib/email/settings.js +82 -82
  102. package/$server/$folder/lib/file-viewer/file-viewer.js +8 -8
  103. package/$server/$folder/lib/icon/user/user.js +6 -6
  104. package/$server/$folder/lib/item-data-grid/item-data-grid.js +48 -48
  105. package/$server/$folder/lib/item-form/item-form.js +84 -84
  106. package/$server/$folder/lib/menu/menu.js +3 -2
  107. package/$server/$folder/lib/menu/readme.md +29 -29
  108. package/$server/$folder/lib/node/readme.md +29 -29
  109. package/$server/$folder/lib/pack/pack.js +4 -4
  110. package/$server/$folder/lib/site-loc/readme.md +16 -16
  111. package/.github/workflows/ci.yml +39 -39
  112. package/AGENTS.md +1 -1
  113. package/{models/$ai/$folder/$class/$ai/handlers/pages/form/system/$handler/tabs/ai/$handler/ai.js → MODELS/$ai/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js} +383 -430
  114. package/{models/$ai/$folder/$class/$provider/handlers/pages/form/system/$handler/tabs/ai/$handler/ai.js → MODELS/$ai/$folder/$class/$provider/handlers/pages/form/system/ai/$handler/class.js} +155 -166
  115. package/{models → MODELS}/$ai/$folder/$class/$provider/readme.md +16 -16
  116. package/{models/$ai/handlers/pages/form/system/$handler/tabs/ai/$handler/ai.js → MODELS/$ai/handlers/pages/form/system/ai/$handler/class.js} +34 -33
  117. package/{models → MODELS}/GigaChat/$provider/readme.md +24 -24
  118. package/{models/Local/$provider/handlers/pages/form/system/$handler/tabs/ai/$handler/ai.js → MODELS/Local/$provider/handlers/pages/form/system/ai/$handler/class.js} +569 -626
  119. package/MODULES/$domain/handlers/pages/form/system/{$handler/tabs/mcp → mcp}/$handler/class.js +1 -0
  120. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +648 -20
  121. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +140 -6
  122. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/class.js" +305 -5
  123. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/class.js" +241 -5
  124. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/class.js" +515 -15
  125. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/objects/$handler/class.js +3 -0
  126. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/virtual/$handler/class.js +422 -5
  127. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/241/321/207/321/221/321/202 /320/275/320/260 /320/276/320/277/320/273/320/260/321/202/321/203.html" +40 -40
  128. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/242/320/276/320/262/320/260/321/200/320/275/320/260/321/217 /320/275/320/260/320/272/320/273/320/260/320/264/320/275/320/260/321/217.html" +56 -56
  129. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/analysis/$handler/class.js +13 -7
  130. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/postings/$handler/class.js +1791 -7
  131. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/turnovers/$handler/class.js +13 -7
  132. package/MODULES/Register/REGISTER/$register/handlers/pages/form/journal/$handler/class.js +776 -5
  133. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/class.js +807 -5
  134. package/MODULES/Register/REGISTER/68/01/$account/class.js +1 -1
  135. package/MODULES/Register/REGISTER/68/02/$account/class.js +1 -1
  136. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/320/276/320/262/321/213/320/271 /321/200/320/265/320/267/320/265/321/200/320/262/$account/class.js" +1 -1
  137. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213//320/222 /320/276/321/202/320/277/321/203/321/201/320/272/320/265/$account/class.js" +1 -1
  138. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213//320/240/320/260/320/261/320/276/321/202/320/260/321/216/321/202/$account/class.js +1 -1
  139. package/MODULES/Register/REGISTER//320/242/320/265/321/205/320/275/320/270/321/207/320/265/321/201/320/272/320/270/320/271/$account/class.js +1 -1
  140. package/MODULES/Register/STRUCTS/$struct/class.js +4 -4
  141. package/NODES/$node/$folder/$class/$node/class.js +35 -35
  142. package/NODES/$node/class.js +5 -5
  143. package/NODES/$node/handlers/pages/form/network/$handler/class.js +121 -4
  144. package/oda/benchmarks/dbmon/lib/ENV.js +213 -213
  145. package/oda/benchmarks/dbmon/lib/ga.js +11 -11
  146. package/oda/benchmarks/dbmon/lib/memory-stats.js +105 -105
  147. package/oda/benchmarks/dbmon/lib/monitor.js +69 -69
  148. package/oda/benchmarks/sierpinski/sierpinski.js +149 -149
  149. package/oda/components/editors/code-editor/code-editor.js +387 -387
  150. package/oda/components/editors/code-editor/src/ace.js +16 -16
  151. package/oda/components/editors/code-editor/src/beautify-css.js +1625 -1625
  152. package/oda/components/editors/code-editor/src/beautify-html.js +3122 -3122
  153. package/oda/components/editors/code-editor/src/beautify.js +4005 -4005
  154. package/oda/components/editors/code-editor/src/ext-beautify.js +7 -7
  155. package/oda/components/editors/code-editor/src/ext-code_lens.js +7 -7
  156. package/oda/components/editors/code-editor/src/ext-elastic_tabstops_lite.js +7 -7
  157. package/oda/components/editors/code-editor/src/ext-emmet.js +7 -7
  158. package/oda/components/editors/code-editor/src/ext-error_marker.js +7 -7
  159. package/oda/components/editors/code-editor/src/ext-hardwrap.js +7 -7
  160. package/oda/components/editors/code-editor/src/ext-keybinding_menu.js +7 -7
  161. package/oda/components/editors/code-editor/src/ext-language_tools.js +7 -7
  162. package/oda/components/editors/code-editor/src/ext-linking.js +7 -7
  163. package/oda/components/editors/code-editor/src/ext-modelist.js +7 -7
  164. package/oda/components/editors/code-editor/src/ext-options.js +7 -7
  165. package/oda/components/editors/code-editor/src/ext-prompt.js +7 -7
  166. package/oda/components/editors/code-editor/src/ext-rtl.js +7 -7
  167. package/oda/components/editors/code-editor/src/ext-searchbox.js +7 -7
  168. package/oda/components/editors/code-editor/src/ext-settings_menu.js +7 -7
  169. package/oda/components/editors/code-editor/src/ext-spellcheck.js +7 -7
  170. package/oda/components/editors/code-editor/src/ext-split.js +7 -7
  171. package/oda/components/editors/code-editor/src/ext-static_highlight.js +7 -7
  172. package/oda/components/editors/code-editor/src/ext-statusbar.js +7 -7
  173. package/oda/components/editors/code-editor/src/ext-textarea.js +7 -7
  174. package/oda/components/editors/code-editor/src/ext-themelist.js +7 -7
  175. package/oda/components/editors/code-editor/src/ext-whitespace.js +7 -7
  176. package/oda/components/editors/code-editor/src/keybinding-emacs.js +7 -7
  177. package/oda/components/editors/code-editor/src/keybinding-sublime.js +7 -7
  178. package/oda/components/editors/code-editor/src/keybinding-vim.js +7 -7
  179. package/oda/components/editors/code-editor/src/keybinding-vscode.js +7 -7
  180. package/oda/components/editors/code-editor/src/mode-css.js +7 -7
  181. package/oda/components/editors/code-editor/src/mode-html.js +7 -7
  182. package/oda/components/editors/code-editor/src/mode-javascript.js +7 -7
  183. package/oda/components/editors/code-editor/src/mode-json.js +7 -7
  184. package/oda/components/editors/code-editor/src/mode-markdown.js +7 -7
  185. package/oda/components/editors/code-editor/src/mode-svg.js +7 -7
  186. package/oda/components/editors/code-editor/src/mode-text.js +7 -7
  187. package/oda/components/editors/code-editor/src/mode-xml.js +7 -7
  188. package/oda/components/editors/code-editor/src/mode-xquery.js +7 -7
  189. package/oda/components/editors/code-editor/src/snippets/css.js +7 -7
  190. package/oda/components/editors/code-editor/src/snippets/html.js +7 -7
  191. package/oda/components/editors/code-editor/src/snippets/javascript.js +7 -7
  192. package/oda/components/editors/code-editor/src/snippets/json.js +7 -7
  193. package/oda/components/editors/code-editor/src/snippets/markdown.js +7 -7
  194. package/oda/components/editors/code-editor/src/snippets/svg.js +7 -7
  195. package/oda/components/editors/code-editor/src/snippets/text.js +7 -7
  196. package/oda/components/editors/code-editor/src/snippets/xml.js +7 -7
  197. package/oda/components/editors/code-editor/src/snippets/xquery.js +7 -7
  198. package/oda/components/editors/code-editor/src/theme-solarized_dark.js +7 -7
  199. package/oda/components/editors/code-editor/src/theme-solarized_light.js +7 -7
  200. package/oda/components/editors/markdown/markdown-editor/lib/font-awesome.min.css +3 -3
  201. package/oda/components/editors/markdown/markdown-editor/lib/readme.md +332 -332
  202. package/oda/components/editors/markdown/markdown-editor/markdown-editor.js +78 -78
  203. package/oda/components/editors/markdown/markdown-viewer/test.md +239 -239
  204. package/oda/components/editors/markdown/markdown.js +76 -76
  205. package/oda/components/inputs/block/readme.md +39 -39
  206. package/oda/components/inputs/checkbox/checkbox.js +92 -92
  207. package/oda/components/inputs/color/color.js +83 -83
  208. package/oda/components/inputs/date/date.js +40 -40
  209. package/oda/components/inputs/input/input.js +219 -219
  210. package/oda/components/inputs/link/link.js +1 -1
  211. package/oda/components/inputs/link/readme.md +42 -42
  212. package/oda/components/inputs/markdown-input/markdown-input.js +77 -77
  213. package/oda/components/inputs/numeric/numeric.js +141 -141
  214. package/oda/components/inputs/table-input/readme.md +39 -39
  215. package/oda/components/inputs/text/text.js +88 -88
  216. package/oda/components/inputs/toggle/toggle.js +101 -101
  217. package/oda/components/layouts/hexagon-layout/hexagon-layout.js +218 -218
  218. package/oda/components/menus/menu/index_old.html +140 -140
  219. package/oda/components/structure/controls-map.js +56 -56
  220. package/oda/components/structure/controls.js +29 -29
  221. package/oda/components/structure/readme.md +31 -31
  222. package/oda/components/structure/structure.js +64 -64
  223. package/oda/components/table/index.html +210 -210
  224. package/oda/components/table/lib/coerce.js +68 -68
  225. package/oda/components/table/lib/column.js +568 -568
  226. package/oda/components/table/readme.md +120 -120
  227. package/oda/components/table/router.js +86 -86
  228. package/oda/components/table/settings.js +89 -89
  229. package/oda/index.html +159 -159
  230. package/oda/tools/icons/icons-set/icons-set.js +60 -60
  231. package/oda/tools/icons/lib/svg/_makeSVG.html +41 -41
  232. package/oda/tools/icons/lib/svg/aws.svg +2679 -2679
  233. package/oda/tools/icons/lib/svg/info.json +46 -46
  234. package/oda/tools/jupyter/demo.ipynb +160 -160
  235. package/oda/tools/jupyter/lib/print_elements.js +73 -73
  236. package/oda/tools/jupyter/test-2.ipynb +305 -305
  237. package/oda/tools/jupyter/test.ipynb +603 -603
  238. package/oda/tools/styles/adoptedStyleSheets.js +333 -333
  239. package/oda/tools/tester/device-preview/devices.json +9 -9
  240. package/package.json +1 -1
  241. package/rules/rules.md +445 -445
  242. package/scripts/SYNC-README.md +107 -107
  243. package/scripts/agent-eval.mjs +223 -223
  244. package/scripts/dump-svn-chat.mjs +9 -9
  245. package/scripts/extract-chat-day.mjs +21 -21
  246. package/scripts/rag-bench.mjs +166 -166
  247. package/scripts/restore-chat.mjs +166 -166
  248. package/scripts/sync-svn-git.bat +129 -129
  249. package/scripts/test-merge.mjs +75 -75
  250. package/scripts/work-desktop-bridge.mjs +101 -101
  251. package/sources/client/class.js +3 -0
  252. package/sources/client/field.js +168 -168
  253. package/sources/client/handler.js +68 -32
  254. package/sources/client/index.js +32 -32
  255. package/sources/client/readme.md +16 -16
  256. package/sources/client.js +12 -0
  257. package/sources/core.js +91 -91
  258. package/sources/data/choices.js +125 -125
  259. package/sources/host/babel-merge.js +398 -353
  260. package/sources/host/config.js +48 -48
  261. package/sources/host/index-db.js +94 -94
  262. package/sources/host/net-guard.js +228 -228
  263. package/sources/host/package-install.js +63 -63
  264. package/sources/host/push.js +86 -86
  265. package/sources/host/readme.md +41 -41
  266. package/sources/host/secret-box.js +93 -93
  267. package/sources/host/server-id.js +26 -26
  268. package/sources/host/stun.js +33 -33
  269. package/sources/host/tls-ca.js +60 -60
  270. package/sources/host/vapid.js +14 -14
  271. package/sources/index.html +1 -1
  272. package/sources/modules/a2a/server.js +608 -608
  273. package/sources/modules/agent/connections.js +442 -442
  274. package/sources/modules/agent/diff.js +69 -69
  275. package/sources/modules/agent/eval.js +222 -222
  276. package/sources/modules/agent/hooks.js +131 -131
  277. package/sources/modules/agent/index.js +6 -3
  278. package/sources/modules/agent/log.js +43 -43
  279. package/sources/modules/agent/loop.js +65 -0
  280. package/sources/modules/agent/mcp-pool.js +253 -253
  281. package/sources/modules/agent/recovery.js +89 -89
  282. package/sources/modules/agent/scope.js +387 -0
  283. package/sources/modules/agent/session.js +350 -15
  284. package/sources/modules/agent/taint.js +100 -100
  285. package/sources/modules/agent/tools/branch.js +311 -311
  286. package/sources/modules/agent/tools/browser.js +254 -254
  287. package/sources/modules/agent/tools/computer.js +120 -120
  288. package/sources/modules/agent/tools/connect.js +316 -316
  289. package/sources/modules/agent/tools/dev/lsp.js +334 -334
  290. package/sources/modules/agent/tools/dev/patch.js +564 -564
  291. package/sources/modules/agent/tools/memory.js +153 -153
  292. package/sources/modules/agent/tools/meta.js +60 -0
  293. package/sources/modules/agent/tools/os-files.js +358 -358
  294. package/sources/modules/agent/tools/plugins.js +80 -80
  295. package/sources/modules/agent/tools/sandbox.js +268 -268
  296. package/sources/modules/agent/types.d.ts +183 -183
  297. package/sources/modules/agent/undo.js +254 -254
  298. package/sources/modules/agent/util.js +179 -179
  299. package/sources/modules/contacts/contacts.js +200 -200
  300. package/sources/modules/contacts/index.html +546 -546
  301. package/sources/modules/lan/discovery.js +192 -192
  302. package/sources/modules/lan/store.js +62 -62
  303. package/sources/modules/mcp/readme.md +70 -70
  304. package/sources/modules/mcp/server.js +525 -525
  305. package/sources/modules/mcp/tokens.js +140 -140
  306. package/sources/modules/nodes/identity.js +123 -123
  307. package/sources/modules/nodes/outbound.js +105 -105
  308. package/sources/modules/nodes/signing.js +71 -71
  309. package/sources/modules/rag/embed-worker.js +36 -36
  310. package/sources/modules/rag/readme.md +70 -70
  311. package/sources/modules/readme.md +21 -21
  312. package/sources/modules/sandbox/config.js +74 -74
  313. package/sources/modules/sandbox/driver.js +100 -100
  314. package/sources/modules/sandbox/images/work-computer/Dockerfile +34 -34
  315. package/sources/modules/sandbox/images/work-computer/entrypoint.sh +24 -24
  316. package/sources/modules/sandbox/manager.js +1089 -1089
  317. package/sources/modules/sandbox/readme.md +63 -63
  318. package/sources/modules/sandbox/vnc-proxy.js +296 -296
  319. package/sources/server/access/audit.js +138 -138
  320. package/sources/server/access/refs.js +106 -106
  321. package/sources/server/assert-class-id.js +23 -23
  322. package/sources/server/chat-threads.js +16 -5
  323. package/sources/server/class.js +4 -1
  324. package/sources/server/external-source.js +90 -90
  325. package/sources/server/file.js +1 -1
  326. package/sources/server/folder.js +75 -33
  327. package/sources/server/handler.js +25 -12
  328. package/sources/server/index.js +12 -12
  329. package/sources/server/memory-mark.js +34 -34
  330. package/sources/server/readme.md +110 -110
  331. package/sources/server/safe-node-name.js +67 -67
  332. package/sources/server/server.js +6 -6
  333. package/sources/server/upload-mark.js +24 -24
  334. package/sources/server/zip-guard.js +81 -81
  335. package/whitepaper.md +568 -568
  336. package/$server/$folder/$class/$module/handlers/pages/form/system/$handler/tabs/mcp/$handler/class.js +0 -9
  337. package/$server/$folder/$class/$module/handlers/pages/form/system/$handler/tabs/modules/$handler/modules.js +0 -1
  338. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/$handler/tabs/license/$handler/class.js +0 -6
  339. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/tabs/agent/$handler/class.js +0 -3
  340. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/tabs/messengers/$handler/class.js +0 -3
  341. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/tabs/modules/$handler/class.js +0 -3
  342. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/tabs/profile/$handler/class.js +0 -5
  343. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +0 -313
  344. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +0 -16
  345. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +0 -1226
  346. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +0 -2095
  347. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +0 -1188
  348. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +0 -289
  349. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/agent/$handler/class.js +0 -6
  350. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/database/$handler/class.js +0 -9
  351. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/messengers/$handler/class.js +0 -6
  352. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/modules/$handler/class.js +0 -5
  353. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/modules/$handler/modules.js +0 -281
  354. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/staff/$handler/class.js +0 -5
  355. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/staff/$handler/staff.js +0 -2126
  356. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/site.js +0 -240
  357. package/$server/$folder/$class/handlers/pages/form/object/$handler/class.js +0 -32
  358. package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +0 -1371
  359. package/$server/$folder/$class/handlers/pages/form/objects/$handler/class.js +0 -32
  360. package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +0 -2130
  361. package/$server/$folder/$class/handlers/pages/form/system/$handler/system.js +0 -309
  362. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/files/$handler/files.js +0 -17
  363. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/requisites/$handler/class.js +0 -16
  364. package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +0 -21
  365. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +0 -27
  366. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +0 -31
  367. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +0 -10
  368. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/file.js +0 -72
  369. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +0 -63
  370. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +0 -1845
  371. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +0 -760
  372. package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +0 -29
  373. package/$server/$folder/handlers/pages/form/$handler/form.js +0 -2122
  374. package/MODULES/$domain/handlers/pages/form/system/$handler/tabs/mcp/$handler/mcp.js +0 -1
  375. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +0 -623
  376. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +0 -134
  377. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +0 -293
  378. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +0 -234
  379. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/bpmn.js" +0 -406
  380. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/virtual/$handler/virtual.js +0 -399
  381. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/analysis/$handler/analysis.js +0 -9
  382. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/postings/$handler/postings.js +0 -1700
  383. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/turnovers/$handler/turnovers.js +0 -9
  384. package/MODULES/Register/REGISTER/$register/handlers/pages/form/journal/$handler/journal.js +0 -723
  385. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/sheet.js +0 -808
  386. package/NODES/$node/handlers/pages/form/network/$handler/network.js +0 -110
  387. package/models/$ai/$folder/$class/$ai/handlers/pages/form/system/$handler/tabs/ai/$handler/class.js +0 -6
  388. package/models/$ai/$folder/$class/$provider/handlers/pages/form/system/$handler/tabs/ai/$handler/class.js +0 -6
  389. package/models/$ai/handlers/pages/form/system/$handler/tabs/ai/$handler/class.js +0 -6
  390. package/models/Local/$provider/handlers/pages/form/system/$handler/tabs/ai/$handler/class.js +0 -6
  391. /package/$server/$folder/$class/$structure/$organization/handlers/pages/form/system/{$handler/tabs/requisites → requisites}/$handler/class.js +0 -0
  392. /package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/{$handler/tabs/database → database}/$handler/class.js +0 -0
  393. /package/{models → MODELS}/$ai/$folder/$class/$ai/class.js +0 -0
  394. /package/{models → MODELS}/$ai/$folder/$class/$ai/methods/chat/$method/class.js +0 -0
  395. /package/{models → MODELS}/$ai/$folder/$class/$provider/class.js +0 -0
  396. /package/{models → MODELS}/$ai/class.js +0 -0
  397. /package/{models → MODELS}/$ai/readme.md +0 -0
  398. /package/{models → MODELS}/GigaChat/$provider/$folder/$class/$ai/class.js +0 -0
  399. /package/{models → MODELS}/GigaChat/$provider/class.js +0 -0
  400. /package/{models → MODELS}/GigaChat/GigaChat 2 Lite/$ai/class.js +0 -0
  401. /package/{models → MODELS}/GigaChat/GigaChat 2 Max/$ai/class.js +0 -0
  402. /package/{models → MODELS}/GigaChat/GigaChat 2 Pro/$ai/class.js +0 -0
  403. /package/{models → MODELS}/GigaChat/GigaChat Embeddings/$ai/class.js +0 -0
  404. /package/{models → MODELS}/Local/$provider/$folder/$class/$ai/class.js +0 -0
  405. /package/{models → MODELS}/Local/$provider/class.js +0 -0
  406. /package/{models → MODELS}/Local/$provider/handlers/methods/transfer/$handler/class.js +0 -0
  407. /package/{models → MODELS}/MTS-AI/$provider/$folder/$class/$ai/class.js +0 -0
  408. /package/{models → MODELS}/MTS-AI/$provider/class.js +0 -0
  409. /package/{models → MODELS}/MTS-AI/Cotype Lite/$ai/class.js +0 -0
  410. /package/{models → MODELS}/MTS-AI/Cotype Pro 2/$ai/class.js +0 -0
  411. /package/{models → MODELS}/MTS-AI/Cotype Vision/$ai/class.js +0 -0
  412. /package/{models → MODELS}/T-Bank/$provider/$folder/$class/$ai/class.js +0 -0
  413. /package/{models → MODELS}/T-Bank/$provider/class.js +0 -0
  414. /package/{models → MODELS}/T-Bank/T-Lite 2.0/$ai/class.js +0 -0
  415. /package/{models → MODELS}/T-Bank/T-Pro 2.0/$ai/class.js +0 -0
  416. /package/{models → MODELS}/T-Bank/T-VoiceKit ASR/$ai/class.js +0 -0
  417. /package/{models → MODELS}/T-Bank/T-VoiceKit TTS/$ai/class.js +0 -0
  418. /package/{models → MODELS}/Yandex/$provider/$folder/$class/$ai/class.js +0 -0
  419. /package/{models → MODELS}/Yandex/$provider/class.js +0 -0
  420. /package/{models → MODELS}/Yandex/Alice AI (YandexGPT 5 Pro)/$ai/class.js +0 -0
  421. /package/{models → MODELS}/Yandex/Yandex Embeddings/$ai/class.js +0 -0
  422. /package/{models → MODELS}/Yandex/Yandex SpeechKit ASR/$ai/class.js +0 -0
  423. /package/{models → MODELS}/Yandex/Yandex SpeechKit TTS/$ai/class.js +0 -0
  424. /package/{models → MODELS}/Yandex/YandexART/$ai/class.js +0 -0
  425. /package/{models → MODELS}/Yandex/YandexGPT 5 Lite/$ai/class.js +0 -0
  426. /package/{models → MODELS}/Yandex/YandexGPT Reasoning/$ai/class.js +0 -0
  427. /package/{users → USERS}/$users/class.js +0 -0
@@ -1,4 +1,1701 @@
1
- /** Мета хендлера form/file ($office). Визуалка — file.js. */
1
+ /**
2
+ * Локальный офисный пакет WORK (`oda-office-editor`):
3
+ * - Таблицы (`.xlsx`, `.xls`, `.csv`, `.ods`) — мультилистовая электронная таблица с формулами, стилями и объединением ячеек;
4
+ * - Документы (`.docx`, `.doc`, `.rtf`, `.odt`) — страничный редактор формата А4 с таблицами, стилями и печатью;
5
+ * - Презентации (`.pptx`, `.ppt`, `.odp`) — двухпанельный редактор слайдов 16:9 с перетаскиванием блоков и полноэкранным показом;
6
+ * - Интеграция с десктопным Office на ПК через протоколы `ms-word:ofe|u|...`, `ms-excel:ofe|u|...`, `ms-powerpoint:ofe|u|...` (WebDAV).
7
+ */
8
+
9
+ function colIndexToLetters(col) {
10
+ let n = Number(col) + 1;
11
+ let s = '';
12
+ while (n > 0) {
13
+ const rem = (n - 1) % 26;
14
+ s = String.fromCharCode(65 + rem) + s;
15
+ n = Math.floor((n - 1) / 26);
16
+ }
17
+ return s || 'A';
18
+ }
19
+ function lettersToColIndex(letters) {
20
+ const clean = String(letters || '').toUpperCase().replace(/[^A-Z]/g, '');
21
+ let n = 0;
22
+ for (let i = 0; i < clean.length; i++) n = n * 26 + (clean.charCodeAt(i) - 64);
23
+ return Math.max(0, n - 1);
24
+ }
25
+ function parseCellRef(refStr) {
26
+ const m = String(refStr || '').trim().toUpperCase().match(/^([A-Z]+)(\d+)$/);
27
+ if (!m) return null;
28
+ return {
29
+ c: lettersToColIndex(m[1]),
30
+ r: Math.max(0, parseInt(m[2], 10) - 1)
31
+ };
32
+ }
33
+
34
+ /** Вычислить формулу ячейки Excel (`=SUM(A1:B3)`, `=AVERAGE(...)`, `=IF(...)`, `=A1*B1+10`). */
35
+ export function evaluateSheetFormula(rawFormula, cells = {}, depth = 0) {
36
+ if (depth > 8) return '#ЦИКЛ!';
37
+ const expr = String(rawFormula || '').replace(/^=/, '').trim();
38
+ if (!expr) return '';
39
+ const numVal = (r, c) => {
40
+ const cell = cells[`${r}:${c}`];
41
+ if (!cell) return 0;
42
+ if (cell.f) {
43
+ const v = evaluateSheetFormula(cell.f, cells, depth + 1);
44
+ const n = Number(v);
45
+ return Number.isFinite(n) ? n : 0;
46
+ }
47
+ const raw = typeof cell.v === 'string' ? cell.v.replace(/\s+/g, '').replace(',', '.') : cell.v;
48
+ const n = Number(raw);
49
+ return Number.isFinite(n) ? n : 0;
50
+ };
51
+ const expandRange = (aRef, bRef) => {
52
+ const a = parseCellRef(aRef);
53
+ const b = parseCellRef(bRef);
54
+ if (!a || !b) return [];
55
+ const r1 = Math.min(a.r, b.r),
56
+ r2 = Math.max(a.r, b.r);
57
+ const c1 = Math.min(a.c, b.c),
58
+ c2 = Math.max(a.c, b.c);
59
+ const vals = [];
60
+ for (let r = r1; r <= r2; r++) {
61
+ for (let c = c1; c <= c2; c++) vals.push(numVal(r, c));
62
+ }
63
+ return vals;
64
+ };
65
+ const collectArgs = argsStr => {
66
+ const parts = String(argsStr || '').split(/[;,]/).map(s => s.trim()).filter(Boolean);
67
+ const nums = [];
68
+ for (const p of parts) {
69
+ const rm = p.match(/^([A-Za-z]+\d+)\s*:\s*([A-Za-z]+\d+)$/);
70
+ if (rm) {
71
+ nums.push(...expandRange(rm[1], rm[2]));
72
+ continue;
73
+ }
74
+ const cm = parseCellRef(p);
75
+ if (cm) {
76
+ nums.push(numVal(cm.r, cm.c));
77
+ continue;
78
+ }
79
+ const n = Number(p.replace(',', '.'));
80
+ if (Number.isFinite(n)) nums.push(n);
81
+ }
82
+ return nums;
83
+ };
84
+
85
+ // Функции SUM / СУММ, AVERAGE / СРЗНАЧ, MIN / МИН, MAX / МАКС, COUNT / СЧЁТ, ROUND / ОКРУГЛ
86
+ const withFuncs = expr.replace(/\b(SUM|СУММ|AVERAGE|СРЗНАЧ|AVG|MIN|МИН|MAX|МАКС|COUNT|СЧЁТ|СЧЕТ|ROUND|ОКРУГЛ)\s*\(([^()]*)\)/gi, (_, fnRaw, argsStr) => {
87
+ const fn = fnRaw.toUpperCase();
88
+ const vals = collectArgs(argsStr);
89
+ if (fn === 'SUM' || fn === 'СУММ') return String(vals.reduce((a, b) => a + b, 0));
90
+ if (fn === 'AVERAGE' || fn === 'СРЗНАЧ' || fn === 'AVG') return String(vals.length ? vals.reduce((a, b) => a + b, 0) / vals.length : 0);
91
+ if (fn === 'MIN' || fn === 'МИН') return String(vals.length ? Math.min(...vals) : 0);
92
+ if (fn === 'MAX' || fn === 'МАКС') return String(vals.length ? Math.max(...vals) : 0);
93
+ if (fn === 'COUNT' || fn === 'СЧЁТ' || fn === 'СЧЕТ') return String(vals.length);
94
+ if (fn === 'ROUND' || fn === 'ОКРУГЛ') {
95
+ const v = vals[0] || 0;
96
+ const digits = Math.max(0, Math.min(10, Math.round(vals[1] ?? 0)));
97
+ const factor = 10 ** digits;
98
+ return String(Math.round(v * factor) / factor);
99
+ }
100
+ return '0';
101
+ });
102
+
103
+ // Подстановка одиночных ссылок на ячейки (A1, B12, ...)
104
+ const withRefs = withFuncs.replace(/\b([A-Za-z]{1,2}\d{1,4})\b/g, ref => {
105
+ const pos = parseCellRef(ref);
106
+ if (!pos) return '0';
107
+ return String(numVal(pos.r, pos.c));
108
+ });
109
+
110
+ // Безопасное вычисление арифметики (+, -, *, /, скобки, числа)
111
+ if (!/^[0-9.+\-*/()\s]+$/.test(withRefs)) return '#ЗНАЧ!';
112
+ try {
113
+ const res = Function(`"use strict"; return (${withRefs});`)();
114
+ if (typeof res === 'number' && Number.isFinite(res)) return Math.round(res * 1e6) / 1e6;
115
+ return '#ЧИСЛО!';
116
+ } catch {
117
+ return '#ОШИБКА!';
118
+ }
119
+ }
120
+ ODA({
121
+ is: 'oda-office-editor',
122
+ imports: 'oda//button, oda//icon',
123
+ template: /*html*/`
124
+ <style>
125
+ :host {
126
+ @apply --flex;
127
+ @apply --vertical;
128
+ @apply --content;
129
+ overflow: hidden;
130
+ position: relative;
131
+ font-size: 13px;
132
+ outline: none;
133
+ }
134
+ .office-toolbar {
135
+ @apply --horizontal;
136
+ @apply --light;
137
+ align-items: center;
138
+ flex-wrap: wrap;
139
+ gap: 4px;
140
+ min-height: 36px;
141
+ padding: 4px 10px;
142
+ border-bottom: 1px solid var(--border-color);
143
+ flex-shrink: 0;
144
+ user-select: none;
145
+ }
146
+ .kind-badge {
147
+ display: inline-flex;
148
+ align-items: center;
149
+ gap: 4px;
150
+ padding: 2px 8px;
151
+ border-radius: var(--radius-xs, 3px);
152
+ font-size: 11px;
153
+ font-weight: 700;
154
+ letter-spacing: 0.03em;
155
+ color: #fff;
156
+ margin-right: 4px;
157
+ }
158
+ .kind-badge[data-kind="document"] { background: #2563eb; }
159
+ .kind-badge[data-kind="spreadsheet"] { background: #16a34a; }
160
+ .kind-badge[data-kind="presentation"] { background: #ea580c; }
161
+ .tb-sep {
162
+ width: 1px;
163
+ height: 20px;
164
+ background: var(--border-color);
165
+ margin: 0 4px;
166
+ }
167
+ .tb-btn {
168
+ display: inline-flex;
169
+ align-items: center;
170
+ justify-content: center;
171
+ gap: 4px;
172
+ min-width: 26px;
173
+ height: 26px;
174
+ padding: 0 6px;
175
+ border: 1px solid transparent;
176
+ border-radius: var(--radius-xs, 3px);
177
+ background: transparent;
178
+ color: var(--content-color);
179
+ font-size: 12px;
180
+ font-family: inherit;
181
+ cursor: pointer;
182
+ }
183
+ .tb-btn:hover {
184
+ background: var(--subtle-background);
185
+ border-color: var(--border-color);
186
+ }
187
+ .tb-btn[active] {
188
+ background: var(--selected-background);
189
+ color: var(--selected-color);
190
+ border-color: var(--accent-color);
191
+ font-weight: 600;
192
+ }
193
+ .tb-select {
194
+ height: 26px;
195
+ padding: 0 6px;
196
+ border: 1px solid var(--border-color);
197
+ border-radius: var(--radius-xs, 3px);
198
+ background: var(--content-background);
199
+ color: var(--content-color);
200
+ font-size: 12px;
201
+ outline: none;
202
+ }
203
+ .tb-color {
204
+ width: 24px;
205
+ height: 24px;
206
+ padding: 1px;
207
+ border: 1px solid var(--border-color);
208
+ border-radius: var(--radius-xs, 3px);
209
+ background: var(--content-background);
210
+ cursor: pointer;
211
+ }
212
+ .status-pill {
213
+ font-size: 11.5px;
214
+ color: var(--muted-color);
215
+ margin-right: 6px;
216
+ }
217
+ .status-pill[dirty] {
218
+ color: var(--accent-color);
219
+ font-weight: 600;
220
+ }
221
+ .tb-btn.save-btn {
222
+ background: var(--accent-color, #2563eb);
223
+ color: #ffffff;
224
+ border-color: var(--accent-color, #2563eb);
225
+ font-weight: 600;
226
+ }
227
+ .tb-btn.save-btn:hover {
228
+ opacity: 0.92;
229
+ background: var(--accent-color, #2563eb);
230
+ }
231
+ .office-view-wrap {
232
+ @apply --flex;
233
+ @apply --vertical;
234
+ min-height: 0;
235
+ overflow: hidden;
236
+ }
237
+ .tb-group {
238
+ display: inline-flex;
239
+ align-items: center;
240
+ flex-wrap: wrap;
241
+ gap: 4px;
242
+ }
243
+ :host([inline]) .docx-workspace {
244
+ padding: 12px;
245
+ }
246
+ :host([inline]) .docx-page {
247
+ width: 100%;
248
+ min-height: 260px;
249
+ padding: 20px 24px;
250
+ }
251
+ :host([inline]) .pptx-stage-wrap {
252
+ padding: 10px;
253
+ }
254
+
255
+ /* --- ТАБЛИЦА (.xlsx) --- */
256
+ .formula-bar {
257
+ @apply --horizontal;
258
+ align-items: center;
259
+ gap: 6px;
260
+ height: 28px;
261
+ padding: 2px 10px;
262
+ background: var(--content-background);
263
+ border-bottom: 1px solid var(--border-color);
264
+ flex-shrink: 0;
265
+ }
266
+ .cell-addr-box {
267
+ min-width: 64px;
268
+ text-align: center;
269
+ padding: 2px 6px;
270
+ border: 1px solid var(--border-color);
271
+ border-radius: 2px;
272
+ background: var(--subtle-background);
273
+ font-weight: 600;
274
+ font-size: 12px;
275
+ }
276
+ .fx-label {
277
+ font-style: italic;
278
+ font-weight: 700;
279
+ color: var(--muted-color);
280
+ padding: 0 4px;
281
+ }
282
+ .formula-input {
283
+ @apply --flex;
284
+ height: 22px;
285
+ padding: 0 8px;
286
+ border: 1px solid var(--border-color);
287
+ border-radius: 2px;
288
+ background: var(--content-background);
289
+ color: var(--content-color);
290
+ font-family: var(--font-mono, monospace);
291
+ font-size: 12.5px;
292
+ outline: none;
293
+ }
294
+ .formula-input:focus {
295
+ border-color: var(--accent-color);
296
+ }
297
+ .sheet-scroller {
298
+ @apply --flex;
299
+ overflow: auto;
300
+ background: var(--content-background);
301
+ position: relative;
302
+ }
303
+ table.xlsx-grid {
304
+ border-collapse: collapse;
305
+ table-layout: fixed;
306
+ user-select: none;
307
+ }
308
+ table.xlsx-grid th,
309
+ table.xlsx-grid td {
310
+ border: 1px solid var(--subtle-border, #d4d4d8);
311
+ height: 24px;
312
+ padding: 0 6px;
313
+ font-size: 12.5px;
314
+ box-sizing: border-box;
315
+ overflow: hidden;
316
+ text-overflow: ellipsis;
317
+ white-space: nowrap;
318
+ }
319
+ table.xlsx-grid thead th {
320
+ position: sticky;
321
+ top: 0;
322
+ z-index: 2;
323
+ background: var(--subtle-background);
324
+ color: var(--content-color);
325
+ font-weight: 600;
326
+ text-align: center;
327
+ }
328
+ table.xlsx-grid tbody th.row-num {
329
+ position: sticky;
330
+ left: 0;
331
+ z-index: 1;
332
+ width: 42px;
333
+ min-width: 42px;
334
+ background: var(--subtle-background);
335
+ color: var(--muted-color);
336
+ font-weight: 500;
337
+ text-align: center;
338
+ }
339
+ table.xlsx-grid td.xlsx-cell {
340
+ background: var(--content-background);
341
+ color: var(--content-color);
342
+ cursor: cell;
343
+ position: relative;
344
+ }
345
+ table.xlsx-grid td.xlsx-cell[in-range] {
346
+ background: color-mix(in oklch, var(--accent-color) 12%, var(--content-background));
347
+ }
348
+ table.xlsx-grid td.xlsx-cell[active] {
349
+ outline: 2px solid var(--accent-color);
350
+ outline-offset: -2px;
351
+ z-index: 1;
352
+ }
353
+ .cell-inline-editor {
354
+ width: 100%;
355
+ height: 100%;
356
+ border: none;
357
+ padding: 0;
358
+ margin: 0;
359
+ background: transparent;
360
+ color: inherit;
361
+ font: inherit;
362
+ outline: none;
363
+ }
364
+ .sheet-footer {
365
+ @apply --horizontal;
366
+ @apply --light;
367
+ align-items: center;
368
+ justify-content: space-between;
369
+ min-height: 28px;
370
+ padding: 0 10px;
371
+ border-top: 1px solid var(--border-color);
372
+ flex-shrink: 0;
373
+ user-select: none;
374
+ }
375
+ .sheet-tabs {
376
+ @apply --horizontal;
377
+ align-items: center;
378
+ gap: 4px;
379
+ }
380
+ .sheet-tab {
381
+ padding: 4px 12px;
382
+ border: none;
383
+ border-radius: 7px;
384
+ background: transparent;
385
+ color: var(--content-color);
386
+ opacity: 0.78;
387
+ font-size: 12.5px;
388
+ cursor: pointer;
389
+ transition: background-color var(--duration-fast) var(--easing),
390
+ box-shadow var(--duration-fast) var(--easing),
391
+ opacity var(--duration-fast) var(--easing);
392
+ }
393
+ .sheet-tab:hover {
394
+ opacity: 1;
395
+ background: color-mix(in oklch, var(--content-color) 6%, transparent);
396
+ }
397
+ .sheet-tab[active] {
398
+ opacity: 1;
399
+ background: var(--content-background);
400
+ color: var(--accent-color);
401
+ box-shadow: var(--elevation-1);
402
+ font-weight: 600;
403
+ }
404
+ .sheet-stats {
405
+ font-size: 12px;
406
+ color: var(--muted-color);
407
+ display: flex;
408
+ gap: 14px;
409
+ }
410
+
411
+ /* --- ДОКУМЕНТ WORD (.docx) --- */
412
+ .docx-workspace {
413
+ @apply --flex;
414
+ overflow: auto;
415
+ background: var(--subtle-background);
416
+ padding: 24px 16px;
417
+ display: flex;
418
+ justify-content: center;
419
+ align-items: flex-start;
420
+ }
421
+ .docx-page {
422
+ width: 794px;
423
+ min-height: 1123px;
424
+ padding: 64px 72px;
425
+ background: #ffffff;
426
+ color: #111827;
427
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
428
+ border: 1px solid var(--border-color);
429
+ box-sizing: border-box;
430
+ outline: none;
431
+ line-height: 1.55;
432
+ font-size: 12pt;
433
+ font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
434
+ }
435
+ .docx-page h1 { font-size: 20pt; margin: 12pt 0 6pt; }
436
+ .docx-page h2 { font-size: 16pt; margin: 10pt 0 5pt; }
437
+ .docx-page h3 { font-size: 13.5pt; margin: 8pt 0 4pt; }
438
+ .docx-page p { margin: 0 0 8pt; }
439
+ .docx-page table {
440
+ width: 100%;
441
+ border-collapse: collapse;
442
+ margin: 8pt 0;
443
+ }
444
+ .docx-page table td,
445
+ .docx-page table th {
446
+ border: 1px solid #9ca3af;
447
+ padding: 6px 8px;
448
+ min-width: 40px;
449
+ }
450
+ .docx-page hr.page-break {
451
+ border: none;
452
+ border-top: 2px dashed #9ca3af;
453
+ margin: 24px 0;
454
+ }
455
+
456
+ /* --- ПРЕЗЕНТАЦИЯ POWERPOINT (.pptx) --- */
457
+ .pptx-workspace {
458
+ @apply --flex;
459
+ @apply --horizontal;
460
+ overflow: hidden;
461
+ background: var(--subtle-background);
462
+ }
463
+ .pptx-sidebar {
464
+ width: 200px;
465
+ border-right: 1px solid var(--border-color);
466
+ background: var(--content-background);
467
+ overflow-y: auto;
468
+ padding: 10px;
469
+ display: flex;
470
+ flex-direction: column;
471
+ gap: 10px;
472
+ flex-shrink: 0;
473
+ }
474
+ .slide-thumb {
475
+ border: 2px solid var(--border-color);
476
+ border-radius: 4px;
477
+ padding: 6px;
478
+ background: #fff;
479
+ color: #1e293b;
480
+ cursor: pointer;
481
+ user-select: none;
482
+ min-height: 92px;
483
+ display: flex;
484
+ flex-direction: column;
485
+ justify-content: space-between;
486
+ }
487
+ .slide-thumb[active] {
488
+ border-color: var(--accent-color);
489
+ box-shadow: 0 0 0 2px var(--accent-soft);
490
+ }
491
+ .slide-thumb-num {
492
+ font-size: 11px;
493
+ font-weight: 700;
494
+ color: #64748b;
495
+ }
496
+ .slide-thumb-title {
497
+ font-size: 12px;
498
+ font-weight: 600;
499
+ overflow: hidden;
500
+ text-overflow: ellipsis;
501
+ white-space: nowrap;
502
+ }
503
+ .pptx-stage-wrap {
504
+ @apply --flex;
505
+ overflow: auto;
506
+ display: flex;
507
+ align-items: center;
508
+ justify-content: center;
509
+ padding: 24px;
510
+ }
511
+ .pptx-canvas {
512
+ width: 960px;
513
+ height: 540px;
514
+ position: relative;
515
+ background: #ffffff;
516
+ box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
517
+ border: 1px solid var(--border-color);
518
+ overflow: hidden;
519
+ flex-shrink: 0;
520
+ }
521
+ .pptx-presentation-fullscreen {
522
+ position: fixed;
523
+ inset: 0;
524
+ z-index: 9999;
525
+ background: #000;
526
+ display: flex;
527
+ align-items: center;
528
+ justify-content: center;
529
+ }
530
+ .pptx-el {
531
+ position: absolute;
532
+ box-sizing: border-box;
533
+ padding: 4px 6px;
534
+ border: 1px solid transparent;
535
+ cursor: move;
536
+ outline: none;
537
+ white-space: pre-wrap;
538
+ line-height: 1.3;
539
+ overflow: visible;
540
+ }
541
+ .pptx-el:hover {
542
+ border-color: #94a3b8;
543
+ }
544
+ .pptx-el[selected] {
545
+ border: 2px solid var(--accent-color);
546
+ }
547
+ @media print {
548
+ .office-toolbar, .formula-bar, .sheet-footer, .pptx-sidebar {
549
+ display: none !important;
550
+ }
551
+ .docx-workspace {
552
+ padding: 0 !important;
553
+ background: #fff !important;
554
+ }
555
+ .docx-page {
556
+ box-shadow: none !important;
557
+ border: none !important;
558
+ width: 100% !important;
559
+ padding: 0 !important;
560
+ }
561
+ }
562
+ </style>
563
+
564
+ <!-- Единая панель инструментов -->
565
+ <div class="office-toolbar">
566
+ <!-- Инструменты документа Word -->
567
+ <div class="tb-group" ~if="kind === 'document'">
568
+ <select class="tb-select" @change="onDocFormatBlockChange($event)">
569
+ <option value="">Стиль абзаца…</option>
570
+ <option value="P">Обычный текст</option>
571
+ <option value="H1">Заголовок 1</option>
572
+ <option value="H2">Заголовок 2</option>
573
+ <option value="H3">Заголовок 3</option>
574
+ </select>
575
+ <select class="tb-select" @change="execDocCmd('fontName', $event.target.value, $event)">
576
+ <option value="Inter, Segoe UI, Arial, sans-serif">Sans-serif (Inter / Arial)</option>
577
+ <option value="Times New Roman, serif">Times New Roman</option>
578
+ <option value="Georgia, serif">Georgia</option>
579
+ <option value="Courier New, monospace">Courier New</option>
580
+ </select>
581
+ <div class="tb-sep"></div>
582
+ <button class="tb-btn" title="Жирный (Ctrl+B)" @click="execDocCmd('bold')"><b>Ж</b></button>
583
+ <button class="tb-btn" title="Курсив (Ctrl+I)" @click="execDocCmd('italic')"><i>К</i></button>
584
+ <button class="tb-btn" title="Подчёркнутый (Ctrl+U)" @click="execDocCmd('underline')"><u>Ч</u></button>
585
+ <button class="tb-btn" title="Зачёркнутый" @click="execDocCmd('strikeThrough')"><s>S</s></button>
586
+ <input type="color" class="tb-color" title="Цвет текста" value="#111827" @input="execDocCmd('foreColor', $event.target.value, $event)">
587
+ <div class="tb-sep"></div>
588
+ <button class="tb-btn" title="По левому краю" @click="execDocCmd('justifyLeft')">⇤</button>
589
+ <button class="tb-btn" title="По центру" @click="execDocCmd('justifyCenter')">↔</button>
590
+ <button class="tb-btn" title="По правому краю" @click="execDocCmd('justifyRight')">⇥</button>
591
+ <button class="tb-btn" title="По ширине" @click="execDocCmd('justifyFull')">≡</button>
592
+ <div class="tb-sep"></div>
593
+ <button class="tb-btn" title="Маркированный список" @click="execDocCmd('insertUnorderedList')">• Список</button>
594
+ <button class="tb-btn" title="Нумерованный список" @click="execDocCmd('insertOrderedList')">1. Список</button>
595
+ <button class="tb-btn" title="Вставить таблицу 3×3" @click="insertDocTable()">⊞ Таблица</button>
596
+ <button class="tb-btn" title="Разрыв страницы" @click="insertDocPageBreak()">⎯ Страница</button>
597
+ </div>
598
+
599
+ <!-- Инструменты таблицы Excel -->
600
+ <div class="tb-group" ~if="kind === 'spreadsheet'">
601
+ <button class="tb-btn" :active="activeCellObj?.bold" title="Жирный" @click="toggleCellStyle('bold')"><b>Ж</b></button>
602
+ <button class="tb-btn" :active="activeCellObj?.italic" title="Курсив" @click="toggleCellStyle('italic')"><i>К</i></button>
603
+ <div class="tb-sep"></div>
604
+ <button class="tb-btn" :active="activeCellObj?.align === 'left'" title="По левому краю" @click="setCellStyle('align', 'left')">⇤</button>
605
+ <button class="tb-btn" :active="activeCellObj?.align === 'center'" title="По центру" @click="setCellStyle('align', 'center')">↔</button>
606
+ <button class="tb-btn" :active="activeCellObj?.align === 'right'" title="По правому краю" @click="setCellStyle('align', 'right')">⇥</button>
607
+ <div class="tb-sep"></div>
608
+ <select class="tb-select" title="Формат чисел" :value="activeCellObj?.numFmt || ''" @change="setCellStyle('numFmt', $event.target.value, $event)">
609
+ <option value="">Общий формат</option>
610
+ <option value="number">1 234,56</option>
611
+ <option value="currency">1 234,56 ₽</option>
612
+ <option value="percent">12,3%</option>
613
+ </select>
614
+ <input type="color" class="tb-color" title="Цвет текста ячейки" :value="activeCellObj?.color || '#111827'" @input="setCellStyle('color', $event.target.value, $event)">
615
+ <input type="color" class="tb-color" title="Цвет фона ячейки" :value="activeCellObj?.bg || '#ffffff'" @input="setCellStyle('bg', $event.target.value, $event)">
616
+ <div class="tb-sep"></div>
617
+ <button class="tb-btn" title="Объединить / разъединить выделенные ячейки" @click="toggleMergeSelected()">⊞ Объединить</button>
618
+ <button class="tb-btn" title="Автосумма (SUM)" @click="insertAutoSum()">Σ Сумма</button>
619
+ <div class="tb-sep"></div>
620
+ <button class="tb-btn" title="Вставить строку ниже" @click="insertSheetRow()">+ Строка</button>
621
+ <button class="tb-btn" title="Удалить текущую строку" @click="deleteSheetRow()">− Строка</button>
622
+ <button class="tb-btn" title="Вставить колонку справа" @click="insertSheetCol()">+ Колонка</button>
623
+ </div>
624
+
625
+ <!-- Инструменты презентации PowerPoint -->
626
+ <div class="tb-group" ~if="kind === 'presentation'">
627
+ <button class="tb-btn" @click="addSlide()">+ Слайд</button>
628
+ <button class="tb-btn" @click="duplicateSlide()">⧉ Дублировать</button>
629
+ <button class="tb-btn" @click="deleteSlide()">✕ Удалить слайд</button>
630
+ <div class="tb-sep"></div>
631
+ <button class="tb-btn" @click="addSlideTextElement()">+ Текстовый блок</button>
632
+ <button class="tb-btn" ~if="selectedSlideEl" @click="deleteSlideElement()">− Удалить блок</button>
633
+ <div class="tb-group" ~if="selectedSlideEl">
634
+ <div class="tb-sep"></div>
635
+ <button class="tb-btn" :active="selectedSlideEl.bold" @click="toggleSlideElProp('bold')"><b>Ж</b></button>
636
+ <button class="tb-btn" :active="selectedSlideEl.italic" @click="toggleSlideElProp('italic')"><i>К</i></button>
637
+ <select class="tb-select" :value="String(selectedSlideEl.fontSize || 22)" @change="setSlideElProp('fontSize', Number($event.target.value), $event)">
638
+ <option value="14">14 px</option>
639
+ <option value="18">18 px</option>
640
+ <option value="22">22 px</option>
641
+ <option value="28">28 px</option>
642
+ <option value="36">36 px</option>
643
+ <option value="48">48 px</option>
644
+ </select>
645
+ <button class="tb-btn" :active="selectedSlideEl.align === 'left'" @click="setSlideElProp('align', 'left')">⇤</button>
646
+ <button class="tb-btn" :active="selectedSlideEl.align === 'center'" @click="setSlideElProp('align', 'center')">↔</button>
647
+ <button class="tb-btn" :active="selectedSlideEl.align === 'right'" @click="setSlideElProp('align', 'right')">⇥</button>
648
+ <input type="color" class="tb-color" title="Цвет текста" :value="selectedSlideEl.color || '#1e293b'" @input="setSlideElProp('color', $event.target.value, $event)">
649
+ <input type="color" class="tb-color" title="Заливка блока" :value="selectedSlideEl.fill && selectedSlideEl.fill !== 'transparent' ? selectedSlideEl.fill : '#ffffff'" @input="setSlideElProp('fill', $event.target.value, $event)">
650
+ </div>
651
+ <div class="tb-sep"></div>
652
+ <button class="tb-btn" @click="startSlideShow()">▶ Показ слайдов</button>
653
+ </div>
654
+ </div>
655
+
656
+ <!-- 1. РЕЖИМ ТАБЛИЦЫ (.xlsx / .xls / .csv) -->
657
+ <div class="office-view-wrap" ~if="kind === 'spreadsheet'">
658
+ <div class="formula-bar">
659
+ <div class="cell-addr-box">{{activeCellAddr}}</div>
660
+ <span class="fx-label">fx</span>
661
+ <input class="formula-input" type="text" placeholder="Значение или формула (=SUM(A1:A10), =A1*B1)..." :value="formulaInputValue" @input="onFormulaInput($event)" @keydown="onFormulaKeyDown($event)">
662
+ </div>
663
+ <div class="sheet-scroller" @scroll="onSheetScroll($event)">
664
+ <table class="xlsx-grid">
665
+ <thead>
666
+ <tr>
667
+ <th style="width:42px;min-width:42px;"></th>
668
+ <th ~for="colHeaders" ~style="{width: $for.item.width + 'px', minWidth: $for.item.width + 'px'}">{{$for.item.label}}</th>
669
+ </tr>
670
+ </thead>
671
+ <tbody>
672
+ <tr ~for="gridRows" ~style="{height: '24px'}">
673
+ <th class="row-num">{{$for.item.rowNum}}</th>
674
+ <td ~for="$for.item.cells"
675
+ class="xlsx-cell"
676
+ :col-span="$for.$for.item.colSpan"
677
+ :row-span="$for.$for.item.rowSpan"
678
+ :active="$for.$for.item.isActive"
679
+ :in-range="$for.$for.item.inRange"
680
+ :title="$for.$for.item.display"
681
+ ~style="$for.$for.item.styleStr"
682
+ @mousedown="onCellMouseDown($for.$for.item, $event)"
683
+ @mouseenter="onCellMouseEnter($for.$for.item, $event)"
684
+ @dblclick="startInlineEdit($for.$for.item)">
685
+ <input ~if="editingCoord === $for.$for.item.coord" class="cell-inline-editor" type="text" :value="formulaInputValue" @input="onFormulaInput($event)" @blur="commitInlineEdit()" @keydown="onInlineEditorKeyDown($event)">
686
+ <span ~if="editingCoord !== $for.$for.item.coord">{{$for.$for.item.display}}</span>
687
+ </td>
688
+ </tr>
689
+ </tbody>
690
+ </table>
691
+ </div>
692
+ <div class="sheet-footer">
693
+ <div class="sheet-tabs">
694
+ <div class="sheet-tab" ~for="sheets" :active="$for.index === activeSheetIdx" @click="selectSheet($for.index)" @dblclick="renameSheet($for.index)">
695
+ {{$for.item.name}}
696
+ </div>
697
+ <button class="tb-btn" title="Добавить лист" @click="addSheet()">+</button>
698
+ </div>
699
+ <div class="sheet-stats">
700
+ <span>Кол-во: <b>{{selectionStats.count}}</b></span>
701
+ <span ~if="selectionStats.numCount">Среднее: <b>{{selectionStats.avg}}</b></span>
702
+ <span ~if="selectionStats.numCount">Сумма: <b>{{selectionStats.sum}}</b></span>
703
+ </div>
704
+ </div>
705
+ </div>
706
+
707
+ <!-- 2. РЕЖИМ ДОКУМЕНТА (.docx / .rtf) -->
708
+ <div class="office-view-wrap" ~if="kind === 'document'">
709
+ <div class="docx-workspace">
710
+ <div id="docxPage" class="docx-page" contenteditable="true" spellcheck="true" @input="onDocxInput($event)"></div>
711
+ </div>
712
+ </div>
713
+
714
+ <!-- 3. РЕЖИМ ПРЕЗЕНТАЦИИ (.pptx) -->
715
+ <div class="office-view-wrap" ~if="kind === 'presentation'">
716
+ <div class="pptx-workspace">
717
+ <div class="pptx-sidebar">
718
+ <div class="slide-thumb" ~for="slides" :active="$for.index === activeSlideIdx" @click="selectSlide($for.index)">
719
+ <div class="slide-thumb-num">Слайд {{$for.index + 1}}</div>
720
+ <div class="slide-thumb-title">{{$for.item.title || ('Слайд ' + ($for.index + 1))}}</div>
721
+ <div style="font-size:10px;color:#94a3b8;">Элементов: {{$for.item.elements?.length || 0}}</div>
722
+ </div>
723
+ </div>
724
+ <div class="pptx-stage-wrap" @mousedown="onStageBackgroundClick($event)">
725
+ <div class="pptx-canvas" ~style="{background: currentSlide?.background || '#ffffff'}" @mousemove="onSlideMouseMove($event)" @mouseup="onSlideMouseUp()">
726
+ <div class="pptx-el"
727
+ ~for="currentSlideElements"
728
+ :selected="selectedSlideElId === $for.item.id"
729
+ ~style="slideElStyle($for.item)"
730
+ contenteditable="true"
731
+ @mousedown.stop="onSlideElMouseDown($for.item, $event)"
732
+ @input="onSlideElInput($for.item, $event)">{{$for.item.text}}</div>
733
+ </div>
734
+ </div>
735
+ </div>
736
+ <div class="pptx-presentation-fullscreen" ~if="slideshowActive" @click="nextSlideShow()" @contextmenu.prevent="exitSlideShow()">
737
+ <div class="pptx-canvas" ~style="{background: currentSlide?.background || '#ffffff', transform: 'scale(1.35)'}">
738
+ <div class="pptx-el" ~for="currentSlideElements" ~style="slideElStyle($for.item)" style="cursor:default;">{{$for.item.text}}</div>
739
+ </div>
740
+ </div>
741
+ </div>
742
+ `,
743
+ hostView: null,
744
+ inline: {
745
+ $attr: true,
746
+ $def: false,
747
+ $type: Boolean
748
+ },
749
+ kind: 'document',
750
+ ext: 'docx',
751
+ isChanged: false,
752
+ saving: false,
753
+ statusMessage: '',
754
+ // Состояние таблиц (.xlsx)
755
+ sheets: [],
756
+ activeSheetIdx: 0,
757
+ activeRow: 0,
758
+ activeCol: 0,
759
+ selStartRow: 0,
760
+ selStartCol: 0,
761
+ selEndRow: 0,
762
+ selEndCol: 0,
763
+ _isSelectingCells: false,
764
+ editingCoord: '',
765
+ formulaInputValue: '',
766
+ visibleRowLimit: 120,
767
+ _gridTick: 0,
768
+ // Состояние документа (.docx)
769
+ docHtml: '<p><br></p>',
770
+ pageSetup: null,
771
+ // Состояние презентации (.pptx)
772
+ slides: [],
773
+ activeSlideIdx: 0,
774
+ selectedSlideElId: '',
775
+ slideshowActive: false,
776
+ _dragState: null,
777
+ $item: {
778
+ $def: null,
779
+ set(n) {
780
+ if (n) this.loadOfficeItem(n);
781
+ }
782
+ },
783
+ $listeners: {
784
+ keydown(e) {
785
+ if ((e.ctrlKey || e.metaKey) && (e.key === 's' || e.key === 'S' || e.key === 'ы' || e.key === 'Ы')) {
786
+ e.preventDefault();
787
+ e.stopPropagation();
788
+ this.save();
789
+ return;
790
+ }
791
+ if (this.slideshowActive) {
792
+ if (e.key === 'Escape') {
793
+ e.preventDefault();
794
+ this.exitSlideShow();
795
+ } else if (e.key === 'ArrowRight' || e.key === ' ') {
796
+ e.preventDefault();
797
+ this.nextSlideShow();
798
+ } else if (e.key === 'ArrowLeft') {
799
+ e.preventDefault();
800
+ this.prevSlideShow();
801
+ }
802
+ return;
803
+ }
804
+ if (this.kind === 'spreadsheet' && !this.editingCoord && e.target?.tagName !== 'INPUT' && e.target?.tagName !== 'SELECT') {
805
+ if (e.key === 'ArrowDown' || e.key === 'Enter') {
806
+ e.preventDefault();
807
+ this.moveActiveCell(1, 0, e.shiftKey);
808
+ } else if (e.key === 'ArrowUp') {
809
+ e.preventDefault();
810
+ this.moveActiveCell(-1, 0, e.shiftKey);
811
+ } else if (e.key === 'ArrowRight' || e.key === 'Tab') {
812
+ e.preventDefault();
813
+ this.moveActiveCell(0, 1, e.shiftKey);
814
+ } else if (e.key === 'ArrowLeft') {
815
+ e.preventDefault();
816
+ this.moveActiveCell(0, -1, e.shiftKey);
817
+ } else if (e.key === 'Delete' || e.key === 'Backspace') {
818
+ e.preventDefault();
819
+ this.clearSelectedCells();
820
+ } else if (e.key === 'F2') {
821
+ e.preventDefault();
822
+ this.startInlineEdit({
823
+ r: this.activeRow,
824
+ c: this.activeCol,
825
+ coord: `${this.activeRow}:${this.activeCol}`
826
+ });
827
+ }
828
+ }
829
+ }
830
+ },
831
+ get kindLabel() {
832
+ if (this.kind === 'spreadsheet') return 'ТАБЛИЦА EXCEL';
833
+ if (this.kind === 'presentation') return 'ПРЕЗЕНТАЦИЯ';
834
+ return 'ДОКУМЕНТ WORD';
835
+ },
836
+ get statusText() {
837
+ if (this.saving) return 'Сохранение…';
838
+ if (this.statusMessage) return this.statusMessage;
839
+ return this.isChanged ? '● Есть несохранённые изменения' : '✓ Сохранено';
840
+ },
841
+ markDirty(dirty = true) {
842
+ if (dirty && this._loadingOffice) return;
843
+ this.isChanged = Boolean(dirty);
844
+ if (this.isChanged) this.statusMessage = '';
845
+ if (this.$item) this.$item.isChanged = this.isChanged;
846
+ if (this.hostView) this.hostView.isChanged = this.isChanged;
847
+ const formHost = this._findFormHost();
848
+ if (formHost) {
849
+ formHost.focusedStateVersion = (formHost.focusedStateVersion || 0) + 1;
850
+ formHost.syncFromView?.(this.hostView || formHost.view_control);
851
+ }
852
+ },
853
+ _findFormHost() {
854
+ for (let p = this.parentElement || this.domHost || this.getRootNode?.()?.host; p; p = p.parentElement || p.domHost || p.getRootNode?.()?.host) {
855
+ if (p.localName === 'work-form' || typeof p.syncFromView === 'function') return p;
856
+ }
857
+ return null;
858
+ },
859
+ attached() {
860
+ if (Object.prototype.hasOwnProperty.call(this, '$item')) {
861
+ const pre = this.$item;
862
+ delete this.$item;
863
+ this.$item = pre;
864
+ }
865
+ if (this.$item && this._loadedItem !== this.$item) this.loadOfficeItem(this.$item);
866
+ this._syncDocxDom();
867
+ },
868
+ _syncDocxDom() {
869
+ const apply = () => {
870
+ if (this.kind !== 'document') return true;
871
+ const page = this.$?.('#docxPage');
872
+ if (!page) return false;
873
+ if (page.innerHTML !== this.docHtml) page.innerHTML = this.docHtml;
874
+ return true;
875
+ };
876
+ if (apply()) return;
877
+ for (const delay of [10, 40, 120]) {
878
+ this.async(() => apply(), delay);
879
+ }
880
+ },
881
+ async loadOfficeItem(rawItem) {
882
+ this._loadedItem = rawItem;
883
+ let item = await Promise.resolve(rawItem);
884
+ if (Array.isArray(item)) item = item.at(-1) || null;
885
+ if (!item) return;
886
+ const ext = String(item.ext || item.id?.split('.').pop() || 'docx').toLowerCase();
887
+ this.ext = ext;
888
+ try {
889
+ const res = await item.fetch('office_load');
890
+ this.applyLoadedModel(res || {});
891
+ } catch (err) {
892
+ console.warn('[office-editor] load error:', err);
893
+ this.applyLoadedModel({
894
+ kind: 'document',
895
+ ext,
896
+ html: '<p><br></p>'
897
+ });
898
+ }
899
+ },
900
+ applyLoadedModel(data = {}) {
901
+ this._loadingOffice = true;
902
+ try {
903
+ this.kind = data.kind || 'document';
904
+ if (this.kind === 'spreadsheet') {
905
+ this.sheets = Array.isArray(data.sheets) && data.sheets.length ? data.sheets : [{
906
+ name: 'Лист1',
907
+ rowCount: 30,
908
+ colCount: 12,
909
+ colWidths: Array(12).fill(110),
910
+ merges: [],
911
+ cells: {}
912
+ }];
913
+ this.activeSheetIdx = 0;
914
+ this.visibleRowLimit = 120;
915
+ this.setActiveCell(0, 0);
916
+ this._gridTick++;
917
+ } else if (this.kind === 'presentation') {
918
+ this.slides = Array.isArray(data.slides) && data.slides.length ? data.slides : [{
919
+ id: 'slide_1',
920
+ title: 'Слайд 1',
921
+ background: '#ffffff',
922
+ elements: []
923
+ }];
924
+ this.activeSlideIdx = 0;
925
+ this.selectedSlideElId = '';
926
+ } else {
927
+ this.docHtml = String(data.html || '<p><br></p>');
928
+ this.pageSetup = data.pageSetup || {
929
+ widthMm: 210,
930
+ heightMm: 297,
931
+ marginMm: 20
932
+ };
933
+ this._syncDocxDom();
934
+ }
935
+ this.markDirty(false);
936
+ } finally {
937
+ this.async(() => {
938
+ this._loadingOffice = false;
939
+ this.markDirty(false);
940
+ }, 50);
941
+ }
942
+ },
943
+ buildSavePayload() {
944
+ if (this.kind === 'spreadsheet') {
945
+ return {
946
+ kind: 'spreadsheet',
947
+ ext: this.ext,
948
+ sheets: this.sheets
949
+ };
950
+ }
951
+ if (this.kind === 'presentation') {
952
+ return {
953
+ kind: 'presentation',
954
+ ext: this.ext,
955
+ slides: this.slides
956
+ };
957
+ }
958
+ const page = this.$?.('#docxPage');
959
+ const html = page ? page.innerHTML : this.docHtml;
960
+ this.docHtml = html;
961
+ return {
962
+ kind: 'document',
963
+ ext: this.ext,
964
+ html,
965
+ pageSetup: this.pageSetup
966
+ };
967
+ },
968
+ async save() {
969
+ if (!this.$item || this.saving) return false;
970
+ if (this.editingCoord) this.commitInlineEdit();
971
+ this.saving = true;
972
+ try {
973
+ const payload = this.buildSavePayload();
974
+ await this.$item.fetch('office_save', {}, JSON.stringify(payload));
975
+ this.markDirty(false);
976
+ this.statusMessage = '✓ Сохранено';
977
+ return true;
978
+ } catch (err) {
979
+ this.statusMessage = 'Ошибка сохранения: ' + (err?.message || err);
980
+ throw err;
981
+ } finally {
982
+ this.saving = false;
983
+ }
984
+ },
985
+ // ========================================================================
986
+ // Методы табличного редактора (.xlsx)
987
+ // ========================================================================
988
+
989
+ get currentSheet() {
990
+ void this._gridTick;
991
+ return this.sheets?.[this.activeSheetIdx] || null;
992
+ },
993
+ get activeCellAddr() {
994
+ const r1 = Math.min(this.selStartRow, this.selEndRow);
995
+ const r2 = Math.max(this.selStartRow, this.selEndRow);
996
+ const c1 = Math.min(this.selStartCol, this.selEndCol);
997
+ const c2 = Math.max(this.selStartCol, this.selEndCol);
998
+ const a = `${colIndexToLetters(c1)}${r1 + 1}`;
999
+ if (r1 === r2 && c1 === c2) return a;
1000
+ return `${a}:${colIndexToLetters(c2)}${r2 + 1}`;
1001
+ },
1002
+ get activeCellObj() {
1003
+ void this._gridTick;
1004
+ const sh = this.currentSheet;
1005
+ return sh?.cells?.[`${this.activeRow}:${this.activeCol}`] || null;
1006
+ },
1007
+ get colHeaders() {
1008
+ void this._gridTick;
1009
+ const sh = this.currentSheet;
1010
+ const count = sh?.colCount || 12;
1011
+ const widths = sh?.colWidths || [];
1012
+ const cols = [];
1013
+ for (let c = 0; c < count; c++) {
1014
+ cols.push({
1015
+ col: c,
1016
+ label: colIndexToLetters(c),
1017
+ width: widths[c] || 110
1018
+ });
1019
+ }
1020
+ return cols;
1021
+ },
1022
+ formatCellDisplay(cell, cellsMap) {
1023
+ if (!cell) return '';
1024
+ let val = cell.f ? evaluateSheetFormula(cell.f, cellsMap) : cell.v ?? '';
1025
+ if (val === '' || val === null || val === undefined) return '';
1026
+ const num = typeof val === 'number' ? val : typeof val === 'string' && /^-?\d+(\.\d+)?$/.test(val.trim()) ? Number(val) : NaN;
1027
+ if (Number.isFinite(num)) {
1028
+ if (cell.numFmt === 'currency') return num.toLocaleString('ru-RU', {
1029
+ minimumFractionDigits: 2,
1030
+ maximumFractionDigits: 2
1031
+ }) + ' ₽';
1032
+ if (cell.numFmt === 'number') return num.toLocaleString('ru-RU', {
1033
+ minimumFractionDigits: 2,
1034
+ maximumFractionDigits: 2
1035
+ });
1036
+ if (cell.numFmt === 'percent') return (num * 100).toLocaleString('ru-RU', {
1037
+ maximumFractionDigits: 1
1038
+ }) + '%';
1039
+ }
1040
+ return String(val);
1041
+ },
1042
+ get gridRows() {
1043
+ void this._gridTick;
1044
+ const sh = this.currentSheet;
1045
+ if (!sh) return [];
1046
+ const totalRows = sh.rowCount || 30;
1047
+ const rCount = Math.min(totalRows, Math.max(30, this.visibleRowLimit || 120));
1048
+ const cCount = sh.colCount || 12;
1049
+ const cellsMap = sh.cells || {};
1050
+ const merges = sh.merges || [];
1051
+ const mergeMap = new Map();
1052
+ const hiddenSet = new Set();
1053
+ for (const m of merges) {
1054
+ if (m.s.r >= rCount) continue;
1055
+ const endR = Math.min(rCount - 1, m.e.r);
1056
+ const rs = endR - m.s.r + 1;
1057
+ const cs = m.e.c - m.s.c + 1;
1058
+ if (rs > 1 || cs > 1) {
1059
+ mergeMap.set(`${m.s.r}:${m.s.c}`, {
1060
+ rowSpan: rs,
1061
+ colSpan: cs
1062
+ });
1063
+ for (let r = m.s.r; r <= endR; r++) {
1064
+ for (let c = m.s.c; c <= m.e.c; c++) {
1065
+ if (r !== m.s.r || c !== m.s.c) hiddenSet.add(`${r}:${c}`);
1066
+ }
1067
+ }
1068
+ }
1069
+ }
1070
+ const rMin = Math.min(this.selStartRow, this.selEndRow);
1071
+ const rMax = Math.max(this.selStartRow, this.selEndRow);
1072
+ const cMin = Math.min(this.selStartCol, this.selEndCol);
1073
+ const cMax = Math.max(this.selStartCol, this.selEndCol);
1074
+ const rows = [];
1075
+ for (let r = 0; r < rCount; r++) {
1076
+ const rowCells = [];
1077
+ for (let c = 0; c < cCount; c++) {
1078
+ const coord = `${r}:${c}`;
1079
+ if (hiddenSet.has(coord)) continue;
1080
+ const cell = cellsMap[coord] || null;
1081
+ const mInfo = mergeMap.get(coord);
1082
+ const isActive = r === this.activeRow && c === this.activeCol;
1083
+ const inRange = r >= rMin && r <= rMax && c >= cMin && c <= cMax;
1084
+ const styles = [];
1085
+ if (cell?.bold) styles.push('font-weight:700');
1086
+ if (cell?.italic) styles.push('font-style:italic');
1087
+ if (cell?.align) styles.push(`text-align:${cell.align}`);else if (cell && (cell.t === 'n' || typeof cell.v === 'number')) styles.push('text-align:right');
1088
+ if (cell?.color) styles.push(`color:${cell.color}`);
1089
+ if (cell?.bg && !inRange) styles.push(`background-color:${cell.bg}`);
1090
+ rowCells.push({
1091
+ r,
1092
+ c,
1093
+ coord,
1094
+ hiddenByMerge: hiddenSet.has(coord),
1095
+ rowSpan: mInfo?.rowSpan || 1,
1096
+ colSpan: mInfo?.colSpan || 1,
1097
+ isActive,
1098
+ inRange,
1099
+ styleStr: styles.join(';'),
1100
+ display: this.formatCellDisplay(cell, cellsMap)
1101
+ });
1102
+ }
1103
+ rows.push({
1104
+ r,
1105
+ rowNum: r + 1,
1106
+ cells: rowCells
1107
+ });
1108
+ }
1109
+ return rows;
1110
+ },
1111
+ get selectionStats() {
1112
+ void this._gridTick;
1113
+ const sh = this.currentSheet;
1114
+ if (!sh) return {
1115
+ count: 0,
1116
+ numCount: 0,
1117
+ sum: '0',
1118
+ avg: '0'
1119
+ };
1120
+ const cellsMap = sh.cells || {};
1121
+ const rMin = Math.min(this.selStartRow, this.selEndRow);
1122
+ const rMax = Math.max(this.selStartRow, this.selEndRow);
1123
+ const cMin = Math.min(this.selStartCol, this.selEndCol);
1124
+ const cMax = Math.max(this.selStartCol, this.selEndCol);
1125
+ let count = 0;
1126
+ let numCount = 0;
1127
+ let sum = 0;
1128
+ for (let r = rMin; r <= rMax; r++) {
1129
+ for (let c = cMin; c <= cMax; c++) {
1130
+ const cell = cellsMap[`${r}:${c}`];
1131
+ if (!cell) continue;
1132
+ const val = cell.f ? evaluateSheetFormula(cell.f, cellsMap) : cell.v;
1133
+ if (val === '' || val === null || val === undefined) continue;
1134
+ count++;
1135
+ const n = typeof val === 'number' ? val : Number(String(val).replace(/\s+/g, '').replace(',', '.'));
1136
+ if (Number.isFinite(n)) {
1137
+ numCount++;
1138
+ sum += n;
1139
+ }
1140
+ }
1141
+ }
1142
+ return {
1143
+ count,
1144
+ numCount,
1145
+ sum: sum.toLocaleString('ru-RU', {
1146
+ maximumFractionDigits: 2
1147
+ }),
1148
+ avg: numCount ? (sum / numCount).toLocaleString('ru-RU', {
1149
+ maximumFractionDigits: 2
1150
+ }) : '0'
1151
+ };
1152
+ },
1153
+ onSheetScroll(e) {
1154
+ const el = e?.target;
1155
+ const sh = this.currentSheet;
1156
+ if (!el || !sh) return;
1157
+ const totalRows = sh.rowCount || 30;
1158
+ if (this.visibleRowLimit >= totalRows) return;
1159
+ if (el.scrollTop + el.clientHeight >= el.scrollHeight - 240) {
1160
+ this.visibleRowLimit = Math.min(totalRows, (this.visibleRowLimit || 120) + 150);
1161
+ this._gridTick++;
1162
+ }
1163
+ },
1164
+ setActiveCell(r, c, extendSelection = false) {
1165
+ const sh = this.currentSheet;
1166
+ const maxR = (sh?.rowCount || 30) - 1;
1167
+ const maxC = (sh?.colCount || 12) - 1;
1168
+ const nr = Math.max(0, Math.min(maxR, r));
1169
+ const nc = Math.max(0, Math.min(maxC, c));
1170
+ if (nr + 10 > (this.visibleRowLimit || 120)) this.visibleRowLimit = Math.min(maxR + 1, nr + 60);
1171
+ this.activeRow = nr;
1172
+ this.activeCol = nc;
1173
+ if (!extendSelection) {
1174
+ this.selStartRow = nr;
1175
+ this.selStartCol = nc;
1176
+ }
1177
+ this.selEndRow = nr;
1178
+ this.selEndCol = nc;
1179
+ const cell = sh?.cells?.[`${nr}:${nc}`];
1180
+ this.formulaInputValue = cell?.f ? `=${cell.f}` : String(cell?.v ?? '');
1181
+ this._gridTick++;
1182
+ },
1183
+ moveActiveCell(dr, dc, extend = false) {
1184
+ if (extend) this.setActiveCell(this.selEndRow + dr, this.selEndCol + dc, true);else this.setActiveCell(this.activeRow + dr, this.activeCol + dc, false);
1185
+ },
1186
+ onCellMouseDown(cellItem, e) {
1187
+ if (this.editingCoord && this.editingCoord !== cellItem.coord) this.commitInlineEdit();
1188
+ this.setActiveCell(cellItem.r, cellItem.c, e?.shiftKey);
1189
+ this._isSelectingCells = true;
1190
+ const up = () => {
1191
+ this._isSelectingCells = false;
1192
+ window.removeEventListener('mouseup', up);
1193
+ };
1194
+ window.addEventListener('mouseup', up);
1195
+ },
1196
+ onCellMouseEnter(cellItem) {
1197
+ if (!this._isSelectingCells) return;
1198
+ this.selEndRow = cellItem.r;
1199
+ this.selEndCol = cellItem.c;
1200
+ this._gridTick++;
1201
+ },
1202
+ startInlineEdit(cellItem) {
1203
+ this.setActiveCell(cellItem.r, cellItem.c);
1204
+ this.editingCoord = cellItem.coord;
1205
+ this._gridTick++;
1206
+ this.async(() => {
1207
+ const inp = this.$?.('.cell-inline-editor');
1208
+ inp?.focus?.();
1209
+ }, 10);
1210
+ },
1211
+ commitInlineEdit() {
1212
+ if (!this.editingCoord) return;
1213
+ this.applyFormulaValueToCell(this.activeRow, this.activeCol, this.formulaInputValue);
1214
+ this.editingCoord = '';
1215
+ this._gridTick++;
1216
+ },
1217
+ onInlineEditorKeyDown(e) {
1218
+ if (e.key === 'Enter') {
1219
+ e.preventDefault();
1220
+ this.commitInlineEdit();
1221
+ this.moveActiveCell(1, 0);
1222
+ } else if (e.key === 'Escape') {
1223
+ e.preventDefault();
1224
+ this.editingCoord = '';
1225
+ this.setActiveCell(this.activeRow, this.activeCol);
1226
+ }
1227
+ },
1228
+ onFormulaInput(e) {
1229
+ if (e && e.isTrusted === false) return;
1230
+ const val = e?.target?.value ?? '';
1231
+ this.formulaInputValue = val;
1232
+ if (!this.editingCoord) this.applyFormulaValueToCell(this.activeRow, this.activeCol, val);
1233
+ },
1234
+ onFormulaKeyDown(e) {
1235
+ if (e.key === 'Enter') {
1236
+ e.preventDefault();
1237
+ this.applyFormulaValueToCell(this.activeRow, this.activeCol, this.formulaInputValue);
1238
+ this.moveActiveCell(1, 0);
1239
+ }
1240
+ },
1241
+ applyFormulaValueToCell(r, c, rawVal) {
1242
+ const sh = this.currentSheet;
1243
+ if (!sh) return;
1244
+ sh.cells ??= {};
1245
+ const coord = `${r}:${c}`;
1246
+ const existing = sh.cells[coord] || {};
1247
+ const str = String(rawVal ?? '');
1248
+ if (str.startsWith('=')) {
1249
+ const f = str.slice(1).trim();
1250
+ const computed = evaluateSheetFormula(f, sh.cells);
1251
+ sh.cells[coord] = {
1252
+ ...existing,
1253
+ f,
1254
+ v: computed,
1255
+ t: typeof computed === 'number' ? 'n' : 's'
1256
+ };
1257
+ } else {
1258
+ const trimmed = str.trim();
1259
+ const num = trimmed !== '' && /^-?\d+([.,]\d+)?$/.test(trimmed) ? Number(trimmed.replace(',', '.')) : NaN;
1260
+ const next = {
1261
+ ...existing
1262
+ };
1263
+ delete next.f;
1264
+ delete next.w;
1265
+ if (Number.isFinite(num)) {
1266
+ next.v = num;
1267
+ next.t = 'n';
1268
+ } else {
1269
+ next.v = str;
1270
+ next.t = 's';
1271
+ }
1272
+ sh.cells[coord] = next;
1273
+ }
1274
+ this.markDirty(true);
1275
+ this._gridTick++;
1276
+ },
1277
+ clearSelectedCells() {
1278
+ const sh = this.currentSheet;
1279
+ if (!sh?.cells) return;
1280
+ const rMin = Math.min(this.selStartRow, this.selEndRow);
1281
+ const rMax = Math.max(this.selStartRow, this.selEndRow);
1282
+ const cMin = Math.min(this.selStartCol, this.selEndCol);
1283
+ const cMax = Math.max(this.selStartCol, this.selEndCol);
1284
+ for (let r = rMin; r <= rMax; r++) {
1285
+ for (let c = cMin; c <= cMax; c++) {
1286
+ const cell = sh.cells[`${r}:${c}`];
1287
+ if (cell) {
1288
+ delete cell.v;
1289
+ delete cell.f;
1290
+ delete cell.w;
1291
+ }
1292
+ }
1293
+ }
1294
+ this.formulaInputValue = '';
1295
+ this.markDirty(true);
1296
+ this._gridTick++;
1297
+ },
1298
+ toggleCellStyle(prop) {
1299
+ const cur = Boolean(this.activeCellObj?.[prop]);
1300
+ this.setCellStyle(prop, !cur);
1301
+ },
1302
+ setCellStyle(prop, val, e) {
1303
+ if (e && e.isTrusted === false) return;
1304
+ const sh = this.currentSheet;
1305
+ if (!sh) return;
1306
+ sh.cells ??= {};
1307
+ const rMin = Math.min(this.selStartRow, this.selEndRow);
1308
+ const rMax = Math.max(this.selStartRow, this.selEndRow);
1309
+ const cMin = Math.min(this.selStartCol, this.selEndCol);
1310
+ const cMax = Math.max(this.selStartCol, this.selEndCol);
1311
+ for (let r = rMin; r <= rMax; r++) {
1312
+ for (let c = cMin; c <= cMax; c++) {
1313
+ const coord = `${r}:${c}`;
1314
+ sh.cells[coord] = {
1315
+ ...(sh.cells[coord] || {
1316
+ v: ''
1317
+ }),
1318
+ [prop]: val
1319
+ };
1320
+ }
1321
+ }
1322
+ this.markDirty(true);
1323
+ this._gridTick++;
1324
+ },
1325
+ toggleMergeSelected() {
1326
+ const sh = this.currentSheet;
1327
+ if (!sh) return;
1328
+ sh.merges ??= [];
1329
+ const r1 = Math.min(this.selStartRow, this.selEndRow);
1330
+ const r2 = Math.max(this.selStartRow, this.selEndRow);
1331
+ const c1 = Math.min(this.selStartCol, this.selEndCol);
1332
+ const c2 = Math.max(this.selStartCol, this.selEndCol);
1333
+ const existingIdx = sh.merges.findIndex(m => m.s.r === r1 && m.s.c === c1 && m.e.r === r2 && m.e.c === c2);
1334
+ if (existingIdx >= 0) {
1335
+ sh.merges.splice(existingIdx, 1);
1336
+ } else if (r1 !== r2 || c1 !== c2) {
1337
+ sh.merges.push({
1338
+ s: {
1339
+ r: r1,
1340
+ c: c1
1341
+ },
1342
+ e: {
1343
+ r: r2,
1344
+ c: c2
1345
+ }
1346
+ });
1347
+ }
1348
+ this.markDirty(true);
1349
+ this._gridTick++;
1350
+ },
1351
+ insertAutoSum() {
1352
+ const sh = this.currentSheet;
1353
+ if (!sh) return;
1354
+ const c = this.activeCol;
1355
+ const r = this.activeRow;
1356
+ const colLet = colIndexToLetters(c);
1357
+ const targetRow = r > 0 ? r : 1;
1358
+ const formula = `=SUM(${colLet}1:${colLet}${targetRow})`;
1359
+ this.formulaInputValue = formula;
1360
+ this.applyFormulaValueToCell(r, c, formula);
1361
+ },
1362
+ insertSheetRow() {
1363
+ const sh = this.currentSheet;
1364
+ if (!sh) return;
1365
+ sh.rowCount = (sh.rowCount || 30) + 1;
1366
+ this.markDirty(true);
1367
+ this._gridTick++;
1368
+ },
1369
+ deleteSheetRow() {
1370
+ const sh = this.currentSheet;
1371
+ if (!sh?.cells) return;
1372
+ const targetR = this.activeRow;
1373
+ const nextCells = {};
1374
+ for (const [coord, val] of Object.entries(sh.cells)) {
1375
+ const [rStr, cStr] = coord.split(':');
1376
+ const r = Number(rStr);
1377
+ const c = Number(cStr);
1378
+ if (r === targetR) continue;
1379
+ const nr = r > targetR ? r - 1 : r;
1380
+ nextCells[`${nr}:${c}`] = val;
1381
+ }
1382
+ sh.cells = nextCells;
1383
+ this.markDirty(true);
1384
+ this._gridTick++;
1385
+ },
1386
+ insertSheetCol() {
1387
+ const sh = this.currentSheet;
1388
+ if (!sh) return;
1389
+ sh.colCount = (sh.colCount || 12) + 1;
1390
+ sh.colWidths ??= [];
1391
+ sh.colWidths.push(110);
1392
+ this.markDirty(true);
1393
+ this._gridTick++;
1394
+ },
1395
+ selectSheet(idx) {
1396
+ if (this.editingCoord) this.commitInlineEdit();
1397
+ this.activeSheetIdx = idx;
1398
+ this.setActiveCell(0, 0);
1399
+ },
1400
+ addSheet() {
1401
+ const num = (this.sheets?.length || 0) + 1;
1402
+ this.sheets.push({
1403
+ name: `Лист${num}`,
1404
+ rowCount: 30,
1405
+ colCount: 12,
1406
+ colWidths: Array(12).fill(110),
1407
+ merges: [],
1408
+ cells: {}
1409
+ });
1410
+ this.activeSheetIdx = this.sheets.length - 1;
1411
+ this.setActiveCell(0, 0);
1412
+ this.markDirty(true);
1413
+ },
1414
+ renameSheet(idx) {
1415
+ const sh = this.sheets?.[idx];
1416
+ if (!sh) return;
1417
+ const next = typeof window.prompt === 'function' ? window.prompt('Название листа:', sh.name) : sh.name;
1418
+ if (next && next.trim()) {
1419
+ sh.name = next.trim().slice(0, 31);
1420
+ this.markDirty(true);
1421
+ this._gridTick++;
1422
+ }
1423
+ },
1424
+ // ========================================================================
1425
+ // Методы редактора документов Word (.docx)
1426
+ // ========================================================================
1427
+
1428
+ onDocxInput(e) {
1429
+ if (e && e.isTrusted === false) return;
1430
+ this.docHtml = e?.target?.innerHTML || '';
1431
+ this.markDirty(true);
1432
+ },
1433
+ execDocCmd(cmd, value = null, e) {
1434
+ if (e && e.isTrusted === false) return;
1435
+ const page = this.$?.('#docxPage');
1436
+ page?.focus?.();
1437
+ try {
1438
+ document.execCommand(cmd, false, value);
1439
+ } catch {/* ignore */}
1440
+ if (page) this.docHtml = page.innerHTML;
1441
+ this.markDirty(true);
1442
+ },
1443
+ onDocFormatBlockChange(e) {
1444
+ if (e && e.isTrusted === false) return;
1445
+ const tag = e?.target?.value || '';
1446
+ if (e?.target) e.target.value = '';
1447
+ this.execDocFormatBlock(tag);
1448
+ },
1449
+ execDocFormatBlock(tag) {
1450
+ if (!tag) return;
1451
+ this.execDocCmd('formatBlock', tag);
1452
+ },
1453
+ insertDocTable() {
1454
+ const tblHtml = `<table class="docx-table"><tbody>
1455
+ <tr><td>Ячейка 1</td><td>Ячейка 2</td><td>Ячейка 3</td></tr>
1456
+ <tr><td><br></td><td><br></td><td><br></td></tr>
1457
+ <tr><td><br></td><td><br></td><td><br></td></tr>
1458
+ </tbody></table><p><br></p>`;
1459
+ this.execDocCmd('insertHTML', tblHtml);
1460
+ },
1461
+ insertDocPageBreak() {
1462
+ this.execDocCmd('insertHTML', '<hr class="page-break"><p><br></p>');
1463
+ },
1464
+ // ========================================================================
1465
+ // Методы редактора презентаций PowerPoint (.pptx)
1466
+ // ========================================================================
1467
+
1468
+ get currentSlide() {
1469
+ return this.slides?.[this.activeSlideIdx] || null;
1470
+ },
1471
+ get currentSlideElements() {
1472
+ return this.currentSlide?.elements || [];
1473
+ },
1474
+ get selectedSlideEl() {
1475
+ return this.currentSlideElements.find(el => el.id === this.selectedSlideElId) || null;
1476
+ },
1477
+ slideElStyle(el) {
1478
+ if (!el) return {};
1479
+ return {
1480
+ left: (el.x || 0) + 'px',
1481
+ top: (el.y || 0) + 'px',
1482
+ width: (el.w || 300) + 'px',
1483
+ minHeight: (el.h || 28) + 'px',
1484
+ fontSize: (el.fontSize || 16) + 'px',
1485
+ fontWeight: el.bold ? '700' : '400',
1486
+ fontStyle: el.italic ? 'italic' : 'normal',
1487
+ textAlign: el.align || 'left',
1488
+ color: el.color || '#1e293b',
1489
+ background: el.fill || 'transparent',
1490
+ zIndex: el.decorative ? '0' : '1',
1491
+ pointerEvents: el.decorative ? 'none' : 'auto'
1492
+ };
1493
+ },
1494
+ selectSlide(idx) {
1495
+ this.activeSlideIdx = idx;
1496
+ this.selectedSlideElId = '';
1497
+ },
1498
+ addSlide() {
1499
+ const n = (this.slides?.length || 0) + 1;
1500
+ const slide = {
1501
+ id: `slide_${Date.now()}`,
1502
+ title: `Слайд ${n}`,
1503
+ background: '#ffffff',
1504
+ elements: [{
1505
+ id: `el_${Date.now()}_1`,
1506
+ type: 'text',
1507
+ x: 80,
1508
+ y: 70,
1509
+ w: 800,
1510
+ h: 70,
1511
+ text: `Заголовок слайда ${n}`,
1512
+ fontSize: 32,
1513
+ bold: true,
1514
+ italic: false,
1515
+ align: 'left',
1516
+ color: '#1e293b',
1517
+ fill: 'transparent'
1518
+ }, {
1519
+ id: `el_${Date.now()}_2`,
1520
+ type: 'text',
1521
+ x: 80,
1522
+ y: 170,
1523
+ w: 800,
1524
+ h: 260,
1525
+ text: '• Ключевой тезис 1\n• Ключевой тезис 2',
1526
+ fontSize: 22,
1527
+ bold: false,
1528
+ italic: false,
1529
+ align: 'left',
1530
+ color: '#334155',
1531
+ fill: 'transparent'
1532
+ }]
1533
+ };
1534
+ this.slides = [...(this.slides || []), slide];
1535
+ this.activeSlideIdx = this.slides.length - 1;
1536
+ this.selectedSlideElId = slide.elements[0].id;
1537
+ this.markDirty(true);
1538
+ },
1539
+ duplicateSlide() {
1540
+ const cur = this.currentSlide;
1541
+ if (!cur) return;
1542
+ const copy = JSON.parse(JSON.stringify(cur));
1543
+ copy.id = `slide_${Date.now()}`;
1544
+ copy.title = (copy.title || 'Слайд') + ' (копия)';
1545
+ copy.elements = (copy.elements || []).map((el, i) => ({
1546
+ ...el,
1547
+ id: `el_${Date.now()}_${i}`
1548
+ }));
1549
+ const next = [...this.slides];
1550
+ next.splice(this.activeSlideIdx + 1, 0, copy);
1551
+ this.slides = next;
1552
+ this.activeSlideIdx++;
1553
+ this.markDirty(true);
1554
+ },
1555
+ deleteSlide() {
1556
+ if ((this.slides?.length || 0) <= 1) return;
1557
+ const next = this.slides.filter((_, idx) => idx !== this.activeSlideIdx);
1558
+ this.slides = next;
1559
+ this.activeSlideIdx = Math.max(0, Math.min(this.activeSlideIdx, next.length - 1));
1560
+ this.markDirty(true);
1561
+ },
1562
+ addSlideTextElement() {
1563
+ const cur = this.currentSlide;
1564
+ if (!cur) return;
1565
+ cur.elements ??= [];
1566
+ const newEl = {
1567
+ id: `el_${Date.now()}`,
1568
+ type: 'text',
1569
+ x: 120,
1570
+ y: 140,
1571
+ w: 500,
1572
+ h: 80,
1573
+ text: 'Новый текстовый блок',
1574
+ fontSize: 22,
1575
+ bold: false,
1576
+ italic: false,
1577
+ align: 'left',
1578
+ color: '#1e293b',
1579
+ fill: 'transparent'
1580
+ };
1581
+ cur.elements = [...cur.elements, newEl];
1582
+ this.selectedSlideElId = newEl.id;
1583
+ this.markDirty(true);
1584
+ this.render();
1585
+ },
1586
+ deleteSlideElement() {
1587
+ const cur = this.currentSlide;
1588
+ if (!cur || !this.selectedSlideElId) return;
1589
+ cur.elements = (cur.elements || []).filter(el => el.id !== this.selectedSlideElId);
1590
+ this.selectedSlideElId = cur.elements[0]?.id || '';
1591
+ this.markDirty(true);
1592
+ this.render();
1593
+ },
1594
+ toggleSlideElProp(prop) {
1595
+ const el = this.selectedSlideEl;
1596
+ if (!el) return;
1597
+ this.setSlideElProp(prop, !el[prop]);
1598
+ },
1599
+ setSlideElProp(prop, val, e) {
1600
+ if (e && e.isTrusted === false) return;
1601
+ const el = this.selectedSlideEl;
1602
+ if (!el) return;
1603
+ el[prop] = val;
1604
+ this.markDirty(true);
1605
+ this.render();
1606
+ },
1607
+ onStageBackgroundClick(e) {
1608
+ if (e?.target?.classList?.contains('pptx-canvas') || e?.target?.classList?.contains('pptx-stage-wrap')) this.selectedSlideElId = '';
1609
+ },
1610
+ onSlideElMouseDown(el, e) {
1611
+ this.selectedSlideElId = el.id;
1612
+ this._dragState = {
1613
+ el,
1614
+ startX: e.clientX,
1615
+ startY: e.clientY,
1616
+ origX: Number(el.x) || 0,
1617
+ origY: Number(el.y) || 0
1618
+ };
1619
+ },
1620
+ onSlideMouseMove(e) {
1621
+ const d = this._dragState;
1622
+ if (!d) return;
1623
+ const dx = e.clientX - d.startX;
1624
+ const dy = e.clientY - d.startY;
1625
+ if (Math.abs(dx) < 3 && Math.abs(dy) < 3) return;
1626
+ d.el.x = Math.max(0, Math.min(900, Math.round(d.origX + dx)));
1627
+ d.el.y = Math.max(0, Math.min(500, Math.round(d.origY + dy)));
1628
+ this.markDirty(true);
1629
+ this.render();
1630
+ },
1631
+ onSlideMouseUp() {
1632
+ this._dragState = null;
1633
+ },
1634
+ onSlideElInput(el, e) {
1635
+ el.text = e?.target?.innerText ?? '';
1636
+ const cur = this.currentSlide;
1637
+ if (cur && cur.elements?.[0]?.id === el.id) cur.title = el.text.split('\n')[0]?.slice(0, 40) || cur.title;
1638
+ this.markDirty(true);
1639
+ },
1640
+ startSlideShow() {
1641
+ this.slideshowActive = true;
1642
+ },
1643
+ exitSlideShow() {
1644
+ this.slideshowActive = false;
1645
+ },
1646
+ nextSlideShow() {
1647
+ if (this.activeSlideIdx < (this.slides?.length || 1) - 1) this.activeSlideIdx++;else this.slideshowActive = false;
1648
+ },
1649
+ prevSlideShow() {
1650
+ if (this.activeSlideIdx > 0) this.activeSlideIdx--;
1651
+ },
1652
+ // ========================================================================
1653
+ // Интеграция с десктопным Office, печать и скачивание
1654
+ // ========================================================================
1655
+
1656
+ openInDesktopOffice() {
1657
+ const url = this.$item?.url ? new URL(this.$item.url, location.origin).href : '';
1658
+ if (!url) return;
1659
+ let proto = 'ms-word:ofe|u|';
1660
+ if (this.kind === 'spreadsheet') proto = 'ms-excel:ofe|u|';else if (this.kind === 'presentation') proto = 'ms-powerpoint:ofe|u|';
1661
+ window.location.href = proto + url;
1662
+ },
1663
+ printDocument() {
1664
+ window.print?.();
1665
+ },
1666
+ downloadDocument() {
1667
+ const url = this.$item?.url;
1668
+ if (!url) return;
1669
+ const a = document.createElement('a');
1670
+ a.href = url + (url.includes('?') ? '&download' : '?download');
1671
+ a.download = this.$item?.id || 'document.' + this.ext;
1672
+ document.body.appendChild(a);
1673
+ a.click();
1674
+ a.remove();
1675
+ }
1676
+ });
2
1677
  export default {
1678
+ allowSave: true,
1679
+ component: {
1680
+ imports: 'oda//button, oda//icon',
1681
+ $public: {
1682
+ allowSave: true
1683
+ },
3
1684
  allowSave: true,
4
- }
1685
+ isChanged: false,
1686
+ fileControl: 'oda-office-editor',
1687
+ attached() {
1688
+ this.async(() => {
1689
+ const ed = this.$?.('oda-office-editor');
1690
+ if (ed) {
1691
+ ed.hostView = this;
1692
+ if (this.$item && ed._loadedItem !== this.$item) ed.loadOfficeItem?.(this.$item);
1693
+ }
1694
+ }, 20);
1695
+ },
1696
+ async save() {
1697
+ const ed = this.$?.('oda-office-editor');
1698
+ if (ed && typeof ed.save === 'function') return ed.save();
1699
+ }
1700
+ }
1701
+ };