@difizen/libro-core 0.0.0-snapshot-20241017072317

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 (433) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +280 -0
  3. package/es/add-cell/index.d.ts +4 -0
  4. package/es/add-cell/index.d.ts.map +1 -0
  5. package/es/add-cell/index.js +3 -0
  6. package/es/add-cell/index.less +38 -0
  7. package/es/add-cell/libro-add-cell-module.d.ts +3 -0
  8. package/es/add-cell/libro-add-cell-module.d.ts.map +1 -0
  9. package/es/add-cell/libro-add-cell-module.js +4 -0
  10. package/es/add-cell/libro-add-cell-slot-contribution.d.ts +11 -0
  11. package/es/add-cell/libro-add-cell-slot-contribution.d.ts.map +1 -0
  12. package/es/add-cell/libro-add-cell-slot-contribution.js +59 -0
  13. package/es/add-cell/libro-add-cell-view.d.ts +21 -0
  14. package/es/add-cell/libro-add-cell-view.d.ts.map +1 -0
  15. package/es/add-cell/libro-add-cell-view.js +121 -0
  16. package/es/cell/index.d.ts +10 -0
  17. package/es/cell/index.d.ts.map +1 -0
  18. package/es/cell/index.js +9 -0
  19. package/es/cell/libro-cell-contribution.d.ts +12 -0
  20. package/es/cell/libro-cell-contribution.d.ts.map +1 -0
  21. package/es/cell/libro-cell-contribution.js +47 -0
  22. package/es/cell/libro-cell-model.d.ts +29 -0
  23. package/es/cell/libro-cell-model.d.ts.map +1 -0
  24. package/es/cell/libro-cell-model.js +130 -0
  25. package/es/cell/libro-cell-module.d.ts +10 -0
  26. package/es/cell/libro-cell-module.d.ts.map +1 -0
  27. package/es/cell/libro-cell-module.js +30 -0
  28. package/es/cell/libro-cell-protocol.d.ts +44 -0
  29. package/es/cell/libro-cell-protocol.d.ts.map +1 -0
  30. package/es/cell/libro-cell-protocol.js +11 -0
  31. package/es/cell/libro-cell-service.d.ts +28 -0
  32. package/es/cell/libro-cell-service.d.ts.map +1 -0
  33. package/es/cell/libro-cell-service.js +245 -0
  34. package/es/cell/libro-cell-view.d.ts +74 -0
  35. package/es/cell/libro-cell-view.d.ts.map +1 -0
  36. package/es/cell/libro-cell-view.js +239 -0
  37. package/es/cell/libro-edit-cell-view.d.ts +44 -0
  38. package/es/cell/libro-edit-cell-view.d.ts.map +1 -0
  39. package/es/cell/libro-edit-cell-view.js +256 -0
  40. package/es/cell/libro-executable-cell-model.d.ts +14 -0
  41. package/es/cell/libro-executable-cell-model.d.ts.map +1 -0
  42. package/es/cell/libro-executable-cell-model.js +7 -0
  43. package/es/cell/libro-executable-cell-view.d.ts +34 -0
  44. package/es/cell/libro-executable-cell-view.d.ts.map +1 -0
  45. package/es/cell/libro-executable-cell-view.js +74 -0
  46. package/es/cell/libro-markdown-cell-model.d.ts +9 -0
  47. package/es/cell/libro-markdown-cell-model.d.ts.map +1 -0
  48. package/es/cell/libro-markdown-cell-model.js +7 -0
  49. package/es/collapse-service.d.ts +36 -0
  50. package/es/collapse-service.d.ts.map +1 -0
  51. package/es/collapse-service.js +55 -0
  52. package/es/command/document-commands.d.ts +5 -0
  53. package/es/command/document-commands.d.ts.map +1 -0
  54. package/es/command/document-commands.js +21 -0
  55. package/es/command/index.d.ts +7 -0
  56. package/es/command/index.d.ts.map +1 -0
  57. package/es/command/index.js +6 -0
  58. package/es/command/kernel-command.d.ts +5 -0
  59. package/es/command/kernel-command.d.ts.map +1 -0
  60. package/es/command/kernel-command.js +40 -0
  61. package/es/command/libro-command-contribution.d.ts +13 -0
  62. package/es/command/libro-command-contribution.d.ts.map +1 -0
  63. package/es/command/libro-command-contribution.js +1842 -0
  64. package/es/command/libro-command-register.d.ts +21 -0
  65. package/es/command/libro-command-register.d.ts.map +1 -0
  66. package/es/command/libro-command-register.js +111 -0
  67. package/es/command/module.d.ts +3 -0
  68. package/es/command/module.d.ts.map +1 -0
  69. package/es/command/module.js +4 -0
  70. package/es/command/notebook-commands.d.ts +6 -0
  71. package/es/command/notebook-commands.d.ts.map +1 -0
  72. package/es/command/notebook-commands.js +472 -0
  73. package/es/components/cell-protocol.d.ts +20 -0
  74. package/es/components/cell-protocol.d.ts.map +1 -0
  75. package/es/components/cell-protocol.js +4 -0
  76. package/es/components/dnd-cell-item-render.d.ts +16 -0
  77. package/es/components/dnd-cell-item-render.d.ts.map +1 -0
  78. package/es/components/dnd-cell-item-render.js +364 -0
  79. package/es/components/dnd-component/custom-drag-layer.d.ts +9 -0
  80. package/es/components/dnd-component/custom-drag-layer.d.ts.map +1 -0
  81. package/es/components/dnd-component/custom-drag-layer.js +140 -0
  82. package/es/components/dnd-component/default-dnd-content.d.ts +11 -0
  83. package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -0
  84. package/es/components/dnd-component/default-dnd-content.js +292 -0
  85. package/es/components/dnd-component/dnd-context.d.ts +3 -0
  86. package/es/components/dnd-component/dnd-context.d.ts.map +1 -0
  87. package/es/components/dnd-component/dnd-context.js +20 -0
  88. package/es/components/dnd-component/dnd-list.d.ts +14 -0
  89. package/es/components/dnd-component/dnd-list.d.ts.map +1 -0
  90. package/es/components/dnd-component/dnd-list.js +182 -0
  91. package/es/components/dnd-component/index.d.ts +5 -0
  92. package/es/components/dnd-component/index.d.ts.map +1 -0
  93. package/es/components/dnd-component/index.js +4 -0
  94. package/es/components/dnd-component/index.less +8 -0
  95. package/es/components/dnd-component/overscanIndices-getter.d.ts +22 -0
  96. package/es/components/dnd-component/overscanIndices-getter.d.ts.map +1 -0
  97. package/es/components/dnd-component/overscanIndices-getter.js +58 -0
  98. package/es/components/dnd-component/virtualized-manager.d.ts +19 -0
  99. package/es/components/dnd-component/virtualized-manager.d.ts.map +1 -0
  100. package/es/components/dnd-component/virtualized-manager.js +60 -0
  101. package/es/components/index.d.ts +6 -0
  102. package/es/components/index.d.ts.map +1 -0
  103. package/es/components/index.js +5 -0
  104. package/es/components/libro-component.d.ts +5 -0
  105. package/es/components/libro-component.d.ts.map +1 -0
  106. package/es/components/libro-component.js +35 -0
  107. package/es/components/libro-side-toolbar-menu.d.ts +21 -0
  108. package/es/components/libro-side-toolbar-menu.d.ts.map +1 -0
  109. package/es/components/libro-side-toolbar-menu.js +58 -0
  110. package/es/components/libro-view-header.d.ts +3 -0
  111. package/es/components/libro-view-header.d.ts.map +1 -0
  112. package/es/components/libro-view-header.js +37 -0
  113. package/es/components/libro-virtualized-render.d.ts +15 -0
  114. package/es/components/libro-virtualized-render.d.ts.map +1 -0
  115. package/es/components/libro-virtualized-render.js +174 -0
  116. package/es/content/index.d.ts +6 -0
  117. package/es/content/index.d.ts.map +1 -0
  118. package/es/content/index.js +5 -0
  119. package/es/content/libro-content-contribution.d.ts +11 -0
  120. package/es/content/libro-content-contribution.d.ts.map +1 -0
  121. package/es/content/libro-content-contribution.js +31 -0
  122. package/es/content/libro-content-module.d.ts +3 -0
  123. package/es/content/libro-content-module.d.ts.map +1 -0
  124. package/es/content/libro-content-module.js +6 -0
  125. package/es/content/libro-content-protocol.d.ts +13 -0
  126. package/es/content/libro-content-protocol.d.ts.map +1 -0
  127. package/es/content/libro-content-protocol.js +3 -0
  128. package/es/content/libro-content-service.d.ts +11 -0
  129. package/es/content/libro-content-service.d.ts.map +1 -0
  130. package/es/content/libro-content-service.js +63 -0
  131. package/es/content/libro-save-content-contribution.d.ts +6 -0
  132. package/es/content/libro-save-content-contribution.d.ts.map +1 -0
  133. package/es/content/libro-save-content-contribution.js +27 -0
  134. package/es/formatter/index.d.ts +6 -0
  135. package/es/formatter/index.d.ts.map +1 -0
  136. package/es/formatter/index.js +5 -0
  137. package/es/formatter/libro-formatter-json-contribution.d.ts +18 -0
  138. package/es/formatter/libro-formatter-json-contribution.d.ts.map +1 -0
  139. package/es/formatter/libro-formatter-json-contribution.js +41 -0
  140. package/es/formatter/libro-formatter-manager.d.ts +16 -0
  141. package/es/formatter/libro-formatter-manager.d.ts.map +1 -0
  142. package/es/formatter/libro-formatter-manager.js +86 -0
  143. package/es/formatter/libro-formatter-module.d.ts +3 -0
  144. package/es/formatter/libro-formatter-module.d.ts.map +1 -0
  145. package/es/formatter/libro-formatter-module.js +7 -0
  146. package/es/formatter/libro-formatter-protocol.d.ts +37 -0
  147. package/es/formatter/libro-formatter-protocol.d.ts.map +1 -0
  148. package/es/formatter/libro-formatter-protocol.js +18 -0
  149. package/es/formatter/libro-formatter-string-contribution.d.ts +18 -0
  150. package/es/formatter/libro-formatter-string-contribution.d.ts.map +1 -0
  151. package/es/formatter/libro-formatter-string-contribution.js +41 -0
  152. package/es/formatter/libro-formatter-trans-default-contribution.d.ts +7 -0
  153. package/es/formatter/libro-formatter-trans-default-contribution.d.ts.map +1 -0
  154. package/es/formatter/libro-formatter-trans-default-contribution.js +19 -0
  155. package/es/index.d.ts +26 -0
  156. package/es/index.d.ts.map +1 -0
  157. package/es/index.js +25 -0
  158. package/es/index.less +781 -0
  159. package/es/libro-context-key.d.ts +26 -0
  160. package/es/libro-context-key.d.ts.map +1 -0
  161. package/es/libro-context-key.js +84 -0
  162. package/es/libro-keybind-registry.d.ts +5 -0
  163. package/es/libro-keybind-registry.d.ts.map +1 -0
  164. package/es/libro-keybind-registry.js +68 -0
  165. package/es/libro-model.d.ts +145 -0
  166. package/es/libro-model.d.ts.map +1 -0
  167. package/es/libro-model.js +921 -0
  168. package/es/libro-protocol.d.ts +315 -0
  169. package/es/libro-protocol.d.ts.map +1 -0
  170. package/es/libro-protocol.js +47 -0
  171. package/es/libro-service.d.ts +69 -0
  172. package/es/libro-service.d.ts.map +1 -0
  173. package/es/libro-service.js +303 -0
  174. package/es/libro-setting-contribution.d.ts +5 -0
  175. package/es/libro-setting-contribution.d.ts.map +1 -0
  176. package/es/libro-setting-contribution.js +23 -0
  177. package/es/libro-setting.d.ts +12 -0
  178. package/es/libro-setting.d.ts.map +1 -0
  179. package/es/libro-setting.js +101 -0
  180. package/es/libro-view-tracker.d.ts +6 -0
  181. package/es/libro-view-tracker.d.ts.map +1 -0
  182. package/es/libro-view-tracker.js +13 -0
  183. package/es/libro-view.d.ts +170 -0
  184. package/es/libro-view.d.ts.map +1 -0
  185. package/es/libro-view.js +2077 -0
  186. package/es/libro-workspace-service.d.ts +17 -0
  187. package/es/libro-workspace-service.d.ts.map +1 -0
  188. package/es/libro-workspace-service.js +36 -0
  189. package/es/material-from-designer.d.ts +31 -0
  190. package/es/material-from-designer.d.ts.map +1 -0
  191. package/es/material-from-designer.js +697 -0
  192. package/es/module.d.ts +3 -0
  193. package/es/module.d.ts.map +1 -0
  194. package/es/module.js +71 -0
  195. package/es/output/index.d.ts +6 -0
  196. package/es/output/index.d.ts.map +1 -0
  197. package/es/output/index.js +5 -0
  198. package/es/output/output-area.d.ts +51 -0
  199. package/es/output/output-area.d.ts.map +1 -0
  200. package/es/output/output-area.js +399 -0
  201. package/es/output/output-contribution.d.ts +10 -0
  202. package/es/output/output-contribution.d.ts.map +1 -0
  203. package/es/output/output-contribution.js +36 -0
  204. package/es/output/output-model.d.ts +28 -0
  205. package/es/output/output-model.d.ts.map +1 -0
  206. package/es/output/output-model.js +105 -0
  207. package/es/output/output-module.d.ts +3 -0
  208. package/es/output/output-module.d.ts.map +1 -0
  209. package/es/output/output-module.js +6 -0
  210. package/es/output/output-protocol.d.ts +134 -0
  211. package/es/output/output-protocol.d.ts.map +1 -0
  212. package/es/output/output-protocol.js +16 -0
  213. package/es/settings/index.d.ts +5 -0
  214. package/es/settings/index.d.ts.map +1 -0
  215. package/es/settings/index.js +4 -0
  216. package/es/settings/index.less +3 -0
  217. package/es/settings/module.d.ts +3 -0
  218. package/es/settings/module.d.ts.map +1 -0
  219. package/es/settings/module.js +4 -0
  220. package/es/settings/setting-editor/configuration-panel-view.d.ts +13 -0
  221. package/es/settings/setting-editor/configuration-panel-view.d.ts.map +1 -0
  222. package/es/settings/setting-editor/configuration-panel-view.js +115 -0
  223. package/es/settings/setting-editor/configuration-render-contribution.d.ts +6 -0
  224. package/es/settings/setting-editor/configuration-render-contribution.d.ts.map +1 -0
  225. package/es/settings/setting-editor/configuration-render-contribution.js +77 -0
  226. package/es/settings/setting-editor/default-node-render.d.ts +9 -0
  227. package/es/settings/setting-editor/default-node-render.d.ts.map +1 -0
  228. package/es/settings/setting-editor/default-node-render.js +79 -0
  229. package/es/settings/setting-editor/index.d.ts +7 -0
  230. package/es/settings/setting-editor/index.d.ts.map +1 -0
  231. package/es/settings/setting-editor/index.js +6 -0
  232. package/es/settings/setting-editor/index.less +12 -0
  233. package/es/settings/setting-editor/module.d.ts +3 -0
  234. package/es/settings/setting-editor/module.d.ts.map +1 -0
  235. package/es/settings/setting-editor/module.js +11 -0
  236. package/es/settings/setting-editor/setting-editor-view.d.ts +15 -0
  237. package/es/settings/setting-editor/setting-editor-view.d.ts.map +1 -0
  238. package/es/settings/setting-editor/setting-editor-view.js +169 -0
  239. package/es/settings/setting-editor/setting-tree-service.d.ts +9 -0
  240. package/es/settings/setting-editor/setting-tree-service.d.ts.map +1 -0
  241. package/es/settings/setting-editor/setting-tree-service.js +118 -0
  242. package/es/settings/setting-editor/setting-tree-view.d.ts +19 -0
  243. package/es/settings/setting-editor/setting-tree-view.d.ts.map +1 -0
  244. package/es/settings/setting-editor/setting-tree-view.js +87 -0
  245. package/es/settings/settings-contribution.d.ts +7 -0
  246. package/es/settings/settings-contribution.d.ts.map +1 -0
  247. package/es/settings/settings-contribution.js +36 -0
  248. package/es/settings/settings-modal.d.ts +5 -0
  249. package/es/settings/settings-modal.d.ts.map +1 -0
  250. package/es/settings/settings-modal.js +53 -0
  251. package/es/settings/settings-modal.less +3 -0
  252. package/es/settings/settings-protocol.d.ts +4 -0
  253. package/es/settings/settings-protocol.d.ts.map +1 -0
  254. package/es/settings/settings-protocol.js +5 -0
  255. package/es/slot/index.d.ts +5 -0
  256. package/es/slot/index.d.ts.map +1 -0
  257. package/es/slot/index.js +4 -0
  258. package/es/slot/libro-slot-manager.d.ts +13 -0
  259. package/es/slot/libro-slot-manager.d.ts.map +1 -0
  260. package/es/slot/libro-slot-manager.js +66 -0
  261. package/es/slot/libro-slot-protocol.d.ts +19 -0
  262. package/es/slot/libro-slot-protocol.d.ts.map +1 -0
  263. package/es/slot/libro-slot-protocol.js +5 -0
  264. package/es/slot/libro-slot-view.d.ts +9 -0
  265. package/es/slot/libro-slot-view.d.ts.map +1 -0
  266. package/es/slot/libro-slot-view.js +81 -0
  267. package/es/slot/module.d.ts +3 -0
  268. package/es/slot/module.d.ts.map +1 -0
  269. package/es/slot/module.js +5 -0
  270. package/es/theme/libro-color-registry.d.ts +6 -0
  271. package/es/theme/libro-color-registry.d.ts.map +1 -0
  272. package/es/theme/libro-color-registry.js +515 -0
  273. package/es/toolbar/all-outputs-scroll-icon.d.ts +3 -0
  274. package/es/toolbar/all-outputs-scroll-icon.d.ts.map +1 -0
  275. package/es/toolbar/all-outputs-scroll-icon.js +10 -0
  276. package/es/toolbar/change-cell-to-selector.d.ts +5 -0
  277. package/es/toolbar/change-cell-to-selector.d.ts.map +1 -0
  278. package/es/toolbar/change-cell-to-selector.js +51 -0
  279. package/es/toolbar/hide-all-selector.d.ts +5 -0
  280. package/es/toolbar/hide-all-selector.d.ts.map +1 -0
  281. package/es/toolbar/hide-all-selector.js +99 -0
  282. package/es/toolbar/index.d.ts +4 -0
  283. package/es/toolbar/index.d.ts.map +1 -0
  284. package/es/toolbar/index.js +3 -0
  285. package/es/toolbar/index.less +59 -0
  286. package/es/toolbar/libro-toolbar-protocol.d.ts +4 -0
  287. package/es/toolbar/libro-toolbar-protocol.d.ts.map +1 -0
  288. package/es/toolbar/libro-toolbar-protocol.js +1 -0
  289. package/es/toolbar/libro-toolbar.d.ts +9 -0
  290. package/es/toolbar/libro-toolbar.d.ts.map +1 -0
  291. package/es/toolbar/libro-toolbar.js +275 -0
  292. package/es/toolbar/module.d.ts +3 -0
  293. package/es/toolbar/module.d.ts.map +1 -0
  294. package/es/toolbar/module.js +5 -0
  295. package/es/toolbar/restart-clear-outputs-contribution.d.ts +5 -0
  296. package/es/toolbar/restart-clear-outputs-contribution.d.ts.map +1 -0
  297. package/es/toolbar/restart-clear-outputs-contribution.js +23 -0
  298. package/es/toolbar/restart-clear-outputs-modal.d.ts +5 -0
  299. package/es/toolbar/restart-clear-outputs-modal.d.ts.map +1 -0
  300. package/es/toolbar/restart-clear-outputs-modal.js +30 -0
  301. package/es/toolbar/save-icon.d.ts +3 -0
  302. package/es/toolbar/save-icon.d.ts.map +1 -0
  303. package/es/toolbar/save-icon.js +54 -0
  304. package/es/toolbar/shutdown-contribution.d.ts +5 -0
  305. package/es/toolbar/shutdown-contribution.d.ts.map +1 -0
  306. package/es/toolbar/shutdown-contribution.js +23 -0
  307. package/es/toolbar/shutdown-modal.d.ts +5 -0
  308. package/es/toolbar/shutdown-modal.d.ts.map +1 -0
  309. package/es/toolbar/shutdown-modal.js +30 -0
  310. package/es/toolbar/side-toolar-more-select.d.ts +4 -0
  311. package/es/toolbar/side-toolar-more-select.d.ts.map +1 -0
  312. package/es/toolbar/side-toolar-more-select.js +161 -0
  313. package/es/typings/index.d.ts +1 -0
  314. package/es/virtualized-manager-helper.d.ts +11 -0
  315. package/es/virtualized-manager-helper.d.ts.map +1 -0
  316. package/es/virtualized-manager-helper.js +51 -0
  317. package/es/virtualized-manager.d.ts +23 -0
  318. package/es/virtualized-manager.d.ts.map +1 -0
  319. package/es/virtualized-manager.js +65 -0
  320. package/package.json +73 -0
  321. package/src/add-cell/index.less +38 -0
  322. package/src/add-cell/index.ts +3 -0
  323. package/src/add-cell/libro-add-cell-module.ts +9 -0
  324. package/src/add-cell/libro-add-cell-slot-contribution.ts +28 -0
  325. package/src/add-cell/libro-add-cell-view.tsx +99 -0
  326. package/src/cell/README.md +14 -0
  327. package/src/cell/index.ts +9 -0
  328. package/src/cell/libro-cell-contribution.ts +34 -0
  329. package/src/cell/libro-cell-model.ts +119 -0
  330. package/src/cell/libro-cell-module.ts +40 -0
  331. package/src/cell/libro-cell-protocol.ts +55 -0
  332. package/src/cell/libro-cell-service.ts +158 -0
  333. package/src/cell/libro-cell-view.tsx +156 -0
  334. package/src/cell/libro-edit-cell-view.tsx +205 -0
  335. package/src/cell/libro-executable-cell-model.ts +32 -0
  336. package/src/cell/libro-executable-cell-view.ts +86 -0
  337. package/src/cell/libro-markdown-cell-model.ts +20 -0
  338. package/src/collapse-service.ts +69 -0
  339. package/src/command/document-commands.ts +24 -0
  340. package/src/command/index.ts +6 -0
  341. package/src/command/kernel-command.ts +42 -0
  342. package/src/command/libro-command-contribution.ts +1346 -0
  343. package/src/command/libro-command-register.ts +168 -0
  344. package/src/command/module.ts +9 -0
  345. package/src/command/notebook-commands.ts +502 -0
  346. package/src/components/cell-protocol.ts +26 -0
  347. package/src/components/dnd-cell-item-render.tsx +465 -0
  348. package/src/components/dnd-component/custom-drag-layer.tsx +144 -0
  349. package/src/components/dnd-component/default-dnd-content.tsx +330 -0
  350. package/src/components/dnd-component/dnd-context.tsx +28 -0
  351. package/src/components/dnd-component/dnd-list.tsx +211 -0
  352. package/src/components/dnd-component/index.less +12 -0
  353. package/src/components/dnd-component/index.tsx +4 -0
  354. package/src/components/dnd-component/overscanIndices-getter.ts +92 -0
  355. package/src/components/dnd-component/virtualized-manager.ts +34 -0
  356. package/src/components/index.ts +5 -0
  357. package/src/components/libro-component.tsx +30 -0
  358. package/src/components/libro-side-toolbar-menu.tsx +82 -0
  359. package/src/components/libro-view-header.tsx +33 -0
  360. package/src/components/libro-virtualized-render.tsx +178 -0
  361. package/src/content/index.ts +5 -0
  362. package/src/content/libro-content-contribution.ts +16 -0
  363. package/src/content/libro-content-module.ts +17 -0
  364. package/src/content/libro-content-protocol.ts +14 -0
  365. package/src/content/libro-content-service.ts +48 -0
  366. package/src/content/libro-save-content-contribution.ts +12 -0
  367. package/src/formatter/index.ts +5 -0
  368. package/src/formatter/libro-formatter-json-contribution.ts +42 -0
  369. package/src/formatter/libro-formatter-manager.ts +85 -0
  370. package/src/formatter/libro-formatter-module.ts +19 -0
  371. package/src/formatter/libro-formatter-protocol.ts +63 -0
  372. package/src/formatter/libro-formatter-string-contribution.ts +41 -0
  373. package/src/formatter/libro-formatter-trans-default-contribution.ts +15 -0
  374. package/src/index.less +789 -0
  375. package/src/index.spec.ts +12 -0
  376. package/src/index.tsx +25 -0
  377. package/src/libro-context-key.ts +84 -0
  378. package/src/libro-keybind-registry.ts +43 -0
  379. package/src/libro-model.ts +710 -0
  380. package/src/libro-protocol.ts +435 -0
  381. package/src/libro-service.ts +234 -0
  382. package/src/libro-setting-contribution.ts +28 -0
  383. package/src/libro-setting.ts +110 -0
  384. package/src/libro-view-tracker.ts +9 -0
  385. package/src/libro-view.tsx +1532 -0
  386. package/src/libro-workspace-service.ts +28 -0
  387. package/src/material-from-designer.tsx +579 -0
  388. package/src/module.ts +121 -0
  389. package/src/output/index.ts +5 -0
  390. package/src/output/output-area.tsx +286 -0
  391. package/src/output/output-contribution.ts +14 -0
  392. package/src/output/output-model.tsx +70 -0
  393. package/src/output/output-module.ts +10 -0
  394. package/src/output/output-protocol.ts +168 -0
  395. package/src/settings/index.less +3 -0
  396. package/src/settings/index.ts +4 -0
  397. package/src/settings/module.ts +8 -0
  398. package/src/settings/setting-editor/configuration-panel-view.tsx +89 -0
  399. package/src/settings/setting-editor/configuration-render-contribution.ts +81 -0
  400. package/src/settings/setting-editor/default-node-render.tsx +65 -0
  401. package/src/settings/setting-editor/index.less +12 -0
  402. package/src/settings/setting-editor/index.ts +6 -0
  403. package/src/settings/setting-editor/module.ts +17 -0
  404. package/src/settings/setting-editor/setting-editor-view.tsx +93 -0
  405. package/src/settings/setting-editor/setting-tree-service.ts +82 -0
  406. package/src/settings/setting-editor/setting-tree-view.tsx +95 -0
  407. package/src/settings/settings-contribution.tsx +24 -0
  408. package/src/settings/settings-modal.less +3 -0
  409. package/src/settings/settings-modal.tsx +51 -0
  410. package/src/settings/settings-protocol.ts +7 -0
  411. package/src/slot/index.ts +4 -0
  412. package/src/slot/libro-slot-manager.ts +38 -0
  413. package/src/slot/libro-slot-protocol.ts +28 -0
  414. package/src/slot/libro-slot-view.tsx +48 -0
  415. package/src/slot/module.ts +9 -0
  416. package/src/theme/libro-color-registry.ts +386 -0
  417. package/src/toolbar/all-outputs-scroll-icon.tsx +19 -0
  418. package/src/toolbar/change-cell-to-selector.tsx +67 -0
  419. package/src/toolbar/hide-all-selector.tsx +126 -0
  420. package/src/toolbar/index.less +59 -0
  421. package/src/toolbar/index.ts +3 -0
  422. package/src/toolbar/libro-toolbar-protocol.ts +4 -0
  423. package/src/toolbar/libro-toolbar.tsx +231 -0
  424. package/src/toolbar/module.ts +11 -0
  425. package/src/toolbar/restart-clear-outputs-contribution.tsx +10 -0
  426. package/src/toolbar/restart-clear-outputs-modal.tsx +37 -0
  427. package/src/toolbar/save-icon.tsx +47 -0
  428. package/src/toolbar/shutdown-contribution.tsx +10 -0
  429. package/src/toolbar/shutdown-modal.tsx +37 -0
  430. package/src/toolbar/side-toolar-more-select.tsx +177 -0
  431. package/src/typings/index.d.ts +1 -0
  432. package/src/virtualized-manager-helper.ts +29 -0
  433. package/src/virtualized-manager.ts +47 -0
@@ -0,0 +1,1346 @@
1
+ import { MIME } from '@difizen/libro-common';
2
+ import type { CommandRegistry } from '@difizen/mana-app';
3
+ import {
4
+ inject,
5
+ ModalService,
6
+ singleton,
7
+ CommandContribution,
8
+ } from '@difizen/mana-app';
9
+ import { equals } from '@difizen/mana-app';
10
+ import { v4 } from 'uuid';
11
+
12
+ import { LibroCellView, ExecutableCellModel, EditorCellView } from '../cell/index.js';
13
+ import type { LibroEditorCellView } from '../cell/index.js';
14
+ import { LibroContextKey } from '../libro-context-key.js';
15
+ import type { LibroModel } from '../libro-model.js';
16
+ import type { CellView, NotebookView } from '../libro-protocol.js';
17
+ import { LibroToolbarArea } from '../libro-protocol.js';
18
+ import { LibroService } from '../libro-service.js';
19
+ import { LibroView } from '../libro-view.js';
20
+ import { SettingsModal } from '../settings/settings-modal.js';
21
+ import { RestartClearOutputModal } from '../toolbar/restart-clear-outputs-modal.js';
22
+ import { ShutdownModal } from '../toolbar/shutdown-modal.js';
23
+
24
+ import { DocumentCommands } from './document-commands.js';
25
+ import { LibroCommandRegister } from './libro-command-register.js';
26
+ import { NotebookCommands } from './notebook-commands.js';
27
+
28
+ @singleton({ contrib: CommandContribution })
29
+ export class LibroCommandContribution implements CommandContribution {
30
+ @inject(ModalService) protected readonly modalService: ModalService;
31
+ @inject(LibroCommandRegister) protected readonly libroCommand: LibroCommandRegister;
32
+ @inject(LibroService) protected readonly libroService: LibroService;
33
+ @inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
34
+
35
+ registerCommands(command: CommandRegistry): void {
36
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['EnterEditMode'], {
37
+ execute: async () => {
38
+ this.libroService.active?.enterEditMode();
39
+ },
40
+ isEnabled: (cell, libro) => {
41
+ if (!libro || !(libro instanceof LibroView) || !libro.model.inputEditable) {
42
+ return false;
43
+ }
44
+ return true;
45
+ },
46
+ });
47
+ this.libroCommand.registerLibroCommand(
48
+ command,
49
+ NotebookCommands['EnterCommandMode'],
50
+ {
51
+ execute: () => {
52
+ return this.libroService.active?.enterCommandMode(true);
53
+ },
54
+ },
55
+ );
56
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['SelectAll'], {
57
+ execute: (cell, libro) => {
58
+ if (!libro || !(libro instanceof LibroView)) {
59
+ return;
60
+ }
61
+ libro.selectAllCell();
62
+ },
63
+ });
64
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['RunCell'], {
65
+ execute: async (cell, libro) => {
66
+ if (
67
+ !cell ||
68
+ !libro ||
69
+ !(cell instanceof LibroCellView) ||
70
+ !(libro instanceof LibroView)
71
+ ) {
72
+ return;
73
+ }
74
+ if ((libro.model as LibroModel).executable) {
75
+ libro.runCell(cell);
76
+ }
77
+ },
78
+ isEnabled: (cell, libro) => {
79
+ if (!libro || !(libro instanceof LibroView)) {
80
+ return false;
81
+ }
82
+ return true;
83
+ },
84
+ });
85
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['RunAllCells'], {
86
+ execute: async (cell, libro) => {
87
+ if (!libro || !(libro instanceof LibroView)) {
88
+ return;
89
+ }
90
+ if ((libro.model as LibroModel).executable) {
91
+ libro.runAllCell();
92
+ }
93
+ },
94
+ });
95
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['RunAllAbove'], {
96
+ execute: async (cell, libro) => {
97
+ if (
98
+ !cell ||
99
+ !libro ||
100
+ !(cell instanceof LibroCellView) ||
101
+ !(libro instanceof LibroView)
102
+ ) {
103
+ return;
104
+ }
105
+ if ((libro.model as LibroModel).executable) {
106
+ libro.runAllAbove(cell);
107
+ }
108
+ },
109
+ });
110
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['RunAllBelow'], {
111
+ execute: async (cell, libro) => {
112
+ if (
113
+ !cell ||
114
+ !libro ||
115
+ !(cell instanceof LibroCellView) ||
116
+ !(libro instanceof LibroView)
117
+ ) {
118
+ return;
119
+ }
120
+ if ((libro.model as LibroModel).executable) {
121
+ libro.runAllBelow(cell);
122
+ }
123
+ },
124
+ });
125
+ this.libroCommand.registerLibroCommand(
126
+ command,
127
+ NotebookCommands['RunCellAndSelectNext'],
128
+ {
129
+ execute: async (cell, libro) => {
130
+ if (
131
+ !cell ||
132
+ !libro ||
133
+ !(cell instanceof LibroCellView) ||
134
+ !(libro instanceof LibroView)
135
+ ) {
136
+ return;
137
+ }
138
+ if ((libro.model as LibroModel).executable) {
139
+ libro.runCellandSelectNext(cell);
140
+ }
141
+ },
142
+ isEnabled: (cell, libro) => {
143
+ if (!libro || !(libro instanceof LibroView)) {
144
+ return false;
145
+ }
146
+ return true;
147
+ },
148
+ },
149
+ );
150
+ this.libroCommand.registerLibroCommand(
151
+ command,
152
+ NotebookCommands['RunCellAndInsertBelow'],
153
+ {
154
+ execute: async (cell, libro) => {
155
+ if (
156
+ !cell ||
157
+ !libro ||
158
+ !(cell instanceof LibroCellView) ||
159
+ !(libro instanceof LibroView)
160
+ ) {
161
+ return;
162
+ }
163
+ if ((libro.model as LibroModel).executable) {
164
+ libro.runCellandInsertBelow(cell);
165
+ }
166
+ },
167
+ isEnabled: (cell, libro) => {
168
+ if (!libro || !(libro instanceof LibroView)) {
169
+ return false;
170
+ }
171
+ return true;
172
+ },
173
+ },
174
+ );
175
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['Interrupt'], {
176
+ execute: async (cell, libro) => {
177
+ if (!libro || !(libro instanceof LibroView)) {
178
+ return false;
179
+ }
180
+ if (libro.model.interrupt) {
181
+ return libro.model.interrupt();
182
+ }
183
+ },
184
+ isEnabled: (cell, libro) => {
185
+ if (!libro || !(libro instanceof LibroView)) {
186
+ return false;
187
+ }
188
+ return (
189
+ libro.model
190
+ .getCells()
191
+ .findIndex(
192
+ (item) => ExecutableCellModel.is(item.model) && item.model.executing,
193
+ ) >= 0
194
+ );
195
+ },
196
+ isVisible: (cell, libro, path) => {
197
+ if (!libro || !(libro instanceof LibroView)) {
198
+ return false;
199
+ }
200
+ return (
201
+ (libro?.model as LibroModel).executable &&
202
+ path === LibroToolbarArea.HeaderCenter
203
+ );
204
+ },
205
+ });
206
+ this.libroCommand.registerLibroCommand(
207
+ command,
208
+ NotebookCommands['RestartClearOutput'],
209
+ {
210
+ execute: async (cell, libro) => {
211
+ if (!libro || !(libro instanceof LibroView)) {
212
+ return false;
213
+ }
214
+ return this.modalService.openModal(RestartClearOutputModal, libro);
215
+ },
216
+ isVisible: (cell, libro, path) => {
217
+ if (!libro || !(libro instanceof LibroView)) {
218
+ return false;
219
+ }
220
+ return (
221
+ (libro?.model as LibroModel).executable &&
222
+ path === LibroToolbarArea.HeaderCenter
223
+ );
224
+ },
225
+ },
226
+ );
227
+ this.libroCommand.registerLibroCommand(
228
+ command,
229
+ NotebookCommands['CloseAndShutdown'],
230
+ {
231
+ execute: async (cell, libro) => {
232
+ if (!libro || !(libro instanceof LibroView)) {
233
+ return false;
234
+ }
235
+ return this.modalService.openModal(ShutdownModal, libro);
236
+ },
237
+ isVisible: () => false,
238
+ // isVisible: (cell, libro, path) => {
239
+ // if (!libro || !(libro instanceof LibroView)) return false;
240
+ // if (path !== LibroToolbarArea.HeaderCenter || libro.model.quickEditMode) return false;
241
+ // return true;
242
+ // },
243
+ },
244
+ );
245
+ this.libroCommand.registerLibroCommand(
246
+ command,
247
+ NotebookCommands['InsertCellBelow'],
248
+ {
249
+ execute: async (cell, libro) => {
250
+ if (!libro || !(libro instanceof LibroView)) {
251
+ return;
252
+ }
253
+ if (!cell || !(cell instanceof LibroCellView)) {
254
+ libro.addCell(
255
+ { id: v4(), cell: { cell_type: 'code', source: '', metadata: {} } },
256
+ 0,
257
+ );
258
+ } else {
259
+ const cellIndex = libro.model.cells.findIndex((item) => equals(item, cell));
260
+ libro.addCell(
261
+ {
262
+ id: v4(),
263
+ cell: { cell_type: cell.model.type, source: '', metadata: {} },
264
+ },
265
+ cellIndex + 1,
266
+ );
267
+ }
268
+ },
269
+ // isVisible: () => false,
270
+ isVisible: (cell, libro, path) => {
271
+ if (!libro || !(libro instanceof LibroView)) {
272
+ return false;
273
+ }
274
+ return libro?.model.cellsEditable && path === LibroToolbarArea.CellRight;
275
+ },
276
+ isEnabled: (cell, libro) => {
277
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
278
+ return false;
279
+ }
280
+ return true;
281
+ },
282
+ },
283
+ );
284
+ this.libroCommand.registerLibroCommand(
285
+ command,
286
+ NotebookCommands['InsertCellAbove'],
287
+ {
288
+ execute: async (cell, libro) => {
289
+ if (
290
+ !cell ||
291
+ !libro ||
292
+ !(cell instanceof LibroCellView) ||
293
+ !(libro instanceof LibroView)
294
+ ) {
295
+ return;
296
+ }
297
+ const cellIndex = libro.model.cells.findIndex((item) => equals(item, cell));
298
+ if (cellIndex > -1) {
299
+ libro.addCellAbove(
300
+ {
301
+ id: v4(),
302
+ cell: { cell_type: cell.model.type, source: '', metadata: {} },
303
+ },
304
+ cellIndex,
305
+ );
306
+ }
307
+ },
308
+ isEnabled: (cell, libro) => {
309
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
310
+ return false;
311
+ }
312
+ return true;
313
+ },
314
+ },
315
+ );
316
+
317
+ command.registerCommand(NotebookCommands['InsertCellBottom'], {
318
+ execute: async (libro, targetType) => {
319
+ if (!libro || !(libro instanceof LibroView)) {
320
+ return;
321
+ }
322
+ const nextIndex = libro.model.cells.length;
323
+ libro.addCell(
324
+ {
325
+ cell: {
326
+ cell_type: targetType,
327
+ metadata: {},
328
+ source: '',
329
+ },
330
+ },
331
+ nextIndex,
332
+ );
333
+ },
334
+ });
335
+
336
+ this.libroCommand.registerLibroCommand(
337
+ command,
338
+ NotebookCommands['MoveCursorDown'],
339
+ {
340
+ execute: async (cell, libro) => {
341
+ if (
342
+ !cell ||
343
+ !libro ||
344
+ !(cell instanceof LibroCellView) ||
345
+ !(libro instanceof LibroView)
346
+ ) {
347
+ return;
348
+ }
349
+ libro.moveCursorDown(cell);
350
+ },
351
+ },
352
+ );
353
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['MoveCursorUp'], {
354
+ execute: async (cell, libro) => {
355
+ if (
356
+ !cell ||
357
+ !libro ||
358
+ !(cell instanceof LibroCellView) ||
359
+ !(libro instanceof LibroView)
360
+ ) {
361
+ return;
362
+ }
363
+ libro.moveCursorUp(cell);
364
+ },
365
+ });
366
+ this.libroCommand.registerLibroCommand(
367
+ command,
368
+ NotebookCommands['MergeCellBelow'],
369
+ {
370
+ execute: async (cell, libro) => {
371
+ if (
372
+ !cell ||
373
+ !libro ||
374
+ !(cell instanceof LibroCellView) ||
375
+ !(libro instanceof LibroView)
376
+ ) {
377
+ return;
378
+ }
379
+ libro.mergeCellBelow(cell);
380
+ },
381
+ isEnabled: (cell, libro) => {
382
+ if (
383
+ !libro ||
384
+ !(libro instanceof LibroView) ||
385
+ !libro.model.inputEditable ||
386
+ !libro.model.cellsEditable
387
+ ) {
388
+ return false;
389
+ }
390
+ return true;
391
+ },
392
+ },
393
+ );
394
+ this.libroCommand.registerLibroCommand(
395
+ command,
396
+ NotebookCommands['MergeCellAbove'],
397
+ {
398
+ execute: async (cell, libro) => {
399
+ if (
400
+ !cell ||
401
+ !libro ||
402
+ !(cell instanceof LibroCellView) ||
403
+ !(libro instanceof LibroView)
404
+ ) {
405
+ return;
406
+ }
407
+ libro.mergeCellAbove(cell);
408
+ },
409
+ isEnabled: (cell, libro) => {
410
+ if (
411
+ !libro ||
412
+ !(libro instanceof LibroView) ||
413
+ !libro.model.inputEditable ||
414
+ !libro.model.cellsEditable
415
+ ) {
416
+ return false;
417
+ }
418
+ return true;
419
+ },
420
+ },
421
+ );
422
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['MergeCells'], {
423
+ execute: async (cell, libro) => {
424
+ if (
425
+ !cell ||
426
+ !libro ||
427
+ !(cell instanceof LibroCellView) ||
428
+ !(libro instanceof LibroView)
429
+ ) {
430
+ return;
431
+ }
432
+ libro.mergeCells(cell);
433
+ },
434
+ isEnabled: (cell, libro) => {
435
+ if (
436
+ !libro ||
437
+ !(libro instanceof LibroView) ||
438
+ !libro.model.inputEditable ||
439
+ !libro.model.cellsEditable
440
+ ) {
441
+ return false;
442
+ }
443
+ return true;
444
+ },
445
+ });
446
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['DeleteCell'], {
447
+ execute: async (cell, libro) => {
448
+ if (
449
+ !cell ||
450
+ !libro ||
451
+ !(cell instanceof LibroCellView) ||
452
+ !(libro instanceof LibroView)
453
+ ) {
454
+ return;
455
+ }
456
+ libro.deleteCell(cell);
457
+ },
458
+ isVisible: (cell, libro, path) => {
459
+ if (!libro || !(libro instanceof LibroView)) {
460
+ return false;
461
+ }
462
+ return libro?.model.cellsEditable && path === LibroToolbarArea.CellRight;
463
+ },
464
+ isEnabled: (cell, libro) => {
465
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
466
+ return false;
467
+ }
468
+ return true;
469
+ },
470
+ });
471
+ this.libroCommand.registerLibroCommand(
472
+ command,
473
+ NotebookCommands['ClearCellOutput'],
474
+ {
475
+ execute: async (cell, libro) => {
476
+ if (
477
+ !cell ||
478
+ !libro ||
479
+ !(cell instanceof LibroCellView) ||
480
+ !(libro instanceof LibroView)
481
+ ) {
482
+ return;
483
+ }
484
+ libro.clearOutputs(cell);
485
+ },
486
+ isEnabled: (cell, libro) => {
487
+ if (!libro || !(libro instanceof LibroView) || !libro.model.outputEditable) {
488
+ return false;
489
+ }
490
+ return true;
491
+ },
492
+ },
493
+ );
494
+ this.libroCommand.registerLibroCommand(
495
+ command,
496
+ NotebookCommands['ClearAllCellOutput'],
497
+ {
498
+ execute: async (cell, libro) => {
499
+ if (!libro || !(libro instanceof LibroView)) {
500
+ return;
501
+ }
502
+ libro.clearAllOutputs();
503
+ },
504
+ isVisible: (cell, libro, path) => {
505
+ if (!libro || !(libro instanceof LibroView)) {
506
+ return false;
507
+ }
508
+ return libro?.model.outputEditable && path === LibroToolbarArea.HeaderCenter;
509
+ },
510
+ isEnabled: (cell, libro) => {
511
+ if (!libro || !(libro instanceof LibroView) || !libro.model.outputEditable) {
512
+ return false;
513
+ }
514
+ return true;
515
+ },
516
+ },
517
+ );
518
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['MoveCellUp'], {
519
+ execute: async (cell, libro) => {
520
+ if (
521
+ !cell ||
522
+ !libro ||
523
+ !(cell instanceof LibroCellView) ||
524
+ !(libro instanceof LibroView)
525
+ ) {
526
+ return;
527
+ }
528
+ libro.moveUpCell(cell);
529
+ },
530
+ isVisible: (cell, libro, path) => {
531
+ return path === LibroToolbarArea.CellRight;
532
+ },
533
+ isEnabled: (cell, libro) => {
534
+ if (
535
+ !cell ||
536
+ !libro ||
537
+ !(cell instanceof LibroCellView) ||
538
+ !(libro instanceof LibroView) ||
539
+ !libro.model.cellsEditable
540
+ ) {
541
+ return false;
542
+ }
543
+ const cellIndex = libro.model
544
+ .getCells()
545
+ .findIndex((item) => equals(item, cell));
546
+ return cellIndex > 0;
547
+ },
548
+ });
549
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['MoveCellDown'], {
550
+ execute: async (cell, libro) => {
551
+ if (
552
+ !cell ||
553
+ !libro ||
554
+ !(cell instanceof LibroCellView) ||
555
+ !(libro instanceof LibroView)
556
+ ) {
557
+ return;
558
+ }
559
+ libro.moveDownCell(cell);
560
+ },
561
+ isEnabled: (cell, libro) => {
562
+ if (
563
+ !cell ||
564
+ !libro ||
565
+ !(cell instanceof LibroCellView) ||
566
+ !(libro instanceof LibroView) ||
567
+ !libro.model.cellsEditable
568
+ ) {
569
+ return false;
570
+ }
571
+ const cellIndex = libro.model
572
+ .getCells()
573
+ .findIndex((item) => equals(item, cell));
574
+ return cellIndex !== libro.model.getCells().length - 1;
575
+ },
576
+ isVisible: (cell, libro, path) => {
577
+ return path === LibroToolbarArea.CellRight;
578
+ },
579
+ });
580
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['CopyCell'], {
581
+ execute: async (cell, libro) => {
582
+ if (
583
+ !cell ||
584
+ !libro ||
585
+ !(cell instanceof LibroCellView) ||
586
+ !(libro instanceof LibroView)
587
+ ) {
588
+ return;
589
+ }
590
+ libro.copyCell(cell);
591
+ },
592
+ isVisible: () => false,
593
+ // isVisible: (cell, libro, path) => {
594
+ // if (
595
+ // ![LibroToolbarArea.CellRight, LibroToolbarArea.HeaderCenter].find(item => item === path)
596
+ // ) {
597
+ // return false;
598
+ // }
599
+ // return true;
600
+ // },
601
+ isEnabled: (cell, libro) => {
602
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
603
+ return false;
604
+ }
605
+ return true;
606
+ },
607
+ });
608
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['CutCell'], {
609
+ execute: async (cell, libro) => {
610
+ if (
611
+ !cell ||
612
+ !libro ||
613
+ !(cell instanceof LibroCellView) ||
614
+ !(libro instanceof LibroView)
615
+ ) {
616
+ return;
617
+ }
618
+ libro.cutCell(cell);
619
+ },
620
+ isVisible: () => false,
621
+ // isVisible: (cell, libro, path) => {
622
+ // if (
623
+ // ![LibroToolbarArea.CellRight, LibroToolbarArea.HeaderCenter].find(item => item === path)
624
+ // ) {
625
+ // return false;
626
+ // }
627
+ // return true;
628
+ // },
629
+ isEnabled: (cell, libro) => {
630
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
631
+ return false;
632
+ }
633
+ return true;
634
+ },
635
+ });
636
+ this.libroCommand.registerLibroCommand(
637
+ command,
638
+ NotebookCommands['PasteCellAbove'],
639
+ {
640
+ execute: async (cell, libro) => {
641
+ if (
642
+ !cell ||
643
+ !libro ||
644
+ !(cell instanceof LibroCellView) ||
645
+ !(libro instanceof LibroView)
646
+ ) {
647
+ return;
648
+ }
649
+ libro.pasteCellAbove(cell);
650
+ },
651
+ isEnabled: (cell, libro) => {
652
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
653
+ return false;
654
+ }
655
+ return true;
656
+ },
657
+ },
658
+ );
659
+ this.libroCommand.registerLibroCommand(
660
+ command,
661
+ NotebookCommands['PasteCellBelow'],
662
+ {
663
+ execute: async (cell, libro) => {
664
+ if (
665
+ !cell ||
666
+ !libro ||
667
+ !(cell instanceof LibroCellView) ||
668
+ !(libro instanceof LibroView)
669
+ ) {
670
+ return;
671
+ }
672
+ libro.pasteCell(cell);
673
+ },
674
+ isVisible: () => false,
675
+ // isVisible: (cell, libro, path) => {
676
+ // if (
677
+ // ![LibroToolbarArea.CellRight, LibroToolbarArea.HeaderCenter].find(item => item === path)
678
+ // ) {
679
+ // return false;
680
+ // }
681
+ // return true;
682
+ // },
683
+ isEnabled: (cell, libro) => {
684
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
685
+ return false;
686
+ }
687
+ return true;
688
+ },
689
+ },
690
+ );
691
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['HideCellCode'], {
692
+ execute: async (cell, libro) => {
693
+ if (
694
+ !cell ||
695
+ !libro ||
696
+ !(cell instanceof LibroCellView) ||
697
+ !(libro instanceof LibroView)
698
+ ) {
699
+ return;
700
+ }
701
+ libro.hideCellCode(cell);
702
+ },
703
+ isVisible: (cell, libro, path) => {
704
+ if (path === LibroToolbarArea.HeaderCenter) {
705
+ return true;
706
+ }
707
+ return false;
708
+ },
709
+ });
710
+ this.libroCommand.registerLibroCommand(
711
+ command,
712
+ NotebookCommands['HideOrShowCellCode'],
713
+ {
714
+ execute: async (cell, libro) => {
715
+ if (
716
+ !cell ||
717
+ !libro ||
718
+ !(cell instanceof LibroCellView) ||
719
+ !(libro instanceof LibroView)
720
+ ) {
721
+ return;
722
+ }
723
+ libro.hideOrShowCellCode(cell);
724
+ },
725
+ },
726
+ );
727
+ this.libroCommand.registerLibroCommand(
728
+ command,
729
+ NotebookCommands['HideCellOutputs'],
730
+ {
731
+ execute: async (cell, libro) => {
732
+ if (
733
+ !cell ||
734
+ !libro ||
735
+ !(cell instanceof LibroCellView) ||
736
+ !(libro instanceof LibroView)
737
+ ) {
738
+ return;
739
+ }
740
+ libro.hideOutputs(cell);
741
+ },
742
+ isVisible: (cell, libro, path) => {
743
+ if (
744
+ cell &&
745
+ cell instanceof LibroCellView &&
746
+ ExecutableCellModel.is(cell.model) &&
747
+ path === LibroToolbarArea.CellRight
748
+ ) {
749
+ return true;
750
+ }
751
+ return false;
752
+ },
753
+ },
754
+ );
755
+ this.libroCommand.registerLibroCommand(
756
+ command,
757
+ NotebookCommands['HideOrShowOutputs'],
758
+ {
759
+ execute: async (cell, libro) => {
760
+ if (
761
+ !cell ||
762
+ !libro ||
763
+ !(cell instanceof LibroCellView) ||
764
+ !(libro instanceof LibroView)
765
+ ) {
766
+ return;
767
+ }
768
+ libro.hideOrShowOutputs(cell);
769
+ },
770
+ },
771
+ );
772
+ this.libroCommand.registerLibroCommand(
773
+ command,
774
+ NotebookCommands['HideAllCellCode'],
775
+ {
776
+ execute: async (cell, libro) => {
777
+ if (!libro || !(libro instanceof LibroView)) {
778
+ return;
779
+ }
780
+ libro.hideAllCellCode();
781
+ },
782
+ },
783
+ );
784
+ this.libroCommand.registerLibroCommand(
785
+ command,
786
+ NotebookCommands['HideAllCellOutput'],
787
+ {
788
+ execute: async (cell, libro) => {
789
+ if (!libro || !(libro instanceof LibroView)) {
790
+ return;
791
+ }
792
+ libro.hideAllOutputs();
793
+ },
794
+ },
795
+ );
796
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['HideAllCell'], {
797
+ execute: () => {
798
+ //
799
+ },
800
+ isVisible: (cell, libro, path) => {
801
+ if (!libro || !(libro instanceof LibroView)) {
802
+ return false;
803
+ }
804
+ return path === LibroToolbarArea.HeaderCenter;
805
+ },
806
+ isEnabled: (cell, libro) => {
807
+ if (!libro || !(libro instanceof LibroView)) {
808
+ return false;
809
+ }
810
+ return true;
811
+ },
812
+ });
813
+ this.libroCommand.registerLibroCommand(
814
+ command,
815
+ NotebookCommands['ShowCellOutputs'],
816
+ {
817
+ execute: async (cell, libro) => {
818
+ if (
819
+ !cell ||
820
+ !libro ||
821
+ !(cell instanceof LibroCellView) ||
822
+ !(libro instanceof LibroView)
823
+ ) {
824
+ return;
825
+ }
826
+ libro.showCellOutputs(cell);
827
+ },
828
+ },
829
+ );
830
+ this.libroCommand.registerLibroCommand(
831
+ command,
832
+ NotebookCommands['ShowAllCellOutputs'],
833
+ {
834
+ execute: async (cell, libro) => {
835
+ if (!libro || !(libro instanceof LibroView)) {
836
+ return;
837
+ }
838
+ libro.showAllCellOutputs();
839
+ },
840
+ },
841
+ );
842
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['ShowCellCode'], {
843
+ execute: async (cell, libro) => {
844
+ if (
845
+ !cell ||
846
+ !libro ||
847
+ !(cell instanceof LibroCellView) ||
848
+ !(libro instanceof LibroView)
849
+ ) {
850
+ return;
851
+ }
852
+ libro.showCellCode(cell);
853
+ },
854
+ });
855
+ this.libroCommand.registerLibroCommand(
856
+ command,
857
+ NotebookCommands['ShowAllCellCode'],
858
+ {
859
+ execute: async (cell, libro) => {
860
+ if (!libro || !(libro instanceof LibroView)) {
861
+ return;
862
+ }
863
+ libro.showAllCellCode();
864
+ },
865
+ },
866
+ );
867
+ this.libroCommand.registerLibroCommand(
868
+ command,
869
+ NotebookCommands['ExtendMarkedCellsAbove'],
870
+ {
871
+ execute: async (cell, libro) => {
872
+ if (!libro || !(libro instanceof LibroView)) {
873
+ return;
874
+ }
875
+ libro.extendSelectionAbove();
876
+ },
877
+ },
878
+ );
879
+ this.libroCommand.registerLibroCommand(
880
+ command,
881
+ NotebookCommands['ExtendMarkedCellsTop'],
882
+ {
883
+ execute: async (cell, libro) => {
884
+ if (!libro || !(libro instanceof LibroView)) {
885
+ return;
886
+ }
887
+ libro.extendSelectionToTop();
888
+ },
889
+ },
890
+ );
891
+ this.libroCommand.registerLibroCommand(
892
+ command,
893
+ NotebookCommands['ExtendMarkedCellsBelow'],
894
+ {
895
+ execute: async (cell, libro) => {
896
+ if (!libro || !(libro instanceof LibroView)) {
897
+ return;
898
+ }
899
+ libro.extendSelectionBelow();
900
+ },
901
+ },
902
+ );
903
+ this.libroCommand.registerLibroCommand(
904
+ command,
905
+ NotebookCommands['ExtendMarkedCellsBottom'],
906
+ {
907
+ execute: async (cell, libro) => {
908
+ if (!libro || !(libro instanceof LibroView)) {
909
+ return;
910
+ }
911
+ libro.extendSelectionToBottom();
912
+ },
913
+ },
914
+ );
915
+ command.registerCommand(NotebookCommands['ChangeCellTo'], {
916
+ execute: async (cell, libro, path, targetType) => {
917
+ if (
918
+ !cell ||
919
+ !libro ||
920
+ !(libro instanceof LibroView) ||
921
+ !(cell instanceof LibroCellView)
922
+ ) {
923
+ return;
924
+ }
925
+
926
+ if (targetType) {
927
+ libro.invertCell(cell, targetType);
928
+ }
929
+ },
930
+ isVisible: (cell, libro, path) => {
931
+ if (!libro || !(libro instanceof LibroView)) {
932
+ return false;
933
+ }
934
+ return libro?.model.cellsEditable && path === LibroToolbarArea.HeaderCenter;
935
+ },
936
+ isEnabled: (cell, libro) => {
937
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
938
+ return false;
939
+ }
940
+ return true;
941
+ },
942
+ });
943
+ this.libroCommand.registerLibroCommand(
944
+ command,
945
+ NotebookCommands['ChangeCellToCode'],
946
+ {
947
+ execute: (cell: CellView | undefined, libro: NotebookView | undefined) => {
948
+ if (
949
+ !cell ||
950
+ !libro ||
951
+ !(cell instanceof LibroCellView) ||
952
+ !(libro instanceof LibroView)
953
+ ) {
954
+ return;
955
+ }
956
+ libro.invertCell(cell, 'code');
957
+ },
958
+ isEnabled: (cell, libro) => {
959
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
960
+ return false;
961
+ }
962
+ return true;
963
+ },
964
+ },
965
+ );
966
+ this.libroCommand.registerLibroCommand(
967
+ command,
968
+ NotebookCommands['ChangeCellToMarkdown'],
969
+ {
970
+ execute: (cell: CellView | undefined, libro: NotebookView | undefined) => {
971
+ if (
972
+ !cell ||
973
+ !libro ||
974
+ !(cell instanceof LibroCellView) ||
975
+ !(libro instanceof LibroView)
976
+ ) {
977
+ return;
978
+ }
979
+ libro.invertCell(cell, 'markdown');
980
+ },
981
+ isEnabled: (cell, libro) => {
982
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
983
+ return false;
984
+ }
985
+ return true;
986
+ },
987
+ },
988
+ );
989
+ this.libroCommand.registerLibroCommand(
990
+ command,
991
+ NotebookCommands['EnableOutputScrolling'],
992
+ {
993
+ execute: (cell: CellView | undefined, libro: NotebookView | undefined) => {
994
+ if (
995
+ !cell ||
996
+ !libro ||
997
+ !(cell instanceof LibroCellView) ||
998
+ !(libro instanceof LibroView)
999
+ ) {
1000
+ return;
1001
+ }
1002
+ libro.enableOutputScrolling(cell);
1003
+ },
1004
+ },
1005
+ );
1006
+ this.libroCommand.registerLibroCommand(
1007
+ command,
1008
+ NotebookCommands['DisableOutputScrolling'],
1009
+ {
1010
+ execute: (cell: CellView | undefined, libro: NotebookView | undefined) => {
1011
+ if (
1012
+ !cell ||
1013
+ !libro ||
1014
+ !(cell instanceof LibroCellView) ||
1015
+ !(libro instanceof LibroView)
1016
+ ) {
1017
+ return;
1018
+ }
1019
+ libro.disableOutputScrolling(cell);
1020
+ },
1021
+ },
1022
+ );
1023
+ this.libroCommand.registerLibroCommand(
1024
+ command,
1025
+ NotebookCommands['EnableOrDisableAllOutputScrolling'],
1026
+ {
1027
+ execute: (cell: CellView | undefined, libro: NotebookView | undefined) => {
1028
+ if (!libro || !(libro instanceof LibroView)) {
1029
+ return;
1030
+ }
1031
+ if (libro.outputsScroll) {
1032
+ libro.disableAllOutputScrolling();
1033
+ } else {
1034
+ libro.enableAllOutputScrolling();
1035
+ }
1036
+ },
1037
+ isVisible: (cell, libro, path) => {
1038
+ if (!libro || !(libro instanceof LibroView)) {
1039
+ return false;
1040
+ }
1041
+ return path === LibroToolbarArea.HeaderCenter;
1042
+ },
1043
+ },
1044
+ );
1045
+ this.libroCommand.registerLibroCommand(command, DocumentCommands['Save'], {
1046
+ execute: async (cell, libro) => {
1047
+ if (!libro || !(libro instanceof LibroView) || !libro.model.savable) {
1048
+ return;
1049
+ }
1050
+ libro.save();
1051
+ },
1052
+ isVisible: (cell, libro, path) => {
1053
+ if (!libro || !(libro instanceof LibroView) || !libro.model.savable) {
1054
+ return false;
1055
+ }
1056
+ return libro?.model.savable && path === LibroToolbarArea.HeaderCenter;
1057
+ },
1058
+ isEnabled: (cell, libro) => {
1059
+ if (!libro || !(libro instanceof LibroView)) {
1060
+ return false;
1061
+ }
1062
+ return true;
1063
+ },
1064
+ });
1065
+ this.libroCommand.registerLibroCommand(command, DocumentCommands['OpenSettings'], {
1066
+ execute: async () => {
1067
+ this.modalService.openModal(SettingsModal);
1068
+ },
1069
+ isVisible: (cell, libro, path) => {
1070
+ if (!libro || !(libro instanceof LibroView)) {
1071
+ return false;
1072
+ }
1073
+ return path === LibroToolbarArea.HeaderRight;
1074
+ },
1075
+ });
1076
+ this.libroCommand.registerLibroCommand(command, DocumentCommands['FormatCell'], {
1077
+ execute: async (cell) => {
1078
+ if (EditorCellView.is(cell) && cell.editor?.model.mimeType === MIME.python) {
1079
+ cell.editor?.format();
1080
+ }
1081
+ },
1082
+ isVisible: (cell, libro, path) => {
1083
+ if (!libro || !(libro instanceof LibroView)) {
1084
+ return false;
1085
+ }
1086
+ return (
1087
+ this.libroService.hasFormatter &&
1088
+ libro?.model.inputEditable &&
1089
+ EditorCellView.is(cell) &&
1090
+ cell.model.mimeType === MIME.python &&
1091
+ path === LibroToolbarArea.CellRight
1092
+ );
1093
+ },
1094
+ });
1095
+ this.libroCommand.registerLibroCommand(
1096
+ command,
1097
+ NotebookCommands['UndoCellAction'],
1098
+ {
1099
+ execute: async (cell, libro) => {
1100
+ if (!libro || !(libro instanceof LibroView)) {
1101
+ return;
1102
+ }
1103
+
1104
+ libro.model.undo();
1105
+ },
1106
+ isVisible: (cell, libro, path) => {
1107
+ if (!libro || !(libro instanceof LibroView)) {
1108
+ return false;
1109
+ }
1110
+ return libro?.model.cellsEditable && path === LibroToolbarArea.HeaderCenter;
1111
+ },
1112
+ isEnabled: (cell, libro) => {
1113
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1114
+ return false;
1115
+ }
1116
+
1117
+ return libro.model.canUndo ?? false;
1118
+ },
1119
+ },
1120
+ );
1121
+ this.libroCommand.registerLibroCommand(
1122
+ command,
1123
+ NotebookCommands['RedoCellAction'],
1124
+ {
1125
+ execute: async (cell, libro) => {
1126
+ if (!libro || !(libro instanceof LibroView)) {
1127
+ return;
1128
+ }
1129
+ libro.model.redo();
1130
+ },
1131
+ isVisible: (cell, libro, path) => {
1132
+ if (!libro || !(libro instanceof LibroView)) {
1133
+ return false;
1134
+ }
1135
+ return libro?.model.cellsEditable && path === LibroToolbarArea.HeaderCenter;
1136
+ },
1137
+ isEnabled: (cell, libro) => {
1138
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1139
+ return false;
1140
+ }
1141
+ return libro.model.canRedo ?? false;
1142
+ },
1143
+ },
1144
+ );
1145
+ this.libroCommand.registerLibroCommand(
1146
+ command,
1147
+ NotebookCommands['SplitCellAntCursor'],
1148
+ {
1149
+ execute: (cell: CellView | undefined, libro: NotebookView | undefined) => {
1150
+ if (
1151
+ !cell ||
1152
+ !libro ||
1153
+ !(cell instanceof LibroCellView) ||
1154
+ !(libro instanceof LibroView)
1155
+ ) {
1156
+ return;
1157
+ }
1158
+ libro.splitCell(cell);
1159
+ },
1160
+ isEnabled: (cell, libro) => {
1161
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1162
+ return false;
1163
+ }
1164
+ return true;
1165
+ },
1166
+ },
1167
+ );
1168
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['Redo'], {
1169
+ execute: async (cell) => {
1170
+ if (!cell || !(cell instanceof LibroCellView)) {
1171
+ return;
1172
+ }
1173
+ (cell as LibroEditorCellView).redo();
1174
+ },
1175
+ isEnabled: (cell, libro) => {
1176
+ if (!libro || !(libro instanceof LibroView) || !libro.model.inputEditable) {
1177
+ return false;
1178
+ }
1179
+ return true;
1180
+ },
1181
+ });
1182
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['Undo'], {
1183
+ execute: async (cell) => {
1184
+ if (!cell || !(cell instanceof LibroCellView)) {
1185
+ return;
1186
+ }
1187
+ (cell as LibroEditorCellView).undo();
1188
+ },
1189
+ isEnabled: (cell, libro) => {
1190
+ if (!libro || !(libro instanceof LibroView) || !libro.model.inputEditable) {
1191
+ return false;
1192
+ }
1193
+ return true;
1194
+ },
1195
+ });
1196
+ this.libroCommand.registerLibroCommand(
1197
+ command,
1198
+ NotebookCommands['ChangeCellToHeading1'],
1199
+ {
1200
+ execute: (cell, libro) => {
1201
+ if (
1202
+ !cell ||
1203
+ !libro ||
1204
+ !(cell instanceof LibroCellView) ||
1205
+ !(libro instanceof LibroView)
1206
+ ) {
1207
+ return;
1208
+ }
1209
+ libro.setMarkdownHeader(cell, 1);
1210
+ },
1211
+ isEnabled: (cell, libro) => {
1212
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1213
+ return false;
1214
+ }
1215
+ return true;
1216
+ },
1217
+ },
1218
+ );
1219
+ this.libroCommand.registerLibroCommand(
1220
+ command,
1221
+ NotebookCommands['ChangeCellToHeading2'],
1222
+ {
1223
+ execute: (cell, libro) => {
1224
+ if (
1225
+ !cell ||
1226
+ !libro ||
1227
+ !(cell instanceof LibroCellView) ||
1228
+ !(libro instanceof LibroView)
1229
+ ) {
1230
+ return;
1231
+ }
1232
+ libro.setMarkdownHeader(cell, 2);
1233
+ },
1234
+ isEnabled: (cell, libro) => {
1235
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1236
+ return false;
1237
+ }
1238
+ return true;
1239
+ },
1240
+ },
1241
+ );
1242
+ this.libroCommand.registerLibroCommand(
1243
+ command,
1244
+ NotebookCommands['ChangeCellToHeading3'],
1245
+ {
1246
+ execute: (cell, libro) => {
1247
+ if (
1248
+ !cell ||
1249
+ !libro ||
1250
+ !(cell instanceof LibroCellView) ||
1251
+ !(libro instanceof LibroView)
1252
+ ) {
1253
+ return;
1254
+ }
1255
+ libro.setMarkdownHeader(cell, 3);
1256
+ },
1257
+ isEnabled: (cell, libro) => {
1258
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1259
+ return false;
1260
+ }
1261
+ return true;
1262
+ },
1263
+ },
1264
+ );
1265
+ this.libroCommand.registerLibroCommand(
1266
+ command,
1267
+ NotebookCommands['ChangeCellToHeading4'],
1268
+ {
1269
+ execute: (cell, libro) => {
1270
+ if (
1271
+ !cell ||
1272
+ !libro ||
1273
+ !(cell instanceof LibroCellView) ||
1274
+ !(libro instanceof LibroView)
1275
+ ) {
1276
+ return;
1277
+ }
1278
+ libro.setMarkdownHeader(cell, 4);
1279
+ },
1280
+ isEnabled: (cell, libro) => {
1281
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1282
+ return false;
1283
+ }
1284
+ return true;
1285
+ },
1286
+ },
1287
+ );
1288
+ this.libroCommand.registerLibroCommand(
1289
+ command,
1290
+ NotebookCommands['ChangeCellToHeading5'],
1291
+ {
1292
+ execute: (cell, libro) => {
1293
+ if (
1294
+ !cell ||
1295
+ !libro ||
1296
+ !(cell instanceof LibroCellView) ||
1297
+ !(libro instanceof LibroView)
1298
+ ) {
1299
+ return;
1300
+ }
1301
+ libro.setMarkdownHeader(cell, 5);
1302
+ },
1303
+ isEnabled: (cell, libro) => {
1304
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1305
+ return false;
1306
+ }
1307
+ return true;
1308
+ },
1309
+ },
1310
+ );
1311
+ this.libroCommand.registerLibroCommand(
1312
+ command,
1313
+ NotebookCommands['ChangeCellToHeading6'],
1314
+ {
1315
+ execute: (cell, libro) => {
1316
+ if (
1317
+ !cell ||
1318
+ !libro ||
1319
+ !(cell instanceof LibroCellView) ||
1320
+ !(libro instanceof LibroView)
1321
+ ) {
1322
+ return;
1323
+ }
1324
+ libro.setMarkdownHeader(cell, 6);
1325
+ },
1326
+ isEnabled: (cell, libro) => {
1327
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1328
+ return false;
1329
+ }
1330
+ return true;
1331
+ },
1332
+ },
1333
+ );
1334
+
1335
+ this.libroCommand.registerLibroCommand(command, NotebookCommands['More'], {
1336
+ execute: async (cell, libro) => {
1337
+ if (!libro || !(libro instanceof LibroView)) {
1338
+ return;
1339
+ }
1340
+ },
1341
+ isVisible: (cell, libro, path) => {
1342
+ return path === LibroToolbarArea.CellRight;
1343
+ },
1344
+ });
1345
+ }
1346
+ }