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