@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,99 @@
1
+ import { DisplayWrapComponent } from '@difizen/libro-common';
2
+ import {
3
+ inject,
4
+ transient,
5
+ prop,
6
+ useInject,
7
+ BaseView,
8
+ CommandRegistry,
9
+ view,
10
+ ViewInstance,
11
+ } from '@difizen/mana-app';
12
+ import { Button } from 'antd';
13
+ import { forwardRef } from 'react';
14
+
15
+ import { CellService } from '../cell/index.js';
16
+ import type { CellMeta } from '../cell/index.js';
17
+ import { NotebookCommands } from '../command/index.js';
18
+ import type { LibroView } from '../libro-view.js';
19
+ import { PlusOutlined } from '../material-from-designer.js';
20
+ import './index.less';
21
+
22
+ type AddType = {
23
+ name: string;
24
+ type: string;
25
+ };
26
+
27
+ export const LibroAddCell: React.FC = () => {
28
+ const instance = useInject<LibroAddCellView>(ViewInstance);
29
+ const command = useInject(CommandRegistry);
30
+ const addCell = async (type: string) => {
31
+ command.executeCommand(
32
+ NotebookCommands['InsertCellBottom'].id,
33
+ instance.parent,
34
+ type,
35
+ );
36
+ };
37
+ return (
38
+ <div className="libro-add-cell-container default-add-cell-container">
39
+ {instance.getCellList().map((item: AddType) => {
40
+ return (
41
+ <Button
42
+ className="libro-add-cell-container-item "
43
+ key={item.name}
44
+ onClick={() => {
45
+ addCell(item.type);
46
+ }}
47
+ icon={<PlusOutlined className="libro-add-cell-icon" />}
48
+ >
49
+ {item.name}
50
+ </Button>
51
+ );
52
+ })}
53
+ </div>
54
+ );
55
+ };
56
+
57
+ export const LibroWrappedAddCell = forwardRef(function LibroWrappedAddCell() {
58
+ const instance = useInject<LibroAddCellView>(ViewInstance);
59
+ return (
60
+ <DisplayWrapComponent mode={!instance.parent?.model.cellsEditable}>
61
+ <LibroAddCell />
62
+ </DisplayWrapComponent>
63
+ );
64
+ });
65
+
66
+ @transient()
67
+ @view('libro-add-cell-view')
68
+ export class LibroAddCellView extends BaseView {
69
+ parent: LibroView | undefined = undefined;
70
+ override view = LibroWrappedAddCell;
71
+
72
+ @prop()
73
+ addList: CellMeta[] = [];
74
+
75
+ cellService: CellService;
76
+
77
+ constructor(@inject(CellService) cellService: CellService) {
78
+ super();
79
+ this.cellService = cellService;
80
+ }
81
+
82
+ override onViewMount() {
83
+ this.addList = this.cellService.cellsMeta;
84
+ }
85
+
86
+ override onViewUnmount() {
87
+ //
88
+ }
89
+
90
+ override onViewResize() {
91
+ //
92
+ }
93
+
94
+ defaultFilter = (cellmeta: CellMeta) => cellmeta.type !== 'raw';
95
+
96
+ getCellList(filter = this.defaultFilter) {
97
+ return this.addList.filter(filter);
98
+ }
99
+ }
@@ -0,0 +1,14 @@
1
+ # Cell abstraction
2
+
3
+ ## Cell View
4
+
5
+ 缩进代表继承关系
6
+
7
+ - LibroCellView
8
+ - LibroEditorCellView: 带有文本编辑器相关能力
9
+ - LibroEditableExecutableCellView: 带有执行、输出能力
10
+ - LibroCodeCellView
11
+ - AIStudioLibroCodeCellView
12
+ - LibroSqlCellView
13
+ - LibroMarkdownCellView
14
+ - LibroRawCellView
@@ -0,0 +1,9 @@
1
+ export * from './libro-cell-protocol.js';
2
+ export * from './libro-cell-service.js';
3
+ export * from './libro-cell-view.js';
4
+ export * from './libro-cell-contribution.js';
5
+ export * from './libro-cell-model.js';
6
+ export * from './libro-edit-cell-view.js';
7
+ export * from './libro-executable-cell-model.js';
8
+ export * from './libro-markdown-cell-model.js';
9
+ export * from './libro-executable-cell-view.js';
@@ -0,0 +1,34 @@
1
+ import { inject, singleton } from '@difizen/mana-app';
2
+
3
+ import type { CellModel, CellOptions } from '../libro-protocol.js';
4
+
5
+ import type { CellMeta } from './libro-cell-protocol.js';
6
+ import {
7
+ CellModelContribution,
8
+ CellModelFactory,
9
+ CellViewContribution,
10
+ } from './libro-cell-protocol.js';
11
+ import { LibroCellView } from './libro-cell-view.js';
12
+
13
+ @singleton({ contrib: [CellModelContribution, CellViewContribution] })
14
+ export class LibroCellContribution
15
+ implements CellModelContribution, CellViewContribution
16
+ {
17
+ @inject(CellModelFactory) libroCellModelFactory: CellModelFactory;
18
+
19
+ cellMeta: CellMeta = {
20
+ type: 'raw',
21
+ name: 'Raw',
22
+ order: 'a',
23
+ };
24
+
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
+ canHandle(options: CellOptions): number {
27
+ return 1;
28
+ }
29
+ createModel(options: CellOptions): CellModel {
30
+ const model = this.libroCellModelFactory(options);
31
+ return model;
32
+ }
33
+ view = LibroCellView;
34
+ }
@@ -0,0 +1,119 @@
1
+ import { Model } from '@difizen/libro-code-editor';
2
+ import type { ICell } from '@difizen/libro-common';
3
+ import { concatMultilineString } from '@difizen/libro-common';
4
+ import { DisposableCollection, watch } from '@difizen/mana-app';
5
+ import { prop, inject, postConstruct, transient } from '@difizen/mana-app';
6
+
7
+ import type { DefaultDecodedFormatter } from '../formatter/index.js';
8
+ import { DefaultEncodedFormatter, LibroFormatterManager } from '../formatter/index.js';
9
+ import { CellOptions } from '../libro-protocol.js';
10
+ import type { CellModel } from '../libro-protocol.js';
11
+
12
+ import type { LibroCellMetadata } from './libro-cell-protocol.js';
13
+ import { getLibroCellType } from './libro-cell-protocol.js';
14
+
15
+ @transient()
16
+ export class LibroCellModel extends Model implements CellModel {
17
+ toDispose = new DisposableCollection();
18
+
19
+ options: CellOptions;
20
+
21
+ libroFormatType: string;
22
+
23
+ _decodeObject: DefaultDecodedFormatter;
24
+
25
+ @inject(LibroFormatterManager)
26
+ libroFormatterManager: LibroFormatterManager<
27
+ DefaultDecodedFormatter,
28
+ DefaultDecodedFormatter
29
+ >;
30
+
31
+ @prop()
32
+ metadata: Partial<LibroCellMetadata>;
33
+
34
+ @prop()
35
+ trusted: boolean;
36
+
37
+ version = 0;
38
+
39
+ constructor(@inject(CellOptions) options: CellOptions) {
40
+ super({
41
+ id: options.cell.id as string,
42
+ value: concatMultilineString(options?.cell?.source ?? ''),
43
+ });
44
+ this.options = options;
45
+ this.type = getLibroCellType(options);
46
+ this.libroFormatType = 'formatter-string';
47
+
48
+ this.metadata = {
49
+ ...options?.cell?.metadata,
50
+ libroFormatter: this.libroFormatType,
51
+ };
52
+ this.trusted = options?.cell?.metadata?.trusted ?? false;
53
+ }
54
+
55
+ @postConstruct()
56
+ init() {
57
+ const formatValue: DefaultEncodedFormatter = DefaultEncodedFormatter.is(
58
+ this.options?.cell,
59
+ )
60
+ ? this.options?.cell
61
+ : {
62
+ ...this.options?.cell,
63
+ metadata: {
64
+ ...this.options?.cell.metadata,
65
+ libroFormatter: this.libroFormatType,
66
+ },
67
+ };
68
+
69
+ this.decodeObject = this.libroFormatterManager.adapter(
70
+ this.libroFormatType,
71
+ formatValue,
72
+ );
73
+ this.updateVersion();
74
+ }
75
+
76
+ updateVersion = () => {
77
+ watch<Model>(this, 'value', () => {
78
+ this.version++;
79
+ });
80
+ };
81
+
82
+ get source(): string {
83
+ const encodedValue = this.libroFormatterManager.encode(
84
+ this.libroFormatType,
85
+ this.decodeObject,
86
+ );
87
+ return concatMultilineString(encodedValue.source);
88
+ }
89
+
90
+ set decodeObject(data: DefaultDecodedFormatter) {
91
+ this.value = data.value;
92
+ this._decodeObject = data;
93
+ }
94
+
95
+ get decodeObject() {
96
+ return { ...this._decodeObject, value: this.value };
97
+ }
98
+
99
+ toJSON(): Omit<ICell, 'outputs'> {
100
+ return {
101
+ id: this.id,
102
+ cell_type: this.type,
103
+ metadata: this.metadata,
104
+ source: this.source,
105
+ };
106
+ }
107
+
108
+ disposed = false;
109
+ override dispose() {
110
+ if (!this.disposed) {
111
+ this.toDispose.dispose();
112
+ }
113
+ this.disposed = true;
114
+ }
115
+ }
116
+
117
+ export function isLibroCellModel(model: CellModel): model is LibroCellModel {
118
+ return model instanceof LibroCellModel;
119
+ }
@@ -0,0 +1,40 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+
3
+ import { CellOptions } from '../libro-protocol.js';
4
+
5
+ import { LibroCellContribution } from './libro-cell-contribution.js';
6
+ import { LibroCellModel } from './libro-cell-model.js';
7
+ import {
8
+ CellModelContribution,
9
+ CellModelFactory,
10
+ CellViewContribution,
11
+ } from './libro-cell-protocol.js';
12
+ import { LibroCellService } from './libro-cell-service.js';
13
+ import { LibroCellView } from './libro-cell-view.js';
14
+
15
+ /**
16
+ * 基础的cell实现,作为实现更复杂的cell的参考,一般不用加载到实际应用中
17
+ */
18
+ export const LibroBaseCellModule = ManaModule.create()
19
+ .register(LibroCellContribution, LibroCellView, LibroCellModel)
20
+ .register({
21
+ token: CellModelFactory,
22
+ useFactory: (ctx) => {
23
+ return (options: CellOptions) => {
24
+ const child = ctx.container.createChild();
25
+ child.register({
26
+ token: CellOptions,
27
+ useValue: options,
28
+ });
29
+ const model = child.get(LibroCellModel);
30
+ return model;
31
+ };
32
+ },
33
+ });
34
+
35
+ /**
36
+ * cell 定义
37
+ */
38
+ export const LibroCellModule = ManaModule.create()
39
+ .contribution(CellViewContribution, CellModelContribution)
40
+ .register(LibroCellService);
@@ -0,0 +1,55 @@
1
+ import type { IBaseCell, ICell, ICellMetadata } from '@difizen/libro-common';
2
+ import type { MaybePromise, Newable } from '@difizen/mana-app';
3
+ import { Syringe } from '@difizen/mana-app';
4
+
5
+ import type { CellModel, CellOptions, CellView } from '../libro-protocol.js';
6
+
7
+ export type LibroCellMetadata = ICellMetadata & {
8
+ libroCellType?: string;
9
+ libroFormatter?: string;
10
+ libroFormatterOptions?: object;
11
+ };
12
+ export interface LibroCustomCell extends IBaseCell {
13
+ metadata: Partial<LibroCellMetadata>;
14
+ }
15
+ export type LibroCell = LibroCustomCell | ICell;
16
+
17
+ export type CellModelFactory = (options: CellOptions) => CellModel;
18
+ export const CellModelFactory = Symbol('CellModelFactory');
19
+
20
+ export const getLibroCellType = (options: CellOptions) => {
21
+ return (options.cell.metadata?.libroCellType as string) ?? options.cell.cell_type;
22
+ };
23
+
24
+ export const CellModelContribution = Syringe.defineToken('CellModelContribution');
25
+ export interface CellModelContribution {
26
+ cellMeta: CellMeta;
27
+ canHandle: (options: CellOptions, libroType?: string) => number;
28
+ createModel: (options: CellOptions) => MaybePromise<CellModel>;
29
+ getDefaultCellOption?: () => CellOptions;
30
+ }
31
+
32
+ export const CellViewContribution = Syringe.defineToken('CellViewContribution');
33
+ export interface CellViewContribution {
34
+ canHandle: (options: CellOptions) => number;
35
+ view: Newable<CellView>;
36
+ }
37
+
38
+ export interface CellMeta {
39
+ type: string;
40
+ name: string;
41
+ order: string;
42
+ nbformatType?: string;
43
+ }
44
+
45
+ //
46
+
47
+ export const CellService = Symbol('CellService');
48
+ export interface CellService {
49
+ cellsMeta: CellMeta[];
50
+ getModelFromCache: (groupId: string, modelId: string) => CellModel | undefined;
51
+ getOrCreateModel: (options: CellOptions, cacheGroupId?: string) => Promise<CellModel>;
52
+ getOrCreateView: (options: CellOptions, parentId: string) => Promise<CellView>;
53
+ findModelProvider: (options: CellOptions) => CellModelContribution | undefined;
54
+ findViewProvider: (options: CellOptions) => CellViewContribution | undefined;
55
+ }
@@ -0,0 +1,158 @@
1
+ import type { Contribution } from '@difizen/mana-app';
2
+ import { Priority, prop } from '@difizen/mana-app';
3
+ import { ApplicationContribution, ViewManager } from '@difizen/mana-app';
4
+ import { contrib, inject, singleton } from '@difizen/mana-app';
5
+
6
+ import type { CellView, CellModel, CellOptions } from '../libro-protocol.js';
7
+ import { LibroService } from '../libro-service.js';
8
+
9
+ import type { CellMeta } from './libro-cell-protocol.js';
10
+ import {
11
+ CellService,
12
+ getLibroCellType,
13
+ CellViewContribution,
14
+ CellModelContribution,
15
+ } from './libro-cell-protocol.js';
16
+
17
+ @singleton({ contrib: [CellService, ApplicationContribution] })
18
+ export class LibroCellService implements CellService, ApplicationContribution {
19
+ @prop()
20
+ cellsMeta: CellMeta[] = [];
21
+
22
+ protected readonly modelProvider: Contribution.Provider<CellModelContribution>;
23
+ protected readonly viewProvider: Contribution.Provider<CellViewContribution>;
24
+ protected cellTypeToModelContribution: Map<string, CellModelContribution> = new Map();
25
+ protected readonly viewManager: ViewManager;
26
+ protected modelCache: Map<string, Map<string, CellModel>> = new Map();
27
+
28
+ libroService: LibroService;
29
+ constructor(
30
+ @inject(ViewManager)
31
+ viewManager: ViewManager,
32
+ @inject(LibroService) libroService: LibroService,
33
+ @contrib(CellModelContribution)
34
+ modelProvider: Contribution.Provider<CellModelContribution>,
35
+ @contrib(CellViewContribution)
36
+ viewProvider: Contribution.Provider<CellViewContribution>,
37
+ ) {
38
+ this.modelProvider = modelProvider;
39
+ this.viewProvider = viewProvider;
40
+ this.viewManager = viewManager;
41
+ this.libroService = libroService;
42
+ }
43
+
44
+ protected getContributionDefaultCellOption(ctb: CellModelContribution): CellOptions {
45
+ if (ctb.getDefaultCellOption) {
46
+ return ctb.getDefaultCellOption();
47
+ }
48
+ return this.cellTypeToOption(ctb.cellMeta.type);
49
+ }
50
+
51
+ initialize() {
52
+ const prioritized = this.getDefaultOptionModelContributionPrioritized();
53
+ const metas: CellMeta[] = [];
54
+ prioritized.forEach((item) => {
55
+ if (!this.cellTypeToModelContribution.get(item.cellMeta.type)) {
56
+ this.cellTypeToModelContribution.set(item.cellMeta.type, item);
57
+ metas.push(item.cellMeta);
58
+ }
59
+ });
60
+ metas.sort((a, b) => a.order.localeCompare(b.order));
61
+ this.cellsMeta = metas;
62
+ }
63
+
64
+ getDefaultCellOption(cellType: string) {
65
+ const contribution = this.cellTypeToModelContribution.get(cellType);
66
+ if (!contribution) {
67
+ throw new Error(`no cell model contribution found for cell type ${cellType}`);
68
+ }
69
+ return this.getContributionDefaultCellOption(contribution);
70
+ }
71
+
72
+ protected cellTypeToOption(cellType: string): CellOptions {
73
+ return { cell: { cell_type: cellType, source: '', metadata: {} } };
74
+ }
75
+
76
+ getModelFromCache(groupId: string, modelId: string) {
77
+ return this.modelCache.get(groupId)?.get(modelId);
78
+ }
79
+
80
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
81
+ async getOrCreateModel(options: CellOptions, cacheGroupId = ''): Promise<CellModel> {
82
+ let cellmodelCache = this.modelCache.get(cacheGroupId);
83
+
84
+ if (!cellmodelCache) {
85
+ cellmodelCache = new Map();
86
+ this.modelCache.set(cacheGroupId, cellmodelCache);
87
+ }
88
+ if (options.modelId) {
89
+ const exist = this.modelCache.get(cacheGroupId)?.get(options.modelId);
90
+ if (exist) {
91
+ return exist;
92
+ }
93
+ }
94
+ const modelProvider = this.findModelProvider(options);
95
+ if (!modelProvider) {
96
+ throw new Error('no cell model provider found');
97
+ }
98
+ const model = await modelProvider.createModel(options);
99
+ cellmodelCache.set(model.id, model);
100
+ return model;
101
+ }
102
+ async getOrCreateView(options: CellOptions, parentId: string): Promise<CellView> {
103
+ const model = await this.getOrCreateModel(options, parentId);
104
+ const viewProvider = this.findViewProvider(options);
105
+ if (!viewProvider) {
106
+ throw new Error('no cell view provider found');
107
+ }
108
+
109
+ const cellViewPromise = this.viewManager.getOrCreateView(viewProvider.view, {
110
+ ...options,
111
+ modelId: model.id,
112
+ parentId: parentId,
113
+ });
114
+
115
+ const cellView = await cellViewPromise;
116
+ const parent = this.libroService.getViewCache().get(parentId);
117
+ if (parent) {
118
+ cellView.parent = parent;
119
+ }
120
+ return cellView;
121
+ }
122
+
123
+ findViewProvider(options: CellOptions): CellViewContribution | undefined {
124
+ const prioritized = Priority.sortSync(
125
+ this.viewProvider.getContributions(),
126
+ (contribution) => this.canHandleOption(contribution, options),
127
+ );
128
+
129
+ const sorted = prioritized.map((c) => c.value);
130
+ return sorted[0];
131
+ }
132
+ findModelProvider(options: CellOptions): CellModelContribution | undefined {
133
+ const prioritized = Priority.sortSync(
134
+ this.modelProvider.getContributions(),
135
+ (contribution) => this.canHandleOption(contribution, options),
136
+ );
137
+ const sorted = prioritized.map((c) => c.value);
138
+ return sorted[0];
139
+ }
140
+
141
+ protected getDefaultOptionModelContributionPrioritized(): CellModelContribution[] {
142
+ const prioritized = Priority.sortSync(
143
+ this.modelProvider.getContributions(),
144
+ (contribution) => {
145
+ const options = this.getContributionDefaultCellOption(contribution);
146
+ return this.canHandleOption(contribution, options);
147
+ },
148
+ );
149
+ const sorted = prioritized.map((c) => c.value);
150
+ return sorted;
151
+ }
152
+ protected canHandleOption(
153
+ ctb: CellModelContribution | CellViewContribution,
154
+ options: CellOptions,
155
+ ) {
156
+ return ctb.canHandle(options, getLibroCellType(options));
157
+ }
158
+ }
@@ -0,0 +1,156 @@
1
+ import type { ViewComponent } from '@difizen/mana-app';
2
+ import { Deferred } from '@difizen/mana-app';
3
+ import { useInject, watch } from '@difizen/mana-app';
4
+ import { BaseView, view, ViewInstance, ViewOption } from '@difizen/mana-app';
5
+ import { inject } from '@difizen/mana-app';
6
+ import { DisposableCollection } from '@difizen/mana-app';
7
+ import { prop } from '@difizen/mana-app';
8
+ import React from 'react';
9
+
10
+ import type { CellViewOptions, CellModel } from '../libro-protocol.js';
11
+ import type { CellView, NotebookView } from '../libro-protocol.js';
12
+
13
+ import { CellService } from './libro-cell-protocol.js';
14
+ import type { LibroCell } from './libro-cell-protocol.js';
15
+ import { ExecutableCellModel } from './libro-executable-cell-model.js';
16
+
17
+ export const LibroCellComponent = React.forwardRef(function LibroCellComponent() {
18
+ const instance = useInject<LibroCellView>(ViewInstance);
19
+ return <>{instance.model.value}</>;
20
+ });
21
+
22
+ @view('libro-cell-view')
23
+ export class LibroCellView extends BaseView implements CellView {
24
+ protected override toDispose = new DisposableCollection();
25
+ options: CellViewOptions;
26
+
27
+ @prop()
28
+ noEditorAreaHeight = 0;
29
+
30
+ @prop()
31
+ cellViewTopPos = 0;
32
+
33
+ @prop()
34
+ renderEditorIntoVirtualized = false;
35
+
36
+ @prop()
37
+ model: CellModel;
38
+ protected cellService: CellService;
39
+ override view: ViewComponent = LibroCellComponent;
40
+
41
+ protected _parent: NotebookView;
42
+
43
+ get parent() {
44
+ return this._parent;
45
+ }
46
+ set parent(value: NotebookView) {
47
+ this._parent = value;
48
+ this.parentDefer.resolve(this.parent);
49
+ }
50
+
51
+ protected parentDefer = new Deferred<NotebookView>();
52
+
53
+ get parentReady() {
54
+ return this.parentDefer.promise;
55
+ }
56
+
57
+ @prop()
58
+ override className?: string | undefined = 'libro-cell-view-container';
59
+
60
+ @prop()
61
+ hasInputHidden: boolean;
62
+
63
+ @prop()
64
+ collapsedHidden = false;
65
+
66
+ @prop()
67
+ hasModal = false;
68
+
69
+ constructor(
70
+ @inject(ViewOption) options: CellViewOptions,
71
+ @inject(CellService) cellService: CellService,
72
+ ) {
73
+ super();
74
+ this.cellService = cellService;
75
+ this.options = options;
76
+ this.hasInputHidden = false;
77
+ const model = cellService.getModelFromCache(options.parentId, options.modelId);
78
+ if (!model) {
79
+ console.warn('cell model does not exist');
80
+ throw new Error('cell model does not exist');
81
+ }
82
+ this.model = model;
83
+ this.cellWatch();
84
+ }
85
+
86
+ cellWatch() {
87
+ this.toDispose.push(
88
+ watch(this.model, 'value', () => {
89
+ this.parent.model.onChange?.();
90
+ this.parent.model.onSourceChange?.([this]);
91
+ }),
92
+ );
93
+ this.toDispose.push(
94
+ watch(this.model, 'type', () => {
95
+ this.parent.model.onChange?.();
96
+ this.parent.model.onSourceChange?.([this]);
97
+ }),
98
+ );
99
+ if (ExecutableCellModel.is(this.model)) {
100
+ this.toDispose.push(
101
+ watch(this.model, 'executeCount', () => {
102
+ this.parent.model.onChange?.();
103
+ }),
104
+ );
105
+ }
106
+ }
107
+
108
+ // 计算编辑器区相对于编辑器区垂直方向的偏移量
109
+ calcEditorOffset() {
110
+ return 16 + 1;
111
+ }
112
+
113
+ hasCellHidden() {
114
+ return this.hasInputHidden;
115
+ }
116
+
117
+ async run() {
118
+ return Promise.resolve(true);
119
+ }
120
+
121
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
122
+ shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>) {
123
+ return false;
124
+ }
125
+
126
+ blur() {
127
+ //
128
+ }
129
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
130
+ focus(isEdit: boolean) {
131
+ //
132
+ }
133
+
134
+ disposed = false;
135
+ override dispose() {
136
+ this.toDispose.dispose();
137
+ super.dispose();
138
+ }
139
+ toJSON(): LibroCell {
140
+ const meta = { ...(this.model.toJSON() as LibroCell), outputs: [] };
141
+ const modelContribution = this.cellService.findModelProvider(this.model.options);
142
+ if (modelContribution?.cellMeta.nbformatType) {
143
+ meta.metadata.libroCellType = modelContribution?.cellMeta.type;
144
+ meta.cell_type = modelContribution?.cellMeta.nbformatType;
145
+ }
146
+ return meta;
147
+ }
148
+
149
+ toJSONWithoutId = () => {
150
+ const JsonObject = this.toJSON();
151
+ delete JsonObject.id;
152
+ return {
153
+ ...JsonObject,
154
+ };
155
+ };
156
+ }