@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,2077 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10;
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
13
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
17
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
18
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
19
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
22
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
26
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
27
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
28
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
29
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
30
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
31
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
32
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
+ import { ToTopOutlined } from '@ant-design/icons';
34
+ import { concatMultilineString, copy2clipboard, readFromClipboard } from '@difizen/libro-common';
35
+ import { equals, useInject, inject, transient, BaseView, Slot, view, ViewInstance, ViewManager, ViewOption, Deferred, Disposable, DisposableCollection, Emitter, getOrigin, prop, watch, ConfigurationService, useConfigurationValue } from '@difizen/mana-app';
36
+ import { FloatButton, Button, Spin } from 'antd';
37
+ import { forwardRef, memo, useCallback, useEffect, useRef } from 'react';
38
+ import { v4 } from 'uuid';
39
+ import { CellService, EditorCellView, ExecutableCellModel, ExecutableCellView } from "./cell/index.js";
40
+ import { CollapseServiceFactory } from "./collapse-service.js";
41
+ import { CustomDragLayer, DndCellContainer, DndCellItemRender, DndContext, DndList } from "./components/index.js";
42
+ import { LibroViewHeader } from "./components/libro-view-header.js";
43
+ import { LibroContextKey } from "./libro-context-key.js";
44
+ import { LibroModel } from "./libro-model.js";
45
+ import { NotebookService, notebookViewFactoryId } from "./libro-protocol.js";
46
+ import { LibroService } from "./libro-service.js";
47
+ import { AutoInsertWhenNoCell, EnterEditModeWhenAddCell, HeaderToolbarVisible, RightContentFixed } from "./libro-setting.js";
48
+ import { LibroSlotManager, LibroSlotView } from "./slot/index.js";
49
+ import { VirtualizedManagerHelper } from "./virtualized-manager-helper.js";
50
+ import "./index.less";
51
+ import { jsx as _jsx } from "react/jsx-runtime";
52
+ import { jsxs as _jsxs } from "react/jsx-runtime";
53
+ import { Fragment as _Fragment } from "react/jsx-runtime";
54
+ export var LibroContentComponent = /*#__PURE__*/memo(function LibroContentComponent() {
55
+ var libroSlotManager = useInject(LibroSlotManager);
56
+ var ref = useRef(null);
57
+ var libroViewTopRef = useRef(null);
58
+ var libroViewRightContentRef = useRef(null);
59
+ var libroViewLeftContentRef = useRef(null);
60
+ var libroViewContentRef = useRef(null);
61
+ var instance = useInject(ViewInstance);
62
+ var HeaderRender = getOrigin(instance.headerRender);
63
+ var _useConfigurationValu = useConfigurationValue(HeaderToolbarVisible),
64
+ _useConfigurationValu2 = _slicedToArray(_useConfigurationValu, 1),
65
+ headerVisible = _useConfigurationValu2[0];
66
+ var _useConfigurationValu3 = useConfigurationValue(RightContentFixed),
67
+ _useConfigurationValu4 = _slicedToArray(_useConfigurationValu3, 1),
68
+ rightContentFixed = _useConfigurationValu4[0];
69
+ var handleScroll = useCallback(function () {
70
+ var _instance$container, _instance$activeCell, _instance$activeCell2, _instance$activeCell3, _activeOutput$outputs, _instance$activeCell4, _libroViewTopRef$curr;
71
+ instance.cellScrollEmitter.fire();
72
+ var cellRightToolbar = (_instance$container = instance.container) === null || _instance$container === void 0 || (_instance$container = _instance$container.current) === null || _instance$container === void 0 ? void 0 : _instance$container.getElementsByClassName('libro-cell-right-toolbar')[instance.model.activeIndex];
73
+ var activeCellOffsetY = (_instance$activeCell = instance.activeCell) === null || _instance$activeCell === void 0 || (_instance$activeCell = _instance$activeCell.container) === null || _instance$activeCell === void 0 || (_instance$activeCell = _instance$activeCell.current) === null || _instance$activeCell === void 0 ? void 0 : _instance$activeCell.getBoundingClientRect().y;
74
+ var activeCellOffsetRight = (_instance$activeCell2 = instance.activeCell) === null || _instance$activeCell2 === void 0 || (_instance$activeCell2 = _instance$activeCell2.container) === null || _instance$activeCell2 === void 0 || (_instance$activeCell2 = _instance$activeCell2.current) === null || _instance$activeCell2 === void 0 ? void 0 : _instance$activeCell2.getBoundingClientRect().right;
75
+ var activeOutput = ExecutableCellView.is(instance.activeCell) && ((_instance$activeCell3 = instance.activeCell) === null || _instance$activeCell3 === void 0 ? void 0 : _instance$activeCell3.outputArea);
76
+ var activeOutputOffsetBottom = activeOutput && activeOutput.length > 0 ? activeOutput === null || activeOutput === void 0 || (_activeOutput$outputs = activeOutput.outputs[activeOutput.length - 1].container) === null || _activeOutput$outputs === void 0 || (_activeOutput$outputs = _activeOutput$outputs.current) === null || _activeOutput$outputs === void 0 ? void 0 : _activeOutput$outputs.getBoundingClientRect().bottom : (_instance$activeCell4 = instance.activeCell) === null || _instance$activeCell4 === void 0 || (_instance$activeCell4 = _instance$activeCell4.container) === null || _instance$activeCell4 === void 0 || (_instance$activeCell4 = _instance$activeCell4.current) === null || _instance$activeCell4 === void 0 ? void 0 : _instance$activeCell4.getBoundingClientRect().bottom;
77
+ var libroViewTopOffsetBottom = (_libroViewTopRef$curr = libroViewTopRef.current) === null || _libroViewTopRef$curr === void 0 ? void 0 : _libroViewTopRef$curr.getBoundingClientRect().bottom;
78
+ if (!cellRightToolbar) {
79
+ return;
80
+ }
81
+ if (activeCellOffsetY !== undefined && libroViewTopOffsetBottom !== undefined && activeOutputOffsetBottom !== undefined && activeCellOffsetY <= libroViewTopOffsetBottom + 12 && activeOutputOffsetBottom >= libroViewTopOffsetBottom && activeCellOffsetRight !== undefined) {
82
+ cellRightToolbar.style.cssText = "position:fixed;top:".concat(libroViewTopOffsetBottom + 12, "px;left:").concat(activeCellOffsetRight + 44 - 34, "px;right:unset;");
83
+ } else {
84
+ cellRightToolbar.style.cssText = ' position: absolute;top: 0px;right: -44px;';
85
+ }
86
+ }, [instance]);
87
+ useEffect(function () {
88
+ if (rightContentFixed && libroViewRightContentRef.current && libroViewContentRef.current && libroViewLeftContentRef.current) {
89
+ libroViewContentRef.current.style.cssText = 'display: block;';
90
+ libroViewRightContentRef.current.style.cssText = 'position: absolute;top:44px;right:20px';
91
+ libroViewLeftContentRef.current.style.cssText = 'padding-right: 80px;';
92
+ }
93
+ }, [rightContentFixed]);
94
+ return /*#__PURE__*/_jsxs(_Fragment, {
95
+ children: [headerVisible && /*#__PURE__*/_jsx("div", {
96
+ className: "libro-view-top",
97
+ ref: libroViewTopRef,
98
+ children: /*#__PURE__*/_jsx(HeaderRender, {})
99
+ }), /*#__PURE__*/_jsxs("div", {
100
+ className: "libro-view-content",
101
+ onScroll: handleScroll,
102
+ ref: libroViewContentRef,
103
+ children: [/*#__PURE__*/_jsx("div", {
104
+ className: "libro-view-content-left",
105
+ ref: libroViewLeftContentRef,
106
+ children: /*#__PURE__*/_jsxs(DndContext, {
107
+ children: [/*#__PURE__*/_jsx(CustomDragLayer, {}), /*#__PURE__*/_jsx(DndList, {
108
+ libroView: instance,
109
+ ref: ref,
110
+ children: /*#__PURE__*/_jsx(Slot, {
111
+ name: libroSlotManager.getSlotName(instance, 'list'),
112
+ slotView: LibroSlotView
113
+ })
114
+ })]
115
+ })
116
+ }), /*#__PURE__*/_jsx("div", {
117
+ className: "libro-view-content-right",
118
+ ref: libroViewRightContentRef,
119
+ children: /*#__PURE__*/_jsx(Slot, {
120
+ name: libroSlotManager.getSlotName(instance, 'right'),
121
+ slotView: LibroSlotView
122
+ })
123
+ }), /*#__PURE__*/_jsx(FloatButton.BackTop, {
124
+ target: function target() {
125
+ return libroViewContentRef.current || document;
126
+ },
127
+ children: /*#__PURE__*/_jsx("div", {
128
+ className: "libro-totop-button",
129
+ children: /*#__PURE__*/_jsx(Button, {
130
+ shape: "circle",
131
+ icon: /*#__PURE__*/_jsx(ToTopOutlined, {})
132
+ })
133
+ })
134
+ }), /*#__PURE__*/_jsx(Slot, {
135
+ name: libroSlotManager.getSlotName(instance, 'content'),
136
+ slotView: LibroSlotView
137
+ })]
138
+ }), /*#__PURE__*/_jsx(Slot, {
139
+ name: libroSlotManager.getSlotName(instance, 'container'),
140
+ slotView: LibroSlotView
141
+ })]
142
+ });
143
+ });
144
+ export var LibroRender = /*#__PURE__*/forwardRef(function LibroRender(props, ref) {
145
+ var instance = useInject(ViewInstance);
146
+ var libroService = useInject(LibroService);
147
+ var handleMouseDown = useCallback(function (e) {
148
+ if (e.defaultPrevented) {
149
+ return;
150
+ }
151
+ if (!instance.model.commandMode) {
152
+ instance.enterCommandMode(true);
153
+ }
154
+ }, [instance]);
155
+ var handFocus = useCallback(
156
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
157
+ function (e) {
158
+ if (!equals(libroService.active, instance)) {
159
+ libroService.active = instance;
160
+ }
161
+ if (!equals(libroService.focus, instance)) {
162
+ libroService.focus = instance;
163
+ }
164
+ }, [instance, libroService]);
165
+ var handBlur = useCallback(function (e) {
166
+ var _ref$current;
167
+ if (typeof ref === 'function') {
168
+ return;
169
+ }
170
+ // focus编辑器host
171
+ if (!e.relatedTarget) {
172
+ return;
173
+ }
174
+ // focus编辑器外部区域
175
+ if (ref !== null && ref !== void 0 && (_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contains(e.relatedTarget)) {
176
+ var _ref$current2;
177
+ var dndDom = ref === null || ref === void 0 || (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.getElementsByClassName('libro-dnd-cells-container')[0];
178
+ if (!(dndDom !== null && dndDom !== void 0 && dndDom.contains(e.relatedTarget)) && (!instance.model.inputEditable || !instance.model.outputEditable || !instance.model.cellsEditable) && !instance.model.runnable) {
179
+ instance.selectCell(undefined);
180
+ }
181
+ } else {
182
+ instance.enterCommandMode(false);
183
+ libroService.focus = undefined;
184
+ instance.onBlurEmitter.fire('');
185
+ if ((!instance.model.inputEditable || !instance.model.outputEditable || !instance.model.cellsEditable) && !instance.model.runnable) {
186
+ instance.selectCell(undefined);
187
+ }
188
+ }
189
+ }, [instance, libroService, ref]);
190
+ return /*#__PURE__*/_jsx("div", {
191
+ className: "".concat(instance.model.libroViewClass, " libro-view"),
192
+ onMouseDown: handleMouseDown,
193
+ ref: ref,
194
+ tabIndex: 0,
195
+ onFocus: handFocus,
196
+ onBlur: handBlur,
197
+ children: /*#__PURE__*/_jsx(LibroContentComponent, {})
198
+ });
199
+ });
200
+ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId), _dec3 = prop(), _dec4 = inject(CellService), _dec5 = inject(LibroService), _dec6 = inject(LibroSlotManager), _dec7 = inject(LibroContextKey), _dec8 = inject(ViewManager), _dec9 = inject(ConfigurationService), _dec10 = prop(), _dec11 = prop(), _dec12 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
201
+ _inherits(LibroView, _BaseView);
202
+ var _super = _createSuper(LibroView);
203
+ function LibroView(_options, collapseServiceFactory, notebookService, virtualizedManagerHelper) {
204
+ var _this;
205
+ _classCallCheck(this, LibroView);
206
+ _this = _super.call(this);
207
+ _this.toDispose = new DisposableCollection();
208
+ _initializerDefineProperty(_this, "model", _descriptor, _assertThisInitialized(_this));
209
+ _this.headerRender = LibroViewHeader;
210
+ _this.loadingRender = function () {
211
+ return /*#__PURE__*/_jsx("div", {
212
+ className: "libro-loading",
213
+ children: /*#__PURE__*/_jsx(Spin, {})
214
+ });
215
+ };
216
+ _this.dndContentRender = DndCellContainer;
217
+ _this.dndItemRender = DndCellItemRender;
218
+ _this.onCellCreateEmitter = new Emitter();
219
+ _this.onCellDeleteEmitter = new Emitter();
220
+ _this.onBlurEmitter = new Emitter();
221
+ _initializerDefineProperty(_this, "cellService", _descriptor2, _assertThisInitialized(_this));
222
+ _initializerDefineProperty(_this, "libroService", _descriptor3, _assertThisInitialized(_this));
223
+ _initializerDefineProperty(_this, "libroSlotManager", _descriptor4, _assertThisInitialized(_this));
224
+ _initializerDefineProperty(_this, "contextKey", _descriptor5, _assertThisInitialized(_this));
225
+ _initializerDefineProperty(_this, "viewManager", _descriptor6, _assertThisInitialized(_this));
226
+ _initializerDefineProperty(_this, "configurationService", _descriptor7, _assertThisInitialized(_this));
227
+ _this.virtualizedManager = void 0;
228
+ _this.virtualizedManagerHelper = void 0;
229
+ _this.notebookService = void 0;
230
+ _this.collapseService = void 0;
231
+ _this.isDragging = false;
232
+ _this.clipboard = void 0;
233
+ _initializerDefineProperty(_this, "collapserVisible", _descriptor8, _assertThisInitialized(_this));
234
+ _initializerDefineProperty(_this, "outputsScroll", _descriptor9, _assertThisInitialized(_this));
235
+ _initializerDefineProperty(_this, "saving", _descriptor10, _assertThisInitialized(_this));
236
+ _this.onSaveEmitter = new Emitter();
237
+ _this.onCellContentChangedEmitter = new Emitter();
238
+ _this.runCellEmitter = new Emitter();
239
+ _this.cellScrollEmitter = new Emitter();
240
+ _this.initializedDefer = new Deferred();
241
+ _this.view = LibroRender;
242
+ _this.onViewMount = function () {
243
+ _this.libroService.active = _assertThisInitialized(_this);
244
+ _this.libroSlotManager.setup(_assertThisInitialized(_this));
245
+
246
+ // this.libroService.libroPerformanceStatistics.setRenderEnd(new Date());
247
+
248
+ // console.log(
249
+ // '[performance] render Time: ',
250
+ // this.libroService.libroPerformanceStatistics.getRenderTime(),
251
+ // );
252
+ };
253
+ _this.onViewUnmount = function () {
254
+ if (equals(_this.libroService.active, _assertThisInitialized(_this))) {
255
+ _this.libroService.active = undefined;
256
+ }
257
+ };
258
+ _this.focus = function () {
259
+ var _this$container, _this$container2;
260
+ if ((_this$container = _this.container) !== null && _this$container !== void 0 && (_this$container = _this$container.current) !== null && _this$container !== void 0 && _this$container.contains(document.activeElement)) {
261
+ return;
262
+ }
263
+ (_this$container2 = _this.container) === null || _this$container2 === void 0 || (_this$container2 = _this$container2.current) === null || _this$container2 === void 0 || _this$container2.focus();
264
+ };
265
+ _this.insertCells = /*#__PURE__*/function () {
266
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, position) {
267
+ var cellView;
268
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
269
+ while (1) switch (_context2.prev = _context2.next) {
270
+ case 0:
271
+ _context2.next = 2;
272
+ return Promise.all(options.map( /*#__PURE__*/function () {
273
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(option) {
274
+ var newView;
275
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
276
+ while (1) switch (_context.prev = _context.next) {
277
+ case 0:
278
+ _context.next = 2;
279
+ return _this.getCellViewByOption(option);
280
+ case 2:
281
+ newView = _context.sent;
282
+ return _context.abrupt("return", newView);
283
+ case 4:
284
+ case "end":
285
+ return _context.stop();
286
+ }
287
+ }, _callee);
288
+ }));
289
+ return function (_x3) {
290
+ return _ref2.apply(this, arguments);
291
+ };
292
+ }()));
293
+ case 2:
294
+ cellView = _context2.sent;
295
+ _this.model.insertCells(cellView, position);
296
+ case 4:
297
+ case "end":
298
+ return _context2.stop();
299
+ }
300
+ }, _callee2);
301
+ }));
302
+ return function (_x, _x2) {
303
+ return _ref.apply(this, arguments);
304
+ };
305
+ }();
306
+ _this.selectCell = function (cell) {
307
+ _this.model.active = cell;
308
+ _this.model.selectCell(cell);
309
+ };
310
+ _this.addCell = /*#__PURE__*/function () {
311
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(option, position) {
312
+ var cellView;
313
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
314
+ while (1) switch (_context3.prev = _context3.next) {
315
+ case 0:
316
+ _context3.next = 2;
317
+ return _this.getCellViewByOption(option);
318
+ case 2:
319
+ cellView = _context3.sent;
320
+ _this.model.addCell(cellView, position);
321
+ case 4:
322
+ case "end":
323
+ return _context3.stop();
324
+ }
325
+ }, _callee3);
326
+ }));
327
+ return function (_x4, _x5) {
328
+ return _ref3.apply(this, arguments);
329
+ };
330
+ }();
331
+ _this.addCellAbove = /*#__PURE__*/function () {
332
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(option, position) {
333
+ var cellView;
334
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
335
+ while (1) switch (_context4.prev = _context4.next) {
336
+ case 0:
337
+ _context4.next = 2;
338
+ return _this.getCellViewByOption(option);
339
+ case 2:
340
+ cellView = _context4.sent;
341
+ _this.model.addCell(cellView, position, 'above');
342
+ case 4:
343
+ case "end":
344
+ return _context4.stop();
345
+ }
346
+ }, _callee4);
347
+ }));
348
+ return function (_x6, _x7) {
349
+ return _ref4.apply(this, arguments);
350
+ };
351
+ }();
352
+ _this.findCellIndex = function (cell) {
353
+ var cellList = _this.model.getCells();
354
+ if (cell) {
355
+ var cellIndex = cellList.findIndex(function (item) {
356
+ return item.id === cell.id;
357
+ });
358
+ return cellIndex;
359
+ }
360
+ return -1;
361
+ };
362
+ _this.deleteCell = function (cell) {
363
+ var deleteIndex = _this.model.getCells().findIndex(function (item) {
364
+ return equals(item, cell);
365
+ });
366
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
367
+ var startIndex = _this.model.getCells().findIndex(function (item) {
368
+ return equals(item, _this.model.selections[0]);
369
+ });
370
+ var endIndex = startIndex + _this.model.selections.length;
371
+ getOrigin(_this.model.sharedModel).transact(function () {
372
+ getOrigin(_this.model.sharedModel).deleteCellRange(startIndex, endIndex);
373
+ });
374
+ _this.configurationService.get(AutoInsertWhenNoCell).then(function (value) {
375
+ var isAutoInsertWhenNoCell = value;
376
+ if (isAutoInsertWhenNoCell && _this.model.cells.length === 0) {
377
+ _this.addCell({
378
+ id: v4(),
379
+ cell: {
380
+ cell_type: 'code',
381
+ source: '',
382
+ metadata: {}
383
+ }
384
+ }, 0);
385
+ }
386
+ return;
387
+ }).catch(function (e) {
388
+ //
389
+ });
390
+ } else {
391
+ if (deleteIndex > -1) {
392
+ _this.model.deletedCells.push(cell);
393
+ _this.model.deleteCell(cell.id);
394
+ cell.isAttached = false;
395
+ }
396
+ _this.configurationService.get(AutoInsertWhenNoCell).then(function (value) {
397
+ var isAutoInsertWhenNoCell = value;
398
+ if (isAutoInsertWhenNoCell && _this.model.cells.length === 0) {
399
+ _this.addCell({
400
+ id: v4(),
401
+ cell: {
402
+ cell_type: 'code',
403
+ source: '',
404
+ metadata: {}
405
+ }
406
+ }, 0);
407
+ }
408
+ return;
409
+ }).catch(function (e) {
410
+ //
411
+ });
412
+ }
413
+ };
414
+ _this.runCells = /*#__PURE__*/function () {
415
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(cells) {
416
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
417
+ while (1) switch (_context5.prev = _context5.next) {
418
+ case 0:
419
+ if (!(_this.model.canRun && !_this.model.canRun())) {
420
+ _context5.next = 2;
421
+ break;
422
+ }
423
+ return _context5.abrupt("return", false);
424
+ case 2:
425
+ return _context5.abrupt("return", Promise.all(cells.map(function (cell) {
426
+ return _this.executeCellRun(cell);
427
+ })).then(function (resultList) {
428
+ return resultList.filter(function (item) {
429
+ return item !== undefined;
430
+ }).every(function (item) {
431
+ return !!item;
432
+ });
433
+ }).catch(function (reason) {
434
+ if (reason.message.startsWith('KernelReplyNotOK')) {
435
+ return undefined;
436
+ } else {
437
+ throw reason;
438
+ }
439
+ }));
440
+ case 3:
441
+ case "end":
442
+ return _context5.stop();
443
+ }
444
+ }, _callee5);
445
+ }));
446
+ return function (_x8) {
447
+ return _ref5.apply(this, arguments);
448
+ };
449
+ }();
450
+ _this.runAllCell = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
451
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
452
+ while (1) switch (_context6.prev = _context6.next) {
453
+ case 0:
454
+ _this.runCells(_this.model.cells);
455
+ case 1:
456
+ case "end":
457
+ return _context6.stop();
458
+ }
459
+ }, _callee6);
460
+ }));
461
+ _this.runAllAbove = /*#__PURE__*/function () {
462
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(cell) {
463
+ var index;
464
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
465
+ while (1) switch (_context7.prev = _context7.next) {
466
+ case 0:
467
+ index = _this.findCellIndex(cell);
468
+ _this.runCells(_this.model.cells.slice(0, index));
469
+ case 2:
470
+ case "end":
471
+ return _context7.stop();
472
+ }
473
+ }, _callee7);
474
+ }));
475
+ return function (_x9) {
476
+ return _ref7.apply(this, arguments);
477
+ };
478
+ }();
479
+ _this.runAllBelow = /*#__PURE__*/function () {
480
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(cell) {
481
+ var index;
482
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
483
+ while (1) switch (_context8.prev = _context8.next) {
484
+ case 0:
485
+ index = _this.findCellIndex(cell);
486
+ _this.runCells(_this.model.cells.slice(index));
487
+ case 2:
488
+ case "end":
489
+ return _context8.stop();
490
+ }
491
+ }, _callee8);
492
+ }));
493
+ return function (_x10) {
494
+ return _ref8.apply(this, arguments);
495
+ };
496
+ }();
497
+ _this.runCell = /*#__PURE__*/function () {
498
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(cell) {
499
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
500
+ while (1) switch (_context9.prev = _context9.next) {
501
+ case 0:
502
+ _this.enterCommandMode(true);
503
+ if (!(_this.model.selections.length !== 0 && _this.isSelected(cell))) {
504
+ _context9.next = 6;
505
+ break;
506
+ }
507
+ _context9.next = 4;
508
+ return _this.runCells(_this.model.selections);
509
+ case 4:
510
+ _context9.next = 8;
511
+ break;
512
+ case 6:
513
+ _context9.next = 8;
514
+ return _this.runCells([cell]);
515
+ case 8:
516
+ case "end":
517
+ return _context9.stop();
518
+ }
519
+ }, _callee9);
520
+ }));
521
+ return function (_x11) {
522
+ return _ref9.apply(this, arguments);
523
+ };
524
+ }();
525
+ _this.runCellandSelectNext = /*#__PURE__*/function () {
526
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(cell) {
527
+ var toRunCells, selectIndex, _selectIndex;
528
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
529
+ while (1) switch (_context10.prev = _context10.next) {
530
+ case 0:
531
+ _this.enterCommandMode(true);
532
+ _this.collapseCell(cell, false);
533
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
534
+ toRunCells = _this.model.selections;
535
+ selectIndex = _this.findCellIndex(_this.model.selections[_this.model.selections.length - 1]);
536
+ if (selectIndex >= 0 && selectIndex < _this.model.cells.length - 1) {
537
+ _this.model.selectCell(_this.model.cells[selectIndex + 1]);
538
+ }
539
+ if (selectIndex === _this.model.cells.length - 1) {
540
+ _this.addCell({
541
+ id: v4(),
542
+ cell: {
543
+ cell_type: cell.model.type,
544
+ source: '',
545
+ metadata: {}
546
+ }
547
+ }, selectIndex + 1).then(function () {
548
+ _this.enterEditMode();
549
+ return;
550
+ }).catch(function (e) {
551
+ //
552
+ });
553
+ }
554
+ _this.runCells(toRunCells);
555
+ } else {
556
+ _selectIndex = _this.findCellIndex(cell);
557
+ if (_selectIndex >= 0 && _selectIndex < _this.model.cells.length - 1) {
558
+ _this.model.selectCell(_this.model.cells[_selectIndex + 1]);
559
+ }
560
+ if (_selectIndex === _this.model.cells.length - 1) {
561
+ _this.addCell({
562
+ id: v4(),
563
+ cell: {
564
+ cell_type: cell.model.type,
565
+ source: '',
566
+ metadata: {}
567
+ }
568
+ }, _selectIndex + 1).then(function () {
569
+ _this.enterEditMode();
570
+ return;
571
+ }).catch(function (e) {
572
+ //
573
+ });
574
+ }
575
+ _this.runCells([cell]);
576
+ }
577
+ setTimeout(function () {
578
+ if (_this.activeCell) {
579
+ _this.model.scrollToView(_this.activeCell);
580
+ }
581
+ });
582
+ case 4:
583
+ case "end":
584
+ return _context10.stop();
585
+ }
586
+ }, _callee10);
587
+ }));
588
+ return function (_x12) {
589
+ return _ref10.apply(this, arguments);
590
+ };
591
+ }();
592
+ _this.runCellandInsertBelow = /*#__PURE__*/function () {
593
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(cell) {
594
+ var insertIndex, _insertIndex;
595
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
596
+ while (1) switch (_context11.prev = _context11.next) {
597
+ case 0:
598
+ _this.enterCommandMode(true);
599
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
600
+ insertIndex = _this.findCellIndex(_this.model.selections[_this.model.selections.length - 1]);
601
+ _this.addCell({
602
+ id: v4(),
603
+ cell: {
604
+ cell_type: cell.model.type,
605
+ source: '',
606
+ metadata: {}
607
+ }
608
+ }, insertIndex + 1);
609
+ _this.runCells(_this.model.selections);
610
+ } else {
611
+ _insertIndex = _this.findCellIndex(cell);
612
+ _this.addCell({
613
+ id: v4(),
614
+ cell: {
615
+ cell_type: cell.model.type,
616
+ source: '',
617
+ metadata: {}
618
+ }
619
+ }, _insertIndex + 1);
620
+ _this.runCells([cell]);
621
+ }
622
+ case 2:
623
+ case "end":
624
+ return _context11.stop();
625
+ }
626
+ }, _callee11);
627
+ }));
628
+ return function (_x13) {
629
+ return _ref11.apply(this, arguments);
630
+ };
631
+ }();
632
+ _this.moveUpCell = function (cell) {
633
+ _this.collapseCell(cell, false);
634
+ var previousCell = _this.getPreviousVisibleCell(cell);
635
+ if (previousCell) {
636
+ _this.collapseCell(previousCell, false);
637
+ }
638
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
639
+ var _iterator = _createForOfIteratorHelper(_this.model.selections),
640
+ _step;
641
+ try {
642
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
643
+ var selectedCell = _step.value;
644
+ var selectIndex = _this.findCellIndex(selectedCell);
645
+ if (selectIndex === 0) {
646
+ return;
647
+ }
648
+ _this.model.exchangeCells(_this.model.selections, selectIndex - 1);
649
+ }
650
+ } catch (err) {
651
+ _iterator.e(err);
652
+ } finally {
653
+ _iterator.f();
654
+ }
655
+ } else {
656
+ var sourceIndex = _this.findCellIndex(cell);
657
+ if (sourceIndex > -1) {
658
+ _this.model.exchangeCell(sourceIndex, sourceIndex - 1);
659
+ }
660
+ }
661
+ };
662
+ _this.moveDownCell = function (cell) {
663
+ _this.collapseCell(cell, false);
664
+ var nextCell = _this.getNextVisibleCell(cell);
665
+ if (nextCell) {
666
+ _this.collapseCell(nextCell, false);
667
+ }
668
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
669
+ for (var i = _this.model.selections.length - 1; i > -1; i--) {
670
+ var selectIndex = _this.findCellIndex(_this.model.selections[i]);
671
+ if (selectIndex === _this.model.cells.length - 1) {
672
+ return;
673
+ }
674
+ _this.model.exchangeCells(_this.model.selections, selectIndex + 1);
675
+ }
676
+ } else {
677
+ var sourceIndex = _this.findCellIndex(cell);
678
+ if (sourceIndex > -1) {
679
+ _this.model.exchangeCell(sourceIndex, sourceIndex + 1);
680
+ }
681
+ }
682
+ };
683
+ _this.copyCell = function (cell) {
684
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
685
+ var clipboard = {
686
+ action: 'copy',
687
+ cells: _this.model.selections.map(function (selection) {
688
+ return selection.toJSONWithoutId();
689
+ })
690
+ };
691
+ copy2clipboard(JSON.stringify(clipboard));
692
+ _this.clipboard = clipboard;
693
+ } else {
694
+ var _clipboard = {
695
+ action: 'copy',
696
+ cells: [cell.toJSONWithoutId()]
697
+ };
698
+ copy2clipboard(JSON.stringify(_clipboard));
699
+ _this.clipboard = _clipboard;
700
+ }
701
+ };
702
+ _this.cutCell = function (cell) {
703
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
704
+ var clipboard = {
705
+ action: 'cut',
706
+ cells: _this.model.selections.map(function (selection) {
707
+ return selection.toJSONWithoutId();
708
+ })
709
+ };
710
+ copy2clipboard(JSON.stringify(clipboard));
711
+ _this.clipboard = clipboard;
712
+ _this.deleteCell(cell);
713
+ } else {
714
+ var _clipboard2 = {
715
+ action: 'cut',
716
+ cells: [cell.toJSONWithoutId()]
717
+ };
718
+ copy2clipboard(JSON.stringify(_clipboard2));
719
+ _this.clipboard = _clipboard2;
720
+ _this.deleteCell(cell);
721
+ }
722
+ };
723
+ _this.pasteCell = /*#__PURE__*/function () {
724
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(cell) {
725
+ var pasteIndex, pasteValue;
726
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
727
+ while (1) switch (_context12.prev = _context12.next) {
728
+ case 0:
729
+ pasteIndex = _this.model.getCells().findIndex(function (item) {
730
+ return equals(item, cell);
731
+ });
732
+ _context12.prev = 1;
733
+ if (!_this.clipboard) {
734
+ _context12.next = 6;
735
+ break;
736
+ }
737
+ pasteValue = _this.clipboard;
738
+ _context12.next = 11;
739
+ break;
740
+ case 6:
741
+ _context12.t0 = JSON;
742
+ _context12.next = 9;
743
+ return readFromClipboard();
744
+ case 9:
745
+ _context12.t1 = _context12.sent;
746
+ pasteValue = _context12.t0.parse.call(_context12.t0, _context12.t1);
747
+ case 11:
748
+ if (!(pasteValue.action === 'copy' || pasteValue.action === 'cut')) {
749
+ _context12.next = 14;
750
+ break;
751
+ }
752
+ _this.insertCells(pasteValue.cells.map(function (item) {
753
+ return {
754
+ id: v4(),
755
+ cell: item
756
+ };
757
+ }), pasteIndex + 1);
758
+ return _context12.abrupt("return");
759
+ case 14:
760
+ _context12.next = 19;
761
+ break;
762
+ case 16:
763
+ _context12.prev = 16;
764
+ _context12.t2 = _context12["catch"](1);
765
+ console.error(_context12.t2);
766
+ case 19:
767
+ case "end":
768
+ return _context12.stop();
769
+ }
770
+ }, _callee12, null, [[1, 16]]);
771
+ }));
772
+ return function (_x14) {
773
+ return _ref12.apply(this, arguments);
774
+ };
775
+ }();
776
+ _this.pasteCellAbove = /*#__PURE__*/function () {
777
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(cell) {
778
+ var pasteIndex, pasteValue;
779
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
780
+ while (1) switch (_context13.prev = _context13.next) {
781
+ case 0:
782
+ pasteIndex = _this.model.getCells().findIndex(function (item) {
783
+ return equals(item, cell);
784
+ });
785
+ _context13.prev = 1;
786
+ if (!_this.clipboard) {
787
+ _context13.next = 6;
788
+ break;
789
+ }
790
+ pasteValue = _this.clipboard;
791
+ _context13.next = 11;
792
+ break;
793
+ case 6:
794
+ _context13.t0 = JSON;
795
+ _context13.next = 9;
796
+ return readFromClipboard();
797
+ case 9:
798
+ _context13.t1 = _context13.sent;
799
+ pasteValue = _context13.t0.parse.call(_context13.t0, _context13.t1);
800
+ case 11:
801
+ if (!(pasteValue.action === 'copy' || pasteValue.action === 'cut')) {
802
+ _context13.next = 14;
803
+ break;
804
+ }
805
+ _this.insertCells(pasteValue.cells.map(function (item) {
806
+ return {
807
+ id: v4(),
808
+ cell: item
809
+ };
810
+ }), pasteIndex);
811
+ return _context13.abrupt("return");
812
+ case 14:
813
+ _context13.next = 19;
814
+ break;
815
+ case 16:
816
+ _context13.prev = 16;
817
+ _context13.t2 = _context13["catch"](1);
818
+ console.error(_context13.t2);
819
+ case 19:
820
+ case "end":
821
+ return _context13.stop();
822
+ }
823
+ }, _callee13, null, [[1, 16]]);
824
+ }));
825
+ return function (_x15) {
826
+ return _ref13.apply(this, arguments);
827
+ };
828
+ }();
829
+ _this.invertCell = /*#__PURE__*/function () {
830
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(cell, type) {
831
+ var cellIndex, _iterator2, _step2, selectedCell, cellOptions, cellView, _cellOptions, _cellView;
832
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
833
+ while (1) switch (_context14.prev = _context14.next) {
834
+ case 0:
835
+ cellIndex = _this.model.getCells().findIndex(function (item) {
836
+ return equals(item, cell);
837
+ });
838
+ if (!(_this.model.selections.length !== 0 && _this.isSelected(cell))) {
839
+ _context14.next = 24;
840
+ break;
841
+ }
842
+ _iterator2 = _createForOfIteratorHelper(_this.model.selections);
843
+ _context14.prev = 3;
844
+ _iterator2.s();
845
+ case 5:
846
+ if ((_step2 = _iterator2.n()).done) {
847
+ _context14.next = 14;
848
+ break;
849
+ }
850
+ selectedCell = _step2.value;
851
+ cellOptions = {
852
+ cell: {
853
+ cell_type: type,
854
+ source: selectedCell.model.source,
855
+ metadata: _objectSpread(_objectSpread({}, selectedCell.model.metadata), {}, {
856
+ libroFormatter: selectedCell.model.libroFormatType
857
+ })
858
+ }
859
+ };
860
+ _context14.next = 10;
861
+ return _this.getCellViewByOption(cellOptions);
862
+ case 10:
863
+ cellView = _context14.sent;
864
+ _this.model.invertCell(cellView, cellIndex);
865
+ case 12:
866
+ _context14.next = 5;
867
+ break;
868
+ case 14:
869
+ _context14.next = 19;
870
+ break;
871
+ case 16:
872
+ _context14.prev = 16;
873
+ _context14.t0 = _context14["catch"](3);
874
+ _iterator2.e(_context14.t0);
875
+ case 19:
876
+ _context14.prev = 19;
877
+ _iterator2.f();
878
+ return _context14.finish(19);
879
+ case 22:
880
+ _context14.next = 29;
881
+ break;
882
+ case 24:
883
+ _cellOptions = {
884
+ cell: {
885
+ cell_type: type,
886
+ source: cell.model.source,
887
+ metadata: _objectSpread(_objectSpread({}, cell.model.metadata), {}, {
888
+ libroFormatter: cell.model.libroFormatType,
889
+ libroCellType: type
890
+ })
891
+ }
892
+ };
893
+ _context14.next = 27;
894
+ return _this.getCellViewByOption(_cellOptions);
895
+ case 27:
896
+ _cellView = _context14.sent;
897
+ _this.model.invertCell(_cellView, cellIndex);
898
+ case 29:
899
+ case "end":
900
+ return _context14.stop();
901
+ }
902
+ }, _callee14, null, [[3, 16, 19, 22]]);
903
+ }));
904
+ return function (_x16, _x17) {
905
+ return _ref14.apply(this, arguments);
906
+ };
907
+ }();
908
+ _this.clearOutputs = function (cell) {
909
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
910
+ var _iterator3 = _createForOfIteratorHelper(_this.model.selections),
911
+ _step3;
912
+ try {
913
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
914
+ var selectedCell = _step3.value;
915
+ if (ExecutableCellView.is(selectedCell) && ExecutableCellModel.is(selectedCell.model)) {
916
+ selectedCell.clearExecution();
917
+ selectedCell.model.executing = false;
918
+ selectedCell.model.hasOutputHidden = false;
919
+ }
920
+ }
921
+ } catch (err) {
922
+ _iterator3.e(err);
923
+ } finally {
924
+ _iterator3.f();
925
+ }
926
+ } else {
927
+ if (ExecutableCellView.is(cell) && ExecutableCellModel.is(cell.model)) {
928
+ cell.clearExecution();
929
+ cell.model.executing = false;
930
+ cell.model.hasOutputHidden = false;
931
+ }
932
+ }
933
+ };
934
+ _this.clearAllOutputs = function () {
935
+ // 清空所有 cell滚动到最上面
936
+ _this.model.scrollToView(_this.model.cells[0]);
937
+ var _iterator4 = _createForOfIteratorHelper(_this.model.cells),
938
+ _step4;
939
+ try {
940
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
941
+ var cell = _step4.value;
942
+ if (ExecutableCellView.is(cell) && ExecutableCellModel.is(cell.model)) {
943
+ cell.clearExecution();
944
+ cell.model.executing = false;
945
+ cell.model.hasOutputHidden = false;
946
+ }
947
+ }
948
+ } catch (err) {
949
+ _iterator4.e(err);
950
+ } finally {
951
+ _iterator4.f();
952
+ }
953
+ };
954
+ _this.hideCellCode = function (cell) {
955
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
956
+ var _iterator5 = _createForOfIteratorHelper(_this.model.selections),
957
+ _step5;
958
+ try {
959
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
960
+ var selectedCell = _step5.value;
961
+ selectedCell.hasInputHidden = true;
962
+ }
963
+ } catch (err) {
964
+ _iterator5.e(err);
965
+ } finally {
966
+ _iterator5.f();
967
+ }
968
+ } else {
969
+ cell.hasInputHidden = true;
970
+ }
971
+ };
972
+ _this.hideOrShowCellCode = function (cell) {
973
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
974
+ var _iterator6 = _createForOfIteratorHelper(_this.model.selections),
975
+ _step6;
976
+ try {
977
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
978
+ var selectedCell = _step6.value;
979
+ selectedCell.hasInputHidden = !selectedCell.hasInputHidden;
980
+ }
981
+ } catch (err) {
982
+ _iterator6.e(err);
983
+ } finally {
984
+ _iterator6.f();
985
+ }
986
+ } else {
987
+ cell.hasInputHidden = !cell.hasInputHidden;
988
+ }
989
+ };
990
+ _this.hideOutputs = function (cell) {
991
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
992
+ var _iterator7 = _createForOfIteratorHelper(_this.model.selections),
993
+ _step7;
994
+ try {
995
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
996
+ var selectedCell = _step7.value;
997
+ if (ExecutableCellModel.is(selectedCell.model)) {
998
+ selectedCell.model.hasOutputHidden = true;
999
+ }
1000
+ }
1001
+ } catch (err) {
1002
+ _iterator7.e(err);
1003
+ } finally {
1004
+ _iterator7.f();
1005
+ }
1006
+ } else {
1007
+ if (ExecutableCellModel.is(cell.model)) {
1008
+ cell.model.hasOutputHidden = true;
1009
+ }
1010
+ }
1011
+ };
1012
+ _this.hideOrShowOutputs = function (cell) {
1013
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
1014
+ var _iterator8 = _createForOfIteratorHelper(_this.model.selections),
1015
+ _step8;
1016
+ try {
1017
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1018
+ var selectedCell = _step8.value;
1019
+ if (ExecutableCellModel.is(selectedCell.model)) {
1020
+ selectedCell.model.hasOutputHidden = !selectedCell.model.hasOutputHidden;
1021
+ }
1022
+ }
1023
+ } catch (err) {
1024
+ _iterator8.e(err);
1025
+ } finally {
1026
+ _iterator8.f();
1027
+ }
1028
+ } else {
1029
+ if (ExecutableCellModel.is(cell.model)) {
1030
+ cell.model.hasOutputHidden = !cell.model.hasOutputHidden;
1031
+ }
1032
+ }
1033
+ };
1034
+ _this.hideAllOutputs = function () {
1035
+ var _iterator9 = _createForOfIteratorHelper(_this.model.cells),
1036
+ _step9;
1037
+ try {
1038
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1039
+ var cell = _step9.value;
1040
+ if (ExecutableCellModel.is(cell.model)) {
1041
+ cell.model.hasOutputHidden = true;
1042
+ }
1043
+ }
1044
+ } catch (err) {
1045
+ _iterator9.e(err);
1046
+ } finally {
1047
+ _iterator9.f();
1048
+ }
1049
+ };
1050
+ _this.hideAllCellCode = function () {
1051
+ var _iterator10 = _createForOfIteratorHelper(_this.model.cells),
1052
+ _step10;
1053
+ try {
1054
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1055
+ var cell = _step10.value;
1056
+ cell.hasInputHidden = true;
1057
+ }
1058
+ } catch (err) {
1059
+ _iterator10.e(err);
1060
+ } finally {
1061
+ _iterator10.f();
1062
+ }
1063
+ };
1064
+ _this.showCellCode = function (cell) {
1065
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
1066
+ var _iterator11 = _createForOfIteratorHelper(_this.model.selections),
1067
+ _step11;
1068
+ try {
1069
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
1070
+ var selectedCell = _step11.value;
1071
+ selectedCell.hasInputHidden = false;
1072
+ }
1073
+ } catch (err) {
1074
+ _iterator11.e(err);
1075
+ } finally {
1076
+ _iterator11.f();
1077
+ }
1078
+ } else {
1079
+ cell.hasInputHidden = false;
1080
+ }
1081
+ };
1082
+ _this.showAllCellCode = function () {
1083
+ var _iterator12 = _createForOfIteratorHelper(_this.model.cells),
1084
+ _step12;
1085
+ try {
1086
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
1087
+ var cell = _step12.value;
1088
+ cell.hasInputHidden = false;
1089
+ }
1090
+ } catch (err) {
1091
+ _iterator12.e(err);
1092
+ } finally {
1093
+ _iterator12.f();
1094
+ }
1095
+ };
1096
+ _this.showCellOutputs = function (cell) {
1097
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
1098
+ var _iterator13 = _createForOfIteratorHelper(_this.model.selections),
1099
+ _step13;
1100
+ try {
1101
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
1102
+ var selectedCell = _step13.value;
1103
+ if (ExecutableCellModel.is(selectedCell.model)) {
1104
+ selectedCell.model.hasOutputHidden = false;
1105
+ }
1106
+ }
1107
+ } catch (err) {
1108
+ _iterator13.e(err);
1109
+ } finally {
1110
+ _iterator13.f();
1111
+ }
1112
+ } else {
1113
+ if (ExecutableCellModel.is(cell.model)) {
1114
+ cell.model.hasOutputHidden = false;
1115
+ }
1116
+ }
1117
+ };
1118
+ _this.showAllCellOutputs = function () {
1119
+ var _iterator14 = _createForOfIteratorHelper(_this.model.cells),
1120
+ _step14;
1121
+ try {
1122
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
1123
+ var cell = _step14.value;
1124
+ if (ExecutableCellModel.is(cell.model)) {
1125
+ cell.model.hasOutputHidden = false;
1126
+ }
1127
+ }
1128
+ } catch (err) {
1129
+ _iterator14.e(err);
1130
+ } finally {
1131
+ _iterator14.f();
1132
+ }
1133
+ };
1134
+ _this.extendSelectionAbove = function () {
1135
+ if (_this.activeCell) {
1136
+ var previousCell = _this.getPreviousVisibleCell(_this.activeCell);
1137
+ if (previousCell) {
1138
+ _this.collapseCell(previousCell, false);
1139
+ }
1140
+ var activeIndex = _this.findCellIndex(_this.activeCell);
1141
+ if (_this.findCellIndex(_this.activeCell) > 0) {
1142
+ _this.extendContiguousSelectionTo(activeIndex - 1);
1143
+ }
1144
+ _this.model.scrollToView(_this.activeCell);
1145
+ }
1146
+ };
1147
+ _this.extendSelectionToTop = function () {
1148
+ if (_this.activeCell) {
1149
+ if (_this.findCellIndex(_this.activeCell) > 0) {
1150
+ _this.extendContiguousSelectionTo(0);
1151
+ }
1152
+ _this.model.scrollToView(_this.activeCell);
1153
+ }
1154
+ };
1155
+ _this.extendSelectionBelow = function () {
1156
+ if (_this.activeCell) {
1157
+ var nextCell = _this.getNextVisibleCell(_this.activeCell);
1158
+ if (nextCell) {
1159
+ _this.collapseCell(nextCell, false);
1160
+ }
1161
+ var activeIndex = _this.findCellIndex(_this.activeCell);
1162
+ if (_this.findCellIndex(_this.activeCell) >= 0) {
1163
+ _this.extendContiguousSelectionTo(activeIndex + 1);
1164
+ }
1165
+ _this.model.scrollToView(_this.activeCell);
1166
+ }
1167
+ };
1168
+ _this.extendSelectionToBottom = function () {
1169
+ if (_this.activeCell) {
1170
+ if (_this.findCellIndex(_this.activeCell) > 0) {
1171
+ _this.extendContiguousSelectionTo(_this.model.cells.length - 1);
1172
+ }
1173
+ _this.model.scrollToView(_this.activeCell);
1174
+ }
1175
+ };
1176
+ _this.enableOutputScrolling = function (cell) {
1177
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
1178
+ var _iterator15 = _createForOfIteratorHelper(_this.model.selections),
1179
+ _step15;
1180
+ try {
1181
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
1182
+ var selectedCell = _step15.value;
1183
+ if (ExecutableCellModel.is(selectedCell.model)) {
1184
+ selectedCell.model.hasOutputsScrolled = true;
1185
+ }
1186
+ }
1187
+ } catch (err) {
1188
+ _iterator15.e(err);
1189
+ } finally {
1190
+ _iterator15.f();
1191
+ }
1192
+ } else {
1193
+ if (ExecutableCellModel.is(cell.model)) {
1194
+ cell.model.hasOutputsScrolled = true;
1195
+ }
1196
+ }
1197
+ };
1198
+ _this.disableOutputScrolling = function (cell) {
1199
+ _this.outputsScroll = false;
1200
+ if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
1201
+ var _iterator16 = _createForOfIteratorHelper(_this.model.selections),
1202
+ _step16;
1203
+ try {
1204
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
1205
+ var selectedCell = _step16.value;
1206
+ if (ExecutableCellModel.is(selectedCell.model)) {
1207
+ selectedCell.model.hasOutputsScrolled = false;
1208
+ }
1209
+ }
1210
+ } catch (err) {
1211
+ _iterator16.e(err);
1212
+ } finally {
1213
+ _iterator16.f();
1214
+ }
1215
+ } else {
1216
+ if (ExecutableCellModel.is(cell.model)) {
1217
+ cell.model.hasOutputsScrolled = false;
1218
+ }
1219
+ }
1220
+ };
1221
+ _this.disableAllOutputScrolling = function () {
1222
+ _this.outputsScroll = false;
1223
+ var _iterator17 = _createForOfIteratorHelper(_this.model.cells),
1224
+ _step17;
1225
+ try {
1226
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
1227
+ var cell = _step17.value;
1228
+ if (ExecutableCellModel.is(cell.model)) {
1229
+ cell.model.hasOutputsScrolled = false;
1230
+ }
1231
+ }
1232
+ } catch (err) {
1233
+ _iterator17.e(err);
1234
+ } finally {
1235
+ _iterator17.f();
1236
+ }
1237
+ };
1238
+ _this.enableAllOutputScrolling = function () {
1239
+ _this.outputsScroll = true;
1240
+ var _iterator18 = _createForOfIteratorHelper(_this.model.cells),
1241
+ _step18;
1242
+ try {
1243
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
1244
+ var cell = _step18.value;
1245
+ if (ExecutableCellModel.is(cell.model)) {
1246
+ cell.model.hasOutputsScrolled = true;
1247
+ }
1248
+ }
1249
+ } catch (err) {
1250
+ _iterator18.e(err);
1251
+ } finally {
1252
+ _iterator18.f();
1253
+ }
1254
+ };
1255
+ _this.disposed = false;
1256
+ _this.enterCommandMode = function (isInLibro) {
1257
+ if (_this.hasModal) {
1258
+ return;
1259
+ }
1260
+ if (_this.model.enterCommandMode) {
1261
+ _this.model.enterCommandMode();
1262
+ }
1263
+ if (isInLibro) {
1264
+ var _this$container3;
1265
+ (_this$container3 = _this.container) === null || _this$container3 === void 0 || (_this$container3 = _this$container3.current) === null || _this$container3 === void 0 || _this$container3.focus();
1266
+ }
1267
+ };
1268
+ _this.enterEditMode = function () {
1269
+ if (_this.model.enterEditMode) {
1270
+ _this.model.enterEditMode();
1271
+ }
1272
+ };
1273
+ _this.moveCursorDown = function (cell) {
1274
+ var newSelectedCell = _this.getNextVisibleCell(cell);
1275
+ if (newSelectedCell) {
1276
+ _this.model.selectCell(newSelectedCell);
1277
+ _this.model.selections = [];
1278
+ _this.model.scrollToView(newSelectedCell);
1279
+ }
1280
+ };
1281
+ _this.moveCursorUp = function (cell) {
1282
+ var newSelectedCell = _this.getPreviousVisibleCell(cell);
1283
+ if (newSelectedCell) {
1284
+ _this.model.selectCell(newSelectedCell);
1285
+ _this.model.selections = [];
1286
+ _this.model.scrollToView(newSelectedCell);
1287
+ }
1288
+ };
1289
+ _this.mergeCellBelow = /*#__PURE__*/function () {
1290
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(cell) {
1291
+ var _this$model, cells, selections, selectedIndex, nextCell, source, cellView, cellData;
1292
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1293
+ while (1) switch (_context15.prev = _context15.next) {
1294
+ case 0:
1295
+ _this$model = _this.model, cells = _this$model.cells, selections = _this$model.selections;
1296
+ if (!(selections.length > 1)) {
1297
+ _context15.next = 4;
1298
+ break;
1299
+ }
1300
+ _this.mergeCells(cell);
1301
+ return _context15.abrupt("return");
1302
+ case 4:
1303
+ selectedIndex = _this.findCellIndex(cell);
1304
+ if (!(selectedIndex >= cells.length - 1)) {
1305
+ _context15.next = 7;
1306
+ break;
1307
+ }
1308
+ return _context15.abrupt("return");
1309
+ case 7:
1310
+ nextCell = cells[selectedIndex + 1];
1311
+ source = concatMultilineString([cell.model.value + '\n', nextCell.model.value]);
1312
+ _context15.next = 11;
1313
+ return _this.getCellViewByOption({
1314
+ id: v4(),
1315
+ cell: {
1316
+ cell_type: cell.model.type,
1317
+ source: source,
1318
+ metadata: {}
1319
+ }
1320
+ });
1321
+ case 11:
1322
+ cellView = _context15.sent;
1323
+ if (_this.model instanceof LibroModel) {
1324
+ _this.model.activeIndex = selectedIndex;
1325
+ cellData = [cellView].map(function (_cell) {
1326
+ _this.model.cellViewCache.set(_cell.model.id, _cell);
1327
+ return _cell.toJSON();
1328
+ });
1329
+ _this.model.sharedModel.transact(function () {
1330
+ _this.model.sharedModel.deleteCell(selectedIndex);
1331
+ _this.model.sharedModel.insertCells(selectedIndex, cellData);
1332
+ _this.model.sharedModel.deleteCell(selectedIndex + 1);
1333
+ });
1334
+ }
1335
+ case 13:
1336
+ case "end":
1337
+ return _context15.stop();
1338
+ }
1339
+ }, _callee15);
1340
+ }));
1341
+ return function (_x18) {
1342
+ return _ref15.apply(this, arguments);
1343
+ };
1344
+ }();
1345
+ _this.mergeCellAbove = /*#__PURE__*/function () {
1346
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(cell) {
1347
+ var _this$model2, cells, selections, selectedIndex, prevCell, source, cellView, cellData;
1348
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1349
+ while (1) switch (_context16.prev = _context16.next) {
1350
+ case 0:
1351
+ _this$model2 = _this.model, cells = _this$model2.cells, selections = _this$model2.selections;
1352
+ if (!(selections.length > 1)) {
1353
+ _context16.next = 4;
1354
+ break;
1355
+ }
1356
+ _this.mergeCells(cell);
1357
+ return _context16.abrupt("return");
1358
+ case 4:
1359
+ selectedIndex = _this.findCellIndex(cell);
1360
+ if (!(selectedIndex <= 0)) {
1361
+ _context16.next = 7;
1362
+ break;
1363
+ }
1364
+ return _context16.abrupt("return");
1365
+ case 7:
1366
+ prevCell = cells[selectedIndex - 1];
1367
+ source = concatMultilineString([prevCell.model.value + '\n' + cell.model.value]);
1368
+ _context16.next = 11;
1369
+ return _this.getCellViewByOption({
1370
+ id: v4(),
1371
+ cell: {
1372
+ cell_type: cell.model.type,
1373
+ source: source,
1374
+ metadata: {}
1375
+ }
1376
+ });
1377
+ case 11:
1378
+ cellView = _context16.sent;
1379
+ if (_this.model instanceof LibroModel) {
1380
+ _this.model.activeIndex = selectedIndex - 1;
1381
+ cellData = [cellView].map(function (_cell) {
1382
+ _this.model.cellViewCache.set(_cell.model.id, _cell);
1383
+ return _cell.toJSON();
1384
+ });
1385
+ _this.model.sharedModel.transact(function () {
1386
+ _this.model.sharedModel.deleteCell(selectedIndex - 1);
1387
+ _this.model.sharedModel.insertCells(selectedIndex - 1, cellData);
1388
+ _this.model.sharedModel.deleteCell(selectedIndex);
1389
+ });
1390
+ }
1391
+ case 13:
1392
+ case "end":
1393
+ return _context16.stop();
1394
+ }
1395
+ }, _callee16);
1396
+ }));
1397
+ return function (_x19) {
1398
+ return _ref16.apply(this, arguments);
1399
+ };
1400
+ }();
1401
+ _this.mergeCells = /*#__PURE__*/function () {
1402
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(cell) {
1403
+ var selections, selectionsValue, selectionsIndex, source, cellView, cellData, startIndex, endIndex;
1404
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1405
+ while (1) switch (_context17.prev = _context17.next) {
1406
+ case 0:
1407
+ selections = _this.model.selections;
1408
+ if (!(selections.length <= 1)) {
1409
+ _context17.next = 3;
1410
+ break;
1411
+ }
1412
+ return _context17.abrupt("return");
1413
+ case 3:
1414
+ selectionsValue = [];
1415
+ selectionsIndex = [];
1416
+ selections.map(function (item) {
1417
+ selectionsValue.push(item.model.value);
1418
+ selectionsValue.push('\n');
1419
+ var index = _this.findCellIndex(item);
1420
+ selectionsIndex.push(index);
1421
+ });
1422
+ source = concatMultilineString(selectionsValue);
1423
+ _context17.next = 9;
1424
+ return _this.getCellViewByOption({
1425
+ id: v4(),
1426
+ cell: {
1427
+ cell_type: cell.model.type,
1428
+ source: source,
1429
+ metadata: {}
1430
+ }
1431
+ });
1432
+ case 9:
1433
+ cellView = _context17.sent;
1434
+ if (_this.model instanceof LibroModel) {
1435
+ _this.model.activeIndex = Math.min.apply(Math, selectionsIndex);
1436
+ cellData = [cellView].map(function (_cell) {
1437
+ _this.model.cellViewCache.set(_cell.model.id, _cell);
1438
+ return _cell.toJSON();
1439
+ });
1440
+ startIndex = Math.min.apply(Math, selectionsIndex);
1441
+ endIndex = Math.max.apply(Math, selectionsIndex);
1442
+ _this.model.sharedModel.transact(function () {
1443
+ _this.model.sharedModel.deleteCellRange(startIndex, endIndex + 1);
1444
+ _this.model.sharedModel.insertCells(Math.min.apply(Math, selectionsIndex), cellData);
1445
+ });
1446
+ }
1447
+ case 11:
1448
+ case "end":
1449
+ return _context17.stop();
1450
+ }
1451
+ }, _callee17);
1452
+ }));
1453
+ return function (_x20) {
1454
+ return _ref17.apply(this, arguments);
1455
+ };
1456
+ }();
1457
+ _this.selectAllCell = function () {
1458
+ _this.model.selections = _this.model.cells;
1459
+ };
1460
+ _this.splitCell = /*#__PURE__*/function () {
1461
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(cell) {
1462
+ var index, _cell$editor$getSelec, _cell$editor, selections, offsets, i, _cell$editor$getOffse, _cell$editor2, _cell$editor$getOffse2, _cell$editor3, select, start, end, splitCells;
1463
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1464
+ while (1) switch (_context19.prev = _context19.next) {
1465
+ case 0:
1466
+ index = _this.findCellIndex(cell);
1467
+ if (!EditorCellView.is(cell)) {
1468
+ _context19.next = 10;
1469
+ break;
1470
+ }
1471
+ selections = (_cell$editor$getSelec = (_cell$editor = cell.editor) === null || _cell$editor === void 0 ? void 0 : _cell$editor.getSelections()) !== null && _cell$editor$getSelec !== void 0 ? _cell$editor$getSelec : [];
1472
+ offsets = [0];
1473
+ for (i = 0; i < selections.length; i++) {
1474
+ // append start and end to handle selections
1475
+ // cursors will have same start and end
1476
+ select = selections[i];
1477
+ start = (_cell$editor$getOffse = (_cell$editor2 = cell.editor) === null || _cell$editor2 === void 0 ? void 0 : _cell$editor2.getOffsetAt(select.start)) !== null && _cell$editor$getOffse !== void 0 ? _cell$editor$getOffse : 0;
1478
+ end = (_cell$editor$getOffse2 = (_cell$editor3 = cell.editor) === null || _cell$editor3 === void 0 ? void 0 : _cell$editor3.getOffsetAt(select.end)) !== null && _cell$editor$getOffse2 !== void 0 ? _cell$editor$getOffse2 : 0;
1479
+ if (start < end) {
1480
+ offsets.push(start);
1481
+ offsets.push(end);
1482
+ } else if (end < start) {
1483
+ offsets.push(end);
1484
+ offsets.push(start);
1485
+ } else {
1486
+ offsets.push(start);
1487
+ }
1488
+ }
1489
+ offsets.push(cell.model.value.length);
1490
+ _context19.next = 8;
1491
+ return Promise.all(offsets.slice(0, -1).map( /*#__PURE__*/function () {
1492
+ var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(offset, offsetIdx) {
1493
+ var cellView;
1494
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1495
+ while (1) switch (_context18.prev = _context18.next) {
1496
+ case 0:
1497
+ _context18.next = 2;
1498
+ return _this.getCellViewByOption({
1499
+ id: v4(),
1500
+ cell: {
1501
+ cell_type: cell.model.type,
1502
+ source: cell.model.value.slice(offset, offsets[offsetIdx + 1]).replace(/^\n+/, '').replace(/\n+$/, ''),
1503
+ metadata: {}
1504
+ }
1505
+ });
1506
+ case 2:
1507
+ cellView = _context18.sent;
1508
+ return _context18.abrupt("return", cellView);
1509
+ case 4:
1510
+ case "end":
1511
+ return _context18.stop();
1512
+ }
1513
+ }, _callee18);
1514
+ }));
1515
+ return function (_x22, _x23) {
1516
+ return _ref19.apply(this, arguments);
1517
+ };
1518
+ }()));
1519
+ case 8:
1520
+ splitCells = _context19.sent;
1521
+ _this.model.splitCell(splitCells, index);
1522
+ case 10:
1523
+ case "end":
1524
+ return _context19.stop();
1525
+ }
1526
+ }, _callee19);
1527
+ }));
1528
+ return function (_x21) {
1529
+ return _ref18.apply(this, arguments);
1530
+ };
1531
+ }();
1532
+ _this.restartClearOutput = function () {
1533
+ if (_this.model.restart) {
1534
+ _this.model.restart();
1535
+ }
1536
+ _this.clearAllOutputs();
1537
+ };
1538
+ _this.closeAndShutdown = function () {
1539
+ if (_this.model.shutdown) {
1540
+ _this.model.shutdown();
1541
+ }
1542
+ };
1543
+ /**
1544
+ * Set the markdown header level of a cell.
1545
+ */
1546
+ _this.setMarkdownHeader = /*#__PURE__*/function () {
1547
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(cell, level) {
1548
+ var selections, selectionsValue, selectionsIndex, cellViews, cellData, startIndex, endIndex, index, source, regex, newHeader, matches, cellView, _cellData;
1549
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1550
+ while (1) switch (_context21.prev = _context21.next) {
1551
+ case 0:
1552
+ if (!(_this.model.selections.length !== 0 && _this.isSelected(cell))) {
1553
+ _context21.next = 10;
1554
+ break;
1555
+ }
1556
+ selections = _this.model.selections;
1557
+ selectionsValue = [];
1558
+ selectionsIndex = [];
1559
+ _context21.next = 6;
1560
+ return Promise.all(selections.map( /*#__PURE__*/function () {
1561
+ var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(item) {
1562
+ var source, regex, newHeader, matches, index, cellView;
1563
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1564
+ while (1) switch (_context20.prev = _context20.next) {
1565
+ case 0:
1566
+ source = item.model.value;
1567
+ regex = /^(#+\s*)|^(\s*)/;
1568
+ newHeader = Array(level + 1).join('#') + ' ';
1569
+ matches = regex.exec(source);
1570
+ if (matches) {
1571
+ source = source.slice(matches[0].length);
1572
+ }
1573
+ source = newHeader + source;
1574
+ selectionsValue.push(source);
1575
+ index = _this.findCellIndex(item);
1576
+ selectionsIndex.push(index);
1577
+ _context20.next = 11;
1578
+ return _this.getCellViewByOption({
1579
+ id: v4(),
1580
+ cell: {
1581
+ cell_type: 'markdown',
1582
+ source: source,
1583
+ metadata: {}
1584
+ }
1585
+ });
1586
+ case 11:
1587
+ cellView = _context20.sent;
1588
+ return _context20.abrupt("return", cellView);
1589
+ case 13:
1590
+ case "end":
1591
+ return _context20.stop();
1592
+ }
1593
+ }, _callee20);
1594
+ }));
1595
+ return function (_x26) {
1596
+ return _ref21.apply(this, arguments);
1597
+ };
1598
+ }()));
1599
+ case 6:
1600
+ cellViews = _context21.sent;
1601
+ // TODO: why is this needed?
1602
+ // const source = concatMultilineString(selectionsValue);
1603
+
1604
+ if (_this.model instanceof LibroModel) {
1605
+ _this.model.activeIndex = Math.min.apply(Math, selectionsIndex);
1606
+ cellData = cellViews.map(function (_cell) {
1607
+ _this.model.cellViewCache.set(_cell.model.id, _cell);
1608
+ return _cell.toJSON();
1609
+ });
1610
+ startIndex = Math.min.apply(Math, selectionsIndex);
1611
+ endIndex = Math.max.apply(Math, selectionsIndex);
1612
+ _this.model.sharedModel.transact(function () {
1613
+ _this.model.sharedModel.deleteCellRange(startIndex, endIndex + 1);
1614
+ _this.model.sharedModel.insertCells(startIndex, cellData);
1615
+ });
1616
+ }
1617
+ _context21.next = 21;
1618
+ break;
1619
+ case 10:
1620
+ index = _this.findCellIndex(cell);
1621
+ source = cell.model.value;
1622
+ regex = /^(#+\s*)|^(\s*)/;
1623
+ newHeader = Array(level + 1).join('#') + ' ';
1624
+ matches = regex.exec(source);
1625
+ if (matches) {
1626
+ source = source.slice(matches[0].length);
1627
+ }
1628
+ source = newHeader + source;
1629
+ _context21.next = 19;
1630
+ return _this.getCellViewByOption({
1631
+ id: v4(),
1632
+ cell: {
1633
+ cell_type: 'markdown',
1634
+ source: source,
1635
+ metadata: {}
1636
+ }
1637
+ });
1638
+ case 19:
1639
+ cellView = _context21.sent;
1640
+ if (_this.model instanceof LibroModel) {
1641
+ _this.model.activeIndex = index;
1642
+ _cellData = [cellView].map(function (_cell) {
1643
+ _this.model.cellViewCache.set(_cell.model.id, _cell);
1644
+ return _cell.toJSON();
1645
+ });
1646
+ _this.model.sharedModel.transact(function () {
1647
+ _this.model.sharedModel.deleteCell(index);
1648
+ _this.model.sharedModel.insertCells(index, _cellData);
1649
+ });
1650
+ }
1651
+ case 21:
1652
+ _this.enterCommandMode(true);
1653
+ case 22:
1654
+ case "end":
1655
+ return _context21.stop();
1656
+ }
1657
+ }, _callee21);
1658
+ }));
1659
+ return function (_x24, _x25) {
1660
+ return _ref20.apply(this, arguments);
1661
+ };
1662
+ }();
1663
+ if (_options.id) {
1664
+ _this.id = _options.id;
1665
+ }
1666
+ _this.notebookService = notebookService;
1667
+ _this.model = _this.notebookService.getOrCreateModel(_options);
1668
+ _this.collapseService = collapseServiceFactory({
1669
+ view: _assertThisInitialized(_this)
1670
+ });
1671
+ _this.collapserVisible = _this.collapseService.collapserVisible;
1672
+ _this.virtualizedManagerHelper = virtualizedManagerHelper;
1673
+ _this.virtualizedManager = virtualizedManagerHelper.getOrCreate(_this.model);
1674
+ _this.initialize();
1675
+ _this.initView();
1676
+ return _this;
1677
+ }
1678
+ LibroView = inject(VirtualizedManagerHelper)(LibroView, undefined, 3) || LibroView;
1679
+ LibroView = inject(NotebookService)(LibroView, undefined, 2) || LibroView;
1680
+ LibroView = inject(CollapseServiceFactory)(LibroView, undefined, 1) || LibroView;
1681
+ LibroView = inject(ViewOption)(LibroView, undefined, 0) || LibroView;
1682
+ _createClass(LibroView, [{
1683
+ key: "onCellCreate",
1684
+ get: function get() {
1685
+ return this.onCellCreateEmitter.event;
1686
+ }
1687
+ }, {
1688
+ key: "onCellDelete",
1689
+ get: function get() {
1690
+ return this.onCellDeleteEmitter.event;
1691
+ }
1692
+ }, {
1693
+ key: "onBlur",
1694
+ get: function get() {
1695
+ return this.onBlurEmitter.event;
1696
+ }
1697
+ }, {
1698
+ key: "hasModal",
1699
+ get: function get() {
1700
+ return this.model.cells.some(function (item) {
1701
+ return item.hasModal;
1702
+ });
1703
+ }
1704
+ }, {
1705
+ key: "onSave",
1706
+ get: function get() {
1707
+ return this.onSaveEmitter.event;
1708
+ }
1709
+ }, {
1710
+ key: "onCellContentChanged",
1711
+ get: function get() {
1712
+ return this.onCellContentChangedEmitter.event;
1713
+ }
1714
+ }, {
1715
+ key: "onRunCell",
1716
+ get: function get() {
1717
+ return this.runCellEmitter.event;
1718
+ }
1719
+ }, {
1720
+ key: "onCellScroll",
1721
+ get: function get() {
1722
+ return this.cellScrollEmitter.event;
1723
+ }
1724
+ }, {
1725
+ key: "initialized",
1726
+ get: function get() {
1727
+ return this.initializedDefer.promise;
1728
+ }
1729
+ }, {
1730
+ key: "initView",
1731
+ value: function initView() {
1732
+ // this.configurationService.get(TOCVisible).then(() => {
1733
+ // this.viewManager.getOrCreateView(MarkdownCellTocView, { id: this.id }).then(toc => {
1734
+ // this.toc = toc;
1735
+ // toc.parent = this;
1736
+ // });
1737
+ // });
1738
+ // this.viewManager
1739
+ // .getOrCreateView(LibroKeybindInstrutionsView, { id: 'libro-keybind-instructions' })
1740
+ // .then(keybindInstrutions => {
1741
+ // this.keybindInstrutionsView = keybindInstrutions;
1742
+ // });
1743
+ }
1744
+ }, {
1745
+ key: "initialize",
1746
+ value: function () {
1747
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1748
+ var _this2 = this;
1749
+ var options;
1750
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1751
+ while (1) switch (_context22.prev = _context22.next) {
1752
+ case 0:
1753
+ this.model.isInitialized = false;
1754
+ _context22.next = 3;
1755
+ return this.model.initialize();
1756
+ case 3:
1757
+ options = _context22.sent;
1758
+ this.configurationService.get(AutoInsertWhenNoCell).then(function (value) {
1759
+ var isAutoInsertWhenNoCell = value;
1760
+ if (isAutoInsertWhenNoCell && options.length === 0) {
1761
+ _this2.addCell({
1762
+ id: v4(),
1763
+ cell: {
1764
+ cell_type: 'code',
1765
+ source: '',
1766
+ metadata: {}
1767
+ }
1768
+ }, 0);
1769
+ }
1770
+ return;
1771
+ }).catch(function (e) {
1772
+ //
1773
+ });
1774
+ _context22.next = 7;
1775
+ return this.insertCells(options);
1776
+ case 7:
1777
+ // 第一次insert不需要历史
1778
+ setTimeout(function () {
1779
+ _this2.model.sharedModel.clearUndoHistory();
1780
+ // 未初始化完成不做渲染,防止重复渲染多次
1781
+ _this2.model.isInitialized = true;
1782
+ _this2.configurationService.get(EnterEditModeWhenAddCell).then(function (value) {
1783
+ if (value) {
1784
+ _this2.enterEditMode();
1785
+ } else {
1786
+ _this2.enterCommandMode(true);
1787
+ }
1788
+ return;
1789
+ }).catch(function (e) {
1790
+ //
1791
+ });
1792
+ _this2.toDispose.push(watch(_this2.model, 'cells', function () {
1793
+ var _this2$model$onChange, _this2$model;
1794
+ (_this2$model$onChange = (_this2$model = _this2.model).onChange) === null || _this2$model$onChange === void 0 || _this2$model$onChange.call(_this2$model);
1795
+ }));
1796
+ _this2.initializedDefer.resolve();
1797
+ }, 0);
1798
+ case 8:
1799
+ case "end":
1800
+ return _context22.stop();
1801
+ }
1802
+ }, _callee22, this);
1803
+ }));
1804
+ function initialize() {
1805
+ return _initialize.apply(this, arguments);
1806
+ }
1807
+ return initialize;
1808
+ }()
1809
+ }, {
1810
+ key: "getCellViewByOption",
1811
+ value: function () {
1812
+ var _getCellViewByOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(option) {
1813
+ var _this3 = this;
1814
+ var toDispose, cellView, disposable;
1815
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1816
+ while (1) switch (_context23.prev = _context23.next) {
1817
+ case 0:
1818
+ toDispose = new DisposableCollection();
1819
+ option.cell.metadata.trusted = this.model.trusted;
1820
+ _context23.next = 4;
1821
+ return this.cellService.getOrCreateView(option, this.id);
1822
+ case 4:
1823
+ cellView = _context23.sent;
1824
+ cellView.parent = this;
1825
+ this.onCellCreateEmitter.fire(cellView);
1826
+ toDispose.push(Disposable.create(function () {
1827
+ _this3.deleteCell(cellView);
1828
+ }));
1829
+ disposable = cellView.onDisposed(function () {
1830
+ toDispose.dispose();
1831
+ });
1832
+ toDispose.push(disposable);
1833
+ return _context23.abrupt("return", cellView);
1834
+ case 11:
1835
+ case "end":
1836
+ return _context23.stop();
1837
+ }
1838
+ }, _callee23, this);
1839
+ }));
1840
+ function getCellViewByOption(_x27) {
1841
+ return _getCellViewByOption.apply(this, arguments);
1842
+ }
1843
+ return getCellViewByOption;
1844
+ }()
1845
+ }, {
1846
+ key: "activeCell",
1847
+ get: function get() {
1848
+ return this.model.active;
1849
+ }
1850
+ }, {
1851
+ key: "activeCellIndex",
1852
+ get: function get() {
1853
+ return this.model.activeIndex;
1854
+ }
1855
+ }, {
1856
+ key: "executeCellRun",
1857
+ value: function executeCellRun(cell) {
1858
+ this.runCellEmitter.fire(cell);
1859
+ if (ExecutableCellView.is(cell)) {
1860
+ return cell.run();
1861
+ } else {
1862
+ return undefined;
1863
+ }
1864
+ }
1865
+ }, {
1866
+ key: "getPreviousVisibleCell",
1867
+ value: function getPreviousVisibleCell(cell) {
1868
+ var _this4 = this;
1869
+ var currentIndex = this.findCellIndex(cell);
1870
+ return this.model.cells.slice().reverse().find(function (item, index) {
1871
+ return index > _this4.model.cells.length - currentIndex - 1 && item.collapsedHidden === false;
1872
+ });
1873
+ }
1874
+ }, {
1875
+ key: "getNextVisibleCell",
1876
+ value: function getNextVisibleCell(cell) {
1877
+ var currentIndex = this.findCellIndex(cell);
1878
+ return this.model.cells.find(function (item, index) {
1879
+ return index > currentIndex && item.collapsedHidden === false;
1880
+ });
1881
+ }
1882
+ }, {
1883
+ key: "isSelected",
1884
+ value:
1885
+ /**
1886
+ * Whether a cell is selected.
1887
+ */
1888
+ function isSelected(cell) {
1889
+ if (equals(this.activeCell, cell)) {
1890
+ return true;
1891
+ }
1892
+ if (this.model.selections.length !== 0) {
1893
+ return this.model.selections.findIndex(function (item) {
1894
+ return item.id === cell.id;
1895
+ }) >= 0 ? true : false;
1896
+ }
1897
+ return false;
1898
+ }
1899
+ }, {
1900
+ key: "extendContiguousSelectionTo",
1901
+ value:
1902
+ /**
1903
+ * Move the head of an existing contiguous selection to extend the selection.
1904
+ *
1905
+ * @param index - The new head of the existing selection.
1906
+ *
1907
+ * #### Notes
1908
+ * If there is no existing selection, the active cell is considered an
1909
+ * existing one-cell selection.
1910
+ *
1911
+ * If the new selection is a single cell, that cell becomes the active cell
1912
+ * and all cells are deselected.
1913
+ *
1914
+ * There is no change if there are no cells (i.e., activeCellIndex is -1).
1915
+ */
1916
+ function extendContiguousSelectionTo(index) {
1917
+ var selectIndex = index;
1918
+ var _this$getContiguousSe = this.getContiguousSelection(),
1919
+ head = _this$getContiguousSe.head,
1920
+ anchor = _this$getContiguousSe.anchor;
1921
+ if (this.activeCell) {
1922
+ // Handle the case of no current selection.
1923
+ if (anchor === null || head === null) {
1924
+ if (selectIndex === this.model.activeIndex) {
1925
+ // Already collapsed selection, nothing more to do.
1926
+ return;
1927
+ }
1928
+
1929
+ // We will start a new selection below.
1930
+ head = this.model.activeIndex;
1931
+ anchor = this.model.activeIndex;
1932
+ }
1933
+ // Move the active cell. We do this before the collapsing shortcut below.
1934
+ if (this.model.cells[selectIndex]) {
1935
+ this.model.active = this.model.cells[selectIndex];
1936
+ this.model.activeIndex = selectIndex;
1937
+ }
1938
+ // Make sure the index is valid, according to the rules for setting and clipping the
1939
+ // active cell index. This may change the index.
1940
+ selectIndex = this.model.activeIndex;
1941
+
1942
+ // Collapse the selection if it is only the active cell.
1943
+ if (selectIndex === anchor) {
1944
+ // this.deselectAll();
1945
+ this.model.selections = [];
1946
+ return;
1947
+ }
1948
+ this.model.selections = this.model.cells.slice(Math.min(anchor, selectIndex), Math.max(anchor, selectIndex) + 1);
1949
+ }
1950
+ }
1951
+
1952
+ /**
1953
+ * Get the head and anchor of a contiguous cell selection.
1954
+ *
1955
+ * The head of a contiguous selection is always the active cell.
1956
+ *
1957
+ * If there are no cells selected, `{head: null, anchor: null}` is returned.
1958
+ *
1959
+ * Throws an error if the currently selected cells do not form a contiguous
1960
+ * selection.
1961
+ */
1962
+ }, {
1963
+ key: "getContiguousSelection",
1964
+ value: function getContiguousSelection() {
1965
+ if (this.model.selections.length !== 0 && this.activeCell) {
1966
+ var first = this.findCellIndex(this.model.selections[0]);
1967
+ var last = this.findCellIndex(this.model.selections[this.model.selections.length - 1]);
1968
+ // Check that the active cell is one of the endpoints of the selection.
1969
+ var activeIndex = this.findCellIndex(this.activeCell);
1970
+ if (first !== activeIndex && last !== activeIndex) {
1971
+ throw new Error('Active cell not at endpoint of selection');
1972
+ }
1973
+
1974
+ // Determine the head and anchor of the selection.
1975
+ if (first === activeIndex) {
1976
+ return {
1977
+ head: first,
1978
+ anchor: last
1979
+ };
1980
+ } else {
1981
+ return {
1982
+ head: last,
1983
+ anchor: first
1984
+ };
1985
+ }
1986
+ }
1987
+ return {
1988
+ head: null,
1989
+ anchor: null
1990
+ };
1991
+ }
1992
+ }, {
1993
+ key: "dispose",
1994
+ value: function dispose() {
1995
+ if (!this.disposed) {
1996
+ this.libroService.deleteLibroViewFromCache(this);
1997
+ this.toDispose.dispose();
1998
+ }
1999
+ this.disposed = true;
2000
+ _get(_getPrototypeOf(LibroView.prototype), "dispose", this).call(this);
2001
+ }
2002
+ }, {
2003
+ key: "collapseCell",
2004
+ value: function collapseCell(cell, collspse) {
2005
+ this.collapseService.setHeadingCollapse(cell, collspse);
2006
+ }
2007
+ }, {
2008
+ key: "save",
2009
+ value: function save() {
2010
+ this.saving = true;
2011
+ try {
2012
+ this.model.saveNotebookContent();
2013
+ this.onSaveEmitter.fire(true);
2014
+ this.model.dirty = false;
2015
+ } catch (ex) {
2016
+ this.onSaveEmitter.fire(false);
2017
+ } finally {
2018
+ this.saving = false;
2019
+ }
2020
+ }
2021
+ }]);
2022
+ return LibroView;
2023
+ }(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "model", [_dec3], {
2024
+ configurable: true,
2025
+ enumerable: true,
2026
+ writable: true,
2027
+ initializer: null
2028
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "cellService", [_dec4], {
2029
+ configurable: true,
2030
+ enumerable: true,
2031
+ writable: true,
2032
+ initializer: null
2033
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "libroService", [_dec5], {
2034
+ configurable: true,
2035
+ enumerable: true,
2036
+ writable: true,
2037
+ initializer: null
2038
+ }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "libroSlotManager", [_dec6], {
2039
+ configurable: true,
2040
+ enumerable: true,
2041
+ writable: true,
2042
+ initializer: null
2043
+ }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "contextKey", [_dec7], {
2044
+ configurable: true,
2045
+ enumerable: true,
2046
+ writable: true,
2047
+ initializer: null
2048
+ }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec8], {
2049
+ configurable: true,
2050
+ enumerable: true,
2051
+ writable: true,
2052
+ initializer: null
2053
+ }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "configurationService", [_dec9], {
2054
+ configurable: true,
2055
+ enumerable: true,
2056
+ writable: true,
2057
+ initializer: null
2058
+ }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "collapserVisible", [_dec10], {
2059
+ configurable: true,
2060
+ enumerable: true,
2061
+ writable: true,
2062
+ initializer: function initializer() {
2063
+ return false;
2064
+ }
2065
+ }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "outputsScroll", [_dec11], {
2066
+ configurable: true,
2067
+ enumerable: true,
2068
+ writable: true,
2069
+ initializer: function initializer() {
2070
+ return false;
2071
+ }
2072
+ }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "saving", [_dec12], {
2073
+ configurable: true,
2074
+ enumerable: true,
2075
+ writable: true,
2076
+ initializer: null
2077
+ })), _class2)) || _class) || _class);