odant-work 1.0.90 → 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 (326) hide show
  1. package/#system/package-manifest.json +275 -246
  2. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  3. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/class.js +4 -0
  4. package/$server/$folder/$class/$data/$catalog/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  5. package/$server/$folder/$class/$data/$catalog/$virtual/class.js +8 -0
  6. package/{MODULES/Register/CATALOGS/$catalog/$folder/$class → $server/$folder/$class/$data}/$catalog/class.js +1 -0
  7. package/$server/$folder/$class/$data/$operation/$folder/$class/$data/$operation/class.js +4 -0
  8. package/{MODULES/Register/OPERATIONS/$operation/$folder/$class → $server/$folder/$class/$data}/$operation/class.js +1 -0
  9. package/$server/$folder/$class/$data/$register/$account/$folder/$class/$data/$register/$account/class.js +4 -0
  10. package/$server/$folder/$class/$data/$register/$account/class.js +8 -0
  11. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/$account/class.js +4 -0
  12. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/class.js +4 -0
  13. package/$server/$folder/$class/$data/$register/class.js +8 -0
  14. package/$server/$folder/$class/$data/$struct/$folder/$class/$data/$struct/class.js +4 -0
  15. package/$server/$folder/$class/$data/$struct/class.js +5 -0
  16. package/$server/$folder/$class/$data/class.js +5 -0
  17. package/$server/$folder/$class/$data/handlers/pages/form/objects/$handler/class.js +2158 -0
  18. package/$server/$folder/$class/$data/handlers/pages/form/objects/object/$handler/class.js +1377 -0
  19. package/$server/$folder/$class/$domain/$folder/$class/$domain/class.js +4 -0
  20. package/$server/$folder/$class/$domain/handlers/methods/restore/$handler/class.js +5 -5
  21. package/$server/$folder/$class/$domain/readme.md +1 -1
  22. package/$server/$folder/$class/$handler/$method/class.js +4 -0
  23. package/$server/$folder/$class/$handler/$timer/class.js +4 -0
  24. package/$server/$folder/$class/$module/$folder/$class/$data/$catalog/class.js +4 -0
  25. package/$server/$folder/$class/$module/$folder/$class/$data/$operation/class.js +4 -0
  26. package/$server/$folder/$class/$module/$folder/$class/$data/$register/class.js +4 -0
  27. package/$server/$folder/$class/$module/$folder/$class/$data/$struct/class.js +4 -0
  28. package/$server/$folder/$class/$module/$folder/$class/$domain/class.js +4 -0
  29. package/$server/$folder/$class/$module/$folder/$class/$module/class.js +4 -0
  30. package/$server/$folder/$class/$module/class.js +418 -6
  31. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/mcp.js → $module/handlers/pages/form/system/mcp/$handler/class.js} +261 -220
  32. package/$server/$folder/$class/$module/handlers/pages/form/system/modules/$handler/class.js +7 -0
  33. package/$server/$folder/$class/$structure/$folder/$class/$structure/class.js +4 -0
  34. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$catalog/class.js +4 -0
  35. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$operation/class.js +4 -0
  36. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$register/class.js +4 -0
  37. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$struct/class.js +4 -0
  38. package/$server/$folder/$class/$structure/$organization/$folder/$class/$domain/class.js +4 -0
  39. package/$server/$folder/$class/$structure/$organization/$folder/$class/$module/class.js +4 -0
  40. package/{ORGANIZATIONS/$domain/$folder/$class/$base → $server/$folder/$class/$structure/$organization/$folder/$class/$structure/$organization}/class.js +4 -5
  41. package/$server/$folder/$class/$structure/$organization/$folder/$class/$structure/class.js +4 -0
  42. package/{ORGANIZATIONS/$domain/$folder/$class/$base/$folder/$class/$structure/$base → $server/$folder/$class/$structure/$organization}/class.js +19 -17
  43. package/$server/$folder/$class/$structure/$organization/handlers/pages/form/system/requisites/$handler/class.js +3 -0
  44. package/$server/$folder/$class/$structure/{$base/handlers/pages/site/$handler/site.js → $organization/handlers/pages/site/$handler/class.js} +352 -365
  45. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$catalog/class.js +4 -0
  46. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$operation/class.js +4 -0
  47. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$register/class.js +4 -0
  48. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$struct/class.js +4 -0
  49. package/$server/$folder/$class/$structure/$project/$folder/$class/$domain/class.js +4 -0
  50. package/$server/$folder/$class/$structure/$project/$folder/$class/$module/class.js +4 -0
  51. package/$server/$folder/$class/$structure/$project/class.js +1 -0
  52. package/$server/$folder/$class/$structure/$project/readme.md +1 -1
  53. package/$server/$folder/$class/$structure/$server/$folder/$class/$domain/class.js +4 -0
  54. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/database/$handler/class.js +3 -0
  55. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/license.js → $structure/$server/handlers/pages/form/system/license/$handler/class.js} +104 -103
  56. package/$server/$folder/$class/$structure/$server/handlers/pages/site/$handler/{site.js → class.js} +45 -30
  57. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +3 -0
  58. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +3 -0
  59. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/modules/$handler/class.js +3 -0
  60. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +18 -0
  61. package/$server/$folder/$class/$structure/ai/system.md +1 -1
  62. package/$server/$folder/$class/$structure/class.js +1 -1
  63. package/$server/$folder/$class/$structure/handlers/methods/archive/$handler/class.js +3 -3
  64. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +309 -8
  65. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +15 -4
  66. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1281 -7
  67. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2216 -6
  68. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1304 -6
  69. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/methods/refresh/$method/class.js +1 -1
  70. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +305 -9
  71. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/agent.js → $structure/handlers/pages/form/system/agent/$handler/class.js} +329 -320
  72. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/database.js → $structure/handlers/pages/form/system/database/$handler/class.js} +510 -577
  73. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/messengers.js → $structure/handlers/pages/form/system/messengers/$handler/class.js} +143 -144
  74. package/$server/$folder/$class/$structure/handlers/pages/form/system/modules/$handler/class.js +270 -0
  75. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2114 -0
  76. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +229 -4
  77. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/readme.md +1 -1
  78. package/$server/$folder/$class/$structure/readme.md +3 -3
  79. package/$server/$folder/$class/$users/$folder/$class/$structure/$user/class.js +4 -0
  80. package/$server/$folder/$class/$users/class.js +4 -0
  81. package/$server/$folder/$class/ai/agents/integrator-1c.md +1 -1
  82. package/$server/$folder/$class/ai/agents/it-admin.md +1 -1
  83. package/$server/$folder/$class/ai/agents/org-architect.md +4 -4
  84. package/$server/$folder/$class/ai/agents/readme.md +1 -1
  85. package/$server/$folder/$class/ai/agents/schema-validator.md +2 -2
  86. package/$server/$folder/$class/ai/skills/lan-inventory.md +2 -2
  87. package/$server/$folder/$class/ai/skills/org-structure.md +1 -1
  88. package/$server/$folder/$class/ai/skills/printer-setup.md +1 -1
  89. package/$server/$folder/$class/ai/skills/telegram-notify.md +2 -2
  90. package/$server/$folder/$class/ai/skills/work-scenarios.md +3 -3
  91. package/$server/$folder/$class/ai/system.md +14 -8
  92. package/$server/$folder/$class/class.js +2 -6
  93. package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +3 -0
  94. package/$server/$folder/$class/handlers/pages/form/system/$handler/class.js +2 -4
  95. package/$server/$folder/$class/handlers/pages/form/system/files/$handler/class.js +7 -0
  96. package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +100 -0
  97. package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +25 -6
  98. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +32 -5
  99. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +31 -3
  100. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +11 -3
  101. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +83 -3
  102. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +61 -3
  103. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/class.js +1699 -2
  104. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +827 -2
  105. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +1 -1
  106. package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +33 -3
  107. package/$server/$folder/$file/handlers/pages/form/folder/$handler/class.js +3 -0
  108. package/$server/$folder/handlers/methods/create/$handler/class.js +5 -5
  109. package/$server/$folder/handlers/pages/form/$handler/class.js +2467 -3
  110. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +22 -0
  111. package/$server/$folder/handlers/readme.md +1 -1
  112. package/$server/$folder/lib/chat-item/chat-item.js +5 -10
  113. package/$server/$folder/lib/consultant/consultant.js +7 -10
  114. package/$server/$folder/lib/explorer/explorer.js +1 -1
  115. package/$server/$folder/lib/icon/icon.js +1 -1
  116. package/$server/$folder/lib/menu/menu.js +3 -2
  117. package/$server/$folder/lib/messenger-settings/messenger-settings.js +4 -4
  118. package/$server/$folder/lib/node/node.js +3 -3
  119. package/$server/$folder/lib/prompt-bar/prompt-bar.js +2 -2
  120. package/$server/$folder/lib/role/role.js +1 -2
  121. package/$server/$folder/lib/security/admin/admin.js +3 -3
  122. package/$server/$folder/lib/security/security.js +4 -4
  123. package/$server/$folder/lib/security/users/users.js +2 -5
  124. package/$server/$folder/lib/site-loc/site-loc.js +3 -3
  125. package/$server/$folder/lib/tree/tree.js +14 -22
  126. package/$server/class.js +1 -0
  127. package/AGENTS.md +21 -13
  128. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-model.js → MODELS/$ai/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js} +385 -425
  129. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-provider.js → MODELS/$ai/$folder/$class/$provider/handlers/pages/form/system/ai/$handler/class.js} +157 -161
  130. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-root.js → MODELS/$ai/handlers/pages/form/system/ai/$handler/class.js} +34 -33
  131. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-local.js → MODELS/Local/$provider/handlers/pages/form/system/ai/$handler/class.js} +572 -622
  132. package/MODULES/$domain/class.js +85 -4
  133. package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +7 -0
  134. package/MODULES/$domain/readme.md +7 -6
  135. package/{SERVICES/1C/$service → MODULES/1C/$module}/class.js +7 -1
  136. package/MODULES/2GIS/$module/class.js +32 -0
  137. package/MODULES/2GIS/$module/readme.md +57 -0
  138. package/{SERVICES/Bitrix24/$service → MODULES/Bitrix24/$module}/class.js +7 -2
  139. package/{SERVICES/CBR/$service → MODULES/CBR/$module}/class.js +5 -0
  140. package/{SERVICES/DaData/$service → MODULES/DaData/$module}/class.js +9 -3
  141. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +648 -21
  142. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +140 -6
  143. package/{SERVICES/Marketplaces/$service → MODULES/Marketplaces/$domain}/class.js +1 -1
  144. package/{SERVICES/Marketplaces/Ozon/$service → MODULES/Marketplaces/Ozon/$module}/class.js +1 -1
  145. package/{SERVICES/Marketplaces/Wildberries/$service → MODULES/Marketplaces/Wildberries/$module}/class.js +1 -1
  146. package/{SERVICES/Marketplaces/YandexMarket/$service → MODULES/Marketplaces/YandexMarket/$module}/class.js +1 -1
  147. package/MODULES/Process/$module/readme.md +1 -1
  148. 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 -6
  149. 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 -6
  150. 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 -16
  151. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual → $data/$catalog/$virtual}/class.js +3 -0
  152. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/objects/$handler/class.js +3 -0
  153. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/handlers/pages/form/virtual/$handler/virtual.js → $data/$catalog/$virtual/handlers/pages/form/virtual/$handler/class.js} +413 -390
  154. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/class.js +14 -0
  155. package/MODULES/Register/CATALOGS/$catalog/class.js +7 -14
  156. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +9 -0
  157. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/class.js +0 -7
  158. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/$folder/$class/$data/$catalog/class.js +11 -0
  159. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/class.js +0 -9
  160. package/MODULES/Register/OPERATIONS/$operation/$folder/$class/$data/$operation/class.js +16 -0
  161. package/MODULES/Register/OPERATIONS/$operation/class.js +0 -9
  162. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/$folder/$class/$data/$operation/class.js +8 -0
  163. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/class.js +4 -10
  164. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/$folder/$class/$data/$operation/class.js +8 -0
  165. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/class.js +0 -6
  166. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/$folder/$class/$data/$operation/class.js +8 -0
  167. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/class.js +4 -10
  168. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  169. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/class.js" +4 -12
  170. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  171. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/class.js" +4 -12
  172. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/$folder/$class/$data/$operation/class.js +24 -0
  173. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/class.js +0 -22
  174. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/analysis/$handler/analysis.js → $data/$register/$account/handlers/pages/form/analysis/$handler/class.js} +9 -4
  175. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/postings/$handler/postings.js → $data/$register/$account/handlers/pages/form/postings/$handler/class.js} +845 -753
  176. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/turnovers/$handler/turnovers.js → $data/$register/$account/handlers/pages/form/turnovers/$handler/class.js} +9 -4
  177. package/MODULES/Register/REGISTER/$register/{$folder/$class/$register/handlers/pages/form/journal/$handler/journal.js → handlers/pages/form/journal/$handler/class.js} +382 -329
  178. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/class.js +807 -0
  179. package/MODULES/Register/REGISTER/10/$account/$folder/$class/$data/$register/$account/class.js +21 -0
  180. package/MODULES/Register/REGISTER/10/$account/class.js +0 -19
  181. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/$folder/$class/$data/$register/$account/class.js +14 -0
  182. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/class.js +4 -16
  183. package/{SERVICES/SearXNG/$service → MODULES/SearXNG/$module}/class.js +5 -0
  184. package/{SERVICES/Yandex/$service → MODULES/Yandex/$module}/class.js +7 -0
  185. package/{SERVICES/YandexDisk/$service → MODULES/YandexDisk/$module}/class.js +8 -2
  186. package/NODES/$node/handlers/pages/form/network/$handler/class.js +122 -5
  187. package/ORGANIZATIONS/$domain/$folder/$class/$structure/$organization/class.js +5 -0
  188. package/ORGANIZATIONS/$domain/class.js +5 -5
  189. package/oda/components/inputs/link/link.js +1 -1
  190. package/package.json +1 -1
  191. package/readme.md +6 -7
  192. package/scripts/check-architecture.mjs +541 -0
  193. package/scripts/cleanup-storage.mjs +1 -1
  194. package/scripts/demo-seed.mjs +3 -3
  195. package/scripts/import-bis.mjs +33 -15
  196. package/scripts/import-delovaya.mjs +26 -14
  197. package/sources/client/class.js +19 -10
  198. package/sources/client/folder.js +10 -22
  199. package/sources/client/handler.js +75 -33
  200. package/sources/data/api.js +9 -10
  201. package/sources/data/classes.js +85 -9
  202. package/sources/data/db.js +10 -6
  203. package/sources/data/print.js +15 -41
  204. package/sources/data/readme.md +5 -5
  205. package/sources/data/schema.js +206 -118
  206. package/sources/data/sql-inspector.js +7 -7
  207. package/sources/host/auth-methods.js +2 -5
  208. package/sources/host/auto-updater.js +1 -2
  209. package/sources/host/babel-merge.js +174 -129
  210. package/sources/host/prewarm.js +1 -1
  211. package/sources/host/watch.js +1 -1
  212. package/sources/index.html +1 -1
  213. package/sources/modules/agent/extensions.js +48 -38
  214. package/sources/modules/agent/index.js +1 -1
  215. package/sources/modules/agent/node-rules.js +69 -41
  216. package/sources/modules/agent/permissions.js +1 -1
  217. package/sources/modules/agent/plugins.js +11 -11
  218. package/sources/modules/agent/resources.js +96 -52
  219. package/sources/modules/agent/tools/net.js +1 -1
  220. package/sources/modules/agent/tools/services.js +7 -7
  221. package/sources/modules/agent/tools/work/access.js +10 -8
  222. package/sources/modules/agent/tools/work/classes.js +26 -47
  223. package/sources/modules/agent/tools/work/common.js +8 -10
  224. package/sources/modules/agent/tools/work/data.js +4 -4
  225. package/sources/modules/agent/triggers.js +1 -1
  226. package/sources/modules/agent/twin-bus.js +4 -4
  227. package/sources/modules/agent/voice.js +1 -1
  228. package/sources/modules/call/call.js +4 -4
  229. package/sources/modules/kladr/index.js +3 -3
  230. package/sources/modules/lan/register.js +7 -7
  231. package/sources/modules/mcp-marketplaces/ozon.js +1 -1
  232. package/sources/modules/mcp-marketplaces/wildberries.js +1 -1
  233. package/sources/modules/mcp-marketplaces/yandex-market.js +1 -1
  234. package/sources/modules/nodes/mount.js +2 -4
  235. package/sources/modules/notify/index.js +18 -18
  236. package/sources/modules/rag/extract.js +9 -2
  237. package/sources/modules/rag/indexer.js +1 -1
  238. package/sources/modules/rag/scope.js +7 -33
  239. package/sources/modules/trainer/dataset.js +2 -2
  240. package/sources/modules/trainer/local-engine.js +1 -1
  241. package/sources/page.html +2 -2
  242. package/sources/readme.md +1 -1
  243. package/sources/server/access/gateway.js +19 -19
  244. package/sources/server/access/invites.js +4 -5
  245. package/sources/server/access/links.js +10 -8
  246. package/sources/server/access/policy.js +65 -39
  247. package/sources/server/access/workplaces.js +20 -14
  248. package/sources/server/chat-threads.js +4 -4
  249. package/sources/server/class/archive.js +15 -15
  250. package/sources/server/class/base-template.js +13 -9
  251. package/sources/server/class/distro.js +3 -4
  252. package/sources/server/class/feed.js +3 -3
  253. package/sources/server/class/mail-calendar.js +9 -8
  254. package/sources/server/class/scaffold.js +110 -60
  255. package/sources/server/class/search.js +2 -2
  256. package/sources/server/class/security.js +76 -94
  257. package/sources/server/class.js +181 -64
  258. package/sources/server/file.js +2 -2
  259. package/sources/server/folder.js +376 -191
  260. package/sources/server/handler.js +52 -13
  261. package/sources/server/logs.js +7 -7
  262. package/sources/server/node.js +12 -43
  263. package/sources/server/server.js +16 -17
  264. package/$server/$folder/$class/$device/class.js +0 -3
  265. package/$server/$folder/$class/$handler/$task/class.js +0 -3
  266. package/$server/$folder/$class/$service/$class/$service/class.js +0 -4
  267. package/$server/$folder/$class/$structure/$base/class.js +0 -10
  268. package/$server/$folder/$class/$structure/$base/roots_1/roots.test +0 -0
  269. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +0 -313
  270. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +0 -16
  271. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +0 -1226
  272. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +0 -2217
  273. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +0 -1188
  274. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +0 -289
  275. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/site.js +0 -240
  276. package/$server/$folder/$class/handlers/pages/form/object/$handler/class.js +0 -33
  277. package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +0 -1371
  278. package/$server/$folder/$class/handlers/pages/form/objects/$handler/class.js +0 -33
  279. package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +0 -2130
  280. package/$server/$folder/$class/handlers/pages/form/system/$handler/system.js +0 -384
  281. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/modules.js +0 -244
  282. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/staff.js +0 -2126
  283. package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +0 -21
  284. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +0 -27
  285. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +0 -31
  286. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +0 -10
  287. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/file.js +0 -72
  288. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +0 -63
  289. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +0 -1845
  290. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +0 -785
  291. package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +0 -29
  292. package/$server/$folder/handlers/pages/form/$handler/form.js +0 -2122
  293. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +0 -623
  294. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +0 -134
  295. 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
  296. 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
  297. 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
  298. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$virtual/handlers/pages/form/virtual/$handler/class.js +0 -6
  299. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/analysis/$handler/class.js +0 -9
  300. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/postings/$handler/class.js +0 -9
  301. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/turnovers/$handler/class.js +0 -9
  302. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/journal/$handler/class.js +0 -6
  303. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/class.js +0 -6
  304. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/sheet.js +0 -808
  305. package/NODES/$node/handlers/pages/form/network/$handler/network.js +0 -110
  306. package/SERVICES/$service/$folder/$storage/$service/class.js +0 -8
  307. package/SERVICES/$service/class.js +0 -442
  308. package/SERVICES/readme.md +0 -36
  309. /package/$server/$folder/$class/$structure/{$base → $organization}/icon.png +0 -0
  310. /package/{SERVICES/DuckDuckGo/$service → MODULES/DuckDuckGo/$module}/class.js +0 -0
  311. /package/MODULES/KLADR/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  312. /package/MODULES/Process/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  313. /package/MODULES/Register/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  314. /package/MODULES/Register/$module/$folder/$class/{$operation → $data/$operation}/class.js +0 -0
  315. /package/MODULES/Register/$module/$folder/$class/{$register → $data/$register}/class.js +0 -0
  316. /package/MODULES/Register/$module/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  317. /package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/$folder/$class → $data/$catalog/$virtual/$folder/$class/$data/$catalog}/$virtual/class.js +0 -0
  318. /package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/{print → $folder/$class/$data/$operation/print}//320/237/320/273/320/260/321/202/321/221/320/266/320/275/320/276/320/265 /320/277/320/276/321/200/321/203/321/207/320/265/320/275/320/270/320/265.html" +0 -0
  319. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/class.js +0 -0
  320. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/readme.md +0 -0
  321. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$register → $data/$register}/class.js +0 -0
  322. /package/MODULES/Register/STRUCTS/$struct/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  323. /package/{SERVICES/RuCalendar/$service → MODULES/RuCalendar/$module}/class.js +0 -0
  324. /package/{SERVICES/Telegram/$service → MODULES/Telegram/$module}/class.js +0 -0
  325. /package/{SERVICES/Weather/$service → MODULES/Weather/$module}/class.js +0 -0
  326. /package/PROJECTS/$domain/$folder/$class/{$project → $structure/$project}/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
+ };